msync.c 951 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * msync() for uClibc
  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. #include <sys/syscall.h>
  10. #include <unistd.h>
  11. #include <sys/mman.h>
  12. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  13. #include <sysdep-cancel.h>
  14. #else
  15. #define SINGLE_THREAD_P 1
  16. #endif
  17. #define __NR___syscall_msync __NR_msync
  18. static __always_inline _syscall3(int, __syscall_msync, void *, addr, size_t, length,
  19. int, flags)
  20. extern __typeof(msync) __libc_msync;
  21. int __libc_msync(void * addr, size_t length, int flags)
  22. {
  23. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  24. int oldtype, result;
  25. #endif
  26. if (SINGLE_THREAD_P)
  27. return __syscall_msync(addr, length, flags);
  28. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  29. oldtype = LIBC_CANCEL_ASYNC ();
  30. result = __syscall_msync(addr, length, flags);
  31. LIBC_CANCEL_RESET (oldtype);
  32. return result;
  33. #endif
  34. }
  35. weak_alias(__libc_msync,msync)