1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if jit.os == "Linux" or jit.os == "OSX" or jit.os == "BSD" or jit.os == "POSIX" or jit.os == "Other" then
	local ffi = require("ffi")
	ffi.cdef [[
		struct timeval {
			long tv_sec;
			long tv_usec;
		};
		struct timezone {
			int tz_minuteswest;
			int tz_dsttime;
		};
		int gettimeofday(struct timeval *tv, struct timezone *tz);
	]]
	function os.clock()
		local Time = new("struct timeval")
		C.gettimeofday(Time, nil)
		return (Time.tv_sec + Time.tv_usec/1.0e6) - Start
	end
	local StartTimeval = ffi.new("struct timeval"); ffi.C.gettimeofday(StartTimeval, nil)
	local StartTime = StartTimeval.tv_sec + StartTimeval.tv_usec/1.0e6
	setfenv(os.clock, {Start = StartTime, new = ffi.new, C = ffi.C})
end
Note: Place the code into sys/lua/autorun to get it working.
I placed the thread on this section because Counter-Strike 2D just got LuaJIT, and I intended it for that usage
edited 2×, last 22.06.15 05:16:31 pm
[LuaJIT] Fix for os.clock
1 
[LuaJIT] Fix for os.clock
Offline
VADemon