posix_madvise.c 970 B

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