2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2018-05-29 13:21:26 -06:00
|
|
|
* libs/libc/pthread/pthread_barrierattr_setpshared.c
|
2012-11-10 16:06:01 +00:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2012-11-10 16:06:01 +00:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-11-10 16:06:01 +00:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2012-11-10 16:06:01 +00:00
|
|
|
*
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2012-11-10 16:06:01 +00:00
|
|
|
* Included Files
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2015-04-08 07:32:08 -06:00
|
|
|
* Pre-processor Definitions
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2012-11-10 16:06:01 +00:00
|
|
|
* Private Type Declarations
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2015-10-02 16:30:35 -06:00
|
|
|
* Public Data
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2016-02-21 18:08:58 -06:00
|
|
|
* Private Data
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2012-11-10 16:06:01 +00:00
|
|
|
* Private Function Prototypes
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2012-11-10 16:06:01 +00:00
|
|
|
* Public Functions
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
/****************************************************************************
|
2017-04-21 16:33:14 -06:00
|
|
|
* Name: pthread_barrierattr_setpshared
|
2012-11-10 16:06:01 +00:00
|
|
|
*
|
|
|
|
* Description:
|
2021-03-02 14:33:27 +01:00
|
|
|
* The process-shared attribute is set to PTHREAD_PROCESS_SHARED to permit
|
|
|
|
* a barrier to be operated upon by any thread that has access to the
|
|
|
|
* memory where the barrier is allocated. If the process-shared attribute
|
|
|
|
* is PTHREAD_PROCESS_PRIVATE, the barrier can only be operated upon by
|
|
|
|
* threads created within the same process as the thread that initialized
|
|
|
|
* the barrier.
|
|
|
|
* If threads of different processes attempt to operate on such a barrier,
|
|
|
|
* the behavior is undefined. The default value of the attribute is
|
2012-11-10 16:06:01 +00:00
|
|
|
* PTHREAD_PROCESS_PRIVATE.
|
|
|
|
*
|
2021-03-02 14:33:27 +01:00
|
|
|
* Both constants PTHREAD_PROCESS_SHARED and PTHREAD_PROCESS_PRIVATE are
|
|
|
|
* defined in pthread.h.
|
2012-11-10 16:06:01 +00:00
|
|
|
*
|
2018-03-13 09:52:27 -06:00
|
|
|
* Input Parameters:
|
2012-11-10 16:06:01 +00:00
|
|
|
* attr - barrier attributes to be modified.
|
|
|
|
* pshared - the new value of the pshared attribute.
|
|
|
|
*
|
2018-02-01 10:00:02 -06:00
|
|
|
* Returned Value:
|
2021-03-02 14:33:27 +01:00
|
|
|
* 0 (OK) on success or EINVAL if either attr is invalid or pshared is not
|
|
|
|
* one of PTHREAD_PROCESS_SHARED or PTHREAD_PROCESS_PRIVATE.
|
2012-11-10 16:06:01 +00:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
2023-05-10 10:29:32 +02:00
|
|
|
****************************************************************************/
|
2012-11-10 16:06:01 +00:00
|
|
|
|
2023-05-10 10:29:32 +02:00
|
|
|
int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr,
|
|
|
|
int pshared)
|
2012-11-10 16:06:01 +00:00
|
|
|
{
|
|
|
|
int ret = OK;
|
|
|
|
|
2021-03-02 14:33:27 +01:00
|
|
|
if (!attr || (pshared != PTHREAD_PROCESS_SHARED &&
|
|
|
|
pshared != PTHREAD_PROCESS_PRIVATE))
|
2012-11-10 16:06:01 +00:00
|
|
|
{
|
|
|
|
ret = EINVAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
attr->pshared = pshared;
|
|
|
|
}
|
2021-03-02 14:33:27 +01:00
|
|
|
|
2012-11-10 16:06:01 +00:00
|
|
|
return ret;
|
|
|
|
}
|