[PATCH] rtems: Use RTEMS_WHO_AM_I for rtems_task_ident()

Joel Sherrill joel at rtems.org
Thu Nov 18 18:42:46 UTC 2021


This should be OK to push. Plus the minor patch to the documentation.

--joel

On Thu, Nov 18, 2021 at 9:55 AM Sebastian Huber
<sebastian.huber at embedded-brains.de> wrote:
>
> ---
>  cpukit/include/rtems/rtems/tasks.h        | 3 ++-
>  cpukit/rtems/src/taskident.c              | 3 ++-
>  testsuites/libtests/malloctest/task1.c    | 2 +-
>  testsuites/libtests/stackchk/task1.c      | 2 +-
>  testsuites/mptests/mp01/task1.c           | 2 +-
>  testsuites/mptests/mp03/task1.c           | 2 +-
>  testsuites/mptests/mp04/task1.c           | 2 +-
>  testsuites/samples/base_mp/apptask.c      | 2 +-
>  testsuites/samples/base_sp/apptask.c      | 2 +-
>  testsuites/samples/ticker/tasks.c         | 2 +-
>  testsuites/smptests/smp08/tasks.c         | 2 +-
>  testsuites/smptests/smpaffinity01/init.c  | 2 +-
>  testsuites/sptests/sp19/first.c           | 2 +-
>  testsuites/sptests/sp19/fptask.c          | 2 +-
>  testsuites/sptests/sp19/task1.c           | 2 +-
>  testsuites/sptests/sp24/task1.c           | 2 +-
>  testsuites/sptests/sp30/task1.c           | 2 +-
>  testsuites/sptests/sp42/init.c            | 2 +-
>  testsuites/sptests/sp76/init.c            | 2 +-
>  testsuites/sptests/spcbssched01/task1.c   | 2 +-
>  testsuites/sptests/spedfsched01/task1.c   | 2 +-
>  testsuites/sptests/spsimplesched01/init.c | 2 +-
>  testsuites/sptests/spsimplesched02/init.c | 2 +-
>  testsuites/sptests/sptask_err04/task1.c   | 4 ++--
>  24 files changed, 27 insertions(+), 25 deletions(-)
>
> diff --git a/cpukit/include/rtems/rtems/tasks.h b/cpukit/include/rtems/rtems/tasks.h
> index 8c6e8a3bca..0392586759 100644
> --- a/cpukit/include/rtems/rtems/tasks.h
> +++ b/cpukit/include/rtems/rtems/tasks.h
> @@ -1267,7 +1267,8 @@ rtems_status_code rtems_task_construct(
>   * This directive obtains a task identifier associated with the task name
>   * specified in ``name``.
>   *
> - * A task may obtain its own identifier by specifying #RTEMS_SELF for the name.
> + * A task may obtain its own identifier by specifying #RTEMS_WHO_AM_I for the
> + * name.
>   *
>   * The node to search is specified in ``node``.  It shall be
>   *
> diff --git a/cpukit/rtems/src/taskident.c b/cpukit/rtems/src/taskident.c
> index 74a0a53982..89c2c7ce7e 100644
> --- a/cpukit/rtems/src/taskident.c
> +++ b/cpukit/rtems/src/taskident.c
> @@ -40,6 +40,7 @@
>  #endif
>
>  #include <rtems/rtems/tasksimpl.h>
> +#include <rtems/rtems/object.h>
>  #include <rtems/rtems/objectimpl.h>
>  #include <rtems/score/percpu.h>
>
> @@ -53,7 +54,7 @@ rtems_status_code rtems_task_ident(
>      return RTEMS_INVALID_ADDRESS;
>    }
>
> -  if ( name == OBJECTS_ID_OF_SELF ) {
> +  if ( name == RTEMS_WHO_AM_I ) {
>      *id = _Thread_Get_executing()->Object.id;
>      return RTEMS_SUCCESSFUL;
>    }
> diff --git a/testsuites/libtests/malloctest/task1.c b/testsuites/libtests/malloctest/task1.c
> index 753a74e77a..4f0309af5a 100644
> --- a/testsuites/libtests/malloctest/task1.c
> +++ b/testsuites/libtests/malloctest/task1.c
> @@ -34,7 +34,7 @@ rtems_task Task_1_through_5(
>    unsigned char *mem_ptr;
>    int mem_amt;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    while (TRUE)
> diff --git a/testsuites/libtests/stackchk/task1.c b/testsuites/libtests/stackchk/task1.c
> index 7a9f488ff0..4e08d20819 100644
> --- a/testsuites/libtests/stackchk/task1.c
> +++ b/testsuites/libtests/stackchk/task1.c
> @@ -25,7 +25,7 @@ rtems_task Task_1_through_3(
>    rtems_time_of_day time;
>    rtems_status_code status;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    while( FOREVER ) {
> diff --git a/testsuites/mptests/mp01/task1.c b/testsuites/mptests/mp01/task1.c
> index 50821e1b49..18682130aa 100644
> --- a/testsuites/mptests/mp01/task1.c
> +++ b/testsuites/mptests/mp01/task1.c
> @@ -35,7 +35,7 @@ rtems_task Test_task(
>    rtems_id          tid;
>    rtems_time_of_day time;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    status = rtems_clock_get_tod( &time );
> diff --git a/testsuites/mptests/mp03/task1.c b/testsuites/mptests/mp03/task1.c
> index 48682e032c..9b0c1b2459 100644
> --- a/testsuites/mptests/mp03/task1.c
> +++ b/testsuites/mptests/mp03/task1.c
> @@ -94,7 +94,7 @@ rtems_task Test_task(
>    rtems_id          tid;
>    rtems_status_code status;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    puts( "Getting TID of remote task" );
> diff --git a/testsuites/mptests/mp04/task1.c b/testsuites/mptests/mp04/task1.c
> index 878effd237..6e350d8527 100644
> --- a/testsuites/mptests/mp04/task1.c
> +++ b/testsuites/mptests/mp04/task1.c
> @@ -33,7 +33,7 @@ rtems_task Test_task(
>    rtems_task_priority previous_priority;
>    rtems_task_priority previous_priority_1;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    puts( "Getting TID of remote task" );
> diff --git a/testsuites/samples/base_mp/apptask.c b/testsuites/samples/base_mp/apptask.c
> index e54e08afe8..063328ed42 100644
> --- a/testsuites/samples/base_mp/apptask.c
> +++ b/testsuites/samples/base_mp/apptask.c
> @@ -32,7 +32,7 @@ rtems_task Application_task(
>    rtems_id          tid;
>    rtems_status_code status;
>
> -  rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    (void) status;
>    printf( "This task was invoked with the node argument (%" PRIdrtems_task_argument ")\n", node );
>    printf( "This task has the id of 0x%" PRIxrtems_id "\n",  tid );
> diff --git a/testsuites/samples/base_sp/apptask.c b/testsuites/samples/base_sp/apptask.c
> index f450f71467..02df777bea 100644
> --- a/testsuites/samples/base_sp/apptask.c
> +++ b/testsuites/samples/base_sp/apptask.c
> @@ -34,7 +34,7 @@ rtems_task Application_task(
>    rtems_status_code status;
>    unsigned int      a = (unsigned int) argument;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "ident" );
>
>    printf(
> diff --git a/testsuites/samples/ticker/tasks.c b/testsuites/samples/ticker/tasks.c
> index 12e806884d..7ff6eb7319 100644
> --- a/testsuites/samples/ticker/tasks.c
> +++ b/testsuites/samples/ticker/tasks.c
> @@ -30,7 +30,7 @@ rtems_task Test_task(
>    uint32_t          task_index;
>    rtems_status_code status;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "task ident" );
>
>    task_index = task_number( tid );
> diff --git a/testsuites/smptests/smp08/tasks.c b/testsuites/smptests/smp08/tasks.c
> index 40a097d034..28271253b8 100644
> --- a/testsuites/smptests/smp08/tasks.c
> +++ b/testsuites/smptests/smp08/tasks.c
> @@ -28,7 +28,7 @@ rtems_task Test_task(
>    p = rtems_object_get_name( RTEMS_SELF, 5, name );
>    rtems_test_assert( p != NULL );
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    rtems_test_assert( status == RTEMS_SUCCESSFUL );
>    task_index = task_number( tid );
>    for ( ; ; ) {
> diff --git a/testsuites/smptests/smpaffinity01/init.c b/testsuites/smptests/smpaffinity01/init.c
> index 9ec687d816..e0065bfcb0 100644
> --- a/testsuites/smptests/smpaffinity01/init.c
> +++ b/testsuites/smptests/smpaffinity01/init.c
> @@ -213,7 +213,7 @@ static void Init(rtems_task_argument arg)
>    TEST_BEGIN();
>
>    /* Initialize thread id */
> -  sc = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &Init_id );
> +  sc = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &Init_id );
>    directive_failed( sc, "Identify Init Task" );
>
>    Validate_setaffinity_errors();
> diff --git a/testsuites/sptests/sp19/first.c b/testsuites/sptests/sp19/first.c
> index 69ff29762f..00da9edd6e 100644
> --- a/testsuites/sptests/sp19/first.c
> +++ b/testsuites/sptests/sp19/first.c
> @@ -26,7 +26,7 @@ rtems_task First_FP_task(
>    INTEGER_DECLARE;
>    FP_DECLARE;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    task_index = task_number( tid );
> diff --git a/testsuites/sptests/sp19/fptask.c b/testsuites/sptests/sp19/fptask.c
> index 5ffff37f7e..c91a163f47 100644
> --- a/testsuites/sptests/sp19/fptask.c
> +++ b/testsuites/sptests/sp19/fptask.c
> @@ -27,7 +27,7 @@ rtems_task FP_task(
>    INTEGER_DECLARE;
>    FP_DECLARE;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident of self" );
>
>    task_index = task_number( tid );
> diff --git a/testsuites/sptests/sp19/task1.c b/testsuites/sptests/sp19/task1.c
> index 912ed26ac6..b5cbdcd181 100644
> --- a/testsuites/sptests/sp19/task1.c
> +++ b/testsuites/sptests/sp19/task1.c
> @@ -24,7 +24,7 @@ rtems_task Task_1(
>    uint32_t          task_index;
>    INTEGER_DECLARE;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    task_index = task_number( tid );
> diff --git a/testsuites/sptests/sp24/task1.c b/testsuites/sptests/sp24/task1.c
> index 9a2de67f40..d6f51f6333 100644
> --- a/testsuites/sptests/sp24/task1.c
> +++ b/testsuites/sptests/sp24/task1.c
> @@ -30,7 +30,7 @@ rtems_task Task_1_through_3(
>    rtems_time_of_day time;
>    rtems_status_code status;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident of self" );
>
>    while ( FOREVER )  {
> diff --git a/testsuites/sptests/sp30/task1.c b/testsuites/sptests/sp30/task1.c
> index da4b0d20e7..56aa6aa4ab 100644
> --- a/testsuites/sptests/sp30/task1.c
> +++ b/testsuites/sptests/sp30/task1.c
> @@ -30,7 +30,7 @@ rtems_task Task_1_through_3(
>    rtems_time_of_day time;
>    rtems_status_code status;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident of self" );
>
>    while ( FOREVER )  {
> diff --git a/testsuites/sptests/sp42/init.c b/testsuites/sptests/sp42/init.c
> index 10e49275e5..0004694741 100644
> --- a/testsuites/sptests/sp42/init.c
> +++ b/testsuites/sptests/sp42/init.c
> @@ -74,7 +74,7 @@ static rtems_task Locker_task(
>    rtems_status_code   status;
>    rtems_task_argument my_obtain_counter;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    rtems_test_assert( task_index == task_number( tid ) - 1 );
> diff --git a/testsuites/sptests/sp76/init.c b/testsuites/sptests/sp76/init.c
> index c7e451c32a..6315850b51 100644
> --- a/testsuites/sptests/sp76/init.c
> +++ b/testsuites/sptests/sp76/init.c
> @@ -49,7 +49,7 @@ static rtems_task Init(
>
>    TEST_BEGIN();
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &id );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &id );
>    directive_failed( status, "task ident" );
>
>    /* to make sure it is equal to TA2 */
> diff --git a/testsuites/sptests/spcbssched01/task1.c b/testsuites/sptests/spcbssched01/task1.c
> index f5d180831f..1e51b80966 100644
> --- a/testsuites/sptests/spcbssched01/task1.c
> +++ b/testsuites/sptests/spcbssched01/task1.c
> @@ -31,7 +31,7 @@ rtems_task Task_1_through_3(
>    rtems_status_code status;
>    rtems_interval    ticks;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    ticks = RTEMS_MILLISECONDS_TO_TICKS( task_number( tid ) * 5 * 1000 );
> diff --git a/testsuites/sptests/spedfsched01/task1.c b/testsuites/sptests/spedfsched01/task1.c
> index f5d180831f..1e51b80966 100644
> --- a/testsuites/sptests/spedfsched01/task1.c
> +++ b/testsuites/sptests/spedfsched01/task1.c
> @@ -31,7 +31,7 @@ rtems_task Task_1_through_3(
>    rtems_status_code status;
>    rtems_interval    ticks;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "rtems_task_ident" );
>
>    ticks = RTEMS_MILLISECONDS_TO_TICKS( task_number( tid ) * 5 * 1000 );
> diff --git a/testsuites/sptests/spsimplesched01/init.c b/testsuites/sptests/spsimplesched01/init.c
> index f2a06732d8..0bb05bf137 100644
> --- a/testsuites/sptests/spsimplesched01/init.c
> +++ b/testsuites/sptests/spsimplesched01/init.c
> @@ -34,7 +34,7 @@ rtems_task Test_task(
>    uint32_t           task_index;
>    rtems_status_code  status;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "task ident" );
>
>    task_index = task_number( tid );
> diff --git a/testsuites/sptests/spsimplesched02/init.c b/testsuites/sptests/spsimplesched02/init.c
> index d19d3553d9..1366c93d7b 100644
> --- a/testsuites/sptests/spsimplesched02/init.c
> +++ b/testsuites/sptests/spsimplesched02/init.c
> @@ -38,7 +38,7 @@ rtems_task Test_task(
>    rtems_id          tid;
>    rtems_status_code status;
>
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &tid );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &tid );
>    directive_failed( status, "wake after" );
>
>    for ( ; ; ) {
> diff --git a/testsuites/sptests/sptask_err04/task1.c b/testsuites/sptests/sptask_err04/task1.c
> index c1f59d81fb..ba93d67da7 100644
> --- a/testsuites/sptests/sptask_err04/task1.c
> +++ b/testsuites/sptests/sptask_err04/task1.c
> @@ -50,7 +50,7 @@ rtems_task Task_1(
>    puts( "TA1 - rtems_task_delete - RTEMS_INVALID_ID" );
>
>    /* NULL param */
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, NULL );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, NULL );
>    fatal_directive_status(
>      status,
>      RTEMS_INVALID_ADDRESS,
> @@ -59,7 +59,7 @@ rtems_task Task_1(
>    puts( "TA1 - rtems_task_ident - RTEMS_INVALID_ADDRESS" );
>
>    /* OK */
> -  status = rtems_task_ident( RTEMS_SELF, RTEMS_SEARCH_ALL_NODES, &self_id );
> +  status = rtems_task_ident( RTEMS_WHO_AM_I, RTEMS_SEARCH_ALL_NODES, &self_id );
>    directive_failed( status, "rtems_task_ident of self" );
>    if ( self_id != Task_id[ 1 ] ) {
>      puts( "ERROR - rtems_task_ident - incorrect ID returned!" );
> --
> 2.26.2
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel


More information about the devel mailing list