This is an archive of the discontinued LLVM Phabricator instance.

[libc] Make time_t 64 bits long on all platforms but arm32
ClosedPublic

Authored by mikhail.ramalho on Aug 29 2023, 11:04 AM.

Details

Summary

This patch changes the size of time_t to be an int64_t. This still
follows the POSIX standard which only requires time_t to be an integer.

Making time_t a 64-bit integer also fixes two cases in 32 bits platforms
that use SYS_clock_nanosleep_time64 and SYS_clock_gettime64, as the name
of these calls implies, they require a 64-bit time_t. For instance, in rv32,
the 32-bit version of these syscalls is not available.

We also follow glibc here, where time_t is still a 32-bit integer in
arm32.

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptAug 29 2023, 11:04 AM
mikhail.ramalho requested review of this revision.Aug 29 2023, 11:04 AM
  • define time64_t as INT64_TYPE
  • rebased
  • define INT64_TYPE time_t
  • Rebased
mikhail.ramalho retitled this revision from [libc] Fix nanosleep implementation when using SYS_clock_nanosleep_time64 in 32-bit systems to [libc] Make time_t 64 bits long on all platforms but arm32.Sep 8 2023, 10:34 AM
mikhail.ramalho edited the summary of this revision. (Show Details)
sivachandra added inline comments.Sep 8 2023, 12:18 PM
libc/src/time/linux/clockGetTimeImpl.h
17

cstdint is a C++ header which we cannot include in the runtime code. Use stdint.h.

  • Fix header include
sivachandra accepted this revision.Sep 12 2023, 1:37 PM
This revision is now accepted and ready to land.Sep 12 2023, 1:37 PM