summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/fdatasync.c
diff options
context:
space:
mode:
authorSalvatore Cro <salvatore.cro@st.com>2010-09-09 16:01:04 +0200
committerCarmelo Amoroso <carmelo.amoroso@st.com>2010-09-15 12:38:42 +0200
commit4b88e6e858b55def2ef0392278ddf81835f2ac45 (patch)
treee97e06b8eb18ef18f86e598ccec879405bdcee53 /libc/sysdeps/linux/common/fdatasync.c
parent37eb913ed8c4798b736e678f4dbd9f4a91a68f74 (diff)
libc: Fix cancellation handling in some C functions
According to POSIX.1-2008 standard, the following syscalls shall be cancellation points : waitid, sleep, fdatasync, ppoll. Further, if generic syscall is not available and stubs are configured, provide the stub implementation for function. Signed-off-by: Salvatore Cro <salvatore.cro@st.com> Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/sysdeps/linux/common/fdatasync.c')
-rw-r--r--libc/sysdeps/linux/common/fdatasync.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/libc/sysdeps/linux/common/fdatasync.c b/libc/sysdeps/linux/common/fdatasync.c
index a40f3e00c..19d37b6e0 100644
--- a/libc/sysdeps/linux/common/fdatasync.c
+++ b/libc/sysdeps/linux/common/fdatasync.c
@@ -14,4 +14,37 @@
# define __NR_fdatasync __NR_osf_fdatasync
#endif
-_syscall1(int, fdatasync, int, fd)
+#ifdef __NR_fdatasync
+
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+# include <sysdep-cancel.h>
+# else
+# define SINGLE_THREAD_P 1
+# endif
+
+#define __NR___syscall_fdatasync __NR_fdatasync
+
+static __always_inline
+_syscall1(int, __syscall_fdatasync, int, fd)
+
+int fdatasync(int fd)
+{
+ if (SINGLE_THREAD_P)
+ return __syscall_fdatasync(fd);
+
+# ifdef __UCLIBC_HAS_THREADS_NATIVE__
+ int oldtype = LIBC_CANCEL_ASYNC ();
+ int result = __syscall_fdatasync(fd);
+ LIBC_CANCEL_RESET (oldtype);
+ return result;
+# endif
+}
+
+#elif defined __UCLIBC_HAS_STUBS__
+/* no syscall available, so provide a stub */
+int fdatasync(int fd)
+{
+ __set_errno(ENOSYS);
+ return -1;
+}
+#endif