This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FreeBSD port (22): the DO_CALL macro argument order


The DO_CALL macro is defined to take 2 arguments for most CPUs: the system
call name and the number of arguments. In some sysdep.h files they come
in this order, in some other sysdep.h files in the reverse order.

This is not a bug, but a major porting hassle: When I was combining
the DO_CALL macro from sysdeps/unix/i386/sysdep.h with the PSEUDO macro
from sysdeps/unix/sysv/linux/i386/sysdep.h, all system calls used syscall
number 0, because e.g. SYS_fork was replaced by SYS_2 which expanded to 0.

The right argument order, as you can see from sysdeps/unix/bsd/i386/vfork.S,
sysdeps/unix/bsd/i386/wait3.S and others, is first the system call name,
second the number of arguments.

Here is a patch to fix this confusion once and for all.


2002-07-06  Bruno Haible  <bruno@clisp.org>

	* sysdeps/unix/sysv/linux/arm/sysdep.h (PSEUDO): Swap DO_CALL
	arguments.
	(DO_CALL): Swap argument order.
	* sysdeps/unix/sysv/linux/hppa/sysdep.h (PSEUDO): Swap DO_CALL
	arguments.
	(DO_CALL): Swap argument order.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (PSEUDO): Swap DO_CALL
	arguments.
	(DO_CALL): Swap argument order.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h (PSEUDO): Swap DO_CALL
	arguments.
	(DO_CALL): Swap argument order.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h (PSEUDO): Swap DO_CALL
	arguments.
	(DO_CALL): Swap argument order.
	* sysdeps/unix/sysv/linux/sh/sysdep.h (PSEUDO): Swap DO_CALL
	arguments.
	(DO_CALL): Swap argument order.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (PSEUDO): Swap DO_CALL
	arguments.
	(DO_CALL): Swap argument order.

diff -r -c3 glibc-20020627.bak/sysdeps/unix/sysv/linux/arm/sysdep.h glibc-20020627/sysdeps/unix/sysv/linux/arm/sysdep.h
--- glibc-20020627.bak/sysdeps/unix/sysv/linux/arm/sysdep.h	Tue Jul 10 23:01:40 2001
+++ glibc-20020627/sysdeps/unix/sysv/linux/arm/sysdep.h	Fri Jul  5 01:17:11 2002
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 93, 95-99, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 93, 95-99, 2000, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
    ARM changes by Philip Blundell, <pjb27@cam.ac.uk>, May 1997.
@@ -51,7 +51,7 @@
   .text;								      \
   .type syscall_error,%function;					      \
   ENTRY (name);								      \
-    DO_CALL (args, syscall_name);					      \
+    DO_CALL (syscall_name, args);					      \
     cmn r0, $4096;
 
 #define PSEUDO_RET							      \
@@ -95,7 +95,7 @@
 */
 
 #undef	DO_CALL
-#define DO_CALL(args, syscall_name)		\
+#define DO_CALL(syscall_name, args)		\
     DOARGS_##args				\
     swi SYS_ify (syscall_name); 		\
     UNDOARGS_##args
diff -r -c3 glibc-20020627.bak/sysdeps/unix/sysv/linux/hppa/sysdep.h glibc-20020627/sysdeps/unix/sysv/linux/hppa/sysdep.h
--- glibc-20020627.bak/sysdeps/unix/sysv/linux/hppa/sysdep.h	Tue Jul 10 23:01:43 2001
+++ glibc-20020627/sysdeps/unix/sysv/linux/hppa/sysdep.h	Fri Jul  5 01:18:01 2002
@@ -1,5 +1,5 @@
 /* Assembler macros for PA-RISC.
-   Copyright (C) 1999, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001-2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper, <drepper@cygnus.com>, August 1999.
    Linux/PA-RISC changes by Philipp Rumpf, <prumpf@tux.org>, March 2000.
@@ -108,7 +108,7 @@
 
 #define	PSEUDO(name, syscall_name, args)				      \
   ENTRY (name)								      \
-  DO_CALL(args, syscall_name)					ASM_LINE_SEP  \
+  DO_CALL(syscall_name, args)					ASM_LINE_SEP  \
   nop
 
 #undef	PSEUDO_END
@@ -145,7 +145,7 @@
  */
 
 #undef	DO_CALL
-#define DO_CALL(args, syscall_name)				\
+#define DO_CALL(syscall_name, args)				\
 	DOARGS_##args						\
 	ble  0x100(%sr2,%r0)			ASM_LINE_SEP	\
 	ldi SYS_ify (syscall_name), %r20	ASM_LINE_SEP	\
diff -r -c3 glibc-20020627.bak/sysdeps/unix/sysv/linux/i386/sysdep.h glibc-20020627/sysdeps/unix/sysv/linux/i386/sysdep.h
--- glibc-20020627.bak/sysdeps/unix/sysv/linux/i386/sysdep.h	Fri Jun 14 21:06:40 2002
+++ glibc-20020627/sysdeps/unix/sysv/linux/i386/sysdep.h	Fri Jul  5 01:18:01 2002
@@ -61,7 +57,7 @@
 #define	PSEUDO(name, syscall_name, args)				      \
   .text;								      \
   ENTRY (name)								      \
-    DO_CALL (args, syscall_name);					      \
+    DO_CALL (syscall_name, args);					      \
     cmpl $-4095, %eax;							      \
     jae SYSCALL_ERROR_LABEL;						      \
   L(pseudo_end):
@@ -193,7 +189,7 @@
    other processors though.  */
 
 #undef	DO_CALL
-#define DO_CALL(args, syscall_name)			      		      \
+#define DO_CALL(syscall_name, args)			      		      \
     PUSHARGS_##args							      \
     DOARGS_##args							      \
     movl $SYS_ify (syscall_name), %eax;					      \
diff -r -c3 glibc-20020627.bak/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h glibc-20020627/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
--- glibc-20020627.bak/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h	Tue Jul 10 23:01:52 2001
+++ glibc-20020627/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h	Fri Jul  5 01:18:02 2002
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2002 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -55,7 +55,7 @@
 #define	PSEUDO(name, syscall_name, args)				      \
   .text;                                                                      \
   ENTRY (name)							              \
-    DO_CALL (args, syscall_name);                                             \
+    DO_CALL (syscall_name, args);                                             \
     lhi  %r4,-4095 ;                                                          \
     clr  %r2,%r4 ;		                                              \
     jnl  SYSCALL_ERROR_LABEL ;                                                \
@@ -110,7 +110,7 @@
    right.
  */
 
-#define DO_CALL(args, syscall)						      \
+#define DO_CALL(syscall, args)						      \
     svc     SYS_ify (syscall)
 
 #define ret                                                                   \
diff -r -c3 glibc-20020627.bak/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h glibc-20020627/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
--- glibc-20020627.bak/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h	Tue Jul 10 23:01:53 2001
+++ glibc-20020627/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h	Fri Jul  5 01:18:02 2002
@@ -1,5 +1,5 @@
 /* Assembler macros for 64 bit S/390.
-   Copyright (C) 2001 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002 Free Software Foundation, Inc.
    Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com).
    This file is part of the GNU C Library.
 
@@ -56,7 +56,7 @@
 #define	PSEUDO(name, syscall_name, args)				      \
   .text;								      \
   ENTRY (name)								      \
-    DO_CALL (args, syscall_name);					      \
+    DO_CALL (syscall_name, args);					      \
     lghi %r4,-4095 ;							      \
     clgr %r2,%r4 ;							      \
     jnl SYSCALL_ERROR_LABEL ;						      \
@@ -104,7 +104,7 @@
    right.
  */
 
-#define DO_CALL(args, syscall)						      \
+#define DO_CALL(syscall, args)						      \
     svc	    SYS_ify (syscall)
 
 #define ret								      \
diff -r -c3 glibc-20020627.bak/sysdeps/unix/sysv/linux/sh/sysdep.h glibc-20020627/sysdeps/unix/sysv/linux/sh/sysdep.h
--- glibc-20020627.bak/sysdeps/unix/sysv/linux/sh/sysdep.h	Tue Jul 10 23:01:53 2001
+++ glibc-20020627/sysdeps/unix/sysv/linux/sh/sysdep.h	Fri Jul  5 01:18:02 2002
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 93, 95-99, 2000 Free Software Foundation,
+/* Copyright (C) 1992, 93, 95-99, 2000, 2002 Free Software Foundation,
    Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>, August 1995.
@@ -52,7 +52,7 @@
 #define	PSEUDO(name, syscall_name, args) \
  .text; \
  ENTRY (name); \
-    DO_CALL (args, syscall_name); \
+    DO_CALL (syscall_name, args); \
     mov r0,r1; \
     mov _IMM12,r2; \
     shad r2,r1; \
@@ -81,7 +81,7 @@
 #define	PSEUDO(name, syscall_name, args) \
  .text; \
  ENTRY (name); \
-    DO_CALL (args, syscall_name); \
+    DO_CALL (syscall_name, args); \
     mov r0,r1; \
     mov _IMM12,r2; \
     shad r2,r1; \
@@ -112,7 +112,7 @@
 #define SYSCALL_INST6	mov.l @(0,r15),r0; mov.l @(4,r15),r1; trapa #0x16
 
 #undef	DO_CALL
-#define DO_CALL(args, syscall_name)	\
+#define DO_CALL(syscall_name, args)	\
     mov.l 1f,r3;			\
     SYSCALL_INST##args;			\
     bra 2f;				\
diff -r -c3 glibc-20020627.bak/sysdeps/unix/sysv/linux/x86_64/sysdep.h glibc-20020627/sysdeps/unix/sysv/linux/x86_64/sysdep.h
--- glibc-20020627.bak/sysdeps/unix/sysv/linux/x86_64/sysdep.h	Wed Sep 19 12:32:01 2001
+++ glibc-20020627/sysdeps/unix/sysv/linux/x86_64/sysdep.h	Fri Jul  5 01:18:02 2002
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002 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
@@ -60,7 +60,7 @@
 #define	PSEUDO(name, syscall_name, args)				      \
   .text;								      \
   ENTRY (name)								      \
-    DO_CALL (args, syscall_name);					      \
+    DO_CALL (syscall_name, args);					      \
     cmpq $-4095, %rax;							      \
     jae SYSCALL_ERROR_LABEL;						      \
   L(pseudo_end):
@@ -134,7 +134,7 @@
      Syscalls of more than 6 arguments are not supported.  */
 
 #undef	DO_CALL
-#define DO_CALL(args, syscall_name)		\
+#define DO_CALL(syscall_name, args)		\
     DOARGS_##args				\
     movq $SYS_ify (syscall_name), %rax;		\
     syscall;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]