Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / native_client / src / trusted / service_runtime / include / sys / fcntl.h
1 /*
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.
5  */
6
7 /*
8  * NaCl Service Runtime API.
9  */
10
11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_SYS_FCNTL_H_
12 #define NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_INCLUDE_SYS_FCNTL_H_
13
14 #if defined(NACL_IN_TOOLCHAIN_HEADERS)
15 #include <sys/types.h>
16 #endif
17
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
23
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
27
28 /*
29  * Features not implemented by NaCl, but required by the newlib build.
30  */
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
37
38 /* XXX close on exec request; must match UF_EXCLOSE in user.h */
39 #define FD_CLOEXEC  1 /* posix */
40
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 */
47 #ifndef _POSIX_SOURCE
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) */
54 #ifndef _POSIX_SOURCE
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 */
60
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) */
65 #ifndef _POSIX_SOURCE
66 #define NACL_ABI_F_UNLKSYS 4 /* remove remote locks for a given system */
67 #endif  /* !_POSIX_SOURCE */
68
69 #if defined(NACL_IN_TOOLCHAIN_HEADERS)
70 /* file segment locking set data type - information passed to system by user */
71 struct flock {
72   short l_type;
73   short l_whence;
74   off_t l_start;
75   off_t l_len;
76   pid_t l_pid;
77 };
78
79 #ifdef __cplusplus
80 extern "C" {
81 #endif  /* __cplusplus */
82
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, ...);
86
87 #ifdef __cplusplus
88 }  /* extern "C" */
89 #endif  /* __cplusplus */
90 #endif  /* defined(NACL_IN_TOOLCHAIN_HEADERS) */
91
92 #endif