From 6bcd83eb04ec5058318e7046ae4dac59e5d9fa51 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Wed, 13 Oct 2021 12:29:19 +0800 Subject: [PATCH] time:follow POSIX use long to define time_t MIRTOS-883 https: //man7.org/linux/man-pages/man3/clock_settime.3.html Signed-off-by: anjiahao Change-Id: If573ad33b1ff61d5549e476b191309d4d4024801 --- include/time.h | 2 +- sched/clock/clock_settime.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/time.h b/include/time.h index 5952f1b69da..bf5d0c1be7a 100644 --- a/include/time.h +++ b/include/time.h @@ -102,7 +102,7 @@ /* Scalar types */ -typedef uint32_t time_t; /* Holds time in seconds */ +typedef long time_t; /* Holds time in seconds */ typedef uint8_t clockid_t; /* Identifies one time base source */ typedef FAR void *timer_t; /* Represents one POSIX timer */ diff --git a/sched/clock/clock_settime.c b/sched/clock/clock_settime.c index 6eb8233a8ad..b0f8de9a1b5 100644 --- a/sched/clock/clock_settime.c +++ b/sched/clock/clock_settime.c @@ -65,7 +65,8 @@ int clock_settime(clockid_t clock_id, FAR const struct timespec *tp) */ if (clock_id == CLOCK_REALTIME && - tp->tv_nsec >= 0 && tp->tv_nsec < 1000000000) + tp->tv_nsec >= 0 && tp->tv_nsec < 1000000000 && + tp->tv_sec >= 0) { #ifndef CONFIG_CLOCK_TIMEKEEPING /* Interrupts are disabled here so that the in-memory time