forked from mia/Aegisub
Also stub out the `system` lua module that newer versions of busted use
This commit is contained in:
parent
61028916c8
commit
bc157d9bbc
|
@ -7,16 +7,36 @@ ffi.cdef[[
|
||||||
} timeval;
|
} timeval;
|
||||||
|
|
||||||
int gettimeofday(timeval *t, void *tzp);
|
int gettimeofday(timeval *t, void *tzp);
|
||||||
|
|
||||||
|
typedef struct timespec {
|
||||||
|
long tv_sec;
|
||||||
|
long tv_nsec;
|
||||||
|
} timespec;
|
||||||
|
int clock_gettime(int clk_id, timespec *tp);
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
function gettime()
|
||||||
|
local t = ffi.new("timeval")
|
||||||
|
ffi.C.gettimeofday(t, nil)
|
||||||
|
return tonumber(t.tv_sec) + tonumber(t.tv_usec) / 1000000.0
|
||||||
|
end
|
||||||
|
function monotime()
|
||||||
|
local ts = ffi.new("timespec")
|
||||||
|
ffi.C.clock_gettime(6, ts)
|
||||||
|
return tonumber(ts.tv_sec) + tonumber(ts.tv_nsec) / 1000000000.0
|
||||||
|
end
|
||||||
|
function sleep()
|
||||||
|
end
|
||||||
|
|
||||||
-- busted depends on luasocket just for gettime(), so just supply a definition
|
-- busted depends on luasocket just for gettime(), so just supply a definition
|
||||||
-- of that to avoid the dep
|
-- of that to avoid the dep
|
||||||
package.loaded['socket'] = {
|
package.loaded['socket'] = {
|
||||||
gettime = function()
|
gettime = gettime
|
||||||
local t = ffi.new("timeval")
|
}
|
||||||
ffi.C.gettimeofday(t, nil)
|
package.loaded['system'] = {
|
||||||
return tonumber(t.tv_sec) + tonumber(t.tv_usec) / 1000000.0
|
gettime = gettime,
|
||||||
end
|
monotime = monotime,
|
||||||
|
sleep = sleep
|
||||||
}
|
}
|
||||||
|
|
||||||
package.loaded['term'] = {
|
package.loaded['term'] = {
|
||||||
|
|
Loading…
Reference in New Issue