yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame] | 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 | |
| 10 | #include <sys/syscall.h> |
| 11 | #include <unistd.h> |
| 12 | |
| 13 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 14 | #include "sysdep-cancel.h" |
| 15 | #else |
| 16 | #define SINGLE_THREAD_P 1 |
| 17 | #endif |
| 18 | |
| 19 | #define __NR___syscall_fsync __NR_fsync |
| 20 | static inline _syscall1(int, __syscall_fsync, int, fd) |
| 21 | |
| 22 | extern __typeof(fsync) __libc_fsync; |
| 23 | |
| 24 | int __libc_fsync(int fd) |
| 25 | { |
| 26 | if (SINGLE_THREAD_P) |
| 27 | return __syscall_fsync(fd); |
| 28 | |
| 29 | #ifdef __UCLIBC_HAS_THREADS_NATIVE__ |
| 30 | int oldtype = LIBC_CANCEL_ASYNC (); |
| 31 | int result = __syscall_fsync(fd); |
| 32 | LIBC_CANCEL_RESET (oldtype); |
| 33 | return result; |
| 34 | #endif |
| 35 | } |
| 36 | |
| 37 | weak_alias(__libc_fsync, fsync) |