[PATCH 11/13] rtems: New errors for rtems_signal_catch()

Gedare Bloom gedare at rtems.org
Thu Feb 18 17:32:06 UTC 2021


On Wed, Feb 17, 2021 at 12:30 PM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> Ensure that no invalid modes are set during ASR processing.
>
> Update #4244.
> ---
>  cpukit/rtems/src/signalcatch.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/cpukit/rtems/src/signalcatch.c b/cpukit/rtems/src/signalcatch.c
> index 8ee22e5ec1..da56d26dc5 100644
> --- a/cpukit/rtems/src/signalcatch.c
> +++ b/cpukit/rtems/src/signalcatch.c
> @@ -22,7 +22,10 @@
>  #endif
>
>  #include <rtems/rtems/signalimpl.h>
> +#include <rtems/rtems/modesimpl.h>
>  #include <rtems/rtems/tasksdata.h>
> +#include <rtems/score/schedulerimpl.h>
> +#include <rtems/score/smpimpl.h>
>  #include <rtems/score/threadimpl.h>
>
>  RTEMS_STATIC_ASSERT( RTEMS_DEFAULT_MODES == 0, _ASR_Create_mode_set );
> @@ -37,7 +40,31 @@ rtems_status_code rtems_signal_catch(
>    ASR_Information    *asr;
>    ISR_lock_Context    lock_context;
>
> +#if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
> +  if (
> +    _Modes_Get_interrupt_level( mode_set ) != 0
> +#if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
> +      && _SMP_Need_inter_processor_interrupts()
> +#endif
> +  ) {
> +    return RTEMS_NOT_IMPLEMENTED;
> +  }
> +#endif
> +
>    executing = _Thread_State_acquire_for_executing( &lock_context );
> +
> +#if defined(RTEMS_SMP)
add a brief comment here, the logic a little complicated with
double-negatives, e.g.,
/* Check for non-preempt mode requested with a scheduler that does not
support non-preemption */
> +  if (
> +    !_Modes_Is_preempt( mode_set ) &&
> +      !_Scheduler_Is_non_preempt_mode_supported(
no indent (align the !)

> +        _Thread_Scheduler_get_home( executing )
> +      )
> +  ) {
> +    _Thread_State_release( executing, &lock_context );
> +    return RTEMS_NOT_IMPLEMENTED;
> +  }
> +#endif
> +
>    api = executing->API_Extensions[ THREAD_API_RTEMS ];
>    asr = &api->Signal;
>    asr->handler = asr_handler;
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list