forked from justincormack/ljsyscall
-
Notifications
You must be signed in to change notification settings - Fork 5
/
syscall.lua
70 lines (52 loc) · 1.99 KB
/
syscall.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
-- this puts everything into one table ready to use
local require, print, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string, math =
require, print, error, assert, tonumber, tostring,
setmetatable, pairs, ipairs, unpack, rawget, rawset,
pcall, type, table, string, math
local abi = require "syscall.abi"
if abi.rump and abi.types then abi.os = abi.types end -- pretend to be NetBSD for normal rump, Linux for rumplinux
if abi.os == "netbsd" then
-- TODO merge
require("syscall.netbsd.ffitypes")
if not abi.rump then
require("syscall.netbsd.ffifunctions")
end
else
require("syscall." .. abi.os .. ".ffi")
end
local c = require("syscall." .. abi.os .. ".constants")
local ostypes = require("syscall." .. abi.os .. ".types")
local bsdtypes
if (abi.rump and abi.types == "netbsd") or (not abi.rump and abi.bsd) then
bsdtypes = require("syscall.bsd.types")
end
local types = require "syscall.types".init(c, ostypes, bsdtypes)
local C
if abi.rump then -- TODO merge these with conditionals
C = require("syscall.rump.c")
else
C = require("syscall." .. abi.os .. ".c")
end
-- cannot put in S, needed for tests, cannot be put in c earlier due to deps TODO remove see #94
c.IOCTL = require("syscall." .. abi.os .. ".ioctl").init(types)
local S = require "syscall.syscalls".init(C, c, types)
S.abi, S.types, S.t, S.c = abi, types, types.t, c -- add to main table returned
-- add compatibility code
S = require "syscall.compat".init(S)
-- add functions from libc
S = require "syscall.libc".init(S)
-- add methods
S = require "syscall.methods".init(S)
-- add utils
S.util = require "syscall.util".init(S)
if abi.os == "linux" then
S.cgroup = require "syscall.linux.cgroup".init(S)
S.nl = require "syscall.linux.nl".init(S)
-- TODO add the other Linux specific modules here
end
S._VERSION = "v0.11pre"
S._DESCRIPTION = "ljsyscall: A Unix system call API for LuaJIT"
S._COPYRIGHT = "Copyright (C) 2011-2014 Justin Cormack. MIT licensed."
return S