fdatasync.c 867 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * fdatasync() 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. #if !defined __NR_fdatasync && defined __NR_osf_fdatasync
  12. # define __NR_fdatasync __NR_osf_fdatasync
  13. #endif
  14. #ifdef __NR_fdatasync
  15. # ifdef __UCLIBC_HAS_THREADS_NATIVE__
  16. # include <sysdep-cancel.h>
  17. # else
  18. # define SINGLE_THREAD_P 1
  19. # endif
  20. #define __NR___syscall_fdatasync __NR_fdatasync
  21. static __always_inline
  22. _syscall1(int, __syscall_fdatasync, int, fd)
  23. int fdatasync(int fd)
  24. {
  25. if (SINGLE_THREAD_P)
  26. return __syscall_fdatasync(fd);
  27. # ifdef __UCLIBC_HAS_THREADS_NATIVE__
  28. int oldtype = LIBC_CANCEL_ASYNC ();
  29. int result = __syscall_fdatasync(fd);
  30. LIBC_CANCEL_RESET (oldtype);
  31. return result;
  32. # endif
  33. }
  34. #endif