This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 22/23] off_t: fix register pair calculation for 64-bit case
- From: Yury Norov <ynorov at caviumnetworks dot com>
- To: <libc-alpha at sourceware dot org>, <linux-kernel at vger dot kernel dot org>
- Cc: <arnd at arndb dot de>, <catalin dot marinas at arm dot com>, <marcus dot shawcroft at arm dot com>, <philb at gnu dot org>, <davem at davemloft dot net>, <szabolcs dot nagy at arm dot com>, <maxim dot kuvyrkov at linaro dot org>, <joseph at codesourcery dot com>, <pinskia at gmail dot com>, <bamvor dot zhangjian at huawei dot com>, <schwab at suse dot de>, <fweimer at redhat dot com>, <Prasun dot Kapoor at cavium dot com>, <cmetcalf at mellanox dot com>, <hjl dot tools at gmail dot com>, <adhemerval dot zanella at linaro dot org>, Yury Norov <ynorov at caviumnetworks dot com>
- Date: Tue, 28 Jun 2016 19:39:37 +0300
- Subject: [PATCH 22/23] off_t: fix register pair calculation for 64-bit case
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp dot mailfrom=Yuri dot Norov at caviumnetworks dot com;
- References: <1467131978-669-1-git-send-email-ynorov at caviumnetworks dot com>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
There are 3 syscall wrappers under sysdeps/unix/sysv/linux that
calculate register pair for off_t like this:
__LONG_LONG_PAIR (offset >> 31, offset)
While it works for 32-bit off_t, new 32-bit APIs that use 64-bit
off_t will be broken with it. This patch redirects affected syscalls
to their 64-bit versions. It also saves few instructions and symbols
in glibc, as 32-bit syscall wrappers are not generated anymore.
This patch has also been sent separately and is found correct during
discussion.
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
sysdeps/unix/sysv/linux/fallocate.c | 4 ++++
sysdeps/unix/sysv/linux/fallocate64.c | 4 ++++
sysdeps/unix/sysv/linux/posix_fadvise.c | 4 ++++
sysdeps/unix/sysv/linux/posix_fadvise64.c | 4 ++++
sysdeps/unix/sysv/linux/posix_fallocate.c | 4 ++++
sysdeps/unix/sysv/linux/posix_fallocate64.c | 4 ++++
6 files changed, 24 insertions(+)
diff --git a/sysdeps/unix/sysv/linux/fallocate.c b/sysdeps/unix/sysv/linux/fallocate.c
index 6a58a5f..4ec55a5 100644
--- a/sysdeps/unix/sysv/linux/fallocate.c
+++ b/sysdeps/unix/sysv/linux/fallocate.c
@@ -20,6 +20,8 @@
#include <sysdep-cancel.h>
+#ifndef __OFF_T_MATCHES_OFF64_T
+
/* Reserve storage for the data of the file associated with FD. */
int
fallocate (int fd, int mode, __off_t offset, __off_t len)
@@ -33,3 +35,5 @@ fallocate (int fd, int mode, __off_t offset, __off_t len)
return -1;
#endif
}
+
+#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/fallocate64.c b/sysdeps/unix/sysv/linux/fallocate64.c
index 8e76d6f..f4f73d5 100644
--- a/sysdeps/unix/sysv/linux/fallocate64.c
+++ b/sysdeps/unix/sysv/linux/fallocate64.c
@@ -35,3 +35,7 @@ fallocate64 (int fd, int mode, __off64_t offset, __off64_t len)
return -1;
#endif
}
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias(fallocate64, fallocate)
+#endif
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise.c b/sysdeps/unix/sysv/linux/posix_fadvise.c
index 093d707..8356bc7 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise.c
@@ -19,6 +19,8 @@
#include <fcntl.h>
#include <sysdep.h>
+#ifndef __OFF_T_MATCHES_OFF64_T
+
/* Advice the system about the expected behaviour of the application with
respect to the file associated with FD. */
@@ -46,3 +48,5 @@ posix_fadvise (int fd, off_t offset, off_t len, int advise)
return ENOSYS;
#endif
}
+
+#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/posix_fadvise64.c b/sysdeps/unix/sysv/linux/posix_fadvise64.c
index 6d10558..c76d52f 100644
--- a/sysdeps/unix/sysv/linux/posix_fadvise64.c
+++ b/sysdeps/unix/sysv/linux/posix_fadvise64.c
@@ -56,3 +56,7 @@ compat_symbol (libc, __posix_fadvise64_l32, posix_fadvise64, GLIBC_2_2);
#else
strong_alias (__posix_fadvise64_l64, posix_fadvise64);
#endif
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias(__posix_fadvise64_l64, __posix_fadvise)
+#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate.c b/sysdeps/unix/sysv/linux/posix_fallocate.c
index fc9ac37..f9ca34b 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate.c
@@ -18,6 +18,8 @@
#include <fcntl.h>
#include <sysdep.h>
+#ifndef __OFF_T_MATCHES_OFF64_T
+
#define posix_fallocate static internal_fallocate
#include <sysdeps/posix/posix_fallocate.c>
#undef posix_fallocate
@@ -37,3 +39,5 @@ posix_fallocate (int fd, __off_t offset, __off_t len)
return INTERNAL_SYSCALL_ERRNO (res, err);
return internal_fallocate (fd, offset, len);
}
+
+#endif /* __OFF_T_MATCHES_OFF64_T */
diff --git a/sysdeps/unix/sysv/linux/posix_fallocate64.c b/sysdeps/unix/sysv/linux/posix_fallocate64.c
index 4a0a722..3a65d35 100644
--- a/sysdeps/unix/sysv/linux/posix_fallocate64.c
+++ b/sysdeps/unix/sysv/linux/posix_fallocate64.c
@@ -40,3 +40,7 @@ __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
return INTERNAL_SYSCALL_ERRNO (res, err);
return internal_fallocate64 (fd, offset, len);
}
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias(__posix_fallocate64_l64, posix_fallocate)
+#endif
--
2.7.4