mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-04-11 09:52:31 +00:00
Merge ed4872abc6
into 6c3bda4aca
This commit is contained in:
commit
f511312ced
1 changed files with 18 additions and 1 deletions
|
@ -34,12 +34,29 @@ end
|
||||||
function M.cputime()
|
function M.cputime()
|
||||||
if M.C == nil then
|
if M.C == nil then
|
||||||
pcall(function()
|
pcall(function()
|
||||||
|
local pad = ""
|
||||||
|
-- If we're a 32-bit platform, we need to pad by 4 bytes.
|
||||||
|
if ffi.abi("32bit") then
|
||||||
|
pad = "int _tv_pad;"
|
||||||
|
end
|
||||||
|
|
||||||
|
local pad_before_nsec = ""
|
||||||
|
local pad_after_nsec = ""
|
||||||
|
-- Where we place the padding depends on the endianness.
|
||||||
|
if ffi.abi("le") then
|
||||||
|
pad_after_nsec = pad
|
||||||
|
else
|
||||||
|
pad_before_nsec = pad
|
||||||
|
end
|
||||||
|
|
||||||
ffi.cdef([[
|
ffi.cdef([[
|
||||||
typedef long time_t;
|
typedef int64_t time_t;
|
||||||
typedef int clockid_t;
|
typedef int clockid_t;
|
||||||
typedef struct timespec {
|
typedef struct timespec {
|
||||||
time_t tv_sec; /* seconds */
|
time_t tv_sec; /* seconds */
|
||||||
|
]] .. pad_before_nsec .. [[
|
||||||
long tv_nsec; /* nanoseconds */
|
long tv_nsec; /* nanoseconds */
|
||||||
|
]] .. pad_after_nsec .. [[
|
||||||
} nanotime;
|
} nanotime;
|
||||||
int clock_gettime(clockid_t clk_id, struct timespec *tp);
|
int clock_gettime(clockid_t clk_id, struct timespec *tp);
|
||||||
]])
|
]])
|
||||||
|
|
Loading…
Add table
Reference in a new issue