This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 3/5] Consolidate off_t/off64_t syscall argument passing
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Cc: Adhemerval Zanella <adhemerval dot zanella at linaro dot com>
- Date: Wed, 24 Feb 2016 17:48:07 -0300
- Subject: [PATCH 3/5] Consolidate off_t/off64_t syscall argument passing
- Authentication-results: sourceware.org; auth=none
- References: <1456346889-9862-1-git-send-email-adhemerval dot zanella at linaro dot org>
From: Adhemerval Zanella <adhemerval.zanella@linaro.com>
This patch add two new macros to use along with off_t and off64_t argument
syscalls. The rationale for this change is:
1. Remove multiple implementations for the same syscall for different
architectures (for instance, pread have 6 different implementations).
2. Also remove the requirement to use syscall wrappers for cancellable
entrypoints.
The macro usage should be used along __ALIGNMENT_ARG to follow ABI constrains
for architecture where it applies. For instance, pread can be rewritten as:
return SYSCALL_CANCEL (pread, fd, buf, count,
__ALIGNMENT_ARG SYSCALL_LL (offset));
Another macro, SYSCALL_LL64, is provided for off64_t.
The changes itself are not currently used in any implementation, so no
code change is expected.
* sysdeps/unix/sysv/linux/generic/sysdep.h (__NR__llseek): Define only
if it is not already defined.
(SYSCALL_LL): Define.
(SYSCALL_LL64): Likewise.
---
sysdeps/unix/sysv/linux/generic/sysdep.h | 13 +++++++++++++
2 files changed, 18 insertions(+)
diff --git a/sysdeps/unix/sysv/linux/generic/sysdep.h b/sysdeps/unix/sysv/linux/generic/sysdep.h
index 4f2c65d..22bfe59 100644
--- a/sysdeps/unix/sysv/linux/generic/sysdep.h
+++ b/sysdeps/unix/sysv/linux/generic/sysdep.h
@@ -22,7 +22,9 @@
#include <sysdeps/unix/sysv/linux/sysdep.h>
/* Provide the common name to allow more code reuse. */
+#ifndef __NR__llseek
#define __NR__llseek __NR_llseek
+#endif
#if __WORDSIZE == 64
/* By defining the older names, glibc will build syscall wrappers for
@@ -41,3 +43,14 @@
#define __ALIGNMENT_ARG
#define __ALIGNMENT_COUNT(a,b) a
#endif
+
+/* Provide a common macro to pass 64-bit value on syscalls. */
+#if __WORDSIZE == 64 || defined __ASSUME_WORDSIZE64_ILP32
+# define SYSCALL_LL(__val) (__val)
+# define SYSCALL_LL64(__val) (__val)
+#else
+#define SYSCALL_LL(__val) \
+ __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+ __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))
+#endif
--
1.9.1