[PATCH] Cleanup PPC32 syscalls.list
Franz Sirl
Franz.Sirl-kernel@lauterbach.com
Tue Nov 5 07:11:00 GMT 2002
Resend with patch attached and 2 missing ChangeLog entries added.
On Tuesday 05 November 2002 04:01, Roland McGrath wrote:
> I put your changes in and removed some other s_* and sys_* stubs too.
> After converting various explicit __syscall_* calls to use INLINE_SYSCALL
> it looks like it's all working fine. You should probably check to make
> sure I didn't make any more typos that weren't caught by make check.
Hehe, remember the PPC32 register passing ABI for long long? :-)
You just broke [f]truncate64, pread[64], pwrite[64]. I would like to leave
these with the s_*+prototype setup which isn't as error prone as trying to
emulate the ABI when using the INLINE_SYSCALL macro. I guess I should add
something like
if (sizeof (arg) > 4) __illegal_INLINE_SYSCALL_usage ();
to INLINE_SYSCALL to prevent future abuses?
The attached patch reverts the problematic parts and also moves the
__NR_pread64 and __NR_pwrite64 handling to sysdep.h, so the __syscall_* stubs
will do the right thing too. These files should probably be splitted between
ppc32 and ppc64 as ppc64 doesn't need compatibility with old kernels. I
talked to the ppc64 people and it seems they are already working on it the
split, so I will leave that move to them.
After talking to Paul Mackerras on the syscall ABI in linux-2.5 I added a
small fix for powerpc32/sysdep.h as well.
Franz.
2002-11-05 Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h,
sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Handle __NR_pread64
and __NR_pwrite64.
* sysdeps/unix/sysv/linux/powerpc/pread.c,
sysdeps/unix/sysv/linux/powerpc/pread64.c,
sysdeps/unix/sysv/linux/powerpc/pwrite.c,
sysdeps/unix/sysv/linux/powerpc/pwrite64.c: Remove __NR_pread64
and __NR_pwrite64.
Revert change to use INLINE_SYSCALL.
* sysdeps/unix/sysv/linux/powerpc/ftruncate64.c,
sysdeps/unix/sysv/linux/powerpc/truncate64.c: Revert change to use
INLINE_SYSCALL.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h (INLINE_SYSCALL):
Update clobber list and add a comment about the syscall ABI.
-------------- next part --------------
Index: sysdeps/unix/sysv/linux/powerpc//ftruncate64.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/ftruncate64.c,v
retrieving revision 1.5
diff -u -p -r1.5 ftruncate64.c
--- sysdeps/unix/sysv/linux/powerpc//ftruncate64.c 5 Nov 2002 03:02:00 -0000 1.5
+++ sysdeps/unix/sysv/linux/powerpc//ftruncate64.c 5 Nov 2002 14:34:26 -0000
@@ -47,7 +47,7 @@ __ftruncate64 (fd, length)
#ifndef __ASSUME_TRUNCATE64_SYSCALL
int saved_errno = errno;
#endif
- int result = INLINE_SYSCALL (ftruncate64, 2, fd, length);
+ int result = __syscall_ftruncate64 (fd, length);
#ifndef __ASSUME_TRUNCATE64_SYSCALL
if (result != -1 || errno != ENOSYS)
Index: sysdeps/unix/sysv/linux/powerpc//pread.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/pread.c,v
retrieving revision 1.5
diff -u -p -r1.5 pread.c
--- sysdeps/unix/sysv/linux/powerpc//pread.c 5 Nov 2002 03:02:02 -0000 1.5
+++ sysdeps/unix/sysv/linux/powerpc//pread.c 5 Nov 2002 14:34:26 -0000
@@ -24,13 +24,6 @@
#include <sys/syscall.h>
#include <bp-checks.h>
-#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
-# ifdef __NR_pread
-# error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
#ifdef __NR_pread
extern ssize_t __syscall_pread (int fd, void *buf, size_t count,
@@ -50,7 +43,7 @@ __libc_pread (fd, buf, count, offset)
ssize_t result;
/* First try the syscall. */
- result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count, offset);
+ result = __syscall_pread (fd, CHECK_N (buf, count), count, (off64_t) offset);
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
result = __emulate_pread (fd, buf, count, offset);
Index: sysdeps/unix/sysv/linux/powerpc//pread64.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/pread64.c,v
retrieving revision 1.6
diff -u -p -r1.6 pread64.c
--- sysdeps/unix/sysv/linux/powerpc//pread64.c 5 Nov 2002 03:02:02 -0000 1.6
+++ sysdeps/unix/sysv/linux/powerpc//pread64.c 5 Nov 2002 14:34:26 -0000
@@ -24,13 +24,6 @@
#include <sys/syscall.h>
#include <bp-checks.h>
-#ifdef __NR_pread64 /* Newer kernels renamed but it's the same. */
-# ifdef __NR_pread
-# error "__NR_pread and __NR_pread64 both defined???"
-# endif
-# define __NR_pread __NR_pread64
-#endif
-
#ifdef __NR_pread
extern ssize_t __syscall_pread (int fd, void *buf, size_t count,
@@ -50,7 +43,7 @@ __libc_pread64 (fd, buf, count, offset)
ssize_t result;
/* First try the syscall. */
- result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count, offset);
+ result = __syscall_pread (fd, CHECK_N (buf, count), count, offset);
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
result = __emulate_pread64 (fd, buf, count, offset);
Index: sysdeps/unix/sysv/linux/powerpc//pwrite.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/pwrite.c,v
retrieving revision 1.6
diff -u -p -r1.6 pwrite.c
--- sysdeps/unix/sysv/linux/powerpc//pwrite.c 5 Nov 2002 03:02:02 -0000 1.6
+++ sysdeps/unix/sysv/linux/powerpc//pwrite.c 5 Nov 2002 14:34:26 -0000
@@ -24,13 +24,6 @@
#include <sys/syscall.h>
#include <bp-checks.h>
-#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
-# ifdef __NR_pwrite
-# error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
#ifdef __NR_pwrite
extern ssize_t __syscall_pwrite (int fd, const void *buf, size_t count,
@@ -50,7 +43,7 @@ __libc_pwrite (fd, buf, count, offset)
ssize_t result;
/* First try the syscall. */
- result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count, offset);
+ result = __syscall_pwrite (fd, CHECK_N (buf, count), count, (off64_t) offset);
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
result = __emulate_pwrite (fd, buf, count, offset);
Index: sysdeps/unix/sysv/linux/powerpc//pwrite64.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/pwrite64.c,v
retrieving revision 1.8
diff -u -p -r1.8 pwrite64.c
--- sysdeps/unix/sysv/linux/powerpc//pwrite64.c 5 Nov 2002 03:02:02 -0000 1.8
+++ sysdeps/unix/sysv/linux/powerpc//pwrite64.c 5 Nov 2002 14:34:26 -0000
@@ -24,13 +24,6 @@
#include <sys/syscall.h>
#include <bp-checks.h>
-#ifdef __NR_pwrite64 /* Newer kernels renamed but it's the same. */
-# ifdef __NR_pwrite
-# error "__NR_pwrite and __NR_pwrite64 both defined???"
-# endif
-# define __NR_pwrite __NR_pwrite64
-#endif
-
#ifdef __NR_pwrite
extern ssize_t __syscall_pwrite (int fd, const void *buf, size_t count,
@@ -50,7 +43,7 @@ __libc_pwrite64 (fd, buf, count, offset)
ssize_t result;
/* First try the syscall. */
- result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count, offset);
+ result = __syscall_pwrite (fd, CHECK_N (buf, count), count, offset);
if (result == -1 && errno == ENOSYS)
/* No system call available. Use the emulation. */
result = __emulate_pwrite64 (fd, buf, count, offset);
Index: sysdeps/unix/sysv/linux/powerpc//truncate64.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/truncate64.c,v
retrieving revision 1.3
diff -u -p -r1.3 truncate64.c
--- sysdeps/unix/sysv/linux/powerpc//truncate64.c 5 Nov 2002 03:02:00 -0000 1.3
+++ sysdeps/unix/sysv/linux/powerpc//truncate64.c 5 Nov 2002 14:34:26 -0000
@@ -48,7 +48,7 @@ truncate64 (path, length)
#ifndef __ASSUME_TRUNCATE64_SYSCALL
int saved_errno = errno;
#endif
- int result = INLINE_SYSCALL (truncate64, 2, CHECK_STRING (path), length);
+ int result = __syscall_truncate64 (CHECK_STRING (path), length);
#ifndef __ASSUME_TRUNCATE64_SYSCALL
if (result != -1 || errno != ENOSYS)
Index: sysdeps/unix/sysv/linux/powerpc//powerpc32/syscalls.list
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list,v
retrieving revision 1.3
diff -u -p -r1.3 syscalls.list
--- sysdeps/unix/sysv/linux/powerpc//powerpc32/syscalls.list 5 Nov 2002 03:01:58 -0000 1.3
+++ sysdeps/unix/sysv/linux/powerpc//powerpc32/syscalls.list 5 Nov 2002 14:34:26 -0000
@@ -9,3 +9,9 @@ rt_sigsuspend - rt_sigsuspend i:pi __sys
rt_sigtimedwait - rt_sigtimedwait i:pppi __syscall_rt_sigtimedwait
oldgetrlimit EXTRA getrlimit i:ip __old_getrlimit getrlimit@GLIBC_2.0
oldsetrlimit EXTRA setrlimit i:ip __old_setrlimit setrlimit@GLIBC_2.0
+
+# System calls with 64bit args
+s_ftruncate64 ftruncate64 ftruncate64 i:iii __syscall_ftruncate64
+s_pread64 pread64 pread i:ibnii __syscall_pread
+s_pwrite64 pwrite64 pwrite i:ibnii __syscall_pwrite
+s_truncate64 truncate64 truncate64 i:sii __syscall_truncate64
Index: sysdeps/unix/sysv/linux/powerpc//powerpc32/sysdep.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h,v
retrieving revision 1.4
diff -u -p -r1.4 sysdep.h
--- sysdeps/unix/sysv/linux/powerpc//powerpc32/sysdep.h 11 Oct 2002 07:20:46 -0000 1.4
+++ sysdeps/unix/sysv/linux/powerpc//powerpc32/sysdep.h 5 Nov 2002 14:34:26 -0000
@@ -21,6 +21,24 @@
#include <sysdeps/unix/powerpc/sysdep.h>
+/* Some systen calls got renamed over time, but retained the same semantics.
+ Handle them here so they can be catched by both C and assembler stubs in
+ glibc. */
+
+#ifdef __NR_pread64
+# ifdef __NR_pread
+# error "__NR_pread and __NR_pread64 both defined???"
+# endif
+# define __NR_pread __NR_pread64
+#endif
+
+#ifdef __NR_pwrite64
+# ifdef __NR_pwrite
+# error "__NR_pwrite and __NR_pwrite64 both defined???"
+# endif
+# define __NR_pwrite __NR_pwrite64
+#endif
+
/* 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
@@ -36,6 +54,11 @@
# include <errno.h>
+/* On powerpc a system call basically clobbers the same registers like a
+ function call, with the exception of LR (which is needed for the
+ "sc; bnslr" sequence) and CR (where only CR0.SO is clobbered to signal
+ an error return status). */
+
# undef INLINE_SYSCALL
# define INLINE_SYSCALL(name, nr, args...) \
({ \
@@ -59,7 +82,7 @@
"=&r" (r3), "=&r" (r4), "=&r" (r5), "=&r" (r6), "=&r" (r7), \
"=&r" (r8), "=&r" (r9), "=&r" (r10), "=&r" (r11), "=&r" (r12) \
: ASM_INPUT_##nr \
- : "cc", "memory"); \
+ : "cr0", "ctr", "memory"); \
err = r0; \
ret = r3; \
if (err & (1 << 28)) \
Index: sysdeps/unix/sysv/linux/powerpc//powerpc64/sysdep.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h,v
retrieving revision 1.2
diff -u -p -r1.2 sysdep.h
--- sysdeps/unix/sysv/linux/powerpc//powerpc64/sysdep.h 29 Sep 2002 11:31:22 -0000 1.2
+++ sysdeps/unix/sysv/linux/powerpc//powerpc64/sysdep.h 5 Nov 2002 14:34:26 -0000
@@ -29,6 +29,24 @@
#include <errno.h>
#endif
+/* Some systen calls got renamed over time, but retained the same semantics.
+ Handle them here so they can be catched by both C and assembler stubs in
+ glibc. */
+
+#ifdef __NR_pread64
+# ifdef __NR_pread
+# error "__NR_pread and __NR_pread64 both defined???"
+# endif
+# define __NR_pread __NR_pread64
+#endif
+
+#ifdef __NR_pwrite64
+# ifdef __NR_pwrite
+# error "__NR_pwrite and __NR_pwrite64 both defined???"
+# endif
+# define __NR_pwrite __NR_pwrite64
+#endif
+
/* 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
More information about the Libc-alpha
mailing list