From dba942c80dc2cfa5768a856fff98e22a755fdd27 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Tue, 4 Oct 2016 06:51:35 +0200 Subject: add experimental aarch64 support Ported over from GNU C Library and runtime tested in Qemu. --- libc/sysdeps/linux/common/fstat.c | 28 ++++++++++++++-------------- libc/sysdeps/linux/common/fstatat.c | 9 --------- libc/sysdeps/linux/common/lstat.c | 9 +++++++++ libc/sysdeps/linux/common/lstat64.c | 14 +++++++++++--- libc/sysdeps/linux/common/stat.c | 8 ++++++++ 5 files changed, 42 insertions(+), 26 deletions(-) (limited to 'libc/sysdeps/linux/common') diff --git a/libc/sysdeps/linux/common/fstat.c b/libc/sysdeps/linux/common/fstat.c index eae3c8006..ac77eb295 100644 --- a/libc/sysdeps/linux/common/fstat.c +++ b/libc/sysdeps/linux/common/fstat.c @@ -7,25 +7,26 @@ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. */ -#include +#include #include #include +#include + #include "xstatconv.h" #if defined __NR_fstat64 && !defined __NR_fstat int fstat(int fd, struct stat *buf) { - int result = INLINE_SYSCALL(fstat64, 2, fd, buf); - if (result == 0) { - /* Did we overflow? */ - if (buf->__pad1 || buf->__pad2 || buf->__pad3 - || buf->__pad4 || buf->__pad5 - || buf->__pad6 || buf->__pad7) { - __set_errno(EOVERFLOW); - return -1; - } - } - return result; + return INLINE_SYSCALL(fstat64, 2, fd, buf); +} +libc_hidden_def(fstat) + +#elif __WORDSIZE == 64 && defined __NR_newfstatat +#include + +int fstat(int fd, struct stat *buf) +{ + return INLINE_SYSCALL(fstat, 2, fd, buf); } libc_hidden_def(fstat) @@ -55,10 +56,9 @@ int fstat(int fd, struct stat *buf) return result; } libc_hidden_def(fstat) +#endif # if ! defined __NR_fstat64 strong_alias_untyped(fstat,fstat64) libc_hidden_def(fstat64) -# endif - #endif diff --git a/libc/sysdeps/linux/common/fstatat.c b/libc/sysdeps/linux/common/fstatat.c index 4006814f0..13673d76c 100644 --- a/libc/sysdeps/linux/common/fstatat.c +++ b/libc/sysdeps/linux/common/fstatat.c @@ -26,15 +26,6 @@ int fstatat(int fd, const char *file, struct stat *buf, int flag) __xstat32_conv(&kbuf, buf); # else ret = INLINE_SYSCALL(fstatat64, 4, fd, file, buf, flag); - if (ret == 0) { - /* Did we overflow */ - if (buf->__pad1 || buf->__pad2 || buf->__pad3 - || buf->__pad4 || buf->__pad5 || buf->__pad6 - || buf->__pad7) { - __set_errno(EOVERFLOW); - return -1; - } - } # endif /* __ARCH_HAS_DEPRECATED_SYSCALLS__ */ return ret; } diff --git a/libc/sysdeps/linux/common/lstat.c b/libc/sysdeps/linux/common/lstat.c index 143cc1916..cef9b463d 100644 --- a/libc/sysdeps/linux/common/lstat.c +++ b/libc/sysdeps/linux/common/lstat.c @@ -20,6 +20,15 @@ int lstat(const char *file_name, struct stat *buf) } libc_hidden_def(lstat) +#elif __WORDSIZE == 64 && defined __NR_newfstatat +# include + +int lstat(const char *file_name, struct stat *buf) +{ + return fstatat(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW); +} +libc_hidden_def(lstat) + /* For systems which have both, prefer the old one */ #else # include "xstatconv.h" diff --git a/libc/sysdeps/linux/common/lstat64.c b/libc/sysdeps/linux/common/lstat64.c index c43e53e1d..76637b556 100644 --- a/libc/sysdeps/linux/common/lstat64.c +++ b/libc/sysdeps/linux/common/lstat64.c @@ -9,11 +9,19 @@ #include <_lfs_64.h> #include +#include +#include -# include -# include +#if defined __NR_fstatat64 && !defined __NR_lstat +# include + +int lstat64(const char *file_name, struct stat64 *buf) +{ + return fstatat64(AT_FDCWD, file_name, buf, AT_SYMLINK_NOFOLLOW); +} +libc_hidden_def(lstat64) -#if defined __NR_fstatat64 && !defined __NR_lstat64 +#elif __WORDSIZE == 64 && defined __NR_newfstatat # include int lstat64(const char *file_name, struct stat64 *buf) diff --git a/libc/sysdeps/linux/common/stat.c b/libc/sysdeps/linux/common/stat.c index b3c2a19ea..8e4542a74 100644 --- a/libc/sysdeps/linux/common/stat.c +++ b/libc/sysdeps/linux/common/stat.c @@ -21,6 +21,14 @@ int stat(const char *file_name, struct stat *buf) return fstatat(AT_FDCWD, file_name, buf, 0); } +#elif __WORDSIZE == 64 && defined __NR_newfstatat +# include + +int stat(const char *file_name, struct stat *buf) +{ + return fstatat64(AT_FDCWD, file_name, buf, 0); +} + #else # include "xstatconv.h" -- cgit v1.2.3