This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/5] Consolidate off_t/off64_t syscall argument passing

From: Adhemerval Zanella <>

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

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
 #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
+/* 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)
+#define SYSCALL_LL(__val)   \
+  __LONG_LONG_PAIR (__val >> 31, __val)
+#define SYSCALL_LL64(__val) \
+  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]