diff --git a/Documentation/guides/pysimcoder.rst b/Documentation/guides/pysimcoder.rst index c227fb3777..463c86f46a 100644 --- a/Documentation/guides/pysimcoder.rst +++ b/Documentation/guides/pysimcoder.rst @@ -49,19 +49,18 @@ with NuttX. The list is the following: ``CONFIG_BOARDCTL_APP_SYMTAB=y`` ``CONFIG_NSH_LINELEN=64`` ``CONFIG_BOARDCTL_OS_SYMTAB=y`` ``CONFIG_NSH_READLINE=y`` ``CONFIG_BUILTIN=y`` ``CONFIG_NSH_ROMFSETC=y`` -``CONFIG_CLOCK_MONOTONIC=y`` ``CONFIG_PSEUDOTERM=y`` -``CONFIG_ELF=y`` ``CONFIG_PTHREAD_CLEANUP=y`` -``CONFIG_FS_BINFS=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y`` +``CONFIG_ELF=y`` ``CONFIG_PSEUDOTERM=y`` +``CONFIG_FS_BINFS=y`` ``CONFIG_PTHREAD_CLEANUP=y`` ``CONFIG_FS_PROCFS=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y`` -``CONFIG_FS_PROCFS_REGISTER=y`` ``CONFIG_PTHREAD_STACK_MIN=1024`` -``CONFIG_FS_ROMFS=y`` ``CONFIG_RR_INTERVAL=10`` -``CONFIG_FS_TMPFS=y`` ``CONFIG_SCHED_WAITPID=y`` -``CONFIG_IDLETHREAD_STACKSIZE=2048`` ``CONFIG_SERIAL_TERMIOS=y`` -``CONFIG_LIBC_EXECFUNCS=y`` ``CONFIG_SYMTAB_ORDEREDBYNAME=y`` -``CONFIG_LIBC_STRERROR=y`` ``CONFIG_SYSTEM_NSH=y`` -``CONFIG_MAX_TASKS=16`` ``CONFIG_SYSTEM_NSH_STACKSIZE=4096`` -``CONFIG_NSH_BUILTIN_APPS=y`` ``CONFIG_INIT_ENTRYPOINT="nsh_main"`` -``CONFIG_NSH_FILEIOSIZE=512`` +``CONFIG_FS_PROCFS_REGISTER=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y`` +``CONFIG_FS_ROMFS=y`` ``CONFIG_PTHREAD_STACK_MIN=1024`` +``CONFIG_FS_TMPFS=y`` ``CONFIG_RR_INTERVAL=10`` +``CONFIG_IDLETHREAD_STACKSIZE=2048`` ``CONFIG_SCHED_WAITPID=y`` +``CONFIG_LIBC_EXECFUNCS=y`` ``CONFIG_SERIAL_TERMIOS=y`` +``CONFIG_LIBC_STRERROR=y`` ``CONFIG_SYMTAB_ORDEREDBYNAME=y`` +``CONFIG_MAX_TASKS=16`` ``CONFIG_SYSTEM_NSH=y`` +``CONFIG_NSH_BUILTIN_APPS=y`` ``CONFIG_SYSTEM_NSH_STACKSIZE=4096`` +``CONFIG_NSH_FILEIOSIZE=512`` ``CONFIG_INIT_ENTRYPOINT="nsh_main"`` ==================================== ===================================== In case you want to use Network and blocks like TCP or UDP, following configuration diff --git a/arch/arm/src/lc823450/lc823450_dvfs2.c b/arch/arm/src/lc823450/lc823450_dvfs2.c index 3b2e3bdeb1..9a3f71e79c 100644 --- a/arch/arm/src/lc823450/lc823450_dvfs2.c +++ b/arch/arm/src/lc823450/lc823450_dvfs2.c @@ -127,11 +127,7 @@ static uint64_t _get_current_time64(void) { struct timespec ts; -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif return (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec; } diff --git a/arch/arm/src/lc823450/lc823450_rtc.c b/arch/arm/src/lc823450/lc823450_rtc.c index b5a4952b3b..82431f2570 100644 --- a/arch/arm/src/lc823450/lc823450_rtc.c +++ b/arch/arm/src/lc823450/lc823450_rtc.c @@ -147,10 +147,8 @@ static struct pm_callback_s pm_cb = static int cboot = 1; #endif /* CONFIG_RTC_DIV */ -#ifdef CONFIG_CLOCK_MONOTONIC static struct timespec lastupdate_mono; static struct timespec lastupdate_rtc; -#endif /**************************************************************************** * Public Data @@ -550,10 +548,8 @@ int up_rtc_settime(FAR const struct timespec *ts) up_rtc_set_default_datetime(tp); #endif /* CONFIG_RTC_SAVE_DEFAULT */ -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &lastupdate_mono); lastupdate_rtc = *ts; -#endif /* Start rtc update */ @@ -661,8 +657,6 @@ int up_rtc_cancelalarm(void) int up_rtc_getrawtime(FAR struct timespec *ts) { struct tm tm; - -#ifdef CONFIG_CLOCK_MONOTONIC struct timespec now; struct timespec diff; @@ -676,7 +670,6 @@ int up_rtc_getrawtime(FAR struct timespec *ts) *ts = lastupdate_rtc; return 0; } -#endif tm.tm_sec = getreg8(RTC_SEC); tm.tm_min = getreg8(RTC_MIN); diff --git a/arch/risc-v/src/esp32c3/esp32c3_i2c.c b/arch/risc-v/src/esp32c3/esp32c3_i2c.c index a43d08d2a0..84e954004d 100644 --- a/arch/risc-v/src/esp32c3/esp32c3_i2c.c +++ b/arch/risc-v/src/esp32c3/esp32c3_i2c.c @@ -851,11 +851,7 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv) * forward and backwards. */ - #ifdef CONFIG_CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, ¤t_time); - #else - clock_gettime(CLOCK_REALTIME, ¤t_time); - #endif + clock_gettime(CLOCK_MONOTONIC, ¤t_time); timeout.tv_sec = current_time.tv_sec + 10; timeout.tv_nsec = current_time.tv_nsec + 0; @@ -896,11 +892,7 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv) /* Update current time */ - #ifdef CONFIG_CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, ¤t_time); - #else - clock_gettime(CLOCK_REALTIME, ¤t_time); - #endif + clock_gettime(CLOCK_MONOTONIC, ¤t_time); current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec); } diff --git a/arch/xtensa/src/esp32/esp32_i2c.c b/arch/xtensa/src/esp32/esp32_i2c.c index e53f0582b4..2ccaea64fc 100644 --- a/arch/xtensa/src/esp32/esp32_i2c.c +++ b/arch/xtensa/src/esp32/esp32_i2c.c @@ -784,11 +784,7 @@ static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv) * forward and backwards. */ - #ifdef CONFIG_CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, ¤t_time); - #else - clock_gettime(CLOCK_REALTIME, ¤t_time); - #endif + clock_gettime(CLOCK_MONOTONIC, ¤t_time); timeout.tv_sec = current_time.tv_sec + 10; timeout.tv_nsec = current_time.tv_nsec + 0; @@ -829,11 +825,7 @@ static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv) /* Update current time */ - #ifdef CONFIG_CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, ¤t_time); - #else - clock_gettime(CLOCK_REALTIME, ¤t_time); - #endif + clock_gettime(CLOCK_MONOTONIC, ¤t_time); current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec); } diff --git a/drivers/sensors/bmp280.c b/drivers/sensors/bmp280.c index bb4400755d..e5373a3792 100644 --- a/drivers/sensors/bmp280.c +++ b/drivers/sensors/bmp280.c @@ -643,11 +643,7 @@ static int bmp280_fetch(FAR struct sensor_lowerhalf_s *lower, temp = bmp280_compensate_temp(priv, temp); press = bmp280_compensate_press(priv, press); -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif baro_data.timestamp = 1000000ull * ts.tv_sec + ts.tv_nsec / 1000; baro_data.pressure = press / 100.0f; diff --git a/drivers/sensors/ds18b20.c b/drivers/sensors/ds18b20.c index 40053d1fd9..a1ff3d7e8d 100644 --- a/drivers/sensors/ds18b20.c +++ b/drivers/sensors/ds18b20.c @@ -549,12 +549,8 @@ static int ds18b20_set_alarm(FAR struct ds18b20_dev_s *dev, static unsigned long ds18b20_curtime(void) { struct timespec ts; -#ifdef CONFIG_CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif + clock_gettime(CLOCK_MONOTONIC, &ts); return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000; } diff --git a/drivers/sensors/hyt271.c b/drivers/sensors/hyt271.c index 22033b2f69..ae9fa92048 100644 --- a/drivers/sensors/hyt271.c +++ b/drivers/sensors/hyt271.c @@ -187,12 +187,8 @@ static void hyt271_temp_from_rawdata(FAR struct hyt271_sensor_data_s *data, static unsigned long hyt271_curtime(void) { struct timespec ts; -#ifdef CONFIG_CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif + clock_gettime(CLOCK_MONOTONIC, &ts); return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000; } diff --git a/drivers/sensors/lis2dh.c b/drivers/sensors/lis2dh.c index 43471a10fb..211af19529 100644 --- a/drivers/sensors/lis2dh.c +++ b/drivers/sensors/lis2dh.c @@ -1667,11 +1667,7 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev) /* Prefer monotonic for timeout calculation when enabled. */ -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &start); -#else - clock_gettime(CLOCK_REALTIME, &start); -#endif /* Reboot to reset chip. */ @@ -1696,11 +1692,7 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev) break; } -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &curr); -#else - clock_gettime(CLOCK_REALTIME, &curr); -#endif diff_msec = (curr.tv_sec - start.tv_sec) * 1000; diff_msec += (curr.tv_nsec - start.tv_nsec) / (1000 * 1000); diff --git a/drivers/sensors/ms5611.c b/drivers/sensors/ms5611.c index e446e89e00..36f8f700f1 100644 --- a/drivers/sensors/ms5611.c +++ b/drivers/sensors/ms5611.c @@ -157,12 +157,8 @@ static const struct sensor_ops_s g_sensor_ops = static unsigned long ms5611_curtime(void) { struct timespec ts; -#ifdef CONFIG_CLOCK_MONOTONIC - clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif + clock_gettime(CLOCK_MONOTONIC, &ts); return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000; } diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index 050b9483a1..171966da9f 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -105,17 +105,12 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap) clock_gettime(CLOCK_REALTIME, &ts); -#elif defined(CONFIG_CLOCK_MONOTONIC) +#else /* Prefer monotonic when enabled, as it can be synchronized to * RTC with clock_resynchronize. */ clock_gettime(CLOCK_MONOTONIC, &ts); - -#else - /* Otherwise, fall back to the system timer */ - - clock_systime_timespec(&ts); #endif /* Prepend the message with the current time, if available */ diff --git a/fs/vfs/fs_epoll.c b/fs/vfs/fs_epoll.c index dcc2599bc2..e091e2504b 100644 --- a/fs/vfs/fs_epoll.c +++ b/fs/vfs/fs_epoll.c @@ -387,12 +387,7 @@ int epoll_pwait(int epfd, FAR struct epoll_event *evs, expire.tv_sec = timeout / 1000; expire.tv_nsec = timeout % 1000 * 1000; -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &curr); -#else - clock_gettime(CLOCK_REALTIME, &curr); -#endif - clock_timespec_add(&curr, &expire, &expire); } @@ -403,11 +398,7 @@ again: } else { -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &curr); -#else - clock_gettime(CLOCK_REALTIME, &curr); -#endif clock_timespec_subtract(&expire, &curr, &diff); rc = ppoll(eph->poll, eph->occupied + 1, &diff, sigmask); diff --git a/fs/vfs/fs_timerfd.c b/fs/vfs/fs_timerfd.c index 358a9743f9..ef1b50d4ed 100644 --- a/fs/vfs/fs_timerfd.c +++ b/fs/vfs/fs_timerfd.c @@ -540,12 +540,9 @@ int timerfd_create(int clockid, int flags) /* Sanity checks. */ - if (clockid != CLOCK_REALTIME -#ifdef CONFIG_CLOCK_MONOTONIC - && clockid != CLOCK_MONOTONIC - && clockid != CLOCK_BOOTTIME -#endif /* CONFIG_CLOCK_MONOTONIC */ - ) + if (clockid != CLOCK_REALTIME && + clockid != CLOCK_MONOTONIC && + clockid != CLOCK_BOOTTIME) { ret = -EINVAL; goto errout; diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index 0e0b4091c7..d0b90157b4 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -182,7 +182,7 @@ #define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */ #if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_SYSTEM_TIME64) && \ - defined(CONFIG_CLOCK_MONOTONIC) && !defined(CONFIG_SCHED_TICKLESS) + !defined(CONFIG_SCHED_TICKLESS) /* Initial system timer ticks value close to maximum 32-bit value, to test * 64-bit system-timer after going over 32-bit value. This is to make errors * of casting 64-bit system-timer to 32-bit variables more visible. diff --git a/include/nuttx/input/touchscreen.h b/include/nuttx/input/touchscreen.h index 7a6a61cde1..0836ef1c8c 100644 --- a/include/nuttx/input/touchscreen.h +++ b/include/nuttx/input/touchscreen.h @@ -204,11 +204,7 @@ static inline uint64_t touch_get_time(void) { struct timespec ts; -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000; } diff --git a/include/nuttx/rc/lirc_dev.h b/include/nuttx/rc/lirc_dev.h index 3c357bcc8f..4797ba2cf4 100644 --- a/include/nuttx/rc/lirc_dev.h +++ b/include/nuttx/rc/lirc_dev.h @@ -44,12 +44,7 @@ static inline uint64_t lirc_get_timestamp(void) { struct timespec ts; -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif - return 1000000000ull * ts.tv_sec + ts.tv_nsec; } diff --git a/include/nuttx/sensors/sensor.h b/include/nuttx/sensors/sensor.h index a526761d0c..9e1c613fab 100644 --- a/include/nuttx/sensors/sensor.h +++ b/include/nuttx/sensors/sensor.h @@ -283,12 +283,7 @@ static inline uint64_t sensor_get_timestamp(void) { struct timespec ts; -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif - return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000; } diff --git a/include/time.h b/include/time.h index 8f045e3afe..82900c05d5 100644 --- a/include/time.h +++ b/include/time.h @@ -71,15 +71,11 @@ * system time-of-day clock. */ -#ifdef CONFIG_CLOCK_MONOTONIC -# define CLOCK_MONOTONIC 1 -#endif +#define CLOCK_MONOTONIC 1 /* Monotonic system-wide clock that includes time spent in suspension. */ -#ifdef CONFIG_CLOCK_MONOTONIC -# define CLOCK_BOOTTIME 2 -#endif +#define CLOCK_BOOTTIME 2 /* This is a flag that may be passed to the timer_settime() and * clock_nanosleep() functions. diff --git a/libs/libc/netdb/lib_dnscache.c b/libs/libc/netdb/lib_dnscache.c index 5f2ccafb57..c5a18af510 100644 --- a/libs/libc/netdb/lib_dnscache.c +++ b/libs/libc/netdb/lib_dnscache.c @@ -35,18 +35,6 @@ #if CONFIG_NETDB_DNSCLIENT_ENTRIES > 0 -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Use clock monotonic, if possible */ - -#ifdef CONFIG_CLOCK_MONOTONIC -# define DNS_CLOCK CLOCK_MONOTONIC -#else -# define DNS_CLOCK CLOCK_REALTIME -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -148,9 +136,9 @@ void dns_save_answer(FAR const char *hostname, entry = &g_dns_cache[ndx]; #if CONFIG_NETDB_DNSCLIENT_LIFESEC > 0 - /* Get the current time, using CLOCK_MONOTONIC if possible */ + /* Get the current time */ - clock_gettime(DNS_CLOCK, &now); + clock_gettime(CLOCK_MONOTONIC, &now); entry->ctime = (time_t)now.tv_sec; #endif @@ -228,9 +216,9 @@ int dns_find_answer(FAR const char *hostname, FAR union dns_addr_u *addr, dns_semtake(); #if CONFIG_NETDB_DNSCLIENT_LIFESEC > 0 - /* Get the current time, using CLOCK_MONOTONIC if possible */ + /* Get the current time */ - ret = clock_gettime(DNS_CLOCK, &now); + ret = clock_gettime(CLOCK_MONOTONIC, &now); #endif for (ndx = g_dns_tail; ndx != g_dns_head; ndx = next) diff --git a/libs/libc/netdb/lib_dnsquery.c b/libs/libc/netdb/lib_dnsquery.c index 130373d87b..cb3b69d597 100644 --- a/libs/libc/netdb/lib_dnsquery.c +++ b/libs/libc/netdb/lib_dnsquery.c @@ -181,7 +181,7 @@ static inline uint16_t dns_alloc_id(void) { struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); return (uint32_t)ts.tv_nsec + ((uint32_t)ts.tv_nsec >> 16); } diff --git a/libs/libc/pthread/pthread_condattr_setclock.c b/libs/libc/pthread/pthread_condattr_setclock.c index f3a0c2f6f5..0697d2d086 100644 --- a/libs/libc/pthread/pthread_condattr_setclock.c +++ b/libs/libc/pthread/pthread_condattr_setclock.c @@ -51,11 +51,8 @@ int pthread_condattr_setclock(FAR pthread_condattr_t *attr, clockid_t clock_id) { if (!attr || - ( -#ifdef CONFIG_CLOCK_MONOTONIC - clock_id != CLOCK_MONOTONIC && -#endif - clock_id != CLOCK_REALTIME)) + (clock_id != CLOCK_MONOTONIC && + clock_id != CLOCK_REALTIME)) { return EINVAL; } diff --git a/libs/libc/time/lib_gethrtime.c b/libs/libc/time/lib_gethrtime.c index f620ee61c2..278aed154e 100644 --- a/libs/libc/time/lib_gethrtime.c +++ b/libs/libc/time/lib_gethrtime.c @@ -46,11 +46,6 @@ hrtime_t gethrtime(void) { struct timespec ts; -#ifdef CONFIG_CLOCK_MONOTONIC clock_gettime(CLOCK_MONOTONIC, &ts); -#else - clock_gettime(CLOCK_REALTIME, &ts); -#endif - return (hrtime_t)1000000000 * ts.tv_sec + ts.tv_nsec; } diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c index a35c1b7604..031e76ea83 100644 --- a/libs/libc/unistd/lib_sysconf.c +++ b/libs/libc/unistd/lib_sysconf.c @@ -225,11 +225,7 @@ long sysconf(int name) return CONFIG_SMP_NCPUS; case _SC_MONOTONIC_CLOCK: -#ifdef CONFIG_CLOCK_MONOTONIC return 1; -#else - return 0; -#endif case _SC_PAGESIZE: #ifdef CONFIG_MM_PGSIZE diff --git a/libs/libxx/Kconfig b/libs/libxx/Kconfig index 650e1ab8ef..693c871dd2 100644 --- a/libs/libxx/Kconfig +++ b/libs/libxx/Kconfig @@ -35,7 +35,6 @@ config LIBCXXMINI config LIBCXX bool "LLVM libc++ C++ Standard Library" - select CLOCK_MONOTONIC select LIBC_WCHAR select LIBC_LOCALE ---help--- diff --git a/sched/Kconfig b/sched/Kconfig index 01e110f658..f08815d631 100644 --- a/sched/Kconfig +++ b/sched/Kconfig @@ -162,20 +162,6 @@ config SYSTEM_TIME64 and/or if a very long "uptime" is required, then this option can be selected to support a 64-bit wide timer. -config CLOCK_MONOTONIC - bool "Support CLOCK_MONOTONIC" - default n - ---help--- - CLOCK_MONOTONIC is an optional standard POSIX clock. Unlike - CLOCK_REALTIME which can move forward and backward when the - time-of-day changes, CLOCK_MONOTONIC is the elapsed time since some - arbitrary point in the post (the system start-up time for NuttX) - and, hence, is always monotonically increasing. CLOCK_MONOTONIC - is, hence, the more appropriate clock for determining time - differences. - - The value of the CLOCK_MONOTONIC clock cannot be set via clock_settime(). - config ARCH_HAVE_TIMEKEEPING bool default n diff --git a/sched/clock/clock_getres.c b/sched/clock/clock_getres.c index ca9b718d06..4253e2a4aa 100644 --- a/sched/clock/clock_getres.c +++ b/sched/clock/clock_getres.c @@ -57,10 +57,8 @@ int clock_getres(clockid_t clock_id, struct timespec *res) ret = ERROR; break; -#ifdef CONFIG_CLOCK_MONOTONIC case CLOCK_MONOTONIC: case CLOCK_BOOTTIME: -#endif case CLOCK_REALTIME: /* Form the timspec using clock resolution in nanoseconds */ diff --git a/sched/clock/clock_gettime.c b/sched/clock/clock_gettime.c index 172c2db10f..6b0b30074c 100644 --- a/sched/clock/clock_gettime.c +++ b/sched/clock/clock_gettime.c @@ -61,7 +61,6 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) sinfo("clock_id=%d\n", clock_id); DEBUGASSERT(tp != NULL); -#ifdef CONFIG_CLOCK_MONOTONIC /* CLOCK_MONOTONIC is an optional under POSIX: "If the Monotonic Clock * option is supported, all implementations shall support a clock_id * of CLOCK_MONOTONIC defined in . This clock represents the @@ -82,8 +81,6 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) ret = clock_systime_timespec(tp); } - else -#endif /* CLOCK_REALTIME - POSIX demands this to be present. CLOCK_REALTIME * represents the machine's best-guess as to the current wall-clock, @@ -91,7 +88,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) * backward as the system time-of-day clock is changed. */ - if (clock_id == CLOCK_REALTIME) + else if (clock_id == CLOCK_REALTIME) { /* Get the elapsed time since the time-of-day was last set. * clock_systime_timespec() provides the time since power was applied; diff --git a/sched/timer/timer_create.c b/sched/timer/timer_create.c index 85449faa9a..a499b44d92 100644 --- a/sched/timer/timer_create.c +++ b/sched/timer/timer_create.c @@ -158,12 +158,8 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp, /* Sanity checks. */ - if (timerid == NULL || (clockid != CLOCK_REALTIME -#ifdef CONFIG_CLOCK_MONOTONIC - && clockid != CLOCK_MONOTONIC - && clockid != CLOCK_BOOTTIME -#endif /* CONFIG_CLOCK_MONOTONIC */ - )) + if (timerid == NULL || (clockid != CLOCK_REALTIME && + clockid != CLOCK_MONOTONIC && clockid != CLOCK_BOOTTIME)) { set_errno(EINVAL); return ERROR;