2 * posix_fadvise() for uClibc
3 * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
10 #include <sys/syscall.h>
12 #ifdef __NR_arm_fadvise64_64
13 /* We handle the 64bit alignment issue which is why the arm guys renamed their
14 * syscall in the first place. So rename it back.
16 # define __NR_fadvise64_64 __NR_arm_fadvise64_64
19 #if defined(__NR_fadvise64) || defined(__NR_fadvise64_64)
22 # include <bits/wordsize.h>
24 # if defined(__NR_fadvise64_64)
27 int posix_fadvise64(int fd, off64_t offset, off64_t len, int advice);
28 int posix_fadvise(int fd, off_t offset, off_t len, int advice)
30 return posix_fadvise64(fd, offset, len, advice);
34 int posix_fadvise(int fd, off_t offset, off_t len, int advice)
37 INTERNAL_SYSCALL_DECL(err);
39 # ifdef __NR_fadvise64_64
41 ret = INTERNAL_SYSCALL(fadvise64_64, err, 4, fd, offset, len, advice);
43 # if defined (__arm__) || defined (__nds32__) || defined(__csky__) || \
44 (defined(__UCLIBC_SYSCALL_ALIGN_64BIT__) && (defined(__powerpc__) || defined(__xtensa__)))
45 /* arch with 64-bit data in even reg alignment #1: [powerpc/xtensa]
46 * custom syscall handler (rearranges @advice to avoid register hole punch) */
47 ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd, advice,
48 OFF_HI_LO (offset), OFF_HI_LO (len));
49 # elif defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
50 /* arch with 64-bit data in even reg alignment #2: [arcv2/others-in-future]
51 * stock syscall handler in kernel (reg hole punched) */
52 ret = INTERNAL_SYSCALL(fadvise64_64, err, 7, fd, 0,
53 OFF_HI_LO (offset), OFF_HI_LO (len), advice);
55 ret = INTERNAL_SYSCALL(fadvise64_64, err, 6, fd,
56 OFF_HI_LO (offset), OFF_HI_LO (len), advice);
59 # else /* __NR_fadvise64 */
61 ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
63 # if defined(__UCLIBC_SYSCALL_ALIGN_64BIT__)
64 ret = INTERNAL_SYSCALL(fadvise64, err, 6, fd, /*unused*/0,
66 ret = INTERNAL_SYSCALL(fadvise64, err, 5, fd,
68 OFF_HI_LO (offset), len, advice);
71 if (INTERNAL_SYSCALL_ERROR_P (ret, err))
72 return INTERNAL_SYSCALL_ERRNO (ret, err);
75 # if !defined __NR_fadvise64_64 || __WORDSIZE == 64
76 strong_alias(posix_fadvise,posix_fadvise64)