[luatex] Linking to C libraries / TL2017 / FFI
luigi scarso
luigi.scarso at gmail.com
Sun Apr 23 19:14:40 CEST 2017
--
-- sleep.lua
--
local ffi = require("ffi")
ffi.cdef[[
void Sleep(int ms);
int poll(struct pollfd *fds, unsigned long nfds, int timeout);
]]
local sleep
if ffi.os == "Windows" then
function sleep(s)
ffi.C.Sleep(s*1000)
end
else
function sleep(s)
ffi.C.poll(nil, 0, s*1000)
end
end
for i=1,160 do
io.write("."); io.flush()
sleep(0.01)
end
io.write("\n")
Under linux
$ luajittex --luaonly sleep.lua
................................................................................................................................................................
$ luatex --luaonly sleep.lua
................................................................................................................................................................
--
luigi
More information about the luatex
mailing list