From 31acfe7a5fe499c1698ae23ada97519b4b262469 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 8 Mar 2017 10:49:28 +1100 Subject: [PATCH 1/1] luatz/gettime: Check that CLOCK constants exist ljsyscall can end up defining a clock_gettime function without defining clock symbols. Closes #11 --- luatz/gettime.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/luatz/gettime.lua b/luatz/gettime.lua index e0da6b4..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 -- 2.39.5