sched/clock: Remove CLOCK_MONOTONIC option from Kconfig
here is the reason: 1.clock_systime_timespec(core function) always exist regardless the setting 2.CLOCK_MONOTONIC is a foundamental clock type required by many places Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
7b00c8bdb8
commit
f1ed349dd9
@ -49,19 +49,18 @@ with NuttX. The list is the following:
|
|||||||
``CONFIG_BOARDCTL_APP_SYMTAB=y`` ``CONFIG_NSH_LINELEN=64``
|
``CONFIG_BOARDCTL_APP_SYMTAB=y`` ``CONFIG_NSH_LINELEN=64``
|
||||||
``CONFIG_BOARDCTL_OS_SYMTAB=y`` ``CONFIG_NSH_READLINE=y``
|
``CONFIG_BOARDCTL_OS_SYMTAB=y`` ``CONFIG_NSH_READLINE=y``
|
||||||
``CONFIG_BUILTIN=y`` ``CONFIG_NSH_ROMFSETC=y``
|
``CONFIG_BUILTIN=y`` ``CONFIG_NSH_ROMFSETC=y``
|
||||||
``CONFIG_CLOCK_MONOTONIC=y`` ``CONFIG_PSEUDOTERM=y``
|
``CONFIG_ELF=y`` ``CONFIG_PSEUDOTERM=y``
|
||||||
``CONFIG_ELF=y`` ``CONFIG_PTHREAD_CLEANUP=y``
|
``CONFIG_FS_BINFS=y`` ``CONFIG_PTHREAD_CLEANUP=y``
|
||||||
``CONFIG_FS_BINFS=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y``
|
|
||||||
``CONFIG_FS_PROCFS=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y``
|
``CONFIG_FS_PROCFS=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y``
|
||||||
``CONFIG_FS_PROCFS_REGISTER=y`` ``CONFIG_PTHREAD_STACK_MIN=1024``
|
``CONFIG_FS_PROCFS_REGISTER=y`` ``CONFIG_PTHREAD_MUTEX_TYPES=y``
|
||||||
``CONFIG_FS_ROMFS=y`` ``CONFIG_RR_INTERVAL=10``
|
``CONFIG_FS_ROMFS=y`` ``CONFIG_PTHREAD_STACK_MIN=1024``
|
||||||
``CONFIG_FS_TMPFS=y`` ``CONFIG_SCHED_WAITPID=y``
|
``CONFIG_FS_TMPFS=y`` ``CONFIG_RR_INTERVAL=10``
|
||||||
``CONFIG_IDLETHREAD_STACKSIZE=2048`` ``CONFIG_SERIAL_TERMIOS=y``
|
``CONFIG_IDLETHREAD_STACKSIZE=2048`` ``CONFIG_SCHED_WAITPID=y``
|
||||||
``CONFIG_LIBC_EXECFUNCS=y`` ``CONFIG_SYMTAB_ORDEREDBYNAME=y``
|
``CONFIG_LIBC_EXECFUNCS=y`` ``CONFIG_SERIAL_TERMIOS=y``
|
||||||
``CONFIG_LIBC_STRERROR=y`` ``CONFIG_SYSTEM_NSH=y``
|
``CONFIG_LIBC_STRERROR=y`` ``CONFIG_SYMTAB_ORDEREDBYNAME=y``
|
||||||
``CONFIG_MAX_TASKS=16`` ``CONFIG_SYSTEM_NSH_STACKSIZE=4096``
|
``CONFIG_MAX_TASKS=16`` ``CONFIG_SYSTEM_NSH=y``
|
||||||
``CONFIG_NSH_BUILTIN_APPS=y`` ``CONFIG_INIT_ENTRYPOINT="nsh_main"``
|
``CONFIG_NSH_BUILTIN_APPS=y`` ``CONFIG_SYSTEM_NSH_STACKSIZE=4096``
|
||||||
``CONFIG_NSH_FILEIOSIZE=512``
|
``CONFIG_NSH_FILEIOSIZE=512`` ``CONFIG_INIT_ENTRYPOINT="nsh_main"``
|
||||||
==================================== =====================================
|
==================================== =====================================
|
||||||
|
|
||||||
In case you want to use Network and blocks like TCP or UDP, following configuration
|
In case you want to use Network and blocks like TCP or UDP, following configuration
|
||||||
|
@ -127,11 +127,7 @@ static uint64_t _get_current_time64(void)
|
|||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
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;
|
return (uint64_t)ts.tv_sec * NSEC_PER_SEC + (uint64_t)ts.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,10 +147,8 @@ static struct pm_callback_s pm_cb =
|
|||||||
static int cboot = 1;
|
static int cboot = 1;
|
||||||
#endif /* CONFIG_RTC_DIV */
|
#endif /* CONFIG_RTC_DIV */
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
static struct timespec lastupdate_mono;
|
static struct timespec lastupdate_mono;
|
||||||
static struct timespec lastupdate_rtc;
|
static struct timespec lastupdate_rtc;
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Data
|
* Public Data
|
||||||
@ -550,10 +548,8 @@ int up_rtc_settime(FAR const struct timespec *ts)
|
|||||||
up_rtc_set_default_datetime(tp);
|
up_rtc_set_default_datetime(tp);
|
||||||
#endif /* CONFIG_RTC_SAVE_DEFAULT */
|
#endif /* CONFIG_RTC_SAVE_DEFAULT */
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &lastupdate_mono);
|
clock_gettime(CLOCK_MONOTONIC, &lastupdate_mono);
|
||||||
lastupdate_rtc = *ts;
|
lastupdate_rtc = *ts;
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Start rtc update */
|
/* Start rtc update */
|
||||||
|
|
||||||
@ -661,8 +657,6 @@ int up_rtc_cancelalarm(void)
|
|||||||
int up_rtc_getrawtime(FAR struct timespec *ts)
|
int up_rtc_getrawtime(FAR struct timespec *ts)
|
||||||
{
|
{
|
||||||
struct tm tm;
|
struct tm tm;
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
struct timespec now;
|
struct timespec now;
|
||||||
struct timespec diff;
|
struct timespec diff;
|
||||||
|
|
||||||
@ -676,7 +670,6 @@ int up_rtc_getrawtime(FAR struct timespec *ts)
|
|||||||
*ts = lastupdate_rtc;
|
*ts = lastupdate_rtc;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
tm.tm_sec = getreg8(RTC_SEC);
|
tm.tm_sec = getreg8(RTC_SEC);
|
||||||
tm.tm_min = getreg8(RTC_MIN);
|
tm.tm_min = getreg8(RTC_MIN);
|
||||||
|
@ -851,11 +851,7 @@ static int esp32c3_i2c_polling_waitdone(struct esp32c3_i2c_priv_s *priv)
|
|||||||
* forward and backwards.
|
* forward and backwards.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, ¤t_time);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
timeout.tv_sec = current_time.tv_sec + 10;
|
timeout.tv_sec = current_time.tv_sec + 10;
|
||||||
timeout.tv_nsec = current_time.tv_nsec + 0;
|
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 */
|
/* Update current time */
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, ¤t_time);
|
|
||||||
#endif
|
|
||||||
current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
|
current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -784,11 +784,7 @@ static int esp32_i2c_polling_waitdone(struct esp32_i2c_priv_s *priv)
|
|||||||
* forward and backwards.
|
* forward and backwards.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, ¤t_time);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
timeout.tv_sec = current_time.tv_sec + 10;
|
timeout.tv_sec = current_time.tv_sec + 10;
|
||||||
timeout.tv_nsec = current_time.tv_nsec + 0;
|
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 */
|
/* Update current time */
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
||||||
clock_gettime(CLOCK_MONOTONIC, ¤t_time);
|
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, ¤t_time);
|
|
||||||
#endif
|
|
||||||
current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
|
current_us = TIMESPEC_TO_US(current_time.tv_sec, current_time.tv_nsec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,11 +643,7 @@ static int bmp280_fetch(FAR struct sensor_lowerhalf_s *lower,
|
|||||||
temp = bmp280_compensate_temp(priv, temp);
|
temp = bmp280_compensate_temp(priv, temp);
|
||||||
press = bmp280_compensate_press(priv, press);
|
press = bmp280_compensate_press(priv, press);
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
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.timestamp = 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||||
baro_data.pressure = press / 100.0f;
|
baro_data.pressure = press / 100.0f;
|
||||||
|
@ -549,12 +549,8 @@ static int ds18b20_set_alarm(FAR struct ds18b20_dev_s *dev,
|
|||||||
static unsigned long ds18b20_curtime(void)
|
static unsigned long ds18b20_curtime(void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
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;
|
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,12 +187,8 @@ static void hyt271_temp_from_rawdata(FAR struct hyt271_sensor_data_s *data,
|
|||||||
static unsigned long hyt271_curtime(void)
|
static unsigned long hyt271_curtime(void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
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;
|
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1667,11 +1667,7 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev)
|
|||||||
|
|
||||||
/* Prefer monotonic for timeout calculation when enabled. */
|
/* Prefer monotonic for timeout calculation when enabled. */
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &start);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Reboot to reset chip. */
|
/* Reboot to reset chip. */
|
||||||
|
|
||||||
@ -1696,11 +1692,7 @@ static int lis2dh_reboot(FAR struct lis2dh_dev_s *dev)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &curr);
|
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_sec - start.tv_sec) * 1000;
|
||||||
diff_msec += (curr.tv_nsec - start.tv_nsec) / (1000 * 1000);
|
diff_msec += (curr.tv_nsec - start.tv_nsec) / (1000 * 1000);
|
||||||
|
@ -157,12 +157,8 @@ static const struct sensor_ops_s g_sensor_ops =
|
|||||||
static unsigned long ms5611_curtime(void)
|
static unsigned long ms5611_curtime(void)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
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;
|
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,17 +105,12 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
|
|||||||
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
|
|
||||||
#elif defined(CONFIG_CLOCK_MONOTONIC)
|
#else
|
||||||
/* Prefer monotonic when enabled, as it can be synchronized to
|
/* Prefer monotonic when enabled, as it can be synchronized to
|
||||||
* RTC with clock_resynchronize.
|
* RTC with clock_resynchronize.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
|
||||||
#else
|
|
||||||
/* Otherwise, fall back to the system timer */
|
|
||||||
|
|
||||||
clock_systime_timespec(&ts);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Prepend the message with the current time, if available */
|
/* Prepend the message with the current time, if available */
|
||||||
|
@ -387,12 +387,7 @@ int epoll_pwait(int epfd, FAR struct epoll_event *evs,
|
|||||||
expire.tv_sec = timeout / 1000;
|
expire.tv_sec = timeout / 1000;
|
||||||
expire.tv_nsec = timeout % 1000 * 1000;
|
expire.tv_nsec = timeout % 1000 * 1000;
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &curr);
|
clock_gettime(CLOCK_MONOTONIC, &curr);
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &curr);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
clock_timespec_add(&curr, &expire, &expire);
|
clock_timespec_add(&curr, &expire, &expire);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,11 +398,7 @@ again:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &curr);
|
clock_gettime(CLOCK_MONOTONIC, &curr);
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &curr);
|
|
||||||
#endif
|
|
||||||
clock_timespec_subtract(&expire, &curr, &diff);
|
clock_timespec_subtract(&expire, &curr, &diff);
|
||||||
|
|
||||||
rc = ppoll(eph->poll, eph->occupied + 1, &diff, sigmask);
|
rc = ppoll(eph->poll, eph->occupied + 1, &diff, sigmask);
|
||||||
|
@ -540,12 +540,9 @@ int timerfd_create(int clockid, int flags)
|
|||||||
|
|
||||||
/* Sanity checks. */
|
/* Sanity checks. */
|
||||||
|
|
||||||
if (clockid != CLOCK_REALTIME
|
if (clockid != CLOCK_REALTIME &&
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
clockid != CLOCK_MONOTONIC &&
|
||||||
&& clockid != CLOCK_MONOTONIC
|
clockid != CLOCK_BOOTTIME)
|
||||||
&& clockid != CLOCK_BOOTTIME
|
|
||||||
#endif /* CONFIG_CLOCK_MONOTONIC */
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto errout;
|
goto errout;
|
||||||
|
@ -182,7 +182,7 @@
|
|||||||
#define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */
|
#define TICK2SEC(tick) (((tick)+(TICK_PER_SEC/2))/TICK_PER_SEC) /* Rounds */
|
||||||
|
|
||||||
#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_SYSTEM_TIME64) && \
|
#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
|
/* 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
|
* 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.
|
* of casting 64-bit system-timer to 32-bit variables more visible.
|
||||||
|
@ -204,11 +204,7 @@ static inline uint64_t touch_get_time(void)
|
|||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
|
||||||
#endif
|
|
||||||
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,12 +44,7 @@ static inline uint64_t lirc_get_timestamp(void)
|
|||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1000000000ull * ts.tv_sec + ts.tv_nsec;
|
return 1000000000ull * ts.tv_sec + ts.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,12 +283,7 @@ static inline uint64_t sensor_get_timestamp(void)
|
|||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
return 1000000ull * ts.tv_sec + ts.tv_nsec / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,15 +71,11 @@
|
|||||||
* system time-of-day clock.
|
* system time-of-day clock.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
#define CLOCK_MONOTONIC 1
|
||||||
# define CLOCK_MONOTONIC 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Monotonic system-wide clock that includes time spent in suspension. */
|
/* Monotonic system-wide clock that includes time spent in suspension. */
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
#define CLOCK_BOOTTIME 2
|
||||||
# define CLOCK_BOOTTIME 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This is a flag that may be passed to the timer_settime() and
|
/* This is a flag that may be passed to the timer_settime() and
|
||||||
* clock_nanosleep() functions.
|
* clock_nanosleep() functions.
|
||||||
|
@ -35,18 +35,6 @@
|
|||||||
|
|
||||||
#if CONFIG_NETDB_DNSCLIENT_ENTRIES > 0
|
#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
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -148,9 +136,9 @@ void dns_save_answer(FAR const char *hostname,
|
|||||||
entry = &g_dns_cache[ndx];
|
entry = &g_dns_cache[ndx];
|
||||||
|
|
||||||
#if CONFIG_NETDB_DNSCLIENT_LIFESEC > 0
|
#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;
|
entry->ctime = (time_t)now.tv_sec;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -228,9 +216,9 @@ int dns_find_answer(FAR const char *hostname, FAR union dns_addr_u *addr,
|
|||||||
dns_semtake();
|
dns_semtake();
|
||||||
|
|
||||||
#if CONFIG_NETDB_DNSCLIENT_LIFESEC > 0
|
#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
|
#endif
|
||||||
|
|
||||||
for (ndx = g_dns_tail; ndx != g_dns_head; ndx = next)
|
for (ndx = g_dns_tail; ndx != g_dns_head; ndx = next)
|
||||||
|
@ -181,7 +181,7 @@ static inline uint16_t dns_alloc_id(void)
|
|||||||
{
|
{
|
||||||
struct timespec ts;
|
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);
|
return (uint32_t)ts.tv_nsec + ((uint32_t)ts.tv_nsec >> 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,8 @@ int pthread_condattr_setclock(FAR pthread_condattr_t *attr,
|
|||||||
clockid_t clock_id)
|
clockid_t clock_id)
|
||||||
{
|
{
|
||||||
if (!attr ||
|
if (!attr ||
|
||||||
(
|
(clock_id != CLOCK_MONOTONIC &&
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
clock_id != CLOCK_REALTIME))
|
||||||
clock_id != CLOCK_MONOTONIC &&
|
|
||||||
#endif
|
|
||||||
clock_id != CLOCK_REALTIME))
|
|
||||||
{
|
{
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -46,11 +46,6 @@ hrtime_t gethrtime(void)
|
|||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
#else
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return (hrtime_t)1000000000 * ts.tv_sec + ts.tv_nsec;
|
return (hrtime_t)1000000000 * ts.tv_sec + ts.tv_nsec;
|
||||||
}
|
}
|
||||||
|
@ -225,11 +225,7 @@ long sysconf(int name)
|
|||||||
return CONFIG_SMP_NCPUS;
|
return CONFIG_SMP_NCPUS;
|
||||||
|
|
||||||
case _SC_MONOTONIC_CLOCK:
|
case _SC_MONOTONIC_CLOCK:
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case _SC_PAGESIZE:
|
case _SC_PAGESIZE:
|
||||||
#ifdef CONFIG_MM_PGSIZE
|
#ifdef CONFIG_MM_PGSIZE
|
||||||
|
@ -35,7 +35,6 @@ config LIBCXXMINI
|
|||||||
|
|
||||||
config LIBCXX
|
config LIBCXX
|
||||||
bool "LLVM libc++ C++ Standard Library"
|
bool "LLVM libc++ C++ Standard Library"
|
||||||
select CLOCK_MONOTONIC
|
|
||||||
select LIBC_WCHAR
|
select LIBC_WCHAR
|
||||||
select LIBC_LOCALE
|
select LIBC_LOCALE
|
||||||
---help---
|
---help---
|
||||||
|
@ -162,20 +162,6 @@ config SYSTEM_TIME64
|
|||||||
and/or if a very long "uptime" is required, then this option can be
|
and/or if a very long "uptime" is required, then this option can be
|
||||||
selected to support a 64-bit wide timer.
|
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
|
config ARCH_HAVE_TIMEKEEPING
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
@ -57,10 +57,8 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
|
|||||||
ret = ERROR;
|
ret = ERROR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
case CLOCK_MONOTONIC:
|
case CLOCK_MONOTONIC:
|
||||||
case CLOCK_BOOTTIME:
|
case CLOCK_BOOTTIME:
|
||||||
#endif
|
|
||||||
case CLOCK_REALTIME:
|
case CLOCK_REALTIME:
|
||||||
|
|
||||||
/* Form the timspec using clock resolution in nanoseconds */
|
/* Form the timspec using clock resolution in nanoseconds */
|
||||||
|
@ -61,7 +61,6 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
|||||||
sinfo("clock_id=%d\n", clock_id);
|
sinfo("clock_id=%d\n", clock_id);
|
||||||
DEBUGASSERT(tp != NULL);
|
DEBUGASSERT(tp != NULL);
|
||||||
|
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
|
||||||
/* CLOCK_MONOTONIC is an optional under POSIX: "If the Monotonic Clock
|
/* CLOCK_MONOTONIC is an optional under POSIX: "If the Monotonic Clock
|
||||||
* option is supported, all implementations shall support a clock_id
|
* option is supported, all implementations shall support a clock_id
|
||||||
* of CLOCK_MONOTONIC defined in <time.h>. This clock represents the
|
* of CLOCK_MONOTONIC defined in <time.h>. This clock represents the
|
||||||
@ -82,8 +81,6 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
|||||||
|
|
||||||
ret = clock_systime_timespec(tp);
|
ret = clock_systime_timespec(tp);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* CLOCK_REALTIME - POSIX demands this to be present. CLOCK_REALTIME
|
/* CLOCK_REALTIME - POSIX demands this to be present. CLOCK_REALTIME
|
||||||
* represents the machine's best-guess as to the current wall-clock,
|
* 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.
|
* 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.
|
/* Get the elapsed time since the time-of-day was last set.
|
||||||
* clock_systime_timespec() provides the time since power was applied;
|
* clock_systime_timespec() provides the time since power was applied;
|
||||||
|
@ -158,12 +158,8 @@ int timer_create(clockid_t clockid, FAR struct sigevent *evp,
|
|||||||
|
|
||||||
/* Sanity checks. */
|
/* Sanity checks. */
|
||||||
|
|
||||||
if (timerid == NULL || (clockid != CLOCK_REALTIME
|
if (timerid == NULL || (clockid != CLOCK_REALTIME &&
|
||||||
#ifdef CONFIG_CLOCK_MONOTONIC
|
clockid != CLOCK_MONOTONIC && clockid != CLOCK_BOOTTIME))
|
||||||
&& clockid != CLOCK_MONOTONIC
|
|
||||||
&& clockid != CLOCK_BOOTTIME
|
|
||||||
#endif /* CONFIG_CLOCK_MONOTONIC */
|
|
||||||
))
|
|
||||||
{
|
{
|
||||||
set_errno(EINVAL);
|
set_errno(EINVAL);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user