prefer consts to importing #defines from headers

to be completed - better would be to have a libc wrapper that deals with
all pesky C ABI details
This commit is contained in:
Jacek Sieka 2016-06-06 23:00:00 +08:00
commit 8d7a45f205
6 changed files with 65 additions and 39 deletions

View file

@ -78,11 +78,16 @@ elif defined(posixRealtime):
else:
# fallback Posix implementation:
when defined(linux):
type Time = clong
else:
type Time = int
type
Timeval {.importc: "struct timeval", header: "<sys/select.h>",
final, pure.} = object ## struct timeval
tv_sec: int ## Seconds.
tv_usec: int ## Microseconds.
tv_sec: Time ## Seconds.
tv_usec: clong ## Microseconds.
{.deprecated: [Ttimeval: Timeval].}
proc posix_gettimeofday(tp: var Timeval, unused: pointer = nil) {.
importc: "gettimeofday", header: "<sys/time.h>".}