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]

[patch] fix mips linux n32/n64 pread/pwrite


For mips linux n32 and n64 p{read,write}{,64} syscalls, you don't have
to do the horrible dummy-pad-word + split-64-bit-value game that you
do on o32 (or on lots of non-mips 32-bit ABIs).

You can just pass the args "as one would expect."

The existing code did avoided the split-64-bit-value part, for
n32/n64, but left the dummy pad word in.  (the result was
entertaining: pread/pwrite always occurred to offset 0!  yay!)

Also, the code was incorrectly asserting that sizeof(off_t) == 4.
(For n64, it is 8.)

The problems were noticed because elf/check-textrel.c failed badly.

After fixing (in glibc sources as of 2003-08-16 00:00 UTC), that test
worked fine as did a couple of other throwaway tests i whipped up.



chris
--
Chris Demetriou                                            Broadcom Corporation
                Principal Design Engineer, Broadband Processors
  Any opinions expressed in this message are mine, not necessarily Broadcom's.
--
2003-09-10  Chris Demetriou  <cgd@broadcom.com>

        * sysdeps/unix/sysv/linux/mips/pread.c (__syscall_pread): Fix
        prototype for N32 and N64.
        (__libc_pread): Fix syscall invocation.  Only assert off_t
        size is 4 for N32 and O32.
        * sysdeps/unix/sysv/linux/mips/pwrite.c (__syscall_write): Fix
        prototype for N32 and N64.
        (__libc_pwrite): Fix syscall invocation.  Only assert off_t
        size is 4 for N32 and O32.
        * sysdeps/unix/sysv/linux/mips/pread64.c (__syscall_pread64): Fix
        prototype for N32 and N64.
        (__libc_pread64): Fix syscall invocation.
        * sysdeps/unix/sysv/linux/mips/pwrite64.c (__syscall_write64): Fix
        prototype for N32 and N64.
        (__libc_pwrite64): Fix syscall invocation.

Index: sysdeps/unix/sysv/linux/mips/pread.c
--- sysdeps/unix/sysv/linux/mips/pread.c	Fri Aug 15 19:35:02 2003
+++ sysdeps/unix/sysv/linux/mips/pread.c	Mon Sep  1 20:53:24 2003
@@ -42,11 +42,10 @@
 				off_t offset) internal_function;
 # endif
 extern ssize_t __syscall_pread (int fd, void *__unbounded buf, size_t count,
-				int dummy,
-#if defined _ABI64 && _MIPS_SIM == _ABI64
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
 				off_t offset
 #else
-				off_t offset_hi, off_t offset_lo
+				int dummy, off_t offset_hi, off_t offset_lo
 #endif
 				);
 
@@ -61,32 +60,33 @@
 {
   ssize_t result;
 
+#if (defined _ABI64 && _MIPS_SIM != _ABI64)
+  assert (sizeof (offset) == 4);
+#endif
+
   if (SINGLE_THREAD_P)
     {
-     /* First try the syscall.  */
-     assert (sizeof (offset) == 4);
-#if defined _ABI64 && _MIPS_SIM == _ABI64
-     result = INLINE_SYSCALL (pread, 5, fd, CHECK_N (buf, count), count, 0,
-			      offset);
+      /* First try the syscall.  */
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
+      result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count,
+			       offset);
 #else
-     result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
-			      __LONG_LONG_PAIR (offset >> 31, offset));
+      result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
+			       __LONG_LONG_PAIR (offset >> 31, offset));
 #endif
 # if __ASSUME_PREAD_SYSCALL == 0
-     if (result == -1 && errno == ENOSYS)
-     /* No system call available.  Use the emulation.  */
-     result = __emulate_pread (fd, buf, count, offset);
+      if (result == -1 && errno == ENOSYS)
+        /* No system call available.  Use the emulation.  */
+        result = __emulate_pread (fd, buf, count, offset);
 # endif
-     return result;
+      return result;
     }
 
   int oldtype = LIBC_CANCEL_ASYNC ();
 
   /* First try the syscall.  */
-  assert (sizeof (offset) == 4);
-#if defined _ABI64 && _MIPS_SIM == _ABI64
-  result = INLINE_SYSCALL (pread, 5, fd, CHECK_N (buf, count), count, 0,
-			   offset);
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
+  result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count, offset);
 #else
   result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
 			   __LONG_LONG_PAIR (offset >> 31, offset));
Index: sysdeps/unix/sysv/linux/mips/pread64.c
--- sysdeps/unix/sysv/linux/mips/pread64.c	Fri Aug 15 19:35:02 2003
+++ sysdeps/unix/sysv/linux/mips/pread64.c	Sat Aug 30 20:43:12 2003
@@ -42,11 +42,10 @@
 # endif
 
 extern ssize_t __syscall_pread (int fd, void *__unbounded buf, size_t count,
-				int dummy,
-#if defined _ABI64 && _MIPS_SIM == _ABI64
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
 				off_t offset
 #else
-				off_t offset_hi, off_t offset_lo
+				int dummy, off_t offset_hi, off_t offset_lo
 #endif
 				);
 
@@ -65,8 +64,8 @@
   if (SINGLE_THREAD_P)
     {
      /* First try the syscall.  */
-#if defined _ABI64 && _MIPS_SIM == _ABI64
-      result = INLINE_SYSCALL (pread, 5, fd, CHECK_N (buf, count), count, 0,
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
+      result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count,
 			       offset);
 #else
      result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
@@ -84,9 +83,8 @@
   int oldtype = LIBC_CANCEL_ASYNC ();
 
   /* First try the syscall.  */
-#if defined _ABI64 && _MIPS_SIM == _ABI64
-  result = INLINE_SYSCALL (pread, 5, fd, CHECK_N (buf, count), count, 0,
-			   offset);
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
+  result = INLINE_SYSCALL (pread, 4, fd, CHECK_N (buf, count), count, offset);
 #else
   result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
 			   __LONG_LONG_PAIR ((off_t) (offset >> 32),
Index: sysdeps/unix/sysv/linux/mips/pwrite.c
--- sysdeps/unix/sysv/linux/mips/pwrite.c	Fri Aug 15 19:35:02 2003
+++ sysdeps/unix/sysv/linux/mips/pwrite.c	Mon Sep  1 20:53:24 2003
@@ -38,11 +38,10 @@
 #if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0
 
 extern ssize_t __syscall_pwrite (int fd, const void *__unbounded buf, size_t count,
-				 int dummy,
-#if defined _ABI64 && _MIPS_SIM == _ABI64
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
 				 off_t offset
 #else
-				 off_t offset_hi, off_t offset_lo
+				 int dummy, off_t offset_hi, off_t offset_lo
 #endif
 				 );
 
@@ -60,33 +59,33 @@
 {
   ssize_t result;
 
+#if (defined _ABI64 && _MIPS_SIM != _ABI64)
+  assert (sizeof (offset) == 4);
+#endif
+
   if (SINGLE_THREAD_P)
     {
       /* First try the syscall.  */
-     assert (sizeof (offset) == 4);
-#if defined _ABI64 && _MIPS_SIM == _ABI64
-     result = INLINE_SYSCALL (pwrite, 5, fd, CHECK_N (buf, count), count, 0,
-			      offset);
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
+      result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count,
+			       offset);
 #else
-     result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
-			      __LONG_LONG_PAIR (offset >> 31, offset));
+      result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
+			       __LONG_LONG_PAIR (offset >> 31, offset));
 #endif
 # if __ASSUME_PWRITE_SYSCALL == 0
-     if (result == -1 && errno == ENOSYS)
-       /* No system call available.  Use the emulation.  */
-       result = __emulate_pwrite (fd, buf, count, offset);
+      if (result == -1 && errno == ENOSYS)
+        /* No system call available.  Use the emulation.  */
+        result = __emulate_pwrite (fd, buf, count, offset);
 # endif
-
       return result;
     }
 
   int oldtype = LIBC_CANCEL_ASYNC ();
 
   /* First try the syscall.  */
-  assert (sizeof (offset) == 4);
-#if defined _ABI64 && _MIPS_SIM == _ABI64
-  result = INLINE_SYSCALL (pwrite, 5, fd, CHECK_N (buf, count), count, 0,
-			   offset);
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
+  result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count, offset);
 #else
   result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
 			   __LONG_LONG_PAIR (offset >> 31, offset));
Index: sysdeps/unix/sysv/linux/mips/pwrite64.c
--- sysdeps/unix/sysv/linux/mips/pwrite64.c	Fri Aug 15 19:35:02 2003
+++ sysdeps/unix/sysv/linux/mips/pwrite64.c	Sat Aug 30 20:43:12 2003
@@ -37,11 +37,10 @@
 #if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0
 
 extern ssize_t __syscall_pwrite (int fd, const void *__unbounded buf, size_t count,
-				 int dummy,
-#if defined _ABI64 && _MIPS_SIM == _ABI64
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
 				 off_t offset
 #else
-				 off_t offset_hi, off_t offset_lo
+				 int dummy, off_t offset_hi, off_t offset_lo
 #endif
 				 );
 
@@ -62,8 +61,8 @@
   if (SINGLE_THREAD_P)
     {
      /* First try the syscall.  */
-#if defined _ABI64 && _MIPS_SIM == _ABI64
-      result = INLINE_SYSCALL (pwrite, 5, fd, CHECK_N (buf, count), count, 0,
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
+      result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count,
 			       offset);
 #else
      result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
@@ -82,9 +81,8 @@
   int oldtype = LIBC_CANCEL_ASYNC ();
 
   /* First try the syscall.  */
-#if defined _ABI64 && _MIPS_SIM == _ABI64
-  result = INLINE_SYSCALL (pwrite, 5, fd, CHECK_N (buf, count), count, 0,
-			   offset);
+#if (defined _ABIN32 && _MIPS_SIM == _ABIN32) || (defined _ABI64 && _MIPS_SIM == _ABI64)
+  result = INLINE_SYSCALL (pwrite, 4, fd, CHECK_N (buf, count), count, offset);
 #else
   result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
 			   __LONG_LONG_PAIR ((off_t) (offset >> 32),


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