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