[git commit future] adapt fdatasync, fsync, msync to use cancel.h

Peter S. Mazinger ps.m at gmx.net
Wed Apr 20 10:50:38 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=6fd9946086ab1e100fbb7a4e8806bc09d7d6d587
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 libc/sysdeps/linux/common/fdatasync.c |   29 ++++--------------------
 libc/sysdeps/linux/common/fsync.c     |   28 +++--------------------
 libc/sysdeps/linux/common/msync.c     |   38 ++++++--------------------------
 3 files changed, 16 insertions(+), 79 deletions(-)

diff --git a/libc/sysdeps/linux/common/fdatasync.c b/libc/sysdeps/linux/common/fdatasync.c
index e51c723..6c2f4f9 100644
--- a/libc/sysdeps/linux/common/fdatasync.c
+++ b/libc/sysdeps/linux/common/fdatasync.c
@@ -8,36 +8,17 @@
  */
 
 #include <sys/syscall.h>
-#include <unistd.h>
 
 #if !defined __NR_fdatasync && defined __NR_osf_fdatasync
 # define __NR_fdatasync __NR_osf_fdatasync
 #endif
 
 #ifdef __NR_fdatasync
+# include <unistd.h>
+# include <cancel.h>
 
-# 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
-}
+# define __NR___fdatasync_nocancel __NR_fdatasync
+static _syscall1(int, __NC(fdatasync), int, fd)
 
+CANCELLABLE_SYSCALL(int, fdatasync, (int fd), (fd))
 #endif
diff --git a/libc/sysdeps/linux/common/fsync.c b/libc/sysdeps/linux/common/fsync.c
index dcf77eb..f13a1e6 100644
--- a/libc/sysdeps/linux/common/fsync.c
+++ b/libc/sysdeps/linux/common/fsync.c
@@ -9,29 +9,9 @@
 
 #include <sys/syscall.h>
 #include <unistd.h>
+#include <cancel.h>
 
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include "sysdep-cancel.h"
-#else
-#define SINGLE_THREAD_P 1
-#endif
+#define __NR___fsync_nocancel __NR_fsync
+static _syscall1(int, __NC(fsync), int, fd)
 
-#define __NR___syscall_fsync __NR_fsync
-static _syscall1(int, __syscall_fsync, int, fd)
-
-extern __typeof(fsync) __libc_fsync;
-
-int __libc_fsync(int fd)
-{
-	if (SINGLE_THREAD_P)
-		return __syscall_fsync(fd);
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-	int oldtype = LIBC_CANCEL_ASYNC ();
-	int result = __syscall_fsync(fd);
-	LIBC_CANCEL_RESET (oldtype);
-	return result;
-#endif
-}
-
-weak_alias(__libc_fsync, fsync)
+CANCELLABLE_SYSCALL(int, fsync, (int fd), (fd))
diff --git a/libc/sysdeps/linux/common/msync.c b/libc/sysdeps/linux/common/msync.c
index 844dbaa..e183fbf 100644
--- a/libc/sysdeps/linux/common/msync.c
+++ b/libc/sysdeps/linux/common/msync.c
@@ -8,38 +8,14 @@
  */
 
 #include <sys/syscall.h>
-#include <unistd.h>
-#include <sys/mman.h>
 
-#ifdef __NR_msync
+#if defined __NR_msync && defined __ARCH_USE_MMU__
+# include <sys/mman.h>
+# include <cancel.h>
 
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-#include <sysdep-cancel.h>
-#else
-#define SINGLE_THREAD_P 1
-#endif
-
-#define __NR___syscall_msync __NR_msync
-static __always_inline _syscall3(int, __syscall_msync, void *, addr, size_t, length,
-						int, flags)
-
-extern __typeof(msync) __libc_msync;
-int __libc_msync(void * addr, size_t length, int flags)
-{
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-	int oldtype, result;
-#endif
-
-	if (SINGLE_THREAD_P)
-		return __syscall_msync(addr, length, flags);
-
-#ifdef __UCLIBC_HAS_THREADS_NATIVE__
-	oldtype = LIBC_CANCEL_ASYNC ();
-	result = __syscall_msync(addr, length, flags);
-	LIBC_CANCEL_RESET (oldtype);
-	return result;
-#endif
-}
-weak_alias(__libc_msync,msync)
+# define __NR___msync_nocancel __NR_msync
+static _syscall3(int, __NC(msync), void *, addr, size_t, length, int, flags)
 
+CANCELLABLE_SYSCALL(int, msync, (void *addr, size_t length, int flags),
+		    (addr, length, flags))
 #endif
-- 
1.7.3.4



More information about the uClibc-cvs mailing list