1 /* vi: set sw=4 ts=4: */
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
10 #include <sys/syscall.h>
16 # define __NR___syscall_open __NR_open
17 static __always_inline _syscall3(int, __syscall_open, const char *, file,
18 int, flags, __kernel_mode_t, mode)
19 strong_alias_untyped(__syscall_open,__NC(open))
21 # define __NR___open2_nocancel __NR_open
22 _syscall2(int, __NC(open2), const char *, file, int, flags)
24 int __open2_nocancel(const char *, int) __nonnull ((1)) attribute_hidden;
25 int __open_nocancel(const char *, int, mode_t) __nonnull ((1)) attribute_hidden;
28 int open(const char *file, int oflag, ...)
32 if (oflag & O_CREAT) {
35 mode = va_arg(arg, mode_t);
40 #if defined(__NR_open)
41 return __NC(open)(file, oflag, mode);
42 #elif defined(__NR_openat)
43 return openat(AT_FDCWD, file, oflag, mode);
47 int oldtype = LIBC_CANCEL_ASYNC ();
48 # if defined(__NR_open)
49 int result = __NC(open)(file, oflag, mode);
51 int result = openat(AT_FDCWD, file, oflag, mode);
53 LIBC_CANCEL_RESET (oldtype);
59 #if !defined(__NR_open)
60 strong_alias_untyped(open,__open2_nocancel)
61 strong_alias_untyped(open,__open_nocancel)