Skip to content

[FEATURE] "portable" implementation for POSIX's uint64_t time. #18849

@cederom

Description

@cederom

Is your feature request related to a problem? Please describe.

  • We are moving to POSIX compliant time representation (The Open Group Base Specifications Issue 8 IEEE Std 1003.1-2024 [1][2][3]) with uint64_t.
  • POSIX sys/types.h [3] defines:

    time_t as "Used for time in seconds"
    time_t shall be an integer type with a width (see <stdint.h>) of at least 64 bits.

  • What it solves:
    • year 2038 problem.
    • 32-bit system clock wrapped in ~497 days and almost every active board already enabled it.
    • runtime time overflow calculation errors after some weeks.
  • What it breaks:
    • 8/16/32-bit platforms are most likely impacted by increased code size (i.e. ~2KB) when long long type is not natively supported.
    • time calculation will be slower on older platforms.
    • non-atomic time access (needs some additional protection).

This is a long standing challenge discussed on our mailing list [4][5].

Related PR: #18840, #14460, apache/nuttx-apps#3468.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/
[2] https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/time.h.html
[3] https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_types.h.html
[4] https://www.mail-archive.com/dev@nuttx.apache.org/msg12060.html
[5] https://www.mail-archive.com/dev@nuttx.apache.org/msg14534.html

Describe the solution you'd like

  1. We are moving towards POSIX standard compliant time representation with int64_t type as default.
  2. We need alternative portable implementation of the time representation on platforms that do not support native int64_t type that will solve size increase, slow down, and non-atomic time access protections, but still assure POSIX compliant interface.
  3. Form the OS perspective both implementations should provide exactly the same and one-to-one compatible / replaceable solution, but the "portable" should assure best fit for the small architectures.

Describe alternatives you've considered

No response

Verification

  • I have verified before submitting the report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arch: avrIssues related to all AVR(8-bit or 32-bit) architecturesArch: avr32Issues related to AVR32 (32-bit) architectureArch: avr8Issues related to AVR (8-bit) architectureArch: mipsIssues related to the MIPS architectureArch: risc-vIssues related to the RISC-V (32-bit or 64-bit) architectureArch: simulatorIssues related to the SIMulatorArch: x86Issues related to the x86 architectureArch: xtensaIssues related to the Xtensa architectureArch: z16Issues related to the Z16 architectureArch: z80Issues related to the Z80 architectureArea: DocumentationImprovements or additions to documentationArea: KernelKernel issuesArea: ModularityNeeded to support modular architectureArea: PosixPosix issuesArea: StandardsNuttX application interfaces must compy to standardsBoard: allType: EnhancementNew feature or requestType: Improvement

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions