Skip to content

!sched/clock: drop CONFIG_SYSTEM_TIME64 / CONFIG_HAVE_LONG_LONG / CONFIG_LIBC_LONG_LONG and sclock_t#18840

Open
xiaoxiang781216 wants to merge 5 commits intoapache:masterfrom
xiaoxiang781216:sched/remove-system-time64
Open

!sched/clock: drop CONFIG_SYSTEM_TIME64 / CONFIG_HAVE_LONG_LONG / CONFIG_LIBC_LONG_LONG and sclock_t#18840
xiaoxiang781216 wants to merge 5 commits intoapache:masterfrom
xiaoxiang781216:sched/remove-system-time64

Conversation

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

@xiaoxiang781216 xiaoxiang781216 commented May 3, 2026

Summary

note:

  1. need merge !sched: drop CONFIG_SYSTEM_TIME64 / CONFIG_HAVE_LONG_LONG / CONFIG_LIBC_LONG_LONG and sclock_t nuttx-apps#3468 first
  2. see the follow link for more information:
    SIGNED time_t #3390
    [BREAKING] types.h: time_t as int64_t #14460

Collapse the long-standing 32-bit/64-bit time_t flavor split in NuttX
into a single 64-bit signed configuration, and drop three companion
"toggle" Kconfig options that no longer pull their weight:

  1. CONFIG_SYSTEM_TIME64 – always on; the 32-bit system clock wrapped
    in ~497 days and almost every active board already enabled it.
  2. CONFIG_HAVE_LONG_LONG – every supported toolchain provides
    long long; the indirection only obscured the libc/libm code.
  3. CONFIG_LIBC_LONG_LONG – follow-up to the above; printf("%lld")
    and friends are now unconditional.

While there, retype time_t/clock_t from uint64_t to int64_t to
match POSIX practice on Linux/glibc, the BSDs, macOS, RTEMS, Zephyr
and Windows _time64. This lets (time_t)-1 sentinels and signed
tick deltas work without source churn, and folds the now-redundant
sclock_t alias back to clock_t.

Commits in this PR

dd4f46beeac compiler: drop CONFIG_HAVE_LONG_LONG and require long long support
de3d4d06a1e libc/stream: remove CONFIG_LIBC_LONG_LONG and always support long long
b00d9d98634 sched/clock: remove CONFIG_SYSTEM_TIME64 and always use 64-bit time
dbc8713c36a sys/types.h: change time_t and clock_t to int64_t to align with other OSes

Impact

Behavior

  • time_t : uint64_tint64_t
  • clock_t : uint64_tint64_t
  • sclock_t: removed (alias of clock_t)
  • nuttx_time_t (hostfs ABI): always 64-bit signed
  • CLOCK_MAX / SCLOCK_MAX: UINT64_MAXINT64_MAX
  • PRI*TM / SCN*TM: removed (use PRId64 / SCNd64)
  • long long printf/scanf conversions are always available

Removed Kconfig options

  • CONFIG_SYSTEM_TIME64
  • CONFIG_HAVE_LONG_LONG
  • CONFIG_LIBC_LONG_LONG
  • depends on SYSTEM_TIME64 in PERF_OVERFLOW_CORRECTION / HRTIMER

All =y / "is not set" lines stripped from board defconfigs (sed pass).

Build setup

Item Value
Board / config stm32f4discovery:nsh (Cortex-M4F, STM32F407, 1 MiB flash / 192 KiB SRAM)
Toolchain Arm GNU Toolchain 13.2.rel1 (arm-none-eabi-gcc 13.2.1 20231009)
Build system NuttX make (default flags from nsh defconfig)
Baseline apache/nuttx@2b8be4a3da1 (upstream/master) + apache/nuttx-apps@0105a9b2387
PR tip apache/nuttx@d0366cf98fa (4 commits) + apache/nuttx-apps@677d340a4ee (4 commits)
Both builds identical .config, same apps/ tree state, fresh make distclean

Top-line size delta

Output of arm-none-eabi-size -A nuttx:

Section master PR Δ bytes Δ %
.text 84 376 85 056 +680 +0.81 %
.ARM.exidx 8 8 0 0.00 %
.data 884 888 +4 +0.45 %
.bss 4 504 4 600 +96 +2.13 %
.comment 68 68 0 0.00 %
.ARM.attributes 44 44 0 0.00 %
.debug_frame 428 496 +68 +15.9 %
.debug_line_str 216 216 0 0.00 %
Total (sum) 90 528 91 376 +848 +0.94 %

Linker memory regions:

Region master used PR used Δ bytes Region % (master → PR)
flash (1 MiB) 85 268 85 952 +684 8.13 % → 8.20 %
sram (112 KiB) 5 400 5 496 +96 4.71 % → 4.79 %

Berkeley size:

   text    data     bss     dec     hex filename
  84384     884    4504   89772   15eac  master
  85064     888    4600   90552   161b8  PR

Code cleanup highlights

  • All #ifdef CONFIG_SYSTEM_TIME64 / CONFIG_HAVE_LONG_LONG /
    CONFIG_LIBC_LONG_LONG branches removed in headers, sched, fs, mm,
    net, libs/libc{,m}, drivers, and the arch RTC / oneshot / tickless
    lower-halves (cxd56xx, efm32, imxrt, lc823450, max326xx, sam34,
    sama5, samd5e5, samv7, stm32*, xmc4, pic32mz, bm3803, intel64,
    espressif esp32{,s2,s3,c3}_*, mpfs_perf).
  • sclock_t and SCLOCK_MAX references collapsed onto clock_t /
    CLOCK_MAX across sched/wdog, sched/mqueue, sched/sched,
    sched/clock, sched/timer, libs/libc/time, fs/vfs and drivers.
  • Tick/period constants (NSEC_PER_SEC, USEC_PER_SEC,
    MSEC_PER_SEC, ...) retyped to INT64_C(...) so 64-bit math no
    longer depends on host long width.
  • Now-redundant (time_t) / (clock_t) / (unsigned long) casts
    and unsigned-only fast paths removed.
  • printf format strings that assumed an unsigned 64-bit tv_sec
    flipped to signed (PRIu64PRId64) in drivers/rpmsg/rpmsg_ping.c
    and arch/xtensa/src/esp32{,s2,s3}/esp32*_oneshot_lowerhalf.c.
  • Soft b32/ub32 fixed-math helpers (-261 lines) and the llround*
    empty stubs gone now that long long is required.
  • mld_mrc2mrd helper deleted in net/mld/mld_query.c (signed math
    handles the conversion directly).

wd_start signed-delay guard

With clock_t now signed, a negative delay is no longer caught by
the existing delay <= WDOG_MAX_DELAY test (WDOG_MAX_DELAY is
INT64_MAX >> 2). The inline wrappers in include/nuttx/wdog.h
have been adjusted accordingly:

/* wd_start */
-  if (delay <= WDOG_MAX_DELAY)
+  if (delay >= 0 && delay <= WDOG_MAX_DELAY)

/* wd_start_next */
-  if (delay > WDOG_MAX_DELAY)
+  if (delay < 0 || delay > WDOG_MAX_DELAY)

This is what ostest exercises (see logs below) and what surfaced
the regression on first run.

Testing

  • tools/checkpatch.sh -f clean on every changed C/H file in this PR.
  • sim:nsh (Linux x86_64): build OK, ostest passes.
  • rv-virt:nsh64 (qemu-system-riscv64): build OK, ostest passes.

sim:nsh — ostest summary

$ ./tools/configure.sh sim:nsh
$ make -j$(nproc)
$ ./nuttx
NuttShell (NSH) NuttX-...
nsh> ostest
...
user_main: nxevent test
...
ostest_main: Exiting with status 0
nsh> poweroff

Full log: 1030 lines, all sub-tests reach Exiting with status 0.

rv-virt:nsh64 — ostest summary

$ ./tools/configure.sh rv-virt:nsh64
$ make -j$(nproc)
$ qemu-system-riscv64 -semihosting -M virt,aclint=on -cpu rv64 \
      -smp 8 -bios none -kernel nuttx -nographic
NuttShell (NSH) NuttX-...
nsh> ostest
...
user_main: vfork() test
vfork_test: Child 79 ran successfully
...
ostest_main: Exiting with status 0
nsh> poweroff

Full log: 958 lines, all sub-tests reach Exiting with status 0.

The first iteration of this PR hit a wd_start DEBUGASSERT in
ostest once clock_t became signed; that crash is what motivated
the wd_start / wd_start_next guard fix above. With the fix
applied, both targets run ostest end-to-end without assertion.

Related apps PR

apache/nuttx-apps#3468 — drops the matching
CONFIG_SYSTEM_TIME64 / CONFIG_HAVE_LONG_LONG / CONFIG_LIBC_LONG_LONG
ifdefs and sclock_t references on the apps side.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the CONFIG_SYSTEM_TIME64 switch and standardizes NuttX on 64-bit system time types across the kernel, headers, and selected user-visible interfaces. It mainly simplifies conditional time-width handling and cleans up board configurations that were explicitly enabling the now-default behavior.

Changes:

  • Remove the CONFIG_SYSTEM_TIME64 Kconfig option and related guards/dependencies.
  • Make time-related typedefs/constants/header paths unconditionally use 64-bit variants.
  • Delete obsolete CONFIG_SYSTEM_TIME64=y entries from affected board defconfigs and refresh related comments/docs.

Reviewed changes

Copilot reviewed 111 out of 111 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sched/clock/clock.h Removes obsolete local CONFIG_SYSTEM_TIME64 handling comment/block.
sched/Kconfig Deletes the Kconfig option and removes dependencies tied to it.
libs/libc/wqueue/work_usrthread.c Simplifies work-delay max constant to unconditional 64-bit.
include/sys/types.h Makes clock_t and time_t always 64-bit.
include/nuttx/fs/hostfs.h Makes hostfs nuttx_time_t always 64-bit.
include/nuttx/clock.h Removes conditional time-width logic and simplifies sclock_t/debug guard.
include/limits.h Makes CLOCK_MAX unconditionally 64-bit.
include/inttypes.h Removes conditional time_t format/scan macro section.
fs/procfs/fs_procfsuptime.c Simplifies uptime formatting to unconditional 64-bit seconds handling.
drivers/rpmsg/rpmsg_ping.c Simplifies perf timestamp logging to unconditional 64-bit seconds formatting.
drivers/power/pm/pm_procfs.c Simplifies PM procfs format strings to unconditional 64-bit time output.
boards/xtensa/esp32s3/esp32s3-devkit/configs/python/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/ostest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/nsh_pci_smp/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/nsh_pci/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/lvgl/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/knsh_romfs_pci/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/knsh_romfs/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/jumbo/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/fb/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/x86_64/qemu/qemu-intel64/configs/earlyfb/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/tricore/tc4da/triboard_tc4x9_com/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/tricore/tc397/a2g-tc397-5v-tft/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/sim/sim/sim/configs/windows64/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/sim/sim/sim/configs/windows/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/sim/sim/sim/configs/tcpblaster/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/sim/sim/sim/configs/rtptools/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/sim/sim/sim/configs/ostest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/sim/sim/sim/configs/matter/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/qemu-rv/rv-virt/configs/citest64/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/icicle/configs/rpmsg-sbi/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/icicle/configs/rpmsg-ch2/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/icicle/configs/rpmsg-ch1/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/icicle/configs/pnsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/icicle/configs/opensbi/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/icicle/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/icicle/configs/knsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/mpfs/icicle/configs/hwtest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/litex/arty_a7/configs/knsh-tickless/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/risc-v/c906/smartl-c906/configs/sotest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/zynq-mpsoc/zcu111/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/zynq-mpsoc/zcu111/configs/netnsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/zynq-mpsoc/zcu111/configs/netjtag/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/zynq-mpsoc/zcu111/configs/jtag/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/rk3399/pinephonepro/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/rk3399/nanopi_m4/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/xedge_demo/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/sw_tags/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/sotest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/rpserver/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/rpproxy/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/nsh_smp_tickless/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/nsh_smp/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/nsh_gicv2/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/nsh_fiq/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/netnsh_smp_hv/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/netnsh_smp/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/netnsh_hv/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/netnsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/mte/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/knsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/gdbstub/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/fb/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/fastboot/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/citest_smp/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/qemu/qemu-armv8a/configs/citest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/imx9/imx95-a55-evk/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/imx9/imx95-a55-evk/configs/emmc/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/imx9/imx93-evk/configs/optee/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/imx9/imx93-evk/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/imx9/imx93-evk/configs/koptee/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/imx9/imx93-evk/configs/knsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/imx9/imx93-evk/configs/bootloader/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/imx8/imx8qm-mek/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/fvp-v8r/fvp-armv8r/configs/pnsh_smp/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/fvp-v8r/fvp-armv8r/configs/pnsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/fvp-v8r/fvp-armv8r/configs/nsh_smp/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/fvp-v8r/fvp-armv8r/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/fvp-v8r/fvp-armv8r/configs/citest_smp/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/fvp-v8r/fvp-armv8r/configs/citest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/bcm2711/raspberrypi-4b/configs/sd/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/bcm2711/raspberrypi-4b/configs/ostest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/bcm2711/raspberrypi-4b/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/bcm2711/raspberrypi-4b/configs/lvgl/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/bcm2711/raspberrypi-4b/configs/fb/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/bcm2711/raspberrypi-4b/configs/coremark/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/bcm2711/raspberrypi-4b/configs/cgol/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/a64/pinephone/configs/sensor/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/a64/pinephone/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/a64/pinephone/configs/lvgl/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/a64/pinephone/configs/lcd/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm64/a527/avaota-a1/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/stm32/stm32f4discovery/configs/canard/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/stm32/olimexino-stm32/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/stm32/olimexino-stm32/configs/composite/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/stm32/olimexino-stm32/configs/can/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/stm32/nucleo-f302r8/configs/can/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/lc823450/lc823450-xgevk/configs/usb/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/lc823450/lc823450-xgevk/configs/rndis/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/lc823450/lc823450-xgevk/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/lc823450/lc823450-xgevk/configs/krndis/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/lc823450/lc823450-xgevk/configs/kostest/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/lc823450/lc823450-xgevk/configs/knsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/lc823450/lc823450-xgevk/configs/bt/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/lc823450/lc823450-xgevk/configs/audio/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
boards/arm/fvp-v8r-aarch32/fvp-armv8r-aarch32/configs/nsh/defconfig Drops obsolete CONFIG_SYSTEM_TIME64=y.
arch/avr/src/avrdx/avrdx_timerisr_tickless_alarm.c Updates a stale type comment to reflect fixed 64-bit time_t.
Documentation/guides/rust.rst Removes outdated Rust guide mention of CONFIG_SYSTEM_TIME64.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drivers/rpmsg/rpmsg_ping.c Outdated
Comment thread include/nuttx/clock.h
Comment thread include/inttypes.h
Comment thread fs/procfs/fs_procfsuptime.c
Comment thread drivers/power/pm/pm_procfs.c
@lupyuen
Copy link
Copy Markdown
Member

lupyuen commented May 3, 2026

@xiaoxiang781216 FYI: GitHub Copilot code review will start consuming GitHub Actions minutes on June 1, 2026. Please be careful :-)

@github-actions github-actions Bot added Arch: arm Issues related to ARM (32-bit) architecture Arch: mips Issues related to the MIPS architecture Arch: sparc Issues related to the SPARC architecture Arch: x86_64 Issues related to the x86_64 architecture Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces. and removed Size: L The size of the change in this PR is large labels May 3, 2026
@xiaoxiang781216 xiaoxiang781216 force-pushed the sched/remove-system-time64 branch from dbc8713 to 4a9ec96 Compare May 3, 2026 15:12
@cederom
Copy link
Copy Markdown
Contributor

cederom commented May 3, 2026

Thank you @xiaoxiang781216, I am for this change, please lets mark it with ! in the PR title and git commits so it attracts attention when reading logs, also we should announce this on mailing list, I remember we had this discussion before and this may be good time for this change :-)

@xiaoxiang781216
Copy link
Copy Markdown
Contributor Author

xiaoxiang781216 commented May 3, 2026

@xiaoxiang781216 this kind of broad change needs to be discussed before in the mailing list because it affect all architectures. Just to highlight some concerning points:

already discuss before in email thread: #14460

  1. This kind of modification cannot be merged without been tested in all architectures, "tools/checkpatch.sh -f" is not a valid testing;

add the test and log

  1. Increasing the system time to 64-bit could have size impact, please provide this value for small boards (like AVR8 or a STM32 chip with few KB of RAM like, stm32vldiscovery is a good candidate)

see the size change in Impact section

  1. Instead removing it, better to enable it by default, except for DEFAULT_SMALL

64bit time_t is required by POSIX spec, it can't be an option anymore.

Every compiler supported by NuttX provides the "long long" types,
so the CONFIG_HAVE_LONG_LONG indirection is no longer useful.
Remove the option from include/nuttx/compiler.h and treat
"long long" as unconditionally available across the OS.

In addition to deleting the guard itself, this commit unconditionally
enables the long-long flavored helpers that used to be gated behind
it:

  - libs/libc/fixedmath: drop the soft-emulated b32/ub32 routines
    in lib_fixedmath.c (-261 lines) and trim the matching
    prototypes, Make.defs and CMakeLists.txt entries; keep only
    the long-long backed implementations.
  - include/sys/endian.h, include/strings.h, libs/libc/string
    /lib_ffsll.c, lib_flsll.c: always expose the 64-bit byte-swap
    and ffsll/flsll variants.
  - libs/libm/libm/lib_llround{,f,l}.c: drop the empty stubs.
  - libs/libc/stdlib (atoll, llabs, lldiv, strtoll/ull, rand48,
    strtold), libs/libc/stream (libvsprintf, libvscanf,
    libbsprintf, ultoa_invert), libs/libc/misc (crc64, crc64emac),
    libs/libc/inttypes/strtoimax, libs/libc/lzf, libs/libc/libc.csv,
    libs/libc/string (memset, vikmemcpy): remove the
    #ifdef CONFIG_HAVE_LONG_LONG branches.
  - include/{stddef.h,stdlib.h,fixedmath.h,sys/epoll.h,cxx/cstdlib,
    nuttx/audio/audio.h,nuttx/crc64.h,nuttx/lib/math.h,
    nuttx/lib/math32.h,nuttx/lib/stdbit.h}: same guard cleanup.
  - drivers/note/note_driver.c, fs/spiffs/src/spiffs.h,
    sched/irq/irq_procfs.c: drop their local guards as well.
  - Documentation/applications/netutils/ntpclient/index.rst:
    refresh the documentation snippet.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Long long support is now unconditional in printf/scanf and related
helpers. Remove the Kconfig option, the conditional compilation in
libvsprintf/libvscanf/ultoa_invert, the build-time #error in the
rn2xx3 driver, and clean up CONFIG_LIBC_LONG_LONG entries from all
board defconfigs.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
The 32-bit system clock has a limited range (~497 days) and the
configuration knob is no longer worth the complexity given that
practically every modern target already enables it.  Make 64-bit
time_t/clock_t/sclock_t/nuttx_time_t the only supported flavor.

Specifically:
  - Drop the SYSTEM_TIME64 Kconfig option and its dependent
    PERF_OVERFLOW_CORRECTION/HRTIMER guards in sched/Kconfig.
  - Remove every #ifdef CONFIG_SYSTEM_TIME64 branch in headers
    (include/{sys/types.h,limits.h,inttypes.h,nuttx/clock.h,
    nuttx/fs/hostfs.h}) and core code paths
    (sched/clock/clock.h, drivers/power/pm/pm_procfs.c,
    drivers/rpmsg/rpmsg_ping.c, fs/procfs/fs_procfsuptime.c,
    libs/libc/wqueue/work_usrthread.c,
    arch/avr/src/avrdx/avrdx_timerisr_tickless_alarm.c).
  - Strip CONFIG_SYSTEM_TIME64=y from every board defconfig.
  - Update Documentation/guides/rust.rst accordingly.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 force-pushed the sched/remove-system-time64 branch from 4a9ec96 to 0af5eef Compare May 3, 2026 15:48
@xiaoxiang781216 xiaoxiang781216 changed the title sched/clock: drop CONFIG_SYSTEM_TIME64 / CONFIG_HAVE_LONG_LONG / CONFIG_LIBC_LONG_LONG and sclock_t !sched/clock: drop CONFIG_SYSTEM_TIME64 / CONFIG_HAVE_LONG_LONG / CONFIG_LIBC_LONG_LONG and sclock_t May 3, 2026
@xiaoxiang781216 xiaoxiang781216 added the breaking change This change requires a mitigation entry in the release notes. label May 3, 2026
@github-actions github-actions Bot removed the breaking change This change requires a mitigation entry in the release notes. label May 3, 2026
@xiaoxiang781216
Copy link
Copy Markdown
Contributor Author

Thank you @xiaoxiang781216, I am for this change, please lets mark it with ! in the PR title and git commits so it attracts attention when reading logs, also we should announce this on mailing list, I remember we had this discussion before and this may be good time for this change :-)

Done.

@xiaoxiang781216 xiaoxiang781216 force-pushed the sched/remove-system-time64 branch from 0af5eef to d0366cf Compare May 3, 2026 16:02
…r OSes

POSIX leaves the signedness of time_t and clock_t unspecified, but
mainstream implementations (Linux glibc/musl, the BSDs, macOS, RTEMS,
Zephyr's POSIX layer, Windows _time64) expose time_t as signed 64-bit.
NuttX has historically used uint64_t only because it was tied to the
CONFIG_SYSTEM_TIME64 knob; with that gone, switch:

  time_t   : uint64_t  -> int64_t
  clock_t  : uint64_t  -> int64_t
  CLOCK_MAX: UINT64_MAX -> INT64_MAX

This lets (time_t)-1 sentinels, negative tick deltas, and host-side
headers behave as on every other POSIX system without source churn.

Headers updated:
  - include/sys/types.h, include/limits.h, include/nuttx/clock.h
  - include/nuttx/fs/hostfs.h (nuttx_time_t alias)
  - include/nuttx/{mqueue.h,wdog.h,wqueue.h,timers/clkcnt.h}

Because clock_t is now signed 64-bit, the NuttX-internal sclock_t
alias becomes redundant: every sclock_t/SCLOCK_MAX use is folded
back to clock_t/CLOCK_MAX (notably in sched/wdog, sched/mqueue,
sched/sched, sched/clock, sched/timer, libs/libc/time, fs/vfs and
the drivers/arch consumers below).

Tick/period constants (NSEC_PER_SEC, USEC_PER_SEC, MSEC_PER_SEC,
SEC_PER_MIN, ...) in include/nuttx/clock.h are retyped from "long"
literals to INT64_C(...) so that 64-bit arithmetic no longer
depends on the host's long width.

Strip now-redundant (time_t)/(clock_t)/(unsigned long) casts and
unsigned-only branches across the tree:
  - arch RTC / oneshot / tickless lowerhalfs:
      arm: cxd56xx, efm32, imxrt, lc823450, max326xx, sam34, sama5,
           samd5e5, samv7, stm32, stm32f7, stm32h7, stm32l4, stm32wb,
           xmc4
      mips: pic32mz       sparc: bm3803       x86_64: intel64
      risc-v/xtensa: espressif (esp_i2c[_slave], esp_rtc,
           esp32c3{_i2c,_rtc,_wifi_adapter}, esp32{,s2,s3}_*),
           mpfs_perf
  - drivers: audio/tone, input/aw86225, power/pm/{activity,
           stability}_governor, rpmsg/rpmsg_ping,
           timers/{ds3231,mcp794xx,pcf85263,rx8010},
           wireless/ieee80211/bcm43xxx, wireless/spirit/spirit_spi
  - core: fs/vfs/{fs_poll,fs_timerfd}, mm/iob/iob_alloc,
          libs/libc/{netdb/lib_dnscache,time/{lib_calendar2utc,
          lib_time}}, net/icmp/icmp_pmtu, net/icmpv6/icmpv6_pmtu,
          net/ipfrag, net/tcp/{tcp.h,tcp_timer},
          net/utils/net_snoop, net/mld/mld_query (drop the now-dead
          mld_mrc2mrd helper since signed math handles it directly),
          sched/clock/{clock,clock_initialize},
          sched/sched/{sched_profil,sched_setparam,sched_setscheduler},
          sched/pthread/pthread_create,
          sched/wdog/{wd_gettime,wd_start,wdog.h},
          sched/timer/timer_gettime, sched/mqueue/*

Flip the few in-tree printf format strings that assumed an
unsigned 64-bit tv_sec:
  * drivers/rpmsg/rpmsg_ping.c                       PRIu64 -> PRId64
  * arch/xtensa/src/esp32{,s2,s3}/esp32*_oneshot_lowerhalf.c
                                          PRIu32 (already wrong) -> PRId64

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 force-pushed the sched/remove-system-time64 branch from d0366cf to 55e3c3d Compare May 3, 2026 16:45
D:/a/nuttx/nuttx/sources/nuttx/arch/risc-v/src/common/espressif/esp_libc_stubs.c:131:9: error: conflicting types for '_times_r'; have 'clock_t(struct _reent *, struct tms *)' {aka 'long long int(struct _reent *, struct tms *)'}
  131 | clock_t _times_r(struct _reent *r, struct tms *buf)
      |         ^~~~~~~~
In file included from D:/a/nuttx/nuttx/sources/nuttx/build/arch/risc-v/src/common/espressif/esp-hal-3rdparty/components/esp_rom/esp32c3/include/esp32c3/rom/libc_stubs.h:15,
                 from D:/a/nuttx/nuttx/sources/nuttx/arch/risc-v/src/common/espressif/esp_libc_stubs.c:44:
D:/a/nuttx/nuttx/sources/tools/riscv-none-elf-gcc/riscv-none-elf/include/reent.h:156:18: note: previous declaration of '_times_r' with type 'long unsigned int(struct _reent *, struct tms *)'
  156 | extern _CLOCK_T_ _times_r (struct _reent *, struct tms *);
      |                  ^~~~~~~~

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@cederom
Copy link
Copy Markdown
Contributor

cederom commented May 4, 2026

@xiaoxiang781216 what is the impact on 32-bit platforms (i.e. ARM, Xtensa)?

Are there any risk related with non-atomic access that may cause issues in projects like PX4-Autopilot after upgrade to NuttX >12.13.0 (PX4/PX4-Autopilot#26215)?

@cederom
Copy link
Copy Markdown
Contributor

cederom commented May 4, 2026

Okay, #18849 is the Issue marked with 13.0.0 milestone that states this implementation will be default while we need to work out portable implementation for the smaller 8/16/32-bit architectures :-)

@cederom
Copy link
Copy Markdown
Contributor

cederom commented May 4, 2026

There are CI build errors reported, please review @xiaoxiang781216, thanks :-)

@acassis acassis dismissed their stale review May 4, 2026 16:15

Let merge it and later find some optimization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm Issues related to ARM (32-bit) architecture Arch: avr Issues related to all AVR(8-bit or 32-bit) architectures Arch: mips Issues related to the MIPS architecture Arch: risc-v Issues related to the RISC-V (32-bit or 64-bit) architecture Arch: sparc Issues related to the SPARC architecture Arch: x86_64 Issues related to the x86_64 architecture Arch: xtensa Issues related to the Xtensa architecture Area: Audio Board: arm Board: arm64 Board: risc-v Board: simulator Board: sparc Board: tricore Board: x86_64 Board: xtensa Size: XL The size of the change in this PR is very large. Consider breaking down the PR into smaller pieces.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIGNED time_t

7 participants