Make makesyscalls.lua initialize 'struct sysent' entries using c99

designated initializers.  This makes it easier to modify 'struct sysent'
layout.

Reviewed by:	kevans
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D26530
This commit is contained in:
trasz 2020-09-25 09:34:00 +00:00
parent e77e27faf1
commit 340b78c6d4

View File

@ -740,12 +740,14 @@ local function handle_noncompat(sysnum, thr_flag, flags, sysflags, rettype,
config['syscallprefix'], funcalias, auditev))
end
write_line("sysent", string.format("\t{ %s, (sy_call_t *)", argssize))
write_line("sysent",
string.format("\t{ .sy_narg = %s, .sy_call = (sy_call_t *)", argssize))
local column = 8 + 2 + #argssize + 15
if flags & known_flags["NOSTD"] ~= 0 then
write_line("sysent", string.format(
"lkmressys, AUE_NULL, NULL, 0, 0, %s, SY_THR_ABSENT },",
"lkmressys, .sy_auevent = AUE_NULL, " ..
".sy_flags = %s, .sy_thrcnt = SY_THR_ABSENT },",
sysflags))
column = column + #"lkmressys" + #"AUE_NULL" + 3
else
@ -754,12 +756,12 @@ local function handle_noncompat(sysnum, thr_flag, flags, sysflags, rettype,
funcname:find("^linux") or
funcname:find("^cloudabi") then
write_line("sysent", string.format(
"%s, %s, NULL, 0, 0, %s, %s },",
"%s, .sy_auevent = %s, .sy_flags = %s, .sy_thrcnt = %s },",
funcname, auditev, sysflags, thr_flag))
column = column + #funcname + #auditev + #sysflags + 3
else
write_line("sysent", string.format(
"sys_%s, %s, NULL, 0, 0, %s, %s },",
"sys_%s, .sy_auevent = %s, .sy_flags = %s, .sy_thrcnt = %s },",
funcname, auditev, sysflags, thr_flag))
column = column + #funcname + #auditev + #sysflags + 7
end
@ -781,7 +783,8 @@ end
local function handle_obsol(sysnum, funcname, comment)
write_line("sysent",
"\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },")
"\t{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, " ..
".sy_auevent = AUE_NULL, .sy_flags = 0, .sy_thrcnt = SY_THR_ABSENT },")
align_sysent_comment(34)
write_line("sysent", string.format("/* %d = obsolete %s */\n",
@ -849,13 +852,15 @@ local function handle_compat(sysnum, thr_flag, flags, sysflags, rettype,
if flags & known_flags['NOSTD'] ~= 0 then
write_line("sysent", string.format(
"\t{ %s, (sy_call_t *)%s, %s, NULL, 0, 0, 0, SY_THR_ABSENT },",
"\t{ .sy_narg = %s, .sy_call = (sy_call_t *)%s, " ..
".sy_auevent = %s, .sy_flags = 0, " ..
".sy_thrcnt = SY_THR_ABSENT },",
"0", "lkmressys", "AUE_NULL"))
align_sysent_comment(8 + 2 + #"0" + 15 + #"lkmressys" +
#"AUE_NULL" + 3)
else
write_line("sysent", string.format(
"\t{ %s(%s,%s), %s, NULL, 0, 0, %s, %s },",
"\t{ %s(%s,%s), .sy_auevent = %s, .sy_flags = %s, .sy_thrcnt = %s },",
wrap, argssize, funcname, auditev, sysflags, thr_flag))
align_sysent_comment(8 + 9 + #argssize + 1 + #funcname +
#auditev + #sysflags + 4)
@ -889,7 +894,9 @@ local function handle_unimpl(sysnum, sysstart, sysend, comment)
sysnum = sysstart
while sysnum <= sysend do
write_line("sysent", string.format(
"\t{ 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_ABSENT },\t\t\t/* %d = %s */\n",
"\t{ .sy_narg = 0, .sy_call = (sy_call_t *)nosys, " ..
".sy_auevent = AUE_NULL, .sy_flags = 0, " ..
".sy_thrcnt = SY_THR_ABSENT },\t\t\t/* %d = %s */\n",
sysnum, comment))
write_line("sysnames", string.format(
"\t\"#%d\",\t\t\t/* %d = %s */\n",
@ -1302,9 +1309,9 @@ for _, v in pairs(compat_options) do
write_line("sysinc", string.format([[
#ifdef %s
#define %s(n, name) n, (sy_call_t *)__CONCAT(%s,name)
#define %s(n, name) .sy_narg = n, .sy_call = (sy_call_t *)__CONCAT(%s,name)
#else
#define %s(n, name) 0, (sy_call_t *)nosys
#define %s(n, name) .sy_narg = 0, .sy_call = (sy_call_t *)nosys
#endif
]], v["definition"], v["flag"]:lower(), v["prefix"], v["flag"]:lower()))
end