diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-13 07:45:29 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-18 07:08:51 +0200 |
commit | a7af34d0cfdb8b1cfa553fad78339798334963ad (patch) | |
tree | 50678af852f84ac1008c263afa5abc97b485e881 /cpukit/libtest | |
parent | e67eff2b53d4178a66f48de6d496e6272898761a (diff) |
libtest: Add T_do_is_runner()
Update #3199.
Diffstat (limited to 'cpukit/libtest')
-rw-r--r-- | cpukit/libtest/t-test.c | 64 |
1 files changed, 34 insertions, 30 deletions
diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c index e8d0542c31..92aed62b9b 100644 --- a/cpukit/libtest/t-test.c +++ b/cpukit/libtest/t-test.c @@ -92,6 +92,40 @@ const T_check_context T_special = { .flags = T_CHECK_FMT | T_CHECK_QUIET }; +static bool +T_do_is_runner(T_context *ctx) +{ + bool is_runner; +#ifdef __rtems__ + ISR_Level level; + const Per_CPU_Control *cpu_self; +#endif + +#ifdef __rtems__ + _ISR_Local_disable(level); + cpu_self = _Per_CPU_Get(); + + if (ctx->runner_thread != NULL) { + is_runner = cpu_self->isr_nest_level == 0 && + _Per_CPU_Get_executing(cpu_self) == ctx->runner_thread; + } else { + is_runner = cpu_self == ctx->runner_cpu; + } + + _ISR_Local_enable(level); +#else + is_runner = ctx->runner_valid && + pthread_equal(pthread_self(), ctx->runner_thread) != 0; +#endif + + return is_runner; +} + +bool T_is_runner(void) +{ + return T_do_is_runner(&T_instance); +} + typedef struct { char *s; size_t n; @@ -952,36 +986,6 @@ T_main(const T_config *config) return T_do_run_finalize(ctx) ? 0 : 1; } -bool T_is_runner(void) -{ - T_context *ctx; - bool is_runner; -#ifdef __rtems__ - ISR_Level level; - const Per_CPU_Control *cpu_self; -#endif - - ctx = &T_instance; -#ifdef __rtems__ - _ISR_Local_disable(level); - cpu_self = _Per_CPU_Get(); - - if (ctx->runner_thread != NULL) { - is_runner = cpu_self->isr_nest_level == 0 && - _Per_CPU_Get_executing(cpu_self) == ctx->runner_thread; - } else { - is_runner = cpu_self == ctx->runner_cpu; - } - - _ISR_Local_enable(level); -#else - is_runner = ctx->runner_valid && - pthread_equal(pthread_self(), ctx->runner_thread) != 0; -#endif - - return is_runner; -} - #ifdef __rtems__ RTEMS_LINKER_ROSET(_T, T_case_context *); #endif /* __rtems__ */ |