[PATCH] score: Add _Thread_Dispatch_direct_no_return()
Gedare Bloom
gedare at rtems.org
Sun May 2 13:58:38 UTC 2021
ok, that's annoying.
On Fri, Apr 30, 2021 at 9:02 AM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> 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 _Thread_Dispatch_direct() to avoid generation
> of dead code.
> ---
> cpukit/include/rtems/score/threaddispatch.h | 11 +++++++++++
> cpukit/posix/src/pthreadexit.c | 2 +-
> cpukit/rtems/src/taskexit.c | 2 +-
> cpukit/score/src/threaddispatch.c | 3 +++
> cpukit/score/src/threadrestart.c | 4 ++--
> 5 files changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/cpukit/include/rtems/score/threaddispatch.h b/cpukit/include/rtems/score/threaddispatch.h
> index 707b449771..7f3673a0d5 100644
> --- a/cpukit/include/rtems/score/threaddispatch.h
> +++ b/cpukit/include/rtems/score/threaddispatch.h
> @@ -125,6 +125,17 @@ void _Thread_Dispatch( void );
> */
> void _Thread_Dispatch_direct( Per_CPU_Control *cpu_self );
>
> +/**
> + * @brief Directly do a thread dispatch and do not return.
> + *
> + * @param cpu_self is the current processor.
> + *
> + * @see _Thread_Dispatch_direct().
> + */
> +RTEMS_NO_RETURN void _Thread_Dispatch_direct_no_return(
> + Per_CPU_Control *cpu_self
> +);
> +
> /**
> * @brief Performs a thread dispatch on the current processor.
> *
> diff --git a/cpukit/posix/src/pthreadexit.c b/cpukit/posix/src/pthreadexit.c
> index 502476d141..657497010b 100644
> --- a/cpukit/posix/src/pthreadexit.c
> +++ b/cpukit/posix/src/pthreadexit.c
> @@ -35,6 +35,6 @@ void pthread_exit( void *value_ptr )
>
> _Thread_Exit( executing, THREAD_LIFE_TERMINATING, value_ptr );
>
> - _Thread_Dispatch_direct( cpu_self );
> + _Thread_Dispatch_direct_no_return( cpu_self );
> RTEMS_UNREACHABLE();
> }
> diff --git a/cpukit/rtems/src/taskexit.c b/cpukit/rtems/src/taskexit.c
> index c08089e956..4c8420d255 100644
> --- a/cpukit/rtems/src/taskexit.c
> +++ b/cpukit/rtems/src/taskexit.c
> @@ -42,6 +42,6 @@ void rtems_task_exit( void )
> NULL
> );
>
> - _Thread_Dispatch_direct( cpu_self );
> + _Thread_Dispatch_direct_no_return( cpu_self );
> RTEMS_UNREACHABLE();
> }
> diff --git a/cpukit/score/src/threaddispatch.c b/cpukit/score/src/threaddispatch.c
> index 2fd125dd76..fd3f4eda4d 100644
> --- a/cpukit/score/src/threaddispatch.c
> +++ b/cpukit/score/src/threaddispatch.c
> @@ -358,6 +358,9 @@ void _Thread_Dispatch_direct( Per_CPU_Control *cpu_self )
> _Thread_Do_dispatch( cpu_self, level );
> }
>
> +RTEMS_ALIAS( _Thread_Dispatch_direct ) void
> +_Thread_Dispatch_direct_no_return( Per_CPU_Control * );
> +
> void _Thread_Dispatch_enable( Per_CPU_Control *cpu_self )
> {
> uint32_t disable_level = cpu_self->thread_dispatch_disable_level;
> diff --git a/cpukit/score/src/threadrestart.c b/cpukit/score/src/threadrestart.c
> index 3c0190164e..364d67d04e 100644
> --- a/cpukit/score/src/threadrestart.c
> +++ b/cpukit/score/src/threadrestart.c
> @@ -288,7 +288,7 @@ void _Thread_Life_action_handler(
> if ( _Thread_Is_life_terminating( previous_life_state ) ) {
> cpu_self = _Thread_Wait_for_join( executing, cpu_self );
> _Thread_Make_zombie( executing );
> - _Thread_Dispatch_direct( cpu_self );
> + _Thread_Dispatch_direct_no_return( cpu_self );
> RTEMS_UNREACHABLE();
> }
>
> @@ -610,7 +610,7 @@ void _Thread_Restart_self(
> _Thread_Wait_release_default( executing, lock_context );
>
> _Thread_Priority_update( &queue_context );
> - _Thread_Dispatch_direct( cpu_self );
> + _Thread_Dispatch_direct_no_return( cpu_self );
> RTEMS_UNREACHABLE();
> }
>
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
More information about the devel
mailing list