From nobody Tue Apr 16 16:48:20 2024 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 4VJqjc6y91z5H9Q4; Tue, 16 Apr 2024 16:48:20 +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 4VJqjc4Jzjz4Xv0; Tue, 16 Apr 2024 16:48:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713286100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IXrlHiBlX1zIbWFjTSJoS/Zxwg9N414saDmBgzI7Fq8=; b=D9m9BvWOzmMvxWB0a4q8GPOaSQ1J6pTDcQezAxcHshiOrt+Xqy01FBt+c+4vJIx2yJmiRz DhzImh89AT49fuDAFFzU5Yyg+/LA7vConSK9tXdQaSewIFtykR7OHDEIqTmQ/kqy4fU7Aa 0wOjDExTaRKxc8tB4hsXNXwgm1mP0KZ6R3peL0Z235M4ED4AwmrF41kphDXEH6zoDC7cDV TesLyC92HEz2/d7TD19opzIPriduCGImh0zQBCOFtq8hTFlGbaPUqugJHLP7o9V1oArke7 Xb+adEOH5fuApWOx0lysd09c90A/ZI7dIx0mruTdeAoc32mT410wO162JFKjcg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713286100; a=rsa-sha256; cv=none; b=HpfVeymHQFmqjbttZUarHgnyLVVtvdhyJALLtaVoD8OEnm9UPxQo91jBLnZPurSoppnftx z05xnNqOZPmp8H9lWuUrGwmF4lReyZY4P30gBFH4xIHGkrZPrstaMoP5T0QeYEsS6Mct2s VcwczzR3XgOQ3nb/xhgmSeMjIb5AEQJH3slHJxHxjuoGOjsHtdSvBlhdVB3pBECpQJ7m2K CXdJPC62U/+iRqgwB0jX4FOUNf+CLZ0JYpvB6MBAG09yA310VP3ArwhIzo3vF5qzkk/MVH 8QnOi54oqLoawceIooao+fqS0pi7AM41ESr7D4gjYyetNcbAWPE5B8uTIyAr7A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713286100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=IXrlHiBlX1zIbWFjTSJoS/Zxwg9N414saDmBgzI7Fq8=; b=ZsZUwAtFPmGqKHCR2H27AWssYF21PTNoA7+MkCzjRoKCiM0Lx57fA5HysYC8gjcJVBusiS yDiXqfswZLOi852bW7BvHnQpQMoD84/VpNbPlkZzYG0qel/hTcwrn5rW9EBp1K1W7xDpNQ Q/Plyu67i16I22ZMD24biRxmib15yTXn0w9w7VZ9dzN5X1m61dJeG9k+agQuFi4DgXHbMo ybHefF9UiByHereq7DEZCsnsrazcqN5imwRshA1whi2lIukaYSpu6Jgr6F/12/p0SHUEk7 YjeIEBqJyjqEE9ZiQ5nO64PDHhD94Dz9rmR3xpqHa6JCMmcSykoR+/cPZ+FDuQ== 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 4VJqjc3wXkzqL4; Tue, 16 Apr 2024 16:48:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GGmKnU079935; Tue, 16 Apr 2024 16:48:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GGmKYG079932; Tue, 16 Apr 2024 16:48:20 GMT (envelope-from git) Date: Tue, 16 Apr 2024 16:48:20 GMT Message-Id: <202404161648.43GGmKYG079932@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: 79b758e32775 - main - makesyscalls: generate core libsys header 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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: 79b758e327757dc015fb26a122fdc9608c405e9e Auto-Submitted: auto-generated The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=79b758e327757dc015fb26a122fdc9608c405e9e commit 79b758e327757dc015fb26a122fdc9608c405e9e Author: Brooks Davis AuthorDate: 2024-04-16 16:48:07 +0000 Commit: Brooks Davis CommitDate: 2024-04-16 16:48:07 +0000 makesyscalls: generate core libsys header Create a header covering most of the "stable" libsys interfaces. Specifically __sys_ syscall stubs and __sys__t typedefs for those interfaces. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44386 --- sys/tools/makesyscalls.lua | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua index 624b84a32eb1..a87c8c421313 100644 --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -35,6 +35,7 @@ local unistd = require("posix.unistd") local savesyscall = -1 local maxsyscall = -1 +local structs = {} local generated_tag = "@" .. "generated" -- Default configuration; any of these may get replaced by a configuration file @@ -43,6 +44,7 @@ local config = { os_id_keyword = "FreeBSD", -- obsolete, ignored on input, not generated abi_func_prefix = "", libsysmap = "/dev/null", + libsys_h = "/dev/null", sysnames = "syscalls.c", sysproto = "../sys/sysproto.h", sysproto_h = "_SYS_SYSPROTO_H_", @@ -87,6 +89,7 @@ local output_files = { "syshdr", "sysmk", "libsysmap", + "libsys_h", "syssw", "systrace", "sysproto", @@ -94,6 +97,8 @@ local output_files = { -- These ones we'll create temporary files for; generation purposes. local temp_files = { + "libsys_h_type", + "libsys_h_func", "sysaue", "sysdcl", "syscompat", @@ -934,6 +939,47 @@ local function handle_noncompat(sysnum, thr_flag, flags, sysflags, rettype, end write_line("libsysmap", string.format("\t__sys_%s;\n", funcalias)) + + if flags & known_flags.SYSMUX == 0 then + local argstr_type = "" + local argstr_var = "" + local comma = "" + if #funcargs == 0 then + argstr_type = "void" + argstr_var = "void" + end + for _, v in ipairs(funcargs) do + local argname, argtype = v.name, v.type + argstr_type = argstr_type .. comma .. argtype + argstr_var = argstr_var .. comma .. argtype .. " " .. argname + comma = ", " + + -- Accumulate a list of struct types for + -- forward decls. We can't do this in + -- process_args because we don't want compat + -- types in userspace even as no-op. + if isptrtype(argtype) then + local is_struct = false + for word in argtype:gmatch("[^ *]+") do + if is_struct then + structs[word] = word + break + end + if word == "struct" then + is_struct = true + -- next word is the name + end + end + end + end + write_line("libsys_h_type", + string.format("typedef %s (__sys_%s_t)(%s);\n", + syscallret, funcalias, argstr_type)) + write_line("libsys_h_func", + string.format("%s __sys_%s(%s);\n", + syscallret, funcalias, argstr_var)) + + end end end @@ -1330,6 +1376,20 @@ process_syscall_def = function(line) end end +local function pairsByKeys (t, f) + local a = {} + for n in pairs(t) do table.insert(a, n) end + table.sort(a, f) + local i = 0 -- iterator variable + local iter = function () -- iterator function + i = i + 1 + if a[i] == nil then return nil + else return a[i], t[a[i]] + end + end + return iter +end + -- Entry point if #arg < 1 or #arg > 2 then @@ -1504,6 +1564,27 @@ write_line("libsysmap", string.format([[/* FBSDprivate_1.0 { ]], generated_tag)) +write_line("libsys_h", string.format([[/* + * Public system call stubs provided by libsys. + * + * Do not use directly, include instead. + * + * DO NOT EDIT-- this file is automatically %s. + */ +#ifndef __LIBSYS_H_ +#define __LIBSYS_H_ + +#include +#include +#include +#include +#include +#include /* for mcontext_t */ +#include +#include + +]], generated_tag)) + write_line("systrace", string.format([[/* * System call argument to DTrace register array converstion. * @@ -1600,6 +1681,16 @@ write_line("systraceret", [[ ]]) -- Finish up; output +table.sort(structs) +for name,_ in pairsByKeys(structs) do + write_line("libsys_h", string.format("struct %s;\n", name)) +end +write_line("libsys_h", "union semun;\n\n__BEGIN_DECLS\n") +write_line("libsys_h", read_file("libsys_h_type")) +write_line("libsys_h", "\n") +write_line("libsys_h", read_file("libsys_h_func")) +write_line("libsys_h", "__END_DECLS\n\n#endif /* __LIBSYS_H_ */\n") + write_line("syssw", read_file("sysinc")) write_line("syssw", read_file("sysent"))