d8307d
commit fed33b0fb03d1942a6713286176d42869c0f1580
d8307d
Author: Leandro Pereira <leandro.pereira@microsoft.com>
d8307d
Date:   Wed Oct 2 12:42:28 2019 -0400
d8307d
d8307d
    Add nocancel version of pread64()
d8307d
    
d8307d
    This is in preparation for changes in the dynamic linker so that
d8307d
    pread() is used instead of lseek()+read().
d8307d
    
d8307d
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
d8307d
d8307d
Conflicts:
d8307d
	sysdeps/unix/sysv/linux/Makefile
d8307d
	  (Textual conflict in routines list.)
d8307d
d8307d
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
d8307d
index d9f8a75dbda85ed5..260e6e4081f5fe16 100644
d8307d
--- a/sysdeps/generic/not-cancel.h
d8307d
+++ b/sysdeps/generic/not-cancel.h
d8307d
@@ -41,6 +41,8 @@
d8307d
   (void) __close (fd)
d8307d
 #define __read_nocancel(fd, buf, n) \
d8307d
   __read (fd, buf, n)
d8307d
+#define __pread64_nocancel(fd, buf, count, offset) \
d8307d
+  __pread64 (fd, buf, count, offset)
d8307d
 #define __write_nocancel(fd, buf, n) \
d8307d
   __write (fd, buf, n)
d8307d
 #define __writev_nocancel_nostatus(fd, iov, n) \
d8307d
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
d8307d
index 773aaea0e980bdd6..fb4ccd63ddec7eca 100644
d8307d
--- a/sysdeps/unix/sysv/linux/Makefile
d8307d
+++ b/sysdeps/unix/sysv/linux/Makefile
d8307d
@@ -174,7 +174,8 @@ sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
d8307d
 		   close_nocancel fcntl_nocancel nanosleep_nocancel \
d8307d
 		   open_nocancel open64_nocancel \
d8307d
 		   openat_nocancel openat64_nocancel \
d8307d
-		   pause_nocancel read_nocancel waitpid_nocancel write_nocancel
d8307d
+		   pause_nocancel read_nocancel pread64_nocancel \
d8307d
+		   waitpid_nocancel write_nocancel
d8307d
 
d8307d
 sysdep_headers += bits/fcntl-linux.h
d8307d
 
d8307d
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
d8307d
index 336c13b57dba727a..95759bead1b0b3ca 100644
d8307d
--- a/sysdeps/unix/sysv/linux/Versions
d8307d
+++ b/sysdeps/unix/sysv/linux/Versions
d8307d
@@ -176,6 +176,7 @@ libc {
d8307d
     __syscall_rt_sigqueueinfo;
d8307d
     __open_nocancel;
d8307d
     __read_nocancel;
d8307d
+    __pread64_nocancel;
d8307d
     __close_nocancel;
d8307d
     __sigtimedwait;
d8307d
     # functions used by nscd
d8307d
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
d8307d
index 09de92dee9437d98..e58db475682a8c6a 100644
d8307d
--- a/sysdeps/unix/sysv/linux/not-cancel.h
d8307d
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
d8307d
@@ -43,6 +43,9 @@ __typeof (openat64) __openat64_nocancel;
d8307d
 /* Non cancellable read syscall.  */
d8307d
 __typeof (__read) __read_nocancel;
d8307d
 
d8307d
+/* Non cancellable pread syscall (LFS version).  */
d8307d
+__typeof (__pread64) __pread64_nocancel;
d8307d
+
d8307d
 /* Uncancelable write.  */
d8307d
 __typeof (__write) __write_nocancel;
d8307d
 
d8307d
@@ -84,6 +87,7 @@ hidden_proto (__open64_nocancel)
d8307d
 hidden_proto (__openat_nocancel)
d8307d
 hidden_proto (__openat64_nocancel)
d8307d
 hidden_proto (__read_nocancel)
d8307d
+hidden_proto (__pread64_nocancel)
d8307d
 hidden_proto (__write_nocancel)
d8307d
 hidden_proto (__close_nocancel)
d8307d
 hidden_proto (__waitpid_nocancel)
d8307d
diff --git a/sysdeps/unix/sysv/linux/pread64_nocancel.c b/sysdeps/unix/sysv/linux/pread64_nocancel.c
d8307d
new file mode 100644
d8307d
index 0000000000000000..dab61260e5db43b5
d8307d
--- /dev/null
d8307d
+++ b/sysdeps/unix/sysv/linux/pread64_nocancel.c
d8307d
@@ -0,0 +1,32 @@
d8307d
+/* Linux pread64() syscall implementation -- non-cancellable.
d8307d
+   Copyright (C) 2019 Free Software Foundation, Inc.
d8307d
+   This file is part of the GNU C Library.
d8307d
+
d8307d
+   The GNU C Library is free software; you can redistribute it and/or
d8307d
+   modify it under the terms of the GNU Lesser General Public
d8307d
+   License as published by the Free Software Foundation; either
d8307d
+   version 2.1 of the License, or (at your option) any later version.
d8307d
+
d8307d
+   The GNU C Library is distributed in the hope that it will be useful,
d8307d
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
d8307d
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
d8307d
+   Lesser General Public License for more details.
d8307d
+
d8307d
+   You should have received a copy of the GNU Lesser General Public
d8307d
+   License along with the GNU C Library; if not, see
d8307d
+   <http://www.gnu.org/licenses/>.  */
d8307d
+
d8307d
+#include <unistd.h>
d8307d
+#include <sysdep-cancel.h>
d8307d
+#include <not-cancel.h>
d8307d
+
d8307d
+#ifndef __NR_pread64
d8307d
+# define __NR_pread64 __NR_pread
d8307d
+#endif
d8307d
+
d8307d
+ssize_t
d8307d
+__pread64_nocancel (int fd, void *buf, size_t count, off64_t offset)
d8307d
+{
d8307d
+  return INLINE_SYSCALL_CALL (pread64, fd, buf, count, SYSCALL_LL64_PRW (offset));
d8307d
+}
d8307d
+hidden_def (__pread64_nocancel)