From nobody Mon Nov 22 22:38:00 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 97FE11893145; Mon, 22 Nov 2021 22:38:02 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HyhxP3NpQz4YQc; Mon, 22 Nov 2021 22:38:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B20DC2EF4; Mon, 22 Nov 2021 22:38:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1AMMc0IJ047520; Mon, 22 Nov 2021 22:38:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1AMMc0rJ047519; Mon, 22 Nov 2021 22:38:00 GMT (envelope-from git) Date: Mon, 22 Nov 2021 22:38:00 GMT Message-Id: <202111222238.1AMMc0rJ047519@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: 988e8db3c041 - main - makesyscalls: automate detection of ABI changes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 988e8db3c041e39db0da9fbb0edde9e0e3d53326 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=988e8db3c041e39db0da9fbb0edde9e0e3d53326 commit 988e8db3c041e39db0da9fbb0edde9e0e3d53326 Author: Brooks Davis AuthorDate: 2021-11-22 22:36:58 +0000 Commit: Brooks Davis CommitDate: 2021-11-22 22:36:58 +0000 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 --- sys/tools/makesyscalls.lua | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua index e723346f1679..48ad05eb0469 100644 --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -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