This in particular extracts the structure related functions into separate files to better follow the functional oriented programming practice.
build_sources_library type_array/private-array_length.c type_array/private-cell.c type_array/private-fll_id.c type_array/private-int8.c type_array/private-int16.c type_array/private-int32.c type_array/private-int64.c type_array/private-int128.c type_array/private-state.c type_array/private-status.c type_array/private-uint8.c type_array/private-uint16.c type_array/private-uint32.c type_array/private-uint64.c type_array/private-uint128.c
build_sources_library utf.c private-utf.c private-utf_alphabetic.c private-utf_combining.c private-utf_control.c private-utf_digit.c private-utf_emoji.c private-utf_numeric.c private-utf_phonetic.c private-utf_private.c private-utf_punctuation.c private-utf_subscript.c private-utf_superscript.c private-utf_symbol.c private-utf_valid.c private-utf_whitespace.c private-utf_wide.c private-utf_word.c private-utf_zero_width.c
build_sources_library utf/common.c utf/convert.c utf/dynamic.c utf/is.c utf/is_character.c utf/map.c utf/private-dynamic.c utf/private-map.c utf/private-map_multi.c utf/private-triple.c utf/private-is_unassigned.c utf/private-string.c utf/static.c utf/string.c utf/triple.c
-build_sources_library-level thread.c private-thread.c
-build_sources_library_shared
-build_sources_library_static
+
+build_sources_library-level thread.c private-thread.c thread/attribute.c thread/barrier.c thread/barrier_attribute.c thread/condition.c thread/condition_attribute.c thread/id.c thread/key.c thread/lock.c thread/lock_attribute.c thread/mutex.c thread/mutex_attribute.c thread/once.c thread/semaphore.c thread/set.c thread/spin.c
build_sources_headers account.h account/common.h
build_sources_headers capability.h capability/common.h
build_sources_headers type_array.h type_array/common.h
build_sources_headers type_array/array_length.h type_array/cell.h type_array/fll_id.h type_array/int8.h type_array/int16.h type_array/int32.h type_array/int64.h type_array/int128.h type_array/state.h type_array/status.h type_array/uint8.h type_array/uint16.h type_array/uint32.h type_array/uint64.h type_array/uint128.h
build_sources_headers utf.h utf/common.h utf/convert.h utf/dynamic.h utf/is.h utf/is_character.h utf/map.h utf/map_multi.h utf/static.h utf/string.h utf/triple.h
-build_sources_headers-level thread.h thread/common.h
+
+build_sources_headers-level thread.h thread/attribute.h thread/barrier.h thread/barrier_attribute.h thread/condition.h thread/condition_attribute.h thread/id.h thread/key.h thread/lock.h thread/lock_attribute.h thread/mutex.h thread/mutex_attribute.h thread/once.h thread/semaphore.h thread/set.h thread/spin.h
build_script yes
build_shared yes
build_sources_library level_2/program.c level_2/program/common.c
build_sources_library level_2/status_string.c
-build_sources_library-monolithic level_0/thread.c level_0/private-thread.c
+build_sources_library-monolithic level_0/thread.c level_0/private-thread.c level_0/thread/attribute.c level_0/thread/barrier.c level_0/thread/barrier_attribute.c level_0/thread/condition.c level_0/thread/condition_attribute.c level_0/thread/id.c level_0/thread/key.c level_0/thread/lock.c level_0/thread/lock_attribute.c level_0/thread/mutex.c level_0/thread/mutex_attribute.c level_0/thread/once.c level_0/thread/semaphore.c level_0/thread/set.c level_0/thread/spin.c
build_sources_headers level_0/account.h level_0/account/common.h
build_sources_headers level_0/capability.h level_0/capability/common.h
build_sources_headers level_2/program.h level_2/program/common.h
build_sources_headers level_2/status_string.h
-build_sources_headers-level level_0/thread.h level_0/thread/common.h
-
-build_sources_headers-monolithic level_0/thread.h level_0/thread/common.h
+build_sources_headers-monolithic level_0/thread.h level_0/thread/attribute.h level_0/thread/barrier.h level_0/thread/barrier_attribute.h level_0/thread/condition.h level_0/thread/condition_attribute.h level_0/thread/id.h level_0/thread/key.h level_0/thread/lock.h level_0/thread/lock_attribute.h level_0/thread/mutex.h level_0/thread/mutex_attribute.h level_0/thread/once.h level_0/thread/semaphore.h level_0/thread/set.h level_0/thread/spin.h
build_script yes
build_shared yes
#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_)
f_status_t private_f_thread_attributes_adjust(const f_array_length_t length, f_thread_attributes_t * const attributes) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < attributes->size; ++i) {
#if !defined(_di_f_thread_attributes_decrease_) || !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_)
f_status_t private_f_thread_attributes_resize(const f_array_length_t length, f_thread_attributes_t * const attributes) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < attributes->size; ++i) {
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);
+
return F_status_set_error(F_failure);
}
#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_)
f_status_t private_f_thread_barriers_adjust(const f_array_length_t length, f_thread_barriers_t * const barriers) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < barriers->size; ++i) {
#if !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_)
f_status_t private_f_thread_barriers_resize(const f_array_length_t length, f_thread_barriers_t * const barriers) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < barriers->size; ++i) {
#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_)
f_status_t private_f_thread_barrier_attributes_adjust(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < attributes->size; ++i) {
#if !defined(_di_f_thread_barrier_attributes_decrease_) || !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_)
f_status_t private_f_thread_barrier_attributes_resize(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < attributes->size; ++i) {
#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_)
f_status_t private_f_thread_condition_attributes_adjust(const f_array_length_t length, f_thread_condition_attributes_t * const attributes) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < attributes->size; ++i) {
#if !defined(_di_f_thread_condition_attributes_decrease_) || !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_)
f_status_t private_f_thread_condition_attributes_resize(const f_array_length_t length, f_thread_condition_attributes_t * const attributes) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < attributes->size; ++i) {
#if !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_)
f_status_t private_f_thread_conditions_adjust(const f_array_length_t length, f_thread_conditions_t * const conditions) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < conditions->size; ++i) {
#if !defined(_di_f_thread_conditions_decrease_) || !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_)
f_status_t private_f_thread_conditions_resize(const f_array_length_t length, f_thread_conditions_t * const conditions) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < conditions->size; ++i) {
}
#endif // !defined(_di_f_thread_conditions_decrease_) || !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_)
+#if !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_)
+ f_status_t private_f_thread_ids_adjust(const f_array_length_t length, f_thread_ids_t * const ids) {
+
+ f_status_t status = F_none;
+
+ for (f_array_length_t i = length; i < ids->size; ++i) {
+ memset(&ids->array[i], 0, sizeof(f_thread_id_t));
+ } // for
+
+ status = f_memory_adjust(ids->size, length, sizeof(f_thread_id_t), (void **) & ids->array);
+ if (F_status_is_error(status)) return status;
+
+ ids->size = length;
+
+ if (ids->used > ids->size) {
+ ids->used = length;
+ }
+
+ return F_none;
+ }
+#endif // !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_)
+
+#if !defined(_di_f_thread_ids_decrease_) || !defined(_di_f_thread_ids_decrease_by_) || !defined(_di_f_thread_ids_increase_) || !defined(_di_f_thread_ids_increase_by_)
+ f_status_t private_f_thread_ids_resize(const f_array_length_t length, f_thread_ids_t * const ids) {
+
+ const f_status_t status = f_memory_resize(ids->size, length, sizeof(f_thread_id_t), (void **) & ids->array);
+ if (F_status_is_error(status)) return status;
+
+ ids->size = length;
+
+ if (ids->used > ids->size) {
+ ids->used = length;
+ }
+
+ return F_none;
+ }
+#endif // !defined(_di_f_thread_ids_decrease_) || !defined(_di_f_thread_ids_decrease_by_) || !defined(_di_f_thread_ids_increase_) || !defined(_di_f_thread_ids_increase_by_)
+
#if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) || !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) || !defined(_di_f_thread_keys_resize_)
f_status_t private_f_thread_key_delete(f_thread_key_t *key) {
#if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_)
f_status_t private_f_thread_keys_adjust(const f_array_length_t length, f_thread_keys_t * const keys) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < keys->size; ++i) {
#if !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_)
f_status_t private_f_thread_keys_resize(const f_array_length_t length, f_thread_keys_t * const keys) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < keys->size; ++i) {
}
#endif // !defined(_di_f_thread_keys_decrease_) || !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_)
-#if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_)
- f_status_t private_f_thread_lock_delete(f_thread_lock_t *lock) {
+#if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_)
+ f_status_t private_f_thread_lock_attribute_delete(f_thread_lock_attribute_t *attribute) {
- const int error = pthread_rwlock_destroy(lock);
+ const int error = pthread_rwlockattr_destroy(attribute);
if (error) {
if (error == EBUSY) return F_status_set_error(F_busy);
return F_none;
}
-#endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_)
+#endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_)
+
+#if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_)
+ f_status_t private_f_thread_lock_attributes_adjust(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) {
-#if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_)
- f_status_t private_f_thread_locks_adjust(const f_array_length_t length, f_thread_locks_t * const locks) {
f_status_t status = F_none;
- for (f_array_length_t i = length; i < locks->size; ++i) {
+ for (f_array_length_t i = length; i < attributes->size; ++i) {
- status = private_f_thread_lock_delete(&locks->array[i]);
+ status = private_f_thread_lock_attribute_delete(&attributes->array[i]);
if (F_status_is_error(status)) return status;
} // for
- status = f_memory_adjust(locks->size, length, sizeof(f_thread_lock_t), (void **) & locks->array);
+ status = f_memory_adjust(attributes->size, length, sizeof(f_thread_lock_t), (void **) & attributes->array);
if (F_status_is_error(status)) return status;
- locks->size = length;
+ attributes->size = length;
- if (locks->used > locks->size) {
- locks->used = length;
+ if (attributes->used > attributes->size) {
+ attributes->used = length;
}
return F_none;
}
-#endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_)
+#endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_)
+
+#if !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_)
+ f_status_t private_f_thread_lock_attributes_resize(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) {
-#if !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_)
- f_status_t private_f_thread_locks_resize(const f_array_length_t length, f_thread_locks_t * const locks) {
f_status_t status = F_none;
- for (f_array_length_t i = length; i < locks->size; ++i) {
+ for (f_array_length_t i = length; i < attributes->size; ++i) {
- status = private_f_thread_lock_delete(&locks->array[i]);
+ status = private_f_thread_lock_attribute_delete(&attributes->array[i]);
if (F_status_is_error(status)) return status;
} // for
- status = f_memory_resize(locks->size, length, sizeof(f_thread_lock_t), (void **) & locks->array);
+ status = f_memory_resize(attributes->size, length, sizeof(f_thread_lock_t), (void **) & attributes->array);
if (F_status_is_error(status)) return status;
- locks->size = length;
+ attributes->size = length;
- if (locks->used > locks->size) {
- locks->used = length;
+ if (attributes->used > attributes->size) {
+ attributes->used = length;
}
return F_none;
}
-#endif // !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_)
+#endif // !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_)
-#if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_)
- f_status_t private_f_thread_lock_attribute_delete(f_thread_lock_attribute_t *attribute) {
+#if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_)
+ f_status_t private_f_thread_lock_delete(f_thread_lock_t *lock) {
- const int error = pthread_rwlockattr_destroy(attribute);
+ const int error = pthread_rwlock_destroy(lock);
if (error) {
if (error == EBUSY) return F_status_set_error(F_busy);
return F_none;
}
-#endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_)
+#endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_)
+
+#if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_)
+ f_status_t private_f_thread_locks_adjust(const f_array_length_t length, f_thread_locks_t * const locks) {
-#if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_)
- f_status_t private_f_thread_lock_attributes_adjust(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) {
f_status_t status = F_none;
- for (f_array_length_t i = length; i < attributes->size; ++i) {
+ for (f_array_length_t i = length; i < locks->size; ++i) {
- status = private_f_thread_lock_attribute_delete(&attributes->array[i]);
+ status = private_f_thread_lock_delete(&locks->array[i]);
if (F_status_is_error(status)) return status;
} // for
- status = f_memory_adjust(attributes->size, length, sizeof(f_thread_lock_t), (void **) & attributes->array);
+ status = f_memory_adjust(locks->size, length, sizeof(f_thread_lock_t), (void **) & locks->array);
if (F_status_is_error(status)) return status;
- attributes->size = length;
+ locks->size = length;
- if (attributes->used > attributes->size) {
- attributes->used = length;
+ if (locks->used > locks->size) {
+ locks->used = length;
}
return F_none;
}
-#endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_)
+#endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_)
+
+#if !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_)
+ f_status_t private_f_thread_locks_resize(const f_array_length_t length, f_thread_locks_t * const locks) {
-#if !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_)
- f_status_t private_f_thread_lock_attributes_resize(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) {
f_status_t status = F_none;
- for (f_array_length_t i = length; i < attributes->size; ++i) {
+ for (f_array_length_t i = length; i < locks->size; ++i) {
- status = private_f_thread_lock_attribute_delete(&attributes->array[i]);
+ status = private_f_thread_lock_delete(&locks->array[i]);
if (F_status_is_error(status)) return status;
} // for
- status = f_memory_resize(attributes->size, length, sizeof(f_thread_lock_t), (void **) & attributes->array);
+ status = f_memory_resize(locks->size, length, sizeof(f_thread_lock_t), (void **) & locks->array);
if (F_status_is_error(status)) return status;
- attributes->size = length;
+ locks->size = length;
- if (attributes->used > attributes->size) {
- attributes->used = length;
+ if (locks->used > locks->size) {
+ locks->used = length;
}
return F_none;
}
-#endif // !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_)
+#endif // !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_)
#if !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) || !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) || !defined(_di_f_thread_mutex_attributes_resize_)
f_status_t private_f_thread_mutex_attribute_delete(f_thread_mutex_attribute_t *attribute) {
#if !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_)
f_status_t private_f_thread_mutex_attributes_adjust(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < attributes->size; ++i) {
#if !defined(_di_f_thread_mutex_attributes_decrease_) || !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_)
f_status_t private_f_thread_mutex_attributes_resize(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < attributes->size; ++i) {
#if !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_)
f_status_t private_f_thread_mutexs_adjust(const f_array_length_t length, f_thread_mutexs_t * const mutexs) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < mutexs->size; ++i) {
#if !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_)
f_status_t private_f_thread_mutexs_resize(const f_array_length_t length, f_thread_mutexs_t * const mutexs) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < mutexs->size; ++i) {
}
#endif // !defined(_di_f_thread_mutexs_decrease_) || !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_)
+#if !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_)
+ f_status_t private_f_thread_onces_adjust(const f_array_length_t length, f_thread_onces_t * const onces) {
+
+ for (f_array_length_t i = length; i < onces->size; ++i) {
+ memset(&onces->array[i], 0, sizeof(f_thread_once_t));
+ } // for
+
+ const f_status_t status = f_memory_adjust(onces->size, length, sizeof(f_thread_once_t), (void **) & onces->array);
+ if (F_status_is_error(status)) return status;
+
+ onces->size = length;
+
+ if (onces->used > onces->size) {
+ onces->used = length;
+ }
+
+ return F_none;
+ }
+#endif // !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_)
+
+#if !defined(_di_f_thread_onces_decrease_) || !defined(_di_f_thread_onces_decrease_by_) || !defined(_di_f_thread_onces_increase_) || !defined(_di_f_thread_onces_increase_by_)
+ f_status_t private_f_thread_onces_resize(const f_array_length_t length, f_thread_onces_t * const onces) {
+
+ f_status_t status = F_none;
+
+ status = f_memory_resize(onces->size, length, sizeof(f_thread_once_t), (void **) & onces->array);
+ if (F_status_is_error(status)) return status;
+
+ onces->size = length;
+
+ if (onces->used > onces->size) {
+ onces->used = length;
+ }
+
+ return F_none;
+ }
+#endif // !defined(_di_f_thread_onces_decrease_) || !defined(_di_f_thread_onces_decrease_by_) || !defined(_di_f_thread_onces_increase_) || !defined(_di_f_thread_onces_increase_by_)
+
#if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) || !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) || !defined(_di_f_thread_semaphores_resize_)
f_status_t private_f_thread_semaphore_delete(f_thread_semaphore_t *semaphore) {
#if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_)
f_status_t private_f_thread_semaphores_adjust(const f_array_length_t length, f_thread_semaphores_t * const semaphores) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < semaphores->size; ++i) {
#if !defined(_di_f_thread_semaphores_decrease_) || !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_)
f_status_t private_f_thread_semaphores_resize(const f_array_length_t length, f_thread_semaphores_t * const semaphores) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < semaphores->size; ++i) {
#if !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_)
f_status_t private_f_thread_sets_adjust(const f_array_length_t length, f_thread_sets_t * const sets) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < sets->size; ++i) {
#if !defined(_di_f_thread_sets_decrease_) || !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_)
f_status_t private_f_thread_sets_resize(const f_array_length_t length, f_thread_sets_t * const sets) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < sets->size; ++i) {
#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_)
f_status_t private_f_thread_spins_adjust(const f_array_length_t length, f_thread_spins_t * const spins) {
+
f_status_t status = F_none;
for (f_array_length_t i = length; i < spins->size; ++i) {
#endif // !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_)
/**
+ * Private implementation for resizing.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ * The new size to use.
+ * @param ids
+ * The ids to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_adjust().
+ *
+ * @see f_memory_adjust()
+ * @see f_thread_ids_adjust()
+ * @see f_thread_ids_decimate_by()
+ */
+#if !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_)
+ extern f_status_t private_f_thread_ids_adjust(const f_array_length_t length, f_thread_ids_t * const ids) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_)
+
+/**
+ * Private implementation for resizing.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ * The new size to use.
+ * @param ids
+ * The ids to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_resize().
+ *
+ * @see f_memory_resize()
+ * @see f_thread_ids_decrease_by()
+ * @see f_thread_ids_increase()
+ * @see f_thread_ids_increase_by()
+ */
+#if !defined(_di_f_thread_ids_decrease_by_) || !defined(_di_f_thread_ids_increase_) || !defined(_di_f_thread_ids_increase_by_)
+ extern f_status_t private_f_thread_ids_resize(const f_array_length_t length, f_thread_ids_t * const ids) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_ids_decrease_by_) || !defined(_di_f_thread_ids_increase_) || !defined(_di_f_thread_ids_increase_by_)
+
+/**
* Private implementation for deleting (and destroying).
*
* Intended to be shared to each of the different implementation variations.
*
* Intended to be shared to each of the different implementation variations.
*
- * @param lock
- * The locks to delete.
+ * @param attribute
+ * The attribute to delete.
*
* @return
* F_none on success.
* F_failure (with error bit) on error.
* F_parameter (with error bit) if a parameter is invalid.
*
- * @see pthread_rwlock_destroy()
+ * @see pthread_rwlockattr_destroy()
*
- * @see f_thread_locks_adjust()
- * @see f_thread_locks_decimate_by()
- * @see f_thread_locks_decrease()
- * @see f_thread_locks_decrease_by()
- * @see f_thread_locks_increase()
- * @see f_thread_locks_increase_by()
- * @see f_thread_locks_resize()
+ * @see f_thread_lock_attributes_adjust()
+ * @see f_thread_lock_attributes_decimate_by()
+ * @see f_thread_lock_attributes_decrease()
+ * @see f_thread_lock_attributes_decrease_by()
+ * @see f_thread_lock_attributes_increase()
+ * @see f_thread_lock_attributes_increase_by()
+ * @see f_thread_lock_attributes_resize()
*/
-#if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_)
- extern f_status_t private_f_thread_lock_delete(f_thread_lock_t *lock) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_)
+#if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_)
+ extern f_status_t private_f_thread_lock_attribute_delete(f_thread_lock_attribute_t *attribute) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_)
/**
* Private implementation for resizing.
*
* @param length
* The new size to use.
- * @param locks
- * The locks to adjust.
+ * @param attributes
+ * The attributes to adjust.
*
* @return
* F_none on success.
* Errors (with error bit) from: f_memory_adjust().
*
* @see f_memory_adjust()
- * @see f_thread_locks_adjust()
- * @see f_thread_locks_decimate_by()
+ * @see f_thread_lock_attributes_adjust()
+ * @see f_thread_lock_attributes_decimate_by()
*/
-#if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_)
- extern f_status_t private_f_thread_locks_adjust(const f_array_length_t length, f_thread_locks_t * const locks) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_)
+#if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_)
+ extern f_status_t private_f_thread_lock_attributes_adjust(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_)
/**
* Private implementation for resizing.
*
* @param length
* The new size to use.
- * @param locks
- * The locks to resize.
+ * @param attributes
+ * The attributes to resize.
*
* @return
* F_none on success.
* Errors (with error bit) from: f_memory_resize().
*
* @see f_memory_resize()
- * @see f_thread_locks_decrease_by()
- * @see f_thread_locks_increase()
- * @see f_thread_locks_increase_by()
+ * @see f_thread_lock_attributes_decrease_by()
+ * @see f_thread_lock_attributes_increase()
+ * @see f_thread_lock_attributes_increase_by()
*/
-#if !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_)
- extern f_status_t private_f_thread_locks_resize(const f_array_length_t length, f_thread_locks_t * const locks) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_)
+#if !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_)
+ extern f_status_t private_f_thread_lock_attributes_resize(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_)
/**
* Private implementation for deleting (and destroying).
*
* Intended to be shared to each of the different implementation variations.
*
- * @param attribute
- * The attribute to delete.
+ * @param lock
+ * The locks to delete.
*
* @return
* F_none on success.
* F_failure (with error bit) on error.
* F_parameter (with error bit) if a parameter is invalid.
*
- * @see pthread_rwlockattr_destroy()
+ * @see pthread_rwlock_destroy()
*
- * @see f_thread_lock_attributes_adjust()
- * @see f_thread_lock_attributes_decimate_by()
- * @see f_thread_lock_attributes_decrease()
- * @see f_thread_lock_attributes_decrease_by()
- * @see f_thread_lock_attributes_increase()
- * @see f_thread_lock_attributes_increase_by()
- * @see f_thread_lock_attributes_resize()
+ * @see f_thread_locks_adjust()
+ * @see f_thread_locks_decimate_by()
+ * @see f_thread_locks_decrease()
+ * @see f_thread_locks_decrease_by()
+ * @see f_thread_locks_increase()
+ * @see f_thread_locks_increase_by()
+ * @see f_thread_locks_resize()
*/
-#if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_)
- extern f_status_t private_f_thread_lock_attribute_delete(f_thread_lock_attribute_t *attribute) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_) || !defined(_di_f_thread_lock_attributes_decrease_) || !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_) || !defined(_di_f_thread_lock_attributes_resize_)
+#if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_)
+ extern f_status_t private_f_thread_lock_delete(f_thread_lock_t *lock) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_) || !defined(_di_f_thread_locks_decrease_) || !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_) || !defined(_di_f_thread_locks_resize_)
/**
* Private implementation for resizing.
*
* @param length
* The new size to use.
- * @param attributes
- * The attributes to adjust.
+ * @param locks
+ * The locks to adjust.
*
* @return
* F_none on success.
* Errors (with error bit) from: f_memory_adjust().
*
* @see f_memory_adjust()
- * @see f_thread_lock_attributes_adjust()
- * @see f_thread_lock_attributes_decimate_by()
+ * @see f_thread_locks_adjust()
+ * @see f_thread_locks_decimate_by()
*/
-#if !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_)
- extern f_status_t private_f_thread_lock_attributes_adjust(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_thread_lock_attributes_adjust_) || !defined(_di_f_thread_lock_attributes_decimate_by_)
+#if !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_)
+ extern f_status_t private_f_thread_locks_adjust(const f_array_length_t length, f_thread_locks_t * const locks) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_locks_adjust_) || !defined(_di_f_thread_locks_decimate_by_)
/**
* Private implementation for resizing.
*
* @param length
* The new size to use.
- * @param attributes
- * The attributes to resize.
+ * @param locks
+ * The locks to resize.
*
* @return
* F_none on success.
* Errors (with error bit) from: f_memory_resize().
*
* @see f_memory_resize()
- * @see f_thread_lock_attributes_decrease_by()
- * @see f_thread_lock_attributes_increase()
- * @see f_thread_lock_attributes_increase_by()
+ * @see f_thread_locks_decrease_by()
+ * @see f_thread_locks_increase()
+ * @see f_thread_locks_increase_by()
*/
-#if !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_)
- extern f_status_t private_f_thread_lock_attributes_resize(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) F_attribute_visibility_internal_d;
-#endif // !defined(_di_f_thread_lock_attributes_decrease_by_) || !defined(_di_f_thread_lock_attributes_increase_) || !defined(_di_f_thread_lock_attributes_increase_by_)
-
+#if !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_)
+ extern f_status_t private_f_thread_locks_resize(const f_array_length_t length, f_thread_locks_t * const locks) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_locks_decrease_by_) || !defined(_di_f_thread_locks_increase_) || !defined(_di_f_thread_locks_increase_by_)
/**
* Private implementation for deleting (and destroying).
*
#endif // !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_)
/**
+ * Private implementation for resizing.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ * The new size to use.
+ * @param onces
+ * The onces to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_adjust().
+ *
+ * @see f_memory_adjust()
+ * @see f_thread_onces_adjust()
+ * @see f_thread_onces_decimate_by()
+ */
+#if !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_)
+ extern f_status_t private_f_thread_onces_adjust(const f_array_length_t length, f_thread_onces_t * const onces) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_)
+
+/**
+ * Private implementation for resizing.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ * The new size to use.
+ * @param onces
+ * The onces to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * Errors (with error bit) from: f_memory_resize().
+ *
+ * @see f_memory_resize()
+ * @see f_thread_onces_decrease_by()
+ * @see f_thread_onces_increase()
+ * @see f_thread_onces_increase_by()
+ */
+#if !defined(_di_f_thread_onces_decrease_by_) || !defined(_di_f_thread_onces_increase_) || !defined(_di_f_thread_onces_increase_by_)
+ extern f_status_t private_f_thread_onces_resize(const f_array_length_t length, f_thread_onces_t * const onces) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_thread_onces_decrease_by_) || !defined(_di_f_thread_onces_increase_) || !defined(_di_f_thread_onces_increase_by_)
+
+/**
* Private implementation for deleting (and destroying).
*
* Intended to be shared to each of the different implementation variations.
}
#endif // defined(_pthread_attr_unsupported_) && !defined(_di_f_thread_attribute_affinity_set_)
-#ifndef _di_f_thread_attribute_clock_get_
- f_status_t f_thread_attribute_clock_get(const f_thread_condition_attribute_t * const attribute, clockid_t * const id) {
+#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_
- if (pthread_condattr_getclock(attribute, id)) {
+ 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_clock_get_
+#endif // _di_f_thread_attribute_condition_clock_get_
-#ifndef _di_f_thread_attribute_clock_set_
- f_status_t f_thread_attribute_clock_set(const clockid_t id, f_thread_condition_attribute_t * const attribute) {
+#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_
return F_none;
}
-#endif // _di_f_thread_attribute_clock_set_
+#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) {
if (!shared) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (pthread_condattr_getpshared(attribute, shared)) {
+ 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);
}
#ifndef _di_f_thread_attribute_create_
f_status_t f_thread_attribute_create(f_thread_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_attr_init(attribute);
const int error = pthread_setattr_default_np(attribute);
if (error) {
- if (error == ENOMEM) return F_status_set_error(F_memory_not);
if (error == EINVAL) return F_status_set_error(F_parameter);
+ if (error == ENOMEM) return F_status_set_error(F_memory_not);
return F_status_set_error(F_failure);
}
}
#endif // _di_f_thread_attribute_stack_size_set_
-#ifndef _di_f_thread_attributes_adjust_
- f_status_t f_thread_attributes_adjust(const f_array_length_t length, f_thread_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_attributes_adjust(length, attributes);
- }
-#endif // _di_f_thread_attributes_adjust_
-
-#ifndef _di_f_thread_attributes_decimate_by_
- f_status_t f_thread_attributes_decimate_by(const f_array_length_t amount, f_thread_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!amount) return F_status_set_error(F_parameter);
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (attributes->size - amount > 0) {
- return private_f_thread_attributes_adjust(attributes->size - amount, attributes);
- }
-
- return private_f_thread_attributes_adjust(0, attributes);
- }
-#endif // _di_f_thread_attributes_decimate_by_
-
-#ifndef _di_f_thread_attributes_decrease_by_
- f_status_t f_thread_attributes_decrease_by(const f_array_length_t amount, f_thread_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_attributes_resize(attributes->size - amount, attributes);
- }
-
- return private_f_thread_attributes_resize(0, attributes);
- }
-#endif // _di_f_thread_attributes_decrease_by_
-
-#ifndef _di_f_thread_attributes_increase_
- f_status_t f_thread_attributes_increase(const f_array_length_t step, f_thread_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && attributes->used + 1 > attributes->size) {
- f_array_length_t size = attributes->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (attributes->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_attributes_resize(size, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_attributes_increase_
-
-#ifndef _di_f_thread_attributes_increase_by_
- f_status_t f_thread_attributes_increase_by(const f_array_length_t amount, f_thread_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->used + amount > attributes->size) {
- if (attributes->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_attributes_resize(attributes->used + amount, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_attributes_increase_by_
-
-#ifndef _di_f_thread_attributes_resize_
- f_status_t f_thread_attributes_resize(const f_array_length_t length, f_thread_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_attributes_resize(length, attributes);
- }
-#endif // _di_f_thread_attributes_resize_
-
#ifndef _di_f_thread_barrier_attribute_create_
f_status_t f_thread_barrier_attribute_create(f_thread_barrier_attribute_t * const attribute) {
if (!shared) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (pthread_barrierattr_getpshared(attribute, shared)) {
+ const int error = pthread_barrierattr_getpshared(attribute, shared);
+
+ if (error) {
+ if (error == EINVAL) return F_status_set_error(F_parameter);
+
return F_status_set_error(F_failure);
}
}
#endif // _di_f_thread_barrier_attribute_shared_set_
-#ifndef _di_f_thread_barrier_attributes_adjust_
- f_status_t f_thread_barrier_attributes_adjust(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_barrier_attributes_adjust(length, attributes);
- }
-#endif // _di_f_thread_barrier_attributes_adjust_
-
-#ifndef _di_f_thread_barrier_attributes_decimate_by_
- f_status_t f_thread_barrier_attributes_decimate_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_barrier_attributes_adjust(attributes->size - amount, attributes);
- }
-
- return private_f_thread_barrier_attributes_adjust(0, attributes);
- }
-#endif // _di_f_thread_barrier_attributes_decimate_by_
-
-#ifndef _di_f_thread_barrier_attributes_decrease_by_
- f_status_t f_thread_barrier_attributes_decrease_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_barrier_attributes_resize(attributes->size - amount, attributes);
- }
-
- return private_f_thread_barrier_attributes_resize(0, attributes);
- }
-#endif // _di_f_thread_barrier_attributes_decrease_by_
-
-#ifndef _di_f_thread_barrier_attributes_increase_
- f_status_t f_thread_barrier_attributes_increase(const f_array_length_t step, f_thread_barrier_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && attributes->used + 1 > attributes->size) {
- f_array_length_t size = attributes->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (attributes->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_barrier_attributes_resize(size, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_barrier_attributes_increase_
-
-#ifndef _di_f_thread_barrier_attributes_increase_by_
- f_status_t f_thread_barrier_attributes_increase_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->used + amount > attributes->size) {
- if (attributes->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_barrier_attributes_resize(attributes->used + amount, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_barrier_attributes_increase_by_
-
-#ifndef _di_f_thread_barrier_attributes_resize_
- f_status_t f_thread_barrier_attributes_resize(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_barrier_attributes_resize(length, attributes);
- }
-#endif // _di_f_thread_barrier_attributes_resize_
-
#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) {
const int error = pthread_barrier_init(barrier, attribute, count);
if (error) {
+ if (error == EAGAIN) return F_status_set_error(F_resource_not);
+ if (error == EBUSY) return F_status_set_error(F_busy);
+ if (error == EINVAL) return F_status_set_error(F_parameter);
if (error == ENOMEM) return F_status_set_error(F_memory_not);
return F_status_set_error(F_failure);
}
#endif // _di_f_thread_barrier_wait_
-#ifndef _di_f_thread_barriers_adjust_
- f_status_t f_thread_barriers_adjust(const f_array_length_t length, f_thread_barriers_t * const barriers) {
- #ifndef _di_level_0_parameter_checking_
- if (!barriers) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_barriers_adjust(length, barriers);
- }
-#endif // _di_f_thread_barriers_adjust_
-
-#ifndef _di_f_thread_barriers_decimate_by_
- f_status_t f_thread_barriers_decimate_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) {
- #ifndef _di_level_0_parameter_checking_
- if (!barriers) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (barriers->size - amount > 0) {
- return private_f_thread_barriers_adjust(barriers->size - amount, barriers);
- }
-
- return private_f_thread_barriers_adjust(0, barriers);
- }
-#endif // _di_f_thread_barriers_decimate_by_
-
-#ifndef _di_f_thread_barriers_decrease_by_
- f_status_t f_thread_barriers_decrease_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) {
- #ifndef _di_level_0_parameter_checking_
- if (!barriers) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (barriers->size - amount > 0) {
- return private_f_thread_barriers_resize(barriers->size - amount, barriers);
- }
-
- return private_f_thread_barriers_resize(0, barriers);
- }
-#endif // _di_f_thread_barriers_decrease_by_
-
-#ifndef _di_f_thread_barriers_increase_
- f_status_t f_thread_barriers_increase(const f_array_length_t step, f_thread_barriers_t * const barriers) {
- #ifndef _di_level_0_parameter_checking_
- if (!barriers) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && barriers->used + 1 > barriers->size) {
- f_array_length_t size = barriers->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (barriers->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_barriers_resize(size, barriers);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_barriers_increase_
-
-#ifndef _di_f_thread_barriers_increase_by_
- f_status_t f_thread_barriers_increase_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) {
- #ifndef _di_level_0_parameter_checking_
- if (!barriers) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (barriers->used + amount > barriers->size) {
- if (barriers->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_barriers_resize(barriers->used + amount, barriers);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_barriers_increase_by_
-
-#ifndef _di_f_thread_barriers_resize_
- f_status_t f_thread_barriers_resize(const f_array_length_t length, f_thread_barriers_t * const barriers) {
- #ifndef _di_level_0_parameter_checking_
- if (!barriers) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_barriers_resize(length, barriers);
- }
-#endif // _di_f_thread_barriers_resize_
-
#ifndef _di_f_thread_caller_
f_thread_id_t f_thread_caller(void) {
+
return pthread_self();
}
#endif // _di_f_thread_caller_
}
#endif // _di_f_thread_condition_attribute_delete_
-#ifndef _di_f_thread_condition_attributes_adjust_
- f_status_t f_thread_condition_attributes_adjust(const f_array_length_t length, f_thread_condition_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_condition_attributes_adjust(length, attributes);
- }
-#endif // _di_f_thread_condition_attributes_adjust_
-
-#ifndef _di_f_thread_condition_attributes_decimate_by_
- f_status_t f_thread_condition_attributes_decimate_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_condition_attributes_adjust(attributes->size - amount, attributes);
- }
-
- return private_f_thread_condition_attributes_adjust(0, attributes);
- }
-#endif // _di_f_thread_condition_attributes_decimate_by_
-
-#ifndef _di_f_thread_condition_attributes_decrease_by_
- f_status_t f_thread_condition_attributes_decrease_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_condition_attributes_resize(attributes->size - amount, attributes);
- }
-
- return private_f_thread_condition_attributes_resize(0, attributes);
- }
-#endif // _di_f_thread_condition_attributes_decrease_by_
-
-#ifndef _di_f_thread_condition_attributes_increase_
- f_status_t f_thread_condition_attributes_increase(const f_array_length_t step, f_thread_condition_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && attributes->used + 1 > attributes->size) {
- f_array_length_t size = attributes->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (attributes->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_condition_attributes_resize(size, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_condition_attributes_increase_
-
-#ifndef _di_f_thread_condition_attributes_increase_by_
- f_status_t f_thread_condition_attributes_increase_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->used + amount > attributes->size) {
- if (attributes->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_condition_attributes_resize(attributes->used + amount, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_condition_attributes_increase_by_
-
-#ifndef _di_f_thread_condition_attributes_resize_
- f_status_t f_thread_condition_attributes_resize(const f_array_length_t length, f_thread_condition_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_condition_attributes_resize(length, attributes);
- }
-#endif // _di_f_thread_condition_attributes_resize_
-
#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_
}
#endif // _di_f_thread_condition_wait_timed_
-#ifndef _di_f_thread_conditions_adjust_
- f_status_t f_thread_conditions_adjust(const f_array_length_t length, f_thread_conditions_t * const conditions) {
- #ifndef _di_level_0_parameter_checking_
- if (!conditions) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_conditions_adjust(length, conditions);
- }
-#endif // _di_f_thread_conditions_adjust_
-
-#ifndef _di_f_thread_conditions_decimate_by_
- f_status_t f_thread_conditions_decimate_by(const f_array_length_t amount, f_thread_conditions_t * const conditions) {
- #ifndef _di_level_0_parameter_checking_
- if (!amount) return F_status_set_error(F_parameter);
- if (!conditions) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (conditions->size - amount > 0) {
- return private_f_thread_conditions_adjust(conditions->size - amount, conditions);
- }
-
- return private_f_thread_conditions_adjust(0, conditions);
- }
-#endif // _di_f_thread_conditions_decimate_by_
-
-#ifndef _di_f_thread_conditions_decrease_by_
- f_status_t f_thread_conditions_decrease_by(const f_array_length_t amount, f_thread_conditions_t * const conditions) {
- #ifndef _di_level_0_parameter_checking_
- if (!conditions) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (conditions->size - amount > 0) {
- return private_f_thread_conditions_resize(conditions->size - amount, conditions);
- }
-
- return private_f_thread_conditions_resize(0, conditions);
- }
-#endif // _di_f_thread_conditions_decrease_by_
-
-#ifndef _di_f_thread_conditions_increase_
- f_status_t f_thread_conditions_increase(const f_array_length_t step, f_thread_conditions_t * const conditions) {
- #ifndef _di_level_0_parameter_checking_
- if (!conditions) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && conditions->used + 1 > conditions->size) {
- f_array_length_t size = conditions->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (conditions->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_conditions_resize(size, conditions);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_conditions_increase_
-
-#ifndef _di_f_thread_conditions_increase_by_
- f_status_t f_thread_conditions_increase_by(const f_array_length_t amount, f_thread_conditions_t * const conditions) {
- #ifndef _di_level_0_parameter_checking_
- if (!conditions) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (conditions->used + amount > conditions->size) {
- if (conditions->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_conditions_resize(conditions->used + amount, conditions);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_conditions_increase_by_
-
-#ifndef _di_f_thread_conditions_resize_
- f_status_t f_thread_conditions_resize(const f_array_length_t length, f_thread_conditions_t * const conditions) {
- #ifndef _di_level_0_parameter_checking_
- if (!conditions) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_conditions_resize(length, conditions);
- }
-#endif // _di_f_thread_conditions_resize_
-
#ifndef _di_f_thread_create_
f_status_t f_thread_create(const f_thread_attribute_t * const attribute, f_thread_id_t * const id, void *(*routine) (void *), void *argument) {
#ifndef _di_level_0_parameter_checking_
}
#endif // _di_f_thread_key_set_
-#ifndef _di_f_thread_keys_adjust_
- f_status_t f_thread_keys_adjust(const f_array_length_t length, f_thread_keys_t * const keys) {
- #ifndef _di_level_0_parameter_checking_
- if (!keys) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_keys_adjust(length, keys);
- }
-#endif // _di_f_thread_keys_adjust_
-
-#ifndef _di_f_thread_keys_decimate_by_
- f_status_t f_thread_keys_decimate_by(const f_array_length_t amount, f_thread_keys_t * const keys) {
- #ifndef _di_level_0_parameter_checking_
- if (!keys) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (keys->size - amount > 0) {
- return private_f_thread_keys_adjust(keys->size - amount, keys);
- }
-
- return private_f_thread_keys_adjust(0, keys);
- }
-#endif // _di_f_thread_keys_decimate_by_
-
-#ifndef _di_f_thread_keys_decrease_by_
- f_status_t f_thread_keys_decrease_by(const f_array_length_t amount, f_thread_keys_t * const keys) {
- #ifndef _di_level_0_parameter_checking_
- if (!keys) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (keys->size - amount > 0) {
- return private_f_thread_keys_resize(keys->size - amount, keys);
- }
-
- return private_f_thread_keys_resize(0, keys);
- }
-#endif // _di_f_thread_keys_decrease_by_
-
-#ifndef _di_f_thread_keys_increase_
- f_status_t f_thread_keys_increase(const f_array_length_t step, f_thread_keys_t * const keys) {
- #ifndef _di_level_0_parameter_checking_
- if (!keys) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && keys->used + 1 > keys->size) {
- f_array_length_t size = keys->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (keys->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_keys_resize(size, keys);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_keys_increase_
-
-#ifndef _di_f_thread_keys_increase_by_
- f_status_t f_thread_keys_increase_by(const f_array_length_t amount, f_thread_keys_t * const keys) {
- #ifndef _di_level_0_parameter_checking_
- if (!keys) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (keys->used + amount > keys->size) {
- if (keys->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_keys_resize(keys->used + amount, keys);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_keys_increase_by_
-
-#ifndef _di_f_thread_keys_resize_
- f_status_t f_thread_keys_resize(const f_array_length_t length, f_thread_keys_t * const keys) {
- #ifndef _di_level_0_parameter_checking_
- if (!keys) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_keys_resize(length, keys);
- }
-#endif // _di_f_thread_keys_resize_
-
-#ifndef _di_f_thread_lock_attribute_create_
- f_status_t f_thread_lock_attribute_create(f_thread_lock_attribute_t * const attribute) {
+#ifndef _di_f_thread_lock_attribute_create_
+ f_status_t f_thread_lock_attribute_create(f_thread_lock_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_
}
#endif // _di_f_thread_lock_attribute_shared_set_
-#ifndef _di_f_thread_lock_attributes_adjust_
- f_status_t f_thread_lock_attributes_adjust(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_lock_attributes_adjust(length, attributes);
- }
-#endif // _di_f_thread_lock_attributes_adjust_
-
-#ifndef _di_f_thread_lock_attributes_decimate_by_
- f_status_t f_thread_lock_attributes_decimate_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_lock_attributes_adjust(attributes->size - amount, attributes);
- }
-
- return private_f_thread_lock_attributes_adjust(0, attributes);
- }
-#endif // _di_f_thread_lock_attributes_decimate_by_
-
-#ifndef _di_f_thread_lock_attributes_decrease_by_
- f_status_t f_thread_lock_attributes_decrease_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_lock_attributes_resize(attributes->size - amount, attributes);
- }
-
- return private_f_thread_lock_attributes_resize(0, attributes);
- }
-#endif // _di_f_thread_lock_attributes_decrease_by_
-
-#ifndef _di_f_thread_lock_attributes_increase_
- f_status_t f_thread_lock_attributes_increase(const f_array_length_t step, f_thread_lock_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && attributes->used + 1 > attributes->size) {
- f_array_length_t size = attributes->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (attributes->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_lock_attributes_resize(size, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_lock_attributes_increase_
-
-#ifndef _di_f_thread_lock_attributes_increase_by_
- f_status_t f_thread_lock_attributes_increase_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->used + amount > attributes->size) {
- if (attributes->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_lock_attributes_resize(attributes->used + amount, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_lock_attributes_increase_by_
-
-#ifndef _di_f_thread_lock_attributes_resize_
- f_status_t f_thread_lock_attributes_resize(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_lock_attributes_resize(length, attributes);
- }
-#endif // _di_f_thread_lock_attributes_resize_
-
#ifndef _di_f_thread_lock_create_
f_status_t f_thread_lock_create(const f_thread_lock_attribute_t * const attribute, f_thread_lock_t * const lock) {
#ifndef _di_level_0_parameter_checking_
}
#endif // _di_f_thread_lock_write_try_
-#ifndef _di_f_thread_locks_adjust_
- f_status_t f_thread_locks_adjust(const f_array_length_t length, f_thread_locks_t * const locks) {
- #ifndef _di_level_0_parameter_checking_
- if (!locks) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_locks_adjust(length, locks);
- }
-#endif // _di_f_thread_locks_adjust_
-
-#ifndef _di_f_thread_locks_decimate_by_
- f_status_t f_thread_locks_decimate_by(const f_array_length_t amount, f_thread_locks_t * const locks) {
- #ifndef _di_level_0_parameter_checking_
- if (!locks) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (locks->size - amount > 0) {
- return private_f_thread_locks_adjust(locks->size - amount, locks);
- }
-
- return private_f_thread_locks_adjust(0, locks);
- }
-#endif // _di_f_thread_locks_decimate_by_
-
-#ifndef _di_f_thread_locks_decrease_by_
- f_status_t f_thread_locks_decrease_by(const f_array_length_t amount, f_thread_locks_t * const locks) {
- #ifndef _di_level_0_parameter_checking_
- if (!locks) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (locks->size - amount > 0) {
- return private_f_thread_locks_resize(locks->size - amount, locks);
- }
-
- return private_f_thread_locks_resize(0, locks);
- }
-#endif // _di_f_thread_locks_decrease_by_
-
-#ifndef _di_f_thread_locks_increase_
- f_status_t f_thread_locks_increase(const f_array_length_t step, f_thread_locks_t * const locks) {
- #ifndef _di_level_0_parameter_checking_
- if (!locks) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && locks->used + 1 > locks->size) {
- f_array_length_t size = locks->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (locks->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_locks_resize(size, locks);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_locks_increase_
-
-#ifndef _di_f_thread_locks_increase_by_
- f_status_t f_thread_locks_increase_by(const f_array_length_t amount, f_thread_locks_t * const locks) {
- #ifndef _di_level_0_parameter_checking_
- if (!locks) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (locks->used + amount > locks->size) {
- if (locks->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_locks_resize(locks->used + amount, locks);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_locks_increase_by_
-
-#ifndef _di_f_thread_locks_resize_
- f_status_t f_thread_locks_resize(const f_array_length_t length, f_thread_locks_t * const locks) {
- #ifndef _di_level_0_parameter_checking_
- if (!locks) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_locks_resize(length, locks);
- }
-#endif // _di_f_thread_locks_resize_
-
#ifndef _di_f_thread_mutex_attribute_create_
f_status_t f_thread_mutex_attribute_create(f_thread_mutex_attribute_t * const attribute) {
#ifndef _di_level_0_parameter_checking_
}
#endif // _di_f_thread_mutex_attribute_protocol_set_
-#ifndef _di_f_thread_mutex_attributes_adjust_
- f_status_t f_thread_mutex_attributes_adjust(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_mutex_attributes_adjust(length, attributes);
- }
-#endif // _di_f_thread_mutex_attributes_adjust_
-
-#ifndef _di_f_thread_mutex_attributes_decimate_by_
- f_status_t f_thread_mutex_attributes_decimate_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_mutex_attributes_adjust(attributes->size - amount, attributes);
- }
-
- return private_f_thread_mutex_attributes_adjust(0, attributes);
- }
-#endif // _di_f_thread_mutex_attributes_decimate_by_
-
-#ifndef _di_f_thread_mutex_attributes_decrease_by_
- f_status_t f_thread_mutex_attributes_decrease_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->size - amount > 0) {
- return private_f_thread_mutex_attributes_resize(attributes->size - amount, attributes);
- }
-
- return private_f_thread_mutex_attributes_resize(0, attributes);
- }
-#endif // _di_f_thread_mutex_attributes_decrease_by_
-
-#ifndef _di_f_thread_mutex_attributes_increase_
- f_status_t f_thread_mutex_attributes_increase(const f_array_length_t step, f_thread_mutex_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && attributes->used + 1 > attributes->size) {
- f_array_length_t size = attributes->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (attributes->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_mutex_attributes_resize(size, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_mutex_attributes_increase_
-
-#ifndef _di_f_thread_mutex_attributes_increase_by_
- f_status_t f_thread_mutex_attributes_increase_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (attributes->used + amount > attributes->size) {
- if (attributes->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_mutex_attributes_resize(attributes->used + amount, attributes);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_mutex_attributes_increase_by_
-
-#ifndef _di_f_thread_mutex_attributes_resize_
- f_status_t f_thread_mutex_attributes_resize(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes) {
- #ifndef _di_level_0_parameter_checking_
- if (!attributes) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_mutex_attributes_resize(length, attributes);
- }
-#endif // _di_f_thread_mutex_attributes_resize_
-
#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) {
#ifndef _di_level_0_parameter_checking_
}
#endif // _di_f_thread_mutex_unlock_
-#ifndef _di_f_thread_mutexs_adjust_
- f_status_t f_thread_mutexs_adjust(const f_array_length_t length, f_thread_mutexs_t * const mutexs) {
- #ifndef _di_level_0_parameter_checking_
- if (!mutexs) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_mutexs_adjust(length, mutexs);
- }
-#endif // _di_f_thread_mutexs_adjust_
-
-#ifndef _di_f_thread_mutexs_decimate_by_
- f_status_t f_thread_mutexs_decimate_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) {
- #ifndef _di_level_0_parameter_checking_
- if (!mutexs) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (mutexs->size - amount > 0) {
- return private_f_thread_mutexs_adjust(mutexs->size - amount, mutexs);
- }
-
- return private_f_thread_mutexs_adjust(0, mutexs);
- }
-#endif // _di_f_thread_mutexs_decimate_by_
-
-#ifndef _di_f_thread_mutexs_decrease_by_
- f_status_t f_thread_mutexs_decrease_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) {
- #ifndef _di_level_0_parameter_checking_
- if (!mutexs) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (mutexs->size - amount > 0) {
- return private_f_thread_mutexs_resize(mutexs->size - amount, mutexs);
- }
-
- return private_f_thread_mutexs_resize(0, mutexs);
- }
-#endif // _di_f_thread_mutexs_decrease_by_
-
-#ifndef _di_f_thread_mutexs_increase_
- f_status_t f_thread_mutexs_increase(const f_array_length_t step, f_thread_mutexs_t * const mutexs) {
- #ifndef _di_level_0_parameter_checking_
- if (!mutexs) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && mutexs->used + 1 > mutexs->size) {
- f_array_length_t size = mutexs->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (mutexs->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_mutexs_resize(size, mutexs);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_mutexs_increase_
-
-#ifndef _di_f_thread_mutexs_increase_by_
- f_status_t f_thread_mutexs_increase_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) {
- #ifndef _di_level_0_parameter_checking_
- if (!mutexs) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (mutexs->used + amount > mutexs->size) {
- if (mutexs->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_mutexs_resize(mutexs->used + amount, mutexs);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_mutexs_increase_by_
-
-#ifndef _di_f_thread_mutexs_resize_
- f_status_t f_thread_mutexs_resize(const f_array_length_t length, f_thread_mutexs_t * const mutexs) {
- #ifndef _di_level_0_parameter_checking_
- if (!mutexs) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_mutexs_resize(length, mutexs);
- }
-#endif // _di_f_thread_mutexs_resize_
-
#ifndef _di_f_thread_once_
f_status_t f_thread_once(void (*routine) (void), f_thread_once_t * const once) {
#ifndef _di_level_0_parameter_checking_
}
#endif // _di_f_thread_scheduler_priority_set_
-#ifndef _di_f_thread_semaphores_adjust_
- f_status_t f_thread_semaphores_adjust(const f_array_length_t length, f_thread_semaphores_t * const semaphores) {
- #ifndef _di_level_0_parameter_checking_
- if (!semaphores) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_semaphores_adjust(length, semaphores);
- }
-#endif // _di_f_thread_semaphores_adjust_
-
-#ifndef _di_f_thread_semaphores_decimate_by_
- f_status_t f_thread_semaphores_decimate_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) {
- #ifndef _di_level_0_parameter_checking_
- if (!semaphores) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (semaphores->size - amount > 0) {
- return private_f_thread_semaphores_adjust(semaphores->size - amount, semaphores);
- }
-
- return private_f_thread_semaphores_adjust(0, semaphores);
- }
-#endif // _di_f_thread_semaphores_decimate_by_
-
-#ifndef _di_f_thread_semaphores_decrease_by_
- f_status_t f_thread_semaphores_decrease_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) {
- #ifndef _di_level_0_parameter_checking_
- if (!semaphores) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (semaphores->size - amount > 0) {
- return private_f_thread_semaphores_resize(semaphores->size - amount, semaphores);
- }
-
- return private_f_thread_semaphores_resize(0, semaphores);
- }
-#endif // _di_f_thread_semaphores_decrease_by_
-
-#ifndef _di_f_thread_semaphores_increase_
- f_status_t f_thread_semaphores_increase(const f_array_length_t step, f_thread_semaphores_t * const semaphores) {
- #ifndef _di_level_0_parameter_checking_
- if (!semaphores) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && semaphores->used + 1 > semaphores->size) {
- f_array_length_t size = semaphores->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (semaphores->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_semaphores_resize(size, semaphores);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_semaphores_increase_
-
-#ifndef _di_f_thread_semaphores_increase_by_
- f_status_t f_thread_semaphores_increase_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) {
- #ifndef _di_level_0_parameter_checking_
- if (!semaphores) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (semaphores->used + amount > semaphores->size) {
- if (semaphores->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_semaphores_resize(semaphores->used + amount, semaphores);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_semaphores_increase_by_
-
-#ifndef _di_f_thread_semaphores_resize_
- f_status_t f_thread_semaphores_resize(const f_array_length_t length, f_thread_semaphores_t * const semaphores) {
- #ifndef _di_level_0_parameter_checking_
- if (!semaphores) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_semaphores_resize(length, semaphores);
- }
-#endif // _di_f_thread_semaphores_resize_
-
-#ifndef _di_f_thread_sets_adjust_
- f_status_t f_thread_sets_adjust(const f_array_length_t length, f_thread_sets_t * const sets) {
- #ifndef _di_level_0_parameter_checking_
- if (!sets) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_sets_adjust(length, sets);
- }
-#endif // _di_f_thread_sets_adjust_
-
-#ifndef _di_f_thread_sets_decimate_by_
- f_status_t f_thread_sets_decimate_by(const f_array_length_t amount, f_thread_sets_t * const sets) {
- #ifndef _di_level_0_parameter_checking_
- if (!sets) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (sets->size - amount > 0) {
- return private_f_thread_sets_adjust(sets->size - amount, sets);
- }
-
- return private_f_thread_sets_adjust(0, sets);
- }
-#endif // _di_f_thread_sets_decimate_by_
-
-#ifndef _di_f_thread_sets_decrease_by_
- f_status_t f_thread_sets_decrease_by(const f_array_length_t amount, f_thread_sets_t * const sets) {
- #ifndef _di_level_0_parameter_checking_
- if (!sets) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (sets->size - amount > 0) {
- return private_f_thread_sets_resize(sets->size - amount, sets);
- }
-
- return private_f_thread_sets_resize(0, sets);
- }
-#endif // _di_f_thread_sets_decrease_by_
-
-#ifndef _di_f_thread_sets_increase_
- f_status_t f_thread_sets_increase(const f_array_length_t step, f_thread_sets_t * const sets) {
- #ifndef _di_level_0_parameter_checking_
- if (!sets) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && sets->used + 1 > sets->size) {
- f_array_length_t size = sets->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (sets->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_sets_resize(size, sets);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_sets_increase_
-
-#ifndef _di_f_thread_sets_increase_by_
- f_status_t f_thread_sets_increase_by(const f_array_length_t amount, f_thread_sets_t * const sets) {
- #ifndef _di_level_0_parameter_checking_
- if (!sets) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (sets->used + amount > sets->size) {
- if (sets->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_sets_resize(sets->used + amount, sets);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_sets_increase_by_
-
-#ifndef _di_f_thread_sets_resize_
- f_status_t f_thread_sets_resize(const f_array_length_t length, f_thread_sets_t * const sets) {
- #ifndef _di_level_0_parameter_checking_
- if (!sets) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_sets_resize(length, sets);
- }
-#endif // _di_f_thread_sets_resize_
-
#ifndef _di_f_thread_signal_mask_
f_status_t f_thread_signal_mask(const int how, const sigset_t *next, sigset_t * const current) {
#ifndef _di_level_0_parameter_checking_
if (!next && !current) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
- if (pthread_sigmask(how, next, current) < 0) {
- if (errno == EFAULT) return F_status_set_error(F_buffer);
- if (errno == EINVAL) return F_status_set_error(F_parameter);
+ const int error = pthread_sigmask(how, next, current);
+
+ if (error) {
+ if (error == EFAULT) return F_status_set_error(F_buffer);
+ if (error == EINVAL) return F_status_set_error(F_parameter);
return F_status_set_error(F_failure);
}
}
#endif // _di_f_thread_spin_unlock_
-#ifndef _di_f_thread_spins_adjust_
- f_status_t f_thread_spins_adjust(const f_array_length_t length, f_thread_spins_t * const spins) {
- #ifndef _di_level_0_parameter_checking_
- if (!spins) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_spins_adjust(length, spins);
- }
-#endif // _di_f_thread_spins_adjust_
-
-#ifndef _di_f_thread_spins_decimate_by_
- f_status_t f_thread_spins_decimate_by(const f_array_length_t amount, f_thread_spins_t * const spins) {
- #ifndef _di_level_0_parameter_checking_
- if (!spins) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (spins->size - amount > 0) {
- return private_f_thread_spins_adjust(spins->size - amount, spins);
- }
-
- return private_f_thread_spins_adjust(0, spins);
- }
-#endif // _di_f_thread_spins_decimate_by_
-
-#ifndef _di_f_thread_spins_decrease_by_
- f_status_t f_thread_spins_decrease_by(const f_array_length_t amount, f_thread_spins_t * const spins) {
- #ifndef _di_level_0_parameter_checking_
- if (!spins) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (spins->size - amount > 0) {
- return private_f_thread_spins_resize(spins->size - amount, spins);
- }
-
- return private_f_thread_spins_resize(0, spins);
- }
-#endif // _di_f_thread_spins_decrease_by_
-
-#ifndef _di_f_thread_spins_increase_
- f_status_t f_thread_spins_increase(const f_array_length_t step, f_thread_spins_t * const spins) {
- #ifndef _di_level_0_parameter_checking_
- if (!spins) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (step && spins->used + 1 > spins->size) {
- f_array_length_t size = spins->used + step;
-
- if (size > F_array_length_t_size_d) {
- if (spins->used + 1 > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- size = F_array_length_t_size_d;
- }
-
- return private_f_thread_spins_resize(size, spins);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_spins_increase_
-
-#ifndef _di_f_thread_spins_increase_by_
- f_status_t f_thread_spins_increase_by(const f_array_length_t amount, f_thread_spins_t * const spins) {
- #ifndef _di_level_0_parameter_checking_
- if (!spins) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- if (!amount) return F_data_not;
-
- if (spins->used + amount > spins->size) {
- if (spins->used + amount > F_array_length_t_size_d) {
- return F_status_set_error(F_array_too_large);
- }
-
- return private_f_thread_spins_resize(spins->used + amount, spins);
- }
-
- return F_data_not;
- }
-#endif // _di_f_thread_spins_increase_by_
-
-#ifndef _di_f_thread_spins_resize_
- f_status_t f_thread_spins_resize(const f_array_length_t length, f_thread_spins_t * const spins) {
- #ifndef _di_level_0_parameter_checking_
- if (!spins) return F_status_set_error(F_parameter);
- #endif // _di_level_0_parameter_checking_
-
- return private_f_thread_spins_resize(length, spins);
- }
-#endif // _di_f_thread_spins_resize_
-
#ifndef _di_f_thread_unlock_
f_status_t f_thread_unlock(f_thread_lock_t * const lock) {
#ifndef _di_level_0_parameter_checking_
#include <fll/level_0/string.h>
// FLL-0 thread includes.
-#include <fll/level_0/thread/common.h>
+#include <fll/level_0/thread/attribute.h>
+#include <fll/level_0/thread/barrier.h>
+#include <fll/level_0/thread/barrier_attribute.h>
+#include <fll/level_0/thread/condition.h>
+#include <fll/level_0/thread/condition_attribute.h>
+#include <fll/level_0/thread/id.h>
+#include <fll/level_0/thread/key.h>
+#include <fll/level_0/thread/lock.h>
+#include <fll/level_0/thread/lock_attribute.h>
+#include <fll/level_0/thread/mutex.h>
+#include <fll/level_0/thread/mutex_attribute.h>
+#include <fll/level_0/thread/once.h>
+#include <fll/level_0/thread/semaphore.h>
+#include <fll/level_0/thread/set.h>
+#include <fll/level_0/thread/spin.h>
#ifdef __cplusplus
extern "C" {
*
* @see pthread_condattr_getclock()
*/
-#ifndef _di_f_thread_attribute_clock_get_
- extern f_status_t f_thread_attribute_clock_get(const f_thread_condition_attribute_t * const attribute, clockid_t * const id);
-#endif // _di_f_thread_attribute_clock_get_
+#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.
*
* @see pthread_condattr_setclock()
*/
-#ifndef _di_f_thread_attribute_clock_set_
- extern f_status_t f_thread_attribute_clock_set(const clockid_t id, f_thread_condition_attribute_t * const attribute);
-#endif // _di_f_thread_attribute_clock_set_
+#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_
/**
* Get the process shared thread condition attribute.
#endif // _di_f_thread_attribute_stack_size_set_
/**
- * Resize the thread attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_attributes_adjust_
- extern f_status_t f_thread_attributes_adjust(const f_array_length_t length, f_thread_attributes_t * const attributes);
-#endif // _di_f_thread_attributes_adjust_
-
-/**
- * Resize the thread attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_attributes_decimate_by_
- extern f_status_t f_thread_attributes_decimate_by(const f_array_length_t amount, f_thread_attributes_t * const attributes);
-#endif // _di_f_thread_attributes_decimate_by_
-
-/**
- * Resize the thread attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_attributes_decrease_by_
- extern f_status_t f_thread_attributes_decrease_by(const f_array_length_t amount, f_thread_attributes_t * const attributes);
-#endif // _di_f_thread_attributes_decrease_by_
-
-/**
- * Increase the size of the thread attributes array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_attributes_increase_
- extern f_status_t f_thread_attributes_increase(const f_array_length_t step, f_thread_attributes_t * const attributes);
-#endif // _di_f_thread_attributes_increase_
-
-/**
- * Resize the thread attributes array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_attributes_increase_by_
- extern f_status_t f_thread_attributes_increase_by(const f_array_length_t amount, f_thread_attributes_t * const attributes);
-#endif // _di_f_thread_attributes_increase_by_
-
-/**
- * Resize the thread attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The string attributes array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_attributes_resize_
- extern f_status_t f_thread_attributes_resize(const f_array_length_t length, f_thread_attributes_t * const attributes);
-#endif // _di_f_thread_attributes_resize_
-
-/**
* Create (initialize) a thread barrier attribute structure.
*
* @param attribute
#endif // _di_f_thread_barrier_attribute_shared_set_
/**
- * Resize the thread barrier attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The thread attributes array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barrier_attributes_adjust_
- extern f_status_t f_thread_barrier_attributes_adjust(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes);
-#endif // _di_f_thread_barrier_attributes_adjust_
-
-/**
- * Resize the thread barrier attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param attributes
- * The thread attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barrier_attributes_decimate_by_
- extern f_status_t f_thread_barrier_attributes_decimate_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes);
-#endif // _di_f_thread_barrier_attributes_decimate_by_
-
-/**
- * Resize the thread barrier attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param attributes
- * The thread attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barrier_attributes_decrease_by_
- extern f_status_t f_thread_barrier_attributes_decrease_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes);
-#endif // _di_f_thread_barrier_attributes_decrease_by_
-
-/**
- * Increase the size of the thread barrier attributes array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param attributes
- * The thread attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barrier_attributes_increase_
- extern f_status_t f_thread_barrier_attributes_increase(const f_array_length_t step, f_thread_barrier_attributes_t * const attributes);
-#endif // _di_f_thread_barrier_attributes_increase_
-
-/**
- * Resize the thread barrier attributes array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param attributes
- * The thread attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barrier_attributes_increase_by_
- extern f_status_t f_thread_barrier_attributes_increase_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes);
-#endif // _di_f_thread_barrier_attributes_increase_by_
-
-/**
- * Resize the thread barrier attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The thread attributes array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barrier_attributes_resize_
- extern f_status_t f_thread_barrier_attributes_resize(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes);
-#endif // _di_f_thread_barrier_attributes_resize_
-
-/**
* Create (initialize) a thread barrier structure.
*
* @param barrier
* @return
* F_none on success.
*
- * F_parameter (with error bit) if a parameter is invalid.
+ * F_busy (with error bit) if barrier is already in use (a re-initialization attempt).
* F_memory_not (with error bit) if out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ * F_resource_not (with error bit) if necessary resouces to perform create are unavailable.
*
* F_failure (with error bit) on any other error.
*
#endif // _di_f_thread_barrier_wait_
/**
- * Resize the thread barriers array.
- *
- * @param length
- * The new size to use.
- * @param barriers
- * The thread barriers array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barriers_adjust_
- extern f_status_t f_thread_barriers_adjust(const f_array_length_t length, f_thread_barriers_t * const barriers);
-#endif // _di_f_thread_barriers_adjust_
-
-/**
- * Resize the thread barriers array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param barriers
- * The thread barriers array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barriers_decimate_by_
- extern f_status_t f_thread_barriers_decimate_by(const f_array_length_t amount, f_thread_barriers_t * const barriers);
-#endif // _di_f_thread_barriers_decimate_by_
-
-/**
- * Resize the thread barriers array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param barriers
- * The thread barriers array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barriers_decrease_by_
- extern f_status_t f_thread_barriers_decrease_by(const f_array_length_t amount, f_thread_barriers_t * const barriers);
-#endif // _di_f_thread_barriers_decrease_by_
-
-/**
- * Increase the size of the thread barriers array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param barriers
- * The thread barriers array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barriers_increase_
- extern f_status_t f_thread_barriers_increase(const f_array_length_t step, f_thread_barriers_t * const barriers);
-#endif // _di_f_thread_barriers_increase_
-
-/**
- * Resize the thread barriers array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param barriers
- * The thread barriers array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barriers_increase_by_
- extern f_status_t f_thread_barriers_increase_by(const f_array_length_t amount, f_thread_barriers_t * const barriers);
-#endif // _di_f_thread_barriers_increase_by_
-
-/**
- * Resize the thread barriers array.
- *
- * @param length
- * The new size to use.
- * @param barriers
- * The thread barriers array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_barriers_resize_
- extern f_status_t f_thread_barriers_resize(const f_array_length_t length, f_thread_barriers_t * const barriers);
-#endif // _di_f_thread_barriers_resize_
-
-/**
* Get the ID of the calling thread.
*
* @return
#endif // _di_f_thread_condition_attribute_delete_
/**
- * Resize the thread attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_condition_attributes_adjust_
- extern f_status_t f_thread_condition_attributes_adjust(const f_array_length_t length, f_thread_condition_attributes_t * const attributes);
-#endif // _di_f_thread_condition_attributes_adjust_
-
-/**
- * Resize the thread attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_condition_attributes_decimate_by_
- extern f_status_t f_thread_condition_attributes_decimate_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes);
-#endif // _di_f_thread_condition_attributes_decimate_by_
-
-/**
- * Resize the thread attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_condition_attributes_decrease_by_
- extern f_status_t f_thread_condition_attributes_decrease_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes);
-#endif // _di_f_thread_condition_attributes_decrease_by_
-
-/**
- * Increase the size of the thread attributes array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_condition_attributes_increase_
- extern f_status_t f_thread_condition_attributes_increase(const f_array_length_t step, f_thread_condition_attributes_t * const attributes);
-#endif // _di_f_thread_condition_attributes_increase_
-
-/**
- * Resize the thread attributes array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_condition_attributes_increase_by_
- extern f_status_t f_thread_condition_attributes_increase_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes);
-#endif // _di_f_thread_condition_attributes_increase_by_
-
-/**
- * Resize the thread attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The string attributes array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_condition_attributes_resize_
- extern f_status_t f_thread_condition_attributes_resize(const f_array_length_t length, f_thread_condition_attributes_t * const attributes);
-#endif // _di_f_thread_condition_attributes_resize_
-
-/**
* Initialize a condition.
*
* @param attribute
#endif // _di_f_thread_condition_wait_timed_
/**
- * Resize the thread conditions array.
- *
- * @param length
- * The new size to use.
- * @param conditions
- * The string conditions array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_conditions_adjust_
- extern f_status_t f_thread_conditions_adjust(const f_array_length_t length, f_thread_conditions_t * const conditions);
-#endif // _di_f_thread_conditions_adjust_
-
-/**
- * Resize the thread conditions array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param conditions
- * The string conditions array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_conditions_decimate_by_
- extern f_status_t f_thread_conditions_decimate_by(const f_array_length_t amount, f_thread_conditions_t * const conditions);
-#endif // _di_f_thread_conditions_decimate_by_
-
-/**
- * Resize the thread conditions array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param conditions
- * The string conditions array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_conditions_decrease_by_
- extern f_status_t f_thread_conditions_decrease_by(const f_array_length_t amount, f_thread_conditions_t * const conditions);
-#endif // _di_f_thread_conditions_decrease_by_
-
-/**
- * Increase the size of the thread conditions array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param conditions
- * The string conditions array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_conditions_increase_
- extern f_status_t f_thread_conditions_increase(const f_array_length_t step, f_thread_conditions_t * const conditions);
-#endif // _di_f_thread_conditions_increase_
-
-/**
- * Resize the thread conditions array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param conditions
- * The string conditions array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_conditions_increase_by_
- extern f_status_t f_thread_conditions_increase_by(const f_array_length_t amount, f_thread_conditions_t * const conditions);
-#endif // _di_f_thread_conditions_increase_by_
-
-/**
- * Resize the thread conditions array.
- *
- * @param length
- * The new size to use.
- * @param conditions
- * The string conditions array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_conditions_resize_
- extern f_status_t f_thread_conditions_resize(const f_array_length_t length, f_thread_conditions_t * const conditions);
-#endif // _di_f_thread_conditions_resize_
-
-/**
* Create a thread.
*
* @param attribute
#endif // _di_f_thread_key_set_
/**
- * Resize the thread keys array.
- *
- * @param length
- * The new size to use.
- * @param keys
- * The string keys array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_keys_adjust_
- extern f_status_t f_thread_keys_adjust(const f_array_length_t length, f_thread_keys_t * const keys);
-#endif // _di_f_thread_keys_adjust_
-
-/**
- * Resize the thread keys array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param keys
- * The string keys array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_keys_decimate_by_
- extern f_status_t f_thread_keys_decimate_by(const f_array_length_t amount, f_thread_keys_t * const keys);
-#endif // _di_f_thread_keys_decimate_by_
-
-/**
- * Resize the thread keys array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param keys
- * The string keys array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_keys_decrease_by_
- extern f_status_t f_thread_keys_decrease_by(const f_array_length_t amount, f_thread_keys_t * const keys);
-#endif // _di_f_thread_keys_decrease_by_
-
-/**
- * Increase the size of the thread keys array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param keys
- * The string keys array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_keys_increase_
- extern f_status_t f_thread_keys_increase(const f_array_length_t step, f_thread_keys_t * const keys);
-#endif // _di_f_thread_keys_increase_
-
-/**
- * Resize the thread keys array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param keys
- * The string keys array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_keys_increase_by_
- extern f_status_t f_thread_keys_increase_by(const f_array_length_t amount, f_thread_keys_t * const keys);
-#endif // _di_f_thread_keys_increase_by_
-
-/**
- * Resize the thread keys array.
- *
- * @param length
- * The new size to use.
- * @param keys
- * The string keys array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_keys_resize_
- extern f_status_t f_thread_keys_resize(const f_array_length_t length, f_thread_keys_t * const keys);
-#endif // _di_f_thread_keys_resize_
-
-/**
* Create a thread lock attribute.
*
* @param attribute
#endif // _di_f_thread_lock_attribute_shared_set_
/**
- * Resize the thread attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_lock_attributes_adjust_
- extern f_status_t f_thread_lock_attributes_adjust(const f_array_length_t length, f_thread_lock_attributes_t * const attributes);
-#endif // _di_f_thread_lock_attributes_adjust_
-
-/**
- * Resize the thread attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_lock_attributes_decimate_by_
- extern f_status_t f_thread_lock_attributes_decimate_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes);
-#endif // _di_f_thread_lock_attributes_decimate_by_
-
-/**
- * Resize the thread attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_lock_attributes_decrease_by_
- extern f_status_t f_thread_lock_attributes_decrease_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes);
-#endif // _di_f_thread_lock_attributes_decrease_by_
-
-/**
- * Increase the size of the thread attributes array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_lock_attributes_increase_
- extern f_status_t f_thread_lock_attributes_increase(const f_array_length_t step, f_thread_lock_attributes_t * const attributes);
-#endif // _di_f_thread_lock_attributes_increase_
-
-/**
- * Resize the thread attributes array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_lock_attributes_increase_by_
- extern f_status_t f_thread_lock_attributes_increase_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes);
-#endif // _di_f_thread_lock_attributes_increase_by_
-
-/**
- * Resize the thread attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The string attributes array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_lock_attributes_resize_
- extern f_status_t f_thread_lock_attributes_resize(const f_array_length_t length, f_thread_lock_attributes_t * const attributes);
-#endif // _di_f_thread_lock_attributes_resize_
-
-/**
* Create a thread read/write lock.
*
* @param attribute
#endif // _di_f_thread_lock_write_try_
/**
- * Resize the read/write locks array.
- *
- * @param length
- * The new size to use.
- * @param locks
- * The string locks array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_locks_adjust_
- extern f_status_t f_thread_locks_adjust(const f_array_length_t length, f_thread_locks_t * const locks);
-#endif // _di_f_thread_locks_adjust_
-
-/**
- * Resize the read/write locks array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param locks
- * The string locks array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_locks_decimate_by_
- extern f_status_t f_thread_locks_decimate_by(const f_array_length_t amount, f_thread_locks_t * const locks);
-#endif // _di_f_thread_locks_decimate_by_
-
-/**
- * Resize the read/write locks array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param locks
- * The string locks array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_locks_decrease_by_
- extern f_status_t f_thread_locks_decrease_by(const f_array_length_t amount, f_thread_locks_t * const locks);
-#endif // _di_f_thread_locks_decrease_by_
-
-/**
- * Increase the size of the read/write array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param locks
- * The string locks array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_locks_increase_
- extern f_status_t f_thread_locks_increase(const f_array_length_t step, f_thread_locks_t * const locks);
-#endif // _di_f_thread_locks_increase_
-
-/**
- * Resize the read/write locks array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param locks
- * The string locks array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_locks_increase_by_
- extern f_status_t f_thread_locks_increase_by(const f_array_length_t amount, f_thread_locks_t * const locks);
-#endif // _di_f_thread_locks_increase_by_
-
-/**
- * Resize the read/write locks array.
- *
- * @param length
- * The new size to use.
- * @param locks
- * The string locks array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_locks_resize_
- extern f_status_t f_thread_locks_resize(const f_array_length_t length, f_thread_locks_t * const locks);
-#endif // _di_f_thread_locks_resize_
-
-/**
* Create a thread mutex attribute.
*
* @param attribute
*
* @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_
-
-/**
- * Resize the thread attributes array.
- *
- * @param length
- * The new size to use.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutex_attributes_adjust_
- extern f_status_t f_thread_mutex_attributes_adjust(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes);
-#endif // _di_f_thread_mutex_attributes_adjust_
-
-/**
- * Resize the thread attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutex_attributes_decimate_by_
- extern f_status_t f_thread_mutex_attributes_decimate_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes);
-#endif // _di_f_thread_mutex_attributes_decimate_by_
-
-/**
- * Resize the thread attributes array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutex_attributes_decrease_by_
- extern f_status_t f_thread_mutex_attributes_decrease_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes);
-#endif // _di_f_thread_mutex_attributes_decrease_by_
-
-/**
- * Increase the size of the thread attributes array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param attributes
- * The string attributes array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutex_attributes_increase_
- extern f_status_t f_thread_mutex_attributes_increase(const f_array_length_t step, f_thread_mutex_attributes_t * const attributes);
-#endif // _di_f_thread_mutex_attributes_increase_
-
-/**
- * Resize the thread attributes array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param attributes
- * The string attributes array to resize.
+ * @param protocol
+ * The protocol.
*
* @return
* F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
*
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
* 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_attributes_increase_by_
- extern f_status_t f_thread_mutex_attributes_increase_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes);
-#endif // _di_f_thread_mutex_attributes_increase_by_
+#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_
/**
- * Resize the thread attributes array.
+ * Set the mutex attribute protocol.
*
- * @param length
- * The new size to use.
- * @param attributes
- * The string attributes array to adjust.
+ * @param protocol
+ * The protocol.
+ * @param attribute
+ * The thread mutex attribute.
*
* @return
* F_none on success.
*
- * F_memory_not (with error bit) on out of memory.
* 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_attributes_resize_
- extern f_status_t f_thread_mutex_attributes_resize(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes);
-#endif // _di_f_thread_mutex_attributes_resize_
+#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.
#endif // _di_f_thread_mutex_unlock_
/**
- * Resize the thread mutexs array.
- *
- * @param length
- * The new size to use.
- * @param mutexs
- * The string mutexs array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutexs_adjust_
- extern f_status_t f_thread_mutexs_adjust(const f_array_length_t length, f_thread_mutexs_t * const mutexs);
-#endif // _di_f_thread_mutexs_adjust_
-
-/**
- * Resize the thread mutexs array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param mutexs
- * The string mutexs array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutexs_decimate_by_
- extern f_status_t f_thread_mutexs_decimate_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs);
-#endif // _di_f_thread_mutexs_decimate_by_
-
-/**
- * Resize the thread mutexs array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param mutexs
- * The string mutexs array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutexs_decrease_by_
- extern f_status_t f_thread_mutexs_decrease_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs);
-#endif // _di_f_thread_mutexs_decrease_by_
-
-/**
- * Increase the size of the thread mutexs array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param mutexs
- * The string mutexs array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutexs_increase_
- extern f_status_t f_thread_mutexs_increase(const f_array_length_t step, f_thread_mutexs_t * const mutexs);
-#endif // _di_f_thread_mutexs_increase_
-
-/**
- * Resize the thread mutexs array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param mutexs
- * The string mutexs array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutexs_increase_by_
- extern f_status_t f_thread_mutexs_increase_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs);
-#endif // _di_f_thread_mutexs_increase_by_
-
-/**
- * Resize the thread mutexs array.
- *
- * @param length
- * The new size to use.
- * @param mutexs
- * The string mutexs array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_mutexs_resize_
- extern f_status_t f_thread_mutexs_resize(const f_array_length_t length, f_thread_mutexs_t * const mutexs);
-#endif // _di_f_thread_mutexs_resize_
-
-/**
* Call the given routine only one time and never again.
*
* Subsequent calls will not call the given routine.
#endif // _di_f_thread_semaphore_value_get_
/**
- * Resize the thread semaphores array.
- *
- * @param length
- * The new size to use.
- * @param semaphores
- * The string semaphores array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_semaphores_adjust_
- extern f_status_t f_thread_semaphores_adjust(const f_array_length_t length, f_thread_semaphores_t * const semaphores);
-#endif // _di_f_thread_semaphores_adjust_
-
-/**
- * Resize the thread semaphores array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param semaphores
- * The string semaphores array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_semaphores_decimate_by_
- extern f_status_t f_thread_semaphores_decimate_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores);
-#endif // _di_f_thread_semaphores_decimate_by_
-
-/**
- * Resize the thread semaphores array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param semaphores
- * The string semaphores array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_semaphores_decrease_by_
- extern f_status_t f_thread_semaphores_decrease_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores);
-#endif // _di_f_thread_semaphores_decrease_by_
-
-/**
- * Increase the size of the thread semaphores array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param semaphores
- * The string semaphores array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_semaphores_increase_
- extern f_status_t f_thread_semaphores_increase(const f_array_length_t step, f_thread_semaphores_t * const semaphores);
-#endif // _di_f_thread_semaphores_increase_
-
-/**
- * Resize the thread semaphores array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param semaphores
- * The string semaphores array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_semaphores_increase_by_
- extern f_status_t f_thread_semaphores_increase_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores);
-#endif // _di_f_thread_semaphores_increase_by_
-
-/**
- * Resize the thread semaphores array.
- *
- * @param length
- * The new size to use.
- * @param semaphores
- * The string semaphores array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_semaphores_resize_
- extern f_status_t f_thread_semaphores_resize(const f_array_length_t length, f_thread_semaphores_t * const semaphores);
-#endif // _di_f_thread_semaphores_resize_
-
-/**
- * Resize the thread sets array.
- *
- * @param length
- * The new size to use.
- * @param sets
- * The string sets array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_sets_adjust_
- extern f_status_t f_thread_sets_adjust(const f_array_length_t length, f_thread_sets_t * const sets);
-#endif // _di_f_thread_sets_adjust_
-
-/**
- * Resize the thread sets array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param sets
- * The string sets array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_sets_decimate_by_
- extern f_status_t f_thread_sets_decimate_by(const f_array_length_t amount, f_thread_sets_t * const sets);
-#endif // _di_f_thread_sets_decimate_by_
-
-/**
- * Resize the thread sets array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param sets
- * The string sets array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_sets_decrease_by_
- extern f_status_t f_thread_sets_decrease_by(const f_array_length_t amount, f_thread_sets_t * const sets);
-#endif // _di_f_thread_sets_decrease_by_
-
-/**
- * Increase the size of the thread sets array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param sets
- * The string sets array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_sets_increase_
- extern f_status_t f_thread_sets_increase(const f_array_length_t step, f_thread_sets_t * const sets);
-#endif // _di_f_thread_sets_increase_
-
-/**
- * Resize the thread sets array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param sets
- * The string sets array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_sets_increase_by_
- extern f_status_t f_thread_sets_increase_by(const f_array_length_t amount, f_thread_sets_t * const sets);
-#endif // _di_f_thread_sets_increase_by_
-
-/**
- * Resize the thread sets array.
- *
- * @param length
- * The new size to use.
- * @param sets
- * The string sets array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_sets_resize_
- extern f_status_t f_thread_sets_resize(const f_array_length_t length, f_thread_sets_t * const sets);
-#endif // _di_f_thread_sets_resize_
-
-/**
* Get or assign the current signal set in use.
*
* Either set or previous may be NULL but not both (at least one is required).
#endif // _di_f_thread_spin_unlock_
/**
- * Resize the thread spin locks array.
- *
- * @param length
- * The new size to use.
- * @param spins
- * The string spins array to resize.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_spins_adjust_
- extern f_status_t f_thread_spins_adjust(const f_array_length_t length, f_thread_spins_t * const spins);
-#endif // _di_f_thread_spins_adjust_
-
-/**
- * Resize the thread spin locks array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decimate the size by.
- * @param spins
- * The string spins array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_spins_decimate_by_
- extern f_status_t f_thread_spins_decimate_by(const f_array_length_t amount, f_thread_spins_t * const spins);
-#endif // _di_f_thread_spins_decimate_by_
-
-/**
- * Resize the thread spin locks array to a smaller size.
- *
- * This will resize making the array smaller based on (size - given length).
- * If the given length is too small, then the resize will fail.
- * This will not shrink the size to less than 0.
- *
- * @param amount
- * A positive number representing how much to decrease the size by.
- * @param spins
- * The string spins array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not if amount is 0.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_spins_decrease_by_
- extern f_status_t f_thread_spins_decrease_by(const f_array_length_t amount, f_thread_spins_t * const spins);
-#endif // _di_f_thread_spins_decrease_by_
-
-/**
- * Increase the size of the thread spin locks array, but only if necessary.
- *
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param step
- * The allocation step to use.
- * Must be greater than 0.
- * @param spins
- * The string spins array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_spins_increase_
- extern f_status_t f_thread_spins_increase(const f_array_length_t step, f_thread_spins_t * const spins);
-#endif // _di_f_thread_spins_increase_
-
-/**
- * Resize the thread spin locks array to a larger size.
- *
- * This will resize making the array larger based on the given length.
- * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
- * If already set to the maximum buffer size, then the resize will fail.
- *
- * @param amount
- * A positive number representing how much to increase the size by.
- * @param spins
- * The string spins array to resize.
- *
- * @return
- * F_none on success.
- * F_data_not on success, but there is no reason to increase size (used + amount <= size).
- *
- * F_array_too_large (with error bit) if the new array length is too large.
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_spins_increase_by_
- extern f_status_t f_thread_spins_increase_by(const f_array_length_t amount, f_thread_spins_t * const spins);
-#endif // _di_f_thread_spins_increase_by_
-
-/**
- * Resize the thread spin locks array.
- *
- * @param length
- * The new size to use.
- * @param spins
- * The string spins array to adjust.
- *
- * @return
- * F_none on success.
- *
- * F_memory_not (with error bit) on out of memory.
- * F_parameter (with error bit) if a parameter is invalid.
- */
-#ifndef _di_f_thread_spins_resize_
- extern f_status_t f_thread_spins_resize(const f_array_length_t length, f_thread_spins_t * const spins);
-#endif // _di_f_thread_spins_resize_
-
-/**
* Unlock the read/write lock.
*
* @param lock
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "attribute.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_attributes_adjust_
+ f_status_t f_thread_attributes_adjust(const f_array_length_t length, f_thread_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_attributes_adjust(length, attributes);
+ }
+#endif // _di_f_thread_attributes_adjust_
+
+#ifndef _di_f_thread_attributes_decimate_by_
+ f_status_t f_thread_attributes_decimate_by(const f_array_length_t amount, f_thread_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_attributes_adjust(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_attributes_adjust(0, attributes);
+ }
+#endif // _di_f_thread_attributes_decimate_by_
+
+#ifndef _di_f_thread_attributes_decrease_by_
+ f_status_t f_thread_attributes_decrease_by(const f_array_length_t amount, f_thread_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_attributes_resize(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_attributes_resize(0, attributes);
+ }
+#endif // _di_f_thread_attributes_decrease_by_
+
+#ifndef _di_f_thread_attributes_increase_
+ f_status_t f_thread_attributes_increase(const f_array_length_t step, f_thread_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && attributes->used + 1 > attributes->size) {
+ f_array_length_t size = attributes->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (attributes->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_attributes_resize(size, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_attributes_increase_
+
+#ifndef _di_f_thread_attributes_increase_by_
+ f_status_t f_thread_attributes_increase_by(const f_array_length_t amount, f_thread_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->used + amount > attributes->size) {
+ if (attributes->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_attributes_resize(attributes->used + amount, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_attributes_increase_by_
+
+#ifndef _di_f_thread_attributes_resize_
+ f_status_t f_thread_attributes_resize(const f_array_length_t length, f_thread_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_attributes_resize(length, attributes);
+ }
+#endif // _di_f_thread_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_attribute_h
+#define _F_thread_attribute_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_attr_t.
+ */
+#ifndef _di_f_thread_attribute_t_
+ typedef pthread_attr_t f_thread_attribute_t;
+
+ #define f_thread_attribute_t_initialize { 0 }
+
+ #define macro_f_thread_attribute_t_initialize(attribute) attribute
+
+ // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
+ #define macro_f_thread_attribute_t_clear(attribute) attribute.__align = 0;
+
+ #define macro_f_thread_attribute_t_delete_simple(attribute) f_thread_attribute_delete(&attribute);
+#endif // _di_f_thread_attribute_t_
+
+/**
+ * An array of f_thread_attribute_t.
+ *
+ * array: The array of f_thread_attribute_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_attributes_t_
+ typedef struct {
+ f_thread_attribute_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_attributes_t;
+
+ #define f_thread_attributes_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_attributes_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_attributes_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes)
+
+ #define macro_f_thread_attributes_t_resize(status, attributes, length) status = f_thread_attributes_resize(length, &attributes);
+ #define macro_f_thread_attributes_t_adjust(status, attributes, length) status = f_thread_attributes_adjust(length, &attributes);
+
+ #define macro_f_thread_attributes_t_delete_simple(attributes) f_thread_attributes_resize(0, &attributes);
+ #define macro_f_thread_attributes_t_destroy_simple(attributes) f_thread_attributes_adjust(0, &attributes);
+
+ #define macro_f_thread_attributes_t_increase(status, step, attributes) status = f_thread_attributes_increase(step, attributes);
+ #define macro_f_thread_attributes_t_increase_by(status, attributes, amount) status = f_thread_attributes_increase_by(amount, attributes);
+ #define macro_f_thread_attributes_t_decrease_by(status, attributes, amount) status = f_thread_attributes_decrease_by(amount, attributes);
+ #define macro_f_thread_attributes_t_decimate_by(status, attributes, amount) status = f_thread_attributes_decimate_by(amount, attributes);
+#endif // _di_f_thread_attributes_t_
+
+/**
+ * Resize the thread attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_attributes_adjust_
+ extern f_status_t f_thread_attributes_adjust(const f_array_length_t length, f_thread_attributes_t * const attributes);
+#endif // _di_f_thread_attributes_adjust_
+
+/**
+ * Resize the thread attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_attributes_decimate_by_
+ extern f_status_t f_thread_attributes_decimate_by(const f_array_length_t amount, f_thread_attributes_t * const attributes);
+#endif // _di_f_thread_attributes_decimate_by_
+
+/**
+ * Resize the thread attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_attributes_decrease_by_
+ extern f_status_t f_thread_attributes_decrease_by(const f_array_length_t amount, f_thread_attributes_t * const attributes);
+#endif // _di_f_thread_attributes_decrease_by_
+
+/**
+ * Increase the size of the thread attributes array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_attributes_increase_
+ extern f_status_t f_thread_attributes_increase(const f_array_length_t step, f_thread_attributes_t * const attributes);
+#endif // _di_f_thread_attributes_increase_
+
+/**
+ * Resize the thread attributes array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_attributes_increase_by_
+ extern f_status_t f_thread_attributes_increase_by(const f_array_length_t amount, f_thread_attributes_t * const attributes);
+#endif // _di_f_thread_attributes_increase_by_
+
+/**
+ * Resize the thread attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The string attributes array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_attributes_resize_
+ extern f_status_t f_thread_attributes_resize(const f_array_length_t length, f_thread_attributes_t * const attributes);
+#endif // _di_f_thread_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_attribute_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "barrier.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_barriers_adjust_
+ f_status_t f_thread_barriers_adjust(const f_array_length_t length, f_thread_barriers_t * const barriers) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!barriers) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_barriers_adjust(length, barriers);
+ }
+#endif // _di_f_thread_barriers_adjust_
+
+#ifndef _di_f_thread_barriers_decimate_by_
+ f_status_t f_thread_barriers_decimate_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!barriers) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (barriers->size - amount > 0) {
+ return private_f_thread_barriers_adjust(barriers->size - amount, barriers);
+ }
+
+ return private_f_thread_barriers_adjust(0, barriers);
+ }
+#endif // _di_f_thread_barriers_decimate_by_
+
+#ifndef _di_f_thread_barriers_decrease_by_
+ f_status_t f_thread_barriers_decrease_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!barriers) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (barriers->size - amount > 0) {
+ return private_f_thread_barriers_resize(barriers->size - amount, barriers);
+ }
+
+ return private_f_thread_barriers_resize(0, barriers);
+ }
+#endif // _di_f_thread_barriers_decrease_by_
+
+#ifndef _di_f_thread_barriers_increase_
+ f_status_t f_thread_barriers_increase(const f_array_length_t step, f_thread_barriers_t * const barriers) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!barriers) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && barriers->used + 1 > barriers->size) {
+ f_array_length_t size = barriers->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (barriers->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_barriers_resize(size, barriers);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_barriers_increase_
+
+#ifndef _di_f_thread_barriers_increase_by_
+ f_status_t f_thread_barriers_increase_by(const f_array_length_t amount, f_thread_barriers_t * const barriers) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!barriers) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (barriers->used + amount > barriers->size) {
+ if (barriers->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_barriers_resize(barriers->used + amount, barriers);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_barriers_increase_by_
+
+#ifndef _di_f_thread_barriers_resize_
+ f_status_t f_thread_barriers_resize(const f_array_length_t length, f_thread_barriers_t * const barriers) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!barriers) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_barriers_resize(length, barriers);
+ }
+#endif // _di_f_thread_barriers_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_barrier_h
+#define _F_thread_barrier_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_barrier_t.
+ */
+#ifndef _di_f_thread_barrier_t_
+ typedef pthread_barrier_t f_thread_barrier_t;
+
+ #define f_thread_barrier_t_initialize { 0 }
+
+ #define macro_f_thread_barrier_t_initialize(barrier) barrier
+
+ #define macro_f_thread_barrier_t_clear(barrier) barrier = 0;
+
+ #define macro_f_thread_barrier_t_delete_simple(barrier) f_thread_barrier_delete(&barrier);
+#endif // _di_f_thread_barrier_t_
+
+/**
+ * An array of f_thread_barrier_t.
+ *
+ * array: The array of f_thread_barrier_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_barriers_t_
+ typedef struct {
+ f_thread_barrier_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_barriers_t;
+
+ #define f_thread_barriers_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_barriers_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_barriers_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_barriers_t_clear(barriers) macro_f_memory_structure_clear(barriers)
+
+ #define macro_f_thread_barriers_t_resize(status, barriers, length) status = f_thread_barriers_resize(length, &barriers);
+ #define macro_f_thread_barriers_t_adjust(status, barriers, length) status = f_thread_barriers_adjust(length, &barriers);
+
+ #define macro_f_thread_barriers_t_delete_simple(barriers) f_thread_barriers_resize(0, &barriers);
+ #define macro_f_thread_barriers_t_destroy_simple(barriers) f_thread_barriers_adjust(0, &barriers);
+
+ #define macro_f_thread_barriers_t_increase(status, step, barriers) status = f_thread_barriers_increase(step, barriers);
+ #define macro_f_thread_barriers_t_increase_by(status, barriers, amount) status = f_thread_barriers_increase_by(amount, barriers);
+ #define macro_f_thread_barriers_t_decrease_by(status, barriers, amount) status = f_thread_barriers_decrease_by(amount, barriers);
+ #define macro_f_thread_barriers_t_decimate_by(status, barriers, amount) status = f_thread_barriers_decimate_by(amount, barriers);
+#endif // _di_f_thread_barriers_t_
+
+/**
+ * Resize the thread barriers array.
+ *
+ * @param length
+ * The new size to use.
+ * @param barriers
+ * The thread barriers array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barriers_adjust_
+ extern f_status_t f_thread_barriers_adjust(const f_array_length_t length, f_thread_barriers_t * const barriers);
+#endif // _di_f_thread_barriers_adjust_
+
+/**
+ * Resize the thread barriers array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param barriers
+ * The thread barriers array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barriers_decimate_by_
+ extern f_status_t f_thread_barriers_decimate_by(const f_array_length_t amount, f_thread_barriers_t * const barriers);
+#endif // _di_f_thread_barriers_decimate_by_
+
+/**
+ * Resize the thread barriers array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param barriers
+ * The thread barriers array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barriers_decrease_by_
+ extern f_status_t f_thread_barriers_decrease_by(const f_array_length_t amount, f_thread_barriers_t * const barriers);
+#endif // _di_f_thread_barriers_decrease_by_
+
+/**
+ * Increase the size of the thread barriers array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param barriers
+ * The thread barriers array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barriers_increase_
+ extern f_status_t f_thread_barriers_increase(const f_array_length_t step, f_thread_barriers_t * const barriers);
+#endif // _di_f_thread_barriers_increase_
+
+/**
+ * Resize the thread barriers array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param barriers
+ * The thread barriers array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barriers_increase_by_
+ extern f_status_t f_thread_barriers_increase_by(const f_array_length_t amount, f_thread_barriers_t * const barriers);
+#endif // _di_f_thread_barriers_increase_by_
+
+/**
+ * Resize the thread barriers array.
+ *
+ * @param length
+ * The new size to use.
+ * @param barriers
+ * The thread barriers array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barriers_resize_
+ extern f_status_t f_thread_barriers_resize(const f_array_length_t length, f_thread_barriers_t * const barriers);
+#endif // _di_f_thread_barriers_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_barrier_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "barrier_attribute.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_barrier_attributes_adjust_
+ f_status_t f_thread_barrier_attributes_adjust(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_barrier_attributes_adjust(length, attributes);
+ }
+#endif // _di_f_thread_barrier_attributes_adjust_
+
+#ifndef _di_f_thread_barrier_attributes_decimate_by_
+ f_status_t f_thread_barrier_attributes_decimate_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_barrier_attributes_adjust(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_barrier_attributes_adjust(0, attributes);
+ }
+#endif // _di_f_thread_barrier_attributes_decimate_by_
+
+#ifndef _di_f_thread_barrier_attributes_decrease_by_
+ f_status_t f_thread_barrier_attributes_decrease_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_barrier_attributes_resize(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_barrier_attributes_resize(0, attributes);
+ }
+#endif // _di_f_thread_barrier_attributes_decrease_by_
+
+#ifndef _di_f_thread_barrier_attributes_increase_
+ f_status_t f_thread_barrier_attributes_increase(const f_array_length_t step, f_thread_barrier_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && attributes->used + 1 > attributes->size) {
+ f_array_length_t size = attributes->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (attributes->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_barrier_attributes_resize(size, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_barrier_attributes_increase_
+
+#ifndef _di_f_thread_barrier_attributes_increase_by_
+ f_status_t f_thread_barrier_attributes_increase_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->used + amount > attributes->size) {
+ if (attributes->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_barrier_attributes_resize(attributes->used + amount, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_barrier_attributes_increase_by_
+
+#ifndef _di_f_thread_barrier_attributes_resize_
+ f_status_t f_thread_barrier_attributes_resize(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_barrier_attributes_resize(length, attributes);
+ }
+#endif // _di_f_thread_barrier_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_barrier_attribute_h
+#define _F_thread_barrier_attribute_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_barrierattr_t.
+ */
+#ifndef _di_f_thread_barrier_attribute_t_
+ typedef pthread_barrierattr_t f_thread_barrier_attribute_t;
+
+ #define f_thread_barrier_attribute_t_initialize { 0 }
+
+ #define macro_f_thread_barrier_attribute_t_initialize(attribute) attribute
+
+ // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
+ #define macro_f_thread_barrier_attribute_t_clear(attribute) attribute.__align = 0;
+
+ #define macro_f_thread_barrier_attribute_t_delete_simple(attribute) f_thread_barrier_attribute_delete(&attribute);
+#endif // _di_f_thread_barrier_attribute_t_
+
+/**
+ * An array of f_thread_barrier_attribute_t.
+ *
+ * array: The array of f_thread_barrier_attribute_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_barrier_attributes_t_
+ typedef struct {
+ f_thread_barrier_attribute_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_barrier_attributes_t;
+
+ #define f_thread_barrier_attributes_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_barrier_attributes_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_barrier_attributes_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_barrier_attributes_t_clear(barrier_attributes) macro_f_memory_structure_clear(barrier_attributes)
+
+ #define macro_f_thread_barrier_attributes_t_resize(status, barrier_attributes, length) status = f_thread_barrier_attributes_resize(length, &barrier_attributes);
+ #define macro_f_thread_barrier_attributes_t_adjust(status, barrier_attributes, length) status = f_thread_barrier_attributes_adjust(length, &barrier_attributes);
+
+ #define macro_f_thread_barrier_attributes_t_delete_simple(barrier_attributes) f_thread_barrier_attributes_resize(0, &barrier_attributes);
+ #define macro_f_thread_barrier_attributes_t_destroy_simple(barrier_attributes) f_thread_barrier_attributes_adjust(0, &barrier_attributes);
+
+ #define macro_f_thread_barrier_attributes_t_increase(status, step, barrier_attributes) status = f_thread_barrier_attributes_increase(step, barrier_attributes);
+ #define macro_f_thread_barrier_attributes_t_increase_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_increase_by(amount, barrier_attributes);
+ #define macro_f_thread_barrier_attributes_t_decrease_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_decrease_by(amount, barrier_attributes);
+ #define macro_f_thread_barrier_attributes_t_decimate_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_decimate_by(amount, barrier_attributes);
+#endif // _di_f_thread_barrier_attributes_t_
+
+/**
+ * Resize the thread barrier attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The thread attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barrier_attributes_adjust_
+ extern f_status_t f_thread_barrier_attributes_adjust(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes);
+#endif // _di_f_thread_barrier_attributes_adjust_
+
+/**
+ * Resize the thread barrier attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param attributes
+ * The thread attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barrier_attributes_decimate_by_
+ extern f_status_t f_thread_barrier_attributes_decimate_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes);
+#endif // _di_f_thread_barrier_attributes_decimate_by_
+
+/**
+ * Resize the thread barrier attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param attributes
+ * The thread attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barrier_attributes_decrease_by_
+ extern f_status_t f_thread_barrier_attributes_decrease_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes);
+#endif // _di_f_thread_barrier_attributes_decrease_by_
+
+/**
+ * Increase the size of the thread barrier attributes array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param attributes
+ * The thread attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barrier_attributes_increase_
+ extern f_status_t f_thread_barrier_attributes_increase(const f_array_length_t step, f_thread_barrier_attributes_t * const attributes);
+#endif // _di_f_thread_barrier_attributes_increase_
+
+/**
+ * Resize the thread barrier attributes array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param attributes
+ * The thread attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barrier_attributes_increase_by_
+ extern f_status_t f_thread_barrier_attributes_increase_by(const f_array_length_t amount, f_thread_barrier_attributes_t * const attributes);
+#endif // _di_f_thread_barrier_attributes_increase_by_
+
+/**
+ * Resize the thread barrier attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The thread attributes array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_barrier_attributes_resize_
+ extern f_status_t f_thread_barrier_attributes_resize(const f_array_length_t length, f_thread_barrier_attributes_t * const attributes);
+#endif // _di_f_thread_barrier_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_barrier_attribute_h
+++ /dev/null
-/**
- * FLL - Level 0
- *
- * Project: Thread
- * API Version: 0.5
- * Licenses: lgpl-2.1-or-later
- *
- * Defines common data to be used for/by POSIX thread related functionality.
- *
- * This is auto-included by thread.h and should not need to be explicitly included.
- */
-#ifndef _F_thread_common_h
-#define _F_thread_common_h
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * A typedef representing pthread_attr_t.
- */
-#ifndef _di_f_thread_attribute_t_
- typedef pthread_attr_t f_thread_attribute_t;
-
- #define f_thread_attribute_t_initialize { 0 }
-
- #define macro_f_thread_attribute_t_initialize(attribute) attribute
-
- // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
- #define macro_f_thread_attribute_t_clear(attribute) attribute.__align = 0;
-
- #define macro_f_thread_attribute_t_delete_simple(attribute) f_thread_attribute_delete(&attribute);
-#endif // _di_f_thread_attribute_t_
-
-/**
- * An array of f_thread_attribute_t.
- *
- * array: The array of f_thread_attribute_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_attributes_t_
- typedef struct {
- f_thread_attribute_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_attributes_t;
-
- #define f_thread_attributes_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_attributes_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_attributes_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes)
-
- #define macro_f_thread_attributes_t_resize(status, attributes, length) status = f_thread_attributes_resize(length, &attributes);
- #define macro_f_thread_attributes_t_adjust(status, attributes, length) status = f_thread_attributes_adjust(length, &attributes);
-
- #define macro_f_thread_attributes_t_delete_simple(attributes) f_thread_attributes_resize(0, &attributes);
- #define macro_f_thread_attributes_t_destroy_simple(attributes) f_thread_attributes_adjust(0, &attributes);
-
- #define macro_f_thread_attributes_t_increase(status, step, attributes) status = f_thread_attributes_increase(step, attributes);
- #define macro_f_thread_attributes_t_increase_by(status, attributes, amount) status = f_thread_attributes_increase_by(amount, attributes);
- #define macro_f_thread_attributes_t_decrease_by(status, attributes, amount) status = f_thread_attributes_decrease_by(amount, attributes);
- #define macro_f_thread_attributes_t_decimate_by(status, attributes, amount) status = f_thread_attributes_decimate_by(amount, attributes);
-#endif // _di_f_thread_attributes_t_
-
-/**
- * A typedef representing pthread_barrier_t.
- */
-#ifndef _di_f_thread_barrier_t_
- typedef pthread_barrier_t f_thread_barrier_t;
-
- #define f_thread_barrier_t_initialize { 0 }
-
- #define macro_f_thread_barrier_t_initialize(barrier) barrier
-
- #define macro_f_thread_barrier_t_clear(barrier) barrier = 0;
-
- #define macro_f_thread_barrier_t_delete_simple(barrier) f_thread_barrier_delete(&barrier);
-#endif // _di_f_thread_barrier_t_
-
-/**
- * An array of f_thread_barrier_t.
- *
- * array: The array of f_thread_barrier_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_barriers_t_
- typedef struct {
- f_thread_barrier_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_barriers_t;
-
- #define f_thread_barriers_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_barriers_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_barriers_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_barriers_t_clear(barriers) macro_f_memory_structure_clear(barriers)
-
- #define macro_f_thread_barriers_t_resize(status, barriers, length) status = f_thread_barriers_resize(length, &barriers);
- #define macro_f_thread_barriers_t_adjust(status, barriers, length) status = f_thread_barriers_adjust(length, &barriers);
-
- #define macro_f_thread_barriers_t_delete_simple(barriers) f_thread_barriers_resize(0, &barriers);
- #define macro_f_thread_barriers_t_destroy_simple(barriers) f_thread_barriers_adjust(0, &barriers);
-
- #define macro_f_thread_barriers_t_increase(status, step, barriers) status = f_thread_barriers_increase(step, barriers);
- #define macro_f_thread_barriers_t_increase_by(status, barriers, amount) status = f_thread_barriers_increase_by(amount, barriers);
- #define macro_f_thread_barriers_t_decrease_by(status, barriers, amount) status = f_thread_barriers_decrease_by(amount, barriers);
- #define macro_f_thread_barriers_t_decimate_by(status, barriers, amount) status = f_thread_barriers_decimate_by(amount, barriers);
-#endif // _di_f_thread_barriers_t_
-
-/**
- * A typedef representing pthread_barrierattr_t.
- */
-#ifndef _di_f_thread_barrier_attribute_t_
- typedef pthread_barrierattr_t f_thread_barrier_attribute_t;
-
- #define f_thread_barrier_attribute_t_initialize { 0 }
-
- #define macro_f_thread_barrier_attribute_t_initialize(attribute) attribute
-
- // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
- #define macro_f_thread_barrier_attribute_t_clear(attribute) attribute.__align = 0;
-
- #define macro_f_thread_barrier_attribute_t_delete_simple(attribute) f_thread_barrier_attribute_delete(&attribute);
-#endif // _di_f_thread_barrier_attribute_t_
-
-/**
- * An array of f_thread_barrier_attribute_t.
- *
- * array: The array of f_thread_barrier_attribute_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_barrier_attributes_t_
- typedef struct {
- f_thread_barrier_attribute_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_barrier_attributes_t;
-
- #define f_thread_barrier_attributes_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_barrier_attributes_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_barrier_attributes_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_barrier_attributes_t_clear(barrier_attributes) macro_f_memory_structure_clear(barrier_attributes)
-
- #define macro_f_thread_barrier_attributes_t_resize(status, barrier_attributes, length) status = f_thread_barrier_attributes_resize(length, &barrier_attributes);
- #define macro_f_thread_barrier_attributes_t_adjust(status, barrier_attributes, length) status = f_thread_barrier_attributes_adjust(length, &barrier_attributes);
-
- #define macro_f_thread_barrier_attributes_t_delete_simple(barrier_attributes) f_thread_barrier_attributes_resize(0, &barrier_attributes);
- #define macro_f_thread_barrier_attributes_t_destroy_simple(barrier_attributes) f_thread_barrier_attributes_adjust(0, &barrier_attributes);
-
- #define macro_f_thread_barrier_attributes_t_increase(status, step, barrier_attributes) status = f_thread_barrier_attributes_increase(step, barrier_attributes);
- #define macro_f_thread_barrier_attributes_t_increase_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_increase_by(amount, barrier_attributes);
- #define macro_f_thread_barrier_attributes_t_decrease_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_decrease_by(amount, barrier_attributes);
- #define macro_f_thread_barrier_attributes_t_decimate_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_decimate_by(amount, barrier_attributes);
-#endif // _di_f_thread_barrier_attributes_t_
-
-/**
- * A typedef representing pthread_cond_t.
- *
- * This must be dynamically initialized using f_thread_condition_create().
- * In some cases, they can be utilized statically, in which case only f_thread_condition_t_initialize is needed.
- */
-#ifndef _di_f_thread_condition_t_
- typedef pthread_cond_t f_thread_condition_t;
-
- #define f_thread_condition_t_initialize PTHREAD_COND_INITIALIZER
-
- #define macro_f_thread_condition_t_initialize(condition) { condition }
-
- #define macro_f_thread_condition_t_delete_simple(condition) f_thread_condition_delete(&condition);
-#endif // _di_f_thread_condition_t_
-
-/**
- * An array of thread conditions.
- *
- * array: The array of f_thread_condition_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_conditions_t_
- typedef struct {
- f_thread_condition_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_conditions_t;
-
- #define f_thread_conditions_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_conditions_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_conditions_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_conditions_t_clear(conditions) macro_f_memory_structure_clear(conditions)
-
- #define macro_f_thread_conditions_t_resize(status, conditions, length) status = f_thread_conditions_resize(length, &conditions);
- #define macro_f_thread_conditions_t_adjust(status, conditions, length) status = f_thread_conditions_adjust(length, &conditions);
-
- #define macro_f_thread_conditions_t_delete_simple(conditions) f_thread_conditions_resize(0, &conditions);
- #define macro_f_thread_conditions_t_destroy_simple(conditions) f_thread_conditions_adjust(0, &conditions);
-
- #define macro_f_thread_conditions_t_increase(status, step, conditions) status = f_thread_conditions_increase(step, conditions);
- #define macro_f_thread_conditions_t_increase_by(status, conditions, amount) status = f_thread_conditions_increase_by(amount, conditions);
- #define macro_f_thread_conditions_t_decrease_by(status, conditions, amount) status = f_thread_conditions_decrease_by(amount, conditions);
- #define macro_f_thread_conditions_t_decimate_by(status, conditions, amount) status = f_thread_conditions_decimate_by(amount, conditions);
-#endif // _di_f_thread_conditions_t_
-
-/**
- * A typedef representing pthread_cond_t.
- */
-#ifndef _di_f_thread_condition_attribute_t_
- typedef pthread_condattr_t f_thread_condition_attribute_t;
-
- #define f_thread_condition_attribute_t_initialize { 0 };
-
- #define macro_f_thread_condition_attribute_t_initialize(array, size, used) attribute
-
- // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
- #define macro_f_thread_condition_attribute_t_clear(attribute) attribute.__align = 0;
-
- #define macro_f_thread_condition_attribute_t_delete_simple(attribute) f_thread_condition_attribute_delete(&attribute);
-#endif // _di_f_thread_condition_attribute_t_
-
-/**
- * An array of thread condition attributes.
- *
- * array: The array of f_thread_condition_attribute_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_condition_attributes_t_
- typedef struct {
- f_thread_condition_attribute_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_condition_attributes_t;
-
- #define f_thread_condition_attributes_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_condition_attributes_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_condition_attributes_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_condition_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes)
-
- #define macro_f_thread_condition_attributes_t_resize(status, attributes, length) status = f_thread_condition_attributes_resize(length, &attributes);
- #define macro_f_thread_condition_attributes_t_adjust(status, attributes, length) status = f_thread_condition_attributes_adjust(length, &attributes);
-
- #define macro_f_thread_condition_attributes_t_delete_simple(attributes) f_thread_condition_attributes_resize(0, &condition_attributes);
- #define macro_f_thread_condition_attributes_t_destroy_simple(attributes) f_thread_condition_attributes_adjust(0, &condition_attributes);
-
- #define macro_f_thread_condition_attributes_t_increase(status, step, attributes) status = f_thread_condition_attributes_increase(step, attributes);
- #define macro_f_thread_condition_attributes_t_increase_by(status, attributes, amount) status = f_thread_condition_attributes_increase_by(amount, attributes);
- #define macro_f_thread_condition_attributes_t_decrease_by(status, attributes, amount) status = f_thread_condition_attributes_decrease_by(amount, attributes);
- #define macro_f_thread_condition_attributes_t_decimate_by(status, attributes, amount) status = f_thread_condition_attributes_decimate_by(amount, attributes);
-#endif // _di_f_thread_condition_attributes_t_
-
-/**
- * A typedef representing pthread_t.
- */
-#ifndef _di_f_thread_id_t_
- typedef pthread_t f_thread_id_t;
-
- #define f_thread_id_t_initialize 0
-
- #define macro_f_thread_id_t_clear(id) id = 0;
-#endif // _di_f_thread_id_t_
-
-/**
- * An array of thread IDs.
- *
- * array: The array of f_thread_id_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_ids_t_
- typedef struct {
- f_thread_id_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_ids_t;
-
- #define f_thread_ids_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_ids_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_ids_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_ids_t_resize(status, ids, length) macro_f_memory_structure_resize(status, ids, f_thread_id_t, length)
- #define macro_f_thread_ids_t_adjust(status, ids, length) macro_f_memory_structure_adjust(status, ids, f_thread_id_t, length)
-
- #define macro_f_thread_ids_t_delete_simple(ids) macro_f_memory_structure_delete_simple(ids, f_thread_id_t)
- #define macro_f_thread_ids_t_destroy_simple(ids) macro_f_memory_structure_destroy_simple(ids, f_thread_id_t)
-
- #define macro_f_thread_ids_t_increase(status, step, ids) macro_f_memory_structure_increase(status, step, ids, f_thread_id_t)
- #define macro_f_thread_ids_t_increase_by(status, ids, amount) macro_f_memory_structure_increase_by(status, ids, f_thread_id_t, amount)
- #define macro_f_thread_ids_t_decrease_by(status, ids, amount) macro_f_memory_structure_decrease_by(status, ids, f_thread_id_t, amount)
- #define macro_f_thread_ids_t_decimate_by(status, ids, amount) macro_f_memory_structure_decimate_by(status, ids, f_thread_id_t, amount)
-#endif // _di_f_thread_ids_t_
-
-/**
- * A typedef representing pthread_key_t.
- */
-#ifndef _di_f_thread_key_t_
- typedef pthread_key_t f_thread_key_t;
-
- #define f_thread_key_t_initialize 0
-
- #define macro_f_thread_key_t_initialize(key) key
-
- #define macro_f_thread_key_t_clear(key) key = 0;
-
- #define macro_f_thread_key_t_delete_simple(key) f_thread_key_delete(&key);
-#endif // _di_f_thread_key_t_
-
-/**
- * An array of thread keys.
- *
- * array: The array of f_thread_key_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_keys_t_
- typedef struct {
- f_thread_key_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_keys_t;
-
- #define f_thread_keys_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_keys_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_keys_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_keys_t_clear(keys) macro_f_memory_structure_clear(keys)
-
- #define macro_f_thread_keys_t_resize(status, keys, length) status = f_thread_keys_resize(length, &keys);
- #define macro_f_thread_keys_t_adjust(status, keys, length) status = f_thread_keys_adjust(length, &keys);
-
- #define macro_f_thread_keys_t_delete_simple(keys) f_thread_keys_resize(0, &keys);
- #define macro_f_thread_keys_t_destroy_simple(keys) f_thread_keys_adjust(0, &keys);
-
- #define macro_f_thread_keys_t_increase(status, step, keys) status = f_thread_keys_increase(step, keys);
- #define macro_f_thread_keys_t_increase_by(status, keys, amount) status = f_thread_keys_increase_by(amount, keys);
- #define macro_f_thread_keys_t_decrease_by(status, keys, amount) status = f_thread_keys_decrease_by(amount, keys);
- #define macro_f_thread_keys_t_decimate_by(status, keys, amount) status = f_thread_keys_decimate_by(amount, keys);
-#endif // _di_f_thread_keys_t_
-
-/**
- * A typedef representing pthread_rwlock_t (read/write lock).
- *
- * This must be dynamically initialized using f_thread_lock_create().
- * In some cases, they can be utilized statically, in which case only f_thread_lock_t_initialize is needed.
- */
-#ifndef _di_f_thread_lock_t_
- typedef pthread_rwlock_t f_thread_lock_t;
-
- #define f_thread_lock_t_initialize PTHREAD_RWLOCK_INITIALIZER
-
- #define macro_f_thread_lock_t_initialize(lock) lock
-
- #define macro_f_thread_lock_t_delete_simple(lock) f_thread_lock_delete(&lock);
-#endif // _di_f_thread_lock_t_
-
-/**
- * An array of thread locks.
- *
- * array: The array of f_thread_lock_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_locks_t_
- typedef struct {
- f_thread_lock_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_locks_t;
-
- #define f_thread_locks_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_locks_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_locks_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_locks_t_resize(status, locks, length) macro_f_memory_structure_resize(status, locks, f_thread_lock_t, length)
- #define macro_f_thread_locks_t_adjust(status, locks, length) macro_f_memory_structure_adjust(status, locks, f_thread_lock_t, length)
-
- #define macro_f_thread_locks_t_delete_simple(locks) macro_f_memory_structure_delete_simple(locks, f_thread_lock_t)
- #define macro_f_thread_locks_t_destroy_simple(locks) macro_f_memory_structure_destroy_simple(locks, f_thread_lock_t)
-
- #define macro_f_thread_locks_t_increase(status, step, locks) macro_f_memory_structure_increase(status, step, locks, f_thread_lock_t)
- #define macro_f_thread_locks_t_increase_by(status, locks, amount) macro_f_memory_structure_increase_by(status, locks, f_thread_lock_t, amount)
- #define macro_f_thread_locks_t_decrease_by(status, locks, amount) macro_f_memory_structure_decrease_by(status, locks, f_thread_lock_t, amount)
- #define macro_f_thread_locks_t_decimate_by(status, locks, amount) macro_f_memory_structure_decimate_by(status, locks, f_thread_lock_t, amount)
-#endif // _di_f_thread_locks_t_
-
-/**
- * A typedef representing pthread_rwlockattr_t.
- */
-#ifndef _di_f_thread_lock_attribute_t_
- typedef pthread_rwlockattr_t f_thread_lock_attribute_t;
-
- #define f_thread_lock_attribute_t_initialize { 0 }
-
- #define macro_f_thread_lock_attribute_t_initialize(attribute) attribute
-
- // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
- #define macro_f_thread_lock_attribute_t_clear(attribute) attribute.__align = 0;
-
- #define macro_f_thread_lock_attribute_t_delete_simple(attribute) f_thread_lock_attribute_delete(&attribute);
-#endif // _di_f_thread_lock_attribute_t_
-
-/**
- * An array of read/write lock attributees.
- *
- * array: The array of f_thread_lock_attribute_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_lock_attributes_t_
- typedef struct {
- f_thread_lock_attribute_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_lock_attributes_t;
-
- #define f_thread_lock_attributes_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_lock_attributes_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_lock_attributes_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_lock_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes)
-
- #define macro_f_thread_lock_attributes_t_resize(status, attributes, length) status = f_thread_lock_attributes_resize(length, &attributes);
- #define macro_f_thread_lock_attributes_t_adjust(status, attributes, length) status = f_thread_lock_attributes_adjust(length, &attributes);
-
- #define macro_f_thread_lock_attributes_t_delete_simple(attributes) f_thread_lock_attributes_resize(0, &attributes);
- #define macro_f_thread_lock_attributes_t_destroy_simple(attributes) f_thread_lock_attributes_adjust(0, &attributes);
-
- #define macro_f_thread_lock_attributes_t_increase(status, step, attributes) status = f_thread_lock_attributes_increase(step, attributes);
- #define macro_f_thread_lock_attributes_t_increase_by(status, attributes, amount) status = f_thread_lock_attributes_increase_by(amount, attributes);
- #define macro_f_thread_lock_attributes_t_decrease_by(status, attributes, amount) status = f_thread_lock_attributes_decrease_by(amount, attributes);
- #define macro_f_thread_lock_attributes_t_decimate_by(status, attributes, amount) status = f_thread_lock_attributes_decimate_by(amount, attributes);
-#endif // _di_f_thread_lock_attributes_t_
-
-/**
- * A typedef representing pthread_mutex_t.
- *
- * This variable cannot be cleared by setting value to 0, so there is no clear macro provided.
- *
- * This must be dynamically initialized using f_thread_mutex_create().
- * In some cases, they can be utilized statically, in which case only f_thread_mutex_t_initialize is needed.
- */
-#ifndef _di_f_thread_mutex_t_
- typedef pthread_mutex_t f_thread_mutex_t;
-
- #define f_thread_mutex_t_initialize PTHREAD_MUTEX_INITIALIZER
-
- #define macro_f_thread_mutex_t_initialize(mutex) mutex
-
- #define macro_f_thread_mutex_t_delete_simple(mutex) f_thread_mutex_delete(&mutex);
-#endif // _di_f_thread_mutex_t_
-
-/**
- * An array of thread mutexes.
- *
- * array: The array of f_thread_mutex_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_mutexs_t_
- typedef struct {
- f_thread_mutex_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_mutexs_t;
-
- #define f_thread_mutexs_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_mutexs_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_mutexs_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_mutexs_t_clear(mutexs) macro_f_memory_structure_clear(mutexs)
-
- #define macro_f_thread_mutexs_t_resize(status, mutexs, length) status = f_thread_mutexs_resize(length, &mutexs);
- #define macro_f_thread_mutexs_t_adjust(status, mutexs, length) status = f_thread_mutexs_adjust(length, &mutexs);
-
- #define macro_f_thread_mutexs_t_delete_simple(mutexs) f_thread_mutexs_resize(0, &mutexs);
- #define macro_f_thread_mutexs_t_destroy_simple(mutexs) f_thread_mutexs_adjust(0, &mutexs);
-
- #define macro_f_thread_mutexs_t_increase(status, step, mutexs) status = f_thread_mutexs_increase(step, mutexs);
- #define macro_f_thread_mutexs_t_increase_by(status, mutexs, amount) status = f_thread_mutexs_increase_by(amount, mutexs);
- #define macro_f_thread_mutexs_t_decrease_by(status, mutexs, amount) status = f_thread_mutexs_decrease_by(amount, mutexs);
- #define macro_f_thread_mutexs_t_decimate_by(status, mutexs, amount) status = f_thread_mutexs_decimate_by(amount, mutexs);
-#endif // _di_f_thread_mutexs_t_
-
-/**
- * A typedef representing pthread_mutex_attribute_t.
- */
-#ifndef _di_f_thread_mutex_attribute_t_
- typedef pthread_mutexattr_t f_thread_mutex_attribute_t;
-
- #define f_thread_mutex_attribute_t_initialize { 0 }
-
- #define macro_f_thread_mutex_attribute_t_initialize(attribute) attribute
-
- // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
- #define macro_f_thread_mutex_attribute_t_clear(attribute) attribute.__align = 0;
-
- #define macro_f_thread_mutex_attribute_t_delete_simple(attribute) f_thread_mutex_attribute_delete(&attribute);
-#endif // _di_f_thread_mutex_attribute_t_
-
-/**
- * An array of thread mutex_attributees.
- *
- * array: The array of f_thread_mutex_attribute_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_mutex_attributes_t_
- typedef struct {
- f_thread_mutex_attribute_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_mutex_attributes_t;
-
- #define f_thread_mutex_attributes_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_mutex_attributes_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_mutex_attributes_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_mutex_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes)
-
- #define macro_f_thread_mutex_attributes_t_resize(status, attributes, length) status = f_thread_mutex_attributes_resize(length, &attributes);
- #define macro_f_thread_mutex_attributes_t_adjust(status, attributes, length) status = f_thread_mutex_attributes_adjust(length, &attributes);
-
- #define macro_f_thread_mutex_attributes_t_delete_simple(attributes) f_thread_mutex_attributes_resize(0, &attributes);
- #define macro_f_thread_mutex_attributes_t_destroy_simple(attributes) f_thread_mutex_attributes_adjust(0, &attributes);
-
- #define macro_f_thread_mutex_attributes_t_increase(status, step, attributes) status = f_thread_mutex_attributes_increase(step, attributes);
- #define macro_f_thread_mutex_attributes_t_increase_by(status, attributes, amount) status = f_thread_mutex_attributes_increase_by(amount, attributes);
- #define macro_f_thread_mutex_attributes_t_decrease_by(status, attributes, amount) status = f_thread_mutex_attributes_decrease_by(amount, attributes);
- #define macro_f_thread_mutex_attributes_t_decimate_by(status, attributes, amount) status = f_thread_mutex_attributes_decimate_by(amount, attributes);
-#endif // _di_f_thread_mutex_attributes_t_
-
-/**
- * A typedef representing pthread_once_t.
- *
- * There are no delete functions and therefore no delete macros.
- */
-#ifndef _di_f_thread_once_t_
- typedef pthread_once_t f_thread_once_t;
-
- #define f_thread_once_t_initialize PTHREAD_ONCE_INIT
-
- #define macro_f_thread_once_t_initialize(once) once
-#endif // _di_f_thread_once_t_
-
-/**
- * An array of thread onces.
- *
- * array: The array of f_thread_once_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_onces_t_
- typedef struct {
- f_thread_once_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_onces_t;
-
- #define f_thread_onces_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_onces_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_onces_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_onces_t_clear(onces) macro_f_memory_structure_clear(onces)
-
- #define macro_f_thread_onces_t_resize(status, onces, length) macro_f_memory_structure_resize(status, onces, f_thread_once_t, length)
- #define macro_f_thread_onces_t_adjust(status, onces, length) macro_f_memory_structure_adjust(status, onces, f_thread_once_t, length)
-
- #define macro_f_thread_onces_t_delete_simple(onces) macro_f_memory_structure_delete_simple(onces, f_thread_once_t)
- #define macro_f_thread_onces_t_destroy_simple(onces) macro_f_memory_structure_destroy_simple(onces, f_thread_once_t)
-
- #define macro_f_thread_onces_t_increase(status, step, onces) macro_f_memory_structure_increase(status, step, onces, f_thread_once_t)
- #define macro_f_thread_onces_t_increase_by(status, onces, amount) macro_f_memory_structure_increase_by(status, onces, f_thread_once_t, amount)
- #define macro_f_thread_onces_t_decrease_by(status, onces, amount) macro_f_memory_structure_decrease_by(status, onces, f_thread_once_t, amount)
- #define macro_f_thread_onces_t_decimate_by(status, onces, amount) macro_f_memory_structure_decimate_by(status, onces, f_thread_once_t, amount)
-#endif // _di_f_thread_onces_t_
-
-/**
- * A typedef representing sem_t.
- *
- * This variable cannot be cleared by setting value to 0, so there is no clear macro provided.
- *
- * This must be dynamically initialized using f_thread_semaphore_create().
- */
-#ifndef _di_f_thread_semaphore_t_
- typedef sem_t f_thread_semaphore_t;
-
- #define f_thread_semaphore_t_initialize 0
-
- #define macro_f_thread_semaphore_t_initialize(semaphore) semaphore
-
- #define macro_f_thread_semaphore_t_delete_simple(semaphore) f_thread_semaphore_delete(&semaphore);
-#endif // _di_f_thread_semaphore_t_
-
-/**
- * An array of thread semaphorees.
- *
- * array: The array of f_thread_semaphore_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_semaphores_t_
- typedef struct {
- f_thread_semaphore_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_semaphores_t;
-
- #define f_thread_semaphores_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_semaphores_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_semaphores_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_semaphores_t_clear(semaphores) macro_f_memory_structure_clear(semaphores)
-
- #define macro_f_thread_semaphores_t_resize(status, semaphores, length) status = f_thread_semaphores_resize(length, &semaphores);
- #define macro_f_thread_semaphores_t_adjust(status, semaphores, length) status = f_thread_semaphores_adjust(length, &semaphores);
-
- #define macro_f_thread_semaphores_t_delete_simple(semaphores) f_thread_semaphores_resize(0, &semaphores);
- #define macro_f_thread_semaphores_t_destroy_simple(semaphores) f_thread_semaphores_adjust(0, &semaphores);
-
- #define macro_f_thread_semaphores_t_increase(status, step, semaphores) status = f_thread_semaphores_increase(step, semaphores);
- #define macro_f_thread_semaphores_t_increase_by(status, semaphores, amount) status = f_thread_semaphores_increase_by(amount, semaphores);
- #define macro_f_thread_semaphores_t_decrease_by(status, semaphores, amount) status = f_thread_semaphores_decrease_by(amount, semaphores);
- #define macro_f_thread_semaphores_t_decimate_by(status, semaphores, amount) status = f_thread_semaphores_decimate_by(amount, semaphores);
-#endif // _di_f_thread_semaphores_t_
-
-/**
- * A structure containing basic thread information.
- *
- * attribute: The thread attributes (which is a union).
- * id: The thread identifier.
- * result: The result of the thread on exit.
- */
-#ifndef _di_f_thread_set_t_
- typedef struct {
- f_thread_attribute_t attribute;
- f_thread_id_t id;
- int result;
- } f_thread_set_t;
-
- #define f_thread_set_t_initialize { f_thread_attribute_t_initialize, f_thread_id_t_initialize, 0 }
-
- #define macro_f_thread_set_t_initialize(attribute, id, result) { attribute, id, result }
-
- #define macro_f_thread_set_t_clear(thread) \
- macro_f_thread_attribute_t_clear(thread.attribute) \
- macro_f_thread_id_t_clear(thread.id) \
- result = 0;
-
- #define macro_f_thread_set_t_delete_simple(set) macro_f_thread_attribute_t_delete_simple(set.attribute)
-#endif // _di_f_thread_set_t_
-
-/**
- * An array of f_thread_set_t.
- *
- * array: The array of f_thread_set_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_sets_t_
- typedef struct {
- f_thread_set_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_sets_t;
-
- #define f_thread_sets_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_sets_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_sets_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_sets_t_clear(sets) macro_f_memory_structure_clear(sets)
-
- #define macro_f_thread_sets_t_resize(status, sets, length) status = f_thread_sets_resize(length, &sets);
- #define macro_f_thread_sets_t_adjust(status, sets, length) status = f_thread_sets_adjust(length, &sets);
-
- #define macro_f_thread_sets_t_delete_simple(sets) f_thread_sets_resize(0, &sets);
- #define macro_f_thread_sets_t_destroy_simple(sets) f_thread_sets_adjust(0, &sets);
-
- #define macro_f_thread_sets_t_increase(status, step, sets) status = f_thread_sets_increase(step, sets);
- #define macro_f_thread_sets_t_increase_by(status, sets, amount) status = f_thread_sets_increase_by(amount, sets);
- #define macro_f_thread_sets_t_decrease_by(status, sets, amount) status = f_thread_sets_decrease_by(amount, sets);
- #define macro_f_thread_sets_t_decimate_by(status, sets, amount) status = f_thread_sets_decimate_by(amount, sets);
-#endif // _di_f_thread_sets_t_
-
-/**
- * A typedef representing pthread_spinlock_t.
- *
- * Note: There appears to be no pthread init macro for spinlock, so initialize manually similarly to how the other inits work.
- */
-#ifndef _di_f_thread_spin_t_
- typedef pthread_spinlock_t f_thread_spin_t;
-
- #define f_thread_spin_t_initialize ((pthread_spinlock_t) 0xFFFFFFFF)
-
- #define macro_f_thread_spin_t_initialize(spin) spin
-
- #define macro_f_thread_spin_t_delete_simple(spin) f_thread_spin_delete(&spin);
-#endif // _di_f_thread_spin_t_
-
-/**
- * An array of thread spins.
- *
- * array: The array of f_thread_spin_t.
- * size: Total amount of allocated space.
- * used: Total number of allocated spaces used.
- */
-#ifndef _di_f_thread_spins_t_
- typedef struct {
- f_thread_spin_t *array;
-
- f_array_length_t size;
- f_array_length_t used;
- } f_thread_spins_t;
-
- #define f_thread_spins_t_initialize { 0, 0, 0 }
-
- #define macro_f_thread_spins_t_initialize(array, size, used) { array, size, used }
- #define macro_f_thread_spins_t_initialize2(array, length) { array, length, length }
-
- #define macro_f_thread_spins_t_clear(spins) macro_f_memory_structure_clear(spins)
-
- #define macro_f_thread_spins_t_resize(status, spins, length) status = f_thread_spins_resize(length, &spins);
- #define macro_f_thread_spins_t_adjust(status, spins, length) status = f_thread_spins_adjust(length, &spins);
-
- #define macro_f_thread_spins_t_delete_simple(spins) f_thread_spins_resize(0, &spins);
- #define macro_f_thread_spins_t_destroy_simple(spins) f_thread_spins_adjust(0, &spins);
-
- #define macro_f_thread_spins_t_increase(status, step, spins) status = f_thread_spins_increase(step, spins);
- #define macro_f_thread_spins_t_increase_by(status, spins, amount) status = f_thread_spins_increase_by(amount, spins);
- #define macro_f_thread_spins_t_decrease_by(status, spins, amount) status = f_thread_spins_decrease_by(amount, spins);
- #define macro_f_thread_spins_t_decimate_by(status, spins, amount) status = f_thread_spins_decimate_by(amount, spins);
-#endif // _di_f_thread_spins_t_
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif // _F_thread_common_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "condition.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_conditions_adjust_
+ f_status_t f_thread_conditions_adjust(const f_array_length_t length, f_thread_conditions_t * const conditions) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!conditions) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_conditions_adjust(length, conditions);
+ }
+#endif // _di_f_thread_conditions_adjust_
+
+#ifndef _di_f_thread_conditions_decimate_by_
+ f_status_t f_thread_conditions_decimate_by(const f_array_length_t amount, f_thread_conditions_t * const conditions) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!conditions) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (conditions->size - amount > 0) {
+ return private_f_thread_conditions_adjust(conditions->size - amount, conditions);
+ }
+
+ return private_f_thread_conditions_adjust(0, conditions);
+ }
+#endif // _di_f_thread_conditions_decimate_by_
+
+#ifndef _di_f_thread_conditions_decrease_by_
+ f_status_t f_thread_conditions_decrease_by(const f_array_length_t amount, f_thread_conditions_t * const conditions) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!conditions) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (conditions->size - amount > 0) {
+ return private_f_thread_conditions_resize(conditions->size - amount, conditions);
+ }
+
+ return private_f_thread_conditions_resize(0, conditions);
+ }
+#endif // _di_f_thread_conditions_decrease_by_
+
+#ifndef _di_f_thread_conditions_increase_
+ f_status_t f_thread_conditions_increase(const f_array_length_t step, f_thread_conditions_t * const conditions) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!conditions) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && conditions->used + 1 > conditions->size) {
+ f_array_length_t size = conditions->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (conditions->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_conditions_resize(size, conditions);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_conditions_increase_
+
+#ifndef _di_f_thread_conditions_increase_by_
+ f_status_t f_thread_conditions_increase_by(const f_array_length_t amount, f_thread_conditions_t * const conditions) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!conditions) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (conditions->used + amount > conditions->size) {
+ if (conditions->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_conditions_resize(conditions->used + amount, conditions);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_conditions_increase_by_
+
+#ifndef _di_f_thread_conditions_resize_
+ f_status_t f_thread_conditions_resize(const f_array_length_t length, f_thread_conditions_t * const conditions) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!conditions) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_conditions_resize(length, conditions);
+ }
+#endif // _di_f_thread_conditions_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_condition_h
+#define _F_thread_condition_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_cond_t.
+ *
+ * This must be dynamically initialized using f_thread_condition_create().
+ * In some cases, they can be utilized statically, in which case only f_thread_condition_t_initialize is needed.
+ */
+#ifndef _di_f_thread_condition_t_
+ typedef pthread_cond_t f_thread_condition_t;
+
+ #define f_thread_condition_t_initialize PTHREAD_COND_INITIALIZER
+
+ #define macro_f_thread_condition_t_initialize(condition) { condition }
+
+ #define macro_f_thread_condition_t_delete_simple(condition) f_thread_condition_delete(&condition);
+#endif // _di_f_thread_condition_t_
+
+/**
+ * An array of thread conditions.
+ *
+ * array: The array of f_thread_condition_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_conditions_t_
+ typedef struct {
+ f_thread_condition_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_conditions_t;
+
+ #define f_thread_conditions_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_conditions_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_conditions_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_conditions_t_clear(conditions) macro_f_memory_structure_clear(conditions)
+
+ #define macro_f_thread_conditions_t_resize(status, conditions, length) status = f_thread_conditions_resize(length, &conditions);
+ #define macro_f_thread_conditions_t_adjust(status, conditions, length) status = f_thread_conditions_adjust(length, &conditions);
+
+ #define macro_f_thread_conditions_t_delete_simple(conditions) f_thread_conditions_resize(0, &conditions);
+ #define macro_f_thread_conditions_t_destroy_simple(conditions) f_thread_conditions_adjust(0, &conditions);
+
+ #define macro_f_thread_conditions_t_increase(status, step, conditions) status = f_thread_conditions_increase(step, conditions);
+ #define macro_f_thread_conditions_t_increase_by(status, conditions, amount) status = f_thread_conditions_increase_by(amount, conditions);
+ #define macro_f_thread_conditions_t_decrease_by(status, conditions, amount) status = f_thread_conditions_decrease_by(amount, conditions);
+ #define macro_f_thread_conditions_t_decimate_by(status, conditions, amount) status = f_thread_conditions_decimate_by(amount, conditions);
+#endif // _di_f_thread_conditions_t_
+
+/**
+ * Resize the thread conditions array.
+ *
+ * @param length
+ * The new size to use.
+ * @param conditions
+ * The string conditions array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_conditions_adjust_
+ extern f_status_t f_thread_conditions_adjust(const f_array_length_t length, f_thread_conditions_t * const conditions);
+#endif // _di_f_thread_conditions_adjust_
+
+/**
+ * Resize the thread conditions array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param conditions
+ * The string conditions array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_conditions_decimate_by_
+ extern f_status_t f_thread_conditions_decimate_by(const f_array_length_t amount, f_thread_conditions_t * const conditions);
+#endif // _di_f_thread_conditions_decimate_by_
+
+/**
+ * Resize the thread conditions array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param conditions
+ * The string conditions array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_conditions_decrease_by_
+ extern f_status_t f_thread_conditions_decrease_by(const f_array_length_t amount, f_thread_conditions_t * const conditions);
+#endif // _di_f_thread_conditions_decrease_by_
+
+/**
+ * Increase the size of the thread conditions array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param conditions
+ * The string conditions array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_conditions_increase_
+ extern f_status_t f_thread_conditions_increase(const f_array_length_t step, f_thread_conditions_t * const conditions);
+#endif // _di_f_thread_conditions_increase_
+
+/**
+ * Resize the thread conditions array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param conditions
+ * The string conditions array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_conditions_increase_by_
+ extern f_status_t f_thread_conditions_increase_by(const f_array_length_t amount, f_thread_conditions_t * const conditions);
+#endif // _di_f_thread_conditions_increase_by_
+
+/**
+ * Resize the thread conditions array.
+ *
+ * @param length
+ * The new size to use.
+ * @param conditions
+ * The string conditions array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_conditions_resize_
+ extern f_status_t f_thread_conditions_resize(const f_array_length_t length, f_thread_conditions_t * const conditions);
+#endif // _di_f_thread_conditions_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_condition_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "condition_attribute.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_condition_attributes_adjust_
+ f_status_t f_thread_condition_attributes_adjust(const f_array_length_t length, f_thread_condition_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_condition_attributes_adjust(length, attributes);
+ }
+#endif // _di_f_thread_condition_attributes_adjust_
+
+#ifndef _di_f_thread_condition_attributes_decimate_by_
+ f_status_t f_thread_condition_attributes_decimate_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_condition_attributes_adjust(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_condition_attributes_adjust(0, attributes);
+ }
+#endif // _di_f_thread_condition_attributes_decimate_by_
+
+#ifndef _di_f_thread_condition_attributes_decrease_by_
+ f_status_t f_thread_condition_attributes_decrease_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_condition_attributes_resize(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_condition_attributes_resize(0, attributes);
+ }
+#endif // _di_f_thread_condition_attributes_decrease_by_
+
+#ifndef _di_f_thread_condition_attributes_increase_
+ f_status_t f_thread_condition_attributes_increase(const f_array_length_t step, f_thread_condition_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && attributes->used + 1 > attributes->size) {
+ f_array_length_t size = attributes->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (attributes->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_condition_attributes_resize(size, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_condition_attributes_increase_
+
+#ifndef _di_f_thread_condition_attributes_increase_by_
+ f_status_t f_thread_condition_attributes_increase_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->used + amount > attributes->size) {
+ if (attributes->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_condition_attributes_resize(attributes->used + amount, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_condition_attributes_increase_by_
+
+#ifndef _di_f_thread_condition_attributes_resize_
+ f_status_t f_thread_condition_attributes_resize(const f_array_length_t length, f_thread_condition_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_condition_attributes_resize(length, attributes);
+ }
+#endif // _di_f_thread_condition_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_condition_attribute_h
+#define _F_thread_condition_attribute_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_cond_t.
+ */
+#ifndef _di_f_thread_condition_attribute_t_
+ typedef pthread_condattr_t f_thread_condition_attribute_t;
+
+ #define f_thread_condition_attribute_t_initialize { 0 };
+
+ #define macro_f_thread_condition_attribute_t_initialize(array, size, used) attribute
+
+ // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
+ #define macro_f_thread_condition_attribute_t_clear(attribute) attribute.__align = 0;
+
+ #define macro_f_thread_condition_attribute_t_delete_simple(attribute) f_thread_condition_attribute_delete(&attribute);
+#endif // _di_f_thread_condition_attribute_t_
+
+/**
+ * An array of thread condition attributes.
+ *
+ * array: The array of f_thread_condition_attribute_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_condition_attributes_t_
+ typedef struct {
+ f_thread_condition_attribute_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_condition_attributes_t;
+
+ #define f_thread_condition_attributes_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_condition_attributes_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_condition_attributes_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_condition_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes)
+
+ #define macro_f_thread_condition_attributes_t_resize(status, attributes, length) status = f_thread_condition_attributes_resize(length, &attributes);
+ #define macro_f_thread_condition_attributes_t_adjust(status, attributes, length) status = f_thread_condition_attributes_adjust(length, &attributes);
+
+ #define macro_f_thread_condition_attributes_t_delete_simple(attributes) f_thread_condition_attributes_resize(0, &condition_attributes);
+ #define macro_f_thread_condition_attributes_t_destroy_simple(attributes) f_thread_condition_attributes_adjust(0, &condition_attributes);
+
+ #define macro_f_thread_condition_attributes_t_increase(status, step, attributes) status = f_thread_condition_attributes_increase(step, attributes);
+ #define macro_f_thread_condition_attributes_t_increase_by(status, attributes, amount) status = f_thread_condition_attributes_increase_by(amount, attributes);
+ #define macro_f_thread_condition_attributes_t_decrease_by(status, attributes, amount) status = f_thread_condition_attributes_decrease_by(amount, attributes);
+ #define macro_f_thread_condition_attributes_t_decimate_by(status, attributes, amount) status = f_thread_condition_attributes_decimate_by(amount, attributes);
+#endif // _di_f_thread_condition_attributes_t_
+
+/**
+ * Resize the thread attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_condition_attributes_adjust_
+ extern f_status_t f_thread_condition_attributes_adjust(const f_array_length_t length, f_thread_condition_attributes_t * const attributes);
+#endif // _di_f_thread_condition_attributes_adjust_
+
+/**
+ * Resize the thread attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_condition_attributes_decimate_by_
+ extern f_status_t f_thread_condition_attributes_decimate_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes);
+#endif // _di_f_thread_condition_attributes_decimate_by_
+
+/**
+ * Resize the thread attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_condition_attributes_decrease_by_
+ extern f_status_t f_thread_condition_attributes_decrease_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes);
+#endif // _di_f_thread_condition_attributes_decrease_by_
+
+/**
+ * Increase the size of the thread attributes array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_condition_attributes_increase_
+ extern f_status_t f_thread_condition_attributes_increase(const f_array_length_t step, f_thread_condition_attributes_t * const attributes);
+#endif // _di_f_thread_condition_attributes_increase_
+
+/**
+ * Resize the thread attributes array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_condition_attributes_increase_by_
+ extern f_status_t f_thread_condition_attributes_increase_by(const f_array_length_t amount, f_thread_condition_attributes_t * const attributes);
+#endif // _di_f_thread_condition_attributes_increase_by_
+
+/**
+ * Resize the thread attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The string attributes array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_condition_attributes_resize_
+ extern f_status_t f_thread_condition_attributes_resize(const f_array_length_t length, f_thread_condition_attributes_t * const attributes);
+#endif // _di_f_thread_condition_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_condition_attribute_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "id.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_ids_adjust_
+ f_status_t f_thread_ids_adjust(const f_array_length_t length, f_thread_ids_t * const ids) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ids) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_ids_adjust(length, ids);
+ }
+#endif // _di_f_thread_ids_adjust_
+
+#ifndef _di_f_thread_ids_decimate_by_
+ f_status_t f_thread_ids_decimate_by(const f_array_length_t amount, f_thread_ids_t * const ids) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ids) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (ids->size - amount > 0) {
+ return private_f_thread_ids_adjust(ids->size - amount, ids);
+ }
+
+ return private_f_thread_ids_adjust(0, ids);
+ }
+#endif // _di_f_thread_ids_decimate_by_
+
+#ifndef _di_f_thread_ids_decrease_by_
+ f_status_t f_thread_ids_decrease_by(const f_array_length_t amount, f_thread_ids_t * const ids) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ids) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (ids->size - amount > 0) {
+ return private_f_thread_ids_resize(ids->size - amount, ids);
+ }
+
+ return private_f_thread_ids_resize(0, ids);
+ }
+#endif // _di_f_thread_ids_decrease_by_
+
+#ifndef _di_f_thread_ids_increase_
+ f_status_t f_thread_ids_increase(const f_array_length_t step, f_thread_ids_t * const ids) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ids) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && ids->used + 1 > ids->size) {
+ f_array_length_t size = ids->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (ids->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_ids_resize(size, ids);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_ids_increase_
+
+#ifndef _di_f_thread_ids_increase_by_
+ f_status_t f_thread_ids_increase_by(const f_array_length_t amount, f_thread_ids_t * const ids) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ids) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (ids->used + amount > ids->size) {
+ if (ids->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_ids_resize(ids->used + amount, ids);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_ids_increase_by_
+
+#ifndef _di_f_thread_ids_resize_
+ f_status_t f_thread_ids_resize(const f_array_length_t length, f_thread_ids_t * const ids) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!ids) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_ids_resize(length, ids);
+ }
+#endif // _di_f_thread_ids_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_id_h
+#define _F_thread_id_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_t.
+ */
+#ifndef _di_f_thread_id_t_
+ typedef pthread_t f_thread_id_t;
+
+ #define f_thread_id_t_initialize 0
+
+ #define macro_f_thread_id_t_clear(id) id = 0;
+#endif // _di_f_thread_id_t_
+
+/**
+ * An array of thread IDs.
+ *
+ * array: The array of f_thread_id_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_ids_t_
+ typedef struct {
+ f_thread_id_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_ids_t;
+
+ #define f_thread_ids_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_ids_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_ids_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_ids_t_clear(attributes) macro_f_memory_structure_clear(attributes)
+
+ #define macro_f_thread_ids_t_resize(status, attributes, length) status = f_thread_ids_resize(length, &attributes);
+ #define macro_f_thread_ids_t_adjust(status, attributes, length) status = f_thread_ids_adjust(length, &attributes);
+
+ #define macro_f_thread_ids_t_delete_simple(attributes) f_thread_ids_resize(0, &ids);
+ #define macro_f_thread_ids_t_destroy_simple(attributes) f_thread_ids_adjust(0, &ids);
+
+ #define macro_f_thread_ids_t_increase(status, step, attributes) status = f_thread_ids_increase(step, attributes);
+ #define macro_f_thread_ids_t_increase_by(status, attributes, amount) status = f_thread_ids_increase_by(amount, attributes);
+ #define macro_f_thread_ids_t_decrease_by(status, attributes, amount) status = f_thread_ids_decrease_by(amount, attributes);
+ #define macro_f_thread_ids_t_decimate_by(status, attributes, amount) status = f_thread_ids_decimate_by(amount, attributes);
+#endif // _di_f_thread_ids_t_
+
+/**
+ * Resize the thread ids array.
+ *
+ * @param length
+ * The new size to use.
+ * @param ids
+ * The thread ids array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_ids_adjust_
+ extern f_status_t f_thread_ids_adjust(const f_array_length_t length, f_thread_ids_t * const ids);
+#endif // _di_f_thread_ids_adjust_
+
+/**
+ * Resize the thread ids array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param ids
+ * The thread ids array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_ids_decimate_by_
+ extern f_status_t f_thread_ids_decimate_by(const f_array_length_t amount, f_thread_ids_t * const ids);
+#endif // _di_f_thread_ids_decimate_by_
+
+/**
+ * Resize the thread ids array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param ids
+ * The thread ids array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_ids_decrease_by_
+ extern f_status_t f_thread_ids_decrease_by(const f_array_length_t amount, f_thread_ids_t * const ids);
+#endif // _di_f_thread_ids_decrease_by_
+
+/**
+ * Increase the size of the thread ids array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param ids
+ * The thread ids array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_ids_increase_
+ extern f_status_t f_thread_ids_increase(const f_array_length_t step, f_thread_ids_t * const ids);
+#endif // _di_f_thread_ids_increase_
+
+/**
+ * Resize the thread ids array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param ids
+ * The thread ids array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_ids_increase_by_
+ extern f_status_t f_thread_ids_increase_by(const f_array_length_t amount, f_thread_ids_t * const ids);
+#endif // _di_f_thread_ids_increase_by_
+
+/**
+ * Resize the thread ids array.
+ *
+ * @param length
+ * The new size to use.
+ * @param ids
+ * The thread ids array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_ids_resize_
+ extern f_status_t f_thread_ids_resize(const f_array_length_t length, f_thread_ids_t * const ids);
+#endif // _di_f_thread_ids_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_id_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "key.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_keys_adjust_
+ f_status_t f_thread_keys_adjust(const f_array_length_t length, f_thread_keys_t * const keys) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!keys) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_keys_adjust(length, keys);
+ }
+#endif // _di_f_thread_keys_adjust_
+
+#ifndef _di_f_thread_keys_decimate_by_
+ f_status_t f_thread_keys_decimate_by(const f_array_length_t amount, f_thread_keys_t * const keys) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!keys) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (keys->size - amount > 0) {
+ return private_f_thread_keys_adjust(keys->size - amount, keys);
+ }
+
+ return private_f_thread_keys_adjust(0, keys);
+ }
+#endif // _di_f_thread_keys_decimate_by_
+
+#ifndef _di_f_thread_keys_decrease_by_
+ f_status_t f_thread_keys_decrease_by(const f_array_length_t amount, f_thread_keys_t * const keys) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!keys) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (keys->size - amount > 0) {
+ return private_f_thread_keys_resize(keys->size - amount, keys);
+ }
+
+ return private_f_thread_keys_resize(0, keys);
+ }
+#endif // _di_f_thread_keys_decrease_by_
+
+#ifndef _di_f_thread_keys_increase_
+ f_status_t f_thread_keys_increase(const f_array_length_t step, f_thread_keys_t * const keys) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!keys) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && keys->used + 1 > keys->size) {
+ f_array_length_t size = keys->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (keys->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_keys_resize(size, keys);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_keys_increase_
+
+#ifndef _di_f_thread_keys_increase_by_
+ f_status_t f_thread_keys_increase_by(const f_array_length_t amount, f_thread_keys_t * const keys) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!keys) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (keys->used + amount > keys->size) {
+ if (keys->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_keys_resize(keys->used + amount, keys);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_keys_increase_by_
+
+#ifndef _di_f_thread_keys_resize_
+ f_status_t f_thread_keys_resize(const f_array_length_t length, f_thread_keys_t * const keys) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!keys) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_keys_resize(length, keys);
+ }
+#endif // _di_f_thread_keys_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_key_h
+#define _F_thread_key_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_key_t.
+ */
+#ifndef _di_f_thread_key_t_
+ typedef pthread_key_t f_thread_key_t;
+
+ #define f_thread_key_t_initialize 0
+
+ #define macro_f_thread_key_t_initialize(key) key
+
+ #define macro_f_thread_key_t_clear(key) key = 0;
+
+ #define macro_f_thread_key_t_delete_simple(key) f_thread_key_delete(&key);
+#endif // _di_f_thread_key_t_
+
+/**
+ * An array of thread keys.
+ *
+ * array: The array of f_thread_key_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_keys_t_
+ typedef struct {
+ f_thread_key_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_keys_t;
+
+ #define f_thread_keys_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_keys_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_keys_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_keys_t_clear(keys) macro_f_memory_structure_clear(keys)
+
+ #define macro_f_thread_keys_t_resize(status, keys, length) status = f_thread_keys_resize(length, &keys);
+ #define macro_f_thread_keys_t_adjust(status, keys, length) status = f_thread_keys_adjust(length, &keys);
+
+ #define macro_f_thread_keys_t_delete_simple(keys) f_thread_keys_resize(0, &keys);
+ #define macro_f_thread_keys_t_destroy_simple(keys) f_thread_keys_adjust(0, &keys);
+
+ #define macro_f_thread_keys_t_increase(status, step, keys) status = f_thread_keys_increase(step, keys);
+ #define macro_f_thread_keys_t_increase_by(status, keys, amount) status = f_thread_keys_increase_by(amount, keys);
+ #define macro_f_thread_keys_t_decrease_by(status, keys, amount) status = f_thread_keys_decrease_by(amount, keys);
+ #define macro_f_thread_keys_t_decimate_by(status, keys, amount) status = f_thread_keys_decimate_by(amount, keys);
+#endif // _di_f_thread_keys_t_
+
+/**
+ * Resize the thread keys array.
+ *
+ * @param length
+ * The new size to use.
+ * @param keys
+ * The string keys array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_keys_adjust_
+ extern f_status_t f_thread_keys_adjust(const f_array_length_t length, f_thread_keys_t * const keys);
+#endif // _di_f_thread_keys_adjust_
+
+/**
+ * Resize the thread keys array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param keys
+ * The string keys array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_keys_decimate_by_
+ extern f_status_t f_thread_keys_decimate_by(const f_array_length_t amount, f_thread_keys_t * const keys);
+#endif // _di_f_thread_keys_decimate_by_
+
+/**
+ * Resize the thread keys array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param keys
+ * The string keys array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_keys_decrease_by_
+ extern f_status_t f_thread_keys_decrease_by(const f_array_length_t amount, f_thread_keys_t * const keys);
+#endif // _di_f_thread_keys_decrease_by_
+
+/**
+ * Increase the size of the thread keys array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param keys
+ * The string keys array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_keys_increase_
+ extern f_status_t f_thread_keys_increase(const f_array_length_t step, f_thread_keys_t * const keys);
+#endif // _di_f_thread_keys_increase_
+
+/**
+ * Resize the thread keys array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param keys
+ * The string keys array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_keys_increase_by_
+ extern f_status_t f_thread_keys_increase_by(const f_array_length_t amount, f_thread_keys_t * const keys);
+#endif // _di_f_thread_keys_increase_by_
+
+/**
+ * Resize the thread keys array.
+ *
+ * @param length
+ * The new size to use.
+ * @param keys
+ * The string keys array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_keys_resize_
+ extern f_status_t f_thread_keys_resize(const f_array_length_t length, f_thread_keys_t * const keys);
+#endif // _di_f_thread_keys_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_key_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "lock.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_locks_adjust_
+ f_status_t f_thread_locks_adjust(const f_array_length_t length, f_thread_locks_t * const locks) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!locks) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_locks_adjust(length, locks);
+ }
+#endif // _di_f_thread_locks_adjust_
+
+#ifndef _di_f_thread_locks_decimate_by_
+ f_status_t f_thread_locks_decimate_by(const f_array_length_t amount, f_thread_locks_t * const locks) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!locks) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (locks->size - amount > 0) {
+ return private_f_thread_locks_adjust(locks->size - amount, locks);
+ }
+
+ return private_f_thread_locks_adjust(0, locks);
+ }
+#endif // _di_f_thread_locks_decimate_by_
+
+#ifndef _di_f_thread_locks_decrease_by_
+ f_status_t f_thread_locks_decrease_by(const f_array_length_t amount, f_thread_locks_t * const locks) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!locks) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (locks->size - amount > 0) {
+ return private_f_thread_locks_resize(locks->size - amount, locks);
+ }
+
+ return private_f_thread_locks_resize(0, locks);
+ }
+#endif // _di_f_thread_locks_decrease_by_
+
+#ifndef _di_f_thread_locks_increase_
+ f_status_t f_thread_locks_increase(const f_array_length_t step, f_thread_locks_t * const locks) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!locks) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && locks->used + 1 > locks->size) {
+ f_array_length_t size = locks->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (locks->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_locks_resize(size, locks);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_locks_increase_
+
+#ifndef _di_f_thread_locks_increase_by_
+ f_status_t f_thread_locks_increase_by(const f_array_length_t amount, f_thread_locks_t * const locks) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!locks) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (locks->used + amount > locks->size) {
+ if (locks->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_locks_resize(locks->used + amount, locks);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_locks_increase_by_
+
+#ifndef _di_f_thread_locks_resize_
+ f_status_t f_thread_locks_resize(const f_array_length_t length, f_thread_locks_t * const locks) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!locks) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_locks_resize(length, locks);
+ }
+#endif // _di_f_thread_locks_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_lock_h
+#define _F_thread_lock_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_rwlock_t (read/write lock).
+ *
+ * This must be dynamically initialized using f_thread_lock_create().
+ * In some cases, they can be utilized statically, in which case only f_thread_lock_t_initialize is needed.
+ */
+#ifndef _di_f_thread_lock_t_
+ typedef pthread_rwlock_t f_thread_lock_t;
+
+ #define f_thread_lock_t_initialize PTHREAD_RWLOCK_INITIALIZER
+
+ #define macro_f_thread_lock_t_initialize(lock) lock
+
+ #define macro_f_thread_lock_t_delete_simple(lock) f_thread_lock_delete(&lock);
+#endif // _di_f_thread_lock_t_
+
+/**
+ * An array of thread locks.
+ *
+ * array: The array of f_thread_lock_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_locks_t_
+ typedef struct {
+ f_thread_lock_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_locks_t;
+
+ #define f_thread_locks_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_locks_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_locks_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_locks_t_resize(status, locks, length) macro_f_memory_structure_resize(status, locks, f_thread_lock_t, length)
+ #define macro_f_thread_locks_t_adjust(status, locks, length) macro_f_memory_structure_adjust(status, locks, f_thread_lock_t, length)
+
+ #define macro_f_thread_locks_t_delete_simple(locks) macro_f_memory_structure_delete_simple(locks, f_thread_lock_t)
+ #define macro_f_thread_locks_t_destroy_simple(locks) macro_f_memory_structure_destroy_simple(locks, f_thread_lock_t)
+
+ #define macro_f_thread_locks_t_increase(status, step, locks) macro_f_memory_structure_increase(status, step, locks, f_thread_lock_t)
+ #define macro_f_thread_locks_t_increase_by(status, locks, amount) macro_f_memory_structure_increase_by(status, locks, f_thread_lock_t, amount)
+ #define macro_f_thread_locks_t_decrease_by(status, locks, amount) macro_f_memory_structure_decrease_by(status, locks, f_thread_lock_t, amount)
+ #define macro_f_thread_locks_t_decimate_by(status, locks, amount) macro_f_memory_structure_decimate_by(status, locks, f_thread_lock_t, amount)
+#endif // _di_f_thread_locks_t_
+
+/**
+ * Resize the read/write locks array.
+ *
+ * @param length
+ * The new size to use.
+ * @param locks
+ * The string locks array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_locks_adjust_
+ extern f_status_t f_thread_locks_adjust(const f_array_length_t length, f_thread_locks_t * const locks);
+#endif // _di_f_thread_locks_adjust_
+
+/**
+ * Resize the read/write locks array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param locks
+ * The string locks array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_locks_decimate_by_
+ extern f_status_t f_thread_locks_decimate_by(const f_array_length_t amount, f_thread_locks_t * const locks);
+#endif // _di_f_thread_locks_decimate_by_
+
+/**
+ * Resize the read/write locks array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param locks
+ * The string locks array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_locks_decrease_by_
+ extern f_status_t f_thread_locks_decrease_by(const f_array_length_t amount, f_thread_locks_t * const locks);
+#endif // _di_f_thread_locks_decrease_by_
+
+/**
+ * Increase the size of the read/write array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param locks
+ * The string locks array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_locks_increase_
+ extern f_status_t f_thread_locks_increase(const f_array_length_t step, f_thread_locks_t * const locks);
+#endif // _di_f_thread_locks_increase_
+
+/**
+ * Resize the read/write locks array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param locks
+ * The string locks array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_locks_increase_by_
+ extern f_status_t f_thread_locks_increase_by(const f_array_length_t amount, f_thread_locks_t * const locks);
+#endif // _di_f_thread_locks_increase_by_
+
+/**
+ * Resize the read/write locks array.
+ *
+ * @param length
+ * The new size to use.
+ * @param locks
+ * The string locks array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_locks_resize_
+ extern f_status_t f_thread_locks_resize(const f_array_length_t length, f_thread_locks_t * const locks);
+#endif // _di_f_thread_locks_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_lock_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "lock_attribute.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_lock_attributes_adjust_
+ f_status_t f_thread_lock_attributes_adjust(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_lock_attributes_adjust(length, attributes);
+ }
+#endif // _di_f_thread_lock_attributes_adjust_
+
+#ifndef _di_f_thread_lock_attributes_decimate_by_
+ f_status_t f_thread_lock_attributes_decimate_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_lock_attributes_adjust(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_lock_attributes_adjust(0, attributes);
+ }
+#endif // _di_f_thread_lock_attributes_decimate_by_
+
+#ifndef _di_f_thread_lock_attributes_decrease_by_
+ f_status_t f_thread_lock_attributes_decrease_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_lock_attributes_resize(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_lock_attributes_resize(0, attributes);
+ }
+#endif // _di_f_thread_lock_attributes_decrease_by_
+
+#ifndef _di_f_thread_lock_attributes_increase_
+ f_status_t f_thread_lock_attributes_increase(const f_array_length_t step, f_thread_lock_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && attributes->used + 1 > attributes->size) {
+ f_array_length_t size = attributes->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (attributes->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_lock_attributes_resize(size, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_lock_attributes_increase_
+
+#ifndef _di_f_thread_lock_attributes_increase_by_
+ f_status_t f_thread_lock_attributes_increase_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->used + amount > attributes->size) {
+ if (attributes->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_lock_attributes_resize(attributes->used + amount, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_lock_attributes_increase_by_
+
+#ifndef _di_f_thread_lock_attributes_resize_
+ f_status_t f_thread_lock_attributes_resize(const f_array_length_t length, f_thread_lock_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_lock_attributes_resize(length, attributes);
+ }
+#endif // _di_f_thread_lock_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_lock_attribute_h
+#define _F_thread_lock_attribute_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_rwlockattr_t.
+ */
+#ifndef _di_f_thread_lock_attribute_t_
+ typedef pthread_rwlockattr_t f_thread_lock_attribute_t;
+
+ #define f_thread_lock_attribute_t_initialize { 0 }
+
+ #define macro_f_thread_lock_attribute_t_initialize(attribute) attribute
+
+ // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
+ #define macro_f_thread_lock_attribute_t_clear(attribute) attribute.__align = 0;
+
+ #define macro_f_thread_lock_attribute_t_delete_simple(attribute) f_thread_lock_attribute_delete(&attribute);
+#endif // _di_f_thread_lock_attribute_t_
+
+/**
+ * An array of read/write lock attributees.
+ *
+ * array: The array of f_thread_lock_attribute_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_lock_attributes_t_
+ typedef struct {
+ f_thread_lock_attribute_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_lock_attributes_t;
+
+ #define f_thread_lock_attributes_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_lock_attributes_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_lock_attributes_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_lock_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes)
+
+ #define macro_f_thread_lock_attributes_t_resize(status, attributes, length) status = f_thread_lock_attributes_resize(length, &attributes);
+ #define macro_f_thread_lock_attributes_t_adjust(status, attributes, length) status = f_thread_lock_attributes_adjust(length, &attributes);
+
+ #define macro_f_thread_lock_attributes_t_delete_simple(attributes) f_thread_lock_attributes_resize(0, &attributes);
+ #define macro_f_thread_lock_attributes_t_destroy_simple(attributes) f_thread_lock_attributes_adjust(0, &attributes);
+
+ #define macro_f_thread_lock_attributes_t_increase(status, step, attributes) status = f_thread_lock_attributes_increase(step, attributes);
+ #define macro_f_thread_lock_attributes_t_increase_by(status, attributes, amount) status = f_thread_lock_attributes_increase_by(amount, attributes);
+ #define macro_f_thread_lock_attributes_t_decrease_by(status, attributes, amount) status = f_thread_lock_attributes_decrease_by(amount, attributes);
+ #define macro_f_thread_lock_attributes_t_decimate_by(status, attributes, amount) status = f_thread_lock_attributes_decimate_by(amount, attributes);
+#endif // _di_f_thread_lock_attributes_t_
+
+/**
+ * Resize the thread attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_lock_attributes_adjust_
+ extern f_status_t f_thread_lock_attributes_adjust(const f_array_length_t length, f_thread_lock_attributes_t * const attributes);
+#endif // _di_f_thread_lock_attributes_adjust_
+
+/**
+ * Resize the thread attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_lock_attributes_decimate_by_
+ extern f_status_t f_thread_lock_attributes_decimate_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes);
+#endif // _di_f_thread_lock_attributes_decimate_by_
+
+/**
+ * Resize the thread attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_lock_attributes_decrease_by_
+ extern f_status_t f_thread_lock_attributes_decrease_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes);
+#endif // _di_f_thread_lock_attributes_decrease_by_
+
+/**
+ * Increase the size of the thread attributes array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_lock_attributes_increase_
+ extern f_status_t f_thread_lock_attributes_increase(const f_array_length_t step, f_thread_lock_attributes_t * const attributes);
+#endif // _di_f_thread_lock_attributes_increase_
+
+/**
+ * Resize the thread attributes array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param attributes
+ * The string attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_lock_attributes_increase_by_
+ extern f_status_t f_thread_lock_attributes_increase_by(const f_array_length_t amount, f_thread_lock_attributes_t * const attributes);
+#endif // _di_f_thread_lock_attributes_increase_by_
+
+/**
+ * Resize the thread attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The string attributes array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_lock_attributes_resize_
+ extern f_status_t f_thread_lock_attributes_resize(const f_array_length_t length, f_thread_lock_attributes_t * const attributes);
+#endif // _di_f_thread_lock_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_lock_attribute_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "mutex.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_mutexs_adjust_
+ f_status_t f_thread_mutexs_adjust(const f_array_length_t length, f_thread_mutexs_t * const mutexs) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!mutexs) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_mutexs_adjust(length, mutexs);
+ }
+#endif // _di_f_thread_mutexs_adjust_
+
+#ifndef _di_f_thread_mutexs_decimate_by_
+ f_status_t f_thread_mutexs_decimate_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!mutexs) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (mutexs->size - amount > 0) {
+ return private_f_thread_mutexs_adjust(mutexs->size - amount, mutexs);
+ }
+
+ return private_f_thread_mutexs_adjust(0, mutexs);
+ }
+#endif // _di_f_thread_mutexs_decimate_by_
+
+#ifndef _di_f_thread_mutexs_decrease_by_
+ f_status_t f_thread_mutexs_decrease_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!mutexs) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (mutexs->size - amount > 0) {
+ return private_f_thread_mutexs_resize(mutexs->size - amount, mutexs);
+ }
+
+ return private_f_thread_mutexs_resize(0, mutexs);
+ }
+#endif // _di_f_thread_mutexs_decrease_by_
+
+#ifndef _di_f_thread_mutexs_increase_
+ f_status_t f_thread_mutexs_increase(const f_array_length_t step, f_thread_mutexs_t * const mutexs) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!mutexs) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && mutexs->used + 1 > mutexs->size) {
+ f_array_length_t size = mutexs->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (mutexs->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_mutexs_resize(size, mutexs);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_mutexs_increase_
+
+#ifndef _di_f_thread_mutexs_increase_by_
+ f_status_t f_thread_mutexs_increase_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!mutexs) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (mutexs->used + amount > mutexs->size) {
+ if (mutexs->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_mutexs_resize(mutexs->used + amount, mutexs);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_mutexs_increase_by_
+
+#ifndef _di_f_thread_mutexs_resize_
+ f_status_t f_thread_mutexs_resize(const f_array_length_t length, f_thread_mutexs_t * const mutexs) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!mutexs) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_mutexs_resize(length, mutexs);
+ }
+#endif // _di_f_thread_mutexs_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_mutex_h
+#define _F_thread_mutex_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_mutex_t.
+ *
+ * This variable cannot be cleared by setting value to 0, so there is no clear macro provided.
+ *
+ * This must be dynamically initialized using f_thread_mutex_create().
+ * In some cases, they can be utilized statically, in which case only f_thread_mutex_t_initialize is needed.
+ */
+#ifndef _di_f_thread_mutex_t_
+ typedef pthread_mutex_t f_thread_mutex_t;
+
+ #define f_thread_mutex_t_initialize PTHREAD_MUTEX_INITIALIZER
+
+ #define macro_f_thread_mutex_t_initialize(mutex) mutex
+
+ #define macro_f_thread_mutex_t_delete_simple(mutex) f_thread_mutex_delete(&mutex);
+#endif // _di_f_thread_mutex_t_
+
+/**
+ * An array of thread mutexes.
+ *
+ * array: The array of f_thread_mutex_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_mutexs_t_
+ typedef struct {
+ f_thread_mutex_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_mutexs_t;
+
+ #define f_thread_mutexs_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_mutexs_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_mutexs_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_mutexs_t_clear(mutexs) macro_f_memory_structure_clear(mutexs)
+
+ #define macro_f_thread_mutexs_t_resize(status, mutexs, length) status = f_thread_mutexs_resize(length, &mutexs);
+ #define macro_f_thread_mutexs_t_adjust(status, mutexs, length) status = f_thread_mutexs_adjust(length, &mutexs);
+
+ #define macro_f_thread_mutexs_t_delete_simple(mutexs) f_thread_mutexs_resize(0, &mutexs);
+ #define macro_f_thread_mutexs_t_destroy_simple(mutexs) f_thread_mutexs_adjust(0, &mutexs);
+
+ #define macro_f_thread_mutexs_t_increase(status, step, mutexs) status = f_thread_mutexs_increase(step, mutexs);
+ #define macro_f_thread_mutexs_t_increase_by(status, mutexs, amount) status = f_thread_mutexs_increase_by(amount, mutexs);
+ #define macro_f_thread_mutexs_t_decrease_by(status, mutexs, amount) status = f_thread_mutexs_decrease_by(amount, mutexs);
+ #define macro_f_thread_mutexs_t_decimate_by(status, mutexs, amount) status = f_thread_mutexs_decimate_by(amount, mutexs);
+#endif // _di_f_thread_mutexs_t_
+
+/**
+ * Resize the thread mutexs array.
+ *
+ * @param length
+ * The new size to use.
+ * @param mutexs
+ * The string mutexs array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutexs_adjust_
+ extern f_status_t f_thread_mutexs_adjust(const f_array_length_t length, f_thread_mutexs_t * const mutexs);
+#endif // _di_f_thread_mutexs_adjust_
+
+/**
+ * Resize the thread mutexs array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param mutexs
+ * The string mutexs array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutexs_decimate_by_
+ extern f_status_t f_thread_mutexs_decimate_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs);
+#endif // _di_f_thread_mutexs_decimate_by_
+
+/**
+ * Resize the thread mutexs array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param mutexs
+ * The string mutexs array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutexs_decrease_by_
+ extern f_status_t f_thread_mutexs_decrease_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs);
+#endif // _di_f_thread_mutexs_decrease_by_
+
+/**
+ * Increase the size of the thread mutexs array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param mutexs
+ * The string mutexs array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutexs_increase_
+ extern f_status_t f_thread_mutexs_increase(const f_array_length_t step, f_thread_mutexs_t * const mutexs);
+#endif // _di_f_thread_mutexs_increase_
+
+/**
+ * Resize the thread mutexs array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param mutexs
+ * The string mutexs array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutexs_increase_by_
+ extern f_status_t f_thread_mutexs_increase_by(const f_array_length_t amount, f_thread_mutexs_t * const mutexs);
+#endif // _di_f_thread_mutexs_increase_by_
+
+/**
+ * Resize the thread mutexs array.
+ *
+ * @param length
+ * The new size to use.
+ * @param mutexs
+ * The string mutexs array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutexs_resize_
+ extern f_status_t f_thread_mutexs_resize(const f_array_length_t length, f_thread_mutexs_t * const mutexs);
+#endif // _di_f_thread_mutexs_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_mutex_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "mutex_attribute.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_mutex_attributes_adjust_
+ f_status_t f_thread_mutex_attributes_adjust(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_mutex_attributes_adjust(length, attributes);
+ }
+#endif // _di_f_thread_mutex_attributes_adjust_
+
+#ifndef _di_f_thread_mutex_attributes_decimate_by_
+ f_status_t f_thread_mutex_attributes_decimate_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_mutex_attributes_adjust(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_mutex_attributes_adjust(0, attributes);
+ }
+#endif // _di_f_thread_mutex_attributes_decimate_by_
+
+#ifndef _di_f_thread_mutex_attributes_decrease_by_
+ f_status_t f_thread_mutex_attributes_decrease_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->size - amount > 0) {
+ return private_f_thread_mutex_attributes_resize(attributes->size - amount, attributes);
+ }
+
+ return private_f_thread_mutex_attributes_resize(0, attributes);
+ }
+#endif // _di_f_thread_mutex_attributes_decrease_by_
+
+#ifndef _di_f_thread_mutex_attributes_increase_
+ f_status_t f_thread_mutex_attributes_increase(const f_array_length_t step, f_thread_mutex_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && attributes->used + 1 > attributes->size) {
+ f_array_length_t size = attributes->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (attributes->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_mutex_attributes_resize(size, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_mutex_attributes_increase_
+
+#ifndef _di_f_thread_mutex_attributes_increase_by_
+ f_status_t f_thread_mutex_attributes_increase_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (attributes->used + amount > attributes->size) {
+ if (attributes->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_mutex_attributes_resize(attributes->used + amount, attributes);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_mutex_attributes_increase_by_
+
+#ifndef _di_f_thread_mutex_attributes_resize_
+ f_status_t f_thread_mutex_attributes_resize(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!attributes) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_mutex_attributes_resize(length, attributes);
+ }
+#endif // _di_f_thread_mutex_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_mutex_attribute_h
+#define _F_thread_mutex_attribute_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_mutex_attribute_t.
+ */
+#ifndef _di_f_thread_mutex_attribute_t_
+ typedef pthread_mutexattr_t f_thread_mutex_attribute_t;
+
+ #define f_thread_mutex_attribute_t_initialize { 0 }
+
+ #define macro_f_thread_mutex_attribute_t_initialize(attribute) attribute
+
+ // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)).
+ #define macro_f_thread_mutex_attribute_t_clear(attribute) attribute.__align = 0;
+
+ #define macro_f_thread_mutex_attribute_t_delete_simple(attribute) f_thread_mutex_attribute_delete(&attribute);
+#endif // _di_f_thread_mutex_attribute_t_
+
+/**
+ * An array of thread mutex_attributees.
+ *
+ * array: The array of f_thread_mutex_attribute_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_mutex_attributes_t_
+ typedef struct {
+ f_thread_mutex_attribute_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_mutex_attributes_t;
+
+ #define f_thread_mutex_attributes_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_mutex_attributes_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_mutex_attributes_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_mutex_attributes_t_clear(attributes) macro_f_memory_structure_clear(attributes)
+
+ #define macro_f_thread_mutex_attributes_t_resize(status, attributes, length) status = f_thread_mutex_attributes_resize(length, &attributes);
+ #define macro_f_thread_mutex_attributes_t_adjust(status, attributes, length) status = f_thread_mutex_attributes_adjust(length, &attributes);
+
+ #define macro_f_thread_mutex_attributes_t_delete_simple(attributes) f_thread_mutex_attributes_resize(0, &attributes);
+ #define macro_f_thread_mutex_attributes_t_destroy_simple(attributes) f_thread_mutex_attributes_adjust(0, &attributes);
+
+ #define macro_f_thread_mutex_attributes_t_increase(status, step, attributes) status = f_thread_mutex_attributes_increase(step, attributes);
+ #define macro_f_thread_mutex_attributes_t_increase_by(status, attributes, amount) status = f_thread_mutex_attributes_increase_by(amount, attributes);
+ #define macro_f_thread_mutex_attributes_t_decrease_by(status, attributes, amount) status = f_thread_mutex_attributes_decrease_by(amount, attributes);
+ #define macro_f_thread_mutex_attributes_t_decimate_by(status, attributes, amount) status = f_thread_mutex_attributes_decimate_by(amount, attributes);
+#endif // _di_f_thread_mutex_attributes_t_
+
+/**
+ * Resize the thread attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The thread mutex attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutex_attributes_adjust_
+ extern f_status_t f_thread_mutex_attributes_adjust(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes);
+#endif // _di_f_thread_mutex_attributes_adjust_
+
+/**
+ * Resize the thread attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param attributes
+ * The thread mutex attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutex_attributes_decimate_by_
+ extern f_status_t f_thread_mutex_attributes_decimate_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes);
+#endif // _di_f_thread_mutex_attributes_decimate_by_
+
+/**
+ * Resize the thread attributes array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param attributes
+ * The thread mutex attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutex_attributes_decrease_by_
+ extern f_status_t f_thread_mutex_attributes_decrease_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes);
+#endif // _di_f_thread_mutex_attributes_decrease_by_
+
+/**
+ * Increase the size of the thread attributes array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param attributes
+ * The thread mutex attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutex_attributes_increase_
+ extern f_status_t f_thread_mutex_attributes_increase(const f_array_length_t step, f_thread_mutex_attributes_t * const attributes);
+#endif // _di_f_thread_mutex_attributes_increase_
+
+/**
+ * Resize the thread attributes array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param attributes
+ * The thread mutex attributes array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutex_attributes_increase_by_
+ extern f_status_t f_thread_mutex_attributes_increase_by(const f_array_length_t amount, f_thread_mutex_attributes_t * const attributes);
+#endif // _di_f_thread_mutex_attributes_increase_by_
+
+/**
+ * Resize the thread attributes array.
+ *
+ * @param length
+ * The new size to use.
+ * @param attributes
+ * The thread mutex attributes array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_mutex_attributes_resize_
+ extern f_status_t f_thread_mutex_attributes_resize(const f_array_length_t length, f_thread_mutex_attributes_t * const attributes);
+#endif // _di_f_thread_mutex_attributes_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_mutex_attribute_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "once.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_onces_adjust_
+ f_status_t f_thread_onces_adjust(const f_array_length_t length, f_thread_onces_t * const onces) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!onces) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_onces_adjust(length, onces);
+ }
+#endif // _di_f_thread_onces_adjust_
+
+#ifndef _di_f_thread_onces_decimate_by_
+ f_status_t f_thread_onces_decimate_by(const f_array_length_t amount, f_thread_onces_t * const onces) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!onces) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (onces->size - amount > 0) {
+ return private_f_thread_onces_adjust(onces->size - amount, onces);
+ }
+
+ return private_f_thread_onces_adjust(0, onces);
+ }
+#endif // _di_f_thread_onces_decimate_by_
+
+#ifndef _di_f_thread_onces_decrease_by_
+ f_status_t f_thread_onces_decrease_by(const f_array_length_t amount, f_thread_onces_t * const onces) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!onces) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (onces->size - amount > 0) {
+ return private_f_thread_onces_resize(onces->size - amount, onces);
+ }
+
+ return private_f_thread_onces_resize(0, onces);
+ }
+#endif // _di_f_thread_onces_decrease_by_
+
+#ifndef _di_f_thread_onces_increase_
+ f_status_t f_thread_onces_increase(const f_array_length_t step, f_thread_onces_t * const onces) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!onces) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && onces->used + 1 > onces->size) {
+ f_array_length_t size = onces->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (onces->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_onces_resize(size, onces);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_onces_increase_
+
+#ifndef _di_f_thread_onces_increase_by_
+ f_status_t f_thread_onces_increase_by(const f_array_length_t amount, f_thread_onces_t * const onces) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!onces) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (onces->used + amount > onces->size) {
+ if (onces->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_onces_resize(onces->used + amount, onces);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_onces_increase_by_
+
+#ifndef _di_f_thread_onces_resize_
+ f_status_t f_thread_onces_resize(const f_array_length_t length, f_thread_onces_t * const onces) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!onces) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_onces_resize(length, onces);
+ }
+#endif // _di_f_thread_onces_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_once_h
+#define _F_thread_once_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_once_t.
+ *
+ * There are no delete functions and therefore no delete macros.
+ */
+#ifndef _di_f_thread_once_t_
+ typedef pthread_once_t f_thread_once_t;
+
+ #define f_thread_once_t_initialize PTHREAD_ONCE_INIT
+
+ #define macro_f_thread_once_t_initialize(once) once
+#endif // _di_f_thread_once_t_
+
+/**
+ * An array of thread onces.
+ *
+ * array: The array of f_thread_once_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_onces_t_
+ typedef struct {
+ f_thread_once_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_onces_t;
+
+ #define f_thread_onces_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_onces_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_onces_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_onces_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_onces_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_onces_t_clear(onces) macro_f_memory_structure_clear(onces)
+
+ #define macro_f_thread_onces_t_resize(status, onces, length) status = f_thread_onces_resize(length, &onces);
+ #define macro_f_thread_onces_t_adjust(status, onces, length) status = f_thread_onces_adjust(length, &onces);
+
+ #define macro_f_thread_onces_t_delete_simple(onces) f_thread_onces_resize(0, &onces);
+ #define macro_f_thread_onces_t_destroy_simple(onces) f_thread_onces_adjust(0, &onces);
+
+ #define macro_f_thread_onces_t_increase(status, step, onces) status = f_thread_onces_increase(step, onces);
+ #define macro_f_thread_onces_t_increase_by(status, onces, amount) status = f_thread_onces_increase_by(amount, onces);
+ #define macro_f_thread_onces_t_decrease_by(status, onces, amount) status = f_thread_onces_decrease_by(amount, onces);
+ #define macro_f_thread_onces_t_decimate_by(status, onces, amount) status = f_thread_onces_decimate_by(amount, onces);
+#endif // _di_f_thread_onces_t_
+
+/**
+ * Resize the thread onces array.
+ *
+ * @param length
+ * The new size to use.
+ * @param onces
+ * The thread onces array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_onces_adjust_
+ extern f_status_t f_thread_onces_adjust(const f_array_length_t length, f_thread_onces_t * const onces);
+#endif // _di_f_thread_onces_adjust_
+
+/**
+ * Resize the thread onces array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param onces
+ * The thread onces array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_onces_decimate_by_
+ extern f_status_t f_thread_onces_decimate_by(const f_array_length_t amount, f_thread_onces_t * const onces);
+#endif // _di_f_thread_onces_decimate_by_
+
+/**
+ * Resize the thread onces array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param onces
+ * The thread onces array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_onces_decrease_by_
+ extern f_status_t f_thread_onces_decrease_by(const f_array_length_t amount, f_thread_onces_t * const onces);
+#endif // _di_f_thread_onces_decrease_by_
+
+/**
+ * Increase the size of the thread onces array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param onces
+ * The thread onces array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_onces_increase_
+ extern f_status_t f_thread_onces_increase(const f_array_length_t step, f_thread_onces_t * const onces);
+#endif // _di_f_thread_onces_increase_
+
+/**
+ * Resize the thread onces array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param onces
+ * The thread onces array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_onces_increase_by_
+ extern f_status_t f_thread_onces_increase_by(const f_array_length_t amount, f_thread_onces_t * const onces);
+#endif // _di_f_thread_onces_increase_by_
+
+/**
+ * Resize the thread onces array.
+ *
+ * @param length
+ * The new size to use.
+ * @param onces
+ * The thread onces array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_onces_resize_
+ extern f_status_t f_thread_onces_resize(const f_array_length_t length, f_thread_onces_t * const onces);
+#endif // _di_f_thread_onces_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_once_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "semaphore.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_semaphores_adjust_
+ f_status_t f_thread_semaphores_adjust(const f_array_length_t length, f_thread_semaphores_t * const semaphores) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!semaphores) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_semaphores_adjust(length, semaphores);
+ }
+#endif // _di_f_thread_semaphores_adjust_
+
+#ifndef _di_f_thread_semaphores_decimate_by_
+ f_status_t f_thread_semaphores_decimate_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!semaphores) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (semaphores->size - amount > 0) {
+ return private_f_thread_semaphores_adjust(semaphores->size - amount, semaphores);
+ }
+
+ return private_f_thread_semaphores_adjust(0, semaphores);
+ }
+#endif // _di_f_thread_semaphores_decimate_by_
+
+#ifndef _di_f_thread_semaphores_decrease_by_
+ f_status_t f_thread_semaphores_decrease_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!semaphores) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (semaphores->size - amount > 0) {
+ return private_f_thread_semaphores_resize(semaphores->size - amount, semaphores);
+ }
+
+ return private_f_thread_semaphores_resize(0, semaphores);
+ }
+#endif // _di_f_thread_semaphores_decrease_by_
+
+#ifndef _di_f_thread_semaphores_increase_
+ f_status_t f_thread_semaphores_increase(const f_array_length_t step, f_thread_semaphores_t * const semaphores) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!semaphores) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && semaphores->used + 1 > semaphores->size) {
+ f_array_length_t size = semaphores->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (semaphores->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_semaphores_resize(size, semaphores);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_semaphores_increase_
+
+#ifndef _di_f_thread_semaphores_increase_by_
+ f_status_t f_thread_semaphores_increase_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!semaphores) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (semaphores->used + amount > semaphores->size) {
+ if (semaphores->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_semaphores_resize(semaphores->used + amount, semaphores);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_semaphores_increase_by_
+
+#ifndef _di_f_thread_semaphores_resize_
+ f_status_t f_thread_semaphores_resize(const f_array_length_t length, f_thread_semaphores_t * const semaphores) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!semaphores) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_semaphores_resize(length, semaphores);
+ }
+#endif // _di_f_thread_semaphores_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_semaphore_h
+#define _F_thread_semaphore_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing sem_t.
+ *
+ * This variable cannot be cleared by setting value to 0, so there is no clear macro provided.
+ *
+ * This must be dynamically initialized using f_thread_semaphore_create().
+ */
+#ifndef _di_f_thread_semaphore_t_
+ typedef sem_t f_thread_semaphore_t;
+
+ #define f_thread_semaphore_t_initialize 0
+
+ #define macro_f_thread_semaphore_t_initialize(semaphore) semaphore
+
+ #define macro_f_thread_semaphore_t_delete_simple(semaphore) f_thread_semaphore_delete(&semaphore);
+#endif // _di_f_thread_semaphore_t_
+
+/**
+ * An array of thread semaphorees.
+ *
+ * array: The array of f_thread_semaphore_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_semaphores_t_
+ typedef struct {
+ f_thread_semaphore_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_semaphores_t;
+
+ #define f_thread_semaphores_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_semaphores_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_semaphores_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_semaphores_t_clear(semaphores) macro_f_memory_structure_clear(semaphores)
+
+ #define macro_f_thread_semaphores_t_resize(status, semaphores, length) status = f_thread_semaphores_resize(length, &semaphores);
+ #define macro_f_thread_semaphores_t_adjust(status, semaphores, length) status = f_thread_semaphores_adjust(length, &semaphores);
+
+ #define macro_f_thread_semaphores_t_delete_simple(semaphores) f_thread_semaphores_resize(0, &semaphores);
+ #define macro_f_thread_semaphores_t_destroy_simple(semaphores) f_thread_semaphores_adjust(0, &semaphores);
+
+ #define macro_f_thread_semaphores_t_increase(status, step, semaphores) status = f_thread_semaphores_increase(step, semaphores);
+ #define macro_f_thread_semaphores_t_increase_by(status, semaphores, amount) status = f_thread_semaphores_increase_by(amount, semaphores);
+ #define macro_f_thread_semaphores_t_decrease_by(status, semaphores, amount) status = f_thread_semaphores_decrease_by(amount, semaphores);
+ #define macro_f_thread_semaphores_t_decimate_by(status, semaphores, amount) status = f_thread_semaphores_decimate_by(amount, semaphores);
+#endif // _di_f_thread_semaphores_t_
+
+/**
+ * Resize the thread semaphores array.
+ *
+ * @param length
+ * The new size to use.
+ * @param semaphores
+ * The string semaphores array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_semaphores_adjust_
+ extern f_status_t f_thread_semaphores_adjust(const f_array_length_t length, f_thread_semaphores_t * const semaphores);
+#endif // _di_f_thread_semaphores_adjust_
+
+/**
+ * Resize the thread semaphores array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param semaphores
+ * The string semaphores array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_semaphores_decimate_by_
+ extern f_status_t f_thread_semaphores_decimate_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores);
+#endif // _di_f_thread_semaphores_decimate_by_
+
+/**
+ * Resize the thread semaphores array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param semaphores
+ * The string semaphores array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_semaphores_decrease_by_
+ extern f_status_t f_thread_semaphores_decrease_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores);
+#endif // _di_f_thread_semaphores_decrease_by_
+
+/**
+ * Increase the size of the thread semaphores array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param semaphores
+ * The string semaphores array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_semaphores_increase_
+ extern f_status_t f_thread_semaphores_increase(const f_array_length_t step, f_thread_semaphores_t * const semaphores);
+#endif // _di_f_thread_semaphores_increase_
+
+/**
+ * Resize the thread semaphores array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param semaphores
+ * The string semaphores array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_semaphores_increase_by_
+ extern f_status_t f_thread_semaphores_increase_by(const f_array_length_t amount, f_thread_semaphores_t * const semaphores);
+#endif // _di_f_thread_semaphores_increase_by_
+
+/**
+ * Resize the thread semaphores array.
+ *
+ * @param length
+ * The new size to use.
+ * @param semaphores
+ * The string semaphores array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_semaphores_resize_
+ extern f_status_t f_thread_semaphores_resize(const f_array_length_t length, f_thread_semaphores_t * const semaphores);
+#endif // _di_f_thread_semaphores_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_semaphore_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "set.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_sets_adjust_
+ f_status_t f_thread_sets_adjust(const f_array_length_t length, f_thread_sets_t * const sets) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!sets) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_sets_adjust(length, sets);
+ }
+#endif // _di_f_thread_sets_adjust_
+
+#ifndef _di_f_thread_sets_decimate_by_
+ f_status_t f_thread_sets_decimate_by(const f_array_length_t amount, f_thread_sets_t * const sets) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!sets) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (sets->size - amount > 0) {
+ return private_f_thread_sets_adjust(sets->size - amount, sets);
+ }
+
+ return private_f_thread_sets_adjust(0, sets);
+ }
+#endif // _di_f_thread_sets_decimate_by_
+
+#ifndef _di_f_thread_sets_decrease_by_
+ f_status_t f_thread_sets_decrease_by(const f_array_length_t amount, f_thread_sets_t * const sets) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!sets) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (sets->size - amount > 0) {
+ return private_f_thread_sets_resize(sets->size - amount, sets);
+ }
+
+ return private_f_thread_sets_resize(0, sets);
+ }
+#endif // _di_f_thread_sets_decrease_by_
+
+#ifndef _di_f_thread_sets_increase_
+ f_status_t f_thread_sets_increase(const f_array_length_t step, f_thread_sets_t * const sets) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!sets) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && sets->used + 1 > sets->size) {
+ f_array_length_t size = sets->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (sets->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_sets_resize(size, sets);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_sets_increase_
+
+#ifndef _di_f_thread_sets_increase_by_
+ f_status_t f_thread_sets_increase_by(const f_array_length_t amount, f_thread_sets_t * const sets) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!sets) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (sets->used + amount > sets->size) {
+ if (sets->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_sets_resize(sets->used + amount, sets);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_sets_increase_by_
+
+#ifndef _di_f_thread_sets_resize_
+ f_status_t f_thread_sets_resize(const f_array_length_t length, f_thread_sets_t * const sets) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!sets) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_sets_resize(length, sets);
+ }
+#endif // _di_f_thread_sets_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_set_h
+#define _F_thread_set_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A structure containing basic thread information.
+ *
+ * attribute: The thread attributes (which is a union).
+ * id: The thread identifier.
+ * result: The result of the thread on exit.
+ */
+#ifndef _di_f_thread_set_t_
+ typedef struct {
+ f_thread_attribute_t attribute;
+ f_thread_id_t id;
+ int result;
+ } f_thread_set_t;
+
+ #define f_thread_set_t_initialize { f_thread_attribute_t_initialize, f_thread_id_t_initialize, 0 }
+
+ #define macro_f_thread_set_t_initialize(attribute, id, result) { attribute, id, result }
+
+ #define macro_f_thread_set_t_clear(thread) \
+ macro_f_thread_attribute_t_clear(thread.attribute) \
+ macro_f_thread_id_t_clear(thread.id) \
+ result = 0;
+
+ #define macro_f_thread_set_t_delete_simple(set) macro_f_thread_attribute_t_delete_simple(set.attribute)
+#endif // _di_f_thread_set_t_
+
+/**
+ * An array of f_thread_set_t.
+ *
+ * array: The array of f_thread_set_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_sets_t_
+ typedef struct {
+ f_thread_set_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_sets_t;
+
+ #define f_thread_sets_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_sets_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_sets_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_sets_t_clear(sets) macro_f_memory_structure_clear(sets)
+
+ #define macro_f_thread_sets_t_resize(status, sets, length) status = f_thread_sets_resize(length, &sets);
+ #define macro_f_thread_sets_t_adjust(status, sets, length) status = f_thread_sets_adjust(length, &sets);
+
+ #define macro_f_thread_sets_t_delete_simple(sets) f_thread_sets_resize(0, &sets);
+ #define macro_f_thread_sets_t_destroy_simple(sets) f_thread_sets_adjust(0, &sets);
+
+ #define macro_f_thread_sets_t_increase(status, step, sets) status = f_thread_sets_increase(step, sets);
+ #define macro_f_thread_sets_t_increase_by(status, sets, amount) status = f_thread_sets_increase_by(amount, sets);
+ #define macro_f_thread_sets_t_decrease_by(status, sets, amount) status = f_thread_sets_decrease_by(amount, sets);
+ #define macro_f_thread_sets_t_decimate_by(status, sets, amount) status = f_thread_sets_decimate_by(amount, sets);
+#endif // _di_f_thread_sets_t_
+
+/**
+ * Resize the thread sets array.
+ *
+ * @param length
+ * The new size to use.
+ * @param sets
+ * The string sets array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_sets_adjust_
+ extern f_status_t f_thread_sets_adjust(const f_array_length_t length, f_thread_sets_t * const sets);
+#endif // _di_f_thread_sets_adjust_
+
+/**
+ * Resize the thread sets array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param sets
+ * The string sets array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_sets_decimate_by_
+ extern f_status_t f_thread_sets_decimate_by(const f_array_length_t amount, f_thread_sets_t * const sets);
+#endif // _di_f_thread_sets_decimate_by_
+
+/**
+ * Resize the thread sets array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param sets
+ * The string sets array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_sets_decrease_by_
+ extern f_status_t f_thread_sets_decrease_by(const f_array_length_t amount, f_thread_sets_t * const sets);
+#endif // _di_f_thread_sets_decrease_by_
+
+/**
+ * Increase the size of the thread sets array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param sets
+ * The string sets array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_sets_increase_
+ extern f_status_t f_thread_sets_increase(const f_array_length_t step, f_thread_sets_t * const sets);
+#endif // _di_f_thread_sets_increase_
+
+/**
+ * Resize the thread sets array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param sets
+ * The string sets array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_sets_increase_by_
+ extern f_status_t f_thread_sets_increase_by(const f_array_length_t amount, f_thread_sets_t * const sets);
+#endif // _di_f_thread_sets_increase_by_
+
+/**
+ * Resize the thread sets array.
+ *
+ * @param length
+ * The new size to use.
+ * @param sets
+ * The string sets array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_sets_resize_
+ extern f_status_t f_thread_sets_resize(const f_array_length_t length, f_thread_sets_t * const sets);
+#endif // _di_f_thread_sets_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_set_h
--- /dev/null
+#include "../thread.h"
+#include "../private-thread.h"
+#include "spin.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_f_thread_spins_adjust_
+ f_status_t f_thread_spins_adjust(const f_array_length_t length, f_thread_spins_t * const spins) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!spins) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_spins_adjust(length, spins);
+ }
+#endif // _di_f_thread_spins_adjust_
+
+#ifndef _di_f_thread_spins_decimate_by_
+ f_status_t f_thread_spins_decimate_by(const f_array_length_t amount, f_thread_spins_t * const spins) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!spins) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (spins->size - amount > 0) {
+ return private_f_thread_spins_adjust(spins->size - amount, spins);
+ }
+
+ return private_f_thread_spins_adjust(0, spins);
+ }
+#endif // _di_f_thread_spins_decimate_by_
+
+#ifndef _di_f_thread_spins_decrease_by_
+ f_status_t f_thread_spins_decrease_by(const f_array_length_t amount, f_thread_spins_t * const spins) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!spins) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (spins->size - amount > 0) {
+ return private_f_thread_spins_resize(spins->size - amount, spins);
+ }
+
+ return private_f_thread_spins_resize(0, spins);
+ }
+#endif // _di_f_thread_spins_decrease_by_
+
+#ifndef _di_f_thread_spins_increase_
+ f_status_t f_thread_spins_increase(const f_array_length_t step, f_thread_spins_t * const spins) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!spins) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (step && spins->used + 1 > spins->size) {
+ f_array_length_t size = spins->used + step;
+
+ if (size > F_array_length_t_size_d) {
+ if (spins->used + 1 > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ size = F_array_length_t_size_d;
+ }
+
+ return private_f_thread_spins_resize(size, spins);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_spins_increase_
+
+#ifndef _di_f_thread_spins_increase_by_
+ f_status_t f_thread_spins_increase_by(const f_array_length_t amount, f_thread_spins_t * const spins) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!spins) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ if (!amount) return F_data_not;
+
+ if (spins->used + amount > spins->size) {
+ if (spins->used + amount > F_array_length_t_size_d) {
+ return F_status_set_error(F_array_too_large);
+ }
+
+ return private_f_thread_spins_resize(spins->used + amount, spins);
+ }
+
+ return F_data_not;
+ }
+#endif // _di_f_thread_spins_increase_by_
+
+#ifndef _di_f_thread_spins_resize_
+ f_status_t f_thread_spins_resize(const f_array_length_t length, f_thread_spins_t * const spins) {
+ #ifndef _di_level_0_parameter_checking_
+ if (!spins) return F_status_set_error(F_parameter);
+ #endif // _di_level_0_parameter_checking_
+
+ return private_f_thread_spins_resize(length, spins);
+ }
+#endif // _di_f_thread_spins_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
--- /dev/null
+/**
+ * FLL - Level 0
+ *
+ * Project: Thread
+ * API Version: 0.5
+ * Licenses: lgpl-2.1-or-later
+ *
+ * Defines common data to be used for/by POSIX thread related functionality.
+ *
+ * This is auto-included by thread.h and should not need to be explicitly included.
+ */
+#ifndef _F_thread_spin_h
+#define _F_thread_spin_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A typedef representing pthread_spinlock_t.
+ *
+ * Note: There appears to be no pthread init macro for spinlock, so initialize manually similarly to how the other inits work.
+ */
+#ifndef _di_f_thread_spin_t_
+ typedef pthread_spinlock_t f_thread_spin_t;
+
+ #define f_thread_spin_t_initialize ((pthread_spinlock_t) 0xFFFFFFFF)
+
+ #define macro_f_thread_spin_t_initialize(spin) spin
+
+ #define macro_f_thread_spin_t_delete_simple(spin) f_thread_spin_delete(&spin);
+#endif // _di_f_thread_spin_t_
+
+/**
+ * An array of thread spins.
+ *
+ * array: The array of f_thread_spin_t.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
+ */
+#ifndef _di_f_thread_spins_t_
+ typedef struct {
+ f_thread_spin_t *array;
+
+ f_array_length_t size;
+ f_array_length_t used;
+ } f_thread_spins_t;
+
+ #define f_thread_spins_t_initialize { 0, 0, 0 }
+
+ #define macro_f_thread_spins_t_initialize(array, size, used) { array, size, used }
+ #define macro_f_thread_spins_t_initialize2(array, length) { array, length, length }
+
+ #define macro_f_thread_spins_t_clear(spins) macro_f_memory_structure_clear(spins)
+
+ #define macro_f_thread_spins_t_resize(status, spins, length) status = f_thread_spins_resize(length, &spins);
+ #define macro_f_thread_spins_t_adjust(status, spins, length) status = f_thread_spins_adjust(length, &spins);
+
+ #define macro_f_thread_spins_t_delete_simple(spins) f_thread_spins_resize(0, &spins);
+ #define macro_f_thread_spins_t_destroy_simple(spins) f_thread_spins_adjust(0, &spins);
+
+ #define macro_f_thread_spins_t_increase(status, step, spins) status = f_thread_spins_increase(step, spins);
+ #define macro_f_thread_spins_t_increase_by(status, spins, amount) status = f_thread_spins_increase_by(amount, spins);
+ #define macro_f_thread_spins_t_decrease_by(status, spins, amount) status = f_thread_spins_decrease_by(amount, spins);
+ #define macro_f_thread_spins_t_decimate_by(status, spins, amount) status = f_thread_spins_decimate_by(amount, spins);
+#endif // _di_f_thread_spins_t_
+
+/**
+ * Resize the thread spin locks array.
+ *
+ * @param length
+ * The new size to use.
+ * @param spins
+ * The string spins array to resize.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_spins_adjust_
+ extern f_status_t f_thread_spins_adjust(const f_array_length_t length, f_thread_spins_t * const spins);
+#endif // _di_f_thread_spins_adjust_
+
+/**
+ * Resize the thread spin locks array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decimate the size by.
+ * @param spins
+ * The string spins array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_spins_decimate_by_
+ extern f_status_t f_thread_spins_decimate_by(const f_array_length_t amount, f_thread_spins_t * const spins);
+#endif // _di_f_thread_spins_decimate_by_
+
+/**
+ * Resize the thread spin locks array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ * A positive number representing how much to decrease the size by.
+ * @param spins
+ * The string spins array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not if amount is 0.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_spins_decrease_by_
+ extern f_status_t f_thread_spins_decrease_by(const f_array_length_t amount, f_thread_spins_t * const spins);
+#endif // _di_f_thread_spins_decrease_by_
+
+/**
+ * Increase the size of the thread spin locks array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ * The allocation step to use.
+ * Must be greater than 0.
+ * @param spins
+ * The string spins array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + 1 <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_spins_increase_
+ extern f_status_t f_thread_spins_increase(const f_array_length_t step, f_thread_spins_t * const spins);
+#endif // _di_f_thread_spins_increase_
+
+/**
+ * Resize the thread spin locks array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d).
+ * If already set to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ * A positive number representing how much to increase the size by.
+ * @param spins
+ * The string spins array to resize.
+ *
+ * @return
+ * F_none on success.
+ * F_data_not on success, but there is no reason to increase size (used + amount <= size).
+ *
+ * F_array_too_large (with error bit) if the new array length is too large.
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_spins_increase_by_
+ extern f_status_t f_thread_spins_increase_by(const f_array_length_t amount, f_thread_spins_t * const spins);
+#endif // _di_f_thread_spins_increase_by_
+
+/**
+ * Resize the thread spin locks array.
+ *
+ * @param length
+ * The new size to use.
+ * @param spins
+ * The string spins array to adjust.
+ *
+ * @return
+ * F_none on success.
+ *
+ * F_memory_not (with error bit) on out of memory.
+ * F_parameter (with error bit) if a parameter is invalid.
+ */
+#ifndef _di_f_thread_spins_resize_
+ extern f_status_t f_thread_spins_resize(const f_array_length_t length, f_thread_spins_t * const spins);
+#endif // _di_f_thread_spins_resize_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_thread_spin_h
build_libraries -pthread -lc
build_libraries-individual -lf_memory -lf_string
-build_sources_library thread.c private-thread.c
+build_sources_library thread.c private-thread.c thread/attribute.c thread/barrier.c thread/barrier_attribute.c thread/condition.c thread/condition_attribute.c thread/id.c thread/key.c thread/lock.c thread/lock_attribute.c thread/mutex.c thread/mutex_attribute.c thread/once.c thread/semaphore.c thread/set.c thread/spin.c
-build_sources_headers thread.h thread/common.h
+build_sources_headers thread.h thread/attribute.h thread/barrier.h thread/barrier_attribute.h thread/condition.h thread/condition_attribute.h thread/id.h thread/key.h thread/lock.h thread/lock_attribute.h thread/mutex.h thread/mutex_attribute.h thread/once.h thread/semaphore.h thread/set.h thread/spin.h
build_script yes
build_shared yes