]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/mips/posix_fadvise.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / mips / posix_fadvise.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * posix_fadvise() for MIPS uClibc
4  * http://www.opengroup.org/onlinepubs/009695399/functions/posix_fadvise.html
5  *
6  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
7  *
8  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
9  */
10
11 #include <sys/syscall.h>
12
13 /* MIPS kernel only has NR_fadvise64 which acts as NR_fadvise64_64 */
14 #ifdef __NR_fadvise64
15 # include <fcntl.h>
16 # include <endian.h>
17 # include <bits/wordsize.h>
18
19 int posix_fadvise(int fd, off_t offset, off_t len, int advice)
20 {
21         INTERNAL_SYSCALL_DECL(err);
22 # if _MIPS_SIM == _ABIO32
23         int ret = INTERNAL_SYSCALL(fadvise64, err, 7, fd, 0,
24                 __LONG_LONG_PAIR ((long) (offset >> 31), (long) offset),
25                 __LONG_LONG_PAIR ((long) (len >> 31), (long) len),
26                 advice);
27 # else /* N32 || N64 */
28         int ret = INTERNAL_SYSCALL(fadvise64, err, 4, fd, offset, len, advice);
29 # endif
30         if (INTERNAL_SYSCALL_ERROR_P (ret, err))
31                 return INTERNAL_SYSCALL_ERRNO (ret, err);
32         return 0;
33 }
34 # if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
35 strong_alias(posix_fadvise,posix_fadvise64)
36 # endif
37
38 #endif