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