OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / posix_fadvise64.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * posix_fadvise64() for uClibc
4  * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
5  *
6  * Copyright (C) 2000-2005 by Erik Andersen <andersen@codepoet.org>
7  *
8  * GNU Library General Public License (LGPL) version 2 or later.
9  */
10
11 #include <features.h>
12 #include <unistd.h>
13 #include <errno.h>
14 #include <endian.h>
15 #include <stdint.h>
16 #include <sys/types.h>
17 #include <sys/syscall.h>
18 #include <fcntl.h>
19
20 #ifdef __UCLIBC_HAS_LFS__
21 #ifdef __NR_fadvise64_64
22
23 /* 64 bit implementation is cake ... or more like pie ... */
24 #if __WORDSIZE == 64
25
26 #define __NR_posix_fadvise64 __NR_fadvise64_64
27 _syscall4(int, posix_fadvise64, int, fd, __off64_t, offset,
28           __off64_t, len, int, advice);
29
30 /* 32 bit implementation is kind of a pita */
31 #elif __WORDSIZE == 32
32
33 #ifdef _syscall6 /* workaround until everyone has _syscall6() */
34 #define __NR___syscall_fadvise64_64 __NR_fadvise64_64
35 static inline _syscall6(int, __syscall_fadvise64_64, int, fd,
36           unsigned long, high_offset, unsigned long, low_offset,
37           unsigned long, high_len, unsigned long, low_len,
38           int, advice);
39 int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
40 {
41         return (__syscall_fadvise64_64(fd,
42                 __LONG_LONG_PAIR(offset >> 32, offset &  0xffffffff),
43                 __LONG_LONG_PAIR(len >> 32, len & 0xffffffff),
44                 advice));
45 }
46 #else
47 #warning _syscall6 has not been defined for your machine :(
48 #endif /* _syscall6 */
49
50 #else
51 #error your machine is neither 32 bit or 64 bit ... it must be magical
52 #endif
53
54 #elif !defined __NR_fadvise64
55 /* This is declared as a strong alias in posix_fadvise.c if __NR_fadvise64
56  * is defined.
57  */
58 int posix_fadvise64(int fd, __off64_t offset, __off64_t len, int advice)
59 {
60         __set_errno(ENOSYS);
61         return -1;
62 }
63 #endif /* __NR_fadvise64_64 */
64 #endif /* __UCLIBC_HAS_LFS__ */