Skip to content

refactor: move definition of time_t in uclibc#5144

Draft
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:uclibc-time_t-patch
Draft

refactor: move definition of time_t in uclibc#5144
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:uclibc-time_t-patch

Conversation

@dybucc
Copy link
Copy Markdown
Contributor

@dybucc dybucc commented Jun 5, 2026

Description

This PR addresses bit-width representation issues under uClibc for the time_t type.

Following the definition in upstream uclibc-ng (the maintained fork of uClibc,) this type should be
defined in terms of either an i64 or a c_long. This depends on a macro, __UCLIBC_USE_TIME64__,
that makes the latter one available in all systems, irrespective of machine word size or
implementation memory model. This type is declared under libc/sysdeps/linux/common/bits/types.h,
in terms of other types in libc/sysdeps/linux/common/bits/typesizes.h, with no alternative
definitions for other platforms.

Yet in the libc crate, time_t under the uclibc module has different definitions for all four
of MIPS32, MIPS64, arm and x86_64. This patch changes that such that the definition is shared by all
targets using uClibc, at the top-level uclibc/mod.rs module instead.

Tests are still pending on all platforms, but this PR has been open anyway to show part of
yesterday's work.

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

The uclibc-ng upstream project did not seem to provide different
definitions for all of the target architectures for which the `libc`
crate does provide different definitions.

This patch aims to solve that by moving the prior type-specific
definition of `time_t` to the top-level `unix/linux_like/linux/uclibc`
module. `time_t` is now defined in terms of a platform- and
implementation-specific `c_long`, which fits the default in upstream.

There is a macro that the uclibc-ng project checks for to ensure that
the type is 64-bits wide and not left to the system implementation, but
that does not exist in the original uClibc. This patch does not add
support for it.
@dybucc dybucc force-pushed the uclibc-time_t-patch branch from 6bfd246 to 77686a8 Compare June 5, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant