X-Git-Url: https://git.madduck.net/etc/awesome.git/blobdiff_plain/cb6821bbbb191868a7b6c8813f8481c897d9dba9..a90e68208dd5bd982fe457b6a4f2c1198db37f7a:/luatz/gettime.lua?ds=sidebyside diff --git a/luatz/gettime.lua b/luatz/gettime.lua index 65366bd..b5dec5a 100644 --- a/luatz/gettime.lua +++ b/luatz/gettime.lua @@ -3,7 +3,7 @@ local _M = { } _M.source , _M.resolution , _M.gettime = (function() local has_syscall , syscall = pcall ( require , "syscall" ) if has_syscall then - if syscall.clock_gettime then + if syscall.clock_gettime and syscall.c.CLOCK then local clock_id = syscall.c.CLOCK.REALTIME local function timespec_to_number ( timespec ) return tonumber ( timespec.tv_sec ) + tonumber ( timespec.tv_nsec ) * 1e-9 @@ -32,8 +32,8 @@ _M.source , _M.resolution , _M.gettime = (function() return "socket.gettime()" , 1e-6 , socket.gettime end - if ngx and ngx.now then - return "ngx.now()" , 1e-3 , ngx.now + if ngx and ngx.now then -- luacheck: ignore 113 + return "ngx.now()" , 1e-3 , ngx.now -- luacheck: ignore 113 end return "os.time()" , 1 , os.time