summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/timespecgetasnanoseconds.c
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2013-12-24 16:38:42 +1100
committerChris Johns <chrisj@rtems.org>2013-12-24 16:46:19 +1100
commit2d1bdc8f797db5ab6e3ba6945befaf73d9062798 (patch)
treee8a3eecc64c589a9d0495790e09092dc572f36cf /cpukit/score/src/timespecgetasnanoseconds.c
parentmips/shared: added new doxygen (diff)
downloadrtems-2d1bdc8f797db5ab6e3ba6945befaf73d9062798.tar.bz2
cpukit/rtems: Add rtems_clock_get_uptime_nanoseconds to the RTEMS API.
Add Timestamp support in the score to return a timestamp in nanoseconds. Add a test. Update the RTEMS API documentation.
Diffstat (limited to 'cpukit/score/src/timespecgetasnanoseconds.c')
-rw-r--r--cpukit/score/src/timespecgetasnanoseconds.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/cpukit/score/src/timespecgetasnanoseconds.c b/cpukit/score/src/timespecgetasnanoseconds.c
new file mode 100644
index 0000000000..4ef1af4f62
--- /dev/null
+++ b/cpukit/score/src/timespecgetasnanoseconds.c
@@ -0,0 +1,29 @@
+/**
+ * @file
+ *
+ * @brief Get As Nanoseconds
+ * @ingroup Timespec
+ */
+
+/*
+ * COPYRIGHT (c) 2013 Chris Johns <chrisj@rtems.org>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/score/timespec.h>
+#include <rtems/score/todimpl.h>
+
+uint64_t _Timespec_Get_As_nanoseconds(
+ const struct timespec *time,
+ const uint32_t nanoseconds
+)
+{
+ return ( ((uint64_t) time->tv_sec) * 1000000000ULL ) + time->tv_nsec + nanoseconds;
+}