This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 1/2] Add nocancel version of pread64()
- From: Leandro Pereira <Leandro dot Pereira at microsoft dot com>
- To: "libc-alpha at sourceware dot org" <libc-alpha at sourceware dot org>
- Date: Mon, 5 Aug 2019 21:54:26 +0000
- Subject: [PATCH 1/2] Add nocancel version of pread64()
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N0WPeRdd5EVx3dWk1MqVlP/Jl+ALvaqTOSyCuQUfkmE=; b=HprfTnD4UqWCGKQLaM50N+CQ/dPL7HW4sqciVxCWbViYAJzFudNAmzynyKcjikjnTMgqXsQ6GQNqPXRdFs/wkbSb0ZcFVxcXPikZJZofq0yZu9C6P5mF5B9U2wGXrlCJZw8RupNKui5iGgMukPVTmb+iZMcad+BRJLn6L6cZRZl7e0+yugMh4tLgiEKBh/CHQnhSz5CBrWCQXCoYvX9j8nf21oWJLgScXwcvvP3Jj7MzCeeybpNztemL+4H3y7iahkeoAnBslZY43dtRwrP7gfTAhGr0CTM5YmO2J2et6GJJxJMjSZocegcfxn6rJIHe9VKB5WGUBMS3K43B9BQPoA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jYEvcZ+JiSCV2SfVKtstrvZ36ia2UOr9gY7Ko0s+qBt9lyvsvdAq8ej49tPXqPb3pzbPC/OS++N8y/+/V4GnjNFCu01f2xgDlUN9TL9MuOqUD0hJSukpp0BVle3fhyu8wDiI+Ea341iu6FVW7pGoOJzlcpxpV7rGCbtNgc6hvUqFBC5lXl88I4CIDBcW3l39MtNjyFjgylYnFBsg7b0+jFjnKqnqFW5F8dhyEoyHI5lwh7z9fY8kJLUyZkT9an8fKZIt+klZS9z13cz2ihnyub1TCJASnwTlqPbrX62qY9fG/VQi4afafh4xaKJ2dFJOebG6Vlfv2n6K7I8OnwSZSw==
This is in preparation for changes in the dynamic linker so that pread() is used instead of lseek()+read().
2019-08-05 Leandro Pereira <leandro.pereira@microsoft.com>
* sysdeps/generic/not-cancel.h: New macro.
* sysdeps/unix/sysv/linux/not-cancel.h: New macro.
* sysdeps/unix/sysv/linux/pread64_nocancel.c: Implement nocancel
version of pread64.
* sysdeps/unix/sysv/linux/Versions (GLIBC_PRIVATE): Add
__pread64_nocancel.
* sysdeps/unix/sysv/linux/Makefile: Reference pread64_nocancel.c.
---
sysdeps/generic/not-cancel.h | 2 ++
sysdeps/unix/sysv/linux/Makefile | 4 +--
sysdeps/unix/sysv/linux/Versions | 1 +
sysdeps/unix/sysv/linux/not-cancel.h | 4 +++
sysdeps/unix/sysv/linux/pread64_nocancel.c | 32 ++++++++++++++++++++++
5 files changed, 41 insertions(+), 2 deletions(-)
create mode 100644 sysdeps/unix/sysv/linux/pread64_nocancel.c
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index f3d862651e..724c3e5e71 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -41,6 +41,8 @@
(void) __close (fd)
#define __read_nocancel(fd, buf, n) \
__read (fd, buf, n)
+#define __pread64_nocancel(fd, buf, count, offset) \
+ __pread64 (fd, buf, count, offset)
#define __write_nocancel(fd, buf, n) \
__write (fd, buf, n)
#define __writev_nocancel_nostatus(fd, iov, n) \
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 1ab6bcbfc8..a7980a60f6 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -212,8 +212,8 @@ sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
close_nocancel fcntl_nocancel nanosleep_nocancel \
open_nocancel open64_nocancel \
openat_nocancel openat64_nocancel \
- pause_nocancel read_nocancel waitpid_nocancel \
- write_nocancel statx_cp
+ pause_nocancel read_nocancel pread64_nocancel \
+ waitpid_nocancel write_nocancel statx_cp
sysdep_headers += bits/fcntl-linux.h
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 1ca102a9e2..d385085c61 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -182,6 +182,7 @@ libc {
__syscall_rt_sigqueueinfo;
__open_nocancel;
__read_nocancel;
+ __pread64_nocancel;
__close_nocancel;
__sigtimedwait;
# functions used by nscd
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 16cc31cba5..bf7d80125a 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -43,6 +43,9 @@ __typeof (openat64) __openat64_nocancel;
/* Non cancellable read syscall. */
__typeof (__read) __read_nocancel;
+/* Non cancellable pread syscall (LFS version). */
+__typeof (__pread64) __pread64_nocancel;
+
/* Uncancelable write. */
__typeof (__write) __write_nocancel;
@@ -84,6 +87,7 @@ hidden_proto (__open64_nocancel)
hidden_proto (__openat_nocancel)
hidden_proto (__openat64_nocancel)
hidden_proto (__read_nocancel)
+hidden_proto (__pread64_nocancel)
hidden_proto (__write_nocancel)
hidden_proto (__close_nocancel)
hidden_proto (__waitpid_nocancel)
diff --git a/sysdeps/unix/sysv/linux/pread64_nocancel.c b/sysdeps/unix/sysv/linux/pread64_nocancel.c
new file mode 100644
index 0000000000..dab61260e5
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/pread64_nocancel.c
@@ -0,0 +1,32 @@
+/* Linux pread64() syscall implementation -- non-cancellable.
+ Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <unistd.h>
+#include <sysdep-cancel.h>
+#include <not-cancel.h>
+
+#ifndef __NR_pread64
+# define __NR_pread64 __NR_pread
+#endif
+
+ssize_t
+__pread64_nocancel (int fd, void *buf, size_t count, off64_t offset)
+{
+ return INLINE_SYSCALL_CALL (pread64, fd, buf, count, SYSCALL_LL64_PRW (offset));
+}
+hidden_def (__pread64_nocancel)
--
2.21.0