summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/ts64divide.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-09 21:27:35 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-12-09 21:27:35 +0000
commite57cb3c9df68ebe3616f8276be8d6fe7e926b4f2 (patch)
tree42483f3fce61b821e9d617a8c633e7fdd53a0d19 /cpukit/score/src/ts64divide.c
parent2008-12-09 Joel Sherrill <joel.sherrill@oarcorp.com> (diff)
downloadrtems-e57cb3c9df68ebe3616f8276be8d6fe7e926b4f2.tar.bz2
2008-12-09 Joel Sherrill <joel.sherrill@oarcorp.com>
* score/Makefile.am, score/preinstall.am, score/include/rtems/score/timespec.h, score/include/rtems/score/timestamp.h: Add 64-bit implementation of SuperCore Timestamps. Tested on PowerPC/psim and SPARC/sis. * score/include/rtems/score/timestamp64.h, score/src/ts64addto.c, score/src/ts64divide.c, score/src/ts64dividebyinteger.c, score/src/ts64equalto.c, score/src/ts64getnanoseconds.c, score/src/ts64getseconds.c, score/src/ts64greaterthan.c, score/src/ts64lessthan.c, score/src/ts64set.c, score/src/ts64settozero.c, score/src/ts64subtract.c, score/src/ts64toticks.c, score/src/ts64totimespec.c: New files.
Diffstat (limited to 'cpukit/score/src/ts64divide.c')
-rw-r--r--cpukit/score/src/ts64divide.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/cpukit/score/src/ts64divide.c b/cpukit/score/src/ts64divide.c
new file mode 100644
index 0000000000..a8a08c985d
--- /dev/null
+++ b/cpukit/score/src/ts64divide.c
@@ -0,0 +1,54 @@
+/**
+ * @file score/src/ts64divide.c
+ */
+
+/*
+ * COPYRIGHT (c) 1989-2007.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * 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.
+ *
+ * $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+
+#include <rtems/system.h>
+#include <sys/types.h>
+#include <rtems/score/timestamp.h>
+
+/* This method is never inlined. */
+#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64)
+void _Timestamp64_Divide(
+ const Timestamp64_Control *_lhs,
+ const Timestamp64_Control *_rhs,
+ uint32_t *_ival_percentage,
+ uint32_t *_fval_percentage
+)
+{
+ Timestamp64_Control answer;
+
+ if ( *_rhs == 0 ) {
+ *_ival_percentage = 0;
+ *_fval_percentage = 0;
+ return;
+ }
+
+ /*
+ * This looks odd but gives the results the proper precision.
+ *
+ * TODO: Rounding on the last digit of the fval.
+ */
+
+ answer = (*_lhs * 100000) / *_rhs;
+
+ *_ival_percentage = answer / 1000;
+ *_fval_percentage = answer % 1000;
+}
+#endif