summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-11-16 14:14:03 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-11-21 16:29:40 +0100
commit90733a86b881374d5c76a3af904a4edc0c86f6ca (patch)
tree6ff20e1e9adf3c948b643a8e7cf2d04dd11147c3 /cpukit/rtems
parentrtems: Add rtems_clock_get_uptime_timeval() (diff)
downloadrtems-90733a86b881374d5c76a3af904a4edc0c86f6ca.tar.bz2
rtems: Add rtems_clock_get_uptime_seconds()
Diffstat (limited to '')
-rw-r--r--cpukit/rtems/Makefile.am1
-rw-r--r--cpukit/rtems/include/rtems/rtems/clock.h7
-rw-r--r--cpukit/rtems/src/clockgetuptimeseconds.c34
3 files changed, 42 insertions, 0 deletions
diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index 10a5cfaf5d..6295990a74 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -155,6 +155,7 @@ librtems_a_SOURCES += src/clockgettod.c
librtems_a_SOURCES += src/clockgettodtimeval.c
librtems_a_SOURCES += src/clockgetuptime.c
librtems_a_SOURCES += src/clockgetuptimetimeval.c
+librtems_a_SOURCES += src/clockgetuptimeseconds.c
librtems_a_SOURCES += src/clockset.c
librtems_a_SOURCES += src/clocksetnsecshandler.c
librtems_a_SOURCES += src/clocktick.c
diff --git a/cpukit/rtems/include/rtems/rtems/clock.h b/cpukit/rtems/include/rtems/rtems/clock.h
index 9805f58e10..c7b9a4ab93 100644
--- a/cpukit/rtems/include/rtems/rtems/clock.h
+++ b/cpukit/rtems/include/rtems/rtems/clock.h
@@ -235,6 +235,13 @@ rtems_status_code rtems_clock_get_uptime(
void rtems_clock_get_uptime_timeval( struct timeval *uptime );
/**
+ * @brief Returns the system uptime in seconds.
+ *
+ * @return The system uptime in seconds.
+ */
+time_t rtems_clock_get_uptime_seconds( void );
+
+/**
* @brief _TOD_Validate
*
* This support function returns true if @a the_tod contains
diff --git a/cpukit/rtems/src/clockgetuptimeseconds.c b/cpukit/rtems/src/clockgetuptimeseconds.c
new file mode 100644
index 0000000000..dc98d1d9e9
--- /dev/null
+++ b/cpukit/rtems/src/clockgetuptimeseconds.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2012 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include <rtems/rtems/clock.h>
+
+time_t rtems_clock_get_uptime_seconds( void )
+{
+ Timestamp_Control snapshot_as_timestamp;
+ struct timespec snapshot_as_timespec;
+ ISR_Level level;
+
+ _ISR_Disable( level );
+ snapshot_as_timestamp = _TOD.uptime;
+ _ISR_Enable( level );
+
+ _Timestamp_To_timespec( &snapshot_as_timestamp, &snapshot_as_timespec );
+
+ return snapshot_as_timespec.tv_sec;
+}