aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOscar Lim <olim@ucla.edu>2016-01-24 22:53:37 -0800
committerOscar Lim <olim@ucla.edu>2016-02-10 23:45:49 -0800
commit7499b422e3f07bf25704cbf7989e845f89697fa8 (patch)
tree524d8a262a9d61486b858e70c64f8aedbda43095
downloadluasystem-7499b422e3f07bf25704cbf7989e845f89697fa8.tar.gz
luasystem-7499b422e3f07bf25704cbf7989e845f89697fa8.tar.bz2
luasystem-7499b422e3f07bf25704cbf7989e845f89697fa8.zip
Support for gettime and sleep functions
Provide `gettime` and `sleep` functions with at least 1 millisecond resolution.
-rw-r--r--.gitignore6
-rw-r--r--.travis.yml23
-rw-r--r--.travis_setup.sh45
-rw-r--r--LICENSE20
-rw-r--r--Makefile32
-rw-r--r--README.md19
-rw-r--r--luasystem-scm-0.rockspec47
-rw-r--r--spec/time_spec.lua13
-rw-r--r--src/Makefile257
-rw-r--r--src/compat.c17
-rw-r--r--src/compat.h11
-rw-r--r--src/core.c19
-rw-r--r--src/time.c89
-rw-r--r--system/init.lua2
14 files changed, 600 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..65b45dd
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
1**/.*.swp
2**/.*.swo
3*.o
4*.obj
5*.dll
6*.so
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..efc632b
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,23 @@
1language: c
2
3env:
4 - LUA='Lua 5.1'
5 - LUA='Lua 5.2'
6 - LUA='Lua 5.3'
7 - LUA='LuaJIT 2.0'
8
9before_install:
10 - bash .travis_setup.sh
11
12install:
13 - sudo luarocks install busted
14 - sudo luarocks make
15
16script: busted spec
17
18branches:
19 only:
20 - master
21
22notifications:
23 email: false
diff --git a/.travis_setup.sh b/.travis_setup.sh
new file mode 100644
index 0000000..f186230
--- /dev/null
+++ b/.travis_setup.sh
@@ -0,0 +1,45 @@
1# A script for setting up environment for travis-ci testing.
2# Sets up Lua and Luarocks.
3# LUA must be "Lua 5.1", "Lua 5.2", "Lua 5.3" or "LuaJIT 2.0".
4
5set -e
6
7echo 'rocks_servers = {
8 "http://luarocks.org/manifests/olivine-labs",
9 "http://rocks.moonscript.org/",
10 "http://luarocks.org/repositories/rocks",
11 "http://luarocks.logiceditor.com/rocks",
12 "http://liblua.so/luarocks/repositories/rocks"
13}' >> ~/config.lua
14
15
16if [ "$LUA" == "LuaJIT 2.0" ]; then
17 wget -O - http://luajit.org/download/LuaJIT-2.0.4.tar.gz | tar xz
18 cd LuaJIT-2.0.4
19 make && sudo make install INSTALL_TSYMNAME=lua;
20else
21 if [ "$LUA" == "Lua 5.1" ]; then
22 wget -O - http://www.lua.org/ftp/lua-5.1.5.tar.gz | tar xz
23 cd lua-5.1.5;
24 elif [ "$LUA" == "Lua 5.2" ]; then
25 wget -O - http://www.lua.org/ftp/lua-5.2.4.tar.gz | tar xz
26 cd lua-5.2.4;
27 elif [ "$LUA" == "Lua 5.3" ]; then
28 wget -O - http://www.lua.org/ftp/lua-5.3.2.tar.gz | tar xz
29 cd lua-5.3.2;
30 fi
31 sudo make linux install;
32fi
33
34cd ..
35wget -O - http://luarocks.org/releases/luarocks-2.3.0.tar.gz | tar xz || wget -O - http://keplerproject.github.io/luarocks/releases/luarocks-2.3.0.tar.gz | tar xz
36cd luarocks-2.3.0
37
38if [ "$LUA" == "LuaJIT 2.0" ]; then
39 ./configure --with-lua-include=/usr/local/include/luajit-2.0;
40else
41 ./configure;
42fi
43
44make build && sudo make install
45cd ..
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..0421a4a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
1MIT License Terms
2=================
3
4Permission is hereby granted, free of charge, to any person obtaining a copy of
5this software and associated documentation files (the "Software"), to deal in
6the Software without restriction, including without limitation the rights to
7use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8of the Software, and to permit persons to whom the Software is furnished to do
9so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in all
12copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..4d83c2a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,32 @@
1# busted_time makefile
2#
3# see csrc/makefile for description of how to customize the build
4#
5# Targets:
6# install install system independent support
7# install-all install for lua51 lua52 lua53
8# print print the build settings
9
10PLAT?= linux
11PLATS= macosx linux win32 mingw freebsd
12
13all: $(PLAT)
14
15$(PLATS) none install local clean:
16 $(MAKE) -C src $@
17
18print:
19 $(MAKE) -C src $@
20
21install-all:
22 $(MAKE) clean
23 @cd src && $(MAKE) $(PLAT) LUA_VERSION=5.1
24 @cd src && $(MAKE) install LUA_VERSION=5.1
25 $(MAKE) clean
26 @cd src && $(MAKE) $(PLAT) LUA_VERSION=5.2
27 @cd src && $(MAKE) install LUA_VERSION=5.2
28 $(MAKE) clean
29 @cd src && $(MAKE) $(PLAT) LUA_VERSION=5.3
30 @cd src && $(MAKE) install LUA_VERSION=5.3
31
32.PHONY: test
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..240c478
--- /dev/null
+++ b/README.md
@@ -0,0 +1,19 @@
1LuaSystem
2======
3
4[![travis-ci status](https://travis-ci.org/o-lim/luasystem.svg?branch=master)](https://travis-ci.org/o-lim/luasystem/builds)
5
6
7luasystem is a platform independent system call library for Lua.
8Supports Lua >= 5.1 and luajit >= 2.0.0.
9
10Currently the following functions are supported:
11* gettime
12* sleep
13
14License
15-------
16
17This code and its accompanying README are
18[MIT licensed](http://www.opensource.org/licenses/mit-license.php).
19See LICENSE for details.
diff --git a/luasystem-scm-0.rockspec b/luasystem-scm-0.rockspec
new file mode 100644
index 0000000..83f4172
--- /dev/null
+++ b/luasystem-scm-0.rockspec
@@ -0,0 +1,47 @@
1package = 'luasystem'
2version = 'scm-0'
3source = {
4 url = "git://github.com/o-lim/luasystem",
5 branch = "master"
6}
7description = {
8 summary = 'Platform independent system calls for Lua.',
9 detailed = [[
10 Adds a Lua API for making platform independent system calls.
11 ]],
12 homepage = 'http://olivinelabs.com/luasystem/',
13 license = 'MIT <http://opensource.org/licenses/MIT>'
14}
15dependencies = {
16 'lua >= 5.1',
17}
18
19local function make_platform(plat)
20 local defines = {
21 unix = { },
22 macosx = { },
23 win32 = { },
24 mingw32 = { "WINVER=0x0501" },
25 }
26 return {
27 modules = {
28 ['system.core'] = {
29 sources = { 'src/core.c', 'src/compat.c', 'src/time.c', },
30 defines = defines[plat],
31 },
32 },
33 }
34end
35
36build = {
37 type = 'builtin',
38 platforms = {
39 unix = make_platform('unix'),
40 macosx = make_platform('macosx'),
41 win32 = make_platform('win32'),
42 mingw32 = make_platform('mingw32'),
43 },
44 modules = {
45 ['system.init'] = 'system/init.lua',
46 },
47}
diff --git a/spec/time_spec.lua b/spec/time_spec.lua
new file mode 100644
index 0000000..8bee5f7
--- /dev/null
+++ b/spec/time_spec.lua
@@ -0,0 +1,13 @@
1local system = require 'system.core'
2
3describe('Test time functions', function()
4 it('gettime returns current time', function()
5 assert.is_near(os.time(), system.gettime(), 1.0)
6 end)
7
8 it('sleep will wait for specified amount of time', function()
9 local starttime = system.gettime()
10 system.sleep(0.5)
11 assert.is_near(0.5, system.gettime() - starttime, 0.1)
12 end)
13end)
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..25f468d
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,257 @@
1# luasystem
2#
3# Definitions in this section can be overriden on the command line or in the
4# environment.
5#
6
7# PLAT: linux macosx win32 mingw
8# platform to build for
9PLAT?=linux
10
11# LUA_VERSION: 5.1 5.2 5.3
12# lua version to build against
13LUA_VERSION?=5.1
14
15# MYCFLAGS: to be set by user if needed
16MYCFLAGS=
17
18# MYLDFLAGS: to be set by user if needed
19MYLDFLAGS=
20
21# where lua headers are found for macosx builds
22# LUAINC_macosx:
23# /opt/local/include
24LUAINC_macosx_base?=/opt/local/include
25LUAINC_macosx?=$(LUAINC_macosx_base)/lua/$(LUA_VERSION)
26# FIXME default should this default to fink or to macports?
27# What happens when more than one Lua version is installed?
28LUAPREFIX_macosx?=/opt/local
29CDIR_macosx?=lib/lua/$(LUA_VERSION)
30LDIR_macosx?=share/lua/$(LUA_VERSION)
31
32# LUAINC_linux:
33# /usr/include/lua$(LUA_VERSION)
34# /usr/local/include
35# /usr/local/include/lua$(LUA_VERSION)
36# where lua headers are found for linux builds
37LUAINC_linux_base?=/usr/include
38LUAINC_linux?=$(LUAINC_linux_base)/lua/$(LUA_VERSION)
39LUAPREFIX_linux?=/usr/local
40CDIR_linux?=lib/lua/$(LUA_VERSION)
41LDIR_linux?=share/lua/$(LUA_VERSION)
42
43# LUAINC_freebsd:
44# /usr/local/include/lua$(LUA_VERSION)
45# where lua headers are found for linux builds
46LUAINC_freebsd_base?=/usr/local/include/
47LUAINC_freebsd?=$(LUAINC_freebsd_base)/lua$(LUA_VERSION)
48LUAPREFIX_freebsd?=/usr/local/
49CDIR_freebsd?=lib/lua/$(LUA_VERSION)
50LDIR_freebsd?=share/lua/$(LUA_VERSION)
51
52# where lua headers are found for mingw builds
53# LUAINC_mingw:
54# /opt/local/include
55LUAINC_mingw_base?=/usr/include
56LUAINC_mingw?=$(LUAINC_mingw_base)/lua/$(LUA_VERSION)
57LUALIB_mingw_base?=/usr/bin
58LUALIB_mingw?=$(LUALIB_mingw_base)/lua/$(LUA_VERSION)/lua$(subst .,,$(LUA_VERSION)).dll
59LUAPREFIX_mingw?=/usr
60CDIR_mingw?=lua/$(LUA_VERSION)
61LDIR_mingw?=lua/$(LUA_VERSION)/lua
62
63
64# LUAINC_win32:
65# LUALIB_win32:
66# where lua headers and libraries are found for win32 builds
67LUAPREFIX_win32?=
68LUAINC_win32?=$(LUAPREFIX_win32)/include/lua/$(LUA_VERSION)
69PLATFORM_win32?=Release
70CDIR_win32?=bin/lua/$(LUA_VERSION)/$(PLATFORM_win32)
71LDIR_win32?=bin/lua/$(LUA_VERSION)/$(PLATFORM_win32)/lua
72LUALIB_win32?=$(LUAPREFIX_win32)/lib/lua/$(LUA_VERSION)/$(PLATFORM_win32)
73LUALIBNAME_win32?=lua$(subst .,,$(LUA_VERSION)).lib
74
75
76# prefix: /usr/local /usr /opt/local /sw
77# the top of the default install tree
78prefix?=$(LUAPREFIX_$(PLAT))
79
80CDIR?=$(CDIR_$(PLAT))
81LDIR?=$(LDIR_$(PLAT))
82
83# DESTDIR: (no default)
84# used by package managers to install into a temporary destination
85DESTDIR=
86
87#------
88# Definitions below can be overridden on the make command line, but
89# shouldn't have to be.
90
91
92#------
93# Install directories
94#
95
96INSTALL_DIR=install -d
97INSTALL_DATA=install -m644
98INSTALL_EXEC=install
99INSTALL_TOP=$(DESTDIR)$(prefix)
100
101INSTALL_TOP_LDIR=$(INSTALL_TOP)/$(LDIR)
102INSTALL_TOP_CDIR=$(INSTALL_TOP)/$(CDIR)
103
104INSTALL_LDIR=$(INSTALL_TOP_LDIR)/system
105INSTALL_CDIR=$(INSTALL_TOP_CDIR)/system
106
107#------
108# Supported platforms
109#
110PLATS= macosx linux win32 mingw
111
112#------
113# Compiler and linker settings
114# for Mac OS X
115SO_macosx=so
116O_macosx=o
117CC_macosx=gcc
118DEF_macosx=
119CFLAGS_macosx= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \
120 -fvisibility=hidden
121LDFLAGS_macosx= -bundle -undefined dynamic_lookup -o
122LD_macosx= export MACOSX_DEPLOYMENT_TARGET="10.3"; gcc
123
124#------
125# Compiler and linker settings
126# for Linux
127SO_linux=so
128O_linux=o
129CC_linux=gcc
130DEF_linux=
131CFLAGS_linux= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \
132 -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden
133LDFLAGS_linux=-O -shared -fpic -o
134LD_linux=gcc
135
136#------
137# Compiler and linker settings
138# for FreeBSD
139SO_freebsd=so
140O_freebsd=o
141CC_freebsd=gcc
142DEF_freebsd=
143CFLAGS_freebsd= -I$(LUAINC) $(DEF) -Wall -Wshadow -Wextra \
144 -Wimplicit -O2 -ggdb3 -fpic -fvisibility=hidden
145LDFLAGS_freebsd=-O -shared -fpic -o
146LD_freebsd=gcc
147
148#------
149# Compiler and linker settings
150# for MingW
151SO_mingw=dll
152O_mingw=o
153CC_mingw=gcc
154DEF_mingw=-DWINVER=0x0501
155CFLAGS_mingw= -I$(LUAINC) $(DEF) -Wall -O2 -fno-common \
156 -fvisibility=hidden
157LDFLAGS_mingw= $(LUALIB) -shared -Wl,-s -o
158LD_mingw=gcc
159
160
161#------
162# Compiler and linker settings
163# for Win32
164SO_win32=dll
165O_win32=obj
166CC_win32=cl
167DEF_win32= //D "WIN32" //D "NDEBUG" //D "_WINDOWS" //D "_USRDLL" \
168 //D "_CRT_SECURE_NO_WARNINGS" //D "_WINDLL"
169CFLAGS_win32=//I "$(LUAINC)" $(DEF) //O2 //Ot //MD //W3 //nologo
170LDFLAGS_win32= //nologo //link //NOLOGO //DLL //INCREMENTAL:NO \
171 //MANIFEST //MANIFESTFILE:"intermediate.manifest" \
172 //MANIFESTUAC:"level='asInvoker' uiAccess='false'" \
173 //SUBSYSTEM:WINDOWS //OPT:REF //OPT:ICF //DYNAMICBASE:NO \
174 //MACHINE:X86 /LIBPATH:"$(shell cmd //c echo $(LUALIB))" \
175 $(LUALIBNAME_win32) //OUT:
176LD_win32=cl
177
178.SUFFIXES: .obj
179
180.c.obj:
181 $(CC) $(CFLAGS) //Fo"$@" //c $<
182
183#------
184# Output file names
185#
186SO=$(SO_$(PLAT))
187O=$(O_$(PLAT))
188SOLIB=core.$(SO)
189
190#------
191# Settings selected for platform
192#
193CC=$(CC_$(PLAT))
194DEF=$(DEF_$(PLAT))
195CFLAGS=$(MYCFLAGS) $(CFLAGS_$(PLAT))
196LDFLAGS=$(MYLDFLAGS) $(LDFLAGS_$(PLAT))
197LD=$(LD_$(PLAT))
198LUAINC= $(LUAINC_$(PLAT))
199LUALIB= $(LUALIB_$(PLAT))
200
201#------
202# Objects
203#
204OBJS=core.$(O) compat.$(O) time.$(O)
205
206#------
207# Targets
208#
209default: $(PLAT)
210
211freebsd:
212 $(MAKE) all PLAT=freebsd
213
214macosx:
215 $(MAKE) all PLAT=macosx
216
217win32:
218 $(MAKE) all PLAT=win32
219
220linux:
221 $(MAKE) all PLAT=linux
222
223mingw:
224 $(MAKE) all PLAT=mingw
225
226none:
227 @echo "Please run"
228 @echo " make PLATFORM"
229 @echo "where PLATFORM is one of these:"
230 @echo " $(PLATS)"
231
232all: $(SOLIB)
233
234$(SOLIB): $(OBJS)
235 $(LD) $(OBJS) $(LDFLAGS)$@
236
237install: all
238 $(INSTALL_DIR) $(INSTALL_TOP_LDIR)
239 $(INSTALL_DIR) $(INSTALL_CDIR)
240 $(INSTALL_EXEC) $(SOLIB) $(INSTALL_CDIR)/$(SOLIB)
241
242local:
243 $(MAKE) install INSTALL_TOP_CDIR=.. INSTALL_TOP_LDIR=..
244
245clean:
246 rm -f $(SOLIB) $(OBJS) ../system/core.so
247
248print:
249 @echo PLAT=$(PLAT)
250 @echo LUA_VERSION=$(LUA_VERSION)
251 @echo prefix=$(prefix)
252 @echo LUAINC_$(PLAT)=$(LUAINC_$(PLAT))
253 @echo LUALIB_$(PLAT)=$(LUALIB_$(PLAT))
254 @echo INSTALL_TOP_CDIR=$(INSTALL_TOP_CDIR)
255 @echo INSTALL_TOP_LDIR=$(INSTALL_TOP_LDIR)
256
257.PHONY: all $(PLATS) default clean none
diff --git a/src/compat.c b/src/compat.c
new file mode 100644
index 0000000..d763c56
--- /dev/null
+++ b/src/compat.c
@@ -0,0 +1,17 @@
1#include <lua.h>
2#include <lauxlib.h>
3
4#if LUA_VERSION_NUM == 501
5void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup) {
6 luaL_checkstack(L, nup+1, "too many upvalues");
7 for (; l->name != NULL; l++) { /* fill the table with given functions */
8 int i;
9 lua_pushstring(L, l->name);
10 for (i = 0; i < nup; i++) /* copy upvalues to the top */
11 lua_pushvalue(L, -(nup+1));
12 lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */
13 lua_settable(L, -(nup + 3));
14 }
15 lua_pop(L, nup); /* remove upvalues */
16}
17#endif
diff --git a/src/compat.h b/src/compat.h
new file mode 100644
index 0000000..f523fd9
--- /dev/null
+++ b/src/compat.h
@@ -0,0 +1,11 @@
1#ifndef COMPAT_H
2#define COMPAT_H
3
4#include <lua.h>
5#include <lauxlib.h>
6
7#if LUA_VERSION_NUM == 501
8void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup);
9#endif
10
11#endif
diff --git a/src/core.c b/src/core.c
new file mode 100644
index 0000000..d2acb95
--- /dev/null
+++ b/src/core.c
@@ -0,0 +1,19 @@
1#include <lua.h>
2#include <lauxlib.h>
3
4#ifdef _WIN32
5#define LUAEXPORT __declspec(dllexport)
6#else
7#define LUAEXPORT __attribute__((visibility("default")))
8#endif
9
10void time_open(lua_State *L);
11
12/*-------------------------------------------------------------------------
13 * Initializes all library modules.
14 *-------------------------------------------------------------------------*/
15LUAEXPORT int luaopen_system_core(lua_State *L) {
16 lua_newtable(L);
17 time_open(L);
18 return 1;
19}
diff --git a/src/time.c b/src/time.c
new file mode 100644
index 0000000..3f61001
--- /dev/null
+++ b/src/time.c
@@ -0,0 +1,89 @@
1#include <lua.h>
2#include <lauxlib.h>
3
4#ifdef _WIN32
5#include <windows.h>
6#else
7#include <time.h>
8#include <sys/time.h>
9#endif
10
11#include "compat.h"
12
13/*-------------------------------------------------------------------------
14 * Gets time in s, relative to January 1, 1970 (UTC)
15 * Returns
16 * time in s.
17 *-------------------------------------------------------------------------*/
18#ifdef _WIN32
19static double time_gettime(void) {
20 FILETIME ft;
21 double t;
22 GetSystemTimeAsFileTime(&ft);
23 /* Windows file time (time since January 1, 1601 (UTC)) */
24 t = ft.dwLowDateTime/1.0e7 + ft.dwHighDateTime*(4294967296.0/1.0e7);
25 /* convert to Unix Epoch time (time since January 1, 1970 (UTC)) */
26 return (t - 11644473600.0);
27}
28#else
29static double time_gettime(void) {
30 struct timeval v;
31 gettimeofday(&v, (struct timezone *) NULL);
32 /* Unix Epoch time (time since January 1, 1970 (UTC)) */
33 return v.tv_sec + v.tv_usec/1.0e6;
34}
35#endif
36
37/*-------------------------------------------------------------------------
38 * Returns the time the system has been up, in secconds.
39 *-------------------------------------------------------------------------*/
40static int time_lua_gettime(lua_State *L)
41{
42 lua_pushnumber(L, time_gettime());
43 return 1;
44}
45
46/*-------------------------------------------------------------------------
47 * Sleep for n seconds.
48 *-------------------------------------------------------------------------*/
49#ifdef _WIN32
50static int time_lua_sleep(lua_State *L)
51{
52 double n = luaL_checknumber(L, 1);
53 if (n < 0.0) n = 0.0;
54 if (n < DBL_MAX/1000.0) n *= 1000.0;
55 if (n > INT_MAX) n = INT_MAX;
56 Sleep((int)n);
57 return 0;
58}
59#else
60static int time_lua_sleep(lua_State *L)
61{
62 double n = luaL_checknumber(L, 1);
63 struct timespec t, r;
64 if (n < 0.0) n = 0.0;
65 if (n > INT_MAX) n = INT_MAX;
66 t.tv_sec = (int) n;
67 n -= t.tv_sec;
68 t.tv_nsec = (int) (n * 1000000000);
69 if (t.tv_nsec >= 1000000000) t.tv_nsec = 999999999;
70 while (nanosleep(&t, &r) != 0) {
71 t.tv_sec = r.tv_sec;
72 t.tv_nsec = r.tv_nsec;
73 }
74 return 0;
75}
76#endif
77
78static luaL_Reg func[] = {
79 { "gettime", time_lua_gettime },
80 { "sleep", time_lua_sleep },
81 { NULL, NULL }
82};
83
84/*-------------------------------------------------------------------------
85 * Initializes module
86 *-------------------------------------------------------------------------*/
87void time_open(lua_State *L) {
88 luaL_setfuncs(L, func, 0);
89}
diff --git a/system/init.lua b/system/init.lua
new file mode 100644
index 0000000..77e0c3b
--- /dev/null
+++ b/system/init.lua
@@ -0,0 +1,2 @@
1local system = require 'system.core'
2return system