unistd.h 13 KB

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