posix_madvise.c 945 B

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