[PATCH] posix: Ignore pshared for semaphores
Joel Sherrill
joel at rtems.org
Fri Sep 8 14:23:12 UTC 2017
On Fri, Sep 8, 2017 at 8:33 AM, Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:
> Since we have only one process, sharing between processes is trivial.
>
> Close #3124.
> ---
> cpukit/posix/include/rtems/posix/semaphore.h | 1 -
> cpukit/posix/include/rtems/posix/semaphoreimpl.h | 1 -
> cpukit/posix/src/semaphorecreatesupp.c | 7 -------
> cpukit/posix/src/seminit.c | 1 -
> cpukit/posix/src/semopen.c | 1 -
> testsuites/psxtests/psxsem01/init.c | 14 +++++++++-----
> 6 files changed, 9 insertions(+), 16 deletions(-)
>
> diff --git a/cpukit/posix/include/rtems/posix/semaphore.h
> b/cpukit/posix/include/rtems/posix/semaphore.h
> index 45de4a93b9..6598397052 100644
> --- a/cpukit/posix/include/rtems/posix/semaphore.h
> +++ b/cpukit/posix/include/rtems/posix/semaphore.h
> @@ -43,7 +43,6 @@ extern "C" {
> typedef struct {
> Objects_Control Object;
> CORE_semaphore_Control Semaphore;
> - int process_shared;
> bool named;
> bool linked;
> uint32_t open_count;
> diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h
> b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
> index 2bafbe9b97..43440298ec 100644
> --- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h
> +++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
> @@ -78,7 +78,6 @@ RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control
> *_POSIX_Semaphore_Get(
> int _POSIX_Semaphore_Create_support(
> const char *name,
> size_t name_len,
> - int pshared,
> unsigned int value,
> POSIX_Semaphore_Control **the_sem
> );
> diff --git a/cpukit/posix/src/semaphorecreatesupp.c b/cpukit/posix/src/
> semaphorecreatesupp.c
> index d66e1942c9..4a33336230 100644
> --- a/cpukit/posix/src/semaphorecreatesupp.c
> +++ b/cpukit/posix/src/semaphorecreatesupp.c
> @@ -42,7 +42,6 @@
> int _POSIX_Semaphore_Create_support(
> const char *name_arg,
> size_t name_len,
> - int pshared,
> unsigned int value,
> POSIX_Semaphore_Control **the_sem
> )
> @@ -50,10 +49,6 @@ int _POSIX_Semaphore_Create_support(
> POSIX_Semaphore_Control *the_semaphore;
> char *name;
>
> - /* Sharing semaphores among processes is not currently supported */
> - if (pshared != 0)
> - rtems_set_errno_and_return_minus_one( ENOSYS );
>
Why are you deleting this error check? I can see not storing the value or
passing
it to create support. But I think it still should be validated. We only
support
requests for process private. Anything else is an error.
> -
> /*
> * Make a copy of the user's string for name just in case it was
> * dynamically constructed.
> @@ -73,8 +68,6 @@ int _POSIX_Semaphore_Create_support(
> rtems_set_errno_and_return_minus_one( ENOSPC );
> }
>
> - the_semaphore->process_shared = pshared;
> -
> if ( name ) {
> the_semaphore->named = true;
> the_semaphore->open_count = 1;
> diff --git a/cpukit/posix/src/seminit.c b/cpukit/posix/src/seminit.c
> index 249edf67ee..cf06f6ce41 100644
> --- a/cpukit/posix/src/seminit.c
> +++ b/cpukit/posix/src/seminit.c
> @@ -55,7 +55,6 @@ int sem_init(
> status = _POSIX_Semaphore_Create_support(
> NULL,
> 0,
> - pshared,
> value,
> &the_semaphore
> );
> diff --git a/cpukit/posix/src/semopen.c b/cpukit/posix/src/semopen.c
> index b844b08bb4..98163cca8d 100644
> --- a/cpukit/posix/src/semopen.c
> +++ b/cpukit/posix/src/semopen.c
> @@ -119,7 +119,6 @@ sem_t *sem_open(
> status =_POSIX_Semaphore_Create_support(
> name,
> name_len,
> - false, /* not shared across processes */
> value,
> &the_semaphore
> );
> diff --git a/testsuites/psxtests/psxsem01/init.c b/testsuites/psxtests/
> psxsem01/init.c
> index 8601f926b3..9ba8935292 100644
> --- a/testsuites/psxtests/psxsem01/init.c
> +++ b/testsuites/psxtests/psxsem01/init.c
> @@ -136,6 +136,14 @@ void *POSIX_Init(
>
> TEST_BEGIN();
>
> + puts( "Init: sem_init - SUCCESSFUL" );
> + status = sem_init(&sem2, 1, 1);
> + fatal_posix_service_status( status, 0, "sem_init with pshared != 0");
> +
> + puts( "Init: sem_destroy - SUCCESSFUL" );
> + status = sem_destroy(&sem2);
> + fatal_posix_service_status( status, 0, "sem_destroy");
> +
> puts( "Init: sem_init - UNSUCCESSFUL (EINVAL)" );
> status = sem_init(NULL, 0, 1);
> fatal_posix_service_status( status, -1, "sem_init error return status");
> @@ -152,11 +160,6 @@ void *POSIX_Init(
> fatal_posix_service_status( status, -1, "sem_init error return status");
> fatal_posix_service_status( errno, ENOSPC, "sem_init errorno ENOSPC" );
>
> - puts( "Init: sem_init - UNSUCCESSFUL (ENOSYS -- pshared not supported)"
> );
> - status = sem_init(&sem2, 1, 1);
> - fatal_posix_service_status( status, -1, "sem_init error return status");
> - fatal_posix_service_status( errno, ENOSYS, "sem_init errno set to
> ENOSYS");
> -
> puts( "Init: sem_getvalue - SUCCESSFUL ");
> for (i = 0; i < MAX_SEMS; i++) {
> status = sem_getvalue(&sems[i], &value);
> @@ -165,6 +168,7 @@ void *POSIX_Init(
> fatal_posix_service_status( value, i, "sem_getvalue correct value" );
> }
> puts( "Init: sem_getvalue - UNSUCCESSFUL ");
> + sem2 = 0;
> status = sem_getvalue(&sem2, &value);
> fatal_posix_service_status( status, -1, "sem_getvalue error return
> status");
> fatal_posix_service_status( errno, EINVAL, "sem_getvalue errno EINVAL");
> --
> 2.12.3
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20170908/11488cd9/attachment-0001.html>
More information about the devel
mailing list