public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/syscall-refactor] sh: Remove assembly syscall macros
@ 2020-06-29 21:50 Adhemerval Zanella
  0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2020-06-29 21:50 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=21d385c92d3efc77c7ace059c30dd06b459827fe

commit 21d385c92d3efc77c7ace059c30dd06b459827fe
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Jun 26 23:48:11 2020 -0300

    sh: Remove assembly syscall macros

Diff:
---
 sysdeps/unix/sysv/linux/sh/____longjmp_chk.S |   9 +-
 sysdeps/unix/sysv/linux/sh/clone.S           |   6 +-
 sysdeps/unix/sysv/linux/sh/makecontext.S     |   2 +-
 sysdeps/unix/sysv/linux/sh/sh3/getcontext.S  |   4 +-
 sysdeps/unix/sysv/linux/sh/sh3/setcontext.S  |   4 +-
 sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S |   4 +-
 sysdeps/unix/sysv/linux/sh/sh4/getcontext.S  |   4 +-
 sysdeps/unix/sysv/linux/sh/sh4/setcontext.S  |   4 +-
 sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S |   4 +-
 sysdeps/unix/sysv/linux/sh/syscall.S         |   2 +-
 sysdeps/unix/sysv/linux/sh/sysdep.h          | 141 ++-------------------------
 sysdeps/unix/sysv/linux/sh/vfork.S           |   3 +-
 12 files changed, 33 insertions(+), 154 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S b/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
index 9ac01ebeed..e32f1d6370 100644
--- a/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
+++ b/sysdeps/unix/sysv/linux/sh/____longjmp_chk.S
@@ -90,7 +90,14 @@ longjmp_msg:
 	cfi_adjust_cfa_offset (sizeSS);					\
 	mov	#0, r4;							\
 	mov	r15, r5;						\
-	DO_CALL (sigaltstack, 2);					\
+	mov.l	1f,r3;							\
+	trapa	#0x12;							\
+	SYSCALL_INST_PAD;						\
+	bra 2f;								\
+	nop;								\
+	.align 2;							\
+  1:	.long __NR_sigaltstack;						\
+  2:									\
 	/* Without working sigaltstack we cannot perform the test.  */	\
 	tst	r0, r0;							\
 	bf	.Lok2;							\
diff --git a/sysdeps/unix/sysv/linux/sh/clone.S b/sysdeps/unix/sysv/linux/sh/clone.S
index 9138010368..04f8aef57e 100644
--- a/sysdeps/unix/sysv/linux/sh/clone.S
+++ b/sysdeps/unix/sysv/linux/sh/clone.S
@@ -47,7 +47,7 @@ ENTRY(__clone)
 	mov.l	@r15, r6
 	mov.l	@(8,r15), r7
 	mov.l	@(4,r15), r0
-	mov	#+SYS_ify(clone), r3
+	mov	#+__NR_clone, r3
 	trapa	#0x15
 	mov     r0, r1
 	mov	#-12, r2
@@ -74,14 +74,14 @@ ENTRY(__clone)
 
 	/* we are done, passing the return value through r0  */
 	mov     r0, r4
-	mov	#+SYS_ify(exit), r3
+	mov	#+__NR_exit, r3
 	trapa	#0x15
 	.align	2
 .LG:
 	.long	_GLOBAL_OFFSET_TABLE_
 .L3:
 	.long	PLTJMP(C_SYMBOL_NAME(_exit))
-PSEUDO_END (__clone)
+END (__clone)
 
 libc_hidden_def (__clone)
 weak_alias (__clone, clone)
diff --git a/sysdeps/unix/sysv/linux/sh/makecontext.S b/sysdeps/unix/sysv/linux/sh/makecontext.S
index 8d748490e1..0f305be3bc 100644
--- a/sysdeps/unix/sysv/linux/sh/makecontext.S
+++ b/sysdeps/unix/sysv/linux/sh/makecontext.S
@@ -155,6 +155,6 @@ ENTRY(__makecontext)
 .Lexit:
 	.long	HIDDEN_JUMPTARGET(exit)
 #endif
-PSEUDO_END(__makecontext)
+END(__makecontext)
 
 weak_alias (__makecontext, makecontext)
diff --git a/sysdeps/unix/sysv/linux/sh/sh3/getcontext.S b/sysdeps/unix/sysv/linux/sh/sh3/getcontext.S
index ce80fae6e9..66d37570ac 100644
--- a/sysdeps/unix/sysv/linux/sh/sh3/getcontext.S
+++ b/sysdeps/unix/sysv/linux/sh/sh3/getcontext.S
@@ -65,7 +65,7 @@ ENTRY(__getcontext)
 	add	#oSIGMASK, r6
 	mov	#SIG_BLOCK, r4
 	mov	#0, r5
-	mov	#+SYS_ify(sigprocmask), r3
+	mov	#+__NR_sigprocmask, r3
 	trapa	#0x13
 	mov     r0, r1
 	mov	#-12, r2
@@ -82,6 +82,6 @@ ENTRY(__getcontext)
 	rts
 	 nop
 
-PSEUDO_END(__getcontext)
+END(__getcontext)
 
 weak_alias (__getcontext, getcontext)
diff --git a/sysdeps/unix/sysv/linux/sh/sh3/setcontext.S b/sysdeps/unix/sysv/linux/sh/sh3/setcontext.S
index ea746dd914..d8b201dcd6 100644
--- a/sysdeps/unix/sysv/linux/sh/sh3/setcontext.S
+++ b/sysdeps/unix/sysv/linux/sh/sh3/setcontext.S
@@ -33,7 +33,7 @@ ENTRY(__setcontext)
 	add	#oSIGMASK, r5
 	mov	#SIG_SETMASK, r4
 	mov	#0, r6
-	mov	#+SYS_ify(sigprocmask), r3
+	mov	#+__NR_sigprocmask, r3
 	trapa	#0x13
 	mov     r0, r1
 	mov	#-12, r2
@@ -94,6 +94,6 @@ ENTRY(__setcontext)
 	jmp	@r0
 	 mov.l	@r15+, r0
 
-PSEUDO_END(__setcontext)
+END(__setcontext)
 
 weak_alias (__setcontext, setcontext)
diff --git a/sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S b/sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S
index 2c76196533..8c256b1e4f 100644
--- a/sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/sh/sh3/swapcontext.S
@@ -67,7 +67,7 @@ ENTRY(__swapcontext)
 	mov	r4, r6
 	add	#oSIGMASK, r6
 	mov	#SIG_SETMASK, r4
-	mov	#+SYS_ify(sigprocmask), r3
+	mov	#+__NR_sigprocmask, r3
 	trapa	#0x13
 	mov     r0, r1
 	mov	#-12, r2
@@ -127,6 +127,6 @@ ENTRY(__swapcontext)
 	jmp	@r0
 	 mov.l	@r15+, r0
 
-PSEUDO_END(__swapcontext)
+END(__swapcontext)
 
 weak_alias (__swapcontext, swapcontext)
diff --git a/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S b/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S
index 2545fe7870..11f0ae21cc 100644
--- a/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S
+++ b/sysdeps/unix/sysv/linux/sh/sh4/getcontext.S
@@ -110,7 +110,7 @@ ENTRY(__getcontext)
 	add	#(oSIGMASK/2), r6
 	mov	#SIG_BLOCK, r4
 	mov	#0, r5
-	mov	#+SYS_ify(sigprocmask), r3
+	mov	#+__NR_sigprocmask, r3
 	trapa	#0x13
 	mov     r0, r1
 	mov	#-12, r2
@@ -127,6 +127,6 @@ ENTRY(__getcontext)
 	rts
 	 nop
 
-PSEUDO_END(__getcontext)
+END(__getcontext)
 
 weak_alias (__getcontext, getcontext)
diff --git a/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S b/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S
index dd523a8cdb..5caaca7b2e 100644
--- a/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S
+++ b/sysdeps/unix/sysv/linux/sh/sh4/setcontext.S
@@ -34,7 +34,7 @@ ENTRY(__setcontext)
 	add	#(oSIGMASK/2), r5
 	mov	#SIG_SETMASK, r4
 	mov	#0, r6
-	mov	#+SYS_ify(sigprocmask), r3
+	mov	#+__NR_sigprocmask, r3
 	trapa	#0x13
 	mov     r0, r1
 	mov	#-12, r2
@@ -136,6 +136,6 @@ ENTRY(__setcontext)
 	jmp	@r0
 	 mov.l	@r15+, r0
 
-PSEUDO_END(__setcontext)
+END(__setcontext)
 
 weak_alias (__setcontext, setcontext)
diff --git a/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S b/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S
index 1ff4fd612b..2b45fe4fc0 100644
--- a/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/sh/sh4/swapcontext.S
@@ -112,7 +112,7 @@ ENTRY(__swapcontext)
 	mov	r4, r6
 	add	r1, r6
 	mov	#SIG_SETMASK, r4
-	mov	#+SYS_ify(sigprocmask), r3
+	mov	#+__NR_sigprocmask, r3
 	trapa	#0x13
 	mov     r0, r1
 	mov	#-12, r2
@@ -213,6 +213,6 @@ ENTRY(__swapcontext)
 	jmp	@r0
 	 mov.l	@r15+, r0
 
-PSEUDO_END(__swapcontext)
+END(__swapcontext)
 
 weak_alias (__swapcontext, swapcontext)
diff --git a/sysdeps/unix/sysv/linux/sh/syscall.S b/sysdeps/unix/sysv/linux/sh/syscall.S
index f211966e6c..5f1c98871f 100644
--- a/sysdeps/unix/sysv/linux/sh/syscall.S
+++ b/sysdeps/unix/sysv/linux/sh/syscall.S
@@ -38,6 +38,6 @@ ENTRY (__syscall)
 	rts
 	 nop
 
-PSEUDO_END (__syscall)
+END (__syscall)
 
 weak_alias (__syscall, syscall)
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep.h b/sysdeps/unix/sysv/linux/sh/sysdep.h
index b4c983dbbd..5af02594b8 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep.h
@@ -23,107 +23,17 @@
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/sh/sysdep.h>
-/* For RTLD_PRIVATE_ERRNO.  */
-#include <dl-sysdep.h>
-
-/* For Linux we can use the system call table in the header file
-	/usr/include/asm/unistd.h
-   of the kernel.  But these symbols do not follow the SYS_* syntax
-   so we have to redefine the `SYS_ify' macro here.  */
-#undef SYS_ify
-#define SYS_ify(syscall_name)	(__NR_##syscall_name)
-
 
 #ifdef __ASSEMBLER__
-
-/* Linux uses a negative return value to indicate syscall errors,
-   unlike most Unices, which use the condition codes' carry flag.
-
-   Since version 2.1 the return value of a system call might be
-   negative even if the call succeeded.  E.g., the `lseek' system call
-   might return a large offset.  Therefore we must not anymore test
-   for < 0, but test for a real error by making sure the value in R0
-   is a real error number.  Linus said he will make sure the no syscall
-   returns a value in -1 .. -4095 as a valid result so we can savely
-   test with -4095.  */
-
-#define _IMM1 #-1
-#define _IMM12 #-12
-#undef	PSEUDO
-#define	PSEUDO(name, syscall_name, args) \
- .text; \
- ENTRY (name); \
-    DO_CALL (syscall_name, args); \
-    mov r0,r1; \
-    mov _IMM12,r2; \
-    shad r2,r1; \
-    not r1,r1; \
-    tst r1,r1; \
-    bf .Lpseudo_end; \
-    SYSCALL_ERROR_HANDLER; \
- .Lpseudo_end:
-
-#undef	PSEUDO_END
-#define	PSEUDO_END(name) \
-  END (name)
-
-#undef	PSEUDO_NOERRNO
-#define	PSEUDO_NOERRNO(name, syscall_name, args) \
- .text; \
- ENTRY (name); \
-    DO_CALL (syscall_name, args)
-
-#undef	PSEUDO_END_NOERRNO
-#define	PSEUDO_END_NOERRNO(name) \
-  END (name)
-
-#define ret_NOERRNO ret
-
-#define	PSEUDO_ERRVAL(name, syscall_name, args) \
- .text; \
- ENTRY (name); \
-    DO_CALL (syscall_name, args);
-
-#undef	PSEUDO_END_ERRVAL
-#define	PSEUDO_END_ERRVAL(name) \
-  END (name)
-
-#define ret_ERRVAL ret
-
-#ifndef PIC
-# define SYSCALL_ERROR_HANDLER	\
+# ifndef PIC
+#  define SYSCALL_ERROR_HANDLER	\
 	mov.l 0f,r1; \
 	jmp @r1; \
 	 mov r0,r4; \
 	.align 2; \
      0: .long __syscall_error
-#else
-# if RTLD_PRIVATE_ERRNO
-#  define SYSCALL_ERROR_HANDLER	\
-	neg r0,r1; \
-	mov r12,r2; \
-	cfi_register (r12, r2); \
-	mov.l 0f,r12; \
-	mova 0f,r0; \
-	add r0,r12; \
-	mov.l 1f,r0; \
-	mov.l r1,@(r0,r12); \
-	mov r2,r12; \
-	cfi_restore (r12); \
-	bra .Lpseudo_end; \
-	 mov _IMM1,r0; \
-	.align 2; \
-     0: .long _GLOBAL_OFFSET_TABLE_; \
-     1: .long rtld_errno@GOTOFF
-
-# elif defined _LIBC_REENTRANT
-
-#  if IS_IN (libc)
-#   define SYSCALL_ERROR_ERRNO __libc_errno
 #  else
-#   define SYSCALL_ERROR_ERRNO errno
-#  endif
-#  define SYSCALL_ERROR_HANDLER \
+#   define SYSCALL_ERROR_HANDLER \
 	neg r0,r1; \
 	mov r12,r2; \
 	cfi_register (r12, r2); \
@@ -138,31 +48,11 @@
 	add r4,r0; \
 	mov.l r1,@r0; \
 	bra .Lpseudo_end; \
-	 mov _IMM1,r0; \
+	 mov #-1,r0; \
 	.align 2; \
      0: .long _GLOBAL_OFFSET_TABLE_; \
-     1: .long SYSCALL_ERROR_ERRNO@GOTTPOFF
-# else
-/* Store (-r0) into errno through the GOT.  */
-#  define SYSCALL_ERROR_HANDLER						      \
-	neg r0,r1; \
-	mov r12,r2; \
-	cfi_register (r12, r2); \
-	mov.l 0f,r12; \
-	mova 0f,r0; \
-	add r0,r12; \
-	mov.l 1f,r0; \
-	mov.l @(r0,r12),r0; \
-	mov r2,r12; \
-	cfi_restore (r12); \
-	mov.l r1,@r0; \
-	bra .Lpseudo_end; \
-	 mov _IMM1,r0; \
-	.align 2; \
-     0: .long _GLOBAL_OFFSET_TABLE_; \
-     1: .long errno@GOT
-# endif	/* _LIBC_REENTRANT */
-#endif	/* PIC */
+     1: .long __libc_errno@GOTTPOFF
+# endif	/* PIC */
 
 # ifdef NEED_SYSCALL_INST_PAD
 #  define SYSCALL_INST_PAD \
@@ -171,25 +61,6 @@
 #  define SYSCALL_INST_PAD
 # endif
 
-#define SYSCALL_INST0	trapa #0x10
-#define SYSCALL_INST1	trapa #0x11
-#define SYSCALL_INST2	trapa #0x12
-#define SYSCALL_INST3	trapa #0x13
-#define SYSCALL_INST4	trapa #0x14
-#define SYSCALL_INST5	mov.l @(0,r15),r0; trapa #0x15
-#define SYSCALL_INST6	mov.l @(0,r15),r0; mov.l @(4,r15),r1; trapa #0x16
-
-#undef	DO_CALL
-#define DO_CALL(syscall_name, args)	\
-    mov.l 1f,r3;			\
-    SYSCALL_INST##args;			\
-    SYSCALL_INST_PAD;			\
-    bra 2f;				\
-     nop;				\
-    .align 2;				\
- 1: .long SYS_ify (syscall_name);	\
- 2:
-
 #else /* not __ASSEMBLER__ */
 
 # ifdef NEED_SYSCALL_INST_PAD
diff --git a/sysdeps/unix/sysv/linux/sh/vfork.S b/sysdeps/unix/sysv/linux/sh/vfork.S
index dd28486267..10e64b31de 100644
--- a/sysdeps/unix/sysv/linux/sh/vfork.S
+++ b/sysdeps/unix/sysv/linux/sh/vfork.S
@@ -29,6 +29,7 @@ ENTRY (__libc_vfork)
 
 	mov.w	.L1, r3
 	trapa	#0x10
+	SYSCALL_INST_PAD
 	mov     r0, r1
 
 	mov	#-12, r2
@@ -43,7 +44,7 @@ ENTRY (__libc_vfork)
 .L1:
 	.word	__NR_vfork
 	.align	2
-PSEUDO_END (__libc_vfork)
+END (__libc_vfork)
 
 #if IS_IN (libc)
 weak_alias (__libc_vfork, vfork)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-29 21:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 21:50 [glibc/azanella/syscall-refactor] sh: Remove assembly syscall macros Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).