Skip to content

refactor: change definition of time_t in TEEOS#5130

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

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

@dybucc dybucc commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

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 OhOS 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

dybucc commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

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

@dybucc dybucc force-pushed the teeos-time_t-transition branch from de93600 to 3a011ec Compare June 4, 2026 07:05
@rustbot

This comment has been minimized.

@dybucc dybucc force-pushed the teeos-time_t-transition branch from 3a011ec to e6a8671 Compare June 9, 2026 07:14
@rustbot

This comment has been minimized.

@dybucc

dybucc commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

CI actually passes. There seems to be an issue with a glob import that is not used, but this has not
been changed in the patch (it's not even part of it, for that matter.) For some reason, rebasing
onto main with dependabot updates has ended up with a warning across all of my open PRs due to
that one (now apparently unused) import.

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 e6a8671 to 56108bc Compare June 15, 2026 15:13
@rustbot

rustbot commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

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.

@dybucc dybucc marked this pull request as draft June 15, 2026 15:15
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.

2 participants