2 * Copyright (c) 2011 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
8 * NaCl Service Runtime API.
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_SYS_FCNTL_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_SYS_FCNTL_H_
14 #if defined(NACL_IN_TOOLCHAIN_HEADERS)
15 #include <sys/types.h>
18 /* from bits/fcntl.h */
19 #define NACL_ABI_O_ACCMODE 0003
20 #define NACL_ABI_O_RDONLY 00
21 #define NACL_ABI_O_WRONLY 01
22 #define NACL_ABI_O_RDWR 02
24 #define NACL_ABI_O_CREAT 0100 /* not fcntl */
25 #define NACL_ABI_O_TRUNC 01000 /* not fcntl */
26 #define NACL_ABI_O_APPEND 02000
29 * Features not implemented by NaCl, but required by the newlib build.
31 #define NACL_ABI_O_EXCL 0200
32 #define NACL_ABI_O_NONBLOCK 04000
33 #define NACL_ABI_O_NDELAY NACL_ABI_O_NONBLOCK
34 #define NACL_ABI_O_SYNC 010000
35 #define NACL_ABI_O_FSYNC NACL_ABI_O_SYNC
36 #define NACL_ABI_O_ASYNC 020000
38 /* XXX close on exec request; must match UF_EXCLOSE in user.h */
39 #define FD_CLOEXEC 1 /* posix */
41 /* fcntl(2) requests */
42 #define NACL_ABI_F_DUPFD 0 /* Duplicate fildes */
43 #define NACL_ABI_F_GETFD 1 /* Get fildes flags (close on exec) */
44 #define NACL_ABI_F_SETFD 2 /* Set fildes flags (close on exec) */
45 #define NACL_ABI_F_GETFL 3 /* Get file flags */
46 #define NACL_ABI_F_SETFL 4 /* Set file flags */
48 #define NACL_ABI_F_GETOWN 5 /* Get owner - for ASYNC */
49 #define NACL_ABI_F_SETOWN 6 /* Set owner - for ASYNC */
50 #endif /* !_POSIX_SOURCE */
51 #define NACL_ABI_F_GETLK 7 /* Get record-locking information */
52 #define NACL_ABI_F_SETLK 8 /* Set or Clear a record-lock (Non-Blocking) */
53 #define NACL_ABI_F_SETLKW 9 /* Set or Clear a record-lock (Blocking) */
55 #define NACL_ABI_F_RGETLK 10 /* Test a remote lock to see if it is blocked */
56 #define NACL_ABI_F_RSETLK 11 /* Set or unlock a remote lock */
57 #define NACL_ABI_F_CNVT 12 /* Convert a fhandle to an open fd */
58 #define NACL_ABI_F_RSETLKW 13 /* Set or Clear remote record-lock(Blocking) */
59 #endif /* !_POSIX_SOURCE */
61 /* fcntl(2) flags (l_type field of flock structure) */
62 #define NACL_ABI_F_RDLCK 1 /* read lock */
63 #define NACL_ABI_F_WRLCK 2 /* write lock */
64 #define NACL_ABI_F_UNLCK 3 /* remove lock(s) */
66 #define NACL_ABI_F_UNLKSYS 4 /* remove remote locks for a given system */
67 #endif /* !_POSIX_SOURCE */
69 #if defined(NACL_IN_TOOLCHAIN_HEADERS)
70 /* file segment locking set data type - information passed to system by user */
81 #endif /* __cplusplus */
83 extern int open(const char *file, int oflag, ...);
84 extern int creat(const char *file, mode_t mode);
85 extern int fcntl(int, int, ...);
89 #endif /* __cplusplus */
90 #endif /* defined(NACL_IN_TOOLCHAIN_HEADERS) */