]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/fdatasync.c
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / common / fdatasync.c
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
10 #include <sys/syscall.h>
11 #include <unistd.h>
12
13 #if !defined __NR_fdatasync && defined __NR_osf_fdatasync
14 # define __NR_fdatasync __NR_osf_fdatasync
15 #endif
16
17 #ifdef __NR_fdatasync
18
19 # ifdef __UCLIBC_HAS_THREADS_NATIVE__
20 # include <sysdep-cancel.h>
21 # else
22 # define SINGLE_THREAD_P 1
23 # endif
24
25 #define __NR___syscall_fdatasync __NR_fdatasync
26
27 static __always_inline
28 _syscall1(int, __syscall_fdatasync, int, fd)
29
30 int fdatasync(int fd)
31 {
32         if (SINGLE_THREAD_P)
33                 return __syscall_fdatasync(fd);
34
35 # ifdef __UCLIBC_HAS_THREADS_NATIVE__
36         int oldtype = LIBC_CANCEL_ASYNC ();
37         int result = __syscall_fdatasync(fd);
38         LIBC_CANCEL_RESET (oldtype);
39         return result;
40 # endif
41 }
42
43 #elif defined __UCLIBC_HAS_STUBS__
44 /* no syscall available, so provide a stub */
45 int fdatasync(int fd)
46 {
47         __set_errno(ENOSYS);
48         return -1;
49 }
50 #endif