2023-10-13 01:04:35 -07:00
|
|
|
import std ffi.struct
|
|
|
|
|
|
|
|
export let timeval = ffiStructDefine(
|
|
|
|
"long", "seconds",
|
|
|
|
"unsigned int", "microseconds"
|
|
|
|
)
|
|
|
|
|
|
|
|
export let timezone = ffiStructDefine(
|
|
|
|
"int", "minutes_greenwich",
|
|
|
|
"int", "dst_time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func gettimeofday(value, tz)
|
|
|
|
native ffi "c" "int gettimeofday(struct timeval*, struct timezone*)"
|
2023-09-06 19:07:28 -07:00
|
|
|
|
|
|
|
export func main() {
|
2023-10-13 01:04:35 -07:00
|
|
|
let time = ffiStructAllocate(timeval)
|
|
|
|
let zone = ffiStructAllocate(timezone)
|
|
|
|
let result = gettimeofday(time, zone)
|
|
|
|
let seconds = ffiStructValue(timeval, "seconds", time)
|
|
|
|
println("Result:", result)
|
|
|
|
println("Seconds:", seconds)
|
2023-09-06 19:07:28 -07:00
|
|
|
}
|