summaryrefslogtreecommitdiff
path: root/src/l_rawio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/l_rawio.c')
-rw-r--r--src/l_rawio.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/l_rawio.c b/src/l_rawio.c
index 3ba2851..213b0c4 100644
--- a/src/l_rawio.c
+++ b/src/l_rawio.c
@@ -124,7 +124,7 @@ static int l_rawio_close(lua_State *L)
return 0;
}
-static const struct luaL_reg rawio_funcs [] = {
+static const struct luaL_Reg rawio_funcs [] = {
{ "open", l_rawio_open },
{ "setnonblock", l_rawio_setnonblock },
{ "write", l_rawio_write },
@@ -136,6 +136,13 @@ static const struct luaL_reg rawio_funcs [] = {
LUALIB_API int luaopen_rawio(lua_State *L)
{
+#if LUA_VERSION_NUM > 501
+ lua_newtable(L);
+ luaL_setfuncs(L, rawio_funcs, 0);
+ lua_pushvalue(L, -1);
+ lua_setglobal(L, LUA_RAWIOLIBNAME);
+#else
luaL_register(L, LUA_RAWIOLIBNAME, rawio_funcs);
+#endif
return 1;
}