[PATCH] mpci: Simplify expressions

Gedare Bloom gedare at rtems.org
Tue Mar 8 13:56:07 UTC 2022


On Mon, Mar 7, 2022 at 11:52 PM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> Use that rtems_configuration_get_user_multiprocessing_table() returns never
> NULL if RTEMS_MULTIPROCESSING defined.
> ---
>  bsps/m68k/mvme147s/start/bspstart.c |  2 +-
>  bsps/riscv/griscv/include/amba.h    |  3 +--
>  bsps/sparc/leon3/btimer/btimer.c    |  5 ++---
>  bsps/sparc/leon3/include/leon.h     |  3 +--
>  cpukit/libmisc/monitor/mon-editor.c |  6 ------
>  cpukit/libmisc/stackchk/check.c     | 10 ++++------
>  6 files changed, 9 insertions(+), 20 deletions(-)
>
> diff --git a/bsps/m68k/mvme147s/start/bspstart.c b/bsps/m68k/mvme147s/start/bspstart.c
> index 497b644150..e5eb48f108 100644
> --- a/bsps/m68k/mvme147s/start/bspstart.c
> +++ b/bsps/m68k/mvme147s/start/bspstart.c
> @@ -58,7 +58,7 @@ void bsp_start( void )
>
>  #if defined(RTEMS_MULTIPROCESSING)
>    node_number = (uint8_t)
> -    (rtems_configuration_get_user_multiprocessing_table()->node - 1) & 0xF;
> +    rtems_configuration_get_user_multiprocessing_table()->node - 1;

node is never 0?

>  #else
>     node_number = 1;
>  #endif
> diff --git a/bsps/riscv/griscv/include/amba.h b/bsps/riscv/griscv/include/amba.h
> index 292660d5c1..b615389df4 100644
> --- a/bsps/riscv/griscv/include/amba.h
> +++ b/bsps/riscv/griscv/include/amba.h
> @@ -46,8 +46,7 @@
>  #define GRLIB_APB_SLAVES 16
>
>  #if defined(RTEMS_MULTIPROCESSING)
> -  #define GRLIB_CLOCK_INDEX \
> -   (rtems_configuration_get_user_multiprocessing_table() ? GRLIB_Cpu_Index : 0)
> +  #define GRLIB_CLOCK_INDEX GRLIB_Cpu_Index
>  #else
>    #define GRLIB_CLOCK_INDEX 0
>  #endif
> diff --git a/bsps/sparc/leon3/btimer/btimer.c b/bsps/sparc/leon3/btimer/btimer.c
> index 9e9f2b02fc..03bbfe06e7 100644
> --- a/bsps/sparc/leon3/btimer/btimer.c
> +++ b/bsps/sparc/leon3/btimer/btimer.c
> @@ -23,10 +23,9 @@
>
>  #if defined(RTEMS_MULTIPROCESSING)
>    #define LEON3_TIMER_INDEX \
> -      ((rtems_configuration_get_user_multiprocessing_table()) ? \
> -        (rtems_configuration_get_user_multiprocessing_table()->node) - 1 : 1)
> +    (rtems_configuration_get_user_multiprocessing_table()->node)

This is not the same value, but

>  #else
> -  #define LEON3_TIMER_INDEX 0
> +  #define LEON3_TIMER_INDEX 1

I guess this corrects the off-by-1?

>  #endif
>
>  bool benchmark_timer_find_average_overhead;
> diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h
> index 5fadb08052..e03185f927 100644
> --- a/bsps/sparc/leon3/include/leon.h
> +++ b/bsps/sparc/leon3/include/leon.h
> @@ -325,8 +325,7 @@ extern rtems_interrupt_lock LEON3_IrqCtrl_Lock;
>  #define LEON_REG_TIMER_COUNTER_CURRENT_MODE_MASK  0x00000003
>
>  #if defined(RTEMS_MULTIPROCESSING)
> -  #define LEON3_CLOCK_INDEX \
> -   (rtems_configuration_get_user_multiprocessing_table() ? LEON3_Cpu_Index : 0)
> +  #define LEON3_CLOCK_INDEX LEON3_Cpu_Index
>  #else
>    #define LEON3_CLOCK_INDEX 0
>  #endif
> diff --git a/cpukit/libmisc/monitor/mon-editor.c b/cpukit/libmisc/monitor/mon-editor.c
> index 6957fee9c8..bea0fc28ba 100644
> --- a/cpukit/libmisc/monitor/mon-editor.c
> +++ b/cpukit/libmisc/monitor/mon-editor.c
> @@ -499,12 +499,6 @@ rtems_monitor_command_read(char *command,
>    /*
>     * put node number in the prompt if we are multiprocessing
>     */
> -#if defined(RTEMS_MULTIPROCESSING)
> -  if (!rtems_configuration_get_user_multiprocessing_table ())
> -    snprintf (monitor_prompt, sizeof(monitor_prompt), "%s",
> -             (env_prompt == NULL) ? MONITOR_PROMPT: env_prompt);
> -  else /* .... */
> -#endif
>    if (rtems_monitor_default_node != rtems_monitor_node)
>      snprintf (monitor_prompt, sizeof(monitor_prompt),
>                "%" PRId32 "-%s-%" PRId32 "", rtems_monitor_node,
> diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c
> index fa0c3ea1ed..437a0476c3 100644
> --- a/cpukit/libmisc/stackchk/check.c
> +++ b/cpukit/libmisc/stackchk/check.c
> @@ -278,12 +278,10 @@ static void Stack_check_report_blown_task(
>    }
>
>    #if defined(RTEMS_MULTIPROCESSING)
> -    if (rtems_configuration_get_user_multiprocessing_table()) {
> -      printk(
> -        "node: 0x%08" PRIxPTR "\n",
> -          (intptr_t) rtems_configuration_get_user_multiprocessing_table()->node
> -      );
> -    }
> +    printk(
> +      "node: 0x%08" PRIxPTR "\n",
> +        (intptr_t) rtems_configuration_get_user_multiprocessing_table()->node
> +    );
>    #endif
>
>    rtems_fatal(
> --
> 2.34.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list