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