[PATCH 3/4] generic/wordsize-32: don't duplicate fxstat syscall family if not needed
Yury Norov
ynorov@caviumnetworks.com
Wed Sep 14 12:03:00 GMT 2016
If XSTAT_IS_XSTAT64 is enabled, there's no difference between that
syscalls and their 64-bit versions. It also means that struct stat has
no pads, and stat_overflow() is not needed. So we can reuse
fxstat{,at}64 syscalls.
There's no corresponding fstat64.c and fstatat64.c under
sysdeps/unix/sysv/linux/generic/wordsize-32, so currently syscall
wrappers are taken from sysdeps/unix/sysv/linux. This is not suitable
for generic/wordsize-32 because redirection depending on
XSTAT_IS_XSTAT64 is implemented in files that define __fxstat() and
__fxstatat().
In this patch, fxstat64.c and fxstatat64.c are created under
sysdeps/unix/sysv/linux/generic/wordsize-32, syscall implementations are
taken from sysdeps/unix/sysv/linux, and proper redirecting is added to
avoid duplication. For fxstatat64(), vers is checked against
_STAT_VER_KERNEL, like in other files under generic/wordsize-32.
2016-09-14: Yury Norov <ynorov@caviumnetworks.com>
* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c: don't
declare __fxstat() and symbols if XSTAT_IS_XSTAT64 is enabled.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c: don't
declare __fxstatat() and symbols if XSTAT_IS_XSTAT64 is enabled.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c: New file
* sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c: New file
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
.../unix/sysv/linux/generic/wordsize-32/fxstat.c | 2 ++
.../unix/sysv/linux/generic/wordsize-32/fxstat64.c | 31 ++++++++++++++++++++++
.../unix/sysv/linux/generic/wordsize-32/fxstatat.c | 2 ++
.../sysv/linux/generic/wordsize-32/fxstatat64.c | 31 ++++++++++++++++++++++
4 files changed, 66 insertions(+)
create mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
create mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
index dd52011..ac015c0 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat.c
@@ -25,6 +25,7 @@
#include <sysdep.h>
#include <sys/syscall.h>
+#ifndef XSTAT_IS_XSTAT64
#include "overflow.h"
/* Get information about the file FD in BUF. */
@@ -43,3 +44,4 @@ __fxstat (int vers, int fd, struct stat *buf)
hidden_def (__fxstat)
weak_alias (__fxstat, _fxstat);
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
new file mode 100644
index 0000000..7df4ac0
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstat64.c
@@ -0,0 +1,31 @@
+/* __fxstat64 () implementation.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+ 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/>. */
+
+#define __fxstat __fxstat_disable
+#define _fxstat _fxstat_disable
+
+#include <sysdeps/unix/sysv/linux/fxstat64.c>
+
+#undef __fxstat
+#undef _fxstat
+#ifdef XSTAT_IS_XSTAT64
+weak_alias (__fxstat64, __fxstat)
+weak_alias (__fxstat64, _fxstat)
+hidden_ver (__fxstat64, __fxstat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
index dc7f934..b00f65d 100644
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat.c
@@ -26,6 +26,7 @@
#include <sysdep.h>
#include <sys/syscall.h>
+#ifndef XSTAT_IS_XSTAT64
#include "overflow.h"
/* Get information about the file NAME in BUF. */
@@ -42,3 +43,4 @@ __fxstatat (int vers, int fd, const char *file, struct stat *buf, int flag)
return -1;
}
libc_hidden_def (__fxstatat)
+#endif
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
new file mode 100644
index 0000000..8f6876a
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/fxstatat64.c
@@ -0,0 +1,31 @@
+/* __fxstatat64 () implementation.
+ Copyright (C) 2011-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
+
+ 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/>. */
+#define __fxstatat __fxstatat_disable
+
+#include <sys/stat.h>
+#undef _STAT_VER_LINUX
+#define _STAT_VER_LINUX _STAT_VER_KERNEL
+
+#include <sysdeps/unix/sysv/linux/fxstatat64.c>
+
+#undef __fxstatat
+#ifdef XSTAT_IS_XSTAT64
+weak_alias (__fxstatat64, __fxstatat)
+libc_hidden_ver (__fxstatat64, __fxstatat)
+#endif
--
2.7.4
More information about the Libc-alpha
mailing list