#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_)
f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *barrier) {
- if (pthread_barrier_destroy(barrier)) {
- if (errno == EBUSY) return F_status_set_error(F_busy);
- if (errno == EINVAL) return F_status_set_error(F_parameter);
+ const int error = pthread_barrier_destroy(barrier);
+
+ if (error) {
+ if (error == EBUSY) return F_status_set_error(F_busy);
+ if (error == EINVAL) return F_status_set_error(F_parameter);
return F_status_set_error(F_failure);
}
#ifndef _di_f_thread_attribute_stack_get_
f_status_t f_thread_attribute_stack_get(const f_thread_attribute_t attribute, size_t * const stack_size, void **stack) {
#ifndef _di_level_0_parameter_checking_
+ if (!stack_size) return F_status_set_error(F_parameter);
if (!stack) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
#ifndef _di_f_thread_attribute_stack_set_
f_status_t f_thread_attribute_stack_set(const size_t stack_size, void * const stack, f_thread_attribute_t * const attribute) {
#ifndef _di_level_0_parameter_checking_
+ if (!stack) return F_status_set_error(F_parameter);
if (!attribute) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
const int error = pthread_attr_getstacksize(&attribute, stack_size);
if (error) {
+ if (error == EINVAL) return F_status_set_error(F_parameter);
+
return F_status_set_error(F_failure);
}
#ifndef _di_f_thread_barrier_attribute_create_
f_status_t f_thread_barrier_attribute_create(f_thread_barrier_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_barrierattr_init(attribute);
#endif // _di_f_thread_barrier_attribute_shared_set_
#ifndef _di_f_thread_barrier_create_
- f_status_t f_thread_barrier_create(const unsigned int count, f_thread_barrier_attribute_t * const attribute, f_thread_barrier_t * const barrier) {
+ f_status_t f_thread_barrier_create(const unsigned int count, f_thread_barrier_attribute_t * const attribute, f_thread_barrier_t *barrier) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!barrier) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
const int error = pthread_barrier_init(barrier, attribute, count);
/**
* Create (initialize) a thread barrier structure.
*
+ * @param count
+ * The number of threads that must call the barrier wait function before any can successfully return.
+ * @param attribute
+ * (optional) The default attributes to initialize the barrier to.
+ * Set to NULL to not use (in which case the default barrier attributes are used).
* @param barrier
- * (optional) The barrier to set.
- * Set to NULL to not use (in which case the default barrier is used).
+ * The barrier to set.
*
* @return
* F_none on success.
* @see pthread_barrier_init()
*/
#ifndef _di_f_thread_barrier_create_
- extern f_status_t f_thread_barrier_create(const unsigned int count, f_thread_barrier_attribute_t * const attribute, f_thread_barrier_t * const barrier);
+ extern f_status_t f_thread_barrier_create(const unsigned int count, f_thread_barrier_attribute_t * const attribute, f_thread_barrier_t *barrier);
#endif // _di_f_thread_barrier_create_
/**