time.lua - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/time.lua
blob: b66d0facff10da72e8606edbd70376c40113fa48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

local windows = jit.os == 'Windows'
local ffi = require 'ffi'
if windows then
 ffi.cdef[[
 int GetTickCount(void);
 ]]
else
 ffi.cdef[[
	 struct timeval {
	 long tv_sec;
	 long tv_usec;
	 };
	 int gettimeofday(struct timeval * tp, void *tzp);
 ]]
end
local function mtime()
 if windows then
 return ffi.C.GetTickCount()
 else
 local tv = ffi.new('struct timeval[1]')
 ffi.C.gettimeofday(tv, nil)
 return tv[0].tv_sec * 1000 + (tv[0].tv_usec / 1000)
 end
end
return {ms= mtime}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月11日 03:24:22 +0000

AltStyle によって変換されたページ (->オリジナル) /