summaryrefslogtreecommitdiff
path: root/nuttx/sched/clock_settime.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-10-02 14:16:30 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-10-02 14:16:30 +0000
commitbbadecee80cf2f48a43097328bb24b73f236934c (patch)
treee3a769b2f63c911bbc57c0e60b863aa996ea9dbb /nuttx/sched/clock_settime.c
parent078ff53de7f505ba714be768a94c1e52e7261b3e (diff)
downloadpx4-nuttx-bbadecee80cf2f48a43097328bb24b73f236934c.tar.gz
px4-nuttx-bbadecee80cf2f48a43097328bb24b73f236934c.tar.bz2
px4-nuttx-bbadecee80cf2f48a43097328bb24b73f236934c.zip
Remove support for UTC time; add support for 64-bit time
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4006 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/sched/clock_settime.c')
-rw-r--r--nuttx/sched/clock_settime.c51
1 files changed, 13 insertions, 38 deletions
diff --git a/nuttx/sched/clock_settime.c b/nuttx/sched/clock_settime.c
index 299e8c65b..f8bff78e3 100644
--- a/nuttx/sched/clock_settime.c
+++ b/nuttx/sched/clock_settime.c
@@ -89,17 +89,25 @@
int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
{
+ irqstate_t flags;
int ret = OK;
sdbg("clock_id=%d\n", clock_id);
+ DEBUGASSERT(tp != NULL);
/* CLOCK_REALTIME - POSIX demands this to be present. This is the wall
* time clock.
*/
- if (clock_id == CLOCK_REALTIME && tp)
+ if (clock_id == CLOCK_REALTIME)
{
-#ifndef CONFIG_SYSTEM_UTC
+ /* Interrupts are disabled here so that the in-memory time
+ * representation and the RTC setting will be as close as
+ * possible.
+ */
+
+ flags = irqsave();
+
/* Save the new base time. */
g_basetime.tv_sec = tp->tv_sec;
@@ -109,55 +117,22 @@ int clock_settime(clockid_t clock_id, FAR const struct timespec *tp)
* as appropriate.
*/
- g_tickbias = clock_systimer();
-
-#else /* if CONFIG_SYSTEM_UTC=y */
+ g_tickbias = g_system_timer;
- /* We ignore everything below one second in time configuration */
+ /* Setup the RTC (lo- or high-res) */
#ifdef CONFIG_RTC
if (g_rtc_enabled)
{
up_rtc_settime(tp);
}
- else
-#endif
- {
- g_system_utc = tp->tv_sec;
- }
#endif
+ irqrestore(flags);
sdbg("basetime=(%d,%d) tickbias=%d\n",
(int)g_basetime.tv_sec, (int)g_basetime.tv_nsec,
(int)g_tickbias);
}
-
- /* CLOCK_ACTIVETIME is non-standard. Returns active UTC time, which is
- * disabled during power down modes. Unit is 1 second.
- */
-
-#ifdef CONFIG_SYSTEM_UTC
- else if (clock_id == CLOCK_ACTIVETIME && tp)
- {
- irqstate_t flags;
- uint32_t tickcount;
-
- /* Calculate the number of ticks correspond to the nanosecond count...
- * exercising care to avoid overflows. This could still overflow
- * if CLOCKS_PER_SEC is very large (something like 4096).
- */
-
- tickcount = ((tp->tv_nsec >> 10) * CLOCKS_PER_SEC) / (1000000000 >> 10);
-
- /* Then set the UTC time (seconds) plus the tickcount (fractional seconds */
-
- flags = irqsave();
- g_system_utc = tp->tv_sec;
- g_tickcount = tickcount;
- irqrestore(flags);
- }
-#endif
-
else
{
sdbg("Returning ERROR\n");