blob: 711811f2368a5f97ec0cbab64a102154fcd8d675 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001/* 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
20static inline _syscall1(int, __syscall_fsync, int, fd)
21
22extern __typeof(fsync) __libc_fsync;
23
24int __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
37weak_alias(__libc_fsync, fsync)