tools/include/linux/types.h: add ulong typedef for musl compatibility
PATCH 1/1 tools/include/linux/types.h: add ulong typedef for musl compatibility
Building KVM selftests with musl libc fails across multiple files (e.g. memslot_perf_test.c, cpuid_test.c) with 'ulong' undeclared.
Under glibc, <semaphore.h> includes <sys/types.h>, which exposes ulong. Under musl, <semaphore.h> includes only <features.h>, <bits/alltypes.h> and <fcntl.h>, and does not include <sys/types.h>. As a result, ulong is not visible through the current selftests include chain.
include/linux/types.h already defines both ulong and ullong in its sysv aliases block. tools/include/linux/types.h mirrors ullong but omits ulong. Add ulong alongside ullong to close the gap.
--- tools/include/linux/types.h | 1 + 1 file changed, 1 insertion(+)
tools/include/linux/types.h +1 -0
@@ -42,6 +42,7 @@ typedef __s16 s16;typedef __u8 u8 ;typedef __s8 s8 ; +typedef unsigned long ulong ;typedef unsigned long long ullong ;#ifdef __CHECKER__
Signature · 1 line
2.51.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Adding `ulong` typedef to `tools/include/linux/types.h` causes a `-Werror=redundant-decls` build…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Adding ulong typedef to tools/include/linux/types.h causes a -Werror=redundant-decls build failure in host tools like perf. --
commit 88e8d7a9a4205d14733be0e5978d3a32589a15e0
Author: Hisam Mehboob <[email protected]>
tools/include/linux/types.h: add ulong typedef for musl compatibility
This commit adds a ulong typedef to tools/include/linux/types.h to fix build failures in KVM selftests when using the musl libc.
tools/include/linux/types.h typedef __s16 s16; · line 45
Quoted 9 lines
tools/include/linux/types.h +1
-0@@ -42,6 +42,7 @@ typedef __s16 s16;typedef __u8 u8 ;typedef __s8 s8 ; +typedef unsigned long ulong ;
[Severity: Low]
Will this unconditional typedef cause a build failure in other host tools like perf?
Because glibc and musl <sys/types.h> also provide a ulong typedef, adding this here without guards triggers a -Werror=redundant-decls build failure in tools like perf, which compile with -Wredundant-decls (via EXTRA_WARNINGS in tools/scripts/Makefile.include) alongside -Werror.
Quoted 3 lines
tools/include/linux/types.h +0
-0typedef unsigned long long ullong ;#ifdef __CHECKER__
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 26 lines · On 5/31/26 20:01, [email protected] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Addingulongtypedef totools/include/linux/types.hcauses a-Werror=redundant-declsbuild failure in host tools likeperf. --commit
88e8d7a9a4205d14733be0e5978d3a32589a15e0
Author: Hisam Mehboob <[email protected]>
tools/include/linux/types.h: add ulong typedef for musl compatibilityThis commit adds a ulong typedef to
tools/include/linux/types.hto fix build failures in KVM selftests when using the musl libc.tools/include/linux/types.h typedef __s16 s16; · line 45
Quoted 9 lines
tools/include/linux/types.h +1
-0@@ -42,6 +42,7 @@ typedef __s16 s16;typedef __u8 u8 ;typedef __s8 s8 ; +typedef unsigned long ulong ;[Severity: Low]
Will this unconditional typedef cause a build failure in other host tools like perf?
Quoted 9 lines
Because glibc and musl <
sys/types.h> also provide a ulong typedef, adding this here without guards triggers a -Werror=redundant-decls build failure in tools like perf, which compile with -Wredundant-decls (viaEXTRA_WARNINGSintools/scripts/Makefile.include) alongside -Werror.Quoted 3 lines
tools/include/linux/types.h +0
-0typedef unsigned long long ullong ;#ifdef __CHECKER__
I couldn't reproduce this. C11 §6.7p3 permits compatible typedef redeclarations, and -Wredundant-decls targets function/object redeclarations, not typedefs.
Happy to hear any feedback on this.
Quoted 2 lines · Hisam Mehboob
Building KVM selftests with musl libc fails across multiple files (e.g.
memslot_perf_test.c,cpuid_test.c) with 'ulong' undeclared.
Gentle ping. Could I get some feedback on this patch?
Thanks,
Hisam