Skip to content

refactor: change definition of time_t in TEEOS#5130

Open
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:teeos-time_t-transition
Open

refactor: change definition of time_t in TEEOS#5130
dybucc wants to merge 1 commit into
rust-lang:mainfrom
dybucc:teeos-time_t-transition

Conversation

@dybucc
Copy link
Copy Markdown
Contributor

@dybucc dybucc commented Jun 1, 2026

Description

This PR aims to both discuss and (possibly) change the bit-width of the time_t type in TEEOS. At
present, we expose a single time_t type whose bit-width relies on semantics specific to each
target system, as c_long is likely to be 64-bit wide under platforms following LP64 and 32-bit
wide under platforms following LLP64, but there's a few things that lead me to believe this may
cause conflicts in TEEOS.

The first issue I would like to address is that if we're exposing the time_t definition in the
OhosOS SDK that TEEOS uses, our current definition is not completely correct. SDKs for all three of
Darwin, Linux and Windows use the same definition as musl; Namely, typedef _Int64 time_t. In
libc, though, we expose it as a c_long.

Just to be sure, though, I then looked at the TEEOS upstream kernel repo, and they define time_t
in terms of either one of a 32-bit unsigned integer or a 64-bit unsigned integer, depending on the
machine's word size. That implies this target OS likely supports running on both such types of
machines, which means that our current definition is sort of OK on the bitwidth side but not on the
signed integer side.

The proposed change in this PR switches the type to be an explicit 64-bit signed integer, though
this has not taken into account the definition in the TEEOS kernel. That's why I would like to spark
some discussion on this, or otherwise call it a day and learn something new.

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

@dybucc dybucc changed the title refactor: change type of time_t in TEEOS refactor: change definition of time_t in TEEOS Jun 1, 2026
@dybucc
Copy link
Copy Markdown
Contributor Author

dybucc commented Jun 1, 2026

CI seems to have failed for reasons unrelated to the changes introduced in this PR. Rerunning it
will likely solve it.

The type with which it was defined did not reflect the right definition,
not by musl standard nor by the actual definitions found in the latest
OhOS SDK. Indeed, `c_long` in Linux systems is likely to be defined as a
64-bit integer, but the definition in all of the above, which are
mentioned to be used by TEEOS in the rustc target information, define
`time_t` specifically as an `_Int64`.

Sources are included in the accompanying PR.
@dybucc dybucc force-pushed the teeos-time_t-transition branch from de93600 to 3a011ec Compare June 4, 2026 07:05
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Jun 4, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

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.

2 participants