1 /* Licensed under the LGPL v2.1, see the file LICENSE in this tarball. */
2
3 #include <sys/mman.h>
4 #include <sys/syscall.h>
5
6 #ifdef __ARCH_USE_MMU__
7 #if defined __NR_madvise && defined __USE_XOPEN2K && defined __UCLIBC_HAS_ADVANCED_REALTIME__
posix_madvise(void * addr,size_t len,int advice)8 int posix_madvise(void *addr, size_t len, int advice)
9 {
10 int result;
11 /* We have one problem: the kernel's MADV_DONTNEED does not
12 * correspond to POSIX's POSIX_MADV_DONTNEED. The former simply
13 * discards changes made to the memory without writing it back to
14 * disk, if this would be necessary. The POSIX behaviour does not
15 * allow this. There is no functionality mapping for the POSIX
16 * behaviour so far so we ignore that advice for now. */
17 if (advice == POSIX_MADV_DONTNEED)
18 return 0;
19
20 /* this part might use madvise function */
21 INTERNAL_SYSCALL_DECL (err);
22 result = INTERNAL_SYSCALL (madvise, err, 3, addr, len, advice);
23 return INTERNAL_SYSCALL_ERRNO (result, err);
24 }
25 #endif
26 #endif
27