msync.c 978 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 __NR_msync
  13. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  14. #include <sysdep-cancel.h>
  15. #else
  16. #define SINGLE_THREAD_P 1
  17. #endif
  18. #define __NR___syscall_msync __NR_msync
  19. static __always_inline _syscall3(int, __syscall_msync, void *, addr, size_t, length,
  20. int, flags)
  21. extern __typeof(msync) __libc_msync;
  22. int __libc_msync(void * addr, size_t length, int flags)
  23. {
  24. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  25. int oldtype, result;
  26. #endif
  27. if (SINGLE_THREAD_P)
  28. return __syscall_msync(addr, length, flags);
  29. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  30. oldtype = LIBC_CANCEL_ASYNC ();
  31. result = __syscall_msync(addr, length, flags);
  32. LIBC_CANCEL_RESET (oldtype);
  33. return result;
  34. #endif
  35. }
  36. weak_alias(__libc_msync,msync)
  37. #endif