posix_nintendoswitch.nim 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2018 Joey Yakimowich-Payne
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. # To be included from posix.nim!
  10. const
  11. hasSpawnH = true
  12. hasAioH = false
  13. type
  14. DIR* {.importc: "DIR", header: "<dirent.h>",
  15. incompleteStruct.} = object
  16. const SIG_HOLD* = cast[Sighandler](2)
  17. type
  18. SocketHandle* = distinct cint # The type used to represent socket descriptors
  19. type
  20. Time* {.importc: "time_t", header: "<time.h>".} = distinct clong
  21. Timespec* {.importc: "struct timespec",
  22. header: "<time.h>", final, pure.} = object ## struct timespec
  23. tv_sec*: Time ## Seconds.
  24. tv_nsec*: clong ## Nanoseconds.
  25. Dirent* {.importc: "struct dirent",
  26. header: "<dirent.h>", final, pure.} = object ## dirent_t struct
  27. d_ino*: Ino
  28. d_type*: int8 # uint8 really!
  29. d_name*: array[256, cchar]
  30. Tflock* {.importc: "struct flock", final, pure,
  31. header: "<fcntl.h>".} = object ## flock type
  32. l_type*: cshort ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
  33. l_whence*: cshort ## Flag for starting offset.
  34. l_start*: Off ## Relative offset in bytes.
  35. l_len*: Off ## Size; if 0 then until EOF.
  36. l_pid*: Pid ## Process ID of the process holding the lock;
  37. ## returned with F_GETLK.
  38. # no struct FTW on linux
  39. Glob* {.importc: "glob_t", header: "<glob.h>",
  40. final, pure.} = object ## glob_t
  41. gl_pathc*: cint ## Count of paths matched by pattern.
  42. gl_matchc*: cint ## Count of paths matching pattern
  43. gl_offs*: cint ## Slots to reserve at the beginning of gl_pathv.
  44. gl_flags*: cint
  45. gl_pathv*: cstringArray ## Pointer to a list of matched pathnames.
  46. gl_errfunc*: pointer
  47. gl_closedir*: pointer
  48. gl_readdir*: pointer
  49. gl_opendir*: pointer
  50. gl_lstat*: pointer
  51. gl_stat*: pointer
  52. Group* {.importc: "struct group", header: "<grp.h>",
  53. final, pure.} = object ## struct group
  54. gr_name*: cstring ## The name of the group.
  55. gr_passwd*: cstring
  56. gr_gid*: Gid ## Numerical group ID.
  57. gr_mem*: cstringArray ## Pointer to a null-terminated array of character
  58. ## pointers to member names.
  59. Iconv* {.importc: "iconv_t", header: "<iconv.h>".} = pointer
  60. ## Identifies the conversion from one codeset to another.
  61. Lconv* {.importc: "struct lconv", header: "<locale.h>", final,
  62. pure.} = object
  63. decimal_point*: cstring
  64. thousands_sep*: cstring
  65. grouping*: cstring
  66. int_curr_symbol*: cstring
  67. currency_symbol*: cstring
  68. mon_decimal_point*: cstring
  69. mon_thousands_sep*: cstring
  70. mon_grouping*: cstring
  71. positive_sign*: cstring
  72. negative_sign*: cstring
  73. int_frac_digits*: char
  74. frac_digits*: char
  75. p_cs_precedes*: char
  76. p_sep_by_space*: char
  77. n_cs_precedes*: char
  78. n_sep_by_space*: char
  79. p_sign_posn*: char
  80. n_sign_posn*: char
  81. int_n_cs_precedes*: char
  82. int_n_sep_by_space*: char
  83. int_n_sign_posn*: char
  84. int_p_cs_precedes*: char
  85. int_p_sep_by_space*: char
  86. int_p_sign_posn*: char
  87. Passwd* {.importc: "struct passwd", header: "<pwd.h>",
  88. final, pure.} = object ## struct passwd
  89. pw_name*: cstring ## User's login name.
  90. pw_passwd*: cstring
  91. pw_uid*: Uid ## Numerical user ID.
  92. pw_gid*: Gid ## Numerical group ID.
  93. pw_comment*: cstring
  94. pw_gecos*: cstring
  95. pw_dir*: cstring ## Initial working directory.
  96. pw_shell*: cstring ## Program to use as shell.
  97. Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = clong
  98. ## used for file block counts
  99. Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = clong
  100. ## used for block sizes
  101. Clock* {.importc: "clock_t", header: "<sys/types.h>".} = clong
  102. ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = cint
  103. Dev* {.importc: "dev_t", header: "<sys/types.h>".} = culong
  104. Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = culong
  105. Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = culong
  106. Gid* {.importc: "gid_t", header: "<sys/types.h>".} = cuint
  107. Id* {.importc: "id_t", header: "<sys/types.h>".} = cuint
  108. Ino* {.importc: "ino_t", header: "<sys/types.h>".} = culong
  109. Key* {.importc: "key_t", header: "<sys/types.h>".} = cint
  110. Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint16
  111. Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = culong
  112. Off* {.importc: "off_t", header: "<sys/types.h>".} = clong
  113. Pid* {.importc: "pid_t", header: "<sys/types.h>".} = cint
  114. Pthread_attr* {.importc: "pthread_attr_t", header: "<sys/types.h>",
  115. pure, final.} = object
  116. abi: array[56 div sizeof(clong), clong]
  117. Pthread_barrier* {.importc: "pthread_barrier_t",
  118. header: "<sys/types.h>", pure, final.} = object
  119. abi: array[32 div sizeof(clong), clong]
  120. Pthread_barrierattr* {.importc: "pthread_barrierattr_t",
  121. header: "<sys/types.h>", pure, final.} = object
  122. abi: array[4 div sizeof(cint), cint]
  123. Pthread_cond* {.importc: "pthread_cond_t", header: "<sys/types.h>",
  124. pure, final.} = object
  125. abi: array[48 div sizeof(clonglong), clonglong]
  126. Pthread_condattr* {.importc: "pthread_condattr_t",
  127. header: "<sys/types.h>", pure, final.} = object
  128. abi: array[4 div sizeof(cint), cint]
  129. Pthread_key* {.importc: "pthread_key_t", header: "<sys/types.h>".} = cuint
  130. Pthread_mutex* {.importc: "pthread_mutex_t", header: "<sys/types.h>",
  131. pure, final.} = object
  132. abi: array[48 div sizeof(clong), clong]
  133. Pthread_mutexattr* {.importc: "pthread_mutexattr_t",
  134. header: "<sys/types.h>", pure, final.} = object
  135. abi: array[4 div sizeof(cint), cint]
  136. Pthread_once* {.importc: "pthread_once_t", header: "<sys/types.h>".} = cint
  137. Pthread_rwlock* {.importc: "pthread_rwlock_t",
  138. header: "<sys/types.h>", pure, final.} = object
  139. abi: array[56 div sizeof(clong), clong]
  140. Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
  141. header: "<sys/types.h>".} = object
  142. abi: array[8 div sizeof(clong), clong]
  143. Pthread_spinlock* {.importc: "pthread_spinlock_t",
  144. header: "<sys/types.h>".} = cint
  145. Pthread* {.importc: "pthread_t", header: "<sys/types.h>".} = culong
  146. Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = clong
  147. #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
  148. Timer* {.importc: "timer_t", header: "<sys/types.h>".} = pointer
  149. Uid* {.importc: "uid_t", header: "<sys/types.h>".} = cuint
  150. Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = cuint
  151. Utsname* {.importc: "struct utsname",
  152. header: "<sys/utsname.h>",
  153. final, pure.} = object ## struct utsname
  154. sysname*, ## Name of this implementation of the operating system.
  155. nodename*, ## Name of this node within the communications
  156. ## network to which this node is attached, if any.
  157. release*, ## Current release level of this implementation.
  158. version*, ## Current version level of this release.
  159. machine*, ## Name of the hardware type on which the
  160. ## system is running.
  161. domainname*: array[65, char]
  162. Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
  163. abi: array[32 div sizeof(clong), clong]
  164. Stat* {.importc: "struct stat",
  165. header: "<sys/stat.h>", final, pure.} = object ## struct stat
  166. st_dev*: Dev ## Device ID of device containing file.
  167. st_ino*: Ino ## File serial number.
  168. st_mode*: Mode ## Mode of file (see below).
  169. st_nlink*: Nlink ## Number of hard links to the file.
  170. st_uid*: Uid ## User ID of file.
  171. st_gid*: Gid ## Group ID of file.
  172. st_rdev*: Dev ## Device ID (if file is character or block special).
  173. st_size*: Off ## For regular files, the file size in bytes.
  174. ## For symbolic links, the length in bytes of the
  175. ## pathname contained in the symbolic link.
  176. ## For a shared memory object, the length in bytes.
  177. ## For a typed memory object, the length in bytes.
  178. ## For other file types, the use of this field is
  179. ## unspecified.
  180. when StatHasNanoseconds:
  181. st_atim*: Timespec ## Time of last access.
  182. pad1: clong
  183. st_mtim*: Timespec ## Time of last data modification.
  184. pad2: clong
  185. st_ctim*: Timespec ## Time of last status change.
  186. pad3: clong
  187. else:
  188. st_atime*: Time ## Time of last access.
  189. pad1: clong
  190. st_mtime*: Time ## Time of last data modification.
  191. pad2: clong
  192. st_ctime*: Time ## Time of last status change.
  193. pad3: clong
  194. st_blksize*: Blksize ## A file system-specific preferred I/O block size
  195. ## for this object. In some file system types, this
  196. ## may vary from file to file.
  197. st_blocks*: Blkcnt ## Number of blocks allocated for this object.
  198. reserved: array[2, clong]
  199. Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
  200. final, pure.} = object ## struct statvfs
  201. f_bsize*: culong ## File system block size.
  202. f_frsize*: culong ## Fundamental file system block size.
  203. f_blocks*: Fsblkcnt ## Total number of blocks on file system
  204. ## in units of f_frsize.
  205. f_bfree*: Fsblkcnt ## Total number of free blocks.
  206. f_bavail*: Fsblkcnt ## Number of free blocks available to
  207. ## non-privileged process.
  208. f_files*: Fsfilcnt ## Total number of file serial numbers.
  209. f_ffree*: Fsfilcnt ## Total number of free file serial numbers.
  210. f_favail*: Fsfilcnt ## Number of file serial numbers available to
  211. ## non-privileged process.
  212. f_fsid*: culong ## File system ID.
  213. f_flag*: culong ## Bit mask of f_flag values.
  214. f_namemax*: culong ## Maximum filename length.
  215. # No Posix_typed_mem_info
  216. Tm* {.importc: "struct tm", header: "<time.h>",
  217. final, pure.} = object ## struct tm
  218. tm_sec*: cint ## Seconds [0,60].
  219. tm_min*: cint ## Minutes [0,59].
  220. tm_hour*: cint ## Hour [0,23].
  221. tm_mday*: cint ## Day of month [1,31].
  222. tm_mon*: cint ## Month of year [0,11].
  223. tm_year*: cint ## Years since 1900.
  224. tm_wday*: cint ## Day of week [0,6] (Sunday =0).
  225. tm_yday*: cint ## Day of year [0,365].
  226. tm_isdst*: cint ## Daylight Savings flag.
  227. Itimerspec* {.importc: "struct itimerspec", header: "<time.h>",
  228. final, pure.} = object ## struct itimerspec
  229. it_interval*: Timespec ## Timer period.
  230. it_value*: Timespec ## Timer expiration.
  231. Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
  232. ## Possibly volatile-qualified integer type of an object that can be
  233. ## accessed as an atomic entity, even in the presence of asynchronous
  234. ## interrupts.
  235. Sigset* {.importc: "sigset_t", header: "<signal.h>", final.} = culong
  236. SigEvent* {.importc: "struct sigevent",
  237. header: "<signal.h>", final, pure.} = object ## struct sigevent
  238. sigev_notify*: cint ## Notification type.
  239. sigev_signo*: cint ## Signal number.
  240. sigev_value*: SigVal ## Signal value.
  241. SigVal* {.importc: "union sigval",
  242. header: "<signal.h>", final, pure.} = object ## struct sigval
  243. sival_int*: cint ## integer signal value
  244. sival_ptr*: pointer ## pointer signal value;
  245. Sigaction* {.importc: "struct sigaction",
  246. header: "<signal.h>", final, pure.} = object ## struct sigaction
  247. sa_handler*: proc (x: cint) {.noconv.} ## Pointer to a signal-catching
  248. ## function or one of the macros
  249. ## SIG_IGN or SIG_DFL.
  250. sa_mask*: Sigset ## Set of signals to be blocked during execution of
  251. ## the signal handling function.
  252. sa_flags*: cint ## Special flags.
  253. Stack* {.importc: "stack_t",
  254. header: "<signal.h>", final, pure.} = object ## stack_t
  255. ss_sp*: pointer ## Stack base or pointer.
  256. ss_flags*: cint ## Flags.
  257. ss_size*: csize ## Stack size.
  258. SigInfo* {.importc: "siginfo_t",
  259. header: "<signal.h>", final, pure.} = object ## siginfo_t
  260. si_signo*: cint ## Signal number.
  261. si_code*: cint ## Signal code.
  262. si_value*: SigVal ## Signal value.
  263. Nl_item* {.importc: "nl_item", header: "<langinfo.h>".} = cint
  264. Sched_param* {.importc: "struct sched_param",
  265. header: "<sched.h>",
  266. final, pure.} = object ## struct sched_param
  267. sched_priority*: cint
  268. Timeval* {.importc: "struct timeval", header: "<sys/select.h>",
  269. final, pure.} = object ## struct timeval
  270. tv_sec*: Time ## Seconds.
  271. tv_usec*: Suseconds ## Microseconds.
  272. TFdSet* {.importc: "fd_set", header: "<sys/select.h>",
  273. final, pure.} = object
  274. abi: array[((64+(sizeof(clong) * 8)-1) div (sizeof(clong) * 8)), clong]
  275. proc si_pid*(info: SigInfo): Pid =
  276. ## This might not be correct behavior. si_pid doesn't exist in Switch's
  277. ## devkitpro headers
  278. raise newException(OSError, "Nintendo switch cannot get si_pid!")
  279. type
  280. Taiocb* {.importc: "struct aiocb", header: "<aio.h>",
  281. final, pure.} = object ## struct aiocb
  282. aio_fildes*: cint ## File descriptor.
  283. aio_lio_opcode*: cint ## Operation to be performed.
  284. aio_reqprio*: cint ## Request priority offset.
  285. aio_buf*: pointer ## Location of buffer.
  286. aio_nbytes*: csize ## Length of transfer.
  287. aio_sigevent*: SigEvent ## Signal number and value.
  288. next_prio: pointer
  289. abs_prio: cint
  290. policy: cint
  291. error_Code: cint
  292. return_value: clong
  293. aio_offset*: Off ## File offset.
  294. reserved: array[32, uint8]
  295. type
  296. Tposix_spawnattr* {.importc: "posix_spawnattr_t",
  297. header: "<spawn.h>", final, pure.} = object
  298. Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
  299. header: "<spawn.h>", final, pure.} = object
  300. # from sys/un.h
  301. const Sockaddr_un_path_length* = 108
  302. type
  303. SockLen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint
  304. # cushort really
  305. TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = cshort
  306. SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
  307. pure, final.} = object ## struct sockaddr
  308. sa_len: uint8
  309. sa_family*: TSa_Family ## Address family.
  310. sa_data*: array[14, char] ## Socket address (variable-length data).
  311. Sockaddr_storage* {.importc: "struct sockaddr_storage",
  312. header: "<sys/socket.h>",
  313. pure, final.} = object ## struct sockaddr_storage
  314. ss_len: uint8
  315. ss_family*: TSa_Family ## Address family.
  316. ss_padding1: array[64 - sizeof(uint8) - sizeof(cshort), char]
  317. ss_align: clonglong
  318. ss_padding2: array[
  319. 128 - sizeof(uint8) - sizeof(cshort) -
  320. (64 - sizeof(uint8) - sizeof(cshort)) - 64, char]
  321. Tif_nameindex* {.importc: "struct if_nameindex", final,
  322. pure, header: "<net/if.h>".} = object ## struct if_nameindex
  323. if_index*: cuint ## Numeric index of the interface.
  324. if_name*: cstring ## Null-terminated name of the interface.
  325. IOVec* {.importc: "struct iovec", pure, final,
  326. header: "<sys/socket.h>".} = object ## struct iovec
  327. iov_base*: pointer ## Base address of a memory region for input or output.
  328. iov_len*: csize_t ## The size of the memory pointed to by iov_base.
  329. Tmsghdr* {.importc: "struct msghdr", pure, final,
  330. header: "<sys/socket.h>".} = object ## struct msghdr
  331. msg_name*: pointer ## Optional address.
  332. msg_namelen*: SockLen ## Size of address.
  333. msg_iov*: ptr IOVec ## Scatter/gather array.
  334. msg_iovlen*: csize ## Members in msg_iov.
  335. msg_control*: pointer ## Ancillary data; see below.
  336. msg_controllen*: csize ## Ancillary data buffer len.
  337. msg_flags*: cint ## Flags on received message.
  338. Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
  339. header: "<sys/socket.h>".} = object ## struct cmsghdr
  340. cmsg_len*: csize ## Data byte count, including the cmsghdr.
  341. cmsg_level*: cint ## Originating protocol.
  342. cmsg_type*: cint ## Protocol-specific type.
  343. TLinger* {.importc: "struct linger", pure, final,
  344. header: "<sys/socket.h>".} = object ## struct linger
  345. l_onoff*: cint ## Indicates whether linger option is enabled.
  346. l_linger*: cint ## Linger time, in seconds.
  347. # data follows...
  348. InPort* = uint16
  349. InAddrScalar* = uint32
  350. InAddrT* {.importc: "in_addr_t", pure, final,
  351. header: "<netinet/in.h>".} = uint32
  352. InAddr* {.importc: "struct in_addr", pure, final,
  353. header: "<netinet/in.h>".} = object ## struct in_addr
  354. s_addr*: InAddrScalar
  355. Sockaddr_in* {.importc: "struct sockaddr_in", pure, final,
  356. header: "<netinet/in.h>".} = object ## struct sockaddr_in
  357. sin_len*: cushort
  358. sin_family*: TSa_Family ## AF_INET.
  359. sin_port*: InPort ## Port number.
  360. sin_addr*: InAddr ## IP address.
  361. sin_zero: array[8, uint8]
  362. In6Addr* {.importc: "struct in6_addr", pure, final,
  363. header: "<netinet/in.h>".} = object ## struct in6_addr
  364. s6_addr*: array[0..15, char]
  365. Sockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
  366. header: "<netinet/in.h>".} = object ## struct sockaddr_in6
  367. sin6_family*: TSa_Family ## AF_INET6.
  368. sin6_port*: InPort ## Port number.
  369. sin6_flowinfo*: uint32 ## IPv6 traffic class and flow information.
  370. sin6_addr*: In6Addr ## IPv6 address.
  371. sin6_scope_id*: uint32 ## Set of interfaces for a scope.
  372. Hostent* {.importc: "struct hostent", pure, final,
  373. header: "<netdb.h>".} = object ## struct hostent
  374. h_name*: cstring ## Official name of the host.
  375. h_aliases*: cstringArray ## A pointer to an array of pointers to
  376. ## alternative host names, terminated by a
  377. ## null pointer.
  378. h_addrtype*: cint ## Address type.
  379. h_length*: cint ## The length, in bytes, of the address.
  380. h_addr_list*: cstringArray ## A pointer to an array of pointers to network
  381. ## addresses (in network byte order) for the
  382. ## host, terminated by a null pointer.
  383. Tnetent* {.importc: "struct netent", pure, final,
  384. header: "<netdb.h>".} = object ## struct netent
  385. n_name*: cstring ## Official, fully-qualified (including the
  386. ## domain) name of the host.
  387. n_aliases*: cstringArray ## A pointer to an array of pointers to
  388. ## alternative network names, terminated by a
  389. ## null pointer.
  390. n_addrtype*: cint ## The address type of the network.
  391. n_net*: uint32 ## The network number, in host byte order.
  392. Protoent* {.importc: "struct protoent", pure, final,
  393. header: "<netdb.h>".} = object ## struct protoent
  394. p_name*: cstring ## Official name of the protocol.
  395. p_aliases*: cstringArray ## A pointer to an array of pointers to
  396. ## alternative protocol names, terminated by
  397. ## a null pointer.
  398. p_proto*: cint ## The protocol number.
  399. Servent* {.importc: "struct servent", pure, final,
  400. header: "<netdb.h>".} = object ## struct servent
  401. s_name*: cstring ## Official name of the service.
  402. s_aliases*: cstringArray ## A pointer to an array of pointers to
  403. ## alternative service names, terminated by
  404. ## a null pointer.
  405. s_port*: cint ## The port number at which the service
  406. ## resides, in network byte order.
  407. s_proto*: cstring ## The name of the protocol to use when
  408. ## contacting the service.
  409. AddrInfo* {.importc: "struct addrinfo", pure, final,
  410. header: "<netdb.h>".} = object ## struct addrinfo
  411. ai_flags*: cint ## Input flags.
  412. ai_family*: cint ## Address family of socket.
  413. ai_socktype*: cint ## Socket type.
  414. ai_protocol*: cint ## Protocol of socket.
  415. ai_addrlen*: SockLen ## Length of socket address.
  416. ai_canonname*: cstring ## Canonical name of service location.
  417. ai_addr*: ptr SockAddr ## Socket address of socket.
  418. ai_next*: ptr AddrInfo ## Pointer to next in list.
  419. TPollfd* {.importc: "struct pollfd", pure, final,
  420. header: "<poll.h>".} = object ## struct pollfd
  421. fd*: cint ## The following descriptor being polled.
  422. events*: cshort ## The input event flags (see below).
  423. revents*: cshort ## The output event flags (see below).
  424. Tnfds* {.importc: "nfds_t", header: "<poll.h>".} = culong
  425. var
  426. errno* {.importc, header: "<errno.h>".}: cint ## error variable
  427. h_errno* {.importc, header: "<netdb.h>".}: cint
  428. daylight* {.importc: "_daylight", header: "<time.h>".}: cint
  429. timezone* {.importc: "_timezone", header: "<time.h>".}: clong
  430. # Regenerate using detect.nim!
  431. include posix_nintendoswitch_consts
  432. const POSIX_SPAWN_USEVFORK* = cint(0x40) # needs _GNU_SOURCE!
  433. # <sys/wait.h>
  434. proc WEXITSTATUS*(s: cint): cint = (s shr 8) and 0xff
  435. proc WIFEXITED*(s:cint) : bool = (s and 0xff) == 0
  436. proc WTERMSIG*(s:cint): cint = s and 0x7f
  437. proc WSTOPSIG*(s:cint): cint = WEXITSTATUS(s)
  438. proc WIFSIGNALED*(s:cint) : bool = ((s and 0x7f) > 0) and ((s and 0x7f) < 0x7f)
  439. proc WIFSTOPPED*(s:cint) : bool = (s and 0xff) == 0x7f