summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/posixintervaltotimespec.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/posix/src/posixintervaltotimespec.c')
-rw-r--r--cpukit/posix/src/posixintervaltotimespec.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/cpukit/posix/src/posixintervaltotimespec.c b/cpukit/posix/src/posixintervaltotimespec.c
new file mode 100644
index 0000000000..e5f883095b
--- /dev/null
+++ b/cpukit/posix/src/posixintervaltotimespec.c
@@ -0,0 +1,34 @@
+/*
+ * $Id$
+ */
+
+#include <assert.h>
+#include <time.h>
+#include <errno.h>
+
+#include <rtems/system.h>
+#include <rtems/score/isr.h>
+#include <rtems/score/thread.h>
+#include <rtems/score/tod.h>
+
+#include <rtems/posix/seterr.h>
+#include <rtems/posix/time.h>
+
+/*PAGE
+ *
+ * _POSIX_Interval_to_timespec
+ */
+
+void _POSIX_Interval_to_timespec(
+ Watchdog_Interval ticks,
+ struct timespec *time
+)
+{
+ unsigned32 usecs;
+
+ usecs = ticks * _TOD_Microseconds_per_tick;
+
+ time->tv_sec = usecs / TOD_MICROSECONDS_PER_SECOND;
+ time->tv_nsec = (usecs % TOD_MICROSECONDS_PER_SECOND) *
+ TOD_NANOSECONDS_PER_MICROSECOND;
+}