summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-17 13:35:42 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2021-05-18 08:02:50 +0200
commitd45f87cf3599b3614ea4b126728aedeb51737695 (patch)
treeccd13083533329b75b02e80627948cc5fea77f94
parentscore: Move _Thread_queue_Queue_get_name_and_id() (diff)
downloadrtems-d45f87cf3599b3614ea4b126728aedeb51737695.tar.bz2
score: Add _CPU_Context_switch_no_return()
The __builtin_unreachable() cannot be used with current GCC versions to tell the compiler that a function does not return to the caller, see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99151 Add a no return variant of _CPU_Context_switch() to avoid generation of dead code in _Thread_Start_multitasking() if RTEMS was built with SMP support enabled.
-rw-r--r--bsps/powerpc/shared/cpu_asm.S2
-rw-r--r--cpukit/score/cpu/arm/cpu_asm.S3
-rw-r--r--cpukit/score/cpu/arm/include/rtems/score/cpu.h5
-rw-r--r--cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h32
-rw-r--r--cpukit/score/cpu/powerpc/include/rtems/score/cpu.h5
-rw-r--r--cpukit/score/cpu/riscv/include/rtems/score/cpu.h5
-rw-r--r--cpukit/score/cpu/riscv/riscv-context-switch.S2
-rw-r--r--cpukit/score/cpu/sparc/cpu_asm.S2
-rw-r--r--cpukit/score/cpu/sparc/include/rtems/score/cpu.h5
-rw-r--r--cpukit/score/src/threadstartmultitasking.c2
10 files changed, 58 insertions, 5 deletions
diff --git a/bsps/powerpc/shared/cpu_asm.S b/bsps/powerpc/shared/cpu_asm.S
index e4d627016c..63f6a3fdfe 100644
--- a/bsps/powerpc/shared/cpu_asm.S
+++ b/bsps/powerpc/shared/cpu_asm.S
@@ -258,7 +258,9 @@ PROC (_CPU_Context_restore_fp):
ALIGN (PPC_CACHE_ALIGNMENT, PPC_CACHE_ALIGN_POWER)
PUBLIC_PROC (_CPU_Context_switch)
+ PUBLIC_PROC (_CPU_Context_switch_no_return)
PROC (_CPU_Context_switch):
+PROC (_CPU_Context_switch_no_return):
#ifdef BSP_USE_SYNC_IN_CONTEXT_SWITCH
sync
diff --git a/cpukit/score/cpu/arm/cpu_asm.S b/cpukit/score/cpu/arm/cpu_asm.S
index 66f8ba6032..46eb46b914 100644
--- a/cpukit/score/cpu/arm/cpu_asm.S
+++ b/cpukit/score/cpu/arm/cpu_asm.S
@@ -54,6 +54,9 @@
*/
DEFINE_FUNCTION_ARM(_CPU_Context_switch)
+ .globl _CPU_Context_switch_no_return
+ .set _CPU_Context_switch_no_return, _CPU_Context_switch
+
/* Start saving context */
GET_SELF_CPU_CONTROL r2
ldr r3, [r2, #PER_CPU_ISR_DISPATCH_DISABLE]
diff --git a/cpukit/score/cpu/arm/include/rtems/score/cpu.h b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
index e5b23e7100..dcda4d525c 100644
--- a/cpukit/score/cpu/arm/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/arm/include/rtems/score/cpu.h
@@ -465,6 +465,11 @@ void _CPU_ISR_install_vector(
*/
void _CPU_Context_switch( Context_Control *run, Context_Control *heir );
+RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
+ Context_Control *executing,
+ Context_Control *heir
+);
+
RTEMS_NO_RETURN void _CPU_Context_restore( Context_Control *new_context );
#if defined(ARM_MULTILIB_ARCH_V7M)
diff --git a/cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h b/cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h
index c067501502..09f34b4acd 100644
--- a/cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/no_cpu/include/rtems/score/cpu.h
@@ -1054,23 +1054,47 @@ void _CPU_ISR_install_vector(
void *_CPU_Thread_Idle_body( uintptr_t ignored );
/**
+ * @brief Performs a context switch from the executing thread to the heir
+ * thread.
+ *
* @addtogroup RTEMSScoreCPUExampleContext
*
- * This routine switches from the run context to the heir context.
+ * This routine switches from the executing context to the heir context.
+ *
+ * @param[out] executing points to the context of the currently executing task.
*
- * @param[in] run points to the context of the currently executing task
- * @param[in] heir points to the context of the heir task
+ * @param[in, out] heir points to the context of the heir task.
*
* Port Specific Information:
*
* XXX document implementation including references if appropriate
*/
void _CPU_Context_switch(
- Context_Control *run,
+ Context_Control *executing,
Context_Control *heir
);
/**
+ * @brief Performs a context switch from the executing thread to the heir
+ * thread and does not return.
+ *
+ * @addtogroup RTEMSScoreCPUExampleContext
+ *
+ * This routine shall be a strong alias to _CPU_Context_switch(). It shall be
+ * provided for all target architectures which support an SMP build
+ * configuration (RTEMS_SMP). The purpose is help to compiler to avoid
+ * generation of dead code in _Thread_Start_multitasking().
+ *
+ * @param[out] executing points to the context of the currently executing task.
+ *
+ * @param[in, out] heir points to the context of the heir task.
+ */
+RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
+ Context_Control *executing,
+ Context_Control *heir
+);
+
+/**
* @addtogroup RTEMSScoreCPUExampleContext
*
* This routine is generally used only to restart self in an
diff --git a/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h b/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h
index 996b6f8e60..f22e1cd7ec 100644
--- a/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/powerpc/include/rtems/score/cpu.h
@@ -914,6 +914,11 @@ void _CPU_Context_switch(
Context_Control *heir
);
+RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
+ Context_Control *executing,
+ Context_Control *heir
+);
+
/*
* _CPU_Context_restore
*
diff --git a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
index 38eb92394d..a44b815b12 100644
--- a/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/riscv/include/rtems/score/cpu.h
@@ -383,6 +383,11 @@ void _CPU_Context_switch(
Context_Control *heir
);
+RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
+ Context_Control *executing,
+ Context_Control *heir
+);
+
/*
* _CPU_Context_restore
*
diff --git a/cpukit/score/cpu/riscv/riscv-context-switch.S b/cpukit/score/cpu/riscv/riscv-context-switch.S
index 96c117b3de..830f8629a4 100644
--- a/cpukit/score/cpu/riscv/riscv-context-switch.S
+++ b/cpukit/score/cpu/riscv/riscv-context-switch.S
@@ -37,9 +37,11 @@
.align 2
PUBLIC(_CPU_Context_switch)
+PUBLIC(_CPU_Context_switch_no_return)
PUBLIC(_CPU_Context_restore)
SYM(_CPU_Context_switch):
+SYM(_CPU_Context_switch_no_return):
GET_SELF_CPU_CONTROL a2
lw a3, PER_CPU_ISR_DISPATCH_DISABLE(a2)
diff --git a/cpukit/score/cpu/sparc/cpu_asm.S b/cpukit/score/cpu/sparc/cpu_asm.S
index e884fb2f9e..a7b87ad5f8 100644
--- a/cpukit/score/cpu/sparc/cpu_asm.S
+++ b/cpukit/score/cpu/sparc/cpu_asm.S
@@ -57,7 +57,9 @@
.align 4
PUBLIC(_CPU_Context_switch)
+ PUBLIC(_CPU_Context_switch_no_return)
SYM(_CPU_Context_switch):
+SYM(_CPU_Context_switch_no_return):
st %g5, [%o0 + G5_OFFSET] ! save the global registers
/*
diff --git a/cpukit/score/cpu/sparc/include/rtems/score/cpu.h b/cpukit/score/cpu/sparc/include/rtems/score/cpu.h
index 8c5330b8ce..6c167e3f08 100644
--- a/cpukit/score/cpu/sparc/include/rtems/score/cpu.h
+++ b/cpukit/score/cpu/sparc/include/rtems/score/cpu.h
@@ -971,6 +971,11 @@ void _CPU_Context_switch(
Context_Control *heir
);
+RTEMS_NO_RETURN void _CPU_Context_switch_no_return(
+ Context_Control *executing,
+ Context_Control *heir
+);
+
/**
* @brief SPARC specific context restore.
*
diff --git a/cpukit/score/src/threadstartmultitasking.c b/cpukit/score/src/threadstartmultitasking.c
index a0b465a226..094a535394 100644
--- a/cpukit/score/src/threadstartmultitasking.c
+++ b/cpukit/score/src/threadstartmultitasking.c
@@ -59,7 +59,7 @@ void _Thread_Start_multitasking( void )
* executing to the currently selected heir thread.
*/
_CPU_Context_Set_is_executing( &trash, true );
- _CPU_Context_switch( &trash, &heir->Registers );
+ _CPU_Context_switch_no_return( &trash, &heir->Registers );
RTEMS_UNREACHABLE();
}
#else