-
-
Save kengonakajima/c91646edb999d12a1dd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require("ffi") | |
ffi.cdef[[ | |
typedef long time_t; | |
typedef struct timeval { | |
time_t tv_sec; | |
time_t tv_usec; | |
} timeval; | |
int gettimeofday(struct timeval* t, void* tzp); | |
]] | |
local function gettimeofday() | |
local t = ffi.new("timeval") | |
ffi.C.gettimeofday(t, nil) | |
return tonumber(t.tv_sec) + tonumber(t.tv_usec)/1000000.0 | |
end | |
print("time of day is " .. gettimeofday()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment