From 10dc034ff43cf09221bb4211f3cec7c69701b1ec Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 26 Dec 2023 16:06:41 +0300 Subject: [PATCH] Add os.clock() function --- dynasm/minilua.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dynasm/minilua.c b/dynasm/minilua.c index a8d7c30..aeacad0 100644 --- a/dynasm/minilua.c +++ b/dynasm/minilua.c @@ -6985,9 +6985,14 @@ return os_pushresult(L,remove(filename)==0,filename); static int os_exit(lua_State*L){ exit(luaL_optint(L,1,EXIT_SUCCESS)); } +static int os_clock(lua_State*L){ +lua_pushnumber(L,((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); +return 1; +} static const luaL_Reg syslib[]={ {"exit",os_exit}, {"remove",os_remove}, +{"clock",os_clock}, {NULL,NULL} }; static int luaopen_os(lua_State*L){