]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Add support for cancellation handling and handle both __NR_pwrite64 and
authorUlrich Drepper <drepper@redhat.com>
Mon, 27 Jan 2003 19:01:03 +0000 (19:01 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 27 Jan 2003 19:01:03 +0000 (19:01 +0000)
__NR_pwrite.

sysdeps/unix/sysv/linux/mips/pwrite.c
sysdeps/unix/sysv/linux/mips/pwrite64.c

index 44f9d30ebfc8286f822f05ee0085078622f330ac..f25e327877320a21d2597ed044cf12d7b6955283 100644 (file)
 #include <unistd.h>
 #include <endian.h>
 
-#include <sysdep.h>
+#include <sysdep-cancel.h>
 #include <sys/syscall.h>
 #include <bp-checks.h>
 
 #include <kernel-features.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
+
 #if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0
 
 extern ssize_t __syscall_pwrite (int fd, const void *__unbounded buf, size_t count,
@@ -47,16 +54,35 @@ __libc_pwrite (fd, buf, count, offset)
 {
   ssize_t result;
 
+  if (SINGLE_THREAD_P)
+    {
+      /* First try the syscall.  */
+     assert (sizeof (offset) == 4);
+     result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
+                          __LONG_LONG_PAIR (offset >> 31, offset));
+# if __ASSUME_PWRITE_SYSCALL == 0
+     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);
   result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
-                          __LONG_LONG_PAIR (offset >> 31, offset));
+                  __LONG_LONG_PAIR (offset >> 31, offset));
 # if __ASSUME_PWRITE_SYSCALL == 0
   if (result == -1 && errno == ENOSYS)
     /* No system call available.  Use the emulation.  */
     result = __emulate_pwrite (fd, buf, count, offset);
 # endif
 
+  LIBC_CANCEL_RESET (oldtype);
+
   return result;
 }
 
index 4f7299ed478de42bb06c57758fcaa2e7dc0258e2..0accc1d37b4ad6e98b1025d19e9633c475c0bf74 100644 (file)
 #include <unistd.h>
 #include <endian.h>
 
-#include <sysdep.h>
+#include <sysdep-cancel.h>
 #include <sys/syscall.h>
 #include <bp-checks.h>
 
 #include <kernel-features.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
+
 #if defined __NR_pwrite || __ASSUME_PWRITE_SYSCALL > 0
 
 extern ssize_t __syscall_pwrite (int fd, const void *__unbounded buf, size_t count,
@@ -46,6 +53,23 @@ __libc_pwrite64 (fd, buf, count, offset)
 {
   ssize_t result;
 
+  if (SINGLE_THREAD_P)
+    {
+     /* First try the syscall.  */
+     result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
+                             __LONG_LONG_PAIR ((off_t) (offset >> 32),
+                            (off_t) (offset & 0xffffffff)));
+# if __ASSUME_PWRITE_SYSCALL == 0
+     if (result == -1 && errno == ENOSYS)
+     /* No system call available.  Use the emulation.  */
+     result = __emulate_pwrite64 (fd, buf, count, offset);
+# endif
+
+     return result;
+    }
+
+  int oldtype = LIBC_CANCEL_ASYNC ();
+
   /* First try the syscall.  */
   result = INLINE_SYSCALL (pwrite, 6, fd, CHECK_N (buf, count), count, 0,
                           __LONG_LONG_PAIR ((off_t) (offset >> 32),
@@ -56,6 +80,8 @@ __libc_pwrite64 (fd, buf, count, offset)
     result = __emulate_pwrite64 (fd, buf, count, offset);
 # endif
 
+  LIBC_CANCEL_RESET (oldtype);
+
   return result;
 }