public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/syscall-refactor] m68k: 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=afe9f59d71086abe9bc3a32960569930a19a2d10

commit afe9f59d71086abe9bc3a32960569930a19a2d10
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sat Jun 27 00:38:16 2020 -0300

    m68k: Remove assembly syscall macros

Diff:
---
 sysdeps/m68k/sysdep.h                              |  10 --
 sysdeps/unix/sysv/linux/m68k/clone.S               |   8 +-
 .../unix/sysv/linux/m68k/coldfire/atomic-machine.h |   2 +-
 sysdeps/unix/sysv/linux/m68k/m680x0/getcontext.S   |   4 +-
 sysdeps/unix/sysv/linux/m68k/m680x0/setcontext.S   |   4 +-
 sysdeps/unix/sysv/linux/m68k/m680x0/swapcontext.S  |   4 +-
 sysdeps/unix/sysv/linux/m68k/mremap.S              |  29 ----
 sysdeps/unix/sysv/linux/m68k/syscall.S             |  38 ++++-
 sysdeps/unix/sysv/linux/m68k/sysdep.h              | 165 ++-------------------
 sysdeps/unix/sysv/linux/m68k/vfork.S               |   5 +-
 10 files changed, 63 insertions(+), 206 deletions(-)

diff --git a/sysdeps/m68k/sysdep.h b/sysdeps/m68k/sysdep.h
index 9a1c4b7fcf..e6e5754afc 100644
--- a/sysdeps/m68k/sysdep.h
+++ b/sysdeps/m68k/sysdep.h
@@ -54,16 +54,6 @@
 #  define CALL_MCOUNT		/* Do nothing.  */
 # endif
 
-# define PSEUDO(name, syscall_name, args)				      \
-  .globl __syscall_error;						      \
-  ENTRY (name)								      \
-    DO_CALL (syscall_name, args);					      \
-    jcc JUMPTARGET(__syscall_error)
-
-# undef PSEUDO_END
-# define PSEUDO_END(name)						      \
-  END (name)
-
 # undef JUMPTARGET
 # ifdef PIC
 #  define JUMPTARGET(name)	name##@PLTPC
diff --git a/sysdeps/unix/sysv/linux/m68k/clone.S b/sysdeps/unix/sysv/linux/m68k/clone.S
index 81d40f267f..24b0fd7d76 100644
--- a/sysdeps/unix/sysv/linux/m68k/clone.S
+++ b/sysdeps/unix/sysv/linux/m68k/clone.S
@@ -70,7 +70,7 @@ ENTRY (__clone)
 	exg	%d2, %a1		/* save %d2 and get stack pointer */
 	cfi_register (%d2, %a1)
 #endif
-	movel	#SYS_ify (clone), %d0
+	movel	#__NR_clone, %d0
 
 	/* End FDE now, because in the child the unwind info will be
 	   wrong.  */
@@ -98,12 +98,14 @@ ENTRY (__clone)
 	subl	%fp, %fp	/* terminate the stack frame */
 	jsr	(%a0)
 	movel	%d0, %d1
-	movel	#SYS_ify (exit), %d0
+	movel	#__NR_exit, %d0
 	trap	#0
 	cfi_endproc
 
 	cfi_startproc
-PSEUDO_END (__clone)
+
+	SYSCALL_ERROR_HANDLER
+END (__clone)
 
 libc_hidden_def (__clone)
 weak_alias (__clone, clone)
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
index 045a284db4..c7576631b0 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
@@ -49,7 +49,7 @@ typedef uintmax_t uatomic_max_t;
     __typeof (mem) _mem = mem;						\
     __typeof (oldval) _oldval = oldval;					\
     __typeof (newval) _newval = newval;					\
-    register uint32_t _d0 asm ("d0") = SYS_ify (atomic_cmpxchg_32);	\
+    register uint32_t _d0 asm ("d0") = __NR_atomic_cmpxchg_32;		\
     register uint32_t *_a0 asm ("a0") = (uint32_t *) _mem;		\
     register uint32_t _d2 asm ("d2") = (uint32_t) _oldval;		\
     register uint32_t _d1 asm ("d1") = (uint32_t) _newval;		\
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/getcontext.S b/sysdeps/unix/sysv/linux/m68k/m680x0/getcontext.S
index 5bcf959c9a..4d2864870d 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/getcontext.S
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/getcontext.S
@@ -58,6 +58,8 @@ ENTRY(__getcontext)
 0:	/* All done, return 0 for success.  */
 	clr.l	%d0
 	rts
-PSEUDO_END(__getcontext)
+
+	SYSCALL_ERROR_HANDLER
+END(__getcontext)
 
 weak_alias (__getcontext, getcontext)
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/setcontext.S b/sysdeps/unix/sysv/linux/m68k/m680x0/setcontext.S
index e1bf295b9f..30781584b4 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/setcontext.S
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/setcontext.S
@@ -89,6 +89,8 @@ ENTRY(__setcontext)
 	jmp	(%a1)
 
 	cfi_offset (%pc, -4)
-PSEUDO_END(__setcontext)
+
+	SYSCALL_ERROR_HANDLER
+END(__setcontext)
 
 weak_alias (__setcontext, setcontext)
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/swapcontext.S b/sysdeps/unix/sysv/linux/m68k/m680x0/swapcontext.S
index 7f6868d2e7..b2a79f6ba8 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/swapcontext.S
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/swapcontext.S
@@ -103,6 +103,8 @@ ENTRY(__swapcontext)
 	jmp	(%a0)
 
 	cfi_offset (%pc, -4)
-PSEUDO_END(__swapcontext)
+
+	SYSCALL_ERROR_HANDLER
+END(__swapcontext)
 
 weak_alias (__swapcontext, swapcontext)
diff --git a/sysdeps/unix/sysv/linux/m68k/mremap.S b/sysdeps/unix/sysv/linux/m68k/mremap.S
deleted file mode 100644
index f7e7c36a2f..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/mremap.S
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright (C) 1996-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-
-/* The mremap system call is special because it needs to return
-   its value in register %a0.  */
-
-	.text
-PSEUDO (__mremap, mremap, 5)
-	move.l %d0, %a0
-	rts
-PSEUDO_END (__mremap)
-libc_hidden_def (__mremap)
-weak_alias (__mremap, mremap)
diff --git a/sysdeps/unix/sysv/linux/m68k/syscall.S b/sysdeps/unix/sysv/linux/m68k/syscall.S
index 79d8520b1c..4fc429c8b4 100644
--- a/sysdeps/unix/sysv/linux/m68k/syscall.S
+++ b/sysdeps/unix/sysv/linux/m68k/syscall.S
@@ -22,11 +22,41 @@
 
 	.text
 ENTRY (syscall)
-	move.l 4(%sp), %d0	/* Load syscall number.  */
-	_DOARGS_6 (28)		/* Frob arguments.  */
+	move.l	4(%sp), %d0	/* Load syscall number.  */
+	move.l	%d5, -(%sp)
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (%d5, 0)
+	move.l	28 (%sp), %d5
+	move.l	%d4, -(%sp)
+	cfi_adjust_cfa_offset (4)
+	cfi_rel_offset (%d4, 0)
+	move.l	28 (%sp), %d4
+	move.l	%d3, %a1
+	cfi_register (%d3, %a1)
+	move.l	24(%sp), %d3
+	move.l %d2, %a0
+	cfi_register (%d2, %a0)
+	move.l	20(%sp), %d2
+	move.l	16(%sp), %d1
+	move.l	%a0, -(%sp)
+	cfi_adjust_cfa_offset (4)
+	move.l	40(%sp), %a0
 	trap &0			/* Do the system call.  */
-	UNDOARGS_6		/* Unfrob arguments.  */
+	move.l	(%sp)+, %a0
+	cfi_adjust_cfa_offset (-4)
+	move.l	%a0, %d2
+	cfi_restore (%d2)
+	move.l %a1, %d3
+	cfi_restore (%d3)
+	move.l (%sp)+, %d4
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (%d4)
+	move.l (%sp)+, %d5
+	cfi_adjust_cfa_offset (-4)
+	cfi_restore (%d5)
 	cmp.l &-4095, %d0	/* Check %d0 for error.  */
 	jcc SYSCALL_ERROR_LABEL	/* Jump to error handler if negative.  */
 	rts			/* Return to caller.  */
-PSEUDO_END (syscall)
+
+	SYSCALL_ERROR_HANDLER
+END (syscall)
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep.h b/sysdeps/unix/sysv/linux/m68k/sysdep.h
index b6cd61cc16..d9d860cb2b 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep.h
@@ -19,94 +19,17 @@
 
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 
-/* Defines 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 %d0 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.  */
-
 /* We don't want the label for the error handler to be visible in the symbol
    table when we define it here.  */
-#undef SYSCALL_ERROR_LABEL
-#ifdef PIC
-#define SYSCALL_ERROR_LABEL .Lsyscall_error
-#else
-#define SYSCALL_ERROR_LABEL __syscall_error
-#endif
-
-#undef PSEUDO
-#define	PSEUDO(name, syscall_name, args)				      \
-  .text;								      \
-  ENTRY (name)								      \
-    DO_CALL (syscall_name, args);					      \
-    cmp.l &-4095, %d0;							      \
-    jcc SYSCALL_ERROR_LABEL
-
-#undef PSEUDO_END
-#define PSEUDO_END(name)						      \
-  SYSCALL_ERROR_HANDLER;						      \
-  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 rts
+# ifdef PIC
+#  define SYSCALL_ERROR_LABEL .Lsyscall_error
+# else
+#  define SYSCALL_ERROR_LABEL __syscall_error
+# endif
 
-/* The function has to return the error code.  */
-#undef	PSEUDO_ERRVAL
-#define	PSEUDO_ERRVAL(name, syscall_name, args) \
-  .text;								      \
-  ENTRY (name)								      \
-    DO_CALL (syscall_name, args);					      \
-    negl %d0
-
-#undef	PSEUDO_END_ERRVAL
-#define	PSEUDO_END_ERRVAL(name) \
-  END (name)
-
-#define ret_ERRVAL rts
-
-#ifdef PIC
-# if RTLD_PRIVATE_ERRNO
-#  define SYSCALL_ERROR_HANDLER						      \
-SYSCALL_ERROR_LABEL:							      \
-    PCREL_OP (lea, rtld_errno, %a0, %a0);				      \
-    neg.l %d0;								      \
-    move.l %d0, (%a0);							      \
-    move.l &-1, %d0;							      \
-    /* Copy return value to %a0 for syscalls that are declared to return      \
-       a pointer (e.g., mmap).  */					      \
-    move.l %d0, %a0;							      \
-    rts;
-# elif defined _LIBC_REENTRANT
-#  if IS_IN (libc)
-#   define SYSCALL_ERROR_ERRNO __libc_errno
-#  else
-#   define SYSCALL_ERROR_ERRNO errno
-#  endif
+# ifdef PIC
 #  define SYSCALL_ERROR_HANDLER						      \
 SYSCALL_ERROR_LABEL:							      \
     neg.l %d0;								      \
@@ -114,7 +37,7 @@ SYSCALL_ERROR_LABEL:							      \
     cfi_adjust_cfa_offset (4);						      \
     jbsr __m68k_read_tp@PLTPC;						      \
     SYSCALL_ERROR_LOAD_GOT (%a1);					      \
-    add.l (SYSCALL_ERROR_ERRNO@TLSIE, %a1), %a0;			      \
+    add.l (__libc_errno@TLSIE, %a1), %a0;				      \
     move.l (%sp)+, (%a0);						      \
     cfi_adjust_cfa_offset (-4);						      \
     move.l &-1, %d0;							      \
@@ -122,22 +45,9 @@ SYSCALL_ERROR_LABEL:							      \
        a pointer (e.g., mmap).  */					      \
     move.l %d0, %a0;							      \
     rts;
-# else /* !_LIBC_REENTRANT */
-/* Store (- %d0) into errno through the GOT.  */
-#  define SYSCALL_ERROR_HANDLER						      \
-SYSCALL_ERROR_LABEL:							      \
-    move.l (errno@GOTPC, %pc), %a0;					      \
-    neg.l %d0;								      \
-    move.l %d0, (%a0);							      \
-    move.l &-1, %d0;							      \
-    /* Copy return value to %a0 for syscalls that are declared to return      \
-       a pointer (e.g., mmap).  */					      \
-    move.l %d0, %a0;							      \
-    rts;
-# endif /* _LIBC_REENTRANT */
-#else
-# define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
-#endif /* PIC */
+# else
+#  define SYSCALL_ERROR_HANDLER	/* Nothing here; code in sysdep.S is used.  */
+# endif /* PIC */
 
 /* Linux takes system call arguments in registers:
 
@@ -166,60 +76,7 @@ SYSCALL_ERROR_LABEL:							      \
    speed is more important, we don't use movem.  Since %a0 and %a1 are
    scratch registers, we can use them for saving as well.  */
 
-#define DO_CALL(syscall_name, args)			      		      \
-    move.l &SYS_ify(syscall_name), %d0;					      \
-    DOARGS_##args							      \
-    trap &0;								      \
-    UNDOARGS_##args
-
-#define	DOARGS_0	/* No arguments to frob.  */
-#define	UNDOARGS_0	/* No arguments to unfrob.  */
-#define	_DOARGS_0(n)	/* No arguments to frob.  */
-
-#define	DOARGS_1	_DOARGS_1 (4)
-#define	_DOARGS_1(n)	move.l n(%sp), %d1; _DOARGS_0 (n)
-#define	UNDOARGS_1	UNDOARGS_0
-
-#define	DOARGS_2	_DOARGS_2 (8)
-#define	_DOARGS_2(n)	move.l %d2, %a0; cfi_register (%d2, %a0);	      \
-			move.l n(%sp), %d2; _DOARGS_1 (n-4)
-#define	UNDOARGS_2	UNDOARGS_1; move.l %a0, %d2; cfi_restore (%d2)
-
-#define DOARGS_3	_DOARGS_3 (12)
-#define _DOARGS_3(n)	move.l %d3, %a1; cfi_register (%d3, %a1);	      \
-			move.l n(%sp), %d3; _DOARGS_2 (n-4)
-#define UNDOARGS_3	UNDOARGS_2; move.l %a1, %d3; cfi_restore (%d3)
-
-#define DOARGS_4	_DOARGS_4 (16)
-#define _DOARGS_4(n)	move.l %d4, -(%sp);				      \
-			cfi_adjust_cfa_offset (4); cfi_rel_offset (%d4, 0);   \
-			move.l n+4(%sp), %d4; _DOARGS_3 (n)
-#define UNDOARGS_4	UNDOARGS_3; move.l (%sp)+, %d4;			      \
-			cfi_adjust_cfa_offset (-4); cfi_restore (%d4)
-
-#define DOARGS_5	_DOARGS_5 (20)
-#define _DOARGS_5(n)	move.l %d5, -(%sp); 				      \
-			cfi_adjust_cfa_offset (4); cfi_rel_offset (%d5, 0);   \
-			move.l n+4(%sp), %d5; _DOARGS_4 (n)
-#define UNDOARGS_5	UNDOARGS_4; move.l (%sp)+, %d5;			      \
-			cfi_adjust_cfa_offset (-4); cfi_restore (%d5)
-
-#define DOARGS_6	_DOARGS_6 (24)
-#define _DOARGS_6(n)	_DOARGS_5 (n-4); move.l %a0, -(%sp);		      \
-			cfi_adjust_cfa_offset (4);			      \
-			move.l n+12(%sp), %a0;
-#define UNDOARGS_6	move.l (%sp)+, %a0; cfi_adjust_cfa_offset (-4);	      \
-			UNDOARGS_5
-
-
-#define	ret	rts
-#if 0 /* Not used by Linux */
-#define	r0	%d0
-#define	r1	%d1
-#define	MOVE(x,y)	movel x , y
-#endif
-
-#else /* not __ASSEMBLER__ */
+# else /* not __ASSEMBLER__ */
 
 static inline long int
 __internal_syscall0 (long int name)
diff --git a/sysdeps/unix/sysv/linux/m68k/vfork.S b/sysdeps/unix/sysv/linux/m68k/vfork.S
index 912447eef9..cf80ef65aa 100644
--- a/sysdeps/unix/sysv/linux/m68k/vfork.S
+++ b/sysdeps/unix/sysv/linux/m68k/vfork.S
@@ -34,7 +34,7 @@ ENTRY (__vfork)
 	cfi_register (%pc, %a0)
 
 	/* Stuff the syscall number in D0 and trap into the kernel.  */
-	movel	#SYS_ify (vfork), %d0
+	movel	#__NR_vfork, %d0
 	trap	#0
 
 	tstl	%d0
@@ -53,7 +53,8 @@ ENTRY (__vfork)
 	jbra	SYSCALL_ERROR_LABEL
 #endif
 
-PSEUDO_END (__vfork)
+	SYSCALL_ERROR_HANDLER
+END (__vfork)
 libc_hidden_def (__vfork)
 
 weak_alias (__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] m68k: 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).