mirror of
https://github.com/GayPizzaSpecifications/pork.git
synced 2025-08-03 05:10:55 +00:00
pork: it's got it all, ffi, state machine tokenizer, and better IDE support
This commit is contained in:
@ -1,7 +1,23 @@
|
||||
import std ffi.malloc
|
||||
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*)"
|
||||
|
||||
export func main() {
|
||||
let pointer = malloc(8192)
|
||||
println(pointer)
|
||||
free(pointer)
|
||||
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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user