summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-13 07:45:29 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-08-18 07:08:51 +0200
commita7af34d0cfdb8b1cfa553fad78339798334963ad (patch)
tree50678af852f84ac1008c263afa5abc97b485e881
parentlibtest: Add output buffer drain and fill (diff)
downloadrtems-a7af34d0cfdb8b1cfa553fad78339798334963ad.tar.bz2
libtest: Add T_do_is_runner()
Update #3199.
-rw-r--r--cpukit/libtest/t-test.c64
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__ */