[rtems commit] record: Pass bintime to client handlers
Sebastian Huber
sebh at rtems.org
Sat Aug 17 18:16:36 UTC 2019
Module: rtems
Branch: master
Commit: c91f6f5f4e236688ba8acb204fe85dc88adaaf0e
Changeset: http://git.rtems.org/rtems/commit/?id=c91f6f5f4e236688ba8acb204fe85dc88adaaf0e
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Sat Aug 17 14:49:42 2019 +0200
record: Pass bintime to client handlers
This is a minor optimization.
---
cpukit/include/rtems/recordclient.h | 30 ++++++++++++++++++++++++++++--
cpukit/libtrace/record/record-client.c | 9 +--------
testsuites/libtests/record02/init.c | 14 +++++++++++---
3 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/cpukit/include/rtems/recordclient.h b/cpukit/include/rtems/recordclient.h
index 35963bd..d38a8a7 100644
--- a/cpukit/include/rtems/recordclient.h
+++ b/cpukit/include/rtems/recordclient.h
@@ -65,8 +65,7 @@ typedef enum {
} rtems_record_client_status;
typedef rtems_record_client_status ( *rtems_record_client_handler )(
- uint32_t seconds,
- uint32_t nanoseconds,
+ uint64_t bt,
uint32_t cpu,
rtems_record_event event,
uint64_t data,
@@ -196,6 +195,33 @@ void rtems_record_client_destroy(
rtems_record_client_context *ctx
);
+static inline uint64_t rtems_record_client_bintime_to_nanoseconds(
+ uint64_t bt
+)
+{
+ uint64_t ns_per_sec;
+ uint64_t nanoseconds;
+
+ ns_per_sec = 1000000000ULL;
+ nanoseconds = ns_per_sec * ( (uint32_t) ( bt >> 32 ) );
+ nanoseconds += ( ns_per_sec * (uint32_t) bt ) >> 32;
+
+ return nanoseconds;
+}
+
+static inline void rtems_record_client_bintime_to_seconds_and_nanoseconds(
+ uint64_t bt,
+ uint32_t *seconds,
+ uint32_t *nanoseconds
+)
+{
+ uint64_t ns_per_sec;
+
+ ns_per_sec = 1000000000ULL;
+ *seconds = (uint32_t) ( bt >> 32 );
+ *nanoseconds = (uint32_t) ( ( ns_per_sec * (uint32_t) bt ) >> 32 );
+}
+
/** @} */
#ifdef __cplusplus
diff --git a/cpukit/libtrace/record/record-client.c b/cpukit/libtrace/record/record-client.c
index 153b8e4..cfe05fd 100644
--- a/cpukit/libtrace/record/record-client.c
+++ b/cpukit/libtrace/record/record-client.c
@@ -88,15 +88,8 @@ static rtems_record_client_status call_handler(
uint64_t data
)
{
- uint32_t seconds;
- uint32_t nanosec;
-
- seconds = (uint32_t) ( bt >> 32 );
- nanosec = (uint32_t) ( ( UINT64_C( 1000000000 ) * (uint32_t) bt ) >> 32 );
-
return ( *ctx->handler )(
- seconds,
- nanosec,
+ bt,
ctx->cpu,
event,
data,
diff --git a/testsuites/libtests/record02/init.c b/testsuites/libtests/record02/init.c
index f1c93f7..5979b5b 100644
--- a/testsuites/libtests/record02/init.c
+++ b/testsuites/libtests/record02/init.c
@@ -46,8 +46,7 @@ typedef struct {
static test_context test_instance;
static rtems_record_client_status client_handler(
- uint32_t seconds,
- uint32_t nanoseconds,
+ uint64_t bt,
uint32_t cpu,
rtems_record_event event,
uint64_t data,
@@ -56,7 +55,16 @@ static rtems_record_client_status client_handler(
{
(void) arg;
- if ( seconds != 0 && nanoseconds != 0 ) {
+ if ( bt != 0 ) {
+ uint32_t seconds;
+ uint32_t nanoseconds;
+
+ rtems_record_client_bintime_to_seconds_and_nanoseconds(
+ bt,
+ &seconds,
+ &nanoseconds
+ );
+
printf( "%" PRIu32 ".%09" PRIu32 ":", seconds, nanoseconds );
} else {
printf( "*:" );
More information about the vc
mailing list