Skip to content

Conversation

kraj
Copy link
Contributor

@kraj kraj commented Jul 25, 2025

time_t and suseconds_t are defined as 64-bit quanity on musl systems regardless of 32bit or 64bit CPU word length

grep "_Int64" in musl tree shows this

arch/aarch64/bits/alltypes.h.in:#define _Int64 long arch/arm/bits/alltypes.h.in:#define _Int64 long long arch/i386/bits/alltypes.h.in:#define _Int64 long long arch/loongarch64/bits/alltypes.h.in:#define _Int64 long arch/m68k/bits/alltypes.h.in:#define _Int64 long long arch/microblaze/bits/alltypes.h.in:#define _Int64 long long arch/mips/bits/alltypes.h.in:#define _Int64 long long arch/mips64/bits/alltypes.h.in:#define _Int64 long arch/mipsn32/bits/alltypes.h.in:#define _Int64 long long arch/or1k/bits/alltypes.h.in:#define _Int64 long long arch/powerpc/bits/alltypes.h.in:#define _Int64 long long arch/powerpc64/bits/alltypes.h.in:#define _Int64 long arch/riscv32/bits/alltypes.h.in:#define _Int64 long long arch/riscv64/bits/alltypes.h.in:#define _Int64 long arch/s390x/bits/alltypes.h.in:#define _Int64 long
arch/sh/bits/alltypes.h.in:#define _Int64 long long arch/x32/bits/alltypes.h.in:#define _Int64 long long arch/x86_64/bits/alltypes.h.in:#define _Int64 long include/alltypes.h.in:TYPEDEF _Int64 time_t;
include/alltypes.h.in:TYPEDEF _Int64 suseconds_t;

Description

Sources

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

time_t and suseconds_t are defined as 64-bit quanity on musl systems
regardless of 32bit or 64bit CPU word length

grep "_Int64" in musl tree shows this

arch/aarch64/bits/alltypes.h.in:#define _Int64 long
arch/arm/bits/alltypes.h.in:#define _Int64 long long
arch/i386/bits/alltypes.h.in:#define _Int64 long long
arch/loongarch64/bits/alltypes.h.in:#define _Int64 long
arch/m68k/bits/alltypes.h.in:#define _Int64 long long
arch/microblaze/bits/alltypes.h.in:#define _Int64 long long
arch/mips/bits/alltypes.h.in:#define _Int64 long long
arch/mips64/bits/alltypes.h.in:#define _Int64 long
arch/mipsn32/bits/alltypes.h.in:#define _Int64 long long
arch/or1k/bits/alltypes.h.in:#define _Int64 long long
arch/powerpc/bits/alltypes.h.in:#define _Int64 long long
arch/powerpc64/bits/alltypes.h.in:#define _Int64 long
arch/riscv32/bits/alltypes.h.in:#define _Int64 long long
arch/riscv64/bits/alltypes.h.in:#define _Int64 long
arch/s390x/bits/alltypes.h.in:#define _Int64 long
arch/sh/bits/alltypes.h.in:#define _Int64 long long
arch/x32/bits/alltypes.h.in:#define _Int64 long long
arch/x86_64/bits/alltypes.h.in:#define _Int64 long
include/alltypes.h.in:TYPEDEF _Int64 time_t;
include/alltypes.h.in:TYPEDEF _Int64 suseconds_t;

Signed-off-by: Khem Raj <[email protected]>
@tgross35
Copy link
Contributor

Unfortunately this isn't just a trivial incorrect type; we also need to use the new link names when the 1.2 definitions are used. There is a work in progress at #4463.

@kraj
Copy link
Contributor Author

kraj commented Jul 29, 2025

Unfortunately this isn't just a trivial incorrect type; we also need to use the new link names when the 1.2 definitions are used. There is a work in progress at #4463.

yeah I did realize it after some testing. We need to keep the underlying types matches with musl, so perhaps c_long and c_longlong based upon architecture would be right thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants