1 /* vi: set sw=4 ts=4: */
3 * posix_fadvise64() for uClibc
4 * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
6 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
8 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
16 #include <sys/types.h>
17 #include <sys/syscall.h>
20 #ifdef __UCLIBC_HAS_LFS__
21 #ifdef __NR_fadvise64_64
23 /* 64 bit implementation is cake ... or more like pie ... */
26 #define __NR_posix_fadvise64 __NR_fadvise64_64
28 int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
30 if (len != (off_t) len)
32 INTERNAL_SYSCALL_DECL (err);
33 int ret = INTERNAL_SYSCALL (posix_fadvise64, err, 5, fd,
34 __LONG_LONG_PAIR ((long) (offset >> 32),
37 if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
39 return INTERNAL_SYSCALL_ERRNO (ret, err);
42 /* 32 bit implementation is kind of a pita */
43 #elif __WORDSIZE == 32
45 int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
47 INTERNAL_SYSCALL_DECL (err);
48 int ret = INTERNAL_SYSCALL (fadvise64_64, err, 6, fd,
49 __LONG_LONG_PAIR(offset >> 32, offset & 0xffffffff),
50 __LONG_LONG_PAIR(len >> 32, len & 0xffffffff),
52 if (!INTERNAL_SYSCALL_ERROR_P (ret, err))
54 return INTERNAL_SYSCALL_ERRNO (ret, err);
58 #error your machine is neither 32 bit or 64 bit ... it must be magical
61 #endif /* __NR_fadvise64_64 */
62 #endif /* __UCLIBC_HAS_LFS__ */