fsync.c 760 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * fsync() 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. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  12. #include "sysdep-cancel.h"
  13. #else
  14. #define SINGLE_THREAD_P 1
  15. #endif
  16. #define __NR___syscall_fsync __NR_fsync
  17. static inline _syscall1(int, __syscall_fsync, int, fd)
  18. extern __typeof(fsync) __libc_fsync;
  19. int __libc_fsync(int fd)
  20. {
  21. if (SINGLE_THREAD_P)
  22. return __syscall_fsync(fd);
  23. #ifdef __UCLIBC_HAS_THREADS_NATIVE__
  24. int oldtype = LIBC_CANCEL_ASYNC ();
  25. int result = __syscall_fsync(fd);
  26. LIBC_CANCEL_RESET (oldtype);
  27. return result;
  28. #endif
  29. }
  30. weak_alias(__libc_fsync, fsync)