makesyscalls: automate detection of ABI changes
Use pattern matching including matches of _Contains_*_ argument annotations to (mostly) determine which system calls require ABI-specific handling. Automatically treat syscalls as NOPROTO if no ABI changes are present. Reviewed by: kevans
This commit is contained in:
parent
804a84fbf2
commit
988e8db3c0
@ -638,9 +638,11 @@ end
|
||||
|
||||
local function process_args(args)
|
||||
local funcargs = {}
|
||||
local changes_abi = false
|
||||
|
||||
for arg in args:gmatch("([^,]+)") do
|
||||
local abi_change = not isptrtype(arg) or check_abi_changes(arg)
|
||||
local arg_abi_change = check_abi_changes(arg)
|
||||
changes_abi = changes_abi or arg_abi_change
|
||||
|
||||
arg = strip_arg_annotations(arg)
|
||||
|
||||
@ -653,6 +655,10 @@ local function process_args(args)
|
||||
goto out
|
||||
end
|
||||
|
||||
-- is64bittype() needs a bare type so check it after argname
|
||||
-- is removed
|
||||
changes_abi = changes_abi or (abi_changes("pair_64bit") and is64bittype(argtype))
|
||||
|
||||
argtype = argtype:gsub("intptr_t", config["abi_intptr_t"])
|
||||
argtype = argtype:gsub("semid_t", config["abi_semid_t"])
|
||||
if isptrtype(argtype) then
|
||||
@ -671,7 +677,7 @@ local function process_args(args)
|
||||
end
|
||||
|
||||
-- XX TODO: Forward declarations? See: sysstubfwd in CheriBSD
|
||||
if abi_change then
|
||||
if arg_abi_change then
|
||||
local abi_type_suffix = config["abi_type_suffix"]
|
||||
argtype = argtype:gsub("(struct [^ ]*)", "%1" ..
|
||||
abi_type_suffix)
|
||||
@ -703,7 +709,7 @@ local function process_args(args)
|
||||
end
|
||||
|
||||
::out::
|
||||
return funcargs
|
||||
return funcargs, changes_abi
|
||||
end
|
||||
|
||||
local function handle_noncompat(sysnum, thr_flag, flags, sysflags, rettype,
|
||||
@ -1187,25 +1193,31 @@ process_syscall_def = function(line)
|
||||
end
|
||||
|
||||
local funcargs = {}
|
||||
local changes_abi = false
|
||||
if args ~= nil then
|
||||
funcargs = process_args(args)
|
||||
funcargs, changes_abi = process_args(args)
|
||||
end
|
||||
local noproto = config["abi_flags"] ~= "" and not changes_abi
|
||||
|
||||
local argprefix = ''
|
||||
local funcprefix = ''
|
||||
if abi_changes("pointer_args") then
|
||||
for _, v in ipairs(funcargs) do
|
||||
if isptrtype(v["type"]) then
|
||||
-- argalias should be:
|
||||
-- COMPAT_PREFIX + ABI Prefix + funcname
|
||||
argprefix = config['abi_func_prefix']
|
||||
funcprefix = config['abi_func_prefix']
|
||||
funcalias = funcprefix .. funcname
|
||||
changes_abi = true
|
||||
goto ptrfound
|
||||
end
|
||||
end
|
||||
::ptrfound::
|
||||
end
|
||||
if changes_abi then
|
||||
-- argalias should be:
|
||||
-- COMPAT_PREFIX + ABI Prefix + funcname
|
||||
argprefix = config['abi_func_prefix']
|
||||
funcprefix = config['abi_func_prefix']
|
||||
funcalias = funcprefix .. funcname
|
||||
noproto = false
|
||||
end
|
||||
if funcname ~= nil then
|
||||
funcname = funcprefix .. funcname
|
||||
end
|
||||
@ -1232,6 +1244,9 @@ process_syscall_def = function(line)
|
||||
local ncompatflags = get_mask({"STD", "NODEF", "NOARGS", "NOPROTO",
|
||||
"NOSTD"})
|
||||
local compatflags = get_mask_pat("COMPAT.*")
|
||||
if noproto then
|
||||
flags = flags | known_flags["NOPROTO"];
|
||||
end
|
||||
if flags & known_flags["OBSOL"] ~= 0 then
|
||||
handle_obsol(sysnum, funcname, funcomment)
|
||||
elseif flags & known_flags["RESERVED"] ~= 0 then
|
||||
|
Loading…
Reference in New Issue
Block a user