Page MenuHomeFreeBSD

D56627.diff
No OneTemporary

D56627.diff

diff --git a/sys/tools/syscalls/scripts/syscall_json.lua b/sys/tools/syscalls/scripts/syscall_json.lua
old mode 100644
new mode 100755
--- a/sys/tools/syscalls/scripts/syscall_json.lua
+++ b/sys/tools/syscalls/scripts/syscall_json.lua
@@ -5,17 +5,13 @@
-- Copyright (c) 2026 Warner Losh <imp@bsdimp.com>
--
--- Setup to be a module, or ran as its own script.
-local syscall_json = {}
-local script = not pcall(debug.getlocal, 4, 1) -- TRUE if script.
-if script then
- -- Add library root to the package path.
- local path = arg[0]:gsub("/[^/]+.lua$", "")
- package.path = package.path .. ";" .. path .. "/../?.lua"
-end
+-- Add library root to the package path.
+local path = arg[0]:gsub("/[^/]+.lua$", "")
+package.path = package.path .. ";" .. path .. "/../?.lua"
local FreeBSDSyscall = require("core.freebsd-syscall")
local ucl = require("ucl")
+local config = require("config")
-- Convert the type flags set (table with flag=true entries) to a sorted list.
local function flagsToList(typetbl)
@@ -75,52 +71,28 @@
return entry
end
-function syscall_json.generate(tbl, config)
+function generate(tbl, config)
-- Build the syscalls array.
local syscalls = {}
for _, v in pairs(tbl.syscalls) do
table.insert(syscalls, syscallToTable(v))
end
- -- Build the structs data into a nicer structure
- local structs = {}
- if tbl.structs ~= nil then
- for k, _ in pairs(tbl.structs) do
- table.insert(structs, k)
- end
- table.sort(structs)
- end
-
- local root = {
- syscalls = syscalls,
- structs = structs,
- }
-
- local json = ucl.to_json(root)
+ local json = ucl.to_json(syscalls)
-- Write to stdout.
io.write(json)
io.write("\n")
end
--- Entry of script:
-if script then
- local config = require("config")
-
- if #arg < 1 or #arg > 2 then
- error("usage: " .. arg[0] .. " syscall.master [config]")
- end
-
- local sysfile, configfile = arg[1], arg[2]
-
- config.merge(configfile)
- config.mergeCompat()
+if #arg < 1 or #arg > 2 then
+ error("usage: " .. arg[0] .. " syscall.master [config]")
+end
- -- The parsed system call table.
- local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
+local sysfile, configfile = arg[1], arg[2]
- syscall_json.generate(tbl, config)
-end
+config.merge(configfile)
+config.mergeCompat()
--- Return the module.
-return syscall_json
+local tbl = FreeBSDSyscall:new{sysfile = sysfile, config = config}
+generate(tbl, config)

File Metadata

Mime Type
text/plain
Expires
Fri, Jun 26, 6:43 PM (17 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
32141195
Default Alt Text
D56627.diff (2 KB)

Event Timeline