git: 79634eb90bff - main - makesyscalls: handle arrays of pointers
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 22 Nov 2021 22:37:52 UTC
The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=79634eb90bff52e9b651bdae6f57082741778d1b commit 79634eb90bff52e9b651bdae6f57082741778d1b Author: Brooks Davis <brooks@FreeBSD.org> AuthorDate: 2021-11-22 22:36:57 +0000 Commit: Brooks Davis <brooks@FreeBSD.org> CommitDate: 2021-11-22 22:36:57 +0000 makesyscalls: handle arrays of pointers When the config variable abi_intptr_t is not "", transform arrays of pointers to arrays of abi_intptr_t. Reviewed by: kevans --- sys/tools/makesyscalls.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua index a4250e072277..a5387463e4e2 100644 --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -66,6 +66,7 @@ local config = { abi_u_long = "u_long", abi_long = "long", abi_semid_t = "semid_t", + abi_ptr_array_t = "", ptr_intptr_t_cast = "intptr_t", } @@ -163,6 +164,7 @@ local known_abi_flags = { value = 0x00000008, exprs = { "_Contains[a-z_]*_ptr_", + "[*][*]", }, }, } @@ -420,6 +422,10 @@ local function isptrtype(type) type:find("intptr_t") or type:find(config['abi_intptr_t']) end +local function isptrarraytype(type) + return type:find("[*][*]") or type:find("[*][ ]*const[ ]*[*]") +end + local process_syscall_def -- These patterns are processed in order on any line that isn't empty. @@ -626,6 +632,12 @@ local function process_args(args) elseif argtype:find("^long$") then argtype = config["abi_long"] end + if isptrarraytype(argtype) and config["abi_ptr_array_t"] ~= "" then + -- `* const *` -> `**` + argtype = argtype:gsub("[*][ ]*const[ ]*[*]", "**") + -- e.g., `struct aiocb **` -> `uint32_t *` + argtype = argtype:gsub("[^*]*[*]", config["abi_ptr_array_t"] .. " ", 1) + end -- XX TODO: Forward declarations? See: sysstubfwd in CheriBSD if abi_change then