summaryrefslogtreecommitdiffstats
path: root/cpukit/rtems/src/clockgetuptimeseconds.c
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/src/clockgetuptimeseconds.c
parentrtems: Add rtems_clock_get_uptime_timeval() (diff)
downloadrtems-90733a86b881374d5c76a3af904a4edc0c86f6ca.tar.bz2
rtems: Add rtems_clock_get_uptime_seconds()
Diffstat (limited to 'cpukit/rtems/src/clockgetuptimeseconds.c')
-rw-r--r--cpukit/rtems/src/clockgetuptimeseconds.c34
1 files changed, 34 insertions, 0 deletions
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;
+}