@@ -54,6 +54,19 @@
# define __LONG_LONG_PAIR(HI, LO) HI, LO
#endif
+/* Declare structure field that has different size
+ in 32- and 64-bit ABIs with paddings where needed,
+ so final layout becomes identical. */
+#if __WORDSIZE == 32
+# if __BYTE_ORDER == __LITTLE_ENDIAN
+# define __type3264(type, name) type name; type name##_pad
+# else
+# define __type3264(type, name) type name##_pad; type name
+# endif
+#else /* __WORDSIZE == 64. */
+# define __type3264(type, name) type name
+#endif
+
#if defined __USE_MISC && !defined __ASSEMBLER__
/* Conversion interfaces. */
@@ -62,6 +62,15 @@
#define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE
#define __CPU_MASK_TYPE __ULONGWORD_TYPE
+
+#ifdef __ILP32__
+# define __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T 1
+# define XSTAT_IS_XSTAT64
+# define STATFS_IS_STATFS64
+#else
+# define __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T 0
+#endif
+
/* Tell the libc code that off_t and off64_t are actually the same type
for all ABI purposes, even if possibly expressed as different base types
for C type-checking purposes. */
@@ -1,4 +1,4 @@
aarch64/nptl
unix/sysv/linux/aarch64
-unix/sysv/linux/generic
unix/sysv/linux/generic/wordsize-32
+unix/sysv/linux/generic
new file mode 100644
@@ -0,0 +1,36 @@
+/* Return information about the filesystem on which FD resides.
+ Copyright (C) 1996-2016 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ 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 __fstatfs __statfs_disable
+#define fstatfs statfs_disable
+
+#include <errno.h>
+#include <sys/statfs.h>
+#include <stddef.h>
+
+/* Return information about the filesystem on which FD resides. */
+int
+__fstatfs64 (int fd, struct statfs64 *buf)
+{
+ return INLINE_SYSCALL (fstatfs64, 2, fd, buf);
+}
+
+#undef __fstatfs
+#undef fstatfs
+strong_alias (__fstatfs64, __fstatfs)
+weak_alias (__fstatfs64, fstatfs64)
+weak_alias (__fstatfs64, fstatfs)
new file mode 100644
@@ -0,0 +1,37 @@
+/* Copyright (C) 2011-2015 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 __statfs __statfs_disable
+#define statfs statfs_disable
+
+#include <errno.h>
+#include <sys/statfs.h>
+#include <stddef.h>
+
+/* Return information about the filesystem on which FILE resides. */
+int
+__statfs64 (const char *file, struct statfs64 *buf)
+{
+ return INLINE_SYSCALL (statfs64, 2, file, buf);
+}
+
+#undef __statfs
+#undef statfs
+weak_alias (__statfs64, statfs64)
+strong_alias (__statfs64, __statfs)
+libc_hidden_ver (__statfs64, __statfs)
+weak_alias (__statfs64, statfs)
@@ -15,6 +15,7 @@
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
#include <errno.h>
#include <stddef.h>
@@ -36,12 +37,22 @@ ___fxstat64 (int vers, int fd, struct stat64 *buf)
#if defined _HAVE_STAT64___ST_INO && !defined __ASSUME_ST_INO_64_BIT
if (__builtin_expect (!result, 1) && buf->__st_ino != (__ino_t) buf->st_ino)
buf->st_ino = buf->__st_ino;
+ return result;
+#endif
+#if __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T
+ if (!result)
+ {
+ conv_timespec(&buf->st_atim, &buf->__st_atim);
+ conv_timespec(&buf->st_mtim, &buf->__st_mtim);
+ conv_timespec(&buf->st_ctim, &buf->__st_ctim);
+ }
#endif
return result;
}
#include <shlib-compat.h>
+#undef __fxstat
#if SHLIB_COMPAT(libc, GLIBC_2_1, GLIBC_2_2)
versioned_symbol (libc, ___fxstat64, __fxstat64, GLIBC_2_2);
strong_alias (___fxstat64, __old__fxstat64)
@@ -51,3 +62,9 @@ hidden_ver (___fxstat64, __fxstat64)
strong_alias (___fxstat64, __fxstat64)
hidden_def (__fxstat64)
#endif
+
+#ifdef XSTAT_IS_XSTAT64
+strong_alias (__fxstat64, __fxstat)
+libc_hidden_ver (__fxstat64, __fxstat)
+#endif
+
@@ -14,6 +14,7 @@
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 <errno.h>
#include <fcntl.h>
@@ -39,9 +40,23 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, st, flag);
if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
- return 0;
+ {
+#ifdef __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T
+ conv_timespec(&st->st_atim, &st->__st_atim);
+ conv_timespec(&st->st_mtim, &st->__st_mtim);
+ conv_timespec(&st->st_ctim, &st->__st_ctim);
+#endif
+ return 0;
+ }
else
return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (result,
err));
}
libc_hidden_def (__fxstatat64)
+
+#undef __fxstatat
+#ifdef XSTAT_IS_XSTAT64
+strong_alias (__fxstatat64, __fxstatat)
+libc_hidden_ver (__fxstatat64, __fxstatat)
+#endif
+
@@ -42,7 +42,7 @@
#if defined __USE_FILE_OFFSET64
# define __field64(type, type64, name) type64 name
-#elif __WORDSIZE == 64
+#elif __WORDSIZE == 64 || defined (XSTAT_IS_XSTAT64)
# define __field64(type, type64, name) type name
#elif __BYTE_ORDER == __LITTLE_ENDIAN
# define __field64(type, type64, name) \
@@ -73,19 +73,28 @@ struct stat
identifier 'timespec' to appear in the <sys/stat.h> header.
Therefore we have to handle the use of this header in strictly
standard-compliant sources special. */
- struct timespec st_atim; /* Time of last access. */
- struct timespec st_mtim; /* Time of last modification. */
- struct timespec st_ctim; /* Time of last status change. */
+ DECLARE_TIMESPEC (st_atim); /* Time of last access. */
+ DECLARE_TIMESPEC (st_mtim); /* Time of last modification. */
+ DECLARE_TIMESPEC (st_ctim); /* Time of last status change. */
# define st_atime st_atim.tv_sec /* Backward compatibility. */
# define st_mtime st_mtim.tv_sec
# define st_ctime st_ctim.tv_sec
#else
+# ifdef __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T
+ __type3264 (__time_t, st_atime); /* Time of last access. */
+ __type3264 (unsigned long int, st_atimensec); /* Nscecs of last access. */
+ __type3264 (__time_t, st_mtime); /* Time of last modification. */
+ __type3264 (unsigned long int, st_mtimensec); /* Nsecs of last modification. */
+ __type3264 (__time_t, st_ctime); /* Time of last status change. */
+ __type3264 (unsigned long int, st_ctimensec); /* Nsecs of last status change. */
+# else
__time_t st_atime; /* Time of last access. */
unsigned long int st_atimensec; /* Nscecs of last access. */
__time_t st_mtime; /* Time of last modification. */
unsigned long int st_mtimensec; /* Nsecs of last modification. */
__time_t st_ctime; /* Time of last status change. */
unsigned long int st_ctimensec; /* Nsecs of last status change. */
+# endif /* __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T. */
#endif
int __glibc_reserved[2];
};
@@ -114,16 +123,28 @@ struct stat64
identifier 'timespec' to appear in the <sys/stat.h> header.
Therefore we have to handle the use of this header in strictly
standard-compliant sources special. */
- struct timespec st_atim; /* Time of last access. */
- struct timespec st_mtim; /* Time of last modification. */
- struct timespec st_ctim; /* Time of last status change. */
+ DECLARE_TIMESPEC (st_atim); /* Time of last access. */
+ DECLARE_TIMESPEC (st_mtim); /* Time of last modification. */
+ DECLARE_TIMESPEC (st_ctim); /* Time of last status change. */
+# define st_atime st_atim.tv_sec /* Backward compatibility. */
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
#else
+# ifdef __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T
+ __type3264 (__time_t, st_atime); /* Time of last access. */
+ __type3264 (unsigned long int, st_atimensec); /* Nscecs of last access. */
+ __type3264 (__time_t, st_mtime); /* Time of last modification. */
+ __type3264 (unsigned long int, st_mtimensec); /* Nsecs of last modification. */
+ __type3264 (__time_t, st_ctime); /* Time of last status change. */
+ __type3264 (unsigned long int, st_ctimensec); /* Nsecs of last status change. */
+# else
__time_t st_atime; /* Time of last access. */
unsigned long int st_atimensec; /* Nscecs of last access. */
__time_t st_mtime; /* Time of last modification. */
unsigned long int st_mtimensec; /* Nsecs of last modification. */
__time_t st_ctime; /* Time of last status change. */
unsigned long int st_ctimensec; /* Nsecs of last status change. */
+# endif /* __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T. */
#endif
int __glibc_reserved[2];
};
@@ -34,7 +34,7 @@
#if defined __USE_FILE_OFFSET64
# define __field64(type, type64, name) type64 name
-#elif __WORDSIZE == 64
+#elif __WORDSIZE == 64 || defined (STATFS_IS_STATFS64)
# define __field64(type, type64, name) type name
#elif __BYTE_ORDER == __LITTLE_ENDIAN
# define __field64(type, type64, name) \
@@ -44,20 +44,26 @@
int __##name##_pad __attribute__((__aligned__ (__alignof__ (type64)))); type name
#endif
+#ifdef STATFS_IS_STATFS64
+# define statfs_word_t long long
+#else
+# define statfs_word_t __SWORD_TYPE
+#endif
+
struct statfs
{
- __SWORD_TYPE f_type;
- __SWORD_TYPE f_bsize;
+ statfs_word_t f_type;
+ statfs_word_t f_bsize;
__field64(__fsblkcnt_t, __fsblkcnt64_t, f_blocks);
__field64(__fsblkcnt_t, __fsblkcnt64_t, f_bfree);
__field64(__fsblkcnt_t, __fsblkcnt64_t, f_bavail);
__field64(__fsfilcnt_t, __fsfilcnt64_t, f_files);
__field64(__fsfilcnt_t, __fsfilcnt64_t, f_ffree);
__fsid_t f_fsid;
- __SWORD_TYPE f_namelen;
- __SWORD_TYPE f_frsize;
- __SWORD_TYPE f_flags;
- __SWORD_TYPE f_spare[4];
+ statfs_word_t f_namelen;
+ statfs_word_t f_frsize;
+ statfs_word_t f_flags;
+ statfs_word_t f_spare[4];
};
#undef __field64
@@ -65,18 +71,18 @@ struct statfs
#ifdef __USE_LARGEFILE64
struct statfs64
{
- __SWORD_TYPE f_type;
- __SWORD_TYPE f_bsize;
+ statfs_word_t f_type;
+ statfs_word_t f_bsize;
__fsblkcnt64_t f_blocks;
__fsblkcnt64_t f_bfree;
__fsblkcnt64_t f_bavail;
__fsfilcnt64_t f_files;
__fsfilcnt64_t f_ffree;
__fsid_t f_fsid;
- __SWORD_TYPE f_namelen;
- __SWORD_TYPE f_frsize;
- __SWORD_TYPE f_flags;
- __SWORD_TYPE f_spare[4];
+ statfs_word_t f_namelen;
+ statfs_word_t f_frsize;
+ statfs_word_t f_flags;
+ statfs_word_t f_spare[4];
};
#endif
@@ -20,6 +20,8 @@
#include <sys/statfs.h>
#include <stddef.h>
+#ifndef STATFS_IS_STATFS64
+
#include "overflow.h"
/* Return information about the filesystem on which FD resides. */
@@ -30,3 +32,5 @@ __fstatfs (int fd, struct statfs *buf)
return rc ?: statfs_overflow (buf);
}
weak_alias (__fstatfs, fstatfs)
+#endif
+
@@ -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,5 @@ __fxstat (int vers, int fd, struct stat *buf)
hidden_def (__fxstat)
weak_alias (__fxstat, _fxstat);
+#endif
+
@@ -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,5 @@ __fxstatat (int vers, int fd, const char *file, struct stat *buf, int flag)
return -1;
}
libc_hidden_def (__fxstatat)
+#endif
+
@@ -25,6 +25,7 @@
#include <sysdep.h>
#include <sys/syscall.h>
+#ifndef XSTAT_IS_XSTAT64
#include "overflow.h"
/* Get information about the file NAME in BUF. */
@@ -41,3 +42,5 @@ __lxstat (int vers, const char *name, struct stat *buf)
return -1;
}
hidden_def (__lxstat)
+#endif
+
@@ -15,6 +15,7 @@
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 __lxstat __lxstat_disable
#include <errno.h>
#include <stddef.h>
@@ -30,9 +31,28 @@ int
__lxstat64 (int vers, const char *name, struct stat64 *buf)
{
if (vers == _STAT_VER_KERNEL)
- return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf,
+ {
+ int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf,
AT_SYMLINK_NOFOLLOW);
+#if __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T
+ if (!rc)
+ {
+ conv_timespec(&buf->st_atim, &buf->__st_atim);
+ conv_timespec(&buf->st_mtim, &buf->__st_mtim);
+ conv_timespec(&buf->st_ctim, &buf->__st_ctim);
+ }
+#endif
+ return rc;
+ }
+
errno = EINVAL;
return -1;
}
hidden_def (__lxstat64)
+
+#undef __lxstat
+#ifdef XSTAT_IS_XSTAT64
+strong_alias (__lxstat64, __lxstat)
+hidden_ver (__lxstat64, __lxstat)
+#endif
+
@@ -20,6 +20,7 @@
#include <sys/statfs.h>
#include <stddef.h>
+#ifndef STATFS_IS_STATFS64
#include "overflow.h"
/* Return information about the filesystem on which FILE resides. */
@@ -31,3 +32,5 @@ __statfs (const char *file, struct statfs *buf)
}
libc_hidden_def (__statfs)
weak_alias (__statfs, statfs)
+#endif
+
@@ -25,6 +25,7 @@
#include <sysdep.h>
#include <sys/syscall.h>
+#ifndef XSTAT_IS_XSTAT64
#include "overflow.h"
/* Get information about the file NAME in BUF. */
@@ -41,3 +42,5 @@ __xstat (int vers, const char *name, struct stat *buf)
return -1;
}
hidden_def (__xstat)
+#endif
+
@@ -15,6 +15,7 @@
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 __xstat __xstat_disable
#include <errno.h>
#include <stddef.h>
@@ -30,9 +31,27 @@ int
__xstat64 (int vers, const char *name, struct stat64 *buf)
{
if (vers == _STAT_VER_KERNEL)
- return INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
+ {
+ int rc = INLINE_SYSCALL (fstatat64, 4, AT_FDCWD, name, buf, 0);
+#if __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T
+ if (!rc)
+ {
+ conv_timespec(&buf->st_atim, &buf->__st_atim);
+ conv_timespec(&buf->st_mtim, &buf->__st_mtim);
+ conv_timespec(&buf->st_ctim, &buf->__st_ctim);
+ }
+#endif
+ return rc;
+ }
errno = EINVAL;
return -1;
}
hidden_def (__xstat64)
+
+#undef __xstat
+#ifdef XSTAT_IS_XSTAT64
+strong_alias (__xstat64, __xstat)
+hidden_ver (__xstat64, __xstat)
+#endif
+
@@ -123,6 +123,33 @@ struct timespec
__syscall_slong_t tv_nsec; /* Nanoseconds. */
};
+# if __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T == 1
+struct __timespec
+ {
+ long long tv_sec; /* Seconds. */
+ long long tv_nsec; /* Nanoseconds. */
+ };
+
+# define conv_timespec(ts, _ts) \
+ do \
+ { \
+ (ts)->tv_sec = (_ts)->tv_sec; \
+ (ts)->tv_nsec = (_ts)->tv_nsec; \
+ } \
+ while (0)
+
+# define DECLARE_TIMESPEC(__name) \
+ union \
+ { \
+ struct timespec __name; \
+ struct __timespec __##__name; \
+ };
+
+# else
+# define DECLARE_TIMESPEC(__name) struct timespec __name
+# define conv_timespec(ts, _ts)
+# endif /* __32_BIT_ABI_SUPPORTS_64_BIT_TIME_T. */
+
#endif /* timespec not defined and <time.h> or need timespec. */
#undef __need_timespec