mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Add mwait
function
This commit is contained in:
parent
e76802f2ce
commit
1d528bada6
1 changed files with 19 additions and 0 deletions
|
@ -10,6 +10,11 @@
|
|||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static void writestring(const char* s, size_t l)
|
||||
{
|
||||
|
@ -32,6 +37,19 @@ static int luaB_print(lua_State* L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int luaB_mwait(lua_State* L)
|
||||
{
|
||||
int milliseconds = lua_gettop(L);
|
||||
luaL_checkinteger(L, milliseconds);
|
||||
#ifdef _WIN32
|
||||
Sleep(milliseconds);
|
||||
#else
|
||||
usleep(milliseconds * 1000);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int luaB_tonumber(lua_State* L)
|
||||
{
|
||||
int base = luaL_optinteger(L, 2, 10);
|
||||
|
@ -434,6 +452,7 @@ static const luaL_Reg base_funcs[] = {
|
|||
{"next", luaB_next},
|
||||
{"newproxy", luaB_newproxy},
|
||||
{"print", luaB_print},
|
||||
{"mwait", luaB_mwait},
|
||||
{"rawequal", luaB_rawequal},
|
||||
{"rawget", luaB_rawget},
|
||||
{"rawset", luaB_rawset},
|
||||
|
|
Loading…
Add table
Reference in a new issue