aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/mips/pread.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/sysv/linux/mips/pread.c')
-rw-r--r--sysdeps/unix/sysv/linux/mips/pread.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sysdeps/unix/sysv/linux/mips/pread.c b/sysdeps/unix/sysv/linux/mips/pread.c
index 45305d2ccc..e6cb21ff93 100644
--- a/sysdeps/unix/sysv/linux/mips/pread.c
+++ b/sysdeps/unix/sysv/linux/mips/pread.c
@@ -22,12 +22,19 @@
#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_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
+
#if defined __NR_pread || __ASSUME_PREAD_SYSCALL > 0
# if __ASSUME_PREAD_SYSCALL == 0
@@ -48,6 +55,22 @@ __libc_pread (fd, buf, count, offset)
{
ssize_t result;
+ if (SINGLE_THREAD_P)
+ {
+ /* First try the syscall. */
+ assert (sizeof (offset) == 4);
+ result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
+ __LONG_LONG_PAIR (offset >> 31, offset));
+# if __ASSUME_PREAD_SYSCALL == 0
+ if (result == -1 && errno == ENOSYS)
+ /* No system call available. Use the emulation. */
+ result = __emulate_pread (fd, buf, count, offset);
+# endif
+ return result;
+ }
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
/* First try the syscall. */
assert (sizeof (offset) == 4);
result = INLINE_SYSCALL (pread, 6, fd, CHECK_N (buf, count), count, 0,
@@ -57,6 +80,9 @@ __libc_pread (fd, buf, count, offset)
/* No system call available. Use the emulation. */
result = __emulate_pread (fd, buf, count, offset);
# endif
+
+ LIBC_CANCEL_RESET (oldtype);
+
return result;
}