summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorMarkos Chandras <markos.chandras@imgtec.com>2012-10-10 14:26:07 +0100
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2013-02-20 13:45:13 +0100
commit9f44c4ca56c2a318fb51029340a26764ed2b708f (patch)
treea8da1fac1832072ac209b8892bc756e45457191c /libc
parentfaa3bc7b7c661857925250d795c35d5c75dd4ca5 (diff)
open: Use openat if arch does not have the open syscall
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com> Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libc')
-rw-r--r--libc/sysdeps/linux/common/open.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/libc/sysdeps/linux/common/open.c b/libc/sysdeps/linux/common/open.c
index a72e84d0b..aab0fb5a7 100644
--- a/libc/sysdeps/linux/common/open.c
+++ b/libc/sysdeps/linux/common/open.c
@@ -12,13 +12,18 @@
#include <stdarg.h>
#include <cancel.h>
-#define __NR___syscall_open __NR_open
+#if defined __NR_open
+# define __NR___syscall_open __NR_open
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
+# define __NR___open2_nocancel __NR_open
_syscall2(int, __NC(open2), const char *, file, int, flags)
+#else
+int __open2_nocancel(const char *, int) __nonnull ((1)) attribute_hidden;
+int __open_nocancel(const char *, int, mode_t) __nonnull ((1)) attribute_hidden;
+#endif
int open(const char *file, int oflag, ...)
{
@@ -32,13 +37,26 @@ int open(const char *file, int oflag, ...)
}
if (SINGLE_THREAD_P)
+#if defined(__NR_open)
return __NC(open)(file, oflag, mode);
+#elif defined(__NR_openat)
+ return openat(AT_FDCWD, file, oflag, mode);
+#endif
+
#ifdef __NEW_THREADS
int oldtype = LIBC_CANCEL_ASYNC ();
+# if defined(__NR_open)
int result = __NC(open)(file, oflag, mode);
+# else
+ int result = openat(AT_FDCWD, file, oflag, mode);
+# endif
LIBC_CANCEL_RESET (oldtype);
return result;
#endif
}
lt_strong_alias(open)
lt_libc_hidden(open)
+#if !defined(__NR_open)
+strong_alias_untyped(open,__open2_nocancel)
+strong_alias_untyped(open,__open_nocancel)
+#endif