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