nuttx/include/sys
dongjiuzhu1 3c486b98dd fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes
Implement Linux-compatible TFD_TIMER_CANCEL_ON_SET flag for timerfd to
allow applications to detect discontinuous changes to CLOCK_REALTIME.

Background:
According to Linux timerfd_create(2) man page, when a timerfd is created
with CLOCK_REALTIME and TFD_TIMER_CANCEL_ON_SET flag is specified, the
read() operation should fail with ECANCELED if the real-time clock
undergoes a discontinuous change. This allows applications to detect
and respond to system time changes.

Implementation:
1. Add clock notifier infrastructure (clock_notifier.h/c) to notify
   interested parties when system time changes
2. Implement TFD_TIMER_CANCEL_ON_SET flag support in timerfd
3. Register timerfd with clock notifier when flag is set
4. Cancel timer and return ECANCELED when clock change is detected
5. Notify clock changes in:
   - clock_settime()
   - clock_initialize()
   - clock_timekeeping_set_wall_time()
   - rpmsg_rtc time synchronization

Changes include:
- New files: include/nuttx/clock_notifier.h, sched/clock/clock_notifier.c
- Modified: fs/vfs/fs_timerfd.c to handle TFD_TIMER_CANCEL_ON_SET
- Modified: clock subsystem to call notifier chain on time changes
- Modified: rpmsg_rtc to notify time changes during sync

Use case example:
Applications using timerfd with absolute time can now detect when
system time is adjusted (e.g., NTP sync, manual time change) and
take appropriate action such as recalculating timeouts or updating
scheduled events.

Reference: https://man7.org/linux/man-pages/man2/timerfd_create.2.html

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2026-01-30 17:20:24 +08:00
..
boardctl.h boards/boardctl: Add BOARDIOC_MACADDR command 2026-01-22 22:13:31 +08:00
custom_file.h
endian.h
epoll.h
eventfd.h
fcntl.h fcntl: add sys/fcntl.h header file 2024-12-20 11:46:14 -03:00
file.h
gmon.h
inotify.h
ioctl.h sys/ioctl: extend the IOCTL defintion that compatible with linux kernel 2026-01-14 09:39:51 +08:00
ipc.h
mman.h
mount.h drivers/fs: Control the behavior of FTL by passing oflags during the open process. 2025-07-16 14:11:41 +08:00
msg.h
param.h arm: systick: fix off-by-one in SysTick RELOAD programming 2026-01-26 19:34:00 +08:00
pciio.h
poll.h fs/poll: remove poll_fdsetup 2025-05-26 18:49:45 +08:00
prctl.h
queue.h
random.h
resource.h sys/resouce: add RLIM_NLIMITS definition 2026-01-15 16:08:23 -03:00
select.h
sem.h sem: add sys/sem.h header file 2024-12-20 11:46:14 -03:00
sendfile.h
shm.h
signal.h signal: add include/sys/signal.h to the signal 2024-12-20 11:46:14 -03:00
signalfd.h
socket.h net: make the sendmsg param type consistent with posix specification 2026-01-16 21:11:39 +08:00
sockio.h
stat.h
statfs.h
statvfs.h
syscall.h
syscall_lookup.h syscall: add sched_note_event_ip syscall for instrumentation dump 2026-01-28 02:06:23 +08:00
sysinfo.h
sysmacros.h
time.h syscall/adjtime: fix minior issue about adjtime and add clock_adjtime to syscall 2025-12-30 10:22:09 -03:00
timerfd.h fs/timerfd: implement TFD_TIMER_CANCEL_ON_SET to detect clock changes 2026-01-30 17:20:24 +08:00
times.h
timex.h sched/clock: support using CLOCKFD to call clock_adjtime 2025-12-30 10:22:09 -03:00
tree.h
types.h sys/types.h: Fixed the conflict issue with the "OK" constant definition 2026-01-16 16:16:21 +08:00
uio.h
un.h
utsname.h
vfs.h
video_controls.h
videoio.h style: fix spelling in code comments and strings 2025-05-23 10:48:41 +08:00
wait.h sys/wait: add WCOREDUMP defintion 2026-01-15 23:16:27 +08:00