unistd.h 13 KB

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