detect.nim 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. # Posix detect program
  2. # (c) 2010 Andreas Rumpf
  3. # This program generates:
  4. # * A c program that prints a nim file containing constant variables holding the
  5. # value of many C #define's, on the platform it's currently running at
  6. # * A nim file that contains the same contants, but as nim var:s that fetch the
  7. # value of the constant using importc/header during the C compile phase.
  8. #
  9. # The first file allows nim to know the value of the constant at nim
  10. # compile time, but since the values differ across platform, isn't as portable.
  11. # The second one is more portable, and less semantically correct. It only works
  12. # when there's a backing C compiler available as well, preventing standalone
  13. # compilation.
  14. import std/[os, strutils]
  15. when defined(nimPreviewSlimSystem):
  16. import std/syncio
  17. when defined(openbsd) or defined(freebsd) or defined(netbsd):
  18. const
  19. cc = "cc -o $# $#.c"
  20. cpp = "cc -E -o $#.i $#.c"
  21. ccLinkMath = "cc -lm -o $# $#.c"
  22. cppLinkMath = "cc -lm -E -o $#.i $#.c"
  23. else:
  24. const
  25. cc = "gcc -o $# $#.c"
  26. cpp = "gcc -E -o $#.i $#.c"
  27. const
  28. cfile = """
  29. /* Generated by detect.nim */
  30. #define _GNU_SOURCE
  31. #define _POSIX_C_SOURCE 200809L
  32. #include <stdlib.h>
  33. #include <stdio.h>
  34. $1
  35. int main() {
  36. FILE* f;
  37. f = fopen("$3_$4_consts.nim", "w+");
  38. fputs("# Generated by detect.nim\n\n", f);
  39. $2
  40. fclose(f);
  41. }
  42. """
  43. ifile = """
  44. /* Generated by detect.nim */
  45. $1
  46. """
  47. nimfile = """
  48. # Generated by detect.nim
  49. $1
  50. """
  51. var
  52. cur = ""
  53. found = false
  54. hd = ""
  55. tl = ""
  56. other = ""
  57. proc myExec(cmd: string): bool =
  58. echo "CMD ", cmd
  59. return execShellCmd(cmd) == 0
  60. proc header(s: string) =
  61. cur = s
  62. const testh = "testh"
  63. var f: File
  64. if open(f, addFileExt(testh, "c"), fmWrite):
  65. f.write("#include $1\n" % s)
  66. f.write("int main() { return 0; }\n")
  67. close(f)
  68. found = myExec(cc % [testh.addFileExt(ExeExt), testh])
  69. removeFile(addFileExt(testh, "c"))
  70. addf(other, "\n# $1\n", cur)
  71. if found:
  72. addf(hd, "#include $1\n", cur)
  73. addf(tl, " fprintf(f, \"\\n# $1\\n\");\n", cur)
  74. echo("Found: ", s)
  75. else:
  76. echo("Not found: ", s)
  77. proc main =
  78. const gen = "genconsts"
  79. const pre = "pre"
  80. var f: File
  81. if open(f, addFileExt(gen, "c"), fmWrite):
  82. f.write(cfile % [hd, tl, system.hostOS, system.hostCPU])
  83. close(f)
  84. if open(f, addFileExt(pre, "c"), fmWrite):
  85. f.write(cfile % [hd, tl, system.hostOS, system.hostCPU])
  86. close(f)
  87. if open(f, "other_consts.nim", fmWrite):
  88. f.write(nimfile % [other])
  89. close(f)
  90. let cCompile = when defined(openbsd) or defined(freebsd) or defined(netbsd): ccLinkMath else: cc
  91. let cppCompile = when defined(openbsd) or defined(freebsd) or defined(netbsd): cppLinkMath else: cpp
  92. if not myExec(cCompile % [gen.addFileExt(ExeExt), gen]): quit(1)
  93. if not myExec(cppCompile % [pre.addFileExt(ExeExt), pre]): quit(1)
  94. when defined(windows):
  95. if not myExec(gen.addFileExt(ExeExt)): quit(1)
  96. else:
  97. if not myExec("./" & gen): quit(1)
  98. #removeFile(addFileExt(gen, "c"))
  99. echo("Success")
  100. proc v(name: string, typ = "cint", no_other = false) =
  101. var n = if name[0] == '_': substr(name, 1) else: name
  102. var t = $typ
  103. if not no_other:
  104. addf(other,
  105. "var $1* {.importc: \"$2\", header: \"$3\".}: $4\n", n, name, cur, t)
  106. if not found: return
  107. case typ
  108. of "pointer":
  109. addf(tl,
  110. "#ifdef $3\n fprintf(f, \"const $1* = cast[$2](%p)\\n\", $3);\n#endif\n",
  111. n, t, name)
  112. of "cstring":
  113. addf(tl,
  114. "#ifdef $3\n fprintf(f, \"const $1* = $2(\\\"%s\\\")\\n\", $3);\n#endif\n",
  115. n, t, name)
  116. of "clong":
  117. addf(tl,
  118. "#ifdef $3\n fprintf(f, \"const $1* = $2(%ld)\\n\", $3);\n#endif\n",
  119. n, t, name)
  120. of "cint", "cshort", "TSa_Family":
  121. addf(tl,
  122. "#ifdef $3\n fprintf(f, \"const $1* = $2(%d)\\n\", $3);\n#endif\n",
  123. n, t, name)
  124. of "InAddrScalar":
  125. addf(tl,
  126. "#ifdef $3\n fprintf(f, \"const $1* = $2(%u)\\n\", $3);\n#endif\n",
  127. n, t, name)
  128. else:
  129. addf(tl,
  130. "#ifdef $3\n fprintf(f, \"const $1* = cast[$2](%d)\\n\", $3);\n#endif\n",
  131. n, t, name)
  132. header("<aio.h>")
  133. v("AIO_ALLDONE")
  134. v("AIO_CANCELED")
  135. v("AIO_NOTCANCELED")
  136. v("LIO_NOP")
  137. v("LIO_NOWAIT")
  138. v("LIO_READ")
  139. v("LIO_WAIT")
  140. v("LIO_WRITE")
  141. header("<dlfcn.h>")
  142. v("RTLD_LAZY")
  143. v("RTLD_NOW")
  144. v("RTLD_GLOBAL")
  145. v("RTLD_LOCAL")
  146. header("<errno.h>")
  147. v("E2BIG")
  148. v("EACCES")
  149. v("EADDRINUSE")
  150. v("EADDRNOTAVAIL")
  151. v("EAFNOSUPPORT")
  152. v("EAGAIN")
  153. v("EALREADY")
  154. v("EBADF")
  155. v("EBADMSG")
  156. v("EBUSY")
  157. v("ECANCELED")
  158. v("ECHILD")
  159. v("ECONNABORTED")
  160. v("ECONNREFUSED")
  161. v("ECONNRESET")
  162. v("EDEADLK")
  163. v("EDESTADDRREQ")
  164. v("EDOM")
  165. v("EDQUOT")
  166. v("EEXIST")
  167. v("EFAULT")
  168. v("EFBIG")
  169. v("EHOSTUNREACH")
  170. v("EIDRM")
  171. v("EILSEQ")
  172. v("EINPROGRESS")
  173. v("EINTR")
  174. v("EINVAL")
  175. v("EIO")
  176. v("EISCONN")
  177. v("EISDIR")
  178. v("ELOOP")
  179. v("EMFILE")
  180. v("EMLINK")
  181. v("EMSGSIZE")
  182. v("EMULTIHOP")
  183. v("ENAMETOOLONG")
  184. v("ENETDOWN")
  185. v("ENETRESET")
  186. v("ENETUNREACH")
  187. v("ENFILE")
  188. v("ENOBUFS")
  189. v("ENODATA")
  190. v("ENODEV")
  191. v("ENOENT")
  192. v("ENOEXEC")
  193. v("ENOLCK")
  194. v("ENOLINK")
  195. v("ENOMEM")
  196. v("ENOMSG")
  197. v("ENOPROTOOPT")
  198. v("ENOSPC")
  199. v("ENOSR")
  200. v("ENOSTR")
  201. v("ENOSYS")
  202. v("ENOTCONN")
  203. v("ENOTDIR")
  204. v("ENOTEMPTY")
  205. v("ENOTSOCK")
  206. v("ENOTSUP")
  207. v("ENOTTY")
  208. v("ENXIO")
  209. v("EOPNOTSUPP")
  210. v("EOVERFLOW")
  211. v("EPERM")
  212. v("EPIPE")
  213. v("EPROTO")
  214. v("EPROTONOSUPPORT")
  215. v("EPROTOTYPE")
  216. v("ERANGE")
  217. v("EROFS")
  218. v("ESPIPE")
  219. v("ESRCH")
  220. v("ESTALE")
  221. v("ETIME")
  222. v("ETIMEDOUT")
  223. v("ETXTBSY")
  224. v("EWOULDBLOCK")
  225. v("EXDEV")
  226. header("<fcntl.h>")
  227. v("F_DUPFD")
  228. v("F_DUPFD_CLOEXEC")
  229. v("F_GETFD")
  230. v("F_SETFD")
  231. v("F_GETFL")
  232. v("F_SETFL")
  233. v("F_GETLK")
  234. v("F_SETLK")
  235. v("F_SETLKW")
  236. v("F_GETOWN")
  237. v("F_SETOWN")
  238. v("FD_CLOEXEC")
  239. v("F_RDLCK")
  240. v("F_UNLCK")
  241. v("F_WRLCK")
  242. v("O_CREAT")
  243. v("O_EXCL")
  244. v("O_NOCTTY")
  245. v("O_TRUNC")
  246. v("O_APPEND")
  247. v("O_DSYNC")
  248. v("O_NONBLOCK")
  249. v("O_RSYNC")
  250. v("O_SYNC")
  251. v("O_ACCMODE")
  252. v("O_RDONLY")
  253. v("O_RDWR")
  254. v("O_WRONLY")
  255. v("O_CLOEXEC")
  256. v("O_DIRECT")
  257. v("O_PATH")
  258. v("O_NOATIME")
  259. v("O_TMPFILE")
  260. v("POSIX_FADV_NORMAL")
  261. v("POSIX_FADV_SEQUENTIAL")
  262. v("POSIX_FADV_RANDOM")
  263. v("POSIX_FADV_WILLNEED")
  264. v("POSIX_FADV_DONTNEED")
  265. v("POSIX_FADV_NOREUSE")
  266. header("<fenv.h>")
  267. v("FE_DIVBYZERO")
  268. v("FE_INEXACT")
  269. v("FE_INVALID")
  270. v("FE_OVERFLOW")
  271. v("FE_UNDERFLOW")
  272. v("FE_ALL_EXCEPT")
  273. v("FE_DOWNWARD")
  274. v("FE_TONEAREST")
  275. v("FE_TOWARDZERO")
  276. v("FE_UPWARD")
  277. v("FE_DFL_ENV")
  278. header("<fmtmsg.h>")
  279. v("MM_HARD")
  280. v("MM_SOFT")
  281. v("MM_FIRM")
  282. v("MM_APPL")
  283. v("MM_UTIL")
  284. v("MM_OPSYS")
  285. v("MM_RECOVER")
  286. v("MM_NRECOV")
  287. v("MM_HALT")
  288. v("MM_ERROR")
  289. v("MM_WARNING")
  290. v("MM_INFO")
  291. v("MM_NOSEV")
  292. v("MM_PRINT")
  293. v("MM_CONSOLE")
  294. v("MM_OK")
  295. v("MM_NOTOK")
  296. v("MM_NOMSG")
  297. v("MM_NOCON")
  298. header("<fnmatch.h>")
  299. v("FNM_NOMATCH")
  300. v("FNM_PATHNAME")
  301. v("FNM_PERIOD")
  302. v("FNM_NOESCAPE")
  303. v("FNM_NOSYS")
  304. header("<ftw.h>")
  305. v("FTW_F")
  306. v("FTW_D")
  307. v("FTW_DNR")
  308. v("FTW_DP")
  309. v("FTW_NS")
  310. v("FTW_SL")
  311. v("FTW_SLN")
  312. v("FTW_PHYS")
  313. v("FTW_MOUNT")
  314. v("FTW_DEPTH")
  315. v("FTW_CHDIR")
  316. header("<glob.h>")
  317. v("GLOB_APPEND")
  318. v("GLOB_DOOFFS")
  319. v("GLOB_ERR")
  320. v("GLOB_MARK")
  321. v("GLOB_NOCHECK")
  322. v("GLOB_NOESCAPE")
  323. v("GLOB_NOSORT")
  324. v("GLOB_ABORTED")
  325. v("GLOB_NOMATCH")
  326. v("GLOB_NOSPACE")
  327. v("GLOB_NOSYS")
  328. header("<langinfo.h>")
  329. v("CODESET")
  330. v("D_T_FMT")
  331. v("D_FMT")
  332. v("T_FMT")
  333. v("T_FMT_AMPM")
  334. v("AM_STR")
  335. v("PM_STR")
  336. v("DAY_1")
  337. v("DAY_2")
  338. v("DAY_3")
  339. v("DAY_4")
  340. v("DAY_5")
  341. v("DAY_6")
  342. v("DAY_7")
  343. v("ABDAY_1")
  344. v("ABDAY_2")
  345. v("ABDAY_3")
  346. v("ABDAY_4")
  347. v("ABDAY_5")
  348. v("ABDAY_6")
  349. v("ABDAY_7")
  350. v("MON_1")
  351. v("MON_2")
  352. v("MON_3")
  353. v("MON_4")
  354. v("MON_5")
  355. v("MON_6")
  356. v("MON_7")
  357. v("MON_8")
  358. v("MON_9")
  359. v("MON_10")
  360. v("MON_11")
  361. v("MON_12")
  362. v("ABMON_1")
  363. v("ABMON_2")
  364. v("ABMON_3")
  365. v("ABMON_4")
  366. v("ABMON_5")
  367. v("ABMON_6")
  368. v("ABMON_7")
  369. v("ABMON_8")
  370. v("ABMON_9")
  371. v("ABMON_10")
  372. v("ABMON_11")
  373. v("ABMON_12")
  374. v("ERA")
  375. v("ERA_D_FMT")
  376. v("ERA_D_T_FMT")
  377. v("ERA_T_FMT")
  378. v("ALT_DIGITS")
  379. v("RADIXCHAR")
  380. v("THOUSEP")
  381. v("YESEXPR")
  382. v("NOEXPR")
  383. v("CRNCYSTR")
  384. header("<locale.h>")
  385. v("LC_ALL")
  386. v("LC_COLLATE")
  387. v("LC_CTYPE")
  388. v("LC_MESSAGES")
  389. v("LC_MONETARY")
  390. v("LC_NUMERIC")
  391. v("LC_TIME")
  392. header("<netdb.h>")
  393. v("IPPORT_RESERVED")
  394. v("HOST_NOT_FOUND")
  395. v("NO_DATA")
  396. v("NO_RECOVERY")
  397. v("TRY_AGAIN")
  398. v("AI_PASSIVE")
  399. v("AI_CANONNAME")
  400. v("AI_NUMERICHOST")
  401. v("AI_NUMERICSERV")
  402. v("AI_V4MAPPED")
  403. v("AI_ALL")
  404. v("AI_ADDRCONFIG")
  405. v("NI_NOFQDN")
  406. v("NI_NUMERICHOST")
  407. v("NI_NAMEREQD")
  408. v("NI_NUMERICSERV")
  409. v("NI_NUMERICSCOPE")
  410. v("NI_DGRAM")
  411. v("EAI_AGAIN")
  412. v("EAI_BADFLAGS")
  413. v("EAI_FAIL")
  414. v("EAI_FAMILY")
  415. v("EAI_MEMORY")
  416. v("EAI_NONAME")
  417. v("EAI_SERVICE")
  418. v("EAI_SOCKTYPE")
  419. v("EAI_SYSTEM")
  420. v("EAI_OVERFLOW")
  421. header("<net/if.h>")
  422. v("IF_NAMESIZE")
  423. header("<netinet/in.h>")
  424. v("IPPROTO_IP")
  425. v("IPPROTO_IPV6")
  426. v("IPPROTO_ICMP")
  427. v("IPPROTO_ICMPV6")
  428. v("IPPROTO_RAW")
  429. v("IPPROTO_TCP")
  430. v("IPPROTO_UDP")
  431. v("INADDR_ANY", "InAddrScalar")
  432. v("INADDR_LOOPBACK", "InAddrScalar")
  433. v("INADDR_BROADCAST", "InAddrScalar")
  434. v("INET_ADDRSTRLEN")
  435. v("INET6_ADDRSTRLEN")
  436. v("IPV6_JOIN_GROUP")
  437. v("IPV6_LEAVE_GROUP")
  438. v("IPV6_MULTICAST_HOPS")
  439. v("IPV6_MULTICAST_IF")
  440. v("IPV6_MULTICAST_LOOP")
  441. v("IPV6_UNICAST_HOPS")
  442. v("IPV6_V6ONLY")
  443. header("<netinet/tcp.h>")
  444. v("TCP_NODELAY")
  445. header("<nl_types.h>")
  446. v("NL_SETD")
  447. v("NL_CAT_LOCALE")
  448. header("<poll.h>")
  449. v("POLLIN", "cshort")
  450. v("POLLRDNORM", "cshort")
  451. v("POLLRDBAND", "cshort")
  452. v("POLLPRI", "cshort")
  453. v("POLLOUT", "cshort")
  454. v("POLLWRNORM", "cshort")
  455. v("POLLWRBAND", "cshort")
  456. v("POLLERR", "cshort")
  457. v("POLLHUP", "cshort")
  458. v("POLLNVAL", "cshort")
  459. header("<pthread.h>")
  460. v("PTHREAD_BARRIER_SERIAL_THREAD")
  461. v("PTHREAD_CANCEL_ASYNCHRONOUS")
  462. v("PTHREAD_CANCEL_ENABLE")
  463. v("PTHREAD_CANCEL_DEFERRED")
  464. v("PTHREAD_CANCEL_DISABLE")
  465. #v("PTHREAD_CANCELED")
  466. #v("PTHREAD_COND_INITIALIZER")
  467. v("PTHREAD_CREATE_DETACHED")
  468. v("PTHREAD_CREATE_JOINABLE")
  469. v("PTHREAD_EXPLICIT_SCHED")
  470. v("PTHREAD_INHERIT_SCHED")
  471. v("PTHREAD_MUTEX_DEFAULT")
  472. v("PTHREAD_MUTEX_ERRORCHECK")
  473. #v("PTHREAD_MUTEX_INITIALIZER")
  474. v("PTHREAD_MUTEX_NORMAL")
  475. v("PTHREAD_MUTEX_RECURSIVE")
  476. #v("PTHREAD_ONCE_INIT")
  477. v("PTHREAD_PRIO_INHERIT")
  478. v("PTHREAD_PRIO_NONE")
  479. v("PTHREAD_PRIO_PROTECT")
  480. v("PTHREAD_PROCESS_SHARED")
  481. v("PTHREAD_PROCESS_PRIVATE")
  482. v("PTHREAD_SCOPE_PROCESS")
  483. v("PTHREAD_SCOPE_SYSTEM")
  484. header("<sched.h>")
  485. v("SCHED_FIFO")
  486. v("SCHED_RR")
  487. v("SCHED_SPORADIC")
  488. v("SCHED_OTHER")
  489. header("<semaphore.h>")
  490. v("SEM_FAILED", "pointer")
  491. header("<signal.h>")
  492. v("SIGEV_NONE")
  493. v("SIGEV_SIGNAL")
  494. v("SIGEV_THREAD")
  495. v("SIGABRT")
  496. v("SIGALRM")
  497. v("SIGBUS")
  498. v("SIGCHLD")
  499. v("SIGCONT")
  500. v("SIGFPE")
  501. v("SIGHUP")
  502. v("SIGILL")
  503. v("SIGINT")
  504. v("SIGKILL")
  505. v("SIGPIPE")
  506. v("SIGQUIT")
  507. v("SIGSEGV")
  508. v("SIGSTOP")
  509. v("SIGTERM")
  510. v("SIGTSTP")
  511. v("SIGTTIN")
  512. v("SIGTTOU")
  513. v("SIGUSR1")
  514. v("SIGUSR2")
  515. v("SIGPOLL")
  516. v("SIGPROF")
  517. v("SIGSYS")
  518. v("SIGTRAP")
  519. v("SIGURG")
  520. v("SIGVTALRM")
  521. v("SIGXCPU")
  522. v("SIGXFSZ")
  523. v("SA_NOCLDSTOP")
  524. v("SIG_BLOCK")
  525. v("SIG_UNBLOCK")
  526. v("SIG_SETMASK")
  527. v("SA_ONSTACK")
  528. v("SA_RESETHAND")
  529. v("SA_RESTART")
  530. v("SA_SIGINFO")
  531. v("SA_NOCLDWAIT")
  532. v("SA_NODEFER")
  533. v("SS_ONSTACK")
  534. v("SS_DISABLE")
  535. v("MINSIGSTKSZ")
  536. v("SIGSTKSZ")
  537. v("SIG_HOLD", "Sighandler")
  538. v("SIG_DFL", "Sighandler")
  539. v("SIG_ERR", "Sighandler")
  540. v("SIG_IGN", "Sighandler")
  541. header("<sys/ipc.h>")
  542. v("IPC_CREAT")
  543. v("IPC_EXCL")
  544. v("IPC_NOWAIT")
  545. v("IPC_PRIVATE")
  546. v("IPC_RMID")
  547. v("IPC_SET")
  548. v("IPC_STAT")
  549. header("<sys/mman.h>")
  550. v("PROT_READ")
  551. v("PROT_WRITE")
  552. v("PROT_EXEC")
  553. v("PROT_NONE")
  554. v("MAP_ANONYMOUS")
  555. v("MAP_FIXED_NOREPLACE")
  556. v("MAP_NORESERVE")
  557. v("MAP_SHARED")
  558. v("MAP_PRIVATE")
  559. v("MAP_FIXED")
  560. v("MS_ASYNC")
  561. v("MS_SYNC")
  562. v("MS_INVALIDATE")
  563. v("MCL_CURRENT")
  564. v("MCL_FUTURE")
  565. v("MAP_FAILED", "pointer")
  566. v("POSIX_MADV_NORMAL")
  567. v("POSIX_MADV_SEQUENTIAL")
  568. v("POSIX_MADV_RANDOM")
  569. v("POSIX_MADV_WILLNEED")
  570. v("POSIX_MADV_DONTNEED")
  571. v("POSIX_TYPED_MEM_ALLOCATE")
  572. v("POSIX_TYPED_MEM_ALLOCATE_CONTIG")
  573. v("POSIX_TYPED_MEM_MAP_ALLOCATABLE")
  574. v("MAP_POPULATE", no_other = true)
  575. header("<sys/resource.h>")
  576. v("RLIMIT_NOFILE")
  577. v("RLIMIT_STACK")
  578. header("<sys/select.h>")
  579. v("FD_SETSIZE")
  580. header("<sys/socket.h>")
  581. v("MSG_CTRUNC")
  582. v("MSG_DONTROUTE")
  583. v("MSG_EOR")
  584. v("MSG_OOB")
  585. v("SCM_RIGHTS")
  586. v("SO_ACCEPTCONN")
  587. v("SO_BINDTODEVICE")
  588. v("SO_BROADCAST")
  589. v("SO_DEBUG")
  590. v("SO_DONTROUTE")
  591. v("SO_ERROR")
  592. v("SO_KEEPALIVE")
  593. v("SO_LINGER")
  594. v("SO_OOBINLINE")
  595. v("SO_RCVBUF")
  596. v("SO_RCVLOWAT")
  597. v("SO_RCVTIMEO")
  598. v("SO_REUSEADDR")
  599. v("SO_SNDBUF")
  600. v("SO_SNDLOWAT")
  601. v("SO_SNDTIMEO")
  602. v("SO_TYPE")
  603. v("SOCK_DGRAM")
  604. v("SOCK_RAW")
  605. v("SOCK_SEQPACKET")
  606. v("SOCK_STREAM")
  607. v("SOCK_CLOEXEC", no_other = true)
  608. v("SOL_SOCKET")
  609. v("SOMAXCONN")
  610. v("SO_REUSEPORT", no_other = true)
  611. v("MSG_NOSIGNAL", no_other = true)
  612. v("MSG_PEEK")
  613. v("MSG_TRUNC")
  614. v("MSG_WAITALL")
  615. v("AF_INET")
  616. v("AF_INET6")
  617. v("AF_UNIX")
  618. v("AF_UNSPEC")
  619. v("SHUT_RD")
  620. v("SHUT_RDWR")
  621. v("SHUT_WR")
  622. header("<sys/stat.h>")
  623. v("S_IFBLK")
  624. v("S_IFCHR")
  625. v("S_IFDIR")
  626. v("S_IFIFO")
  627. v("S_IFLNK")
  628. v("S_IFMT")
  629. v("S_IFREG")
  630. v("S_IFSOCK")
  631. v("S_IRGRP")
  632. v("S_IROTH")
  633. v("S_IRUSR")
  634. v("S_IRWXG")
  635. v("S_IRWXO")
  636. v("S_IRWXU")
  637. v("S_ISGID")
  638. v("S_ISUID")
  639. v("S_ISVTX")
  640. v("S_IWGRP")
  641. v("S_IWOTH")
  642. v("S_IWUSR")
  643. v("S_IXGRP")
  644. v("S_IXOTH")
  645. v("S_IXUSR")
  646. header("<sys/statvfs.h>")
  647. v("ST_RDONLY")
  648. v("ST_NOSUID")
  649. header("<sys/wait.h>")
  650. v("WNOHANG")
  651. v("WUNTRACED")
  652. #v("WEXITSTATUS")
  653. #v("WSTOPSIG")
  654. #v("WTERMSIG")
  655. v("WEXITED")
  656. v("WSTOPPED")
  657. v("WCONTINUED")
  658. v("WNOWAIT")
  659. v("P_ALL")
  660. v("P_PID")
  661. v("P_PGID")
  662. header("<spawn.h>")
  663. v("POSIX_SPAWN_RESETIDS")
  664. v("POSIX_SPAWN_SETPGROUP")
  665. v("POSIX_SPAWN_SETSCHEDPARAM")
  666. v("POSIX_SPAWN_SETSCHEDULER")
  667. v("POSIX_SPAWN_SETSIGDEF")
  668. v("POSIX_SPAWN_SETSIGMASK")
  669. v("POSIX_SPAWN_USEVFORK", no_other = true)
  670. header("<stdio.h>")
  671. v("_IOFBF")
  672. v("_IONBF")
  673. header("<time.h>")
  674. v("CLOCKS_PER_SEC", "clong")
  675. v("CLOCK_PROCESS_CPUTIME_ID")
  676. v("CLOCK_THREAD_CPUTIME_ID")
  677. v("CLOCK_REALTIME")
  678. v("TIMER_ABSTIME")
  679. v("CLOCK_MONOTONIC")
  680. header("<unistd.h>")
  681. v("_POSIX_ASYNC_IO")
  682. v("_POSIX_PRIO_IO")
  683. v("_POSIX_SYNC_IO")
  684. v("F_OK")
  685. v("R_OK")
  686. v("W_OK")
  687. v("X_OK")
  688. v("_CS_PATH")
  689. v("_CS_POSIX_V6_ILP32_OFF32_CFLAGS")
  690. v("_CS_POSIX_V6_ILP32_OFF32_LDFLAGS")
  691. v("_CS_POSIX_V6_ILP32_OFF32_LIBS")
  692. v("_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS")
  693. v("_CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS")
  694. v("_CS_POSIX_V6_ILP32_OFFBIG_LIBS")
  695. v("_CS_POSIX_V6_LP64_OFF64_CFLAGS")
  696. v("_CS_POSIX_V6_LP64_OFF64_LDFLAGS")
  697. v("_CS_POSIX_V6_LP64_OFF64_LIBS")
  698. v("_CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS")
  699. v("_CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS")
  700. v("_CS_POSIX_V6_LPBIG_OFFBIG_LIBS")
  701. v("_CS_POSIX_V6_WIDTH_RESTRICTED_ENVS")
  702. v("F_LOCK")
  703. v("F_TEST")
  704. v("F_TLOCK")
  705. v("F_ULOCK")
  706. v("_PC_2_SYMLINKS")
  707. v("_PC_ALLOC_SIZE_MIN")
  708. v("_PC_ASYNC_IO")
  709. v("_PC_CHOWN_RESTRICTED")
  710. v("_PC_FILESIZEBITS")
  711. v("_PC_LINK_MAX")
  712. v("_PC_MAX_CANON")
  713. v("_PC_MAX_INPUT")
  714. v("_PC_NAME_MAX")
  715. v("_PC_NO_TRUNC")
  716. v("_PC_PATH_MAX")
  717. v("_PC_PIPE_BUF")
  718. v("_PC_PRIO_IO")
  719. v("_PC_REC_INCR_XFER_SIZE")
  720. v("_PC_REC_MIN_XFER_SIZE")
  721. v("_PC_REC_XFER_ALIGN")
  722. v("_PC_SYMLINK_MAX")
  723. v("_PC_SYNC_IO")
  724. v("_PC_VDISABLE")
  725. v("_SC_2_C_BIND")
  726. v("_SC_2_C_DEV")
  727. v("_SC_2_CHAR_TERM")
  728. v("_SC_2_FORT_DEV")
  729. v("_SC_2_FORT_RUN")
  730. v("_SC_2_LOCALEDEF")
  731. v("_SC_2_PBS")
  732. v("_SC_2_PBS_ACCOUNTING")
  733. v("_SC_2_PBS_CHECKPOINT")
  734. v("_SC_2_PBS_LOCATE")
  735. v("_SC_2_PBS_MESSAGE")
  736. v("_SC_2_PBS_TRACK")
  737. v("_SC_2_SW_DEV")
  738. v("_SC_2_UPE")
  739. v("_SC_2_VERSION")
  740. v("_SC_ADVISORY_INFO")
  741. v("_SC_AIO_LISTIO_MAX")
  742. v("_SC_AIO_MAX")
  743. v("_SC_AIO_PRIO_DELTA_MAX")
  744. v("_SC_ARG_MAX")
  745. v("_SC_ASYNCHRONOUS_IO")
  746. v("_SC_ATEXIT_MAX")
  747. v("_SC_BARRIERS")
  748. v("_SC_BC_BASE_MAX")
  749. v("_SC_BC_DIM_MAX")
  750. v("_SC_BC_SCALE_MAX")
  751. v("_SC_BC_STRING_MAX")
  752. v("_SC_CHILD_MAX")
  753. v("_SC_CLK_TCK")
  754. v("_SC_CLOCK_SELECTION")
  755. v("_SC_COLL_WEIGHTS_MAX")
  756. v("_SC_CPUTIME")
  757. v("_SC_DELAYTIMER_MAX")
  758. v("_SC_EXPR_NEST_MAX")
  759. v("_SC_FSYNC")
  760. v("_SC_GETGR_R_SIZE_MAX")
  761. v("_SC_GETPW_R_SIZE_MAX")
  762. v("_SC_HOST_NAME_MAX")
  763. v("_SC_IOV_MAX")
  764. v("_SC_IPV6")
  765. v("_SC_JOB_CONTROL")
  766. v("_SC_LINE_MAX")
  767. v("_SC_LOGIN_NAME_MAX")
  768. v("_SC_MAPPED_FILES")
  769. v("_SC_MEMLOCK")
  770. v("_SC_MEMLOCK_RANGE")
  771. v("_SC_MEMORY_PROTECTION")
  772. v("_SC_MESSAGE_PASSING")
  773. v("_SC_MONOTONIC_CLOCK")
  774. v("_SC_MQ_OPEN_MAX")
  775. v("_SC_MQ_PRIO_MAX")
  776. v("_SC_NGROUPS_MAX")
  777. v("_SC_OPEN_MAX")
  778. v("_SC_PAGESIZE") # Synonym for _SC_PAGE_SIZE
  779. v("_SC_PRIORITIZED_IO")
  780. v("_SC_PRIORITY_SCHEDULING")
  781. v("_SC_RAW_SOCKETS")
  782. v("_SC_RE_DUP_MAX")
  783. v("_SC_READER_WRITER_LOCKS")
  784. v("_SC_REALTIME_SIGNALS")
  785. v("_SC_REGEXP")
  786. v("_SC_RTSIG_MAX")
  787. v("_SC_SAVED_IDS")
  788. v("_SC_SEM_NSEMS_MAX")
  789. v("_SC_SEM_VALUE_MAX")
  790. v("_SC_SEMAPHORES")
  791. v("_SC_SHARED_MEMORY_OBJECTS")
  792. v("_SC_SHELL")
  793. v("_SC_SIGQUEUE_MAX")
  794. v("_SC_SPAWN")
  795. v("_SC_SPIN_LOCKS")
  796. v("_SC_SPORADIC_SERVER")
  797. v("_SC_SS_REPL_MAX")
  798. v("_SC_STREAM_MAX")
  799. v("_SC_SYMLOOP_MAX")
  800. v("_SC_SYNCHRONIZED_IO")
  801. v("_SC_THREAD_ATTR_STACKADDR")
  802. v("_SC_THREAD_ATTR_STACKSIZE")
  803. v("_SC_THREAD_CPUTIME")
  804. v("_SC_THREAD_DESTRUCTOR_ITERATIONS")
  805. v("_SC_THREAD_KEYS_MAX")
  806. v("_SC_THREAD_PRIO_INHERIT")
  807. v("_SC_THREAD_PRIO_PROTECT")
  808. v("_SC_THREAD_PRIORITY_SCHEDULING")
  809. v("_SC_THREAD_PROCESS_SHARED")
  810. v("_SC_THREAD_SAFE_FUNCTIONS")
  811. v("_SC_THREAD_SPORADIC_SERVER")
  812. v("_SC_THREAD_STACK_MIN")
  813. v("_SC_THREAD_THREADS_MAX")
  814. v("_SC_THREADS")
  815. v("_SC_TIMEOUTS")
  816. v("_SC_TIMER_MAX")
  817. v("_SC_TIMERS")
  818. v("_SC_TRACE")
  819. v("_SC_TRACE_EVENT_FILTER")
  820. v("_SC_TRACE_EVENT_NAME_MAX")
  821. v("_SC_TRACE_INHERIT")
  822. v("_SC_TRACE_LOG")
  823. v("_SC_TRACE_NAME_MAX")
  824. v("_SC_TRACE_SYS_MAX")
  825. v("_SC_TRACE_USER_EVENT_MAX")
  826. v("_SC_TTY_NAME_MAX")
  827. v("_SC_TYPED_MEMORY_OBJECTS")
  828. v("_SC_TZNAME_MAX")
  829. v("_SC_V6_ILP32_OFF32")
  830. v("_SC_V6_ILP32_OFFBIG")
  831. v("_SC_V6_LP64_OFF64")
  832. v("_SC_V6_LPBIG_OFFBIG")
  833. v("_SC_VERSION")
  834. v("_SC_XBS5_ILP32_OFF32")
  835. v("_SC_XBS5_ILP32_OFFBIG")
  836. v("_SC_XBS5_LP64_OFF64")
  837. v("_SC_XBS5_LPBIG_OFFBIG")
  838. v("_SC_XOPEN_CRYPT")
  839. v("_SC_XOPEN_ENH_I18N")
  840. v("_SC_XOPEN_LEGACY")
  841. v("_SC_XOPEN_REALTIME")
  842. v("_SC_XOPEN_REALTIME_THREADS")
  843. v("_SC_XOPEN_SHM")
  844. v("_SC_XOPEN_STREAMS")
  845. v("_SC_XOPEN_UNIX")
  846. v("_SC_XOPEN_VERSION")
  847. v("_SC_NPROCESSORS_ONLN")
  848. v("SEEK_SET")
  849. v("SEEK_CUR")
  850. v("SEEK_END")
  851. main()