KZT, fix: Change int64_t to int32_t for signature 'i' and uint64_t to uint32_t for 'u'#295
Merged
Merged
Conversation
… uint32_t for 'u' Co-authored-by: sunguoyun <sunguoyun@loongson.cn>
luzeng87
approved these changes
May 21, 2026
Contributor
luzeng87
left a comment
There was a problem hiding this comment.
审查总结
将 KZT wrapper 中签名字母 i(int)对应的 int64_t → int32_t、u(unsigned)对应的 uint64_t → uint32_t。
x86/x86_64 ABI 中 int = 32-bit,unsigned int = 32-bit。旧代码错用 64-bit 类型,导致参数传递和返回值语义偏差。修复正确。
逐项检查
类型定义(8 个 typedef):
iFippi_t、iFippp_t:返回值和 int 参数全部 int64_t→int32_t ✅vFpppi_t、vFppiip_t、vFppiiip_t、vFppii_t:int 参数 int64_t→int32_t ✅vFpppuuuu_t:unsigned 参数 uint64_t→uint32_t ✅pFppiiiiiip_t:6 个 int 参数 int64_t→int32_t ✅
调用实现(8 个函数体):
- R_RDI/R_RSI/R_RDX/R_RCX/R_R8/R_R9 的 cast 全部
(int64_t)→(int32_t)/(uint64_t)→(uint32_t)✅ - 栈参数
*(int64_t*)→*(int32_t*)/*(uint64_t*)→*(uint32_t*)✅ - 栈参数偏移
+8、+16未变 — x86_64 栈槽仍为 8 字节对齐,指针算术正确 ✅ - 返回值 cast
(int64_t)→(int32_t)— 匹配 int32 返回语义 ✅ - 未涉及的
vFE、pFppL('L'=long)保持不变 ✅
未发现问题
- 符号扩展:
(int32_t)R_RDI仅取低 32 位,x86_64 ABI 中 int 参数高位未定义,无损失 - 栈读取:
*(int32_t*)(R_RSP + 8)从 8 字节栈槽读 4 字节,取低 32 位正确 - 与现有其他 wrapper(
pFppL_t仍用int64_t/uintptr_t)一致
结论
通过。 正确的 ABI 修复,变更范围精确,无副作用。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
Please review my patch.
Thanks,
Leslie Zhai