Changeset View
Changeset View
Standalone View
Standalone View
sys/tools/makesyscalls.lua
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | local config = { | ||||
abi_flags_mask = 0, | abi_flags_mask = 0, | ||||
ptr_intptr_t_cast = "intptr_t", | ptr_intptr_t_cast = "intptr_t", | ||||
} | } | ||||
local config_modified = {} | local config_modified = {} | ||||
local cleantmp = true | local cleantmp = true | ||||
local tmpspace = "/tmp/sysent." .. unistd.getpid() .. "/" | local tmpspace = "/tmp/sysent." .. unistd.getpid() .. "/" | ||||
-- These ones we'll open in place | local output_files = { | ||||
local config_files_needed = { | |||||
"sysnames", | "sysnames", | ||||
"syshdr", | "syshdr", | ||||
"sysmk", | "sysmk", | ||||
"syssw", | "syssw", | ||||
"systrace", | "systrace", | ||||
"sysproto", | |||||
} | } | ||||
-- These ones we'll create temporary files for; generation purposes. | -- These ones we'll create temporary files for; generation purposes. | ||||
local temp_files = { | local temp_files = { | ||||
"sysaue", | "sysaue", | ||||
"sysdcl", | "sysdcl", | ||||
"syscompat", | "syscompat", | ||||
"syscompatdcl", | "syscompatdcl", | ||||
▲ Show 20 Lines • Show All 1,069 Lines • ▼ Show 20 Lines | if not lfs.mkdir(tmpspace) then | ||||
abort(1, "Failed to create tempdir " .. tmpspace) | abort(1, "Failed to create tempdir " .. tmpspace) | ||||
end | end | ||||
for _, v in ipairs(temp_files) do | for _, v in ipairs(temp_files) do | ||||
local tmpname = tmpspace .. v | local tmpname = tmpspace .. v | ||||
files[v] = io.open(tmpname, "w+") | files[v] = io.open(tmpname, "w+") | ||||
end | end | ||||
for _, v in ipairs(output_files) do | |||||
for _, v in ipairs(config_files_needed) do | local tmpname = tmpspace .. v | ||||
files[v] = io.open(config[v], "w+") | files[v] = io.open(tmpname, "w+") | ||||
end | end | ||||
-- Write out all of the preamble bits | -- Write out all of the preamble bits | ||||
write_line("sysent", string.format([[ | write_line("sysent", string.format([[ | ||||
/* The casts are bogus but will do for now. */ | /* The casts are bogus but will do for now. */ | ||||
struct sysent %s[] = { | struct sysent %s[] = { | ||||
]], config['switchname'])) | ]], config['switchname'])) | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | if (p != NULL) | ||||
strlcpy(desc, p, descsz); | strlcpy(desc, p, descsz); | ||||
} | } | ||||
]]) | ]]) | ||||
-- Finish up; output | -- Finish up; output | ||||
write_line("syssw", read_file("sysinc")) | write_line("syssw", read_file("sysinc")) | ||||
write_line("syssw", read_file("sysent")) | write_line("syssw", read_file("sysent")) | ||||
local fh = io.open(config["sysproto"], "w+") | write_line("sysproto", read_file("sysarg")) | ||||
fh:write(read_file("sysarg")) | write_line("sysproto", read_file("sysdcl")) | ||||
fh:write(read_file("sysdcl")) | |||||
for _, v in pairs(compat_options) do | for _, v in pairs(compat_options) do | ||||
fh:write(read_file(v["tmp"])) | write_line("sysproto", read_file(v["tmp"])) | ||||
fh:write(read_file(v["dcltmp"])) | write_line("sysproto", read_file(v["dcltmp"])) | ||||
end | end | ||||
fh:write(read_file("sysaue")) | write_line("sysproto", read_file("sysaue")) | ||||
fh:write(read_file("sysprotoend")) | write_line("sysproto", read_file("sysprotoend")) | ||||
fh:close() | |||||
write_line("systrace", read_file("systracetmp")) | write_line("systrace", read_file("systracetmp")) | ||||
write_line("systrace", read_file("systraceret")) | write_line("systrace", read_file("systraceret")) | ||||
for _, v in ipairs(output_files) do | |||||
local target = config[v] | |||||
if target ~= "/dev/null" then | |||||
local fh = io.open(target, "w+") | |||||
if fh == nil then | |||||
abort(1, "Failed to open '" .. target .. "'") | |||||
end | |||||
fh:write(read_file(v)) | |||||
fh:close() | |||||
end | |||||
end | |||||
cleanup() | cleanup() |