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