[rtems commit] libtest: Add T_do_is_runner()

Sebastian Huber sebh at rtems.org
Tue Aug 18 05:15:14 UTC 2020


Module:    rtems
Branch:    master
Commit:    a7af34d0cfdb8b1cfa553fad78339798334963ad
Changeset: http://git.rtems.org/rtems/commit/?id=a7af34d0cfdb8b1cfa553fad78339798334963ad

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Aug 13 07:45:29 2020 +0200

libtest: Add T_do_is_runner()

Update #3199.

---

 cpukit/libtest/t-test.c | 64 ++++++++++++++++++++++++++-----------------------
 1 file changed, 34 insertions(+), 30 deletions(-)

diff --git a/cpukit/libtest/t-test.c b/cpukit/libtest/t-test.c
index e8d0542..92aed62 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__ */



More information about the vc mailing list