posix_openbsd_amd64.nim 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. #
  2. #
  3. # Nim's Runtime Library
  4. # (c) Copyright 2012 Andreas Rumpf
  5. #
  6. # See the file "copying.txt", included in this
  7. # distribution, for details about the copyright.
  8. #
  9. when defined(nimHasStyleChecks):
  10. {.push styleChecks: off.}
  11. const
  12. hasSpawnH = true # should exist for every Posix system nowadays
  13. hasAioH = false
  14. type
  15. DIR* {.importc: "DIR", header: "<dirent.h>",
  16. incompleteStruct.} = object
  17. ## A type representing a directory stream.
  18. type
  19. SocketHandle* = distinct cint # The type used to represent socket descriptors
  20. type
  21. Time* {.importc: "time_t", header: "<time.h>".} = distinct clonglong
  22. Timespec* {.importc: "struct timespec",
  23. header: "<time.h>", final, pure.} = object ## struct timespec
  24. tv_sec*: Time ## Seconds.
  25. tv_nsec*: int ## Nanoseconds.
  26. Dirent* {.importc: "struct dirent",
  27. header: "<dirent.h>", final, pure.} = object ## dirent_t struct
  28. when defined(haiku):
  29. d_dev*: Dev ## Device (not POSIX)
  30. d_pdev*: Dev ## Parent device (only for queries) (not POSIX)
  31. d_ino*: Ino ## File serial number.
  32. when defined(dragonfly):
  33. # DragonflyBSD doesn't have `d_reclen` field.
  34. d_type*: uint8
  35. elif defined(linux) or defined(macosx) or defined(freebsd) or
  36. defined(netbsd) or defined(openbsd) or defined(genode):
  37. d_reclen*: cshort ## Length of this record. (not POSIX)
  38. d_type*: int8 ## Type of file; not supported by all filesystem types.
  39. ## (not POSIX)
  40. when defined(linux) or defined(openbsd):
  41. d_off*: Off ## Not an offset. Value that `telldir()` would return.
  42. elif defined(haiku):
  43. d_pino*: Ino ## Parent inode (only for queries) (not POSIX)
  44. d_reclen*: cushort ## Length of this record. (not POSIX)
  45. d_name*: array[0..255, char] ## Name of entry.
  46. Tflock* {.importc: "struct flock", final, pure,
  47. header: "<fcntl.h>".} = object ## flock type
  48. l_type*: cshort ## Type of lock; F_RDLCK, F_WRLCK, F_UNLCK.
  49. l_whence*: cshort ## Flag for starting offset.
  50. l_start*: Off ## Relative offset in bytes.
  51. l_len*: Off ## Size; if 0 then until EOF.
  52. l_pid*: Pid ## Process ID of the process holding the lock;
  53. ## returned with F_GETLK.
  54. FTW* {.importc: "struct FTW", header: "<ftw.h>", final, pure.} = object
  55. base*: cint
  56. level*: cint
  57. Glob* {.importc: "glob_t", header: "<glob.h>",
  58. final, pure.} = object ## glob_t
  59. gl_pathc*: int ## Count of paths matched by pattern.
  60. gl_pathv*: cstringArray ## Pointer to a list of matched pathnames.
  61. gl_offs*: int ## Slots to reserve at the beginning of gl_pathv.
  62. Group* {.importc: "struct group", header: "<grp.h>",
  63. final, pure.} = object ## struct group
  64. gr_name*: cstring ## The name of the group.
  65. gr_gid*: Gid ## Numerical group ID.
  66. gr_mem*: cstringArray ## Pointer to a null-terminated array of character
  67. ## pointers to member names.
  68. Iconv* {.importc: "iconv_t", header: "<iconv.h>", final, pure.} =
  69. object ## Identifies the conversion from one codeset to another.
  70. Lconv* {.importc: "struct lconv", header: "<locale.h>", final,
  71. pure.} = object
  72. currency_symbol*: cstring
  73. decimal_point*: cstring
  74. frac_digits*: char
  75. grouping*: cstring
  76. int_curr_symbol*: cstring
  77. int_frac_digits*: char
  78. int_n_cs_precedes*: char
  79. int_n_sep_by_space*: char
  80. int_n_sign_posn*: char
  81. int_p_cs_precedes*: char
  82. int_p_sep_by_space*: char
  83. int_p_sign_posn*: char
  84. mon_decimal_point*: cstring
  85. mon_grouping*: cstring
  86. mon_thousands_sep*: cstring
  87. negative_sign*: cstring
  88. n_cs_precedes*: char
  89. n_sep_by_space*: char
  90. n_sign_posn*: char
  91. positive_sign*: cstring
  92. p_cs_precedes*: char
  93. p_sep_by_space*: char
  94. p_sign_posn*: char
  95. thousands_sep*: cstring
  96. Mqd* {.importc: "mqd_t", header: "<mqueue.h>", final, pure.} = object
  97. MqAttr* {.importc: "struct mq_attr",
  98. header: "<mqueue.h>",
  99. final, pure.} = object ## message queue attribute
  100. mq_flags*: int ## Message queue flags.
  101. mq_maxmsg*: int ## Maximum number of messages.
  102. mq_msgsize*: int ## Maximum message size.
  103. mq_curmsgs*: int ## Number of messages currently queued.
  104. Passwd* {.importc: "struct passwd", header: "<pwd.h>",
  105. final, pure.} = object ## struct passwd
  106. pw_name*: cstring ## User's login name.
  107. pw_uid*: Uid ## Numerical user ID.
  108. pw_gid*: Gid ## Numerical group ID.
  109. pw_dir*: cstring ## Initial working directory.
  110. pw_shell*: cstring ## Program to use as shell.
  111. Blkcnt* {.importc: "blkcnt_t", header: "<sys/types.h>".} = int
  112. ## used for file block counts
  113. Blksize* {.importc: "blksize_t", header: "<sys/types.h>".} = int32
  114. ## used for block sizes
  115. Clock* {.importc: "clock_t", header: "<sys/types.h>".} = int
  116. ClockId* {.importc: "clockid_t", header: "<sys/types.h>".} = int
  117. Dev* {.importc: "dev_t", header: "<sys/types.h>".} = (
  118. when defined(freebsd):
  119. uint32
  120. else:
  121. int32)
  122. Fsblkcnt* {.importc: "fsblkcnt_t", header: "<sys/types.h>".} = int
  123. Fsfilcnt* {.importc: "fsfilcnt_t", header: "<sys/types.h>".} = int
  124. Gid* {.importc: "gid_t", header: "<sys/types.h>".} = uint32
  125. Id* {.importc: "id_t", header: "<sys/types.h>".} = int
  126. Ino* {.importc: "ino_t", header: "<sys/types.h>".} = int
  127. Key* {.importc: "key_t", header: "<sys/types.h>".} = int
  128. Mode* {.importc: "mode_t", header: "<sys/types.h>".} = uint32
  129. Nlink* {.importc: "nlink_t", header: "<sys/types.h>".} = uint32
  130. Off* {.importc: "off_t", header: "<sys/types.h>".} = int64
  131. Pid* {.importc: "pid_t", header: "<sys/types.h>".} = int32
  132. Pthread_attr* {.importc: "pthread_attr_t", header: "<pthread.h>".} = int
  133. Pthread_barrier* {.importc: "pthread_barrier_t",
  134. header: "<pthread.h>".} = int
  135. Pthread_barrierattr* {.importc: "pthread_barrierattr_t",
  136. header: "<pthread.h>".} = int
  137. Pthread_cond* {.importc: "pthread_cond_t", header: "<pthread.h>".} = int
  138. Pthread_condattr* {.importc: "pthread_condattr_t",
  139. header: "<pthread.h>".} = int
  140. Pthread_key* {.importc: "pthread_key_t", header: "<pthread.h>".} = int
  141. Pthread_mutex* {.importc: "pthread_mutex_t", header: "<pthread.h>".} = int
  142. Pthread_mutexattr* {.importc: "pthread_mutexattr_t",
  143. header: "<pthread.h>".} = int
  144. Pthread_once* {.importc: "pthread_once_t", header: "<pthread.h>".} = int
  145. Pthread_rwlock* {.importc: "pthread_rwlock_t",
  146. header: "<pthread.h>".} = int
  147. Pthread_rwlockattr* {.importc: "pthread_rwlockattr_t",
  148. header: "<pthread.h>".} = int
  149. Pthread_spinlock* {.importc: "pthread_spinlock_t",
  150. header: "<pthread.h>".} = int
  151. Pthread* {.importc: "pthread_t", header: "<pthread.h>".} = int
  152. Suseconds* {.importc: "suseconds_t", header: "<sys/types.h>".} = int32
  153. #Ttime* {.importc: "time_t", header: "<sys/types.h>".} = int
  154. Timer* {.importc: "timer_t", header: "<sys/types.h>".} = int
  155. Trace_attr* {.importc: "trace_attr_t", header: "<sys/types.h>".} = int
  156. Trace_event_id* {.importc: "trace_event_id_t",
  157. header: "<sys/types.h>".} = int
  158. Trace_event_set* {.importc: "trace_event_set_t",
  159. header: "<sys/types.h>".} = int
  160. Trace_id* {.importc: "trace_id_t", header: "<sys/types.h>".} = int
  161. Uid* {.importc: "uid_t", header: "<sys/types.h>".} = uint32
  162. Useconds* {.importc: "useconds_t", header: "<sys/types.h>".} = int
  163. Utsname* {.importc: "struct utsname",
  164. header: "<sys/utsname.h>",
  165. final, pure.} = object ## struct utsname
  166. sysname*, ## Name of this implementation of the operating system.
  167. nodename*, ## Name of this node within the communications
  168. ## network to which this node is attached, if any.
  169. release*, ## Current release level of this implementation.
  170. version*, ## Current version level of this release.
  171. machine*: array[0..255, char] ## Name of the hardware type on which the
  172. ## system is running.
  173. Sem* {.importc: "sem_t", header: "<semaphore.h>", final, pure.} = object
  174. Ipc_perm* {.importc: "struct ipc_perm",
  175. header: "<sys/ipc.h>", final, pure.} = object ## struct ipc_perm
  176. uid*: Uid ## Owner's user ID.
  177. gid*: Gid ## Owner's group ID.
  178. cuid*: Uid ## Creator's user ID.
  179. cgid*: Gid ## Creator's group ID.
  180. mode*: Mode ## Read/write permission.
  181. Stat* {.importc: "struct stat",
  182. header: "<sys/stat.h>", final, pure.} = object ## struct stat
  183. st_dev*: Dev ## Device ID of device containing file.
  184. st_ino*: Ino ## File serial number.
  185. st_mode*: Mode ## Mode of file (see below).
  186. st_nlink*: Nlink ## Number of hard links to the file.
  187. st_uid*: Uid ## User ID of file.
  188. st_gid*: Gid ## Group ID of file.
  189. st_rdev*: Dev ## Device ID (if file is character or block special).
  190. st_size*: Off ## For regular files, the file size in bytes.
  191. ## For symbolic links, the length in bytes of the
  192. ## pathname contained in the symbolic link.
  193. ## For a shared memory object, the length in bytes.
  194. ## For a typed memory object, the length in bytes.
  195. ## For other file types, the use of this field is
  196. ## unspecified.
  197. when StatHasNanoseconds:
  198. st_atim*: Timespec ## Time of last access.
  199. st_mtim*: Timespec ## Time of last data modification.
  200. st_ctim*: Timespec ## Time of last status change.
  201. else:
  202. st_atime*: Time ## Time of last access.
  203. st_mtime*: Time ## Time of last data modification.
  204. st_ctime*: Time ## Time of last status change.
  205. st_blksize*: Blksize ## A file system-specific preferred I/O block size
  206. ## for this object. In some file system types, this
  207. ## may vary from file to file.
  208. st_blocks*: Blkcnt ## Number of blocks allocated for this object.
  209. Statvfs* {.importc: "struct statvfs", header: "<sys/statvfs.h>",
  210. final, pure.} = object ## struct statvfs
  211. f_bsize*: int ## File system block size.
  212. f_frsize*: int ## Fundamental file system block size.
  213. f_blocks*: Fsblkcnt ## Total number of blocks on file system
  214. ## in units of f_frsize.
  215. f_bfree*: Fsblkcnt ## Total number of free blocks.
  216. f_bavail*: Fsblkcnt ## Number of free blocks available to
  217. ## non-privileged process.
  218. f_files*: Fsfilcnt ## Total number of file serial numbers.
  219. f_ffree*: Fsfilcnt ## Total number of free file serial numbers.
  220. f_favail*: Fsfilcnt ## Number of file serial numbers available to
  221. ## non-privileged process.
  222. f_fsid*: int ## File system ID.
  223. f_flag*: int ## Bit mask of f_flag values.
  224. f_namemax*: int ## Maximum filename length.
  225. Posix_typed_mem_info* {.importc: "struct posix_typed_mem_info",
  226. header: "<sys/mman.h>", final, pure.} = object
  227. posix_tmi_length*: int
  228. Tm* {.importc: "struct tm", header: "<time.h>",
  229. final, pure.} = object ## struct tm
  230. tm_sec*: cint ## Seconds [0,60].
  231. tm_min*: cint ## Minutes [0,59].
  232. tm_hour*: cint ## Hour [0,23].
  233. tm_mday*: cint ## Day of month [1,31].
  234. tm_mon*: cint ## Month of year [0,11].
  235. tm_year*: cint ## Years since 1900.
  236. tm_wday*: cint ## Day of week [0,6] (Sunday =0).
  237. tm_yday*: cint ## Day of year [0,365].
  238. tm_isdst*: cint ## Daylight Savings flag.
  239. Itimerspec* {.importc: "struct itimerspec", header: "<time.h>",
  240. final, pure.} = object ## struct itimerspec
  241. it_interval*: Timespec ## Timer period.
  242. it_value*: Timespec ## Timer expiration.
  243. Sig_atomic* {.importc: "sig_atomic_t", header: "<signal.h>".} = cint
  244. ## Possibly volatile-qualified integer type of an object that can be
  245. ## accessed as an atomic entity, even in the presence of asynchronous
  246. ## interrupts.
  247. Sigset* {.importc: "sigset_t", header: "<signal.h>", final, pure.} = object
  248. SigEvent* {.importc: "struct sigevent",
  249. header: "<signal.h>", final, pure.} = object ## struct sigevent
  250. sigev_notify*: cint ## Notification type.
  251. sigev_signo*: cint ## Signal number.
  252. sigev_value*: SigVal ## Signal value.
  253. sigev_notify_function*: proc (x: SigVal) {.noconv.} ## Notification func.
  254. sigev_notify_attributes*: ptr Pthread_attr ## Notification attributes.
  255. SigVal* {.importc: "union sigval",
  256. header: "<signal.h>", final, pure.} = object ## struct sigval
  257. sival_ptr*: pointer ## pointer signal value;
  258. ## integer signal value not defined!
  259. Sigaction* {.importc: "struct sigaction",
  260. header: "<signal.h>", final, pure.} = object ## struct sigaction
  261. sa_handler*: proc (x: cint) {.noconv.} ## Pointer to a signal-catching
  262. ## function or one of the macros
  263. ## SIG_IGN or SIG_DFL.
  264. sa_mask*: Sigset ## Set of signals to be blocked during execution of
  265. ## the signal handling function.
  266. sa_flags*: cint ## Special flags.
  267. sa_sigaction*: proc (x: cint, y: ptr SigInfo, z: pointer) {.noconv.}
  268. Stack* {.importc: "stack_t",
  269. header: "<signal.h>", final, pure.} = object ## stack_t
  270. ss_sp*: pointer ## Stack base or pointer.
  271. ss_size*: int ## Stack size.
  272. ss_flags*: cint ## Flags.
  273. SigStack* {.importc: "struct sigstack",
  274. header: "<signal.h>", final, pure.} = object ## struct sigstack
  275. ss_onstack*: cint ## Non-zero when signal stack is in use.
  276. ss_sp*: pointer ## Signal stack pointer.
  277. SigInfo* {.importc: "siginfo_t",
  278. header: "<signal.h>", final, pure.} = object ## siginfo_t
  279. si_signo*: cint ## Signal number.
  280. si_code*: cint ## Signal code.
  281. si_errno*: cint ## If non-zero, an errno value associated with
  282. ## this signal, as defined in <errno.h>.
  283. si_pid*: Pid ## Sending process ID.
  284. si_uid*: Uid ## Real user ID of sending process.
  285. si_addr*: pointer ## Address of faulting instruction.
  286. si_status*: cint ## Exit value or signal.
  287. si_band*: int ## Band event for SIGPOLL.
  288. si_value*: SigVal ## Signal value.
  289. Nl_item* {.importc: "nl_item", header: "<nl_types.h>".} = cint
  290. Nl_catd* {.importc: "nl_catd", header: "<nl_types.h>".} = cint
  291. Sched_param* {.importc: "struct sched_param",
  292. header: "<sched.h>",
  293. final, pure.} = object ## struct sched_param
  294. sched_priority*: cint
  295. sched_ss_low_priority*: cint ## Low scheduling priority for
  296. ## sporadic server.
  297. sched_ss_repl_period*: Timespec ## Replenishment period for
  298. ## sporadic server.
  299. sched_ss_init_budget*: Timespec ## Initial budget for sporadic server.
  300. sched_ss_max_repl*: cint ## Maximum pending replenishments for
  301. ## sporadic server.
  302. Timeval* {.importc: "struct timeval", header: "<sys/select.h>",
  303. final, pure.} = object ## struct timeval
  304. tv_sec*: Time ## Seconds.
  305. tv_usec*: Suseconds ## Microseconds.
  306. TFdSet* {.importc: "fd_set", header: "<sys/select.h>",
  307. final, pure.} = object
  308. # the following aren't actually defined, but they're here to keep things happy for now
  309. Mcontext* {.importc: "mcontext_t", header: "<ucontext.h>",
  310. final, pure.} = object
  311. Ucontext* {.importc: "ucontext_t", header: "<ucontext.h>",
  312. final, pure.} = object ## ucontext_t
  313. uc_link*: ptr Ucontext ## Pointer to the context that is resumed
  314. ## when this context returns.
  315. uc_sigmask*: Sigset ## The set of signals that are blocked when this
  316. ## context is active.
  317. uc_stack*: Stack ## The stack used by this context.
  318. uc_mcontext*: Mcontext ## A machine-specific representation of the saved
  319. ## context.
  320. when hasAioH:
  321. type
  322. Taiocb* {.importc: "struct aiocb", header: "<aio.h>",
  323. final, pure.} = object ## struct aiocb
  324. aio_fildes*: cint ## File descriptor.
  325. aio_offset*: Off ## File offset.
  326. aio_buf*: pointer ## Location of buffer.
  327. aio_nbytes*: int ## Length of transfer.
  328. aio_reqprio*: cint ## Request priority offset.
  329. aio_sigevent*: SigEvent ## Signal number and value.
  330. aio_lio_opcode: cint ## Operation to be performed.
  331. when hasSpawnH:
  332. type
  333. Tposix_spawnattr* {.importc: "posix_spawnattr_t",
  334. header: "<spawn.h>", final, pure.} = object
  335. Tposix_spawn_file_actions* {.importc: "posix_spawn_file_actions_t",
  336. header: "<spawn.h>", final, pure.} = object
  337. # according to https://pubs.opengroup.org/onlinepubs/009604499/basedefs/sys/un.h.html
  338. # this is >=92
  339. const Sockaddr_un_path_length* = 92
  340. type
  341. SockLen* {.importc: "socklen_t", header: "<sys/socket.h>".} = cuint
  342. TSa_Family* {.importc: "sa_family_t", header: "<sys/socket.h>".} = uint8
  343. SockAddr* {.importc: "struct sockaddr", header: "<sys/socket.h>",
  344. pure, final.} = object ## struct sockaddr
  345. sa_family*: TSa_Family ## Address family.
  346. sa_data*: array[0..255, char] ## Socket address (variable-length data).
  347. Sockaddr_un* {.importc: "struct sockaddr_un", header: "<sys/un.h>",
  348. pure, final.} = object ## struct sockaddr_un
  349. sun_family*: TSa_Family ## Address family.
  350. sun_path*: array[0..Sockaddr_un_path_length-1, char] ## Socket path
  351. Sockaddr_storage* {.importc: "struct sockaddr_storage",
  352. header: "<sys/socket.h>",
  353. pure, final.} = object ## struct sockaddr_storage
  354. ss_family*: TSa_Family ## Address family.
  355. Tif_nameindex* {.importc: "struct if_nameindex", final,
  356. pure, header: "<net/if.h>".} = object ## struct if_nameindex
  357. if_index*: cint ## Numeric index of the interface.
  358. if_name*: cstring ## Null-terminated name of the interface.
  359. IOVec* {.importc: "struct iovec", pure, final,
  360. header: "<sys/uio.h>".} = object ## struct iovec
  361. iov_base*: pointer ## Base address of a memory region for input or output.
  362. iov_len*: csize_t ## The size of the memory pointed to by iov_base.
  363. Tmsghdr* {.importc: "struct msghdr", pure, final,
  364. header: "<sys/socket.h>".} = object ## struct msghdr
  365. msg_name*: pointer ## Optional address.
  366. msg_namelen*: SockLen ## Size of address.
  367. msg_iov*: ptr IOVec ## Scatter/gather array.
  368. msg_iovlen*: cint ## Members in msg_iov.
  369. msg_control*: pointer ## Ancillary data; see below.
  370. msg_controllen*: SockLen ## Ancillary data buffer len.
  371. msg_flags*: cint ## Flags on received message.
  372. Tcmsghdr* {.importc: "struct cmsghdr", pure, final,
  373. header: "<sys/socket.h>".} = object ## struct cmsghdr
  374. cmsg_len*: SockLen ## Data byte count, including the cmsghdr.
  375. cmsg_level*: cint ## Originating protocol.
  376. cmsg_type*: cint ## Protocol-specific type.
  377. TLinger* {.importc: "struct linger", pure, final,
  378. header: "<sys/socket.h>".} = object ## struct linger
  379. l_onoff*: cint ## Indicates whether linger option is enabled.
  380. l_linger*: cint ## Linger time, in seconds.
  381. InPort* = uint16
  382. InAddrScalar* = uint32
  383. InAddrT* {.importc: "in_addr_t", pure, final,
  384. header: "<netinet/in.h>".} = uint32
  385. InAddr* {.importc: "struct in_addr", pure, final,
  386. header: "<netinet/in.h>".} = object ## struct in_addr
  387. s_addr*: InAddrScalar
  388. Sockaddr_in* {.importc: "struct sockaddr_in", pure, final,
  389. header: "<netinet/in.h>".} = object ## struct sockaddr_in
  390. sin_family*: TSa_Family ## AF_INET.
  391. sin_port*: InPort ## Port number.
  392. sin_addr*: InAddr ## IP address.
  393. In6Addr* {.importc: "struct in6_addr", pure, final,
  394. header: "<netinet/in.h>".} = object ## struct in6_addr
  395. s6_addr*: array[0..15, char]
  396. Sockaddr_in6* {.importc: "struct sockaddr_in6", pure, final,
  397. header: "<netinet/in.h>".} = object ## struct sockaddr_in6
  398. sin6_family*: TSa_Family ## AF_INET6.
  399. sin6_port*: InPort ## Port number.
  400. sin6_flowinfo*: uint32 ## IPv6 traffic class and flow information.
  401. sin6_addr*: In6Addr ## IPv6 address.
  402. sin6_scope_id*: uint32 ## Set of interfaces for a scope.
  403. Tipv6_mreq* {.importc: "struct ipv6_mreq", pure, final,
  404. header: "<netinet/in.h>".} = object ## struct ipv6_mreq
  405. ipv6mr_multiaddr*: In6Addr ## IPv6 multicast address.
  406. ipv6mr_interface*: cint ## Interface index.
  407. Hostent* {.importc: "struct hostent", pure, final,
  408. header: "<netdb.h>".} = object ## struct hostent
  409. h_name*: cstring ## Official name of the host.
  410. h_aliases*: cstringArray ## A pointer to an array of pointers to
  411. ## alternative host names, terminated by a
  412. ## null pointer.
  413. h_addrtype*: cint ## Address type.
  414. h_length*: cint ## The length, in bytes, of the address.
  415. h_addr_list*: cstringArray ## A pointer to an array of pointers to network
  416. ## addresses (in network byte order) for the
  417. ## host, terminated by a null pointer.
  418. Tnetent* {.importc: "struct netent", pure, final,
  419. header: "<netdb.h>".} = object ## struct netent
  420. n_name*: cstring ## Official, fully-qualified (including the
  421. ## domain) name of the host.
  422. n_aliases*: cstringArray ## A pointer to an array of pointers to
  423. ## alternative network names, terminated by a
  424. ## null pointer.
  425. n_addrtype*: cint ## The address type of the network.
  426. n_net*: uint32 ## The network number, in host byte order.
  427. Protoent* {.importc: "struct protoent", pure, final,
  428. header: "<netdb.h>".} = object ## struct protoent
  429. p_name*: cstring ## Official name of the protocol.
  430. p_aliases*: cstringArray ## A pointer to an array of pointers to
  431. ## alternative protocol names, terminated by
  432. ## a null pointer.
  433. p_proto*: cint ## The protocol number.
  434. Servent* {.importc: "struct servent", pure, final,
  435. header: "<netdb.h>".} = object ## struct servent
  436. s_name*: cstring ## Official name of the service.
  437. s_aliases*: cstringArray ## A pointer to an array of pointers to
  438. ## alternative service names, terminated by
  439. ## a null pointer.
  440. s_port*: cint ## The port number at which the service
  441. ## resides, in network byte order.
  442. s_proto*: cstring ## The name of the protocol to use when
  443. ## contacting the service.
  444. AddrInfo* {.importc: "struct addrinfo", pure, final,
  445. header: "<netdb.h>".} = object ## struct addrinfo
  446. ai_flags*: cint ## Input flags.
  447. ai_family*: cint ## Address family of socket.
  448. ai_socktype*: cint ## Socket type.
  449. ai_protocol*: cint ## Protocol of socket.
  450. ai_addrlen*: SockLen ## Length of socket address.
  451. ai_addr*: ptr SockAddr ## Socket address of socket.
  452. ai_canonname*: cstring ## Canonical name of service location.
  453. ai_next*: ptr AddrInfo ## Pointer to next in list.
  454. TPollfd* {.importc: "struct pollfd", pure, final,
  455. header: "<poll.h>".} = object ## struct pollfd
  456. fd*: cint ## The following descriptor being polled.
  457. events*: cshort ## The input event flags (see below).
  458. revents*: cshort ## The output event flags (see below).
  459. var
  460. errno* {.importc, header: "<errno.h>".}: cint ## error variable
  461. h_errno* {.importc, header: "<netdb.h>".}: cint
  462. daylight* {.importc, header: "<time.h>".}: cint
  463. timezone* {.importc, header: "<time.h>".}: int
  464. # Regenerate using detect.nim!
  465. include posix_other_consts
  466. var
  467. MAP_POPULATE*: cint = 0
  468. when defined(nimdoc):
  469. const SO_REUSEPORT* = cint(0x0200)
  470. else:
  471. var SO_REUSEPORT* {.importc, header: "<sys/socket.h>".}: cint
  472. var SOCK_CLOEXEC* {.importc, header: "<sys/socket.h>".}: cint
  473. var MSG_NOSIGNAL* {.importc, header: "<sys/socket.h>".}: cint
  474. when hasSpawnH:
  475. # openbsd lacks this, so we define the constant to be 0 to not affect
  476. # OR'ing of flags:
  477. const POSIX_SPAWN_USEVFORK* = cint(0)
  478. # <sys/wait.h>
  479. proc WEXITSTATUS*(s: cint): cint {.importc, header: "<sys/wait.h>".}
  480. ## Exit code, if WIFEXITED(s)
  481. proc WTERMSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
  482. ## Termination signal, if WIFSIGNALED(s)
  483. proc WSTOPSIG*(s: cint): cint {.importc, header: "<sys/wait.h>".}
  484. ## Stop signal, if WIFSTOPPED(s)
  485. proc WIFEXITED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
  486. ## True if child exited normally.
  487. proc WIFSIGNALED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
  488. ## True if child exited due to uncaught signal.
  489. proc WIFSTOPPED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
  490. ## True if child is currently stopped.
  491. proc WIFCONTINUED*(s: cint): bool {.importc, header: "<sys/wait.h>".}
  492. ## True if child has been continued.
  493. when defined(nimHasStyleChecks):
  494. {.pop.}