summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/sysdeps/linux/arm/Makefile.arch2
-rw-r--r--libc/sysdeps/linux/arm/posix_fadvise.c24
-rw-r--r--libc/sysdeps/linux/arm/posix_fadvise64.c59
-rw-r--r--libc/sysdeps/linux/common/posix_fadvise.c28
-rw-r--r--libc/sysdeps/linux/common/posix_fadvise64.c64
-rw-r--r--libc/sysdeps/linux/mips/posix_fadvise.c23
-rw-r--r--libc/sysdeps/linux/mips/posix_fadvise64.c32
-rw-r--r--libc/sysdeps/linux/powerpc/Makefile.arch4
-rw-r--r--libc/sysdeps/linux/powerpc/posix_fadvise.c30
-rw-r--r--libc/sysdeps/linux/powerpc/posix_fadvise64.c60
-rw-r--r--libc/sysdeps/linux/xtensa/Makefile.arch2
-rw-r--r--libc/sysdeps/linux/xtensa/posix_fadvise.c22
-rw-r--r--libc/sysdeps/linux/xtensa/posix_fadvise64.c39
13 files changed, 78 insertions, 311 deletions
diff --git a/libc/sysdeps/linux/arm/Makefile.arch b/libc/sysdeps/linux/arm/Makefile.arch
index 0cc2626f3..5fc3e545f 100644
--- a/libc/sysdeps/linux/arm/Makefile.arch
+++ b/libc/sysdeps/linux/arm/Makefile.arch
@@ -17,7 +17,7 @@ SSRC += libc-aeabi_read_tp.S libc-thumb_atomics.S
endif
ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
-CSRC += posix_fadvise.c posix_fadvise64.c
+CSRC += posix_fadvise.c
endif
# Is our compiler set up for EABI ?
diff --git a/libc/sysdeps/linux/arm/posix_fadvise.c b/libc/sysdeps/linux/arm/posix_fadvise.c
index d8ba58fc2..f59cbfb6e 100644
--- a/libc/sysdeps/linux/arm/posix_fadvise.c
+++ b/libc/sysdeps/linux/arm/posix_fadvise.c
@@ -8,18 +8,12 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
#include <sys/syscall.h>
-#include <fcntl.h>
-#if defined __NR_arm_fadvise64_64
+#ifdef __NR_arm_fadvise64_64
+# include <fcntl.h>
+# include <endian.h>
-#define HIGH_BITS(x) (sizeof(x) > 4 ? (x) >> 32 : 0)
-
-/* Was named __libc_posix_fadvise for some inexplicable reason.
-** google says only uclibc has *__libc*_posix_fadviseXXX,
-** so it cannot be compat with anything.
-**
-** Remove this comment and one at the end after 0.9.31
-*/
+# define HIGH_BITS(x) (sizeof(x) > 4 ? (x) >> 32 : 0)
/* This is for the ARM version of fadvise64_64 which swaps the params
* about to avoid having ABI compat issues
@@ -36,14 +30,4 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advise)
return INTERNAL_SYSCALL_ERRNO (ret, err);
return 0;
}
-
-/* weak_alias(__libc_posix_fadvise, posix_fadvise); */
-
-#elif defined __UCLIBC_HAS_STUBS__
-
-int posix_fadvise(int fd attribute_unused, off_t offset attribute_unused, off_t len attribute_unused, int advice attribute_unused)
-{
- return ENOSYS;
-}
-
#endif
diff --git a/libc/sysdeps/linux/arm/posix_fadvise64.c b/libc/sysdeps/linux/arm/posix_fadvise64.c
deleted file mode 100644
index 678c42f90..000000000
--- a/libc/sysdeps/linux/arm/posix_fadvise64.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise64() for ARM uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-
-#if defined __NR_arm_fadvise64_64
-
-/* Was named __libc_posix_fadvise64 for some inexplicable reason.
-** google says only uclibc has *__libc*_posix_fadviseXXX,
-** so it cannot be compat with anything.
-**
-** Remove this comment and one at the end after 0.9.31
-*/
-
-/* This is for the ARM version of fadvise64_64 which swaps the params
- * about to avoid having ABI compat issues
- */
-#define __NR___syscall_arm_fadvise64_64 __NR_arm_fadvise64_64
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (arm_fadvise64_64, err, 6, fd, advise,
- __LONG_LONG_PAIR ((long)(offset >> 32), (long)offset),
- __LONG_LONG_PAIR ((long)(len >> 32), (long)len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- if (INTERNAL_SYSCALL_ERRNO (ret, err) != ENOSYS)
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
-}
-
-/* weak_alias(__libc_posix_fadvise64, posix_fadvise64); */
-
-#elif defined __UCLIBC_HAS_STUBS__
-
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- return ENOSYS;
-}
-
-#endif
-
-#endif
diff --git a/libc/sysdeps/linux/common/posix_fadvise.c b/libc/sysdeps/linux/common/posix_fadvise.c
index 84b7c40d0..22df56982 100644
--- a/libc/sysdeps/linux/common/posix_fadvise.c
+++ b/libc/sysdeps/linux/common/posix_fadvise.c
@@ -9,23 +9,31 @@
*/
#include <sys/syscall.h>
-#include <fcntl.h>
#ifdef __NR_fadvise64
-#define __NR_posix_fadvise __NR_fadvise64
+# include <fcntl.h>
+# include <endian.h>
+# include <bits/wordsize.h>
+
int posix_fadvise(int fd, off_t offset, off_t len, int advice)
{
int ret;
INTERNAL_SYSCALL_DECL(err);
- ret = (int) (INTERNAL_SYSCALL(posix_fadvise, err, 5, fd,
- __LONG_LONG_PAIR (offset >> 31, offset), len, advice));
- if (INTERNAL_SYSCALL_ERROR_P (ret, err))
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
+# if __WORDSIZE == 64
+ ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
+# else
+# ifdef __powerpc__
+ ret = INTERNAL_SYSCALL(fadvise64, err, 6, fd, /*unused*/0,
+# else
+ ret = INTERNAL_SYSCALL(fadvise64, err, 5, fd,
+# endif
+ __LONG_LONG_PAIR (offset >> 31, offset), len, advice);
+# endif
+ if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
}
-
-# if defined __UCLIBC_HAS_LFS__ && !defined __NR_fadvise64_64
+# if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || __WORDSIZE == 64)
strong_alias(posix_fadvise,posix_fadvise64)
# endif
-
#endif
diff --git a/libc/sysdeps/linux/common/posix_fadvise64.c b/libc/sysdeps/linux/common/posix_fadvise64.c
index fa9ff219f..de813ba15 100644
--- a/libc/sysdeps/linux/common/posix_fadvise64.c
+++ b/libc/sysdeps/linux/common/posix_fadvise64.c
@@ -8,55 +8,33 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#include <fcntl.h>
+#include <bits/wordsize.h>
-#ifdef __UCLIBC_HAS_LFS__
-#ifdef __NR_fadvise64_64
-
-/* 64 bit implementation is cake ... or more like pie ... */
-#if __WORDSIZE == 64
-
-#define __NR_posix_fadvise64 __NR_fadvise64_64
-
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
-{
- if (len != (off_t) len)
- return EOVERFLOW;
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (posix_fadvise64, err, 5, fd,
- __LONG_LONG_PAIR ((long) (offset >> 32),
- (long) offset),
- (off_t) len, advice);
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-}
+#ifdef __NR_arm_fadvise64_64
+# define __NR_fadvise64_64 __NR_arm_fadvise64_64
+#endif
-/* 32 bit implementation is kind of a pita */
-#elif __WORDSIZE == 32
+#if defined __NR_fadvise64_64 && defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32
+# include <fcntl.h>
+# include <endian.h>
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
+int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice)
{
INTERNAL_SYSCALL_DECL (err);
+# if defined __powerpc__ || defined __arm__ || defined __xtensa__
+ int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
+ __LONG_LONG_PAIR((long)(offset >> 32), (long)offset),
+ __LONG_LONG_PAIR((long)(len >> 32), (long)len));
+# else
int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd,
- __LONG_LONG_PAIR(offset >> 32, offset & 0xffffffff),
- __LONG_LONG_PAIR(len >> 32, len & 0xffffffff),
- advice);
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
+ __LONG_LONG_PAIR((long)(offset >> 32), (long)offset),
+ __LONG_LONG_PAIR((long)(len >> 32), (long)len),
+ advice);
+# endif
+ if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
}
-
-#else
-#error your machine is neither 32 bit or 64 bit ... it must be magical
#endif
-
-#endif /* __NR_fadvise64_64 */
-#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/mips/posix_fadvise.c b/libc/sysdeps/linux/mips/posix_fadvise.c
index 8546d96ba..b0110bfb2 100644
--- a/libc/sysdeps/linux/mips/posix_fadvise.c
+++ b/libc/sysdeps/linux/mips/posix_fadvise.c
@@ -8,19 +8,16 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
#include <sys/syscall.h>
-#include <fcntl.h>
-int posix_fadvise(int fd, off_t offset, off_t len, int advice)
-{
/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
#ifdef __NR_fadvise64
+# include <fcntl.h>
+# include <endian.h>
+# include <bits/wordsize.h>
+
+int posix_fadvise(int fd, off_t offset, off_t len, int advice)
+{
INTERNAL_SYSCALL_DECL(err);
# if _MIPS_SIM == _ABIO32
int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
@@ -33,7 +30,9 @@ int posix_fadvise(int fd, off_t offset, off_t len, int advice)
if (INTERNAL_SYSCALL_ERROR_P (ret, err))
return INTERNAL_SYSCALL_ERRNO (ret, err);
return 0;
-#else
- return ENOSYS;
-#endif
}
+# if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
+strong_alias(posix_fadvise,posix_fadvise64)
+# endif
+
+#endif
diff --git a/libc/sysdeps/linux/mips/posix_fadvise64.c b/libc/sysdeps/linux/mips/posix_fadvise64.c
index d9b89d123..f97dab97d 100644
--- a/libc/sysdeps/linux/mips/posix_fadvise64.c
+++ b/libc/sysdeps/linux/mips/posix_fadvise64.c
@@ -8,36 +8,28 @@
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
+#include <_lfs_64.h>
#include <sys/syscall.h>
-#include <fcntl.h>
+#include <bits/wordsize.h>
-#ifdef __UCLIBC_HAS_LFS__
+/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
+#if defined __NR_fadvise64 && defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 32
+# include <fcntl.h>
+# include <endian.h>
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
+int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice)
{
-/* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
-#ifdef __NR_fadvise64
INTERNAL_SYSCALL_DECL(err);
-# if _MIPS_SIM == _MIPS_SIM_ABI32
+# if _MIPS_SIM == _ABIO32
int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
- __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
- __LONG_LONG_PAIR ((long) (len >> 32), (long) len),
- advice);
+ __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
+ __LONG_LONG_PAIR ((long) (len >> 32), (long) len),
+ advice);
# else /* N32 || N64 */
int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
# endif
if (INTERNAL_SYSCALL_ERROR_P (ret, err))
return INTERNAL_SYSCALL_ERRNO (ret, err);
return 0;
-#else
- return ENOSYS;
-#endif
}
-
-#endif /* __UCLIBC_HAS_LFS__ */
+#endif
diff --git a/libc/sysdeps/linux/powerpc/Makefile.arch b/libc/sysdeps/linux/powerpc/Makefile.arch
index cdb35ba43..62dbe3b64 100644
--- a/libc/sysdeps/linux/powerpc/Makefile.arch
+++ b/libc/sysdeps/linux/powerpc/Makefile.arch
@@ -7,10 +7,6 @@
CSRC := __syscall_error.c pread_write.c ioctl.c
-ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
-CSRC += posix_fadvise.c posix_fadvise64.c
-endif
-
SSRC := \
__longjmp.S setjmp.S bsd-setjmp.S bsd-_setjmp.S brk.S \
__uClibc_syscall.S syscall.S
diff --git a/libc/sysdeps/linux/powerpc/posix_fadvise.c b/libc/sysdeps/linux/powerpc/posix_fadvise.c
deleted file mode 100644
index 7ceb8ce8f..000000000
--- a/libc/sysdeps/linux/powerpc/posix_fadvise.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise() for uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __NR_fadvise64
-#define __NR_posix_fadvise __NR_fadvise64
-int posix_fadvise(int fd, off_t offset, off_t len, int advice)
-{
- INTERNAL_SYSCALL_DECL(err);
- int ret = (int) (INTERNAL_SYSCALL(posix_fadvise, err, 6, fd, 0,
- __LONG_LONG_PAIR (offset >> 31, offset), len, advice));
- if (INTERNAL_SYSCALL_ERROR_P (ret, err))
- return INTERNAL_SYSCALL_ERRNO (ret, err);
- return 0;
-}
-
-#if defined __UCLIBC_HAS_LFS__ && (!defined __NR_fadvise64_64 || !defined _syscall6)
-strong_alias(posix_fadvise,posix_fadvise64)
-#endif
-
-#endif
diff --git a/libc/sysdeps/linux/powerpc/posix_fadvise64.c b/libc/sysdeps/linux/powerpc/posix_fadvise64.c
deleted file mode 100644
index d92071158..000000000
--- a/libc/sysdeps/linux/powerpc/posix_fadvise64.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise64() for uClibc
- * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-#ifdef __NR_fadvise64_64
-
-/* 64 bit implementation is cake ... or more like pie ... */
-#if __WORDSIZE == 64
-
-#define __NR_posix_fadvise64 __NR_fadvise64_64
-
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- if (len != (off_t) len)
- return EOVERFLOW;
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (posix_fadvise64, err, 6, fd, 0,
- __LONG_LONG_PAIR ((long) (offset >> 32), (long) offset),
- (off_t) len, advise);
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-}
-
-/* 32 bit implementation is kind of a pita */
-#elif __WORDSIZE == 32
-
-int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advise)
-{
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advise,
- __LONG_LONG_PAIR((long) (offset >> 32), (long) offset ),
- __LONG_LONG_PAIR((long) (len >> 32), (long) len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-}
-
-#else
-#error your machine is neither 32 bit or 64 bit ... it must be magical
-#endif
-
-#endif /* __NR_fadvise64_64 */
-#endif /* __UCLIBC_HAS_LFS__ */
diff --git a/libc/sysdeps/linux/xtensa/Makefile.arch b/libc/sysdeps/linux/xtensa/Makefile.arch
index bf4503138..13387f2ff 100644
--- a/libc/sysdeps/linux/xtensa/Makefile.arch
+++ b/libc/sysdeps/linux/xtensa/Makefile.arch
@@ -8,7 +8,7 @@
CSRC := brk.c fork.c pread_write.c sigaction.c __syscall_error.c
ifeq ($(UCLIBC_HAS_ADVANCED_REALTIME),y)
- CSRC += posix_fadvise.c posix_fadvise64.c
+ CSRC += posix_fadvise.c
endif
SSRC := bsd-_setjmp.S bsd-setjmp.S setjmp.S clone.S \
diff --git a/libc/sysdeps/linux/xtensa/posix_fadvise.c b/libc/sysdeps/linux/xtensa/posix_fadvise.c
index 0fe13a1e9..94006ec64 100644
--- a/libc/sysdeps/linux/xtensa/posix_fadvise.c
+++ b/libc/sysdeps/linux/xtensa/posix_fadvise.c
@@ -9,21 +9,19 @@
*/
#include <sys/syscall.h>
-#include <fcntl.h>
+
+#ifdef __NR_fadvise64_64
+# include <fcntl.h>
+# include <endian.h>
int posix_fadvise (int fd, off_t offset, off_t len, int advice)
{
-#ifdef __NR_fadvise64_64
INTERNAL_SYSCALL_DECL (err);
int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
- __LONG_LONG_PAIR ((long) (offset >> 31),
- (long) offset),
- __LONG_LONG_PAIR ((long) (len >> 31),
- (long) len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-#else
- return ENOSYS;
-#endif
+ __LONG_LONG_PAIR ((long) (offset >> 31), (long) offset),
+ __LONG_LONG_PAIR ((long) (len >> 31), (long) len));
+ if (INTERNAL_SYSCALL_ERROR_P (ret, err))
+ return INTERNAL_SYSCALL_ERRNO (ret, err);
+ return 0;
}
+#endif
diff --git a/libc/sysdeps/linux/xtensa/posix_fadvise64.c b/libc/sysdeps/linux/xtensa/posix_fadvise64.c
deleted file mode 100644
index 1fdeeba79..000000000
--- a/libc/sysdeps/linux/xtensa/posix_fadvise64.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* vi: set sw=4 ts=4: */
-/*
- * posix_fadvise64() for Xtensa uClibc
- *
- * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
- * Copyright (C) 2007 Tensilica Inc.
- *
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-#include <features.h>
-#include <unistd.h>
-#include <errno.h>
-#include <endian.h>
-#include <stdint.h>
-#include <sys/types.h>
-#include <sys/syscall.h>
-#include <fcntl.h>
-
-#ifdef __UCLIBC_HAS_LFS__
-
-int posix_fadvise64 (int fd, __off64_t offset, __off64_t len, int advice)
-{
-#ifdef __NR_fadvise64_64
- INTERNAL_SYSCALL_DECL (err);
- int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd, advice,
- __LONG_LONG_PAIR ((long) (offset >> 32),
- (long) offset),
- __LONG_LONG_PAIR ((long) (len >> 32),
- (long) len));
- if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
- return 0;
- return INTERNAL_SYSCALL_ERRNO (ret, err);
-#else
- return ENOSYS;
-#endif
-}
-
-#endif /* __UCLIBC_HAS_LFS__ */