• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef	_UNISTD_H
2 #define	_UNISTD_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <features.h>
9 
10 #define STDIN_FILENO  0
11 #define STDOUT_FILENO 1
12 #define STDERR_FILENO 2
13 
14 #define SEEK_SET 0
15 #define SEEK_CUR 1
16 #define SEEK_END 2
17 #define SEEK_DATA 3
18 #define SEEK_HOLE 4
19 
20 #if __cplusplus >= 201103L
21 #define NULL nullptr
22 #elif defined(__cplusplus)
23 #define NULL 0L
24 #else
25 #define NULL ((void*)0)
26 #endif
27 
28 #define __NEED_size_t
29 #define __NEED_ssize_t
30 #define __NEED_uid_t
31 #define __NEED_gid_t
32 #define __NEED_off_t
33 #define __NEED_pid_t
34 #define __NEED_intptr_t
35 #define __NEED_useconds_t
36 
37 #include <bits/alltypes.h>
38 
39 int pipe(int [2]);
40 int pipe2(int [2], int);
41 int close(int);
42 int posix_close(int, int);
43 int dup(int);
44 int dup2(int, int);
45 int dup3(int, int, int);
46 off_t lseek(int, off_t, int);
47 int fsync(int);
48 int fdatasync(int);
49 
50 ssize_t read(int, void *, size_t);
51 ssize_t write(int, const void *, size_t);
52 ssize_t pread(int, void *, size_t, off_t);
53 ssize_t pwrite(int, const void *, size_t, off_t);
54 
55 int chown(const char *, uid_t, gid_t);
56 int fchown(int, uid_t, gid_t);
57 int lchown(const char *, uid_t, gid_t);
58 int fchownat(int, const char *, uid_t, gid_t, int);
59 
60 int link(const char *, const char *);
61 int linkat(int, const char *, int, const char *, int);
62 int symlink(const char *, const char *);
63 int symlinkat(const char *, int, const char *);
64 ssize_t readlink(const char *__restrict, char *__restrict, size_t);
65 ssize_t readlinkat(int, const char *__restrict, char *__restrict, size_t);
66 int unlink(const char *);
67 int unlinkat(int, const char *, int);
68 int rmdir(const char *);
69 int truncate(const char *, off_t);
70 int ftruncate(int, off_t);
71 
72 #define F_OK 0
73 #define R_OK 4
74 #define W_OK 2
75 #define X_OK 1
76 
77 int access(const char *, int);
78 int faccessat(int, const char *, int, int);
79 
80 int chdir(const char *);
81 int fchdir(int);
82 char *getcwd(char *, size_t);
83 
84 unsigned alarm(unsigned);
85 unsigned sleep(unsigned);
86 int pause(void);
87 
88 pid_t fork(void);
89 pid_t _Fork(void);
90 int execve(const char *, char *const [], char *const []);
91 int execv(const char *, char *const []);
92 int execle(const char *, const char *, ...);
93 int execl(const char *, const char *, ...);
94 int execvp(const char *, char *const []);
95 int execlp(const char *, const char *, ...);
96 int fexecve(int, char *const [], char *const []);
97 _Noreturn void _exit(int);
98 
99 pid_t getpid(void);
100 pid_t getppid(void);
101 pid_t getpgrp(void);
102 pid_t getpgid(pid_t);
103 int setpgid(pid_t, pid_t);
104 pid_t setsid(void);
105 pid_t getsid(pid_t);
106 char *ttyname(int);
107 int ttyname_r(int, char *, size_t);
108 int isatty(int);
109 pid_t tcgetpgrp(int);
110 int tcsetpgrp(int, pid_t);
111 
112 uid_t getuid(void);
113 uid_t geteuid(void);
114 gid_t getgid(void);
115 gid_t getegid(void);
116 int getgroups(int, gid_t []);
117 int setuid(uid_t);
118 int seteuid(uid_t);
119 int setgid(gid_t);
120 int setegid(gid_t);
121 
122 char *getlogin(void);
123 int getlogin_r(char *, size_t);
124 int gethostname(char *, size_t);
125 char *ctermid(char *);
126 
127 int getopt(int, char * const [], const char *);
128 extern char *optarg;
129 extern int optind, opterr, optopt;
130 
131 long pathconf(const char *, int);
132 long fpathconf(int, int);
133 long sysconf(int);
134 size_t confstr(int, char *, size_t);
135 
136 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
137 #define F_ULOCK 0
138 #define F_LOCK  1
139 #define F_TLOCK 2
140 #define F_TEST  3
141 int setreuid(uid_t, uid_t);
142 int setregid(gid_t, gid_t);
143 int lockf(int, int, off_t);
144 long gethostid(void);
145 int nice(int);
146 void sync(void);
147 pid_t setpgrp(void);
148 char *crypt(const char *, const char *);
149 void encrypt(char *, int);
150 void swab(const void *__restrict, void *__restrict, ssize_t);
151 #endif
152 
153 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
154  || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
155 int usleep(unsigned);
156 unsigned ualarm(unsigned, unsigned);
157 #endif
158 
159 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
160 #define L_SET 0
161 #define L_INCR 1
162 #define L_XTND 2
163 int brk(void *);
164 void *sbrk(intptr_t);
165 pid_t vfork(void);
166 int vhangup(void);
167 int chroot(const char *);
168 int getpagesize(void);
169 int getdtablesize(void);
170 int sethostname(const char *, size_t);
171 int getdomainname(char *, size_t);
172 int setdomainname(const char *, size_t);
173 int setgroups(size_t, const gid_t *);
174 char *getpass(const char *);
175 int daemon(int, int);
176 void setusershell(void);
177 void endusershell(void);
178 char *getusershell(void);
179 int acct(const char *);
180 long syscall(long, ...);
181 int execvpe(const char *, char *const [], char *const []);
182 int issetugid(void);
183 int getentropy(void *, size_t);
184 extern int optreset;
185 #endif
186 
187 #ifdef _GNU_SOURCE
188 extern char **environ;
189 int setresuid(uid_t, uid_t, uid_t);
190 int setresgid(gid_t, gid_t, gid_t);
191 int getresuid(uid_t *, uid_t *, uid_t *);
192 int getresgid(gid_t *, gid_t *, gid_t *);
193 char *get_current_dir_name(void);
194 int syncfs(int);
195 int euidaccess(const char *, int);
196 int eaccess(const char *, int);
197 ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned);
198 pid_t gettid(void);
199 #endif
200 
201 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
202 #define lseek64 lseek
203 #define pread64 pread
204 #define pwrite64 pwrite
205 #define truncate64 truncate
206 #define ftruncate64 ftruncate
207 #define lockf64 lockf
208 #define off64_t off_t
209 #endif
210 
211 #define POSIX_CLOSE_RESTART     0
212 
213 #define _XOPEN_VERSION          700
214 #define _XOPEN_UNIX             1
215 #define _XOPEN_ENH_I18N         1
216 
217 #define _POSIX_VERSION          200809L
218 #define _POSIX2_VERSION         _POSIX_VERSION
219 
220 #define _POSIX_ADVISORY_INFO    _POSIX_VERSION
221 #define _POSIX_CHOWN_RESTRICTED 1
222 #define _POSIX_IPV6             _POSIX_VERSION
223 #define _POSIX_JOB_CONTROL      1
224 #define _POSIX_MAPPED_FILES     _POSIX_VERSION
225 #define _POSIX_MEMLOCK          _POSIX_VERSION
226 #define _POSIX_MEMLOCK_RANGE    _POSIX_VERSION
227 #define _POSIX_MEMORY_PROTECTION _POSIX_VERSION
228 #define _POSIX_MESSAGE_PASSING  _POSIX_VERSION
229 #define _POSIX_FSYNC            _POSIX_VERSION
230 #define _POSIX_NO_TRUNC         1
231 #define _POSIX_RAW_SOCKETS      _POSIX_VERSION
232 #define _POSIX_REALTIME_SIGNALS _POSIX_VERSION
233 #define _POSIX_REGEXP           1
234 #define _POSIX_SAVED_IDS        1
235 #define _POSIX_SHELL            1
236 #define _POSIX_SPAWN            _POSIX_VERSION
237 #define _POSIX_VDISABLE         0
238 
239 #define _POSIX_THREADS          _POSIX_VERSION
240 #define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
241 #define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
242 #define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
243 #define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION
244 #define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION
245 #define _POSIX_THREAD_CPUTIME   _POSIX_VERSION
246 #define _POSIX_TIMERS           _POSIX_VERSION
247 #define _POSIX_TIMEOUTS         _POSIX_VERSION
248 #define _POSIX_MONOTONIC_CLOCK  _POSIX_VERSION
249 #define _POSIX_CPUTIME          _POSIX_VERSION
250 #define _POSIX_CLOCK_SELECTION  _POSIX_VERSION
251 #define _POSIX_BARRIERS         _POSIX_VERSION
252 #define _POSIX_SPIN_LOCKS       _POSIX_VERSION
253 #define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
254 #define _POSIX_ASYNCHRONOUS_IO  _POSIX_VERSION
255 #define _POSIX_SEMAPHORES       _POSIX_VERSION
256 #define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION
257 
258 #define _POSIX2_C_BIND          _POSIX_VERSION
259 
260 #include <bits/posix.h>
261 
262 
263 
264 #define _PC_LINK_MAX	0
265 #define _PC_MAX_CANON	1
266 #define _PC_MAX_INPUT	2
267 #define _PC_NAME_MAX	3
268 #define _PC_PATH_MAX	4
269 #define _PC_PIPE_BUF	5
270 #define _PC_CHOWN_RESTRICTED	6
271 #define _PC_NO_TRUNC	7
272 #define _PC_VDISABLE	8
273 #define _PC_SYNC_IO	9
274 #define _PC_ASYNC_IO	10
275 #define _PC_PRIO_IO	11
276 #define _PC_SOCK_MAXBUF	12
277 #define _PC_FILESIZEBITS	13
278 #define _PC_REC_INCR_XFER_SIZE	14
279 #define _PC_REC_MAX_XFER_SIZE	15
280 #define _PC_REC_MIN_XFER_SIZE	16
281 #define _PC_REC_XFER_ALIGN	17
282 #define _PC_ALLOC_SIZE_MIN	18
283 #define _PC_SYMLINK_MAX	19
284 #define _PC_2_SYMLINKS	20
285 
286 #define _SC_ARG_MAX	0
287 #define _SC_CHILD_MAX	1
288 #define _SC_CLK_TCK	2
289 #define _SC_NGROUPS_MAX	3
290 #define _SC_OPEN_MAX	4
291 #define _SC_STREAM_MAX	5
292 #define _SC_TZNAME_MAX	6
293 #define _SC_JOB_CONTROL	7
294 #define _SC_SAVED_IDS	8
295 #define _SC_REALTIME_SIGNALS	9
296 #define _SC_PRIORITY_SCHEDULING	10
297 #define _SC_TIMERS	11
298 #define _SC_ASYNCHRONOUS_IO	12
299 #define _SC_PRIORITIZED_IO	13
300 #define _SC_SYNCHRONIZED_IO	14
301 #define _SC_FSYNC	15
302 #define _SC_MAPPED_FILES	16
303 #define _SC_MEMLOCK	17
304 #define _SC_MEMLOCK_RANGE	18
305 #define _SC_MEMORY_PROTECTION	19
306 #define _SC_MESSAGE_PASSING	20
307 #define _SC_SEMAPHORES	21
308 #define _SC_SHARED_MEMORY_OBJECTS	22
309 #define _SC_AIO_LISTIO_MAX	23
310 #define _SC_AIO_MAX	24
311 #define _SC_AIO_PRIO_DELTA_MAX	25
312 #define _SC_DELAYTIMER_MAX	26
313 #define _SC_MQ_OPEN_MAX	27
314 #define _SC_MQ_PRIO_MAX	28
315 #define _SC_VERSION	29
316 #define _SC_PAGE_SIZE	30
317 #define _SC_PAGESIZE	30 /* !! */
318 #define _SC_RTSIG_MAX	31
319 #define _SC_SEM_NSEMS_MAX	32
320 #define _SC_SEM_VALUE_MAX	33
321 #define _SC_SIGQUEUE_MAX	34
322 #define _SC_TIMER_MAX	35
323 #define _SC_BC_BASE_MAX	36
324 #define _SC_BC_DIM_MAX	37
325 #define _SC_BC_SCALE_MAX	38
326 #define _SC_BC_STRING_MAX	39
327 #define _SC_COLL_WEIGHTS_MAX	40
328 #define _SC_EXPR_NEST_MAX	42
329 #define _SC_LINE_MAX	43
330 #define _SC_RE_DUP_MAX	44
331 #define _SC_2_VERSION	46
332 #define _SC_2_C_BIND	47
333 #define _SC_2_C_DEV	48
334 #define _SC_2_FORT_DEV	49
335 #define _SC_2_FORT_RUN	50
336 #define _SC_2_SW_DEV	51
337 #define _SC_2_LOCALEDEF	52
338 #define _SC_UIO_MAXIOV	60 /* !! */
339 #define _SC_IOV_MAX	60
340 #define _SC_THREADS	67
341 #define _SC_THREAD_SAFE_FUNCTIONS	68
342 #define _SC_GETGR_R_SIZE_MAX	69
343 #define _SC_GETPW_R_SIZE_MAX	70
344 #define _SC_LOGIN_NAME_MAX	71
345 #define _SC_TTY_NAME_MAX	72
346 #define _SC_THREAD_DESTRUCTOR_ITERATIONS	73
347 #define _SC_THREAD_KEYS_MAX	74
348 #define _SC_THREAD_STACK_MIN	75
349 #define _SC_THREAD_THREADS_MAX	76
350 #define _SC_THREAD_ATTR_STACKADDR	77
351 #define _SC_THREAD_ATTR_STACKSIZE	78
352 #define _SC_THREAD_PRIORITY_SCHEDULING	79
353 #define _SC_THREAD_PRIO_INHERIT	80
354 #define _SC_THREAD_PRIO_PROTECT	81
355 #define _SC_THREAD_PROCESS_SHARED	82
356 #define _SC_NPROCESSORS_CONF	83
357 #define _SC_NPROCESSORS_ONLN	84
358 #define _SC_PHYS_PAGES	85
359 #define _SC_AVPHYS_PAGES	86
360 #define _SC_ATEXIT_MAX	87
361 #define _SC_PASS_MAX	88
362 #define _SC_XOPEN_VERSION	89
363 #define _SC_XOPEN_XCU_VERSION	90
364 #define _SC_XOPEN_UNIX	91
365 #define _SC_XOPEN_CRYPT	92
366 #define _SC_XOPEN_ENH_I18N	93
367 #define _SC_XOPEN_SHM	94
368 #define _SC_2_CHAR_TERM	95
369 #define _SC_2_UPE	97
370 #define _SC_XOPEN_XPG2	98
371 #define _SC_XOPEN_XPG3	99
372 #define _SC_XOPEN_XPG4	100
373 #define _SC_NZERO	109
374 #define _SC_XBS5_ILP32_OFF32	125
375 #define _SC_XBS5_ILP32_OFFBIG	126
376 #define _SC_XBS5_LP64_OFF64	127
377 #define _SC_XBS5_LPBIG_OFFBIG	128
378 #define _SC_XOPEN_LEGACY	129
379 #define _SC_XOPEN_REALTIME	130
380 #define _SC_XOPEN_REALTIME_THREADS	131
381 #define _SC_ADVISORY_INFO	132
382 #define _SC_BARRIERS	133
383 #define _SC_CLOCK_SELECTION	137
384 #define _SC_CPUTIME	138
385 #define _SC_THREAD_CPUTIME	139
386 #define _SC_MONOTONIC_CLOCK	149
387 #define _SC_READER_WRITER_LOCKS	153
388 #define _SC_SPIN_LOCKS	154
389 #define _SC_REGEXP	155
390 #define _SC_SHELL	157
391 #define _SC_SPAWN	159
392 #define _SC_SPORADIC_SERVER	160
393 #define _SC_THREAD_SPORADIC_SERVER	161
394 #define _SC_TIMEOUTS	164
395 #define _SC_TYPED_MEMORY_OBJECTS	165
396 #define _SC_2_PBS	168
397 #define _SC_2_PBS_ACCOUNTING	169
398 #define _SC_2_PBS_LOCATE	170
399 #define _SC_2_PBS_MESSAGE	171
400 #define _SC_2_PBS_TRACK	172
401 #define _SC_SYMLOOP_MAX	173
402 #define _SC_STREAMS	174
403 #define _SC_2_PBS_CHECKPOINT	175
404 #define _SC_V6_ILP32_OFF32	176
405 #define _SC_V6_ILP32_OFFBIG	177
406 #define _SC_V6_LP64_OFF64	178
407 #define _SC_V6_LPBIG_OFFBIG	179
408 #define _SC_HOST_NAME_MAX	180
409 #define _SC_TRACE	181
410 #define _SC_TRACE_EVENT_FILTER	182
411 #define _SC_TRACE_INHERIT	183
412 #define _SC_TRACE_LOG	184
413 
414 #define _SC_IPV6	235
415 #define _SC_RAW_SOCKETS	236
416 #define _SC_V7_ILP32_OFF32	237
417 #define _SC_V7_ILP32_OFFBIG	238
418 #define _SC_V7_LP64_OFF64	239
419 #define _SC_V7_LPBIG_OFFBIG	240
420 #define _SC_SS_REPL_MAX	241
421 #define _SC_TRACE_EVENT_NAME_MAX	242
422 #define _SC_TRACE_NAME_MAX	243
423 #define _SC_TRACE_SYS_MAX	244
424 #define _SC_TRACE_USER_EVENT_MAX	245
425 #define _SC_XOPEN_STREAMS	246
426 #define _SC_THREAD_ROBUST_PRIO_INHERIT	247
427 #define _SC_THREAD_ROBUST_PRIO_PROTECT	248
428 #define _SC_MINSIGSTKSZ	249
429 #define _SC_SIGSTKSZ	250
430 
431 #define _CS_PATH	0
432 #define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS	1
433 #define _CS_GNU_LIBC_VERSION	2
434 #define _CS_GNU_LIBPTHREAD_VERSION	3
435 #define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS	4
436 #define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS	5
437 
438 #define _CS_POSIX_V6_ILP32_OFF32_CFLAGS	1116
439 #define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS	1117
440 #define _CS_POSIX_V6_ILP32_OFF32_LIBS	1118
441 #define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS	1119
442 #define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS	1120
443 #define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS	1121
444 #define _CS_POSIX_V6_ILP32_OFFBIG_LIBS	1122
445 #define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS	1123
446 #define _CS_POSIX_V6_LP64_OFF64_CFLAGS	1124
447 #define _CS_POSIX_V6_LP64_OFF64_LDFLAGS	1125
448 #define _CS_POSIX_V6_LP64_OFF64_LIBS	1126
449 #define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS	1127
450 #define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS	1128
451 #define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS	1129
452 #define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS	1130
453 #define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS	1131
454 #define _CS_POSIX_V7_ILP32_OFF32_CFLAGS	1132
455 #define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS	1133
456 #define _CS_POSIX_V7_ILP32_OFF32_LIBS	1134
457 #define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS	1135
458 #define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS	1136
459 #define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS	1137
460 #define _CS_POSIX_V7_ILP32_OFFBIG_LIBS	1138
461 #define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS	1139
462 #define _CS_POSIX_V7_LP64_OFF64_CFLAGS	1140
463 #define _CS_POSIX_V7_LP64_OFF64_LDFLAGS	1141
464 #define _CS_POSIX_V7_LP64_OFF64_LIBS	1142
465 #define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS	1143
466 #define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS	1144
467 #define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS	1145
468 #define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS	1146
469 #define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS	1147
470 #define _CS_V6_ENV	1148
471 #define _CS_V7_ENV	1149
472 #define _CS_POSIX_V7_THREADS_CFLAGS	1150
473 #define _CS_POSIX_V7_THREADS_LDFLAGS	1151
474 
475 #ifdef __cplusplus
476 }
477 #endif
478 
479 #endif
480