posix_madvise.c 939 B

12345678910111213141516171819202122232425
  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. #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