<div dir="auto"><div>I'm not so ok because now the score has symbols for the Classic API and pthreads in it.</div><div dir="auto"><br></div><div dir="auto">The point of putting a method shared by both in the score was to avoid contaminating the score with information about the APIs or the the APIs with knowledge of each other. I think we still need separate files in RTEMS and POSIX to hold the alias declarations.<br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Thu, Apr 29, 2021, 11:03 AM Gedare Bloom <<a href="mailto:gedare@rtems.org">gedare@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">ok<br>
<br>
On Thu, Apr 29, 2021 at 7:18 AM Sebastian Huber<br>
<<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank" rel="noreferrer">sebastian.huber@embedded-brains.de</a>> wrote:<br>
><br>
> This may reduce the code size a bit.<br>
> ---<br>
>  cpukit/Makefile.am                      |  3 +-<br>
>  cpukit/include/rtems/score/threadimpl.h |  7 ++++<br>
>  cpukit/posix/src/pthreadself.c          | 32 ---------------<br>
>  cpukit/rtems/src/taskself.c             | 28 -------------<br>
>  cpukit/score/src/threadselfid.c         | 53 +++++++++++++++++++++++++<br>
>  spec/build/cpukit/librtemscpu.yml       |  3 +-<br>
>  6 files changed, 62 insertions(+), 64 deletions(-)<br>
>  delete mode 100644 cpukit/posix/src/pthreadself.c<br>
>  delete mode 100644 cpukit/rtems/src/taskself.c<br>
>  create mode 100644 cpukit/score/src/threadselfid.c<br>
><br>
> diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am<br>
> index b0df610bed..096187c507 100644<br>
> --- a/cpukit/Makefile.am<br>
> +++ b/cpukit/Makefile.am<br>
> @@ -620,7 +620,6 @@ librtemscpu_a_SOURCES += posix/src/pthreadgetschedparam.c<br>
>  librtemscpu_a_SOURCES += posix/src/pthreadinitthreads.c<br>
>  librtemscpu_a_SOURCES += posix/src/pthreadjoin.c<br>
>  librtemscpu_a_SOURCES += posix/src/pthreadonce.c<br>
> -librtemscpu_a_SOURCES += posix/src/pthreadself.c<br>
>  librtemscpu_a_SOURCES += posix/src/pthreadsetaffinitynp.c<br>
>  librtemscpu_a_SOURCES += posix/src/pthreadsetnamenp.c<br>
>  librtemscpu_a_SOURCES += posix/src/pthreadsetschedparam.c<br>
> @@ -800,7 +799,6 @@ librtemscpu_a_SOURCES += rtems/src/taskmode.c<br>
>  librtemscpu_a_SOURCES += rtems/src/taskrestart.c<br>
>  librtemscpu_a_SOURCES += rtems/src/taskresume.c<br>
>  librtemscpu_a_SOURCES += rtems/src/tasks.c<br>
> -librtemscpu_a_SOURCES += rtems/src/taskself.c<br>
>  librtemscpu_a_SOURCES += rtems/src/tasksetaffinity.c<br>
>  librtemscpu_a_SOURCES += rtems/src/tasksetpriority.c<br>
>  librtemscpu_a_SOURCES += rtems/src/tasksetscheduler.c<br>
> @@ -964,6 +962,7 @@ librtemscpu_a_SOURCES += score/src/threadinitialize.c<br>
>  librtemscpu_a_SOURCES += score/src/threadidledefault.c<br>
>  librtemscpu_a_SOURCES += score/src/threadloadenv.c<br>
>  librtemscpu_a_SOURCES += score/src/threadrestart.c<br>
> +librtemscpu_a_SOURCES += score/src/threadselfid.c<br>
>  librtemscpu_a_SOURCES += score/src/threadsetstate.c<br>
>  librtemscpu_a_SOURCES += score/src/threadstackallocate.c<br>
>  librtemscpu_a_SOURCES += score/src/threadstackfree.c<br>
> diff --git a/cpukit/include/rtems/score/threadimpl.h b/cpukit/include/rtems/score/threadimpl.h<br>
> index 5dfd142b92..c861e8b119 100644<br>
> --- a/cpukit/include/rtems/score/threadimpl.h<br>
> +++ b/cpukit/include/rtems/score/threadimpl.h<br>
> @@ -903,6 +903,13 @@ Thread_Control *_Thread_Get(<br>
>    ISR_lock_Context  *lock_context<br>
>  );<br>
><br>
> +/**<br>
> + * @brief Gets the identifier of the calling thread.<br>
> + *<br>
> + * @return Returns the identifier of the calling thread.<br>
> + */<br>
> +Objects_Id _Thread_Self_id( void );<br>
> +<br>
>  /**<br>
>   * @brief Gets the cpu of the thread's scheduler.<br>
>   *<br>
> diff --git a/cpukit/posix/src/pthreadself.c b/cpukit/posix/src/pthreadself.c<br>
> deleted file mode 100644<br>
> index db5f2f189d..0000000000<br>
> --- a/cpukit/posix/src/pthreadself.c<br>
> +++ /dev/null<br>
> @@ -1,32 +0,0 @@<br>
> -/**<br>
> - * @file<br>
> - *<br>
> - * @ingroup POSIXAPI<br>
> - *<br>
> - * @brief Function returns the ID of the Calling Thread<br>
> - */<br>
> -<br>
> -/*<br>
> - *  16.1.6 Get Calling Thread's ID, p1003.1c/Draft 10, p. 152<br>
> - *<br>
> - *  COPYRIGHT (c) 1989-1999.<br>
> - *  On-Line Applications Research Corporation (OAR).<br>
> - *<br>
> - *  The license and distribution terms for this file may be<br>
> - *  found in the file LICENSE in this distribution or at<br>
> - *  <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
> - */<br>
> -<br>
> -#ifdef HAVE_CONFIG_H<br>
> -#include "config.h"<br>
> -#endif<br>
> -<br>
> -#include <pthread.h><br>
> -<br>
> -#include <rtems/score/percpu.h><br>
> -#include <rtems/score/thread.h><br>
> -<br>
> -pthread_t pthread_self( void )<br>
> -{<br>
> -  return _Thread_Get_executing()->Object.id;<br>
> -}<br>
> diff --git a/cpukit/rtems/src/taskself.c b/cpukit/rtems/src/taskself.c<br>
> deleted file mode 100644<br>
> index 193e691ce5..0000000000<br>
> --- a/cpukit/rtems/src/taskself.c<br>
> +++ /dev/null<br>
> @@ -1,28 +0,0 @@<br>
> -/**<br>
> - * @file<br>
> - *<br>
> - * @ingroup RTEMSImplClassicTask<br>
> - *<br>
> - * @brief This source file contains the implementation of<br>
> - *   rtems_task_self().<br>
> - */<br>
> -<br>
> -/*<br>
> - *  COPYRIGHT (c) 1989-2007.<br>
> - *  On-Line Applications Research Corporation (OAR).<br>
> - *<br>
> - *  The license and distribution terms for this file may be<br>
> - *  found in the file LICENSE in this distribution or at<br>
> - *  <a href="http://www.rtems.org/license/LICENSE" rel="noreferrer noreferrer" target="_blank">http://www.rtems.org/license/LICENSE</a>.<br>
> - */<br>
> -<br>
> -#ifdef HAVE_CONFIG_H<br>
> -#include "config.h"<br>
> -#endif<br>
> -<br>
> -#include <rtems/rtems/tasksimpl.h><br>
> -<br>
> -rtems_id rtems_task_self(void)<br>
> -{<br>
> -   return _Thread_Get_executing()->Object.id;<br>
> -}<br>
> diff --git a/cpukit/score/src/threadselfid.c b/cpukit/score/src/threadselfid.c<br>
> new file mode 100644<br>
> index 0000000000..f888a37619<br>
> --- /dev/null<br>
> +++ b/cpukit/score/src/threadselfid.c<br>
> @@ -0,0 +1,53 @@<br>
> +/* SPDX-License-Identifier: BSD-2-Clause */<br>
> +<br>
> +/**<br>
> + * @file<br>
> + *<br>
> + * @ingroup RTEMSScoreThread<br>
> + *<br>
> + * @brief This source file contains the implementation of _Thread_Self_id().<br>
> + */<br>
> +<br>
> +/*<br>
> + * Copyright (C) 2021 embedded brains GmbH (<a href="http://www.embedded-brains.de" rel="noreferrer noreferrer" target="_blank">http://www.embedded-brains.de</a>)<br>
> + * Copyright (C) 1995 On-Line Applications Research Corporation (OAR)<br>
> + *<br>
> + * Redistribution and use in source and binary forms, with or without<br>
> + * modification, are permitted provided that the following conditions<br>
> + * are met:<br>
> + * 1. Redistributions of source code must retain the above copyright<br>
> + *    notice, this list of conditions and the following disclaimer.<br>
> + * 2. Redistributions in binary form must reproduce the above copyright<br>
> + *    notice, this list of conditions and the following disclaimer in the<br>
> + *    documentation and/or other materials provided with the distribution.<br>
> + *<br>
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"<br>
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE<br>
> + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>
> + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br>
> + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br>
> + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br>
> + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br>
> + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br>
> + * POSSIBILITY OF SUCH DAMAGE.<br>
> + */<br>
> +<br>
> +#ifdef HAVE_CONFIG_H<br>
> +#include "config.h"<br>
> +#endif<br>
> +<br>
> +#include <rtems/score/threadimpl.h><br>
> +<br>
> +#include <pthread.h><br>
> +#include <rtems/rtems/tasksimpl.h><br>
> +<br>
> +Objects_Id _Thread_Self_id( void )<br>
> +{<br>
> +  return _Thread_Get_executing()->Object.id;<br>
> +}<br>
> +<br>
> +RTEMS_ALIAS( _Thread_Self_id ) pthread_t pthread_self( void );<br>
> +<br>
> +RTEMS_ALIAS( _Thread_Self_id ) rtems_id rtems_task_self( void );<br>
> diff --git a/spec/build/cpukit/librtemscpu.yml b/spec/build/cpukit/librtemscpu.yml<br>
> index a3a9ee42e3..21fa6ea787 100644<br>
> --- a/spec/build/cpukit/librtemscpu.yml<br>
> +++ b/spec/build/cpukit/librtemscpu.yml<br>
> @@ -1119,7 +1119,6 @@ source:<br>
>  - cpukit/posix/src/pthreadinitthreads.c<br>
>  - cpukit/posix/src/pthreadjoin.c<br>
>  - cpukit/posix/src/pthreadonce.c<br>
> -- cpukit/posix/src/pthreadself.c<br>
>  - cpukit/posix/src/pthreadsetaffinitynp.c<br>
>  - cpukit/posix/src/pthreadsetnamenp.c<br>
>  - cpukit/posix/src/pthreadsetschedparam.c<br>
> @@ -1299,7 +1298,6 @@ source:<br>
>  - cpukit/rtems/src/taskrestart.c<br>
>  - cpukit/rtems/src/taskresume.c<br>
>  - cpukit/rtems/src/tasks.c<br>
> -- cpukit/rtems/src/taskself.c<br>
>  - cpukit/rtems/src/tasksetaffinity.c<br>
>  - cpukit/rtems/src/tasksetpriority.c<br>
>  - cpukit/rtems/src/tasksetscheduler.c<br>
> @@ -1548,6 +1546,7 @@ source:<br>
>  - cpukit/score/src/threadqtimeout.c<br>
>  - cpukit/score/src/threadrestart.c<br>
>  - cpukit/score/src/threadscheduler.c<br>
> +- cpukit/score/src/threadselfid.c<br>
>  - cpukit/score/src/threadsetstate.c<br>
>  - cpukit/score/src/threadstackallocate.c<br>
>  - cpukit/score/src/threadstackfree.c<br>
> --<br>
> 2.26.2<br>
><br>
> _______________________________________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div></div>