1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/posix/pthread/include/pthread_rwlock_attr.h

88 lines
2.7 KiB
C
Raw Normal View History

/*
* Copyright (C) 2014 Freie Universität Berlin
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
2014-04-17 02:10:55 +02:00
/**
* @ingroup pthread
* @{
* @file
* @brief Implementation of a fair, POSIX conforming reader/writer lock (attribute set).
* @note Do not include this header file directly, but pthread.h.
2014-04-17 02:10:55 +02:00
*/
#ifndef PTHREAD_RWLOCK_ATTR_H
#define PTHREAD_RWLOCK_ATTR_H
2014-04-17 02:10:55 +02:00
#include <errno.h>
2014-10-10 11:51:11 +02:00
#ifdef __cplusplus
extern "C" {
#endif
2014-04-17 02:10:55 +02:00
/**
* @brief Attributes for a new reader/writer lock.
* @details The options set in this struct will be ignored by pthread_rwlock_init().
*/
2016-04-07 21:31:00 +02:00
typedef struct
2014-04-17 02:10:55 +02:00
{
/**
* @brief Whether to share lock with child processes.
* @details Valid values are `PTHREAD_PROCESS_SHARED` and `PTHREAD_PROCESS_PRIVATE`.
* Since RIOT is a single-process operating system, this value is ignored.
*/
int pshared;
} pthread_rwlockattr_t;
/**
* @brief Initilize the attribute set with the defaults.
* @details Default value for pshared: `PTHREAD_PROCESS_PRIVATE`.
* A zeroed out datum is initialized.
* @param[in,out] attr Attribute set to initialize.
* @returns `0` on success.
* `EINVAL` if `attr == NULL`.
*/
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
/**
* @brief Destroy an attribute set.
* @details This function does nothing, don't bother calling it.
* @param[in,out] attr Attribute set to destroy.
* @returns `0` on success.
* `EINVAL` if `attr == NULL`.
*/
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
/**
* @brief Read whether to share the lock with child processes.
* @details There are not child processes in RIOT.
* @param[in] attr Attribute set to query.
* @param[out] pshared Either `PTHREAD_PROCESS_SHARED` or `PTHREAD_PROCESS_PRIVATE`.
* @returns `0` on success.
* `EINVAL` if `attr == NULL`.
*/
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *attr, int *pshared);
/**
* @brief Set whether to share the lock with child processes.
* @details There are not child processes in RIOT.
* @param[in,out] attr Attribute set to operate on.
* @param[in] pshared Either `PTHREAD_PROCESS_SHARED` or `PTHREAD_PROCESS_PRIVATE`.
* @returns `0` on success.
* `EINVAL` if `attr == NULL` or a wrong value for `pshared` was supplied.
*/
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared);
2014-10-10 11:51:11 +02:00
#ifdef __cplusplus
}
#endif
#endif /* PTHREAD_RWLOCK_ATTR_H */
/**
* @}
*/