diff options
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/include/rtems/test.h | 18 | ||||
-rw-r--r-- | cpukit/libtest/t-test-thread-switch.c | 24 |
2 files changed, 22 insertions, 20 deletions
diff --git a/cpukit/include/rtems/test.h b/cpukit/include/rtems/test.h index 10ff665107..f95433bc7c 100644 --- a/cpukit/include/rtems/test.h +++ b/cpukit/include/rtems/test.h @@ -89,10 +89,8 @@ typedef struct T_fixture_node { #if defined(__GNUC__) || __STDC_VERSION__ >= 199409L #define T_ZERO_LENGTH_ARRAY -#define T_ZERO_LENGTH_ARRAY_EXTENSION(n) (n) #else #define T_ZERO_LENGTH_ARRAY 1 -#define T_ZERO_LENGTH_ARRAY_EXTENSION(n) ((n) - 1) #endif /** @} */ @@ -2434,22 +2432,26 @@ typedef struct { size_t recorded; size_t capacity; uint64_t switches; +} T_thread_switch_header; + +typedef struct { + T_thread_switch_header header; T_thread_switch_event events[T_ZERO_LENGTH_ARRAY]; } T_thread_switch_log; typedef struct { - T_thread_switch_log log; - T_thread_switch_event events[T_ZERO_LENGTH_ARRAY_EXTENSION(2)]; + T_thread_switch_header header; + T_thread_switch_event events[2]; } T_thread_switch_log_2; typedef struct { - T_thread_switch_log log; - T_thread_switch_event events[T_ZERO_LENGTH_ARRAY_EXTENSION(4)]; + T_thread_switch_header header; + T_thread_switch_event events[4]; } T_thread_switch_log_4; typedef struct { - T_thread_switch_log log; - T_thread_switch_event events[T_ZERO_LENGTH_ARRAY_EXTENSION(10)]; + T_thread_switch_header header; + T_thread_switch_event events[10]; } T_thread_switch_log_10; T_thread_switch_log *T_thread_switch_record(T_thread_switch_log *); diff --git a/cpukit/libtest/t-test-thread-switch.c b/cpukit/libtest/t-test-thread-switch.c index 87ad4651fc..60179aaa40 100644 --- a/cpukit/libtest/t-test-thread-switch.c +++ b/cpukit/libtest/t-test-thread-switch.c @@ -96,11 +96,11 @@ T_thread_switch_recorder(Thread_Control *executing, Thread_Control *heir) if (log != NULL) { size_t recorded; - ++log->switches; - recorded = log->recorded; + ++log->header.switches; + recorded = log->header.recorded; - if (recorded < log->capacity) { - log->recorded = recorded + 1; + if (recorded < log->header.capacity) { + log->header.recorded = recorded + 1; log->events[recorded].executing = executing->Object.id; log->events[recorded].heir = heir->Object.id; log->events[recorded].cpu = @@ -127,8 +127,8 @@ T_thread_switch_record(T_thread_switch_log *log) } if (log != NULL) { - log->recorded = 0; - log->switches = 0; + log->header.recorded = 0; + log->header.switches = 0; } rtems_interrupt_lock_acquire(&ctx->lock, &lock_context); @@ -142,20 +142,20 @@ T_thread_switch_record(T_thread_switch_log *log) T_thread_switch_log * T_thread_switch_record_2(T_thread_switch_log_2 *log) { - log->log.capacity = 2; - return T_thread_switch_record(&log->log); + log->header.capacity = T_ARRAY_SIZE(log->events); + return T_thread_switch_record((T_thread_switch_log *)log); } T_thread_switch_log * T_thread_switch_record_4(T_thread_switch_log_4 *log) { - log->log.capacity = 4; - return T_thread_switch_record(&log->log); + log->header.capacity = T_ARRAY_SIZE(log->events); + return T_thread_switch_record((T_thread_switch_log *)log); } T_thread_switch_log * T_thread_switch_record_10(T_thread_switch_log_10 *log) { - log->log.capacity = 10; - return T_thread_switch_record(&log->log); + log->header.capacity = T_ARRAY_SIZE(log->events); + return T_thread_switch_record((T_thread_switch_log *)log); } |