From ea52f1c784009e7cb8286e171e17903085306c0f Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 30 Jun 2022 00:39:12 -0500 Subject: [PATCH] Bugfix: Problems exposed by f_thread unit tests. --- level_0/f_thread/c/private-thread.c | 2 +- level_0/f_thread/c/thread.c | 228 ++++++++++++++-------------- level_0/f_thread/c/thread.h | 294 ++++++++++++++++++------------------ 3 files changed, 263 insertions(+), 261 deletions(-) diff --git a/level_0/f_thread/c/private-thread.c b/level_0/f_thread/c/private-thread.c index 362166e..fe1f298 100644 --- a/level_0/f_thread/c/private-thread.c +++ b/level_0/f_thread/c/private-thread.c @@ -366,7 +366,7 @@ extern "C" { return F_status_set_error(F_failure); } - key = 0; + *key = 0; return F_none; } diff --git a/level_0/f_thread/c/thread.c b/level_0/f_thread/c/thread.c index 69ee94c..6d8b936 100644 --- a/level_0/f_thread/c/thread.c +++ b/level_0/f_thread/c/thread.c @@ -78,71 +78,25 @@ extern "C" { } #endif // defined(_pthread_attr_unsupported_) && !defined(_di_f_thread_attribute_affinity_set_) -#ifndef _di_f_thread_attribute_condition_clock_get_ - f_status_t f_thread_attribute_condition_clock_get(const f_thread_condition_attribute_t * const attribute, clockid_t * const id) { - #ifndef _di_level_0_parameter_checking_ - if (!attribute) return F_status_set_error(F_parameter); - if (!id) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - const int error = pthread_condattr_getclock(attribute, id); - - if (error) { - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // _di_f_thread_attribute_condition_clock_get_ - -#ifndef _di_f_thread_attribute_condition_clock_set_ - f_status_t f_thread_attribute_condition_clock_set(const clockid_t id, f_thread_condition_attribute_t * const attribute) { - #ifndef _di_level_0_parameter_checking_ - if (!attribute) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - const int error = pthread_condattr_setclock(attribute, id); - - if (error) { - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // _di_f_thread_attribute_condition_clock_set_ - -#ifndef _di_f_thread_attribute_condition_shared_get_ - f_status_t f_thread_attribute_condition_shared_get(const f_thread_condition_attribute_t * const attribute, int * const shared) { +#ifndef _di_f_thread_attribute_concurrency_get_ + f_status_t f_thread_attribute_concurrency_get(int * const level) { #ifndef _di_level_0_parameter_checking_ - if (!attribute) return F_status_set_error(F_parameter); - if (!shared) return F_status_set_error(F_parameter); + if (!level) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - const int error = pthread_condattr_getpshared(attribute, shared); - - if (error) { - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } + *level = pthread_getconcurrency(); return F_none; } -#endif // _di_f_thread_attribute_condition_shared_get_ +#endif // _di_f_thread_attribute_concurrency_get_ -#ifndef _di_f_thread_attribute_condition_shared_set_ - f_status_t f_thread_attribute_condition_shared_set(const int shared, f_thread_condition_attribute_t * const attribute) { - #ifndef _di_level_0_parameter_checking_ - if (!attribute) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_attribute_concurrency_set_ + f_status_t f_thread_attribute_concurrency_set(const int level) { - const int error = pthread_condattr_setpshared(attribute, shared); + const int error = pthread_setconcurrency(level); if (error) { + if (error == EAGAIN) return F_status_set_error(F_resource_not); if (error == EINVAL) return F_status_set_error(F_parameter); return F_status_set_error(F_failure); @@ -150,7 +104,7 @@ extern "C" { return F_none; } -#endif // _di_f_thread_attribute_condition_shared_set_ +#endif // _di_f_thread_attribute_concurrency_set_ #ifndef _di_f_thread_attribute_create_ f_status_t f_thread_attribute_create(f_thread_attribute_t * const attribute) { @@ -696,6 +650,9 @@ extern "C" { #ifndef _di_f_thread_clock_get_id_ f_status_t f_thread_clock_get_id(const f_thread_id_t id_thread, clockid_t * const id_clock) { + #ifndef _di_level_0_parameter_checking_ + if (!id_clock) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ const int error = pthread_getcpuclockid(id_thread, id_clock); @@ -721,33 +678,42 @@ extern "C" { } #endif // _di_f_thread_compare_ -#ifndef _di_f_thread_attribute_concurrency_get_ - f_status_t f_thread_attribute_concurrency_get(int * const level) { +#ifndef _di_f_thread_condition_attribute_clock_get_ + f_status_t f_thread_condition_attribute_clock_get(const f_thread_condition_attribute_t * const attribute, clockid_t * const id) { #ifndef _di_level_0_parameter_checking_ - if (!level) return F_status_set_error(F_parameter); + if (!attribute) return F_status_set_error(F_parameter); + if (!id) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - *level = pthread_getconcurrency(); + const int error = pthread_condattr_getclock(attribute, id); + + if (error) { + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } return F_none; } -#endif // _di_f_thread_attribute_concurrency_get_ +#endif // _di_f_thread_condition_attribute_clock_get_ -#ifndef _di_f_thread_attribute_concurrency_set_ - f_status_t f_thread_attribute_concurrency_set(const int level) { +#ifndef _di_f_thread_condition_attribute_clock_set_ + f_status_t f_thread_condition_attribute_clock_set(const clockid_t id, f_thread_condition_attribute_t * const attribute) { + #ifndef _di_level_0_parameter_checking_ + if (!attribute) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ - const int error = pthread_setconcurrency(level); + const int error = pthread_condattr_setclock(attribute, id); if (error) { if (error == EINVAL) return F_status_set_error(F_parameter); - if (error == EAGAIN) return F_status_set_error(F_resource_not); return F_status_set_error(F_failure); } return F_none; } -#endif // _di_f_thread_attribute_concurrency_set_ +#endif // _di_f_thread_condition_attribute_clock_set_ #ifndef _di_f_thread_condition_attribute_create_ f_status_t f_thread_condition_attribute_create(f_thread_condition_attribute_t * const attribute) { @@ -778,6 +744,43 @@ extern "C" { } #endif // _di_f_thread_condition_attribute_delete_ +#ifndef _di_f_thread_condition_attribute_shared_get_ + f_status_t f_thread_condition_attribute_shared_get(const f_thread_condition_attribute_t * const attribute, int * const shared) { + #ifndef _di_level_0_parameter_checking_ + if (!attribute) return F_status_set_error(F_parameter); + if (!shared) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + const int error = pthread_condattr_getpshared(attribute, shared); + + if (error) { + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // _di_f_thread_condition_attribute_shared_get_ + +#ifndef _di_f_thread_condition_attribute_shared_set_ + f_status_t f_thread_condition_attribute_shared_set(const int shared, f_thread_condition_attribute_t * const attribute) { + #ifndef _di_level_0_parameter_checking_ + if (!attribute) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + const int error = pthread_condattr_setpshared(attribute, shared); + + if (error) { + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // _di_f_thread_condition_attribute_shared_set_ + #ifndef _di_f_thread_condition_create_ f_status_t f_thread_condition_create(const f_thread_condition_attribute_t * const attribute, f_thread_condition_t * const condition) { #ifndef _di_level_0_parameter_checking_ @@ -809,13 +812,13 @@ extern "C" { } #endif // _di_f_thread_condition_delete_ -#ifndef _di_f_thread_condition_signal_all_ - f_status_t f_thread_condition_signal_all(f_thread_condition_t * const condition) { +#ifndef _di_f_thread_condition_signal_ + f_status_t f_thread_condition_signal(f_thread_condition_t * const condition) { #ifndef _di_level_0_parameter_checking_ if (!condition) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - const int error = pthread_cond_broadcast(condition); + const int error = pthread_cond_signal(condition); if (error) { if (error == EINVAL) return F_status_set_error(F_parameter); @@ -825,15 +828,15 @@ extern "C" { return F_none; } -#endif // _di_f_thread_condition_signal_all_ +#endif // _di_f_thread_condition_signal_ -#ifndef _di_f_thread_condition_signal_ - f_status_t f_thread_condition_signal(f_thread_condition_t * const condition) { +#ifndef _di_f_thread_condition_signal_all_ + f_status_t f_thread_condition_signal_all(f_thread_condition_t * const condition) { #ifndef _di_level_0_parameter_checking_ if (!condition) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - const int error = pthread_cond_signal(condition); + const int error = pthread_cond_broadcast(condition); if (error) { if (error == EINVAL) return F_status_set_error(F_parameter); @@ -843,7 +846,7 @@ extern "C" { return F_none; } -#endif // _di_f_thread_condition_signal_ +#endif // _di_f_thread_condition_signal_all_ #ifndef _di_f_thread_condition_wait_ f_status_t f_thread_condition_wait(f_thread_condition_t * const condition, f_thread_mutex_t * const mutex) { @@ -1162,7 +1165,6 @@ extern "C" { if (error == EAGAIN) return F_status_set_error(F_resource_not); if (error == EDEADLK) return F_status_set_error(F_deadlock); if (error == EINVAL) return F_status_set_error(F_parameter); - if (error == ETIMEDOUT) return F_time; return F_status_set_error(F_failure); } @@ -1172,7 +1174,7 @@ extern "C" { #endif // _di_f_thread_lock_read_ #ifndef _di_f_thread_lock_read_timed_ - f_status_t f_thread_lock_read_timed(const struct timespec *timeout, f_thread_lock_t * const lock) { + f_status_t f_thread_lock_read_timed(const struct timespec * const timeout, f_thread_lock_t * const lock) { #ifndef _di_level_0_parameter_checking_ if (!timeout) return F_status_set_error(F_parameter); if (!lock) return F_status_set_error(F_parameter); @@ -1234,7 +1236,7 @@ extern "C" { #endif // _di_f_thread_lock_write_ #ifndef _di_f_thread_lock_write_timed_ - f_status_t f_thread_lock_write_timed(const struct timespec *timeout, f_thread_lock_t * const lock) { + f_status_t f_thread_lock_write_timed(const struct timespec * const timeout, f_thread_lock_t * const lock) { #ifndef _di_level_0_parameter_checking_ if (!timeout) return F_status_set_error(F_parameter); if (!lock) return F_status_set_error(F_parameter); @@ -1345,61 +1347,68 @@ extern "C" { } #endif // _di_f_thread_mutex_attribute_priority_ceiling_set_ -#ifndef _di_f_thread_mutex_attribute_shared_get_ - f_status_t f_thread_mutex_attribute_shared_get(const f_thread_mutex_attribute_t * const attribute, int * const shared) { +#ifndef _di_f_thread_mutex_attribute_protocol_get_ + f_status_t f_thread_mutex_attribute_protocol_get(const f_thread_mutex_attribute_t * const attribute, int * const protocol) { #ifndef _di_level_0_parameter_checking_ if (!attribute) return F_status_set_error(F_parameter); - if (!shared) return F_status_set_error(F_parameter); + if (!protocol) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (pthread_mutexattr_getpshared(attribute, shared)) { + const int error = pthread_mutexattr_getprotocol(attribute, protocol); + + if (error) { + if (error == EINVAL) return F_status_set_error(F_parameter); + if (error == EPERM) return F_status_set_error(F_prohibited); + return F_status_set_error(F_failure); } return F_none; } -#endif // _di_f_thread_mutex_attribute_shared_get_ +#endif // _di_f_thread_mutex_attribute_protocol_get_ -#ifndef _di_f_thread_mutex_attribute_shared_set_ - f_status_t f_thread_mutex_attribute_shared_set(const int shared, f_thread_mutex_attribute_t * const attribute) { +#ifndef _di_f_thread_mutex_attribute_protocol_set_ + f_status_t f_thread_mutex_attribute_protocol_set(const int protocol, f_thread_mutex_attribute_t * const attribute) { #ifndef _di_level_0_parameter_checking_ if (!attribute) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - const int error = pthread_mutexattr_setpshared(attribute, shared); + const int error = pthread_mutexattr_setprotocol(attribute, protocol); if (error) { if (error == EINVAL) return F_status_set_error(F_parameter); + if (error == EPERM) return F_status_set_error(F_prohibited); + if (error == ENOTSUP) return F_status_set_error(F_supported_not); return F_status_set_error(F_failure); } return F_none; } -#endif // _di_f_thread_mutex_attribute_shared_set_ +#endif // _di_f_thread_mutex_attribute_protocol_set_ -#ifndef _di_f_thread_mutex_attribute_type_get_ - f_status_t f_thread_mutex_attribute_type_get(const f_thread_mutex_attribute_t * const attribute, int * const type) { +#ifndef _di_f_thread_mutex_attribute_shared_get_ + f_status_t f_thread_mutex_attribute_shared_get(const f_thread_mutex_attribute_t * const attribute, int * const shared) { #ifndef _di_level_0_parameter_checking_ if (!attribute) return F_status_set_error(F_parameter); - if (!type) return F_status_set_error(F_parameter); + if (!shared) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (pthread_mutexattr_gettype(attribute, type)) { + if (pthread_mutexattr_getpshared(attribute, shared)) { return F_status_set_error(F_failure); } return F_none; } -#endif // _di_f_thread_mutex_attribute_type_get_ +#endif // _di_f_thread_mutex_attribute_shared_get_ -#ifndef _di_f_thread_mutex_attribute_type_set_ - f_status_t f_thread_mutex_attribute_type_set(const int type, f_thread_mutex_attribute_t * const attribute) { +#ifndef _di_f_thread_mutex_attribute_shared_set_ + f_status_t f_thread_mutex_attribute_shared_set(const int shared, f_thread_mutex_attribute_t * const attribute) { #ifndef _di_level_0_parameter_checking_ if (!attribute) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - const int error = pthread_mutexattr_settype(attribute, type); + const int error = pthread_mutexattr_setpshared(attribute, shared); if (error) { if (error == EINVAL) return F_status_set_error(F_parameter); @@ -1409,47 +1418,40 @@ extern "C" { return F_none; } -#endif // _di_f_thread_mutex_attribute_type_set_ +#endif // _di_f_thread_mutex_attribute_shared_set_ -#ifndef _di_f_thread_mutex_attribute_protocol_get_ - f_status_t f_thread_mutex_attribute_protocol_get(const f_thread_mutex_attribute_t * const attribute, int * const protocol) { +#ifndef _di_f_thread_mutex_attribute_type_get_ + f_status_t f_thread_mutex_attribute_type_get(const f_thread_mutex_attribute_t * const attribute, int * const type) { #ifndef _di_level_0_parameter_checking_ if (!attribute) return F_status_set_error(F_parameter); - if (!protocol) return F_status_set_error(F_parameter); + if (!type) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - const int error = pthread_mutexattr_getprotocol(attribute, protocol); - - if (error) { - if (error == EINVAL) return F_status_set_error(F_parameter); - if (error == EPERM) return F_status_set_error(F_prohibited); - + if (pthread_mutexattr_gettype(attribute, type)) { return F_status_set_error(F_failure); } return F_none; } -#endif // _di_f_thread_mutex_attribute_protocol_get_ +#endif // _di_f_thread_mutex_attribute_type_get_ -#ifndef _di_f_thread_mutex_attribute_protocol_set_ - f_status_t f_thread_mutex_attribute_protocol_set(const int protocol, f_thread_mutex_attribute_t * const attribute) { +#ifndef _di_f_thread_mutex_attribute_type_set_ + f_status_t f_thread_mutex_attribute_type_set(const int type, f_thread_mutex_attribute_t * const attribute) { #ifndef _di_level_0_parameter_checking_ if (!attribute) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - const int error = pthread_mutexattr_setprotocol(attribute, protocol); + const int error = pthread_mutexattr_settype(attribute, type); if (error) { if (error == EINVAL) return F_status_set_error(F_parameter); - if (error == EPERM) return F_status_set_error(F_prohibited); - if (error == ENOTSUP) return F_status_set_error(F_supported_not); return F_status_set_error(F_failure); } return F_none; } -#endif // _di_f_thread_mutex_attribute_protocol_set_ +#endif // _di_f_thread_mutex_attribute_type_set_ #ifndef _di_f_thread_mutex_create_ f_status_t f_thread_mutex_create(f_thread_mutex_attribute_t * const attribute, f_thread_mutex_t * const mutex) { @@ -1504,7 +1506,7 @@ extern "C" { #endif // _di_f_thread_mutex_lock_ #ifndef _di_f_thread_mutex_lock_timed_ - f_status_t f_thread_mutex_lock_timed(const struct timespec *timeout, f_thread_mutex_t * const mutex) { + f_status_t f_thread_mutex_lock_timed(const struct timespec * const timeout, f_thread_mutex_t * const mutex) { #ifndef _di_level_0_parameter_checking_ if (!timeout) return F_status_set_error(F_parameter); if (!mutex) return F_status_set_error(F_parameter); @@ -1654,7 +1656,7 @@ extern "C" { #endif // _di_f_thread_semaphore_lock_ #ifndef _di_f_thread_semaphore_lock_timed_ - f_status_t f_thread_semaphore_lock_timed(const struct timespec *timeout, f_thread_semaphore_t * const semaphore) { + f_status_t f_thread_semaphore_lock_timed(const struct timespec * const timeout, f_thread_semaphore_t * const semaphore) { #ifndef _di_level_0_parameter_checking_ if (!timeout) return F_status_set_error(F_parameter); if (!semaphore) return F_status_set_error(F_parameter); diff --git a/level_0/f_thread/c/thread.h b/level_0/f_thread/c/thread.h index 526e493..e1f4d8f 100644 --- a/level_0/f_thread/c/thread.h +++ b/level_0/f_thread/c/thread.h @@ -121,75 +121,36 @@ extern "C" { #endif // _di_f_thread_attribute_affinity_set_ /** - * Get the clock selection thread condition attribute. - * - * @param attribute - * The thread condition attribute. - * @param id - * The clock ID. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * F_failure (with error bit) on any other error. + * Get the level of concurrency. * - * @see pthread_condattr_getclock() - */ -#ifndef _di_f_thread_attribute_condition_clock_get_ - extern f_status_t f_thread_attribute_condition_clock_get(const f_thread_condition_attribute_t * const attribute, clockid_t * const id); -#endif // _di_f_thread_attribute_condition_clock_get_ - -/** - * Set the clock selection thread condition attribute. + * A level of 0 designates the system to automatically choose concurrency level. + * Any non-zero level is considered a hint and will be followed at the systems discretion. * - * @param id - * The clock ID. - * @param attribute - * The thread condition attribute. + * @param level + * The concurrency level. * * @return * F_none on success. * * F_parameter (with error bit) if a parameter is invalid. + * F_resource_not (with error bit) if the new level would cause the system to exceed available resources. * * F_failure (with error bit) on any other error. * - * @see pthread_condattr_setclock() + * @see pthread_getconcurrency() */ -#ifndef _di_f_thread_attribute_condition_clock_set_ - extern f_status_t f_thread_attribute_condition_clock_set(const clockid_t id, f_thread_condition_attribute_t * const attribute); -#endif // _di_f_thread_attribute_condition_clock_set_ +#ifndef _di_f_thread_attribute_concurrency_get_ + extern f_status_t f_thread_attribute_concurrency_get(int * const level); +#endif // _di_f_thread_attribute_concurrency_get_ /** - * Get the process shared thread condition attribute. - * - * @param attribute - * The thread condition attribute. - * @param shared - * The process shared attribute value. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * F_failure (with error bit) on any other error. + * Set the level of concurrency. * - * @see pthread_condattr_getpshared() - */ -#ifndef _di_f_thread_attribute_condition_shared_get_ - extern f_status_t f_thread_attribute_condition_shared_get(const f_thread_condition_attribute_t * const attribute, int * const shared); -#endif // _di_f_thread_attribute_condition_shared_get_ - -/** - * Set the process shared thread condition attribute. + * A level of 0 designates the system to automatically choose concurrency level. + * Any non-zero level is considered a hint and will be followed at the systems discretion. * - * @param shared - * The process shared attribute value. - * @param attribute - * The thread condition attribute. + * @param level + * The concurrency level. * * @return * F_none on success. @@ -198,11 +159,11 @@ extern "C" { * * F_failure (with error bit) on any other error. * - * @see pthread_condattr_setpshared() + * @see pthread_setconcurrency() */ -#ifndef _di_f_thread_attribute_condition_shared_set_ - extern f_status_t f_thread_attribute_condition_shared_set(const int shared, f_thread_condition_attribute_t * const attribute); -#endif // _di_f_thread_attribute_condition_shared_set_ +#ifndef _di_f_thread_attribute_concurrency_set_ + extern f_status_t f_thread_attribute_concurrency_set(const int level); +#endif // _di_f_thread_attribute_concurrency_set_ /** * Create (initialize) a thread attribute structure. @@ -919,36 +880,32 @@ extern "C" { #endif // _di_f_thread_compare_ /** - * Get the level of concurrency. - * - * A level of 0 designates the system to automatically choose concurrency level. - * Any non-zero level is considered a hint and will be followed at the systems discretion. + * Initialize a attribute. * - * @param level - * The concurrency level. + * @param attribute + * The attribute to set. + * This assigns the default to the attribute. * * @return * F_none on success. * * F_parameter (with error bit) if a parameter is invalid. - * F_resource_not (with error bit) if the new level would cause the system to exceed available resources. * * F_failure (with error bit) on any other error. * - * @see pthread_getconcurrency() + * @see pthread_condattr_init() */ -#ifndef _di_f_thread_attribute_concurrency_get_ - extern f_status_t f_thread_attribute_concurrency_get(int * const level); -#endif // _di_f_thread_attribute_concurrency_get_ +#ifndef _di_f_thread_condition_attribute_create_ + extern f_status_t f_thread_condition_attribute_create(f_thread_condition_attribute_t * const attribute); +#endif // _di_f_thread_condition_attribute_create_ /** - * Set the level of concurrency. - * - * A level of 0 designates the system to automatically choose concurrency level. - * Any non-zero level is considered a hint and will be followed at the systems discretion. + * Get the clock selection thread condition attribute. * - * @param level - * The concurrency level. + * @param attribute + * The thread condition attribute. + * @param id + * The clock ID. * * @return * F_none on success. @@ -957,18 +914,19 @@ extern "C" { * * F_failure (with error bit) on any other error. * - * @see pthread_setconcurrency() + * @see pthread_condattr_getclock() */ -#ifndef _di_f_thread_attribute_concurrency_set_ - extern f_status_t f_thread_attribute_concurrency_set(const int level); -#endif // _di_f_thread_attribute_concurrency_set_ +#ifndef _di_f_thread_condition_attribute_clock_get_ + extern f_status_t f_thread_condition_attribute_clock_get(const f_thread_condition_attribute_t * const attribute, clockid_t * const id); +#endif // _di_f_thread_condition_attribute_clock_get_ /** - * Initialize a attribute. + * Set the clock selection thread condition attribute. * + * @param id + * The clock ID. * @param attribute - * The attribute to set. - * This assigns the default to the attribute. + * The thread condition attribute. * * @return * F_none on success. @@ -977,11 +935,11 @@ extern "C" { * * F_failure (with error bit) on any other error. * - * @see pthread_condattr_init() + * @see pthread_condattr_setclock() */ -#ifndef _di_f_thread_condition_attribute_create_ - extern f_status_t f_thread_condition_attribute_create(f_thread_condition_attribute_t * const attribute); -#endif // _di_f_thread_condition_attribute_create_ +#ifndef _di_f_thread_condition_attribute_clock_set_ + extern f_status_t f_thread_condition_attribute_clock_set(const clockid_t id, f_thread_condition_attribute_t * const attribute); +#endif // _di_f_thread_condition_attribute_clock_set_ /** * Delete a thread attribute. @@ -1007,6 +965,48 @@ extern "C" { #endif // _di_f_thread_condition_attribute_delete_ /** + * Get the process shared thread condition attribute. + * + * @param attribute + * The thread condition attribute. + * @param shared + * The process shared attribute value. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * F_failure (with error bit) on any other error. + * + * @see pthread_condattr_getpshared() + */ +#ifndef _di_f_thread_condition_attribute_shared_get_ + extern f_status_t f_thread_condition_attribute_shared_get(const f_thread_condition_attribute_t * const attribute, int * const shared); +#endif // _di_f_thread_condition_attribute_shared_get_ + +/** + * Set the process shared thread condition attribute. + * + * @param shared + * The process shared attribute value. + * @param attribute + * The thread condition attribute. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * F_failure (with error bit) on any other error. + * + * @see pthread_condattr_setpshared() + */ +#ifndef _di_f_thread_condition_attribute_shared_set_ + extern f_status_t f_thread_condition_attribute_shared_set(const int shared, f_thread_condition_attribute_t * const attribute); +#endif // _di_f_thread_condition_attribute_shared_set_ + +/** * Initialize a condition. * * @param attribute @@ -1051,7 +1051,9 @@ extern "C" { #endif // _di_f_thread_condition_delete_ /** - * Signal all threads waiting on a condition. + * Signal a thread waiting on a condition. + * + * Only a single thread waiting on this condition is signaled. * * @param condition * The condition to broadcast the unblock signal to. @@ -1063,16 +1065,14 @@ extern "C" { * * F_failure (with error bit) on any other error. * - * @see pthread_cond_broadcast() + * @see pthread_cond_signal() */ -#ifndef _di_f_thread_condition_signal_all_ - extern f_status_t f_thread_condition_signal_all(f_thread_condition_t * const condition); -#endif // _di_f_thread_condition_signal_all_ +#ifndef _di_f_thread_condition_signal_ + extern f_status_t f_thread_condition_signal(f_thread_condition_t * const condition); +#endif // _di_f_thread_condition_signal_ /** - * Signal a thread waiting on a condition. - * - * Only a single thread waiting on this condition is signaled. + * Signal all threads waiting on a condition. * * @param condition * The condition to broadcast the unblock signal to. @@ -1084,11 +1084,11 @@ extern "C" { * * F_failure (with error bit) on any other error. * - * @see pthread_cond_signal() + * @see pthread_cond_broadcast() */ -#ifndef _di_f_thread_condition_signal_ - extern f_status_t f_thread_condition_signal(f_thread_condition_t * const condition); -#endif // _di_f_thread_condition_signal_ +#ifndef _di_f_thread_condition_signal_all_ + extern f_status_t f_thread_condition_signal_all(f_thread_condition_t * const condition); +#endif // _di_f_thread_condition_signal_all_ /** * Wait until condition is triggered. @@ -1578,7 +1578,7 @@ extern "C" { * @see pthread_rwlock_timedrdlock() */ #ifndef _di_f_thread_lock_read_timed_ - extern f_status_t f_thread_lock_read_timed(const struct timespec *timeout, f_thread_lock_t * const lock); + extern f_status_t f_thread_lock_read_timed(const struct timespec * const timeout, f_thread_lock_t * const lock); #endif // _di_f_thread_lock_read_timed_ /** @@ -1653,7 +1653,7 @@ extern "C" { * @see pthread_rwlock_timedwrlock() */ #ifndef _di_f_thread_lock_write_timed_ - extern f_status_t f_thread_lock_write_timed(const struct timespec *timeout, f_thread_lock_t * const lock); + extern f_status_t f_thread_lock_write_timed(const struct timespec * const timeout, f_thread_lock_t * const lock); #endif // _di_f_thread_lock_write_timed_ /** @@ -1766,6 +1766,51 @@ extern "C" { #endif // _di_f_thread_mutex_attribute_priority_ceiling_set_ /** + * Get the mutex attribute protocol. + * + * @param attribute + * The thread mutex attribute. + * @param protocol + * The protocol. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_prohibited (with error bit) if not allowed to perform the operation. + * + * F_failure (with error bit) on any other error. + * + * @see pthread_mutexattr_getprotocol() + */ +#ifndef _di_f_thread_mutex_attribute_protocol_get_ + extern f_status_t f_thread_mutex_attribute_protocol_get(const f_thread_mutex_attribute_t * const attribute, int * const protocol); +#endif // _di_f_thread_mutex_attribute_protocol_get_ + +/** + * Set the mutex attribute protocol. + * + * @param protocol + * The protocol. + * @param attribute + * The thread mutex attribute. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_prohibited (with error bit) if not allowed to perform the operation. + * F_supported_not (with error bit) if the protocol is not supported. + * + * F_failure (with error bit) on any other error. + * + * @see pthread_mutexattr_setprotocol() + */ +#ifndef _di_f_thread_mutex_attribute_protocol_set_ + extern f_status_t f_thread_mutex_attribute_protocol_set(const int protocol, f_thread_mutex_attribute_t * const attribute); +#endif // _di_f_thread_mutex_attribute_protocol_set_ + +/** * Get the mutex attribute process shared thread attribute. * * @param attribute @@ -1850,51 +1895,6 @@ extern "C" { #endif // _di_f_thread_mutex_attribute_type_set_ /** - * Get the mutex attribute protocol. - * - * @param attribute - * The thread mutex attribute. - * @param protocol - * The protocol. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * F_prohibited (with error bit) if not allowed to perform the operation. - * - * F_failure (with error bit) on any other error. - * - * @see pthread_mutexattr_getprotocol() - */ -#ifndef _di_f_thread_mutex_attribute_protocol_get_ - extern f_status_t f_thread_mutex_attribute_protocol_get(const f_thread_mutex_attribute_t * const attribute, int * const protocol); -#endif // _di_f_thread_mutex_attribute_protocol_get_ - -/** - * Set the mutex attribute protocol. - * - * @param protocol - * The protocol. - * @param attribute - * The thread mutex attribute. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * F_prohibited (with error bit) if not allowed to perform the operation. - * F_supported_not (with error bit) if the protocol is not supported. - * - * F_failure (with error bit) on any other error. - * - * @see pthread_mutexattr_setprotocol() - */ -#ifndef _di_f_thread_mutex_attribute_protocol_set_ - extern f_status_t f_thread_mutex_attribute_protocol_set(const int protocol, f_thread_mutex_attribute_t * const attribute); -#endif // _di_f_thread_mutex_attribute_protocol_set_ - -/** * Create a thread mutex. * * @param attribute @@ -1994,7 +1994,7 @@ extern "C" { * @see pthread_mutex_timedlock() */ #ifndef _di_f_thread_mutex_lock_timed_ - extern f_status_t f_thread_mutex_lock_timed(const struct timespec *timeout, f_thread_mutex_t * const mutex); + extern f_status_t f_thread_mutex_lock_timed(const struct timespec * const timeout, f_thread_mutex_t * const mutex); #endif // _di_f_thread_mutex_lock_timed_ /** @@ -2373,7 +2373,7 @@ extern "C" { * @see sem_timedwait() */ #ifndef _di_f_thread_semaphore_lock_timed_ - extern f_status_t f_thread_semaphore_lock_timed(const struct timespec *timeout, f_thread_semaphore_t * const semaphore); + extern f_status_t f_thread_semaphore_lock_timed(const struct timespec * const timeout, f_thread_semaphore_t * const semaphore); #endif // _di_f_thread_semaphore_lock_timed_ /** -- 1.8.3.1