detect.nim 17 KB

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