[git commit] open.c: add cancellation using cancel.h

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Fri Jun 15 12:00:40 UTC 2012


commit: http://git.uclibc.org/uClibc/commit/?id=c4b9ff234e2d18ee51f652467986ed0102667737
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/master

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop at gmail.com>
---
 include/fcntl.h                  |    4 ++++
 libc/sysdeps/linux/common/open.c |   31 ++++++++++++++++++-------------
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/include/fcntl.h b/include/fcntl.h
index f2b4629..64c8e20 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -97,6 +97,10 @@ libc_hidden_proto(fcntl64)
 #ifndef __USE_FILE_OFFSET64
 extern int open (__const char *__file, int __oflag, ...) __nonnull ((1));
 libc_hidden_proto(open)
+# ifdef _LIBC
+extern int __open2_nocancel(const char *, int) __nonnull ((1)) attribute_hidden;
+extern int __open_nocancel(const char *, int, mode_t) __nonnull ((1)) attribute_hidden;
+# endif
 #else
 # ifdef __REDIRECT
 extern int __REDIRECT (open, (__const char *__file, int __oflag, ...), open64)
diff --git a/libc/sysdeps/linux/common/open.c b/libc/sysdeps/linux/common/open.c
index 9fb694d..a72e84d 100644
--- a/libc/sysdeps/linux/common/open.c
+++ b/libc/sysdeps/linux/common/open.c
@@ -8,15 +8,17 @@
  */
 
 #include <sys/syscall.h>
-#include <stdlib.h>
-#include <stdarg.h>
 #include <fcntl.h>
-#include <string.h>
-#include <sys/param.h>
+#include <stdarg.h>
+#include <cancel.h>
 
 #define __NR___syscall_open __NR_open
-static __inline__ _syscall3(int, __syscall_open, const char *, file,
-		int, flags, __kernel_mode_t, mode)
+static __always_inline _syscall3(int, __syscall_open, const char *, file,
+				 int, flags, __kernel_mode_t, mode)
+strong_alias_untyped(__syscall_open,__NC(open))
+
+#define __NR___open2_nocancel __NR_open
+_syscall2(int, __NC(open2), const char *, file, int, flags)
 
 int open(const char *file, int oflag, ...)
 {
@@ -29,11 +31,14 @@ int open(const char *file, int oflag, ...)
 		va_end(arg);
 	}
 
-	return __syscall_open(file, oflag, mode);
-}
-#ifndef __LINUXTHREADS_OLD__
-libc_hidden_def(open)
-#else
-libc_hidden_weak(open)
-strong_alias(open,__libc_open)
+	if (SINGLE_THREAD_P)
+		return __NC(open)(file, oflag, mode);
+#ifdef __NEW_THREADS
+	int oldtype = LIBC_CANCEL_ASYNC ();
+	int result = __NC(open)(file, oflag, mode);
+	LIBC_CANCEL_RESET (oldtype);
+	return result;
 #endif
+}
+lt_strong_alias(open)
+lt_libc_hidden(open)


More information about the uClibc-cvs mailing list