Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/libc/musl/include/fcntl.h
6172 views
1
#ifndef _FCNTL_H
2
#define _FCNTL_H
3
4
#ifdef __EMSCRIPTEN__
5
#include <wasi/api.h>
6
#endif
7
8
#ifdef __cplusplus
9
extern "C" {
10
#endif
11
12
#include <features.h>
13
14
#define __NEED_off_t
15
#define __NEED_pid_t
16
#define __NEED_mode_t
17
18
#ifdef _GNU_SOURCE
19
#define __NEED_size_t
20
#define __NEED_ssize_t
21
#define __NEED_struct_iovec
22
#endif
23
24
#include <bits/alltypes.h>
25
26
#include <bits/fcntl.h>
27
28
struct flock {
29
short l_type;
30
short l_whence;
31
off_t l_start;
32
off_t l_len;
33
pid_t l_pid;
34
};
35
36
int creat(const char *, mode_t);
37
int fcntl(int, int, ...);
38
int open(const char *, int, ...);
39
int openat(int, const char *, int, ...);
40
int posix_fadvise(int, off_t, off_t, int);
41
int posix_fallocate(int, off_t, off_t);
42
43
#define O_SEARCH O_PATH
44
#define O_EXEC O_PATH
45
#define O_TTY_INIT 0
46
47
#define O_ACCMODE (03|O_SEARCH)
48
#define O_RDONLY 00
49
#define O_WRONLY 01
50
#define O_RDWR 02
51
52
#define F_OFD_GETLK 36
53
#define F_OFD_SETLK 37
54
#define F_OFD_SETLKW 38
55
56
#define F_DUPFD_CLOEXEC 1030
57
58
#define F_RDLCK 0
59
#define F_WRLCK 1
60
#define F_UNLCK 2
61
62
#define FD_CLOEXEC 1
63
64
#define AT_FDCWD (-100)
65
#define AT_SYMLINK_NOFOLLOW 0x100
66
#define AT_REMOVEDIR 0x200
67
#define AT_SYMLINK_FOLLOW 0x400
68
#define AT_EACCESS 0x200
69
70
#define POSIX_FADV_NORMAL 0
71
#define POSIX_FADV_RANDOM 1
72
#define POSIX_FADV_SEQUENTIAL 2
73
#define POSIX_FADV_WILLNEED 3
74
#ifndef POSIX_FADV_DONTNEED
75
#define POSIX_FADV_DONTNEED 4
76
#define POSIX_FADV_NOREUSE 5
77
#endif
78
79
#undef SEEK_SET
80
#undef SEEK_CUR
81
#undef SEEK_END
82
#ifdef __EMSCRIPTEN__
83
#define SEEK_SET __WASI_WHENCE_SET
84
#define SEEK_CUR __WASI_WHENCE_CUR
85
#define SEEK_END __WASI_WHENCE_END
86
#else
87
#define SEEK_SET 0
88
#define SEEK_CUR 1
89
#define SEEK_END 2
90
#endif // EMSCRIPTEN
91
92
#ifndef S_IRUSR
93
#define S_ISUID 04000
94
#define S_ISGID 02000
95
#define S_ISVTX 01000
96
#define S_IRUSR 0400
97
#define S_IWUSR 0200
98
#define S_IXUSR 0100
99
#define S_IRWXU 0700
100
#define S_IRGRP 0040
101
#define S_IWGRP 0020
102
#define S_IXGRP 0010
103
#define S_IRWXG 0070
104
#define S_IROTH 0004
105
#define S_IWOTH 0002
106
#define S_IXOTH 0001
107
#define S_IRWXO 0007
108
#endif
109
110
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
111
#define AT_NO_AUTOMOUNT 0x800
112
#define AT_EMPTY_PATH 0x1000
113
#define AT_STATX_SYNC_TYPE 0x6000
114
#define AT_STATX_SYNC_AS_STAT 0x0000
115
#define AT_STATX_FORCE_SYNC 0x2000
116
#define AT_STATX_DONT_SYNC 0x4000
117
#define AT_RECURSIVE 0x8000
118
119
#define FAPPEND O_APPEND
120
#define FFSYNC O_SYNC
121
#define FASYNC O_ASYNC
122
#define FNONBLOCK O_NONBLOCK
123
#define FNDELAY O_NDELAY
124
125
#define F_OK 0
126
#define R_OK 4
127
#define W_OK 2
128
#define X_OK 1
129
#define F_ULOCK 0
130
#define F_LOCK 1
131
#define F_TLOCK 2
132
#define F_TEST 3
133
134
#define F_SETLEASE 1024
135
#define F_GETLEASE 1025
136
#define F_NOTIFY 1026
137
#define F_CANCELLK 1029
138
#define F_SETPIPE_SZ 1031
139
#define F_GETPIPE_SZ 1032
140
#define F_ADD_SEALS 1033
141
#define F_GET_SEALS 1034
142
143
#define F_SEAL_SEAL 0x0001
144
#define F_SEAL_SHRINK 0x0002
145
#define F_SEAL_GROW 0x0004
146
#define F_SEAL_WRITE 0x0008
147
#define F_SEAL_FUTURE_WRITE 0x0010
148
149
#define F_GET_RW_HINT 1035
150
#define F_SET_RW_HINT 1036
151
#define F_GET_FILE_RW_HINT 1037
152
#define F_SET_FILE_RW_HINT 1038
153
154
#define RWF_WRITE_LIFE_NOT_SET 0
155
#define RWH_WRITE_LIFE_NONE 1
156
#define RWH_WRITE_LIFE_SHORT 2
157
#define RWH_WRITE_LIFE_MEDIUM 3
158
#define RWH_WRITE_LIFE_LONG 4
159
#define RWH_WRITE_LIFE_EXTREME 5
160
161
#define DN_ACCESS 0x00000001
162
#define DN_MODIFY 0x00000002
163
#define DN_CREATE 0x00000004
164
#define DN_DELETE 0x00000008
165
#define DN_RENAME 0x00000010
166
#define DN_ATTRIB 0x00000020
167
#define DN_MULTISHOT 0x80000000
168
169
int lockf(int, int, off_t);
170
#endif
171
172
#if defined(_GNU_SOURCE)
173
#define F_OWNER_TID 0
174
#define F_OWNER_PID 1
175
#define F_OWNER_PGRP 2
176
#define F_OWNER_GID 2
177
struct file_handle {
178
unsigned handle_bytes;
179
int handle_type;
180
unsigned char f_handle[];
181
};
182
struct f_owner_ex {
183
int type;
184
pid_t pid;
185
};
186
#define FALLOC_FL_KEEP_SIZE 1
187
#define FALLOC_FL_PUNCH_HOLE 2
188
#define MAX_HANDLE_SZ 128
189
#define SYNC_FILE_RANGE_WAIT_BEFORE 1
190
#define SYNC_FILE_RANGE_WRITE 2
191
#define SYNC_FILE_RANGE_WAIT_AFTER 4
192
#define SPLICE_F_MOVE 1
193
#define SPLICE_F_NONBLOCK 2
194
#define SPLICE_F_MORE 4
195
#define SPLICE_F_GIFT 8
196
int fallocate(int, int, off_t, off_t);
197
int name_to_handle_at(int, const char *, struct file_handle *, int *, int);
198
int open_by_handle_at(int, struct file_handle *, int);
199
ssize_t readahead(int, off_t, size_t);
200
int sync_file_range(int, off_t, off_t, unsigned);
201
ssize_t vmsplice(int, const struct iovec *, size_t, unsigned);
202
ssize_t splice(int, off_t *, int, off_t *, size_t, unsigned);
203
ssize_t tee(int, int, size_t, unsigned);
204
#define loff_t off_t
205
#endif
206
207
#if defined(_LARGEFILE64_SOURCE)
208
#define F_GETLK64 F_GETLK
209
#define F_SETLK64 F_SETLK
210
#define F_SETLKW64 F_SETLKW
211
#define flock64 flock
212
#define open64 open
213
#define openat64 openat
214
#define creat64 creat
215
#define lockf64 lockf
216
#define posix_fadvise64 posix_fadvise
217
#define posix_fallocate64 posix_fallocate
218
#define off64_t off_t
219
#if defined(_GNU_SOURCE)
220
#define fallocate64 fallocate
221
#endif
222
#endif
223
224
#ifdef __cplusplus
225
}
226
#endif
227
228
#endif
229
230