diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-12-09 21:27:35 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-12-09 21:27:35 +0000 |
commit | e57cb3c9df68ebe3616f8276be8d6fe7e926b4f2 (patch) | |
tree | 42483f3fce61b821e9d617a8c633e7fdd53a0d19 /cpukit/score/src | |
parent | 2008-12-09 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-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')
-rw-r--r-- | cpukit/score/src/ts64addto.c | 34 | ||||
-rw-r--r-- | cpukit/score/src/ts64divide.c | 54 | ||||
-rw-r--r-- | cpukit/score/src/ts64dividebyinteger.c | 35 | ||||
-rw-r--r-- | cpukit/score/src/ts64equalto.c | 34 | ||||
-rw-r--r-- | cpukit/score/src/ts64getnanoseconds.c | 33 | ||||
-rw-r--r-- | cpukit/score/src/ts64getseconds.c | 33 | ||||
-rw-r--r-- | cpukit/score/src/ts64greaterthan.c | 34 | ||||
-rw-r--r-- | cpukit/score/src/ts64lessthan.c | 34 | ||||
-rw-r--r-- | cpukit/score/src/ts64set.c | 39 | ||||
-rw-r--r-- | cpukit/score/src/ts64settozero.c | 33 | ||||
-rw-r--r-- | cpukit/score/src/ts64subtract.c | 35 | ||||
-rw-r--r-- | cpukit/score/src/ts64toticks.c | 39 | ||||
-rw-r--r-- | cpukit/score/src/ts64totimespec.c | 35 |
13 files changed, 472 insertions, 0 deletions
diff --git a/cpukit/score/src/ts64addto.c b/cpukit/score/src/ts64addto.c new file mode 100644 index 0000000000..14439de0f3 --- /dev/null +++ b/cpukit/score/src/ts64addto.c @@ -0,0 +1,34 @@ +/** + * @file score/src/ts64addto.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +void _Timestamp64_Add_to( + Timestamp64_Control *_time, + Timestamp64_Control *_add +) +{ + *_time += *_add; +} +#endif 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 diff --git a/cpukit/score/src/ts64dividebyinteger.c b/cpukit/score/src/ts64dividebyinteger.c new file mode 100644 index 0000000000..f815078322 --- /dev/null +++ b/cpukit/score/src/ts64dividebyinteger.c @@ -0,0 +1,35 @@ +/** + * @file score/src/ts64dividebyinteger.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +void _Timestamp64_Divide_by_integer( + Timestamp64_Control *_time, + uint32_t _iterations, + Timestamp64_Control *_result +) +{ + *_result = *_time / _iterations; +} +#endif diff --git a/cpukit/score/src/ts64equalto.c b/cpukit/score/src/ts64equalto.c new file mode 100644 index 0000000000..d6c9eca998 --- /dev/null +++ b/cpukit/score/src/ts64equalto.c @@ -0,0 +1,34 @@ +/** + * @file score/src/ts64equalto.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +bool _Timestamp64_Equal_to( + Timestamp64_Control *_lhs, + Timestamp64_Control *_rhs +) +{ + return (*(_lhs) == *(_rhs)); +} +#endif diff --git a/cpukit/score/src/ts64getnanoseconds.c b/cpukit/score/src/ts64getnanoseconds.c new file mode 100644 index 0000000000..86ba1c1b75 --- /dev/null +++ b/cpukit/score/src/ts64getnanoseconds.c @@ -0,0 +1,33 @@ +/** + * @file score/src/ts64toticks.c + */ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +uint32_t _Timestamp64_Get_nanoseconds( + Timestamp64_Control *_time +) +{ + return *(_time) % 1000000000; +} +#endif diff --git a/cpukit/score/src/ts64getseconds.c b/cpukit/score/src/ts64getseconds.c new file mode 100644 index 0000000000..f459ee07a5 --- /dev/null +++ b/cpukit/score/src/ts64getseconds.c @@ -0,0 +1,33 @@ +/** + * @file score/src/ts64getseconds.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +uint32_t _Timestamp64_Get_seconds( + Timestamp64_Control *_time +) +{ + return *(_time) / 1000000000; +} +#endif diff --git a/cpukit/score/src/ts64greaterthan.c b/cpukit/score/src/ts64greaterthan.c new file mode 100644 index 0000000000..571adca4c1 --- /dev/null +++ b/cpukit/score/src/ts64greaterthan.c @@ -0,0 +1,34 @@ +/** + * @file score/src/ts64greaterthan.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +bool _Timestamp64_Greater_than( + Timestamp64_Control *_lhs, + Timestamp64_Control *_rhs +) +{ + return (*(_lhs) > *(_rhs)); +} +#endif diff --git a/cpukit/score/src/ts64lessthan.c b/cpukit/score/src/ts64lessthan.c new file mode 100644 index 0000000000..1df5eb11f8 --- /dev/null +++ b/cpukit/score/src/ts64lessthan.c @@ -0,0 +1,34 @@ +/** + * @file score/src/ts64lessthan.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +bool _Timestamp64_Less_than( + Timestamp64_Control *_lhs, + Timestamp64_Control *_rhs +) +{ + return (*(_lhs) < *(_rhs)); +} +#endif diff --git a/cpukit/score/src/ts64set.c b/cpukit/score/src/ts64set.c new file mode 100644 index 0000000000..f4ed3c40e7 --- /dev/null +++ b/cpukit/score/src/ts64set.c @@ -0,0 +1,39 @@ +/** + * @file score/src/ts64set.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +void _Timestamp64_Set( + Timestamp64_Control *_time, + long _seconds, + long _nanoseconds +) +{ + int64_t time; + + time = (int64_t)_seconds * 1000000000; + time += (int64_t)_nanoseconds; + *_time = time; +} +#endif diff --git a/cpukit/score/src/ts64settozero.c b/cpukit/score/src/ts64settozero.c new file mode 100644 index 0000000000..f5cd78194d --- /dev/null +++ b/cpukit/score/src/ts64settozero.c @@ -0,0 +1,33 @@ +/** + * @file score/src/ts64settozero.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +void _Timestamp64_Set_to_zero( + Timestamp64_Control *_time +) +{ + *_time = 0; +} +#endif diff --git a/cpukit/score/src/ts64subtract.c b/cpukit/score/src/ts64subtract.c new file mode 100644 index 0000000000..be7445b2e6 --- /dev/null +++ b/cpukit/score/src/ts64subtract.c @@ -0,0 +1,35 @@ +/** + * @file score/src/ts64subtract.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +void _Timestamp64_Subtract( + Timestamp64_Control *_start, + Timestamp64_Control *_end, + Timestamp64_Control *_result +) +{ + *_result = *_end - *_start; +} +#endif diff --git a/cpukit/score/src/ts64toticks.c b/cpukit/score/src/ts64toticks.c new file mode 100644 index 0000000000..5594387df8 --- /dev/null +++ b/cpukit/score/src/ts64toticks.c @@ -0,0 +1,39 @@ +/** + * @file score/src/ts64toticks.c + */ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> +#include <rtems/score/tod.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +uint32_t _Timestamp64_To_ticks( + const Timestamp64_Control *time +) +{ + uint32_t ticks; + + ticks = *time / (_TOD_Microseconds_per_tick * 1000); + if ( ticks ) + return ticks; + return 1; +} +#endif diff --git a/cpukit/score/src/ts64totimespec.c b/cpukit/score/src/ts64totimespec.c new file mode 100644 index 0000000000..92c2b690bc --- /dev/null +++ b/cpukit/score/src/ts64totimespec.c @@ -0,0 +1,35 @@ +/** + * @file score/src/ts64totimespec.c +*/ + +/* + * COPYRIGHT (c) 1989-2008. + * 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 <sys/types.h> + +#include <rtems/system.h> +#include <rtems/score/timestamp.h> + +#if defined(CPU_RTEMS_SCORE_TIMESTAMP_IS_INT64) && \ + !defined(CPU_RTEMS_SCORE_TIMESTAMP_INT64_INLINE) +void _Timestamp64_To_timespec( + Timestamp64_Control *_timestamp, + struct timespec *_timespec +) +{ + _timespec->tv_sec = *_timestamp / 1000000000; + _timespec->tv_nsec = *_timestamp % 1000000000; +} +#endif |