]>
git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/include/unistd.h
10 #define STDIN_FILENO 0
11 #define STDOUT_FILENO 1
12 #define STDERR_FILENO 2
14 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
19 #include <__header_unistd.h>
22 #ifdef __wasilibc_unmodified_upstream /* Use the compiler's definition of NULL */
26 #define NULL ((void*)0)
34 #define __NEED_ssize_t
39 #define __NEED_intptr_t
40 #define __NEED_useconds_t
42 #include <bits/alltypes.h>
44 #ifdef __wasilibc_unmodified_upstream /* WASI has no pipe */
46 int pipe2(int [2], int);
49 int posix_close(int, int);
50 #ifdef __wasilibc_unmodified_upstream /* WASI has no dup */
53 int dup3(int, int, int);
55 off_t
lseek(int, off_t
, int);
56 #ifdef __wasilibc_unmodified_upstream /* Optimize the readonly case of lseek */
59 * Optimize lseek in the case where it's just returning the current offset.
60 * This avoids importing `__wasi_fd_seek` altogether in many common cases.
63 off_t
__wasilibc_tell(int);
65 #define lseek(fd, offset, whence) \
68 off_t __o = (offset); \
69 off_t __w = (whence); \
70 __builtin_constant_p((offset)) && \
71 __builtin_constant_p((whence)) && \
74 ? __wasilibc_tell(__f) \
75 : lseek(__f, __o, __w); \
81 ssize_t
read(int, void *, size_t);
82 ssize_t
write(int, const void *, size_t);
83 ssize_t
pread(int, void *, size_t, off_t
);
84 ssize_t
pwrite(int, const void *, size_t, off_t
);
86 #ifdef __wasilibc_unmodified_upstream /* WASI has no chown */
87 int chown(const char *, uid_t
, gid_t
);
88 int fchown(int, uid_t
, gid_t
);
89 int lchown(const char *, uid_t
, gid_t
);
90 int fchownat(int, const char *, uid_t
, gid_t
, int);
93 int link(const char *, const char *);
94 int linkat(int, const char *, int, const char *, int);
95 int symlink(const char *, const char *);
96 int symlinkat(const char *, int, const char *);
97 ssize_t
readlink(const char *__restrict
, char *__restrict
, size_t);
98 ssize_t
readlinkat(int, const char *__restrict
, char *__restrict
, size_t);
99 int unlink(const char *);
100 int unlinkat(int, const char *, int);
101 int rmdir(const char *);
102 int truncate(const char *, off_t
);
103 int ftruncate(int, off_t
);
105 #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */
112 int access(const char *, int);
113 int faccessat(int, const char *, int, int);
115 #ifdef __wasilibc_unmodified_upstream /* WASI has no cwd */
116 int chdir(const char *);
118 char *getcwd(char *, size_t);
121 #ifdef __wasilibc_unmodified_upstream /* WASI has no signals */
122 unsigned alarm(unsigned);
124 unsigned sleep(unsigned);
127 #ifdef __wasilibc_unmodified_upstream /* WASI has no fork/exec */
129 int execve(const char *, char *const [], char *const []);
130 int execv(const char *, char *const []);
131 int execle(const char *, const char *, ...);
132 int execl(const char *, const char *, ...);
133 int execvp(const char *, char *const []);
134 int execlp(const char *, const char *, ...);
135 int fexecve(int, char *const [], char *const []);
137 _Noreturn
void _exit(int);
139 #ifdef __wasilibc_unmodified_upstream /* WASI has no getpid etc. */
143 pid_t
getpgid(pid_t
);
144 int setpgid(pid_t
, pid_t
);
148 #ifdef __wasilibc_unmodified_upstream /* WASI has no ttyname */
150 int ttyname_r(int, char *, size_t);
153 #ifdef __wasilibc_unmodified_upstream /* WASI has no process groups */
154 pid_t
tcgetpgrp(int);
155 int tcsetpgrp(int, pid_t
);
158 #ifdef __wasilibc_unmodified_upstream /* WASI has no getuid etc. */
163 int getgroups(int, gid_t
[]);
170 char *getlogin(void);
171 int getlogin_r(char *, size_t);
172 int gethostname(char *, size_t);
173 char *ctermid(char *);
175 int getopt(int, char * const [], const char *);
177 extern int optind
, opterr
, optopt
;
179 long pathconf(const char *, int);
180 long fpathconf(int, int);
182 size_t confstr(int, char *, size_t);
184 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
189 #ifdef __wasilibc_unmodified_upstream /* WASI has no setreuid */
190 int setreuid(uid_t
, uid_t
);
191 int setregid(gid_t
, gid_t
);
193 #ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
194 int lockf(int, int, off_t
);
196 long gethostid(void);
197 #ifdef __wasilibc_unmodified_upstream /* WASI has no nice, sync, or setpgrp */
202 char *crypt(const char *, const char *);
203 void encrypt(char *, int);
204 void swab(const void *__restrict
, void *__restrict
, ssize_t
);
207 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
208 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
209 int usleep(unsigned);
210 unsigned ualarm(unsigned, unsigned);
213 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
217 #ifdef __wasilibc_unmodified_upstream /* WASI has no brk */
220 void *sbrk(intptr_t);
221 #ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
224 int chroot(const char *);
225 int getpagesize(void);
226 int getdtablesize(void);
227 int sethostname(const char *, size_t);
228 int getdomainname(char *, size_t);
229 int setdomainname(const char *, size_t);
230 int setgroups(size_t, const gid_t
*);
231 char *getpass(const char *);
232 int daemon(int, int);
233 void setusershell(void);
234 void endusershell(void);
235 char *getusershell(void);
236 int acct(const char *);
237 long syscall(long, ...);
238 int execvpe(const char *, char *const [], char *const []);
241 int getentropy(void *, size_t);
245 extern char **environ
;
246 #ifdef __wasilibc_unmodified_upstream /* WASI has no get/setresuid */
247 int setresuid(uid_t
, uid_t
, uid_t
);
248 int setresgid(gid_t
, gid_t
, gid_t
);
249 int getresuid(uid_t
*, uid_t
*, uid_t
*);
250 int getresgid(gid_t
*, gid_t
*, gid_t
*);
252 #ifdef __wasilibc_unmodified_upstream /* WASI has no cwd */
253 char *get_current_dir_name(void);
255 #ifdef __wasilibc_unmodified_upstream /* WASI has no syncfs */
258 #ifdef __wasilibc_unmodified_upstream /* WASI has no eaccess */
259 int euidaccess(const char *, int);
260 int eaccess(const char *, int);
264 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
265 #define lseek64 lseek
266 #define pread64 pread
267 #define pwrite64 pwrite
268 #ifdef __wasilibc_unmodified_upstream /* WASI has no truncate */
269 #define truncate64 truncate
271 #define ftruncate64 ftruncate
272 #ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
273 #define lockf64 lockf
275 #define off64_t off_t
278 #define POSIX_CLOSE_RESTART 0
280 #define _XOPEN_VERSION 700
281 #define _XOPEN_UNIX 1
282 #define _XOPEN_ENH_I18N 1
284 #define _POSIX_VERSION 200809L
285 #define _POSIX2_VERSION _POSIX_VERSION
287 #define _POSIX_ADVISORY_INFO _POSIX_VERSION
288 #define _POSIX_CHOWN_RESTRICTED 1
289 #define _POSIX_IPV6 _POSIX_VERSION
290 #ifdef __wasilibc_unmodified_upstream /* WASI has no processes, mmap, or mq */
291 #define _POSIX_JOB_CONTROL 1
292 #define _POSIX_MAPPED_FILES _POSIX_VERSION
293 #define _POSIX_MEMLOCK _POSIX_VERSION
294 #define _POSIX_MEMLOCK_RANGE _POSIX_VERSION
295 #define _POSIX_MEMORY_PROTECTION _POSIX_VERSION
296 #define _POSIX_MESSAGE_PASSING _POSIX_VERSION
298 #define _POSIX_FSYNC _POSIX_VERSION
299 #define _POSIX_NO_TRUNC 1
300 #ifdef __wasilibc_unmodified_upstream /* WASI has no raw sockets */
301 #define _POSIX_RAW_SOCKETS _POSIX_VERSION
303 #define _POSIX_REALTIME_SIGNALS _POSIX_VERSION
304 #define _POSIX_REGEXP 1
305 #ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
306 #define _POSIX_SAVED_IDS 1
307 #define _POSIX_SHELL 1
308 #define _POSIX_SPAWN _POSIX_VERSION
310 #define _POSIX_VDISABLE 0
312 #define _POSIX_THREADS _POSIX_VERSION
313 #define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
314 #define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
315 #define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
316 #define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION
317 #define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION
318 #define _POSIX_THREAD_CPUTIME _POSIX_VERSION
319 #define _POSIX_TIMERS _POSIX_VERSION
320 #define _POSIX_TIMEOUTS _POSIX_VERSION
321 #define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
322 #define _POSIX_CPUTIME _POSIX_VERSION
323 #define _POSIX_CLOCK_SELECTION _POSIX_VERSION
324 #define _POSIX_BARRIERS _POSIX_VERSION
325 #define _POSIX_SPIN_LOCKS _POSIX_VERSION
326 #define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
327 #ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX async I/O, semaphores, or shared memory */
328 #define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
329 #define _POSIX_SEMAPHORES _POSIX_VERSION
330 #define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION
333 #define _POSIX2_C_BIND _POSIX_VERSION
335 #include <bits/posix.h>
339 #define _PC_LINK_MAX 0
340 #define _PC_MAX_CANON 1
341 #define _PC_MAX_INPUT 2
342 #define _PC_NAME_MAX 3
343 #define _PC_PATH_MAX 4
344 #define _PC_PIPE_BUF 5
345 #define _PC_CHOWN_RESTRICTED 6
346 #define _PC_NO_TRUNC 7
347 #define _PC_VDISABLE 8
348 #define _PC_SYNC_IO 9
349 #define _PC_ASYNC_IO 10
350 #define _PC_PRIO_IO 11
351 #define _PC_SOCK_MAXBUF 12
352 #define _PC_FILESIZEBITS 13
353 #define _PC_REC_INCR_XFER_SIZE 14
354 #define _PC_REC_MAX_XFER_SIZE 15
355 #define _PC_REC_MIN_XFER_SIZE 16
356 #define _PC_REC_XFER_ALIGN 17
357 #define _PC_ALLOC_SIZE_MIN 18
358 #define _PC_SYMLINK_MAX 19
359 #define _PC_2_SYMLINKS 20
361 #define _SC_ARG_MAX 0
362 #define _SC_CHILD_MAX 1
363 #define _SC_CLK_TCK 2
364 #define _SC_NGROUPS_MAX 3
365 #define _SC_OPEN_MAX 4
366 #define _SC_STREAM_MAX 5
367 #define _SC_TZNAME_MAX 6
368 #define _SC_JOB_CONTROL 7
369 #define _SC_SAVED_IDS 8
370 #define _SC_REALTIME_SIGNALS 9
371 #define _SC_PRIORITY_SCHEDULING 10
372 #define _SC_TIMERS 11
373 #define _SC_ASYNCHRONOUS_IO 12
374 #define _SC_PRIORITIZED_IO 13
375 #define _SC_SYNCHRONIZED_IO 14
377 #define _SC_MAPPED_FILES 16
378 #define _SC_MEMLOCK 17
379 #define _SC_MEMLOCK_RANGE 18
380 #define _SC_MEMORY_PROTECTION 19
381 #define _SC_MESSAGE_PASSING 20
382 #define _SC_SEMAPHORES 21
383 #define _SC_SHARED_MEMORY_OBJECTS 22
384 #define _SC_AIO_LISTIO_MAX 23
385 #define _SC_AIO_MAX 24
386 #define _SC_AIO_PRIO_DELTA_MAX 25
387 #define _SC_DELAYTIMER_MAX 26
388 #define _SC_MQ_OPEN_MAX 27
389 #define _SC_MQ_PRIO_MAX 28
390 #define _SC_VERSION 29
391 #define _SC_PAGE_SIZE 30
392 #define _SC_PAGESIZE 30 /* !! */
393 #define _SC_RTSIG_MAX 31
394 #define _SC_SEM_NSEMS_MAX 32
395 #define _SC_SEM_VALUE_MAX 33
396 #define _SC_SIGQUEUE_MAX 34
397 #define _SC_TIMER_MAX 35
398 #define _SC_BC_BASE_MAX 36
399 #define _SC_BC_DIM_MAX 37
400 #define _SC_BC_SCALE_MAX 38
401 #define _SC_BC_STRING_MAX 39
402 #define _SC_COLL_WEIGHTS_MAX 40
403 #define _SC_EXPR_NEST_MAX 42
404 #define _SC_LINE_MAX 43
405 #define _SC_RE_DUP_MAX 44
406 #define _SC_2_VERSION 46
407 #define _SC_2_C_BIND 47
408 #define _SC_2_C_DEV 48
409 #define _SC_2_FORT_DEV 49
410 #define _SC_2_FORT_RUN 50
411 #define _SC_2_SW_DEV 51
412 #define _SC_2_LOCALEDEF 52
413 #define _SC_UIO_MAXIOV 60 /* !! */
414 #define _SC_IOV_MAX 60
415 #define _SC_THREADS 67
416 #define _SC_THREAD_SAFE_FUNCTIONS 68
417 #define _SC_GETGR_R_SIZE_MAX 69
418 #define _SC_GETPW_R_SIZE_MAX 70
419 #define _SC_LOGIN_NAME_MAX 71
420 #define _SC_TTY_NAME_MAX 72
421 #define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
422 #define _SC_THREAD_KEYS_MAX 74
423 #define _SC_THREAD_STACK_MIN 75
424 #define _SC_THREAD_THREADS_MAX 76
425 #define _SC_THREAD_ATTR_STACKADDR 77
426 #define _SC_THREAD_ATTR_STACKSIZE 78
427 #define _SC_THREAD_PRIORITY_SCHEDULING 79
428 #define _SC_THREAD_PRIO_INHERIT 80
429 #define _SC_THREAD_PRIO_PROTECT 81
430 #define _SC_THREAD_PROCESS_SHARED 82
431 #define _SC_NPROCESSORS_CONF 83
432 #define _SC_NPROCESSORS_ONLN 84
433 #define _SC_PHYS_PAGES 85
434 #define _SC_AVPHYS_PAGES 86
435 #define _SC_ATEXIT_MAX 87
436 #define _SC_PASS_MAX 88
437 #define _SC_XOPEN_VERSION 89
438 #define _SC_XOPEN_XCU_VERSION 90
439 #define _SC_XOPEN_UNIX 91
440 #define _SC_XOPEN_CRYPT 92
441 #define _SC_XOPEN_ENH_I18N 93
442 #define _SC_XOPEN_SHM 94
443 #define _SC_2_CHAR_TERM 95
445 #define _SC_XOPEN_XPG2 98
446 #define _SC_XOPEN_XPG3 99
447 #define _SC_XOPEN_XPG4 100
448 #define _SC_NZERO 109
449 #define _SC_XBS5_ILP32_OFF32 125
450 #define _SC_XBS5_ILP32_OFFBIG 126
451 #define _SC_XBS5_LP64_OFF64 127
452 #define _SC_XBS5_LPBIG_OFFBIG 128
453 #define _SC_XOPEN_LEGACY 129
454 #define _SC_XOPEN_REALTIME 130
455 #define _SC_XOPEN_REALTIME_THREADS 131
456 #define _SC_ADVISORY_INFO 132
457 #define _SC_BARRIERS 133
458 #define _SC_CLOCK_SELECTION 137
459 #define _SC_CPUTIME 138
460 #define _SC_THREAD_CPUTIME 139
461 #define _SC_MONOTONIC_CLOCK 149
462 #define _SC_READER_WRITER_LOCKS 153
463 #define _SC_SPIN_LOCKS 154
464 #define _SC_REGEXP 155
465 #define _SC_SHELL 157
466 #define _SC_SPAWN 159
467 #define _SC_SPORADIC_SERVER 160
468 #define _SC_THREAD_SPORADIC_SERVER 161
469 #define _SC_TIMEOUTS 164
470 #define _SC_TYPED_MEMORY_OBJECTS 165
471 #define _SC_2_PBS 168
472 #define _SC_2_PBS_ACCOUNTING 169
473 #define _SC_2_PBS_LOCATE 170
474 #define _SC_2_PBS_MESSAGE 171
475 #define _SC_2_PBS_TRACK 172
476 #define _SC_SYMLOOP_MAX 173
477 #define _SC_STREAMS 174
478 #define _SC_2_PBS_CHECKPOINT 175
479 #define _SC_V6_ILP32_OFF32 176
480 #define _SC_V6_ILP32_OFFBIG 177
481 #define _SC_V6_LP64_OFF64 178
482 #define _SC_V6_LPBIG_OFFBIG 179
483 #define _SC_HOST_NAME_MAX 180
484 #define _SC_TRACE 181
485 #define _SC_TRACE_EVENT_FILTER 182
486 #define _SC_TRACE_INHERIT 183
487 #define _SC_TRACE_LOG 184
490 #define _SC_RAW_SOCKETS 236
491 #define _SC_V7_ILP32_OFF32 237
492 #define _SC_V7_ILP32_OFFBIG 238
493 #define _SC_V7_LP64_OFF64 239
494 #define _SC_V7_LPBIG_OFFBIG 240
495 #define _SC_SS_REPL_MAX 241
496 #define _SC_TRACE_EVENT_NAME_MAX 242
497 #define _SC_TRACE_NAME_MAX 243
498 #define _SC_TRACE_SYS_MAX 244
499 #define _SC_TRACE_USER_EVENT_MAX 245
500 #define _SC_XOPEN_STREAMS 246
501 #define _SC_THREAD_ROBUST_PRIO_INHERIT 247
502 #define _SC_THREAD_ROBUST_PRIO_PROTECT 248
505 #define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 1
506 #define _CS_GNU_LIBC_VERSION 2
507 #define _CS_GNU_LIBPTHREAD_VERSION 3
508 #define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS 4
509 #define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 5
511 #define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 1116
512 #define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 1117
513 #define _CS_POSIX_V6_ILP32_OFF32_LIBS 1118
514 #define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 1119
515 #define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 1120
516 #define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 1121
517 #define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 1122
518 #define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 1123
519 #define _CS_POSIX_V6_LP64_OFF64_CFLAGS 1124
520 #define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 1125
521 #define _CS_POSIX_V6_LP64_OFF64_LIBS 1126
522 #define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 1127
523 #define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 1128
524 #define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 1129
525 #define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 1130
526 #define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 1131
527 #define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1132
528 #define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 1133
529 #define _CS_POSIX_V7_ILP32_OFF32_LIBS 1134
530 #define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS 1135
531 #define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 1136
532 #define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 1137
533 #define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 1138
534 #define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS 1139
535 #define _CS_POSIX_V7_LP64_OFF64_CFLAGS 1140
536 #define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 1141
537 #define _CS_POSIX_V7_LP64_OFF64_LIBS 1142
538 #define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS 1143
539 #define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 1144
540 #define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 1145
541 #define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 1146
542 #define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS 1147
543 #define _CS_V6_ENV 1148
544 #define _CS_V7_ENV 1149