!sched/clock: drop CONFIG_SYSTEM_TIME64 / CONFIG_HAVE_LONG_LONG / CONFIG_LIBC_LONG_LONG and sclock_t#18840
Conversation
There was a problem hiding this comment.
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_TIME64Kconfig option and related guards/dependencies. - Make time-related typedefs/constants/header paths unconditionally use 64-bit variants.
- Delete obsolete
CONFIG_SYSTEM_TIME64=yentries 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.
|
@xiaoxiang781216 FYI: GitHub Copilot code review will start consuming GitHub Actions minutes on June 1, 2026. Please be careful :-) |
dbc8713 to
4a9ec96
Compare
|
Thank you @xiaoxiang781216, I am for this change, please lets mark it with |
already discuss before in email thread: #14460
add the test and log
see the size change in Impact section
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>
4a9ec96 to
0af5eef
Compare
Done. |
0af5eef to
d0366cf
Compare
…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>
d0366cf to
55e3c3d
Compare
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>
|
@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)? |
|
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 :-) |
|
There are CI build errors reported, please review @xiaoxiang781216, thanks :-) |
Let merge it and later find some optimization.
Summary
note:
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:
CONFIG_SYSTEM_TIME64– always on; the 32-bit system clock wrappedin ~497 days and almost every active board already enabled it.
CONFIG_HAVE_LONG_LONG– every supported toolchain provideslong long; the indirection only obscured the libc/libm code.CONFIG_LIBC_LONG_LONG– follow-up to the above;printf("%lld")and friends are now unconditional.
While there, retype
time_t/clock_tfromuint64_ttoint64_ttomatch POSIX practice on Linux/glibc, the BSDs, macOS, RTEMS, Zephyr
and Windows
_time64. This lets(time_t)-1sentinels and signedtick deltas work without source churn, and folds the now-redundant
sclock_talias back toclock_t.Commits in this PR
Impact
Behavior
time_t:uint64_t→int64_tclock_t:uint64_t→int64_tsclock_t: removed (alias ofclock_t)nuttx_time_t(hostfs ABI): always 64-bit signedCLOCK_MAX/SCLOCK_MAX:UINT64_MAX→INT64_MAXPRI*TM/SCN*TM: removed (usePRId64/SCNd64)long longprintf/scanf conversions are always availableRemoved Kconfig options
CONFIG_SYSTEM_TIME64CONFIG_HAVE_LONG_LONGCONFIG_LIBC_LONG_LONGdepends on SYSTEM_TIME64inPERF_OVERFLOW_CORRECTION/HRTIMERAll
=y/ "is not set" lines stripped from board defconfigs (sed pass).Build setup
stm32f4discovery:nsh(Cortex-M4F, STM32F407, 1 MiB flash / 192 KiB SRAM)arm-none-eabi-gcc 13.2.1 20231009)make(default flags fromnshdefconfig)apache/nuttx@2b8be4a3da1(upstream/master) +apache/nuttx-apps@0105a9b2387apache/nuttx@d0366cf98fa(4 commits) +apache/nuttx-apps@677d340a4ee(4 commits).config, sameapps/tree state, freshmake distcleanTop-line size delta
Output of
arm-none-eabi-size -A nuttx:.text.ARM.exidx.data.bss.comment.ARM.attributes.debug_frame.debug_line_strLinker memory regions:
flash(1 MiB)sram(112 KiB)Berkeley
size:Code cleanup highlights
#ifdef CONFIG_SYSTEM_TIME64/CONFIG_HAVE_LONG_LONG/CONFIG_LIBC_LONG_LONGbranches 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_tandSCLOCK_MAXreferences collapsed ontoclock_t/CLOCK_MAXacross sched/wdog, sched/mqueue, sched/sched,sched/clock, sched/timer, libs/libc/time, fs/vfs and drivers.
NSEC_PER_SEC,USEC_PER_SEC,MSEC_PER_SEC, ...) retyped toINT64_C(...)so 64-bit math nolonger depends on host
longwidth.(time_t)/(clock_t)/(unsigned long)castsand unsigned-only fast paths removed.
tv_secflipped to signed (
PRIu64→PRId64) indrivers/rpmsg/rpmsg_ping.cand
arch/xtensa/src/esp32{,s2,s3}/esp32*_oneshot_lowerhalf.c.llround*empty stubs gone now that
long longis required.mld_mrc2mrdhelper deleted innet/mld/mld_query.c(signed mathhandles the conversion directly).
wd_startsigned-delay guardWith
clock_tnow signed, a negativedelayis no longer caught bythe existing
delay <= WDOG_MAX_DELAYtest (WDOG_MAX_DELAYisINT64_MAX >> 2). The inline wrappers ininclude/nuttx/wdog.hhave been adjusted accordingly:
This is what
ostestexercises (see logs below) and what surfacedthe regression on first run.
Testing
tools/checkpatch.sh -fclean on every changed C/H file in this PR.sim:nsh(Linux x86_64): build OK,ostestpasses.rv-virt:nsh64(qemu-system-riscv64): build OK,ostestpasses.sim:nsh —
ostestsummaryFull log: 1030 lines, all sub-tests reach
Exiting with status 0.rv-virt:nsh64 —
ostestsummaryFull log: 958 lines, all sub-tests reach
Exiting with status 0.The first iteration of this PR hit a
wd_startDEBUGASSERTinostestonceclock_tbecame signed; that crash is what motivatedthe
wd_start/wd_start_nextguard fix above. With the fixapplied, both targets run
ostestend-to-end without assertion.Related apps PR
apache/nuttx-apps#3468 — drops the matching
CONFIG_SYSTEM_TIME64/CONFIG_HAVE_LONG_LONG/CONFIG_LIBC_LONG_LONGifdefs and
sclock_treferences on the apps side.