Add CONFIG_CLOCK_MONTONIC

This commit is contained in:
Gregory Nutt 2014-03-31 10:01:03 -06:00
parent 68025784b0
commit 4f59bc5878
4 changed files with 25 additions and 3 deletions

View File

@ -7095,3 +7095,6 @@
* libc/stdio/lib_ftell.c: Fix a logic error in ftell(). It was
simply using the file offset and did not take into account data
buffered in memory. From Macs N (2013-3-31).
* Add CONFIG_CLOCK_MONOTONIC that case used to disable CLOCK_MONOTONIC
for a smaller footprint (2013-3-31).

View File

@ -99,7 +99,9 @@
* system time-of-day clock.
*/
#define CLOCK_MONOTONIC 2
#ifdef CLOCK_MONOTONIC
# define CLOCK_MONOTONIC 2
#endif
/* This is a flag that may be passed to the timer_settime() function */

View File

@ -53,6 +53,20 @@ 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 RR_INTERVAL
int "Round robin timeslice (MSEC)"
default 0

View File

@ -107,6 +107,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
sdbg("clock_id=%d\n", clock_id);
DEBUGASSERT(tp != NULL);
#ifdef 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 <time.h>. This clock represents the
@ -139,6 +140,8 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
tp->tv_sec = (time_t)secs;
tp->tv_nsec = (long)nsecs;
}
else
#endif
/* CLOCK_REALTIME - POSIX demands this to be present. CLOCK_REALTIME
* represents the machine's best-guess as to the current wall-clock,
@ -152,9 +155,9 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp)
*/
#ifdef CONFIG_RTC
else if (clock_id == CLOCK_REALTIME || clock_id == CLOCK_ACTIVETIME)
if (clock_id == CLOCK_REALTIME || clock_id == CLOCK_ACTIVETIME)
#else
else if (clock_id == CLOCK_REALTIME)
if (clock_id == CLOCK_REALTIME)
#endif
{
/* Do we have a high-resolution RTC that can provide us with the time? */