git: 0a4e16446b02 - main - makesyscalls: handle longs in ABI compat
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 22 Nov 2021 22:37:51 UTC
The branch main has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=0a4e16446b02f2aa0701ee0977366678987fba43
commit 0a4e16446b02f2aa0701ee0977366678987fba43
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 longs in ABI compat
Replace long-derived types with their abi equivalent where
required by the target ABI. There are two cases:
- All pointers to types that go from 64-bit to 32-bit between the
default ABI and the target ABI.
- Signed arguments that go from 64-bit to 32-bit (these require
sign-extension before passing to general kernel ABIs).
This adds four new config variables: abi_long, semid_t, abi_size_t,
and abi_u_long which default to long, size_t, and u_long respectively.
Reviewed by: kevans
---
sys/tools/makesyscalls.lua | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua
index 1023e2faa0e6..a4250e072277 100644
--- a/sys/tools/makesyscalls.lua
+++ b/sys/tools/makesyscalls.lua
@@ -62,6 +62,10 @@ local config = {
abi_flags_mask = 0,
abi_headers = "",
abi_intptr_t = "intptr_t",
+ abi_size_t = "size_t",
+ abi_u_long = "u_long",
+ abi_long = "long",
+ abi_semid_t = "semid_t",
ptr_intptr_t_cast = "intptr_t",
}
@@ -134,6 +138,16 @@ local known_abi_flags = {
value = 0x00000001,
exprs = {
"_Contains[a-z_]*_long_",
+ "^long [a-z0-9_]+$",
+ "long [*]",
+ "size_t [*]",
+ -- semid_t is not included because it is only used
+ -- as an argument or written out individually and
+ -- said writes are handled by the ksem framework.
+ -- Technically a sign-extension issue exists for
+ -- arguments, but because semid_t is actually a file
+ -- descriptor negative 32-bit values are invalid
+ -- regardless of sign-extension.
},
},
time_t_size = {
@@ -603,6 +617,15 @@ local function process_args(args)
end
argtype = argtype:gsub("intptr_t", config["abi_intptr_t"])
+ argtype = argtype:gsub("semid_t", config["abi_semid_t"])
+ if isptrtype(argtype) then
+ argtype = argtype:gsub("size_t", config["abi_size_t"])
+ argtype = argtype:gsub("^long", config["abi_long"]);
+ argtype = argtype:gsub("^u_long", config["abi_u_long"]);
+ argtype = argtype:gsub("^const u_long", "const " .. config["abi_u_long"]);
+ elseif argtype:find("^long$") then
+ argtype = config["abi_long"]
+ end
-- XX TODO: Forward declarations? See: sysstubfwd in CheriBSD
if abi_change then