]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re-core/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/common/__syscall_fcntl.c
Update
[l4.git] / l4 / pkg / l4re-core / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / common / __syscall_fcntl.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * __syscall_fcntl() for uClibc
4  *
5  * Copyright (C) 2006 Steven J. Hill <sjhill@realitydiluted.com>
6  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
7  *
8  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
9  */
10
11 #include <sys/syscall.h>
12 #include <stdarg.h>
13 #include <cancel.h>     /* Must come before <fcntl.h>.  */
14 #include <fcntl.h>
15 #include <bits/wordsize.h>
16
17 int __NC(fcntl)(int fd, int cmd, long arg)
18 {
19 #if __WORDSIZE == 32
20         if (cmd == F_GETLK64 || cmd == F_SETLK64 || cmd == F_SETLKW64) {
21 # if (defined __UCLIBC_HAS_LFS__ && defined __NR_fcntl64) || !defined __NR_fcntl
22                 return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
23 # else
24                 __set_errno(ENOSYS);
25                 return -1;
26 # endif
27         }
28 #endif
29
30 #if defined __NR_fcntl
31         return INLINE_SYSCALL(fcntl, 3, fd, cmd, arg);
32 #else
33         __set_errno(ENOSYS);
34         return -1;
35 #endif
36 }
37
38 int fcntl(int fd, int cmd, ...)
39 {
40         va_list ap;
41         long arg;
42
43         va_start (ap, cmd);
44         arg = va_arg (ap, long);
45         va_end (ap);
46
47         if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
48 #if defined __NR_fcntl
49                 return __NC(fcntl)(fd, cmd, arg);
50 #else
51                 return INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
52 #endif
53 #ifdef __NEW_THREADS
54         int oldtype = LIBC_CANCEL_ASYNC ();
55 #if defined __NR_fcntl
56         int result = __NC(fcntl)(fd, cmd, arg);
57 #else
58         int result = INLINE_SYSCALL(fcntl64, 3, fd, cmd, arg);
59 #endif
60         LIBC_CANCEL_RESET (oldtype);
61         return result;
62 #endif
63 }
64 lt_strong_alias(fcntl)
65 lt_libc_hidden(fcntl)
66 #if defined __UCLIBC_HAS_LFS__ && !defined __NR_fcntl64 && __WORDSIZE == 32
67 strong_alias_untyped(fcntl,fcntl64)
68 lt_strong_alias(fcntl64)
69 lt_libc_hidden(fcntl64)
70 #endif