POSIX: Implement pthread_condattr functions
Added: pthread_condattr_init pthread_condattr_destroy pthread_condattr_getclock pthread_condattr_setclock Signed-off-by: Mateusz Marszalek <matti.marszalek@gmail.com>
This commit is contained in:
parent
28ba8368ad
commit
61219dacc6
3 changed files with 56 additions and 14 deletions
|
@ -75,6 +75,7 @@ BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr));
|
|||
typedef uint32_t pthread_cond_t;
|
||||
|
||||
struct pthread_condattr {
|
||||
clockid_t clock;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
|
||||
|
|
|
@ -110,26 +110,34 @@ int pthread_cond_timedwait(pthread_cond_t *cv, pthread_mutex_t *mut,
|
|||
*
|
||||
* See IEEE 1003.1.
|
||||
*
|
||||
* Note that pthread attribute structs are currently noops in Zephyr.
|
||||
*/
|
||||
static inline int pthread_condattr_init(pthread_condattr_t *att)
|
||||
{
|
||||
ARG_UNUSED(att);
|
||||
return 0;
|
||||
}
|
||||
int pthread_condattr_init(pthread_condattr_t *att);
|
||||
|
||||
/**
|
||||
* @brief POSIX threading compatibility API
|
||||
*
|
||||
* See IEEE 1003.1
|
||||
*
|
||||
* Note that pthread attribute structs are currently noops in Zephyr.
|
||||
*/
|
||||
static inline int pthread_condattr_destroy(pthread_condattr_t *att)
|
||||
{
|
||||
ARG_UNUSED(att);
|
||||
return 0;
|
||||
}
|
||||
int pthread_condattr_destroy(pthread_condattr_t *att);
|
||||
|
||||
/**
|
||||
* @brief POSIX threading comatibility API
|
||||
*
|
||||
* See IEEE 1003.1
|
||||
*
|
||||
*/
|
||||
int pthread_condattr_getclock(const pthread_condattr_t *ZRESTRICT att,
|
||||
clockid_t *ZRESTRICT clock_id);
|
||||
|
||||
/**
|
||||
* @brief POSIX threading compatibility API
|
||||
*
|
||||
* See IEEE 1003.1
|
||||
*
|
||||
*/
|
||||
|
||||
int pthread_condattr_setclock(pthread_condattr_t *att, clockid_t clock_id);
|
||||
|
||||
/**
|
||||
* @brief Declare a mutex as initialized
|
||||
|
@ -364,9 +372,7 @@ int pthread_barrierattr_getpshared(const pthread_barrierattr_t *ZRESTRICT attr,
|
|||
* Unix code. Leave the declarations here so they can be easily
|
||||
* uncommented and implemented as needed.
|
||||
|
||||
int pthread_condattr_getclock(const pthread_condattr_t * clockid_t *);
|
||||
int pthread_condattr_getpshared(const pthread_condattr_t * int *);
|
||||
int pthread_condattr_setclock(pthread_condattr_t *, clockid_t);
|
||||
int pthread_condattr_setpshared(pthread_condattr_t *, int);
|
||||
int pthread_mutex_consistent(pthread_mutex_t *);
|
||||
int pthread_mutex_getprioceiling(const pthread_mutex_t * int *);
|
||||
|
|
|
@ -202,4 +202,39 @@ static int pthread_cond_pool_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_init(pthread_condattr_t *att)
|
||||
{
|
||||
__ASSERT_NO_MSG(att != NULL);
|
||||
|
||||
att->clock = CLOCK_MONOTONIC;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_destroy(pthread_condattr_t *att)
|
||||
{
|
||||
ARG_UNUSED(att);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_getclock(const pthread_condattr_t *ZRESTRICT att,
|
||||
clockid_t *ZRESTRICT clock_id)
|
||||
{
|
||||
*clock_id = att->clock;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_setclock(pthread_condattr_t *att, clockid_t clock_id)
|
||||
{
|
||||
if (clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
att->clock = clock_id;
|
||||
|
||||
return 0;
|
||||
}
|
||||
SYS_INIT(pthread_cond_pool_init, PRE_KERNEL_1, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue