2012-11-10 17:06:01 +01:00
|
|
|
/********************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libc/pthread/pthread_barrierattr_setpshared.c
|
2012-11-10 17:06:01 +01: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 17:06:01 +01:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-11-10 17:06:01 +01: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 17:06:01 +01:00
|
|
|
*
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Included Files
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
/********************************************************************************
|
2015-04-08 15:32:08 +02:00
|
|
|
* Pre-processor Definitions
|
2012-11-10 17:06:01 +01:00
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Private Type Declarations
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2012-11-10 17:06:01 +01:00
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
2016-02-22 01:08:58 +01:00
|
|
|
* Private Data
|
2012-11-10 17:06:01 +01:00
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Private Function Prototypes
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
/********************************************************************************
|
2017-04-22 00:33:14 +02:00
|
|
|
* Name: pthread_barrierattr_setpshared
|
2012-11-10 17:06:01 +01: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 17:06:01 +01: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 17:06:01 +01:00
|
|
|
*
|
2018-03-13 16:52:27 +01:00
|
|
|
* Input Parameters:
|
2012-11-10 17:06:01 +01:00
|
|
|
* attr - barrier attributes to be modified.
|
|
|
|
* pshared - the new value of the pshared attribute.
|
|
|
|
*
|
2018-02-01 17:00:02 +01: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 17:06:01 +01:00
|
|
|
*
|
|
|
|
* Assumptions:
|
|
|
|
*
|
|
|
|
********************************************************************************/
|
|
|
|
|
|
|
|
int pthread_barrierattr_setpshared(FAR pthread_barrierattr_t *attr, int pshared)
|
|
|
|
{
|
|
|
|
int ret = OK;
|
|
|
|
|
2021-03-02 14:33:27 +01:00
|
|
|
if (!attr || (pshared != PTHREAD_PROCESS_SHARED &&
|
|
|
|
pshared != PTHREAD_PROCESS_PRIVATE))
|
2012-11-10 17:06:01 +01:00
|
|
|
{
|
|
|
|
ret = EINVAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
attr->pshared = pshared;
|
|
|
|
}
|
2021-03-02 14:33:27 +01:00
|
|
|
|
2012-11-10 17:06:01 +01:00
|
|
|
return ret;
|
|
|
|
}
|