forked from justincormack/ljsyscall
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyscall.lua
66 lines (47 loc) · 1.84 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
-- 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
require "syscall.ffitypes"
require("syscall." .. abi.os .. ".ffitypes")
if not abi.rump then
require "syscall.ffifunctions"
require("syscall." .. abi.os .. ".ffifunctions")
if abi.bsd then require "syscall.bsd.ffifunctions" end
end
local ostypes = require("syscall." .. abi.os .. ".types")
local c = require("syscall." .. abi.os .. ".constants")
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
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
return S