]>
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 #ifdef __wasilibc_unmodified_upstream /* WASI has no getpid etc. */
152 pid_t
getpgid(pid_t
);
153 int setpgid(pid_t
, pid_t
);
157 #ifdef __wasilibc_unmodified_upstream /* WASI has no ttyname */
159 int ttyname_r(int, char *, size_t);
162 #ifdef __wasilibc_unmodified_upstream /* WASI has no process groups */
163 pid_t
tcgetpgrp(int);
164 int tcsetpgrp(int, pid_t
);
167 #ifdef __wasilibc_unmodified_upstream /* WASI has no getuid etc. */
172 int getgroups(int, gid_t
[]);
179 char *getlogin(void);
180 int getlogin_r(char *, size_t);
181 int gethostname(char *, size_t);
182 char *ctermid(char *);
184 int getopt(int, char * const [], const char *);
186 extern int optind
, opterr
, optopt
;
188 long pathconf(const char *, int);
189 long fpathconf(int, int);
191 size_t confstr(int, char *, size_t);
193 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
198 #ifdef __wasilibc_unmodified_upstream /* WASI has no setreuid */
199 int setreuid(uid_t
, uid_t
);
200 int setregid(gid_t
, gid_t
);
202 #ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
203 int lockf(int, int, off_t
);
205 long gethostid(void);
206 #ifdef __wasilibc_unmodified_upstream /* WASI has no nice, sync, or setpgrp */
211 char *crypt(const char *, const char *);
212 void encrypt(char *, int);
213 void swab(const void *__restrict
, void *__restrict
, ssize_t
);
216 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) \
217 || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE+0 < 700)
218 int usleep(unsigned);
219 unsigned ualarm(unsigned, unsigned);
222 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
226 #ifdef __wasilibc_unmodified_upstream /* WASI has no brk */
229 void *sbrk(intptr_t);
230 #ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
233 int chroot(const char *);
234 int getpagesize(void);
235 int getdtablesize(void);
236 int sethostname(const char *, size_t);
237 int getdomainname(char *, size_t);
238 int setdomainname(const char *, size_t);
239 int setgroups(size_t, const gid_t
*);
240 char *getpass(const char *);
241 int daemon(int, int);
242 void setusershell(void);
243 void endusershell(void);
244 char *getusershell(void);
245 int acct(const char *);
246 long syscall(long, ...);
247 int execvpe(const char *, char *const [], char *const []);
250 int getentropy(void *, size_t);
255 extern char **environ
;
256 #ifdef __wasilibc_unmodified_upstream /* WASI has no get/setresuid */
257 int setresuid(uid_t
, uid_t
, uid_t
);
258 int setresgid(gid_t
, gid_t
, gid_t
);
259 int getresuid(uid_t
*, uid_t
*, uid_t
*);
260 int getresgid(gid_t
*, gid_t
*, gid_t
*);
262 #ifdef __wasilibc_unmodified_upstream /* WASI has no cwd */
263 char *get_current_dir_name(void);
265 #ifdef __wasilibc_unmodified_upstream /* WASI has no syncfs */
268 #ifdef __wasilibc_unmodified_upstream /* WASI has no eaccess */
269 int euidaccess(const char *, int);
270 int eaccess(const char *, int);
271 ssize_t
copy_file_range(int, off_t
*, int, off_t
*, size_t, unsigned);
276 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
277 #define lseek64 lseek
278 #define pread64 pread
279 #define pwrite64 pwrite
280 #ifdef __wasilibc_unmodified_upstream /* WASI has no truncate */
281 #define truncate64 truncate
283 #define ftruncate64 ftruncate
284 #ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX file locking */
285 #define lockf64 lockf
287 #define off64_t off_t
290 #define POSIX_CLOSE_RESTART 0
292 #define _XOPEN_VERSION 700
293 #define _XOPEN_UNIX 1
294 #define _XOPEN_ENH_I18N 1
296 #define _POSIX_VERSION 200809L
297 #define _POSIX2_VERSION _POSIX_VERSION
299 #define _POSIX_ADVISORY_INFO _POSIX_VERSION
300 #define _POSIX_CHOWN_RESTRICTED 1
301 #define _POSIX_IPV6 _POSIX_VERSION
302 #ifdef __wasilibc_unmodified_upstream /* WASI has no processes, mmap, or mq */
303 #define _POSIX_JOB_CONTROL 1
304 #define _POSIX_MAPPED_FILES _POSIX_VERSION
305 #define _POSIX_MEMLOCK _POSIX_VERSION
306 #define _POSIX_MEMLOCK_RANGE _POSIX_VERSION
307 #define _POSIX_MEMORY_PROTECTION _POSIX_VERSION
308 #define _POSIX_MESSAGE_PASSING _POSIX_VERSION
310 #define _POSIX_FSYNC _POSIX_VERSION
311 #define _POSIX_NO_TRUNC 1
312 #ifdef __wasilibc_unmodified_upstream /* WASI has no raw sockets */
313 #define _POSIX_RAW_SOCKETS _POSIX_VERSION
315 #define _POSIX_REALTIME_SIGNALS _POSIX_VERSION
316 #define _POSIX_REGEXP 1
317 #ifdef __wasilibc_unmodified_upstream /* WASI has no processes */
318 #define _POSIX_SAVED_IDS 1
319 #define _POSIX_SHELL 1
320 #define _POSIX_SPAWN _POSIX_VERSION
322 #define _POSIX_VDISABLE 0
324 #define _POSIX_THREADS _POSIX_VERSION
325 #define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
326 #define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
327 #define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
328 #define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION
329 #define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION
330 #define _POSIX_THREAD_CPUTIME _POSIX_VERSION
331 #define _POSIX_TIMERS _POSIX_VERSION
332 #define _POSIX_TIMEOUTS _POSIX_VERSION
333 #define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
334 #define _POSIX_CPUTIME _POSIX_VERSION
335 #define _POSIX_CLOCK_SELECTION _POSIX_VERSION
336 #define _POSIX_BARRIERS _POSIX_VERSION
337 #define _POSIX_SPIN_LOCKS _POSIX_VERSION
338 #define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
339 #ifdef __wasilibc_unmodified_upstream /* WASI has no POSIX async I/O, semaphores, or shared memory */
340 #define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
341 #define _POSIX_SEMAPHORES _POSIX_VERSION
342 #define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION
345 #define _POSIX2_C_BIND _POSIX_VERSION
347 #include <bits/posix.h>
351 #define _PC_LINK_MAX 0
352 #define _PC_MAX_CANON 1
353 #define _PC_MAX_INPUT 2
354 #define _PC_NAME_MAX 3
355 #define _PC_PATH_MAX 4
356 #define _PC_PIPE_BUF 5
357 #define _PC_CHOWN_RESTRICTED 6
358 #define _PC_NO_TRUNC 7
359 #define _PC_VDISABLE 8
360 #define _PC_SYNC_IO 9
361 #define _PC_ASYNC_IO 10
362 #define _PC_PRIO_IO 11
363 #define _PC_SOCK_MAXBUF 12
364 #define _PC_FILESIZEBITS 13
365 #define _PC_REC_INCR_XFER_SIZE 14
366 #define _PC_REC_MAX_XFER_SIZE 15
367 #define _PC_REC_MIN_XFER_SIZE 16
368 #define _PC_REC_XFER_ALIGN 17
369 #define _PC_ALLOC_SIZE_MIN 18
370 #define _PC_SYMLINK_MAX 19
371 #define _PC_2_SYMLINKS 20
373 #define _SC_ARG_MAX 0
374 #define _SC_CHILD_MAX 1
375 #define _SC_CLK_TCK 2
376 #define _SC_NGROUPS_MAX 3
377 #define _SC_OPEN_MAX 4
378 #define _SC_STREAM_MAX 5
379 #define _SC_TZNAME_MAX 6
380 #define _SC_JOB_CONTROL 7
381 #define _SC_SAVED_IDS 8
382 #define _SC_REALTIME_SIGNALS 9
383 #define _SC_PRIORITY_SCHEDULING 10
384 #define _SC_TIMERS 11
385 #define _SC_ASYNCHRONOUS_IO 12
386 #define _SC_PRIORITIZED_IO 13
387 #define _SC_SYNCHRONIZED_IO 14
389 #define _SC_MAPPED_FILES 16
390 #define _SC_MEMLOCK 17
391 #define _SC_MEMLOCK_RANGE 18
392 #define _SC_MEMORY_PROTECTION 19
393 #define _SC_MESSAGE_PASSING 20
394 #define _SC_SEMAPHORES 21
395 #define _SC_SHARED_MEMORY_OBJECTS 22
396 #define _SC_AIO_LISTIO_MAX 23
397 #define _SC_AIO_MAX 24
398 #define _SC_AIO_PRIO_DELTA_MAX 25
399 #define _SC_DELAYTIMER_MAX 26
400 #define _SC_MQ_OPEN_MAX 27
401 #define _SC_MQ_PRIO_MAX 28
402 #define _SC_VERSION 29
403 #define _SC_PAGE_SIZE 30
404 #define _SC_PAGESIZE 30 /* !! */
405 #define _SC_RTSIG_MAX 31
406 #define _SC_SEM_NSEMS_MAX 32
407 #define _SC_SEM_VALUE_MAX 33
408 #define _SC_SIGQUEUE_MAX 34
409 #define _SC_TIMER_MAX 35
410 #define _SC_BC_BASE_MAX 36
411 #define _SC_BC_DIM_MAX 37
412 #define _SC_BC_SCALE_MAX 38
413 #define _SC_BC_STRING_MAX 39
414 #define _SC_COLL_WEIGHTS_MAX 40
415 #define _SC_EXPR_NEST_MAX 42
416 #define _SC_LINE_MAX 43
417 #define _SC_RE_DUP_MAX 44
418 #define _SC_2_VERSION 46
419 #define _SC_2_C_BIND 47
420 #define _SC_2_C_DEV 48
421 #define _SC_2_FORT_DEV 49
422 #define _SC_2_FORT_RUN 50
423 #define _SC_2_SW_DEV 51
424 #define _SC_2_LOCALEDEF 52
425 #define _SC_UIO_MAXIOV 60 /* !! */
426 #define _SC_IOV_MAX 60
427 #define _SC_THREADS 67
428 #define _SC_THREAD_SAFE_FUNCTIONS 68
429 #define _SC_GETGR_R_SIZE_MAX 69
430 #define _SC_GETPW_R_SIZE_MAX 70
431 #define _SC_LOGIN_NAME_MAX 71
432 #define _SC_TTY_NAME_MAX 72
433 #define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
434 #define _SC_THREAD_KEYS_MAX 74
435 #define _SC_THREAD_STACK_MIN 75
436 #define _SC_THREAD_THREADS_MAX 76
437 #define _SC_THREAD_ATTR_STACKADDR 77
438 #define _SC_THREAD_ATTR_STACKSIZE 78
439 #define _SC_THREAD_PRIORITY_SCHEDULING 79
440 #define _SC_THREAD_PRIO_INHERIT 80
441 #define _SC_THREAD_PRIO_PROTECT 81
442 #define _SC_THREAD_PROCESS_SHARED 82
443 #define _SC_NPROCESSORS_CONF 83
444 #define _SC_NPROCESSORS_ONLN 84
445 #define _SC_PHYS_PAGES 85
446 #define _SC_AVPHYS_PAGES 86
447 #define _SC_ATEXIT_MAX 87
448 #define _SC_PASS_MAX 88
449 #define _SC_XOPEN_VERSION 89
450 #define _SC_XOPEN_XCU_VERSION 90
451 #define _SC_XOPEN_UNIX 91
452 #define _SC_XOPEN_CRYPT 92
453 #define _SC_XOPEN_ENH_I18N 93
454 #define _SC_XOPEN_SHM 94
455 #define _SC_2_CHAR_TERM 95
457 #define _SC_XOPEN_XPG2 98
458 #define _SC_XOPEN_XPG3 99
459 #define _SC_XOPEN_XPG4 100
460 #define _SC_NZERO 109
461 #define _SC_XBS5_ILP32_OFF32 125
462 #define _SC_XBS5_ILP32_OFFBIG 126
463 #define _SC_XBS5_LP64_OFF64 127
464 #define _SC_XBS5_LPBIG_OFFBIG 128
465 #define _SC_XOPEN_LEGACY 129
466 #define _SC_XOPEN_REALTIME 130
467 #define _SC_XOPEN_REALTIME_THREADS 131
468 #define _SC_ADVISORY_INFO 132
469 #define _SC_BARRIERS 133
470 #define _SC_CLOCK_SELECTION 137
471 #define _SC_CPUTIME 138
472 #define _SC_THREAD_CPUTIME 139
473 #define _SC_MONOTONIC_CLOCK 149
474 #define _SC_READER_WRITER_LOCKS 153
475 #define _SC_SPIN_LOCKS 154
476 #define _SC_REGEXP 155
477 #define _SC_SHELL 157
478 #define _SC_SPAWN 159
479 #define _SC_SPORADIC_SERVER 160
480 #define _SC_THREAD_SPORADIC_SERVER 161
481 #define _SC_TIMEOUTS 164
482 #define _SC_TYPED_MEMORY_OBJECTS 165
483 #define _SC_2_PBS 168
484 #define _SC_2_PBS_ACCOUNTING 169
485 #define _SC_2_PBS_LOCATE 170
486 #define _SC_2_PBS_MESSAGE 171
487 #define _SC_2_PBS_TRACK 172
488 #define _SC_SYMLOOP_MAX 173
489 #define _SC_STREAMS 174
490 #define _SC_2_PBS_CHECKPOINT 175
491 #define _SC_V6_ILP32_OFF32 176
492 #define _SC_V6_ILP32_OFFBIG 177
493 #define _SC_V6_LP64_OFF64 178
494 #define _SC_V6_LPBIG_OFFBIG 179
495 #define _SC_HOST_NAME_MAX 180
496 #define _SC_TRACE 181
497 #define _SC_TRACE_EVENT_FILTER 182
498 #define _SC_TRACE_INHERIT 183
499 #define _SC_TRACE_LOG 184
502 #define _SC_RAW_SOCKETS 236
503 #define _SC_V7_ILP32_OFF32 237
504 #define _SC_V7_ILP32_OFFBIG 238
505 #define _SC_V7_LP64_OFF64 239
506 #define _SC_V7_LPBIG_OFFBIG 240
507 #define _SC_SS_REPL_MAX 241
508 #define _SC_TRACE_EVENT_NAME_MAX 242
509 #define _SC_TRACE_NAME_MAX 243
510 #define _SC_TRACE_SYS_MAX 244
511 #define _SC_TRACE_USER_EVENT_MAX 245
512 #define _SC_XOPEN_STREAMS 246
513 #define _SC_THREAD_ROBUST_PRIO_INHERIT 247
514 #define _SC_THREAD_ROBUST_PRIO_PROTECT 248
517 #define _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS 1
518 #define _CS_GNU_LIBC_VERSION 2
519 #define _CS_GNU_LIBPTHREAD_VERSION 3
520 #define _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS 4
521 #define _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS 5
523 #define _CS_POSIX_V6_ILP32_OFF32_CFLAGS 1116
524 #define _CS_POSIX_V6_ILP32_OFF32_LDFLAGS 1117
525 #define _CS_POSIX_V6_ILP32_OFF32_LIBS 1118
526 #define _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS 1119
527 #define _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS 1120
528 #define _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS 1121
529 #define _CS_POSIX_V6_ILP32_OFFBIG_LIBS 1122
530 #define _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS 1123
531 #define _CS_POSIX_V6_LP64_OFF64_CFLAGS 1124
532 #define _CS_POSIX_V6_LP64_OFF64_LDFLAGS 1125
533 #define _CS_POSIX_V6_LP64_OFF64_LIBS 1126
534 #define _CS_POSIX_V6_LP64_OFF64_LINTFLAGS 1127
535 #define _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS 1128
536 #define _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS 1129
537 #define _CS_POSIX_V6_LPBIG_OFFBIG_LIBS 1130
538 #define _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS 1131
539 #define _CS_POSIX_V7_ILP32_OFF32_CFLAGS 1132
540 #define _CS_POSIX_V7_ILP32_OFF32_LDFLAGS 1133
541 #define _CS_POSIX_V7_ILP32_OFF32_LIBS 1134
542 #define _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS 1135
543 #define _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS 1136
544 #define _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS 1137
545 #define _CS_POSIX_V7_ILP32_OFFBIG_LIBS 1138
546 #define _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS 1139
547 #define _CS_POSIX_V7_LP64_OFF64_CFLAGS 1140
548 #define _CS_POSIX_V7_LP64_OFF64_LDFLAGS 1141
549 #define _CS_POSIX_V7_LP64_OFF64_LIBS 1142
550 #define _CS_POSIX_V7_LP64_OFF64_LINTFLAGS 1143
551 #define _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS 1144
552 #define _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS 1145
553 #define _CS_POSIX_V7_LPBIG_OFFBIG_LIBS 1146
554 #define _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS 1147
555 #define _CS_V6_ENV 1148
556 #define _CS_V7_ENV 1149