OSDN Git Service

a72e84d0b394a3e1b39eea244e8140bb1c33b8f4
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / open.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * open() for uClibc
4  *
5  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9
10 #include <sys/syscall.h>
11 #include <fcntl.h>
12 #include <stdarg.h>
13 #include <cancel.h>
14
15 #define __NR___syscall_open __NR_open
16 static __always_inline _syscall3(int, __syscall_open, const char *, file,
17                                  int, flags, __kernel_mode_t, mode)
18 strong_alias_untyped(__syscall_open,__NC(open))
19
20 #define __NR___open2_nocancel __NR_open
21 _syscall2(int, __NC(open2), const char *, file, int, flags)
22
23 int open(const char *file, int oflag, ...)
24 {
25         mode_t mode = 0;
26
27         if (oflag & O_CREAT) {
28                 va_list arg;
29                 va_start(arg, oflag);
30                 mode = va_arg(arg, mode_t);
31                 va_end(arg);
32         }
33
34         if (SINGLE_THREAD_P)
35                 return __NC(open)(file, oflag, mode);
36 #ifdef __NEW_THREADS
37         int oldtype = LIBC_CANCEL_ASYNC ();
38         int result = __NC(open)(file, oflag, mode);
39         LIBC_CANCEL_RESET (oldtype);
40         return result;
41 #endif
42 }
43 lt_strong_alias(open)
44 lt_libc_hidden(open)