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
2014-04-18 16:20:47 +02:00

59 lines
2.2 KiB
C

/**
* @ingroup pthread
*/
#include <errno.h>
/**
* @brief Attributes for a new reader/writer lock.
* @details The options set in this struct will be ignored by pthread_rwlock_init().
*/
typedef struct pthread_rwlockattr
{
/**
* @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);