forked from izaya/LuPPC
Added usleep native wrapper
This commit is contained in:
parent
aeb3bf786e
commit
e6f07e6cb6
@ -9,6 +9,7 @@
|
|||||||
#define pushctuple(state, name, value) lua_pushstring((state), (name)); lua_pushcfunction((state), (value)); lua_settable((state), -3)
|
#define pushctuple(state, name, value) lua_pushstring((state), (name)); lua_pushcfunction((state), (value)); lua_settable((state), -3)
|
||||||
|
|
||||||
void run_init();
|
void run_init();
|
||||||
|
void luanative_start(lua_State *L);
|
||||||
void setup_modules(lua_State *L);
|
void setup_modules(lua_State *L);
|
||||||
void termutils_start(lua_State *L);
|
void termutils_start(lua_State *L);
|
||||||
#endif
|
#endif
|
||||||
|
19
src/c/lnative.c
Normal file
19
src/c/lnative.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "lupi.h"
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lualib.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
static int l_sleep (lua_State *L) {
|
||||||
|
int t = lua_tonumber(L, 1);
|
||||||
|
usleep(t);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void luanative_start(lua_State *L) {
|
||||||
|
lua_createtable (L, 0, 1);
|
||||||
|
pushctuple(L, "sleep", l_sleep);
|
||||||
|
|
||||||
|
lua_setglobal(L, "native");
|
||||||
|
}
|
@ -11,6 +11,7 @@ void run_init() {
|
|||||||
|
|
||||||
luaL_openlibs (L);
|
luaL_openlibs (L);
|
||||||
setup_modules (L);
|
setup_modules (L);
|
||||||
|
luanative_start (L);
|
||||||
termutils_start (L);
|
termutils_start (L);
|
||||||
|
|
||||||
int status = luaL_loadstring(L, lua_init);
|
int status = luaL_loadstring(L, lua_init);
|
||||||
|
@ -5,8 +5,10 @@ function boot.boot()
|
|||||||
local w, h = gpu.getResolution()
|
local w, h = gpu.getResolution()
|
||||||
print("r= " .. tostring(w) .. " " .. tostring(h))
|
print("r= " .. tostring(w) .. " " .. tostring(h))
|
||||||
gpu.fill(0, 0, w, h, " ")
|
gpu.fill(0, 0, w, h, " ")
|
||||||
|
gpu.set(10, 5, "HHHHHHHHHHHHH")
|
||||||
print("LuPI L2 INIT")
|
print("LuPI L2 INIT")
|
||||||
print("FIXME: boot stub")
|
print("FIXME: boot stub")
|
||||||
|
native.sleep(1000000)
|
||||||
error("Unable to boot")
|
error("Unable to boot")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user