diff mbox

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

Message ID 1456346889-9862-4-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show

Commit Message

Adhemerval Zanella Netto Feb. 24, 2016, 8:48 p.m. UTC
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(+)

Comments

Mike Frysinger Feb. 24, 2016, 9:39 p.m. UTC | #1
On 24 Feb 2016 17:48, Adhemerval Zanella wrote:
> +#define SYSCALL_LL(__val)   \
> +  __LONG_LONG_PAIR (__val >> 31, __val)
> +#define SYSCALL_LL64(__val) \
> +  __LONG_LONG_PAIR ((long) (__val >> 32), (long) (__val & 0xffffffff))

shouldn't __val be parenthesized ?

#define SYSCALL_LL(__val) __LONG_LONG_PAIR ((__val) >> 31, (__val))

also, does this really need to be __val ?  it's a macro so it's not
like someone using a var or define named __val would affect this.
-mike
diff mbox

Patch

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