From 0c03438676f4af05576120b333c7093d51e804a5 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 20 Jul 2023 22:10:39 -0500 Subject: [PATCH] Progress: Continue memory array related changes. This converts a lot of the projects to use the f_memory_array_*() functions. Break the f_thread private functions into their own files. --- build/level_0/settings | 3 +- build/monolithic/settings | 3 +- build/stand_alone/fake.config.h | 4 +- build/stand_alone/fake.settings | 3 +- level_0/f_fss/c/fss/nest.c | 6 +- level_0/f_fss/c/fss/private-item.c | 8 +- level_0/f_fss/c/fss/private-item.h | 18 +- level_0/f_fss/c/fss/private-named.c | 4 +- level_0/f_fss/c/fss/private-named.h | 6 +- level_0/f_fss/c/fss/private-nest.c | 4 +- level_0/f_fss/c/fss/private-nest.h | 6 +- level_0/f_fss/c/fss/private-set.c | 4 +- level_0/f_fss/c/fss/private-set.h | 6 +- level_0/f_fss/c/fss/private-set_quote.c | 4 +- level_0/f_fss/c/fss/private-set_quote.h | 6 +- level_0/f_fss/c/fss/simple_packet.c | 2 +- level_0/f_fss/c/fss/simple_packet.h | 4 +- level_0/f_limit/c/limit/set.c | 2 +- level_0/f_limit/c/limit/set.h | 4 +- level_0/f_limit/c/limit/value.c | 2 +- level_0/f_limit/c/limit/value.h | 4 +- level_0/f_socket/c/socket/private-socket.c | 16 +- level_0/f_socket/c/socket/private-socket.h | 28 +- level_0/f_socket/c/socket/socket.c | 7 +- level_0/f_string/c/private-string.c | 41 +- level_0/f_string/c/string.c | 54 +- level_0/f_string/c/string/dynamic.c | 92 +- level_0/f_string/c/string/dynamics.c | 16 +- level_0/f_string/c/string/dynamicss.c | 16 +- level_0/f_string/c/string/map_multis.c | 16 +- level_0/f_string/c/string/map_multiss.c | 16 +- level_0/f_string/c/string/maps.c | 16 +- level_0/f_string/c/string/mapss.c | 16 +- level_0/f_string/c/string/private-dynamic.c | 47 - level_0/f_string/c/string/private-dynamic.h | 126 --- level_0/f_string/c/string/private-dynamics.c | 30 +- level_0/f_string/c/string/private-dynamics.h | 8 +- level_0/f_string/c/string/private-dynamicss.c | 26 +- level_0/f_string/c/string/private-dynamicss.h | 4 +- level_0/f_string/c/string/private-map_multis.c | 34 +- level_0/f_string/c/string/private-map_multis.h | 2 +- level_0/f_string/c/string/private-map_multiss.c | 30 +- level_0/f_string/c/string/private-maps.c | 38 +- level_0/f_string/c/string/private-maps.h | 4 +- level_0/f_string/c/string/private-mapss.c | 30 +- level_0/f_string/c/string/private-mapss.h | 2 + level_0/f_string/c/string/private-quantitys.c | 44 +- level_0/f_string/c/string/private-quantitys.h | 51 +- level_0/f_string/c/string/private-quantityss.c | 34 +- level_0/f_string/c/string/private-quantityss.h | 2 + level_0/f_string/c/string/private-ranges.c | 42 +- level_0/f_string/c/string/private-ranges.h | 58 -- level_0/f_string/c/string/private-rangess.c | 34 +- level_0/f_string/c/string/private-triples.c | 42 +- level_0/f_string/c/string/private-triples.h | 2 +- level_0/f_string/c/string/private-tripless.c | 30 +- level_0/f_string/c/string/quantitys.c | 51 +- level_0/f_string/c/string/quantityss.c | 16 +- level_0/f_string/c/string/ranges.c | 56 +- level_0/f_string/c/string/rangess.c | 16 +- level_0/f_string/c/string/triples.c | 16 +- level_0/f_string/c/string/tripless.c | 16 +- level_0/f_thread/c/private-thread.c | 896 ---------------- level_0/f_thread/c/private-thread.h | 1094 -------------------- level_0/f_thread/c/thread.c | 12 +- level_0/f_thread/c/thread/attribute.c | 14 +- level_0/f_thread/c/thread/barrier.c | 2 +- level_0/f_thread/c/thread/barrier_attribute.c | 2 +- level_0/f_thread/c/thread/condition.c | 2 +- level_0/f_thread/c/thread/condition_attribute.c | 2 +- level_0/f_thread/c/thread/id.c | 2 +- level_0/f_thread/c/thread/key.c | 2 +- level_0/f_thread/c/thread/lock.c | 2 +- level_0/f_thread/c/thread/lock_attribute.c | 2 +- level_0/f_thread/c/thread/mutex.c | 2 +- level_0/f_thread/c/thread/mutex_attribute.c | 2 +- level_0/f_thread/c/thread/once.c | 2 +- level_0/f_thread/c/thread/private-attribute.c | 51 + level_0/f_thread/c/thread/private-attribute.h | 341 ++++++ level_0/f_thread/c/thread/private-barrier.c | 58 ++ level_0/f_thread/c/thread/private-barrier.h | 100 ++ .../f_thread/c/thread/private-barrier_attribute.c | 51 + .../f_thread/c/thread/private-barrier_attribute.h | 100 ++ level_0/f_thread/c/thread/private-condition.c | 56 + level_0/f_thread/c/thread/private-condition.h | 101 ++ .../c/thread/private-condition_attribute.c | 56 + .../c/thread/private-condition_attribute.h | 100 ++ level_0/f_thread/c/thread/private-id.c | 28 + level_0/f_thread/c/thread/private-id.h | 69 ++ level_0/f_thread/c/thread/private-key.c | 51 + level_0/f_thread/c/thread/private-key.h | 98 ++ level_0/f_thread/c/thread/private-lock.c | 56 + level_0/f_thread/c/thread/private-lock.h | 99 ++ level_0/f_thread/c/thread/private-lock_attribute.c | 56 + level_0/f_thread/c/thread/private-lock_attribute.h | 98 ++ level_0/f_thread/c/thread/private-mutex.c | 56 + level_0/f_thread/c/thread/private-mutex.h | 99 ++ .../f_thread/c/thread/private-mutex_attribute.c | 56 + .../f_thread/c/thread/private-mutex_attribute.h | 98 ++ level_0/f_thread/c/thread/private-once.c | 28 + level_0/f_thread/c/thread/private-once.h | 69 ++ level_0/f_thread/c/thread/private-semaphore.c | 55 + level_0/f_thread/c/thread/private-semaphore.h | 98 ++ level_0/f_thread/c/thread/private-set.c | 41 + level_0/f_thread/c/thread/private-set.h | 69 ++ level_0/f_thread/c/thread/private-spin.c | 56 + level_0/f_thread/c/thread/private-spin.h | 98 ++ level_0/f_thread/c/thread/semaphore.c | 18 +- level_0/f_thread/c/thread/set.c | 18 +- level_0/f_thread/c/thread/spin.c | 14 +- level_0/f_thread/data/build/settings | 3 +- level_0/f_thread/data/build/settings-mocks | 3 +- 112 files changed, 2660 insertions(+), 3154 deletions(-) delete mode 100644 level_0/f_thread/c/private-thread.c delete mode 100644 level_0/f_thread/c/private-thread.h create mode 100644 level_0/f_thread/c/thread/private-attribute.c create mode 100644 level_0/f_thread/c/thread/private-attribute.h create mode 100644 level_0/f_thread/c/thread/private-barrier.c create mode 100644 level_0/f_thread/c/thread/private-barrier.h create mode 100644 level_0/f_thread/c/thread/private-barrier_attribute.c create mode 100644 level_0/f_thread/c/thread/private-barrier_attribute.h create mode 100644 level_0/f_thread/c/thread/private-condition.c create mode 100644 level_0/f_thread/c/thread/private-condition.h create mode 100644 level_0/f_thread/c/thread/private-condition_attribute.c create mode 100644 level_0/f_thread/c/thread/private-condition_attribute.h create mode 100644 level_0/f_thread/c/thread/private-id.c create mode 100644 level_0/f_thread/c/thread/private-id.h create mode 100644 level_0/f_thread/c/thread/private-key.c create mode 100644 level_0/f_thread/c/thread/private-key.h create mode 100644 level_0/f_thread/c/thread/private-lock.c create mode 100644 level_0/f_thread/c/thread/private-lock.h create mode 100644 level_0/f_thread/c/thread/private-lock_attribute.c create mode 100644 level_0/f_thread/c/thread/private-lock_attribute.h create mode 100644 level_0/f_thread/c/thread/private-mutex.c create mode 100644 level_0/f_thread/c/thread/private-mutex.h create mode 100644 level_0/f_thread/c/thread/private-mutex_attribute.c create mode 100644 level_0/f_thread/c/thread/private-mutex_attribute.h create mode 100644 level_0/f_thread/c/thread/private-once.c create mode 100644 level_0/f_thread/c/thread/private-once.h create mode 100644 level_0/f_thread/c/thread/private-semaphore.c create mode 100644 level_0/f_thread/c/thread/private-semaphore.h create mode 100644 level_0/f_thread/c/thread/private-set.c create mode 100644 level_0/f_thread/c/thread/private-set.h create mode 100644 level_0/f_thread/c/thread/private-spin.c create mode 100644 level_0/f_thread/c/thread/private-spin.h diff --git a/build/level_0/settings b/build/level_0/settings index 520533c..38effe0 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -91,7 +91,8 @@ build_sources_library utf/private-map_multis.c utf/private-map_multiss.c build_sources_library utf/private-string.c build_sources_library utf/private-triples.c utf/private-tripless.c -build_sources_library-thread 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_library-thread 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_library-thread thread/private-attribute.c thread/private-barrier.c thread/private-barrier_attribute.c thread/private-condition.c thread/private-condition_attribute.c thread/private-id.c thread/private-key.c thread/private-lock.c thread/private-lock_attribute.c thread/private-mutex.c thread/private-mutex_attribute.c thread/private-once.c thread/private-semaphore.c thread/private-set.c thread/private-spin.c build_sources_headers account.h account/accounts.h account/common.h build_sources_headers capability.h capability/common.h diff --git a/build/monolithic/settings b/build/monolithic/settings index fef20f6..ae95a17 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -113,7 +113,8 @@ build_sources_library level_2/iki.c level_2/private-iki.c build_sources_library level_2/print.c build_sources_library level_2/program.c level_2/program/common.c level_2/program/print.c level_2/private-program.c -build_sources_library-thread 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_library-thread level_0/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_library-thread level_0/thread/private-attribute.c level_0/thread/private-barrier.c level_0/thread/private-barrier_attribute.c level_0/thread/private-condition.c level_0/thread/private-condition_attribute.c level_0/thread/private-id.c level_0/thread/private-key.c level_0/thread/private-lock.c level_0/thread/private-lock_attribute.c level_0/thread/private-mutex.c level_0/thread/private-mutex_attribute.c level_0/thread/private-once.c level_0/thread/private-semaphore.c level_0/thread/private-set.c level_0/thread/private-spin.c build_sources_headers level_0/account.h level_0/account/accounts.h level_0/account/common.h build_sources_headers level_0/capability.h level_0/capability/common.h diff --git a/build/stand_alone/fake.config.h b/build/stand_alone/fake.config.h index 52bea47..4637fa3 100644 --- a/build/stand_alone/fake.config.h +++ b/build/stand_alone/fake.config.h @@ -1177,8 +1177,8 @@ #define _di_f_memory_array_adjust_ #define _di_f_memory_array_decimate_by_ #define _di_f_memory_array_decrease_by_ -#define _di_f_memory_array_increase_ -#define _di_f_memory_array_increase_by_ +//#define _di_f_memory_array_increase_ +//#define _di_f_memory_array_increase_by_ //#define _di_f_memory_array_resize_ //#define _di_f_memory_default_d_ //#define _di_f_memory_delete_ diff --git a/build/stand_alone/fake.settings b/build/stand_alone/fake.settings index 5aff6fe..6eb23f9 100644 --- a/build/stand_alone/fake.settings +++ b/build/stand_alone/fake.settings @@ -62,7 +62,8 @@ build_sources_program fll/level_0/utf.c fll/level_0/private-utf.c fll/level_0/pr build_sources_program fll/level_0/utf/common.c fll/level_0/utf/convert.c fll/level_0/utf/dynamic.c fll/level_0/utf/dynamics.c fll/level_0/utf/dynamicss.c fll/level_0/utf/is.c fll/level_0/utf/is_character.c fll/level_0/utf/map.c fll/level_0/utf/maps.c fll/level_0/utf/mapss.c fll/level_0/utf/map_multi.c fll/level_0/utf/map_multis.c fll/level_0/utf/map_multiss.c fll/level_0/utf/static.c fll/level_0/utf/statics.c fll/level_0/utf/staticss.c fll/level_0/utf/string.c fll/level_0/utf/triple.c fll/level_0/utf/triples.c fll/level_0/utf/tripless.c build_sources_program fll/level_0/utf/private-dynamic.c fll/level_0/utf/private-dynamics.c fll/level_0/utf/private-dynamicss.c fll/level_0/utf/private-maps.c fll/level_0/utf/private-mapss.c fll/level_0/utf/private-map_multis.c fll/level_0/utf/private-map_multiss.c fll/level_0/utf/private-string.c fll/level_0/utf/private-triples.c fll/level_0/utf/private-tripless.c -build_sources_program-thread fll/level_0/thread.c fll/level_0/private-thread.c fll/level_0/thread/attribute.c fll/level_0/thread/barrier.c fll/level_0/thread/barrier_attribute.c fll/level_0/thread/condition.c fll/level_0/thread/condition_attribute.c fll/level_0/thread/id.c fll/level_0/thread/key.c fll/level_0/thread/lock.c fll/level_0/thread/lock_attribute.c fll/level_0/thread/mutex.c fll/level_0/thread/mutex_attribute.c fll/level_0/thread/once.c fll/level_0/thread/semaphore.c fll/level_0/thread/set.c fll/level_0/thread/spin.c +build_sources_program-thread fll/level_0/thread.c fll/level_0/thread/attribute.c fll/level_0/thread/barrier.c fll/level_0/thread/barrier_attribute.c fll/level_0/thread/condition.c fll/level_0/thread/condition_attribute.c fll/level_0/thread/id.c fll/level_0/thread/key.c fll/level_0/thread/lock.c fll/level_0/thread/lock_attribute.c fll/level_0/thread/mutex.c fll/level_0/thread/mutex_attribute.c fll/level_0/thread/once.c fll/level_0/thread/semaphore.c fll/level_0/thread/set.c fll/level_0/thread/spin.c +build_sources_program-thread fll/level_0/thread/private-attribute.c fll/level_0/thread/private-barrier.c fll/level_0/thread/private-barrier_attribute.c fll/level_0/thread/private-condition.c fll/level_0/thread/private-condition_attribute.c fll/level_0/thread/private-id.c fll/level_0/thread/private-key.c fll/level_0/thread/private-lock.c fll/level_0/thread/private-lock_attribute.c fll/level_0/thread/private-mutex.c fll/level_0/thread/private-mutex_attribute.c fll/level_0/thread/private-once.c fll/level_0/thread/private-semaphore.c fll/level_0/thread/private-set.c fll/level_0/thread/private-spin.c build_sources_program fll/level_1/control_group.c build_sources_program fll/level_1/conversion.c fll/level_1/private-conversion.c fll/level_1/conversion/common.c diff --git a/level_0/f_fss/c/fss/nest.c b/level_0/f_fss/c/fss/nest.c index 94f2085..0741aca 100644 --- a/level_0/f_fss/c/fss/nest.c +++ b/level_0/f_fss/c/fss/nest.c @@ -113,9 +113,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (nests->size > amount) return private_f_fss_nests_adjust(nests->size - amount, nests); - return private_f_fss_nests_adjust(0, nests); + return private_f_fss_nests_adjust((nests->size > amount) ? nests->size - amount : 0, nests); } #endif // _di_f_fss_nests_decimate_by_ @@ -126,9 +125,8 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!amount) return F_data_not; - if (nests->size > amount) return private_f_fss_nests_resize(nests->size - amount, nests); - return private_f_fss_nests_resize(0, nests); + return private_f_fss_nests_resize((nests->size > amount) ? nests->size - amount : 0, nests); } #endif // _di_f_fss_nests_decrease_by_ diff --git a/level_0/f_fss/c/fss/private-item.c b/level_0/f_fss/c/fss/private-item.c index ab78342..023da0a 100644 --- a/level_0/f_fss/c/fss/private-item.c +++ b/level_0/f_fss/c/fss/private-item.c @@ -5,7 +5,7 @@ extern "C" { #endif -#if !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) +#if !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) || !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) f_status_t private_f_fss_items_adjust(const f_number_unsigned_t length, f_fss_items_t * const items) { f_status_t status = F_none; @@ -18,9 +18,9 @@ extern "C" { return f_memory_array_adjust(length, sizeof(f_fss_item_t), (void **) &items->array, &items->used, &items->size); } -#endif // !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) +#endif // !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) || !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) -#if !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_increase_) || !defined(_di_f_fss_items_increase_by_) || !defined(_di_f_fss_items_resize_) +#if !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) || !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) f_status_t private_f_fss_items_resize(const f_number_unsigned_t length, f_fss_items_t * const items) { f_status_t status = F_none; @@ -33,7 +33,7 @@ extern "C" { return f_memory_array_resize(length, sizeof(f_fss_item_t), (void **) &items->array, &items->used, &items->size); } -#endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_increase_) || !defined(_di_f_fss_items_increase_by_) || !defined(_di_f_fss_items_resize_) +#endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) || !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-item.h b/level_0/f_fss/c/fss/private-item.h index 2435605..6e46999 100644 --- a/level_0/f_fss/c/fss/private-item.h +++ b/level_0/f_fss/c/fss/private-item.h @@ -35,10 +35,15 @@ extern "C" { * * @see f_memory_array_adjust() * @see f_string_dynamic_adjust() + * + * @see f_fss_items_adjust() + * @see f_fss_items_decimate_by() + * @see f_fss_nest_adjust() + * @see f_fss_nest_decimate_by() */ -#if !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) +#if !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) || !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) extern f_status_t private_f_fss_items_adjust(const f_number_unsigned_t length, f_fss_items_t * const items) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) +#endif // !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) || !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) /** * Private implementation for resizing. @@ -60,10 +65,15 @@ extern "C" { * * @see f_memory_array_resize() * @see f_string_dynamic_resize() + * + * @see f_fss_items_decrease_by() + * @see f_fss_items_resize() + * @see f_fss_nest_decrease_by() + * @see f_fss_nest_resize() */ -#if !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) +#if !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) || !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) extern f_status_t private_f_fss_items_resize(const f_number_unsigned_t length, f_fss_items_t * const items) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) +#endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_resize_) || !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-named.c b/level_0/f_fss/c/fss/private-named.c index bfa04a3..2f20422 100644 --- a/level_0/f_fss/c/fss/private-named.c +++ b/level_0/f_fss/c/fss/private-named.c @@ -21,7 +21,7 @@ extern "C" { } #endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) +#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_named_increase_) || !defined(_di_f_fss_named_increase_by_) || !defined(_di_f_fss_nameds_resize_) f_status_t private_f_fss_named_resize(const f_number_unsigned_t length, f_fss_named_t * const named) { f_status_t status = f_string_ranges_resize(length, &named->objects); @@ -35,7 +35,7 @@ extern "C" { return F_none; } -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) +#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_named_increase_) || !defined(_di_f_fss_named_increase_by_) || !defined(_di_f_fss_nameds_resize_) #if !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) f_status_t private_f_fss_nameds_adjust(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) { diff --git a/level_0/f_fss/c/fss/private-named.h b/level_0/f_fss/c/fss/private-named.h index 6d1f48c..ee29923 100644 --- a/level_0/f_fss/c/fss/private-named.h +++ b/level_0/f_fss/c/fss/private-named.h @@ -129,11 +129,13 @@ extern "C" { * @see f_uint8ss_resize() * * @see f_fss_nameds_decrease_by() + * @see f_fss_nameds_increase() + * @see f_fss_nameds_increase_by() * @see f_fss_nameds_resize() */ -#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) +#if !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_named_increase_) || !defined(_di_f_fss_named_increase_by_) || !defined(_di_f_fss_nameds_resize_) extern f_status_t private_f_fss_nameds_resize(const f_number_unsigned_t length, f_fss_nameds_t * const nameds) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_resize_) +#endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_named_increase_) || !defined(_di_f_fss_named_increase_by_) || !defined(_di_f_fss_nameds_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-nest.c b/level_0/f_fss/c/fss/private-nest.c index bf50fc9..a85fbbb 100644 --- a/level_0/f_fss/c/fss/private-nest.c +++ b/level_0/f_fss/c/fss/private-nest.c @@ -57,7 +57,7 @@ extern "C" { } #endif // !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_decimate_by_) -#if !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_resize_) +#if !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) f_status_t private_f_fss_nests_resize(const f_number_unsigned_t length, f_fss_nests_t * const nests) { { @@ -72,7 +72,7 @@ extern "C" { return f_memory_array_resize(length, sizeof(f_fss_nest_t), (void **) &nests->array, &nests->used, &nests->size); } -#endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_resize_) +#endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-nest.h b/level_0/f_fss/c/fss/private-nest.h index 78cd408..a3e8361 100644 --- a/level_0/f_fss/c/fss/private-nest.h +++ b/level_0/f_fss/c/fss/private-nest.h @@ -121,11 +121,13 @@ extern "C" { * @see f_string_dynamic_resize() * * @see f_fss_nests_decrease_by() + * @see f_fss_nests_increase() + * @see f_fss_nests_increase_by() * @see f_fss_nests_resize() */ -#if !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_resize_) +#if !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) extern f_status_t private_f_fss_nests_resize(const f_number_unsigned_t length, f_fss_nests_t * const nests) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_resize_) +#endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/private-set.c b/level_0/f_fss/c/fss/private-set.c index 067a2ae..2949ff6 100644 --- a/level_0/f_fss/c/fss/private-set.c +++ b/level_0/f_fss/c/fss/private-set.c @@ -18,7 +18,7 @@ extern "C" { } #endif // !defined(_di_f_fss_set_adjust_) || !defined(_di_f_fss_set_decimate_by_) -#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_resize_) +#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) f_status_t private_f_fss_set_resize(const f_number_unsigned_t length, f_fss_set_t *set) { f_status_t status = f_string_ranges_resize(length, &set->objects); @@ -29,7 +29,7 @@ extern "C" { return F_none; } -#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_resize_) +#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) #if !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_decimate_by_) f_status_t private_f_fss_sets_adjust(const f_number_unsigned_t length, f_fss_sets_t * const sets) { diff --git a/level_0/f_fss/c/fss/private-set.h b/level_0/f_fss/c/fss/private-set.h index 82b3781..5250ae5 100644 --- a/level_0/f_fss/c/fss/private-set.h +++ b/level_0/f_fss/c/fss/private-set.h @@ -61,11 +61,13 @@ extern "C" { * @see f_string_rangess_resize()() * * @see f_fss_set_decrease_by() + * @see f_fss_set_increase() + * @see f_fss_set_increase_by() * @see f_fss_set_resize() */ -#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_resize_) +#if !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) extern f_status_t private_f_fss_set_resize(const f_number_unsigned_t length, f_fss_set_t * const set) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_resize_) +#endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) /** * Private implementation for resizing. diff --git a/level_0/f_fss/c/fss/private-set_quote.c b/level_0/f_fss/c/fss/private-set_quote.c index 3324f43..d955e87 100644 --- a/level_0/f_fss/c/fss/private-set_quote.c +++ b/level_0/f_fss/c/fss/private-set_quote.c @@ -24,7 +24,7 @@ extern "C" { } #endif // !defined(_di_f_fss_set_quote_adjust_) || !defined(_di_f_fss_set_quote_decimate_by_) -#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_resize_) +#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) f_status_t private_f_fss_set_quote_resize(const f_number_unsigned_t length, f_fss_set_quote_t * const set_quote) { f_status_t status = f_string_ranges_resize(length, &set_quote->objects); @@ -41,7 +41,7 @@ extern "C" { return F_none; } -#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_resize_) +#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) #if !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_decimate_by_) f_status_t private_f_fss_set_quotes_adjust(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) { diff --git a/level_0/f_fss/c/fss/private-set_quote.h b/level_0/f_fss/c/fss/private-set_quote.h index dd69307..0c9bec6 100644 --- a/level_0/f_fss/c/fss/private-set_quote.h +++ b/level_0/f_fss/c/fss/private-set_quote.h @@ -138,12 +138,14 @@ extern "C" { * @see f_uint8ss_adjust() * * @see f_fss_set_quotes_decrease_by() + * @see f_fss_set_quotes_increase() + * @see f_fss_set_quotes_increase_by() * @see f_fss_set_quotes_resize() * @see f_memory_resize() */ -#if !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_resize_) +#if !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) extern f_status_t private_f_fss_set_quotes_resize(const f_number_unsigned_t length, f_fss_set_quotes_t * const set_quotes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_resize_) +#endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/c/fss/simple_packet.c b/level_0/f_fss/c/fss/simple_packet.c index d7ec68f..4f02106 100644 --- a/level_0/f_fss/c/fss/simple_packet.c +++ b/level_0/f_fss/c/fss/simple_packet.c @@ -177,7 +177,7 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = f_memory_array_increase(source.used, sizeof(f_fss_simple_packet_ranges_t), (void **) &destination->array, &destination->used, &destination->size); + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fss_simple_packet_ranges_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { diff --git a/level_0/f_fss/c/fss/simple_packet.h b/level_0/f_fss/c/fss/simple_packet.h index ec447d9..22024d7 100644 --- a/level_0/f_fss/c/fss/simple_packet.h +++ b/level_0/f_fss/c/fss/simple_packet.h @@ -188,10 +188,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_memory_array_resize(). * - * @see f_memory_array_increase_by() + * @see f_memory_array_increase() * @see f_memory_array_resize() */ #ifndef _di_f_fss_simple_packet_ranges_append_ diff --git a/level_0/f_limit/c/limit/set.c b/level_0/f_limit/c/limit/set.c index 1e78b77..ac187d5 100644 --- a/level_0/f_limit/c/limit/set.c +++ b/level_0/f_limit/c/limit/set.c @@ -126,7 +126,7 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = f_memory_array_increase(source.used, sizeof(f_limit_sets_t), (void **) &destination->array, &destination->used, &destination->size); + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_limit_sets_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { diff --git a/level_0/f_limit/c/limit/set.h b/level_0/f_limit/c/limit/set.h index e32eadd..d96d757 100644 --- a/level_0/f_limit/c/limit/set.h +++ b/level_0/f_limit/c/limit/set.h @@ -336,10 +336,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_memory_array_resize(). * - * @see f_memory_array_increase_by() + * @see f_memory_array_increase() * @see f_memory_array_resize() */ #ifndef _di_f_limit_setss_append_ diff --git a/level_0/f_limit/c/limit/value.c b/level_0/f_limit/c/limit/value.c index f1e3d4c..9792dd2 100644 --- a/level_0/f_limit/c/limit/value.c +++ b/level_0/f_limit/c/limit/value.c @@ -126,7 +126,7 @@ extern "C" { if (!source.used) return F_data_not; - f_status_t status = f_memory_array_increase(source.used, sizeof(f_limit_values_t), (void **) &destination->array, &destination->used, &destination->size); + f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_limit_values_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) { diff --git a/level_0/f_limit/c/limit/value.h b/level_0/f_limit/c/limit/value.h index 9fd7419..c0ad9b7 100644 --- a/level_0/f_limit/c/limit/value.h +++ b/level_0/f_limit/c/limit/value.h @@ -331,10 +331,10 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * - * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_memory_array_increase(). * Errors (with error bit) from: f_memory_array_resize(). * - * @see f_memory_array_increase_by() + * @see f_memory_array_increase() * @see f_memory_array_resize() */ #ifndef _di_f_limit_valuess_append_ diff --git a/level_0/f_socket/c/socket/private-socket.c b/level_0/f_socket/c/socket/private-socket.c index ebf90a8..5838eb2 100644 --- a/level_0/f_socket/c/socket/private-socket.c +++ b/level_0/f_socket/c/socket/private-socket.c @@ -5,19 +5,7 @@ extern "C" { #endif -#if !defined(_di_f_sockets_append_) || !defined(_di_f_socketss_append_) - extern f_status_t private_f_sockets_append(const f_socket_t source, f_sockets_t * const destination) { - - const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size); - if (F_status_is_error(status)) return status; - - destination->array[destination->used++] = source; - - return F_none; - } -#endif // !defined(_di_f_sockets_append_) || !defined(_di_f_socketss_append_) - -#if !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_all_) +#if !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_) || !defined(_di_f_socketss_append_all_) extern f_status_t private_f_sockets_append_all(const f_sockets_t source, f_sockets_t * const destination) { const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size); @@ -29,7 +17,7 @@ extern "C" { return F_none; } -#endif // !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_all_) +#endif // !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_) || !defined(_di_f_socketss_append_all_) #if !defined(_di_f_socketss_adjust_) || !defined(_di_f_socketss_decimate_by_) f_status_t private_f_socketss_adjust(const f_number_unsigned_t length, f_socketss_t * const socketss) { diff --git a/level_0/f_socket/c/socket/private-socket.h b/level_0/f_socket/c/socket/private-socket.h index d86d434..5aa0391 100644 --- a/level_0/f_socket/c/socket/private-socket.h +++ b/level_0/f_socket/c/socket/private-socket.h @@ -21,29 +21,6 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source socket to append. - * @param destination - * The destination lengths the source is appended onto. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_sockets_append() - * @see f_socketss_append() - */ -#if !defined(_di_f_sockets_append_) || !defined(_di_f_socketss_append_) - extern f_status_t private_f_sockets_append(const f_socket_t source, f_sockets_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_sockets_append_) || !defined(_di_f_socketss_append_) - -/** - * Private implementation for appending the socket array. - * - * Intended to be shared to each of the different implementation variations. - * - * @param source * The source sockets to append. * @param destination * The destination lengths the source is appended onto. @@ -54,13 +31,14 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). * * @see f_memory_resize() + * * @see f_sockets_append_all() * @see f_socketss_append() * @see f_socketss_append_all() */ -#if !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_all_) +#if !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_) || !defined(_di_f_socketss_append_all_) extern f_status_t private_f_sockets_append_all(const f_sockets_t source, f_sockets_t * const destination) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_sockets_append_) || !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_all_) +#endif // !defined(_di_f_sockets_append_all_) || !defined(_di_f_socketss_append_) || !defined(_di_f_socketss_append_all_) /** * Private implementation for resizing the socketss array. diff --git a/level_0/f_socket/c/socket/socket.c b/level_0/f_socket/c/socket/socket.c index 9607688..a8d9eea 100644 --- a/level_0/f_socket/c/socket/socket.c +++ b/level_0/f_socket/c/socket/socket.c @@ -22,7 +22,12 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_sockets_append(source, destination); + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; + + destination->array[destination->used++] = source; + + return F_none; } #endif // _di_f_sockets_append_ diff --git a/level_0/f_string/c/private-string.c b/level_0/f_string/c/private-string.c index ea4572e..58080d5 100644 --- a/level_0/f_string/c/private-string.c +++ b/level_0/f_string/c/private-string.c @@ -9,8 +9,8 @@ extern "C" { #if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_dynamic_partial_mish_) || !defined(_di_f_string_dynamic_partial_mish_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_triples_append_) f_status_t private_f_string_append(const f_string_t source, const f_number_unsigned_t length, f_string_dynamic_t * const destination) { - if (destination->used + length + 1 > destination->size) { - const f_status_t status = private_f_string_dynamic_increase_by(length + 1, destination); + { + const f_status_t status = f_memory_array_increase_by(length + 1, sizeof(f_string_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -25,8 +25,9 @@ extern "C" { #if !defined(_di_f_string_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) f_status_t private_f_string_append_nulless(const f_string_t source, const f_number_unsigned_t length, f_string_dynamic_t * const destination) { - f_status_t status = F_none; + if (destination->used >= F_string_t_size_d) return F_status_set_error(F_string_too_large); + f_status_t status = F_none; f_number_unsigned_t i = 0; f_number_unsigned_t size = 0; @@ -35,10 +36,10 @@ extern "C" { if (source[i]) ++size; } // for - if (destination->used + size + 1 > destination->size) { - status = private_f_string_dynamic_increase_by(size + 1, destination); - if (F_status_is_error(status)) return status; - } + if (size + 1 > F_string_t_size_d) return F_status_set_error(F_string_too_large); + + status = f_memory_array_increase_by(size + 1, sizeof(f_string_t), (void **) &destination->string, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; f_number_unsigned_t first = 0; @@ -76,12 +77,11 @@ extern "C" { #if !defined(_di_f_string_dynamic_mish_) || !defined(_di_f_string_dynamic_partial_mish_) || !defined(_di_f_string_dynamic_partial_prepend_assure_) || !defined(_di_f_string_dynamic_partial_prepend_) || !defined(_di_f_string_dynamic_prepend_assure_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_mish_) || !defined(_di_f_string_prepend_assure_) || !defined(_di_f_string_prepend_) f_status_t private_f_string_prepend(const f_string_t source, const f_number_unsigned_t length, f_string_dynamic_t * const destination) { - if (destination->used + length > F_string_t_size_d) { - return F_status_set_error(F_string_too_large); - } + if (destination->used >= F_string_t_size_d) return F_status_set_error(F_string_too_large); + if (destination->used + length + 1 > F_string_t_size_d) return F_status_set_error(F_string_too_large); - if (destination->used + length > destination->size) { - const f_status_t status = private_f_string_dynamic_increase_by(length, destination); + { + const f_status_t status = f_memory_array_increase_by(length + 1, sizeof(f_string_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -102,12 +102,9 @@ extern "C" { #if !defined(_di_f_string_dynamic_mish_nulless_) || !defined(_di_f_string_dynamic_partial_mish_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_mish_nulless_) || !defined(_di_f_string_prepend_assure_nulless_) || !defined(_di_f_string_prepend_nulless_) f_status_t private_f_string_prepend_nulless(const f_string_t source, const f_number_unsigned_t length, f_string_dynamic_t * const destination) { - if (destination->used + length > F_string_t_size_d) { - return F_status_set_error(F_string_too_large); - } + if (destination->used + length > F_string_t_size_d) return F_status_set_error(F_string_too_large); f_status_t status = F_none; - f_number_unsigned_t first = 0; f_number_unsigned_t offset = 0; @@ -119,10 +116,8 @@ extern "C" { if (i > first) { size = i - first; - if (destination->used + size > destination->size) { - status = private_f_string_dynamic_increase_by(size, destination); - if (F_status_is_error(status)) return status; - } + status = f_memory_array_increase_by(size + 1, sizeof(f_string_t), (void **) &destination->string, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; memmove(destination->string + offset + size, destination->string + offset, sizeof(f_char_t) * (destination->used - offset)); memcpy(destination->string + offset, source + first, sizeof(f_char_t) * size); @@ -139,10 +134,8 @@ extern "C" { if (i > first) { size = i - first; - if (destination->used + size > destination->size) { - status = private_f_string_dynamic_increase_by(size, destination); - if (F_status_is_error(status)) return status; - } + status = f_memory_array_increase_by(size + 1, sizeof(f_string_t), (void **) &destination->string, &destination->used, &destination->size); + if (F_status_is_error(status)) return status; memmove(destination->string + offset + size, destination->string + offset, sizeof(f_char_t) * (destination->used - offset)); memcpy(destination->string + offset, source + first, sizeof(f_char_t) * size); diff --git a/level_0/f_string/c/string.c b/level_0/f_string/c/string.c index 8115e9c..20a94c2 100644 --- a/level_0/f_string/c/string.c +++ b/level_0/f_string/c/string.c @@ -24,10 +24,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!length) return F_data_not; - - if (destination->used < length) { - return private_f_string_append(source, length, destination); - } + if (destination->used < length) return private_f_string_append(source, length, destination); f_number_unsigned_t i = 1; f_number_unsigned_t j = 1; @@ -65,10 +62,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!length) return F_data_not; - - if (!destination->used) { - return private_f_string_append_nulless(source, length, destination); - } + if (!destination->used) return private_f_string_append_nulless(source, length, destination); f_number_unsigned_t i = 1; f_number_unsigned_t j = 1; @@ -120,7 +114,7 @@ extern "C" { if (!length) return F_data_not; if (glue_length && destination->used) { - f_status_t status = private_f_string_append(glue, glue_length, destination); + const f_status_t status = private_f_string_append(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -154,7 +148,7 @@ extern "C" { if (!length) return F_data_not; if (glue_length && destination->used) { - f_status_t status = private_f_string_prepend(glue, glue_length, destination); + const f_status_t status = private_f_string_prepend(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -171,7 +165,7 @@ extern "C" { if (!length) return F_data_not; if (glue_length && destination->used) { - f_status_t status = private_f_string_prepend_nulless(glue, glue_length, destination); + const f_status_t status = private_f_string_prepend_nulless(glue, glue_length, destination); if (F_status_is_error(status)) return status; } @@ -198,10 +192,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!length) return F_data_not; - - if (destination->used < length) { - return private_f_string_prepend(source, length, destination); - } + if (destination->used < length) return private_f_string_prepend(source, length, destination); f_number_unsigned_t i = 0; f_number_unsigned_t j = 0; @@ -239,10 +230,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!length) return F_data_not; - - if (!destination->used) { - return private_f_string_prepend_nulless(source, length, destination); - } + if (!destination->used) return private_f_string_prepend_nulless(source, length, destination); f_number_unsigned_t i = 0; f_number_unsigned_t j = 0; @@ -291,17 +279,13 @@ extern "C" { if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (range->start > range->stop) { - return F_data_not_stop; - } + if (range->start > range->stop) return F_data_not_stop; while (string[range->start] != f_string_eol_s.string[0]) { ++range->start; - if (range->start > range->stop) { - return F_none_stop; - } + if (range->start > range->stop) return F_none_stop; } // while return F_none; @@ -314,21 +298,15 @@ extern "C" { if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (range->start > range->stop) { - return F_data_not_stop; - } + if (range->start > range->stop) return F_data_not_stop; while (string[range->start] != seek_to) { - if (string[range->start] == f_string_eol_s.string[0]) { - return F_none_eol; - } + if (string[range->start] == f_string_eol_s.string[0]) return F_none_eol; ++range->start; - if (range->start > range->stop) { - return F_none_stop; - } + if (range->start > range->stop) return F_none_stop; } // while return F_none; @@ -341,17 +319,13 @@ extern "C" { if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (range->start > range->stop) { - return F_data_not_stop; - } + if (range->start > range->stop) return F_data_not_stop; while (string[range->start] != seek_to) { ++range->start; - if (range->start > range->stop) { - return F_none_stop; - } + if (range->start > range->stop) return F_none_stop; } // while return F_none; diff --git a/level_0/f_string/c/string/dynamic.c b/level_0/f_string/c/string/dynamic.c index a5670a3..d99c68b 100644 --- a/level_0/f_string/c/string/dynamic.c +++ b/level_0/f_string/c/string/dynamic.c @@ -12,7 +12,7 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_dynamic_adjust(length, dynamic); + return f_memory_array_adjust(length, sizeof(f_string_t), (void **) &dynamic->string, &dynamic->used, &dynamic->size); } #endif // _di_f_string_dynamic_adjust_ @@ -35,10 +35,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!source.used) return F_data_not; - - if (destination->used < source.used) { - return private_f_string_append(source.string, source.used, destination); - } + if (destination->used < source.used) return private_f_string_append(source.string, source.used, destination); f_number_unsigned_t i = 1; f_number_unsigned_t j = 1; @@ -64,10 +61,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!source.used) return F_data_not; - - if (!destination->used) { - return private_f_string_append_nulless(source.string, source.used, destination); - } + if (!destination->used) return private_f_string_append_nulless(source.string, source.used, destination); f_number_unsigned_t i = 1; f_number_unsigned_t j = 1; @@ -116,13 +110,7 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (dynamic->size > amount) { - return private_f_string_dynamic_adjust(dynamic->size - amount, dynamic); - } - - return private_f_string_dynamic_adjust(0, dynamic); + return f_memory_array_decimate_by(amount, sizeof(f_string_t), (void **) &dynamic->string, &dynamic->used, &dynamic->size); } #endif // _di_f_string_dynamic_decimate_by_ @@ -132,13 +120,7 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (dynamic->size > amount) { - return private_f_string_dynamic_resize(dynamic->size - amount, dynamic); - } - - return private_f_string_dynamic_resize(0, dynamic); + return f_memory_array_decrease_by(amount, sizeof(f_string_t), (void **) &dynamic->string, &dynamic->used, &dynamic->size); } #endif // _di_f_string_dynamic_decrease_by_ @@ -148,21 +130,7 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && dynamic->used + 1 > dynamic->size) { - f_number_unsigned_t size = dynamic->used + step; - - if (size > F_string_t_size_d) { - if (dynamic->used + 1 > F_string_t_size_d) { - return F_status_set_error(F_string_too_large); - } - - size = F_string_t_size_d; - } - - return private_f_string_dynamic_resize(size, dynamic); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_string_t), (void **) &dynamic->string, &dynamic->used, &dynamic->size); } #endif // _di_f_string_dynamic_increase_ @@ -172,9 +140,7 @@ extern "C" { if (!dynamic) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - return private_f_string_dynamic_increase_by(amount, dynamic); + return f_memory_array_increase_by(amount, sizeof(f_string_t), (void **) &dynamic->string, &dynamic->used, &dynamic->size); } #endif // _di_f_string_dynamic_increase_by_ @@ -276,9 +242,7 @@ extern "C" { const f_number_unsigned_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; - if (destination->used < length) { - return private_f_string_append(source.string + range.start, length, destination); - } + if (destination->used < length) return private_f_string_append(source.string + range.start, length, destination); const f_number_unsigned_t stop = range.stop >= source.used ? source.used : range.stop + 1; f_number_unsigned_t i = 1; @@ -310,9 +274,7 @@ extern "C" { const f_number_unsigned_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; - if (!destination->used) { - return private_f_string_append_nulless(source.string + range.start, length, destination); - } + if (!destination->used) return private_f_string_append_nulless(source.string + range.start, length, destination); const f_number_unsigned_t stop = range.stop >= source.used ? source.used : range.stop + 1; f_number_unsigned_t i = 1; @@ -484,9 +446,7 @@ extern "C" { const f_number_unsigned_t length = range.stop >= source.used ? source.used - range.start : (range.stop - range.start) + 1; - if (destination->used < length) { - return private_f_string_prepend(source.string + range.start, length, destination); - } + if (destination->used < length) return private_f_string_prepend(source.string + range.start, length, destination); f_number_unsigned_t i = 0; f_number_unsigned_t j = 0; @@ -583,19 +543,14 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!source.used) return F_data_not; - - if (destination->used < source.used) { - return private_f_string_prepend(source.string, source.used, destination); - } + if (destination->used < source.used) return private_f_string_prepend(source.string, source.used, destination); f_number_unsigned_t i = 0; f_number_unsigned_t j = 0; while (i < source.used && j < destination->used) { - if (source.string[i] != destination->string[j]) { - return private_f_string_prepend(source.string, source.used, destination); - } + if (source.string[i] != destination->string[j]) return private_f_string_prepend(source.string, source.used, destination); ++i; ++j; @@ -612,10 +567,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!source.used) return F_data_not; - - if (!destination->used) { - return private_f_string_prepend_nulless(source.string, source.used, destination); - } + if (!destination->used) return private_f_string_prepend_nulless(source.string, source.used, destination); f_number_unsigned_t i = 0; f_number_unsigned_t j = 0; @@ -634,9 +586,7 @@ extern "C" { continue; } - if (source.string[i] != destination->string[j]) { - return private_f_string_prepend_nulless(source.string, source.used, destination); - } + if (source.string[i] != destination->string[j]) return private_f_string_prepend_nulless(source.string, source.used, destination); ++i; ++j; @@ -664,7 +614,7 @@ extern "C" { if (!buffer) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_dynamic_resize(length, buffer); + return f_memory_array_resize(length, sizeof(f_string_t), (void **) &buffer->string, &buffer->used, &buffer->size); } #endif // _di_f_string_dynamic_resize_ @@ -742,8 +692,8 @@ extern "C" { if (destination->used && !destination->string[destination->used - 1]) return F_none; if (destination->used == F_string_t_size_d) return F_status_set_error(F_string_too_large); - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_string_dynamic_resize(destination->used + (destination->used + 1 == F_string_t_size_d ? 1 : F_memory_default_allocation_small_d), destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -760,15 +710,13 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (destination->used < destination->size) { - if (!destination->string[destination->used]) { - return F_none; - } + if (!destination->string[destination->used]) return F_none; } if (destination->used == F_string_t_size_d) return F_status_set_error(F_string_too_large); - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_string_dynamic_resize(destination->used + (destination->used + 1 == F_string_t_size_d ? 1 : F_memory_default_allocation_small_d), destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } diff --git a/level_0/f_string/c/string/dynamics.c b/level_0/f_string/c/string/dynamics.c index c3a399d..8869ec3 100644 --- a/level_0/f_string/c/string/dynamics.c +++ b/level_0/f_string/c/string/dynamics.c @@ -49,11 +49,7 @@ extern "C" { if (!amount) return F_data_not; - if (dynamics->size > amount) { - return private_f_string_dynamics_adjust(dynamics->size - amount, dynamics); - } - - return private_f_string_dynamics_adjust(0, dynamics); + return private_f_string_dynamics_adjust((dynamics->size > amount) ? dynamics->size - amount : 0, dynamics); } #endif // _di_f_string_dynamics_decimate_by_ @@ -65,11 +61,7 @@ extern "C" { if (!amount) return F_data_not; - if (dynamics->size > amount) { - return private_f_string_dynamics_resize(dynamics->size - amount, dynamics); - } - - return private_f_string_dynamics_resize(0, dynamics); + return private_f_string_dynamics_resize((dynamics->size > amount) ? dynamics->size - amount : 0, dynamics); } #endif // _di_f_string_dynamics_decrease_by_ @@ -85,9 +77,7 @@ extern "C" { f_number_unsigned_t size = dynamics->used + step; if (size > F_number_t_size_unsigned_d) { - if (dynamics->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (dynamics->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/dynamicss.c b/level_0/f_string/c/string/dynamicss.c index 3bd0565..74aee6c 100644 --- a/level_0/f_string/c/string/dynamicss.c +++ b/level_0/f_string/c/string/dynamicss.c @@ -83,11 +83,7 @@ extern "C" { if (!amount) return F_data_not; - if (dynamicss->size > amount) { - return private_f_string_dynamicss_adjust(dynamicss->size - amount, dynamicss); - } - - return private_f_string_dynamicss_adjust(0, dynamicss); + return private_f_string_dynamicss_adjust((dynamicss->size > amount) ? dynamicss->size - amount : 0, dynamicss); } #endif // _di_f_string_dynamicss_decimate_by_ @@ -99,11 +95,7 @@ extern "C" { if (!amount) return F_data_not; - if (dynamicss->size > amount) { - return private_f_string_dynamicss_resize(dynamicss->size - amount, dynamicss); - } - - return private_f_string_dynamicss_resize(0, dynamicss); + return private_f_string_dynamicss_resize((dynamicss->size > amount) ? dynamicss->size - amount : 0, dynamicss); } #endif // _di_f_string_dynamicss_decrease_by_ @@ -119,9 +111,7 @@ extern "C" { f_number_unsigned_t size = dynamicss->used + step; if (size > F_number_t_size_unsigned_d) { - if (dynamicss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (dynamicss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/map_multis.c b/level_0/f_string/c/string/map_multis.c index 4e54d41..758e3e1 100644 --- a/level_0/f_string/c/string/map_multis.c +++ b/level_0/f_string/c/string/map_multis.c @@ -70,11 +70,7 @@ extern "C" { if (!amount) return F_data_not; - if (map_multis->size > amount) { - return private_f_string_map_multis_adjust(map_multis->size - amount, map_multis); - } - - return private_f_string_map_multis_adjust(0, map_multis); + return private_f_string_map_multis_adjust((map_multis->size > amount) ? map_multis->size - amount : 0, map_multis); } #endif // _di_f_string_map_multis_decimate_by_ @@ -86,11 +82,7 @@ extern "C" { if (!amount) return F_data_not; - if (map_multis->size > amount) { - return private_f_string_map_multis_resize(map_multis->size - amount, map_multis); - } - - return private_f_string_map_multis_resize(0, map_multis); + return private_f_string_map_multis_resize((map_multis->size > amount) ? map_multis->size - amount : 0, map_multis); } #endif // _di_f_string_map_multis_decrease_by_ @@ -104,9 +96,7 @@ extern "C" { f_number_unsigned_t size = map_multis->used + step; if (size > F_number_t_size_unsigned_d) { - if (map_multis->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (map_multis->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/map_multiss.c b/level_0/f_string/c/string/map_multiss.c index e269af6..29b0464 100644 --- a/level_0/f_string/c/string/map_multiss.c +++ b/level_0/f_string/c/string/map_multiss.c @@ -84,11 +84,7 @@ extern "C" { if (!amount) return F_data_not; - if (map_multiss->size > amount) { - return private_f_string_map_multiss_adjust(map_multiss->size - amount, map_multiss); - } - - return private_f_string_map_multiss_adjust(0, map_multiss); + return private_f_string_map_multiss_adjust((map_multiss->size > amount) ? map_multiss->size - amount : 0, map_multiss); } #endif // _di_f_string_map_multiss_decimate_by_ @@ -100,11 +96,7 @@ extern "C" { if (!amount) return F_data_not; - if (map_multiss->size > amount) { - return private_f_string_map_multiss_resize(map_multiss->size - amount, map_multiss); - } - - return private_f_string_map_multiss_resize(0, map_multiss); + return private_f_string_map_multiss_resize((map_multiss->size > amount) ? map_multiss->size - amount : 0, map_multiss); } #endif // _di_f_string_map_multiss_decrease_by_ @@ -118,9 +110,7 @@ extern "C" { f_number_unsigned_t size = map_multiss->used + step; if (size > F_number_t_size_unsigned_d) { - if (map_multiss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (map_multiss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/maps.c b/level_0/f_string/c/string/maps.c index 93324e8..bc12a2b 100644 --- a/level_0/f_string/c/string/maps.c +++ b/level_0/f_string/c/string/maps.c @@ -68,11 +68,7 @@ extern "C" { if (!amount) return F_data_not; - if (maps->size > amount) { - return private_f_string_maps_adjust(maps->size - amount, maps); - } - - return private_f_string_maps_adjust(0, maps); + return private_f_string_maps_adjust((maps->size > amount) ? maps->size - amount : 0, maps); } #endif // _di_f_string_maps_decimate_by_ @@ -84,11 +80,7 @@ extern "C" { if (!amount) return F_data_not; - if (maps->size > amount) { - return private_f_string_maps_resize(maps->size - amount, maps); - } - - return private_f_string_maps_resize(0, maps); + return private_f_string_maps_resize((maps->size > amount) ? maps->size - amount : 0, maps); } #endif // _di_f_string_maps_decrease_by_ @@ -102,9 +94,7 @@ extern "C" { f_number_unsigned_t size = maps->used + step; if (size > F_number_t_size_unsigned_d) { - if (maps->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (maps->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/mapss.c b/level_0/f_string/c/string/mapss.c index ddd3824..a68f0b7 100644 --- a/level_0/f_string/c/string/mapss.c +++ b/level_0/f_string/c/string/mapss.c @@ -82,11 +82,7 @@ extern "C" { if (!amount) return F_data_not; - if (mapss->size > amount) { - return private_f_string_mapss_adjust(mapss->size - amount, mapss); - } - - return private_f_string_mapss_adjust(0, mapss); + return private_f_string_mapss_adjust((mapss->size > amount) ? mapss->size - amount : 0, mapss); } #endif // _di_f_string_mapss_decimate_by_ @@ -98,11 +94,7 @@ extern "C" { if (!amount) return F_data_not; - if (mapss->size > amount) { - return private_f_string_mapss_resize(mapss->size - amount, mapss); - } - - return private_f_string_mapss_resize(0, mapss); + return private_f_string_mapss_resize((mapss->size > amount) ? mapss->size - amount : 0, mapss); } #endif // _di_f_string_mapss_decrease_by_ @@ -116,9 +108,7 @@ extern "C" { f_number_unsigned_t size = mapss->used + step; if (size > F_number_t_size_unsigned_d) { - if (mapss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (mapss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/private-dynamic.c b/level_0/f_string/c/string/private-dynamic.c index 7bb7cbf..b947a17 100644 --- a/level_0/f_string/c/string/private-dynamic.c +++ b/level_0/f_string/c/string/private-dynamic.c @@ -6,53 +6,6 @@ extern "C" { #endif -#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - f_status_t private_f_string_dynamic_adjust(const f_number_unsigned_t length, f_string_dynamic_t * const dynamic) { - - const f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_char_t), (void **) & dynamic->string); - if (F_status_is_error(status)) return status; - - dynamic->size = length; - - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - -#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - f_status_t private_f_string_dynamic_increase_by(const f_number_unsigned_t amount, f_string_dynamic_t * const dynamic) { - - const f_number_unsigned_t length = dynamic->used + amount; - - if (length > dynamic->size) { - if (length > F_string_t_size_d) return F_status_set_error(F_string_too_large); - - return private_f_string_dynamic_resize(length, dynamic); - } - - return F_data_not; - } -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - -#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - f_status_t private_f_string_dynamic_resize(const f_number_unsigned_t length, f_string_dynamic_t * const dynamic) { - - const f_status_t status = f_memory_resize(dynamic->size, length, sizeof(f_char_t), (void **) & dynamic->string); - if (F_status_is_error(status)) return status; - - dynamic->size = length; - - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/private-dynamic.h b/level_0/f_string/c/string/private-dynamic.h index 504366a..c0b536a 100644 --- a/level_0/f_string/c/string/private-dynamic.h +++ b/level_0/f_string/c/string/private-dynamic.h @@ -15,132 +15,6 @@ extern "C" { #endif -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamic - * The string to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_dynamic_adjust() - * @see f_string_dynamic_decimate_by() - * @see f_string_dynamics_adjust() - * @see f_string_dynamics_append() - * @see f_string_dynamics_decimate_by() - * @see f_string_map_multis_adjust() - * @see f_string_map_multis_append() - * @see f_string_triples_adjust() - * @see f_string_triples_decimate_by() - */ -#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - extern f_status_t private_f_string_dynamic_adjust(const f_number_unsigned_t length, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) - -/** - * Private implementation of f_string_dynamic_increase_by(). - * - * Intended to be shared to each of the different implementation variations. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param dynamic - * The string to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_string_too_large (with error bit) if the combined string is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see memcpy() - * - * @see f_string_append() - * @see f_string_append_assure() - * @see f_string_append_mash() - * @see f_string_append_nulless() - * @see f_string_dynamic_append() - * @see f_string_dynamic_append_assure() - * @see f_string_dynamic_append_nulless() - * @see f_string_dynamic_increase_by() - * @see f_string_dynamic_mash() - * @see f_string_dynamic_mash_nulless() - * @see f_string_dynamic_partial_append) - * @see f_string_dynamic_partial_append_assure() - * @see f_string_dynamic_partial_mash() - * @see f_string_dynamic_prepend() - * @see f_string_dynamic_prepend_nulless() - * @see f_string_dynamics_append() - * @see f_string_map_multis_append() - * @see f_string_mash() - * @see f_string_mash_nulless() - * @see f_string_maps_append() - * @see f_string_prepend() - * @see f_string_prepend_nulless() - * @see f_string_triples_append() - */ -#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - extern f_status_t private_f_string_dynamic_increase_by(const f_number_unsigned_t amount, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param dynamic - * The string to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_append() - * @see f_string_append_assure() - * @see f_string_append_mash() - * @see f_string_append_nulless() - * @see f_string_dynamic_append() - * @see f_string_dynamic_append_assure() - * @see f_string_dynamic_append_nulless() - * @see f_string_dynamic_decrease_by() - * @see f_string_dynamic_increase() - * @see f_string_dynamic_increase_by() - * @see f_string_dynamic_mash() - * @see f_string_dynamic_mash_nulless() - * @see f_string_dynamic_partial_append) - * @see f_string_dynamic_partial_append_assure() - * @see f_string_dynamic_partial_mash() - * @see f_string_dynamic_prepend() - * @see f_string_dynamic_prepend_nulless() - * @see f_string_dynamic_terminate() - * @see f_string_dynamic_terminate_after() - * @see f_string_dynamics_append() - * @see f_string_map_multis_append() - * @see f_string_mash_nulless() - * @see f_string_mash() - * @see f_string_maps_append() - * @see f_string_prepend() - * @see f_string_prepend_nulless() - * @see f_string_triples_append() - */ -#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - extern f_status_t private_f_string_dynamic_resize(const f_number_unsigned_t length, f_string_dynamic_t * const dynamic) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/private-dynamics.c b/level_0/f_string/c/string/private-dynamics.c index f0c0659..b6472f1 100644 --- a/level_0/f_string/c/string/private-dynamics.c +++ b/level_0/f_string/c/string/private-dynamics.c @@ -10,26 +10,15 @@ extern "C" { #if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) f_status_t private_f_string_dynamics_adjust(const f_number_unsigned_t length, f_string_dynamics_t * const dynamics) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < dynamics->size; ++i) { - status = private_f_string_dynamic_adjust(0, &dynamics->array[i]); + status = f_memory_array_adjust(0, sizeof(f_string_t), (void **) &dynamics->array[i].string, &dynamics->array[i].used, &dynamics->array[i].size); if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(dynamics->size, length, sizeof(f_string_dynamic_t), (void **) & dynamics->array); - if (F_status_is_error(status)) return status; - - dynamics->size = length; - - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_dynamic_t), (void **) &dynamics->array, &dynamics->used, &dynamics->size); } #endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) @@ -83,26 +72,15 @@ extern "C" { #if !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) || !defined(f_string_dynamics_resize) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) f_status_t private_f_string_dynamics_resize(const f_number_unsigned_t length, f_string_dynamics_t * const dynamics) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < dynamics->size; ++i) { - status = private_f_string_dynamic_resize(0, &dynamics->array[i]); + status = f_memory_array_resize(0, sizeof(f_string_t), (void **) &dynamics->array[i].string, &dynamics->array[i].used, &dynamics->array[i].size); if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(dynamics->size, length, sizeof(f_string_dynamic_t), (void **) & dynamics->array); - if (F_status_is_error(status)) return status; - - dynamics->size = length; - - if (dynamics->used > dynamics->size) { - dynamics->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_dynamic_t), (void **) &dynamics->array, &dynamics->used, &dynamics->size); } #endif // !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) || !defined(f_string_dynamics_resize) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) diff --git a/level_0/f_string/c/string/private-dynamics.h b/level_0/f_string/c/string/private-dynamics.h index 7508fee..611591e 100644 --- a/level_0/f_string/c/string/private-dynamics.h +++ b/level_0/f_string/c/string/private-dynamics.h @@ -23,7 +23,7 @@ extern "C" { * @param length * The new size to use. * @param dynamics - * The strings to adjust. + * The dynamics to adjust. * * @return * F_none on success. @@ -52,7 +52,7 @@ extern "C" { * @param source * The source string to append. * @param destination - * The destination strings the source is appended onto. + * The destination dynamics the source is appended onto. * * @return * F_none on success. @@ -79,7 +79,7 @@ extern "C" { * @param source * The source strings to append. * @param destination - * The destination strings the source is appended onto. + * The destination dynamics the source is appended onto. * * @return * F_none on success. @@ -106,7 +106,7 @@ extern "C" { * @param length * The new size to use. * @param dynamics - * The strings to resize. + * The dynamics to resize. * * @return * F_none on success. diff --git a/level_0/f_string/c/string/private-dynamicss.c b/level_0/f_string/c/string/private-dynamicss.c index 76374c9..6c7cbd5 100644 --- a/level_0/f_string/c/string/private-dynamicss.c +++ b/level_0/f_string/c/string/private-dynamicss.c @@ -11,8 +11,6 @@ extern "C" { #if !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) f_status_t private_f_string_dynamicss_adjust(const f_number_unsigned_t length, f_string_dynamicss_t * const dynamicss) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < dynamicss->size; ++i) { @@ -21,24 +19,13 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(dynamicss->size, length, sizeof(f_string_dynamics_t), (void **) & dynamicss->array); - if (F_status_is_error(status)) return status; - - dynamicss->size = length; - - if (dynamicss->used > dynamicss->size) { - dynamicss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_dynamics_t), (void **) &dynamicss->array, &dynamicss->used, &dynamicss->size); } #endif // !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) #if !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) || !defined(_di_f_string_dynamicss_append_all_) || !defined(_di_f_string_map_multis_append_all_) f_status_t private_f_string_dynamicss_resize(const f_number_unsigned_t length, f_string_dynamicss_t * const dynamicss) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < dynamicss->size; ++i) { @@ -47,16 +34,7 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(dynamicss->size, length, sizeof(f_string_dynamics_t), (void **) & dynamicss->array); - if (F_status_is_error(status)) return status; - - dynamicss->size = length; - - if (dynamicss->used > dynamicss->size) { - dynamicss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_dynamics_t), (void **) &dynamicss->array, &dynamicss->used, &dynamicss->size); } #endif // !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) || !defined(_di_f_string_dynamicss_append_all_) || !defined(_di_f_string_map_multis_append_all_) diff --git a/level_0/f_string/c/string/private-dynamicss.h b/level_0/f_string/c/string/private-dynamicss.h index 1a4a796..decf9ea 100644 --- a/level_0/f_string/c/string/private-dynamicss.h +++ b/level_0/f_string/c/string/private-dynamicss.h @@ -23,7 +23,7 @@ extern "C" { * @param length * The new size to use. * @param dynamicss - * The strings to adjust. + * The dynamicss to adjust. * * @return * F_none on success. @@ -52,7 +52,7 @@ extern "C" { * @param length * The new size to use. * @param dynamicss - * The strings to resize. + * The dynamicss to resize. * * @return * F_none on success. diff --git a/level_0/f_string/c/string/private-map_multis.c b/level_0/f_string/c/string/private-map_multis.c index fcbdb86..328ce65 100644 --- a/level_0/f_string/c/string/private-map_multis.c +++ b/level_0/f_string/c/string/private-map_multis.c @@ -11,31 +11,18 @@ extern "C" { #if !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) f_status_t private_f_string_map_multis_adjust(const f_number_unsigned_t length, f_string_map_multis_t * const map_multis) { - if (map_multis->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < map_multis->size; ++i) { - status = private_f_string_dynamic_adjust(0, &map_multis->array[i].name); + status = f_memory_array_adjust(0, sizeof(f_string_t), (void **) &map_multis->array[i].name.string, &map_multis->array[i].name.used, &map_multis->array[i].name.size); if (F_status_is_error(status)) return status; status = private_f_string_dynamics_adjust(0, &map_multis->array[i].value); if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(map_multis->size, length, sizeof(f_string_map_multi_t), (void **) & map_multis->array); - if (F_status_is_error(status)) return status; - - map_multis->size = length; - - if (map_multis->used > map_multis->size) { - map_multis->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_map_multi_t), (void **) &map_multis->array, &map_multis->used, &map_multis->size); } #endif // !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) @@ -72,31 +59,18 @@ extern "C" { #if !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) f_status_t private_f_string_map_multis_resize(const f_number_unsigned_t length, f_string_map_multis_t * const map_multis) { - if (map_multis->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < map_multis->size; ++i) { - status = private_f_string_dynamic_resize(0, &map_multis->array[i].name); + status = f_memory_array_resize(0, sizeof(f_string_t), (void **) &map_multis->array[i].name.string, &map_multis->array[i].name.used, &map_multis->array[i].name.size); if (F_status_is_error(status)) return status; status = private_f_string_dynamics_resize(0, &map_multis->array[i].value); if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(map_multis->size, length, sizeof(f_string_map_multi_t), (void **) & map_multis->array); - if (F_status_is_error(status)) return status; - - map_multis->size = length; - - if (map_multis->used > map_multis->size) { - map_multis->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_map_multi_t), (void **) &map_multis->array, &map_multis->used, &map_multis->size); } #endif // !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_map_multis_append_all_) || !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_resize_) || !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multiss_append_all_) || !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) diff --git a/level_0/f_string/c/string/private-map_multis.h b/level_0/f_string/c/string/private-map_multis.h index a823653..60af0f7 100644 --- a/level_0/f_string/c/string/private-map_multis.h +++ b/level_0/f_string/c/string/private-map_multis.h @@ -46,7 +46,7 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source map_multis to append. + * The source destination to append. * @param destination * The destination map_multis the source is appended onto. * diff --git a/level_0/f_string/c/string/private-map_multiss.c b/level_0/f_string/c/string/private-map_multiss.c index f25b375..e2d5afa 100644 --- a/level_0/f_string/c/string/private-map_multiss.c +++ b/level_0/f_string/c/string/private-map_multiss.c @@ -12,10 +12,6 @@ extern "C" { #if !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) f_status_t private_f_string_map_multiss_adjust(const f_number_unsigned_t length, f_string_map_multiss_t * const map_multiss) { - if (map_multiss->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < map_multiss->size; ++i) { @@ -24,26 +20,13 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(map_multiss->size, length, sizeof(f_string_map_multis_t), (void **) & map_multiss->array); - if (F_status_is_error(status)) return status; - - map_multiss->size = length; - - if (map_multiss->used > map_multiss->size) { - map_multiss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_map_multis_t), (void **) &map_multiss->array, &map_multiss->used, &map_multiss->size); } #endif // !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) #if !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) f_status_t private_f_string_map_multiss_resize(const f_number_unsigned_t length, f_string_map_multiss_t * const map_multiss) { - if (map_multiss->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < map_multiss->size; ++i) { @@ -52,16 +35,7 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(map_multiss->size, length, sizeof(f_string_map_multis_t), (void **) & map_multiss->array); - if (F_status_is_error(status)) return status; - - map_multiss->size = length; - - if (map_multiss->used > map_multiss->size) { - map_multiss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_map_multis_t), (void **) &map_multiss->array, &map_multiss->used, &map_multiss->size); } #endif // !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) diff --git a/level_0/f_string/c/string/private-maps.c b/level_0/f_string/c/string/private-maps.c index 18588cd..86b54c9 100644 --- a/level_0/f_string/c/string/private-maps.c +++ b/level_0/f_string/c/string/private-maps.c @@ -10,31 +10,18 @@ extern "C" { #if !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) f_status_t private_f_string_maps_adjust(const f_number_unsigned_t length, f_string_maps_t * const maps) { - if (maps->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < maps->size; ++i) { - status = private_f_string_dynamic_adjust(0, &maps->array[i].name); + status = f_memory_array_adjust(0, sizeof(f_string_t), (void **) &maps->array[i].name.string, &maps->array[i].name.used, &maps->array[i].name.size); if (F_status_is_error(status)) return status; - status = private_f_string_dynamic_adjust(0, &maps->array[i].value); + status = f_memory_array_adjust(0, sizeof(f_string_t), (void **) &maps->array[i].value.string, &maps->array[i].value.used, &maps->array[i].value.size); if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(maps->size, length, sizeof(f_string_map_t), (void **) & maps->array); - if (F_status_is_error(status)) return status; - - maps->size = length; - - if (maps->used > maps->size) { - maps->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_map_t), (void **) &maps->array, &maps->used, &maps->size); } #endif // !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) @@ -71,31 +58,18 @@ extern "C" { #if !defined(_di_f_string_maps_append_) || !defined(_di_f_string_maps_append_all_) || !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_resize_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) f_status_t private_f_string_maps_resize(const f_number_unsigned_t length, f_string_maps_t * const maps) { - if (maps->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < maps->size; ++i) { - status = private_f_string_dynamic_resize(0, &maps->array[i].name); + status = f_memory_array_resize(0, sizeof(f_string_t), (void **) &maps->array[i].name.string, &maps->array[i].name.used, &maps->array[i].name.size); if (F_status_is_error(status)) return status; - status = private_f_string_dynamic_resize(0, &maps->array[i].value); + status = f_memory_array_resize(0, sizeof(f_string_t), (void **) &maps->array[i].value.string, &maps->array[i].value.used, &maps->array[i].value.size); if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(maps->size, length, sizeof(f_string_map_t), (void **) & maps->array); - if (F_status_is_error(status)) return status; - - maps->size = length; - - if (maps->used > maps->size) { - maps->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_map_t), (void **) &maps->array, &maps->used, &maps->size); } #endif // !defined(_di_f_string_maps_append_) || !defined(_di_f_string_maps_append_all_) || !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_resize_) || !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_mapss_append_all_) || !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) diff --git a/level_0/f_string/c/string/private-maps.h b/level_0/f_string/c/string/private-maps.h index 59a867f..ae06412 100644 --- a/level_0/f_string/c/string/private-maps.h +++ b/level_0/f_string/c/string/private-maps.h @@ -33,6 +33,7 @@ extern "C" { * Errors (with error bit) from: f_memory_adjust(). * * @see f_memory_adjust() + * * @see f_string_maps_adjust() */ #if !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) @@ -45,7 +46,7 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source maps to append. + * The source destination to append. * @param destination * The destination maps the source is appended onto. * @@ -57,6 +58,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). * * @see f_memory_resize() + * * @see f_string_maps_append_all() * @see f_string_mapss_append() * @see f_string_mapss_append_all() diff --git a/level_0/f_string/c/string/private-mapss.c b/level_0/f_string/c/string/private-mapss.c index c59cee8..961a1cc 100644 --- a/level_0/f_string/c/string/private-mapss.c +++ b/level_0/f_string/c/string/private-mapss.c @@ -11,10 +11,6 @@ extern "C" { #if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) f_status_t private_f_string_mapss_adjust(const f_number_unsigned_t length, f_string_mapss_t * const mapss) { - if (mapss->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < mapss->size; ++i) { @@ -23,26 +19,13 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(mapss->size, length, sizeof(f_string_maps_t), (void **) & mapss->array); - if (F_status_is_error(status)) return status; - - mapss->size = length; - - if (mapss->used > mapss->size) { - mapss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_maps_t), (void **) &mapss->array, &mapss->used, &mapss->size); } #endif // !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) #if !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) f_status_t private_f_string_mapss_resize(const f_number_unsigned_t length, f_string_mapss_t * const mapss) { - if (mapss->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < mapss->size; ++i) { @@ -51,16 +34,7 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(mapss->size, length, sizeof(f_string_maps_t), (void **) & mapss->array); - if (F_status_is_error(status)) return status; - - mapss->size = length; - - if (mapss->used > mapss->size) { - mapss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_maps_t), (void **) &mapss->array, &mapss->used, &mapss->size); } #endif // !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) diff --git a/level_0/f_string/c/string/private-mapss.h b/level_0/f_string/c/string/private-mapss.h index f4dfd9f..95a247a 100644 --- a/level_0/f_string/c/string/private-mapss.h +++ b/level_0/f_string/c/string/private-mapss.h @@ -33,6 +33,7 @@ extern "C" { * Errors (with error bit) from: f_memory_adjust(). * * @see f_memory_adjust() + * * @see f_string_mapss_adjust() */ #if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) @@ -57,6 +58,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). * * @see f_memory_resize() + * * @see f_string_mapss_decrease_by() * @see f_string_mapss_increase() * @see f_string_mapss_increase_by() diff --git a/level_0/f_string/c/string/private-quantitys.c b/level_0/f_string/c/string/private-quantitys.c index 9db33a9..da888f3 100644 --- a/level_0/f_string/c/string/private-quantitys.c +++ b/level_0/f_string/c/string/private-quantitys.c @@ -6,31 +6,11 @@ extern "C" { #endif -#if !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) - f_status_t private_f_string_quantitys_adjust(const f_number_unsigned_t length, f_string_quantitys_t * const quantitys) { - - if (quantitys->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_adjust(quantitys->size, length, sizeof(f_string_quantity_t), (void **) & quantitys->array); - if (F_status_is_error(status)) return status; - - quantitys->size = length; - - if (quantitys->used > quantitys->size) { - quantitys->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) - #if !defined(_di_f_string_quantitys_append_all_) || !defined(_di_f_string_quantityss_append_) || !defined(_di_f_string_quantityss_append_all_) f_status_t private_f_string_quantitys_append_all(const f_string_quantitys_t source, f_string_quantitys_t * const destination) { - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_string_quantitys_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_quantity_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -44,26 +24,6 @@ extern "C" { } #endif // !defined(_di_f_string_quantitys_append_all_) || !defined(_di_f_string_quantityss_append_) || !defined(_di_f_string_quantityss_append_all_) -#if !defined(_di_f_string_quantitys_decrease_) || !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) - f_status_t private_f_string_quantitys_resize(const f_number_unsigned_t length, f_string_quantitys_t * const quantitys) { - - if (quantitys->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_resize(quantitys->size, length, sizeof(f_string_quantity_t), (void **) & quantitys->array); - if (F_status_is_error(status)) return status; - - quantitys->size = length; - - if (quantitys->used > quantitys->size) { - quantitys->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_string_quantitys_decrease_) || !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/private-quantitys.h b/level_0/f_string/c/string/private-quantitys.h index 17ad18f..86ffe25 100644 --- a/level_0/f_string/c/string/private-quantitys.h +++ b/level_0/f_string/c/string/private-quantitys.h @@ -16,30 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantitys - * The quantitys to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_quantitys_adjust() - */ -#if !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) - extern f_status_t private_f_string_quantitys_adjust(const f_number_unsigned_t length, f_string_quantitys_t * const quantitys) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_quantitys_adjust_) || !defined(_di_f_string_quantitys_decimate_by_) - -/** * Private implementation for appending. * * Intended to be shared to each of the different implementation variations. @@ -57,6 +33,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). * * @see f_memory_resize() + * * @see f_string_quantitys_append_all() * @see f_string_quantityss_append() * @see f_string_quantityss_append_all() @@ -65,32 +42,6 @@ extern "C" { extern f_status_t private_f_string_quantitys_append_all(const f_string_quantitys_t source, f_string_quantitys_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_string_quantitys_append_all_) || !defined(_di_f_string_quantityss_append_) || !defined(_di_f_string_quantityss_append_all_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantitys - * The quantitys to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_quantitys_decrease_by() - * @see f_string_quantitys_increase() - * @see f_string_quantitys_increase_by() - */ -#if !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) - extern f_status_t private_f_string_quantitys_resize(const f_number_unsigned_t length, f_string_quantitys_t * const quantitys) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_quantitys_decrease_by_) || !defined(_di_f_string_quantitys_increase_) || !defined(_di_f_string_quantitys_increase_by_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/private-quantityss.c b/level_0/f_string/c/string/private-quantityss.c index 39995b9..43e9648 100644 --- a/level_0/f_string/c/string/private-quantityss.c +++ b/level_0/f_string/c/string/private-quantityss.c @@ -10,56 +10,30 @@ extern "C" { #if !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) f_status_t private_f_string_quantityss_adjust(const f_number_unsigned_t length, f_string_quantityss_t * const quantityss) { - if (quantityss->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < quantityss->size; ++i) { - status = private_f_string_quantitys_adjust(0, &quantityss->array[i]); + status = f_memory_array_adjust(length, sizeof(f_string_quantitys_t), (void **) &quantityss->array[i].array, &quantityss->array[i].used, &quantityss->array[i].size); if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(quantityss->size, length, sizeof(f_string_quantitys_t), (void **) & quantityss->array); - if (F_status_is_error(status)) return status; - - quantityss->size = length; - - if (quantityss->used > quantityss->size) { - quantityss->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_quantitys_t), (void **) &quantityss->array, &quantityss->used, &quantityss->size); } #endif // !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) #if !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) f_status_t private_f_string_quantityss_resize(const f_number_unsigned_t length, f_string_quantityss_t * const quantityss) { - if (quantityss->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < quantityss->size; ++i) { - status = private_f_string_quantitys_resize(0, &quantityss->array[i]); + status = f_memory_array_resize(0, sizeof(f_string_quantity_t), (void **) &quantityss->array[i].array, &quantityss->array[i].used, &quantityss->array[i].size); if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(quantityss->size, length, sizeof(f_string_quantitys_t), (void **) & quantityss->array); - if (F_status_is_error(status)) return status; - - quantityss->size = length; - - if (quantityss->used > quantityss->size) { - quantityss->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_quantitys_t), (void **) &quantityss->array, &quantityss->used, &quantityss->size); } #endif // !defined(_di_f_string_quantityss_decrease_by_) || !defined(_di_f_string_quantityss_increase_) || !defined(_di_f_string_quantityss_increase_by_) diff --git a/level_0/f_string/c/string/private-quantityss.h b/level_0/f_string/c/string/private-quantityss.h index ea0d1e3..6900746 100644 --- a/level_0/f_string/c/string/private-quantityss.h +++ b/level_0/f_string/c/string/private-quantityss.h @@ -33,6 +33,7 @@ extern "C" { * Errors (with error bit) from: f_memory_adjust(). * * @see f_memory_adjust() + * * @see f_string_quantityss_adjust() */ #if !defined(_di_f_string_quantityss_adjust_) || !defined(_di_f_string_quantityss_decimate_by_) @@ -57,6 +58,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). * * @see f_memory_resize() + * * @see f_string_quantityss_decrease_by() * @see f_string_quantityss_increase() * @see f_string_quantityss_increase_by() diff --git a/level_0/f_string/c/string/private-ranges.c b/level_0/f_string/c/string/private-ranges.c index 248f491..c2e48d5 100644 --- a/level_0/f_string/c/string/private-ranges.c +++ b/level_0/f_string/c/string/private-ranges.c @@ -6,31 +6,11 @@ extern "C" { #endif -#if !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) - f_status_t private_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const ranges) { - - if (ranges->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_adjust(ranges->size, length, sizeof(f_string_range_t), (void **) & ranges->array); - if (F_status_is_error(status)) return status; - - ranges->size = length; - - if (ranges->used > ranges->size) { - ranges->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) - #if !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) f_status_t private_f_string_ranges_append_all(const f_string_ranges_t source, f_string_ranges_t * const destination) { if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_string_ranges_resize(destination->used + source.used, destination); + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_range_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -44,26 +24,6 @@ extern "C" { } #endif // !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) -#if !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) - f_status_t private_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const ranges) { - - if (ranges->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_resize(ranges->size, length, sizeof(f_string_range_t), (void **) & ranges->array); - if (F_status_is_error(status)) return status; - - ranges->size = length; - - if (ranges->used > ranges->size) { - ranges->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/private-ranges.h b/level_0/f_string/c/string/private-ranges.h index d1d3962..f63d42a 100644 --- a/level_0/f_string/c/string/private-ranges.h +++ b/level_0/f_string/c/string/private-ranges.h @@ -16,30 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param ranges - * The ranges to adjust. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_ranges_adjust() - */ -#if !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) - extern f_status_t private_f_string_ranges_adjust(const f_number_unsigned_t length, f_string_ranges_t * const ranges) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_ranges_adjust_) || !defined(_di_f_string_ranges_decimate_by_) - -/** * Private implementation for appending. * * Intended to be shared to each of the different implementation variations. @@ -65,40 +41,6 @@ extern "C" { extern f_status_t private_f_string_ranges_append_all(const f_string_ranges_t source, f_string_ranges_t * const destination) F_attribute_visibility_internal_d; #endif // !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param ranges - * The ranges to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the combined array is too large. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_string_ranges_append() - * @see f_string_ranges_append_all() - * @see f_string_ranges_decrease_by() - * @see f_string_ranges_increase() - * @see f_string_ranges_increase_by() - * @see f_string_ranges_resize() - * @see f_string_rangess_append() - * @see f_string_rangess_append_all() - * @see f_string_rangess_decrease_by() - * @see f_string_rangess_increase() - * @see f_string_rangess_increase_by() - */ -#if !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) - extern f_status_t private_f_string_ranges_resize(const f_number_unsigned_t length, f_string_ranges_t * const ranges) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string/private-rangess.c b/level_0/f_string/c/string/private-rangess.c index b129caf..376f927 100644 --- a/level_0/f_string/c/string/private-rangess.c +++ b/level_0/f_string/c/string/private-rangess.c @@ -10,56 +10,30 @@ extern "C" { #if !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) f_status_t private_f_string_rangess_adjust(const f_number_unsigned_t length, f_string_rangess_t * const rangess) { - if (rangess->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < rangess->size; ++i) { - status = private_f_string_ranges_adjust(0, &rangess->array[i]); + status = f_memory_array_adjust(0, sizeof(f_string_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size); if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(rangess->size, length, sizeof(f_string_ranges_t), (void **) & rangess->array); - if (F_status_is_error(status)) return status; - - rangess->size = length; - - if (rangess->used > rangess->size) { - rangess->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size); } #endif // !defined(_di_f_string_rangess_adjust_) || !defined(_di_f_string_rangess_decimate_by_) #if !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) f_status_t private_f_string_rangess_resize(const f_number_unsigned_t length, f_string_rangess_t * const rangess) { - if (rangess->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < rangess->size; ++i) { - status = private_f_string_ranges_resize(0, &rangess->array[i]); + status = f_memory_array_resize(0, sizeof(f_string_range_t), (void **) &rangess->array[i].array, &rangess->array[i].used, &rangess->array[i].size); if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(rangess->size, length, sizeof(f_string_ranges_t), (void **) & rangess->array); - if (F_status_is_error(status)) return status; - - rangess->size = length; - - if (rangess->used > rangess->size) { - rangess->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_ranges_t), (void **) &rangess->array, &rangess->used, &rangess->size); } #endif // !defined(_di_f_string_ranges_append_) || !defined(_di_f_string_ranges_append_all_) || !defined(_di_f_string_ranges_decrease_by_) || !defined(_di_f_string_ranges_increase_) || !defined(_di_f_string_ranges_increase_by_) || !defined(_di_f_string_ranges_resize_) || !defined(_di_f_string_rangess_append_) || !defined(_di_f_string_rangess_append_all_) || !defined(_di_f_string_rangess_decrease_by_) || !defined(_di_f_string_rangess_increase_) || !defined(_di_f_string_rangess_increase_by_) diff --git a/level_0/f_string/c/string/private-triples.c b/level_0/f_string/c/string/private-triples.c index 8da8f50..6512048 100644 --- a/level_0/f_string/c/string/private-triples.c +++ b/level_0/f_string/c/string/private-triples.c @@ -10,34 +10,21 @@ extern "C" { #if !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) f_status_t private_f_string_triples_adjust(const f_number_unsigned_t length, f_string_triples_t * const triples) { - if (triples->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < triples->size; ++i) { - status = private_f_string_dynamic_adjust(0, &triples->array[i].a); + status = f_memory_array_adjust(0, sizeof(f_string_triple_t), (void **) &triples->array[i].a.string, &triples->array[i].a.used, &triples->array[i].a.size); if (F_status_is_error(status)) return status; - status = private_f_string_dynamic_adjust(0, &triples->array[i].b); + status = f_memory_array_adjust(0, sizeof(f_string_triple_t), (void **) &triples->array[i].b.string, &triples->array[i].b.used, &triples->array[i].b.size); if (F_status_is_error(status)) return status; - status = private_f_string_dynamic_adjust(0, &triples->array[i].c); + status = f_memory_array_adjust(0, sizeof(f_string_triple_t), (void **) &triples->array[i].c.string, &triples->array[i].c.used, &triples->array[i].c.size); if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(triples->size, length, sizeof(f_string_triple_t), (void **) & triples->array); - if (F_status_is_error(status)) return status; - - triples->size = length; - - if (triples->used > triples->size) { - triples->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_triple_t), (void **) &triples->array, &triples->used, &triples->size); } #endif // !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) @@ -80,34 +67,21 @@ extern "C" { #if !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) f_status_t private_f_string_triples_resize(const f_number_unsigned_t length, f_string_triples_t * const triples) { - if (triples->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < triples->size; ++i) { - status = private_f_string_dynamic_resize(0, &triples->array[i].a); + status = f_memory_array_resize(0, sizeof(f_string_triple_t), (void **) &triples->array[i].a.string, &triples->array[i].a.used, &triples->array[i].a.size); if (F_status_is_error(status)) return status; - status = private_f_string_dynamic_resize(0, &triples->array[i].b); + status = f_memory_array_resize(0, sizeof(f_string_triple_t), (void **) &triples->array[i].b.string, &triples->array[i].b.used, &triples->array[i].b.size); if (F_status_is_error(status)) return status; - status = private_f_string_dynamic_resize(0, &triples->array[i].c); + status = f_memory_array_resize(0, sizeof(f_string_triple_t), (void **) &triples->array[i].c.string, &triples->array[i].c.used, &triples->array[i].c.size); if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(triples->size, length, sizeof(f_string_triple_t), (void **) & triples->array); - if (F_status_is_error(status)) return status; - - triples->size = length; - - if (triples->used > triples->size) { - triples->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_triple_t), (void **) &triples->array, &triples->used, &triples->size); } #endif // !defined(_di_f_string_triples_decrease_by_) || !defined(_di_f_string_triples_increase_) || !defined(_di_f_string_triples_increase_by_) diff --git a/level_0/f_string/c/string/private-triples.h b/level_0/f_string/c/string/private-triples.h index 1140787..fb553ac 100644 --- a/level_0/f_string/c/string/private-triples.h +++ b/level_0/f_string/c/string/private-triples.h @@ -45,7 +45,7 @@ extern "C" { * Intended to be shared to each of the different implementation variations. * * @param source - * The source triples to append. + * The source destination to append. * @param destination * The destination triples the source is appended onto. * diff --git a/level_0/f_string/c/string/private-tripless.c b/level_0/f_string/c/string/private-tripless.c index 7061fc6..24eca73 100644 --- a/level_0/f_string/c/string/private-tripless.c +++ b/level_0/f_string/c/string/private-tripless.c @@ -11,10 +11,6 @@ extern "C" { #if !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) f_status_t private_f_string_tripless_adjust(const f_number_unsigned_t length, f_string_tripless_t * const tripless) { - if (tripless->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < tripless->size; ++i) { @@ -23,26 +19,13 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_adjust(tripless->size, length, sizeof(f_string_triples_t), (void **) & tripless->array); - if (F_status_is_error(status)) return status; - - tripless->size = length; - - if (tripless->used > tripless->size) { - tripless->used = length; - } - - return F_none; + return f_memory_array_adjust(length, sizeof(f_string_triples_t), (void **) &tripless->array, &tripless->used, &tripless->size); } #endif // !defined(_di_f_string_tripless_adjust_) || !defined(_di_f_string_tripless_decimate_by_) #if !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) f_status_t private_f_string_tripless_resize(const f_number_unsigned_t length, f_string_tripless_t * const tripless) { - if (tripless->used + length > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - f_status_t status = F_none; for (f_number_unsigned_t i = length; i < tripless->size; ++i) { @@ -51,16 +34,7 @@ extern "C" { if (F_status_is_error(status)) return status; } // for - status = f_memory_resize(tripless->size, length, sizeof(f_string_triples_t), (void **) & tripless->array); - if (F_status_is_error(status)) return status; - - tripless->size = length; - - if (tripless->used > tripless->size) { - tripless->used = length; - } - - return F_none; + return f_memory_array_resize(length, sizeof(f_string_triples_t), (void **) &tripless->array, &tripless->used, &tripless->size); } #endif // !defined(_di_f_string_tripless_decrease_by_) || !defined(_di_f_string_tripless_increase_) || !defined(_di_f_string_tripless_increase_by_) diff --git a/level_0/f_string/c/string/quantitys.c b/level_0/f_string/c/string/quantitys.c index 0c9289e..d1403ee 100644 --- a/level_0/f_string/c/string/quantitys.c +++ b/level_0/f_string/c/string/quantitys.c @@ -12,7 +12,7 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_quantitys_adjust(length, quantitys); + return f_memory_array_adjust(length, sizeof(f_string_quantity_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); } #endif // _di_f_string_quantitys_adjust_ @@ -23,7 +23,7 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_string_quantitys_resize(destination->used + F_memory_default_allocation_small_d, destination); + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_quantity_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -52,13 +52,7 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (quantitys->size > amount) { - return private_f_string_quantitys_adjust(quantitys->size - amount, quantitys); - } - - return private_f_string_quantitys_adjust(0, quantitys); + return f_memory_array_decimate_by(amount, sizeof(f_string_quantity_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); } #endif // _di_f_string_quantitys_decimate_by_ @@ -68,13 +62,8 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (quantitys->size > amount) { - return private_f_string_quantitys_resize(quantitys->size - amount, quantitys); - } - return private_f_string_quantitys_resize(0, quantitys); + return f_memory_array_decrease_by(amount, sizeof(f_string_quantity_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); } #endif // _di_f_string_quantitys_decrease_by_ @@ -84,21 +73,7 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && quantitys->used + 1 > quantitys->size) { - f_number_unsigned_t size = quantitys->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (quantitys->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_number_t_size_unsigned_d; - } - - return private_f_string_quantitys_resize(size, quantitys); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_string_quantity_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); } #endif // _di_f_string_quantitys_increase_ @@ -108,19 +83,7 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (amount) { - if (quantitys->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = quantitys->used + amount; - - if (length > quantitys->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - return private_f_string_quantitys_resize(length, quantitys); - } - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_string_quantity_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); } #endif // _di_f_string_quantitys_increase_by_ @@ -130,7 +93,7 @@ extern "C" { if (!quantitys) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_quantitys_resize(length, quantitys); + return f_memory_array_resize(length, sizeof(f_string_quantity_t), (void **) &quantitys->array, &quantitys->used, &quantitys->size); } #endif // _di_f_string_quantitys_resize_ diff --git a/level_0/f_string/c/string/quantityss.c b/level_0/f_string/c/string/quantityss.c index 261acb2..07c6950 100644 --- a/level_0/f_string/c/string/quantityss.c +++ b/level_0/f_string/c/string/quantityss.c @@ -82,11 +82,7 @@ extern "C" { if (!amount) return F_data_not; - if (quantityss->size > amount) { - return private_f_string_quantityss_adjust(quantityss->size - amount, quantityss); - } - - return private_f_string_quantityss_adjust(0, quantityss); + return private_f_string_quantityss_adjust((quantityss->size > amount) ? quantityss->size - amount : 0, quantityss); } #endif // _di_f_string_quantityss_decimate_by_ @@ -98,11 +94,7 @@ extern "C" { if (!amount) return F_data_not; - if (quantityss->size > amount) { - return private_f_string_quantityss_resize(quantityss->size - amount, quantityss); - } - - return private_f_string_quantityss_resize(0, quantityss); + return private_f_string_quantityss_resize((quantityss->size > amount) ? quantityss->size - amount : 0, quantityss); } #endif // _di_f_string_quantityss_decrease_by_ @@ -116,9 +108,7 @@ extern "C" { f_number_unsigned_t size = quantityss->used + step; if (size > F_number_t_size_unsigned_d) { - if (quantityss->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (quantityss->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/ranges.c b/level_0/f_string/c/string/ranges.c index 19678ca..aedd32e 100644 --- a/level_0/f_string/c/string/ranges.c +++ b/level_0/f_string/c/string/ranges.c @@ -12,7 +12,7 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_ranges_adjust(length, ranges); + return f_memory_array_adjust(length, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); } #endif // _di_f_string_ranges_adjust_ @@ -22,8 +22,8 @@ extern "C" { if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (destination->used + 1 > destination->size) { - const f_status_t status = private_f_string_ranges_resize(destination->used + F_memory_default_allocation_small_d, destination); + { + const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_string_range_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -42,8 +42,8 @@ extern "C" { if (!source.used) return F_data_not; - if (destination->used + source.used > destination->size) { - const f_status_t status = private_f_string_ranges_resize(destination->used + source.used, destination); + { + const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_string_range_t), (void **) &destination->array, &destination->used, &destination->size); if (F_status_is_error(status)) return status; } @@ -65,11 +65,7 @@ extern "C" { if (!amount) return F_data_not; - if (ranges->size > amount) { - return private_f_string_ranges_adjust(ranges->size - amount, ranges); - } - - return private_f_string_ranges_adjust(0, ranges); + return f_memory_array_decimate_by(amount, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); } #endif // _di_f_string_ranges_decimate_by_ @@ -79,13 +75,7 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!amount) return F_data_not; - - if (ranges->size > amount) { - return private_f_string_ranges_resize(ranges->size - amount, ranges); - } - - return private_f_string_ranges_resize(0, ranges); + return f_memory_array_decrease_by(amount, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); } #endif // _di_f_string_ranges_decrease_by_ @@ -95,21 +85,7 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (step && ranges->used + 1 > ranges->size) { - f_number_unsigned_t size = ranges->used + step; - - if (size > F_number_t_size_unsigned_d) { - if (ranges->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } - - size = F_number_t_size_unsigned_d; - } - - return private_f_string_ranges_resize(size, ranges); - } - - return F_data_not; + return f_memory_array_increase(step, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); } #endif // _di_f_string_ranges_increase_ @@ -119,19 +95,7 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (amount) { - if (ranges->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = ranges->used + amount; - - if (length > ranges->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - return private_f_string_ranges_resize(length, ranges); - } - } - - return F_data_not; + return f_memory_array_increase_by(amount, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); } #endif // _di_f_string_ranges_increase_by_ @@ -141,7 +105,7 @@ extern "C" { if (!ranges) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_ranges_resize(length, ranges); + return f_memory_array_resize(length, sizeof(f_string_range_t), (void **) &ranges->array, &ranges->used, &ranges->size); } #endif // _di_f_string_ranges_resize_ diff --git a/level_0/f_string/c/string/rangess.c b/level_0/f_string/c/string/rangess.c index 026da0b..324739c 100644 --- a/level_0/f_string/c/string/rangess.c +++ b/level_0/f_string/c/string/rangess.c @@ -82,11 +82,7 @@ extern "C" { if (!amount) return F_data_not; - if (rangess->size > amount) { - return private_f_string_rangess_adjust(rangess->size - amount, rangess); - } - - return private_f_string_rangess_adjust(0, rangess); + return private_f_string_rangess_adjust((rangess->size > amount) ? rangess->size - amount : 0, rangess); } #endif // _di_f_string_rangess_decimate_by_ @@ -98,11 +94,7 @@ extern "C" { if (!amount) return F_data_not; - if (rangess->size > amount) { - return private_f_string_rangess_resize(rangess->size - amount, rangess); - } - - return private_f_string_rangess_resize(0, rangess); + return private_f_string_rangess_resize((rangess->size > amount) ? rangess->size - amount : 0, rangess); } #endif // _di_f_string_rangess_decrease_by_ @@ -116,9 +108,7 @@ extern "C" { f_number_unsigned_t size = rangess->used + step; if (size > F_number_t_size_unsigned_d) { - if (rangess->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (rangess->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/triples.c b/level_0/f_string/c/string/triples.c index c65e00b..39ea8de 100644 --- a/level_0/f_string/c/string/triples.c +++ b/level_0/f_string/c/string/triples.c @@ -101,11 +101,9 @@ extern "C" { if (!triples) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (triples->size > amount) { - return private_f_string_triples_adjust(triples->size - amount, triples); - } + if (!amount) return F_data_not; - return private_f_string_triples_adjust(0, triples); + return private_f_string_triples_adjust((triples->size > amount) ? triples->size - amount : 0, triples); } #endif // _di_f_string_triples_decimate_by_ @@ -117,11 +115,7 @@ extern "C" { if (!amount) return F_data_not; - if (triples->size > amount) { - return private_f_string_triples_resize(triples->size - amount, triples); - } - - return private_f_string_triples_resize(0, triples); + return private_f_string_triples_resize((triples->size > amount) ? triples->size - amount : 0, triples); } #endif // _di_f_string_triples_decrease_by_ @@ -135,9 +129,7 @@ extern "C" { f_number_unsigned_t size = triples->used + F_memory_default_allocation_small_d; if (size > F_number_t_size_unsigned_d) { - if (triples->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (triples->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_string/c/string/tripless.c b/level_0/f_string/c/string/tripless.c index d1cee99..196f172 100644 --- a/level_0/f_string/c/string/tripless.c +++ b/level_0/f_string/c/string/tripless.c @@ -82,11 +82,7 @@ extern "C" { if (!amount) return F_data_not; - if (tripless->size > amount) { - return private_f_string_tripless_adjust(tripless->size - amount, tripless); - } - - return private_f_string_tripless_adjust(0, tripless); + return private_f_string_tripless_adjust((tripless->size > amount) ? tripless->size - amount : 0, tripless); } #endif // _di_f_string_tripless_decimate_by_ @@ -98,11 +94,7 @@ extern "C" { if (!amount) return F_data_not; - if (tripless->size > amount) { - return private_f_string_tripless_resize(tripless->size - amount, tripless); - } - - return private_f_string_tripless_resize(0, tripless); + return private_f_string_tripless_resize((tripless->size > amount) ? tripless->size - amount : 0, tripless); } #endif // _di_f_string_tripless_decrease_by_ @@ -116,9 +108,7 @@ extern "C" { f_number_unsigned_t size = tripless->used + step; if (size > F_number_t_size_unsigned_d) { - if (tripless->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (tripless->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_thread/c/private-thread.c b/level_0/f_thread/c/private-thread.c deleted file mode 100644 index 974c774..0000000 --- a/level_0/f_thread/c/private-thread.c +++ /dev/null @@ -1,896 +0,0 @@ -#include "thread.h" -#include "private-thread.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_attributes_resize_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !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_) || !defined(_di_f_thread_sets_resize_) - f_status_t private_f_thread_attribute_delete(f_thread_attribute_t *attribute) { - - if (pthread_attr_destroy(attribute)) { - return F_status_set_error(F_failure); - } - - attribute = 0; - - return F_none; - } -#endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_attributes_resize_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !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_) || !defined(_di_f_thread_sets_resize_) - -#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) - f_status_t private_f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_attribute_delete(&attributes->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(attributes->size, length, sizeof(f_thread_attribute_t), (void **) & attributes->array); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) - -#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_number_unsigned_t length, f_thread_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_attribute_delete(&attributes->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(attributes->size, length, sizeof(f_thread_attribute_t), (void **) & attributes->array); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#endif // !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_) - -#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) - f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *barrier) { - - const int error = pthread_barrier_destroy(barrier); - - if (error) { - if (error == EBUSY) return F_status_set_error(F_busy); - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - barrier = 0; - - return F_none; - } -#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) - -#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) - f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < barriers->size; ++i) { - - status = private_f_thread_barrier_delete(&barriers->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(barriers->size, length, sizeof(f_thread_barrier_t), (void **) & barriers->array); - if (F_status_is_error(status)) return status; - - barriers->size = length; - - if (barriers->used > barriers->size) { - barriers->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) - -#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_number_unsigned_t length, f_thread_barriers_t * const barriers) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < barriers->size; ++i) { - - status = private_f_thread_barrier_delete(&barriers->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(barriers->size, length, sizeof(f_thread_barrier_t), (void **) & barriers->array); - if (F_status_is_error(status)) return status; - - barriers->size = length; - - if (barriers->used > barriers->size) { - barriers->used = length; - } - - return F_none; - } -#endif // !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_) - -#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) - f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *attribute) { - - if (pthread_barrierattr_destroy(attribute)) { - return F_status_set_error(F_failure); - } - - attribute = 0; - - return F_none; - } -#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) - -#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_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_barrier_attribute_delete(&attributes->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(attributes->size, length, sizeof(f_thread_barrier_attribute_t), (void **) & attributes->array); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) - -#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_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_barrier_attribute_delete(&attributes->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(attributes->size, length, sizeof(f_thread_barrier_attribute_t), (void **) & attributes->array); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#endif // !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_) - -#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) - f_status_t private_f_thread_condition_attribute_delete(f_thread_condition_attribute_t * const attribute) { - - const int error = pthread_condattr_destroy(attribute); - - if (error) { - if (error == EBUSY) return F_status_set_error(F_busy); - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) - -#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_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_condition_attribute_delete(&attributes->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(attributes->size, length, sizeof(f_thread_condition_attribute_t), (void **) & attributes->array); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) - -#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_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_condition_attribute_delete(&attributes->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(attributes->size, length, sizeof(f_thread_condition_attribute_t), (void **) & attributes->array); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#endif // !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_) - -#if !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !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_) || !defined(_di_f_thread_conditions_resize_) - f_status_t private_f_thread_condition_delete(f_thread_condition_t *condition) { - - const int error = pthread_cond_destroy(condition); - - if (error) { - if (error == EBUSY) return F_status_set_error(F_busy); - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !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_) || !defined(_di_f_thread_conditions_resize_) - -#if !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) - f_status_t private_f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < conditions->size; ++i) { - - status = private_f_thread_condition_delete(&conditions->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(conditions->size, length, sizeof(f_thread_condition_t), (void **) & conditions->array); - if (F_status_is_error(status)) return status; - - conditions->size = length; - - if (conditions->used > conditions->size) { - conditions->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) - -#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_number_unsigned_t length, f_thread_conditions_t * const conditions) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < conditions->size; ++i) { - - status = private_f_thread_condition_delete(&conditions->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(conditions->size, length, sizeof(f_thread_condition_t), (void **) & conditions->array); - if (F_status_is_error(status)) return status; - - conditions->size = length; - - if (conditions->used > conditions->size) { - conditions->used = length; - } - - return F_none; - } -#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_number_unsigned_t length, f_thread_ids_t * const ids) { - - f_status_t status = F_none; - - for (f_number_unsigned_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_number_unsigned_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 (pthread_key_delete(*key)) { - return F_status_set_error(F_failure); - } - - *key = 0; - - return F_none; - } -#endif // !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_) - -#if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) - f_status_t private_f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const keys) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < keys->size; ++i) { - - status = private_f_thread_key_delete(&keys->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(keys->size, length, sizeof(f_thread_key_t), (void **) & keys->array); - if (F_status_is_error(status)) return status; - - keys->size = length; - - if (keys->used > keys->size) { - keys->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) - -#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_number_unsigned_t length, f_thread_keys_t * const keys) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < keys->size; ++i) { - - status = private_f_thread_key_delete(&keys->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(keys->size, length, sizeof(f_thread_key_t), (void **) & keys->array); - if (F_status_is_error(status)) return status; - - keys->size = length; - - if (keys->used > keys->size) { - keys->used = length; - } - - return F_none; - } -#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_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_rwlockattr_destroy(attribute); - - if (error) { - if (error == EBUSY) return F_status_set_error(F_busy); - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - 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_) - -#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_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_lock_attribute_delete(&attributes->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); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#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_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_lock_attribute_delete(&attributes->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); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->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_) - -#if !defined(_di_f_thread_lock_delete_) || !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_rwlock_destroy(lock); - - if (error) { - if (error == EBUSY) return F_status_set_error(F_busy); - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // !defined(_di_f_thread_lock_delete_) || !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_number_unsigned_t length, f_thread_locks_t * const locks) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < locks->size; ++i) { - - status = private_f_thread_lock_delete(&locks->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); - if (F_status_is_error(status)) return status; - - locks->size = length; - - if (locks->used > locks->size) { - locks->used = length; - } - - return F_none; - } -#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_number_unsigned_t length, f_thread_locks_t * const locks) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < locks->size; ++i) { - - status = private_f_thread_lock_delete(&locks->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); - if (F_status_is_error(status)) return status; - - locks->size = length; - - if (locks->used > locks->size) { - locks->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_) - -#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) { - - const int error = pthread_mutexattr_destroy(attribute); - - if (error) { - if (error == EBUSY) return F_status_set_error(F_busy); - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // !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_) - -#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_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_mutex_attribute_delete(&attributes->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(attributes->size, length, sizeof(f_thread_mutex_t), (void **) & attributes->array); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) - -#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_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < attributes->size; ++i) { - - status = private_f_thread_mutex_attribute_delete(&attributes->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(attributes->size, length, sizeof(f_thread_mutex_t), (void **) & attributes->array); - if (F_status_is_error(status)) return status; - - attributes->size = length; - - if (attributes->used > attributes->size) { - attributes->used = length; - } - - return F_none; - } -#endif // !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_) - - -#if !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !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_) || !defined(_di_f_thread_mutexs_resize_) - f_status_t private_f_thread_mutex_delete(f_thread_mutex_t *mutex) { - - const int error = pthread_mutex_destroy(mutex); - - if (error) { - if (error == EBUSY) return F_status_set_error(F_busy); - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !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_) || !defined(_di_f_thread_mutexs_resize_) - -#if !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) - f_status_t private_f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < mutexs->size; ++i) { - - status = private_f_thread_mutex_delete(&mutexs->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(mutexs->size, length, sizeof(f_thread_mutex_t), (void **) & mutexs->array); - if (F_status_is_error(status)) return status; - - mutexs->size = length; - - if (mutexs->used > mutexs->size) { - mutexs->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) - -#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_number_unsigned_t length, f_thread_mutexs_t * const mutexs) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < mutexs->size; ++i) { - - status = private_f_thread_mutex_delete(&mutexs->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(mutexs->size, length, sizeof(f_thread_mutex_t), (void **) & mutexs->array); - if (F_status_is_error(status)) return status; - - mutexs->size = length; - - if (mutexs->used > mutexs->size) { - mutexs->used = length; - } - - return F_none; - } -#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_number_unsigned_t length, f_thread_onces_t * const onces) { - - for (f_number_unsigned_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_number_unsigned_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) { - - const int result = sem_destroy(semaphore); - - if (result == -1) { - if (errno == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // !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_) - -#if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) - f_status_t private_f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < semaphores->size; ++i) { - - status = private_f_thread_semaphore_delete(&semaphores->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(semaphores->size, length, sizeof(f_thread_semaphore_t), (void **) & semaphores->array); - - if (F_status_is_error_not(status)) { - semaphores->size = length; - - if (semaphores->used > semaphores->size) { - semaphores->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) - -#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_number_unsigned_t length, f_thread_semaphores_t * const semaphores) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < semaphores->size; ++i) { - - status = private_f_thread_semaphore_delete(&semaphores->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(semaphores->size, length, sizeof(f_thread_semaphore_t), (void **) & semaphores->array); - if (F_status_is_error(status)) return status; - - semaphores->size = length; - - if (semaphores->used > semaphores->size) { - semaphores->used = length; - } - - return F_none; - } -#endif // !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_) - -#if !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) - f_status_t private_f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const sets) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < sets->size; ++i) { - - status = private_f_thread_attribute_delete(&sets->array[i].attribute); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(sets->size, length, sizeof(f_thread_set_t), (void **) & sets->array); - if (F_status_is_error(status)) return status; - - sets->size = length; - - if (sets->used > sets->size) { - sets->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) - -#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_number_unsigned_t length, f_thread_sets_t * const sets) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < sets->size; ++i) { - - status = private_f_thread_attribute_delete(&sets->array[i].attribute); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(sets->size, length, sizeof(f_thread_set_t), (void **) & sets->array); - if (F_status_is_error(status)) return status; - - sets->size = length; - - if (sets->used > sets->size) { - sets->used = length; - } - - return F_none; - } -#endif // !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_) - -#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) - f_status_t private_f_thread_spin_delete(f_thread_spin_t *spin) { - - const int error = pthread_spin_destroy(spin); - - if (error) { - if (error == EBUSY) return F_status_set_error(F_busy); - if (error == EINVAL) return F_status_set_error(F_parameter); - - return F_status_set_error(F_failure); - } - - return F_none; - } -#endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) - -#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) - f_status_t private_f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const spins) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < spins->size; ++i) { - - status = private_f_thread_spin_delete(&spins->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(spins->size, length, sizeof(f_thread_spin_t), (void **) & spins->array); - if (F_status_is_error(status)) return status; - - spins->size = length; - - if (spins->used > spins->size) { - spins->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) - -#if !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) - f_status_t private_f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const spins) { - - f_status_t status = F_none; - - for (f_number_unsigned_t i = length; i < spins->size; ++i) { - - status = private_f_thread_spin_delete(&spins->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(spins->size, length, sizeof(f_thread_spin_t), (void **) & spins->array); - if (F_status_is_error(status)) return status; - - spins->size = length; - - if (spins->used > spins->size) { - spins->used = length; - } - - return F_none; - } -#endif // !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/c/private-thread.h b/level_0/f_thread/c/private-thread.h deleted file mode 100644 index 4472d29..0000000 --- a/level_0/f_thread/c/private-thread.h +++ /dev/null @@ -1,1094 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * These are provided for internal reduction in redundant code. - * These should not be exposed/used outside of this project. - */ -#ifndef _PRIVATE_F_thread_h -#define _PRIVATE_F_thread_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Private implementation for deleting (and destroying). - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param attributes - * The attributes to adjust. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_attr_destroy() - * - * @see f_thread_attributes_adjust() - * @see f_thread_attributes_decimate_by() - * @see f_thread_attributes_decrease() - * @see f_thread_attributes_decrease_by() - * @see f_thread_attributes_increase() - * @see f_thread_attributes_increase_by() - * @see f_thread_attributes_resize() - * @see f_thread_sets_adjust() - * @see f_thread_sets_decimate_by() - * @see f_thread_sets_decrease() - * @see f_thread_sets_decrease_by() - * @see f_thread_sets_increase() - * @see f_thread_sets_increase_by() - * @see f_thread_sets_resize() - */ -#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_attributes_resize_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !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_) || !defined(_di_f_thread_sets_resize_) - extern f_status_t private_f_thread_attribute_delete(f_thread_attribute_t *attribute) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !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_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @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_attributes_adjust() - * @see f_thread_attributes_decimate_by() - */ -#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) - extern f_status_t private_f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const attributes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_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 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_attributes_decrease_by() - * @see f_thread_attributes_increase() - * @see f_thread_attributes_increase_by() - */ -#if !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_) - extern f_status_t private_f_thread_attributes_resize(const f_number_unsigned_t length, f_thread_attributes_t * const attributes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_) - -/** - * Private implementation for deleting (and destroying). - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param barriers - * The barriers to adjust. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_attr_destroy() - * - * @see f_thread_barriers_adjust() - * @see f_thread_barriers_decimate_by() - * @see f_thread_barriers_decrease() - * @see f_thread_barriers_decrease_by() - * @see f_thread_barriers_increase() - * @see f_thread_barriers_increase_by() - * @see f_thread_barriers_resize() - */ -#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) - extern f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *barrier) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param barriers - * The barriers to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_barriers_adjust() - * @see f_thread_barriers_decimate_by() - */ -#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) - extern f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_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 barriers - * The barriers to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_barriers_decrease_by() - * @see f_thread_barriers_increase() - * @see f_thread_barriers_increase_by() - */ -#if !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) - extern f_status_t private_f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) - -/** - * Private implementation for deleting (and destroying). - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param attributes - * The attributes to adjust. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_attr_destroy() - * - * @see f_thread_barrier_attributes_adjust() - * @see f_thread_barrier_attributes_decimate_by() - * @see f_thread_barrier_attributes_decrease() - * @see f_thread_barrier_attributes_decrease_by() - * @see f_thread_barrier_attributes_increase() - * @see f_thread_barrier_attributes_increase_by() - * @see f_thread_barrier_attributes_resize() - */ -#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) - extern f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *attribute) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @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_barrier_attributes_adjust() - * @see f_thread_barrier_attributes_decimate_by() - */ -#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) - extern f_status_t private_f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_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 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_barrier_attributes_decrease_by() - * @see f_thread_barrier_attributes_increase() - * @see f_thread_barrier_attributes_increase_by() - */ -#if !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) - extern f_status_t private_f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) - -/** - * Private implementation for deleting (and destroying). - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param attribute - * The attribute to adjust. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_condattr_destroy() - * - * @see f_thread_condition_attributes_adjust() - * @see f_thread_condition_attributes_decimate_by() - * @see f_thread_condition_attributes_decrease() - * @see f_thread_condition_attributes_decrease_by() - * @see f_thread_condition_attributes_increase() - * @see f_thread_condition_attributes_increase_by() - * @see f_thread_condition_attributes_resize() - */ -#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) - extern f_status_t private_f_thread_condition_attribute_delete(f_thread_condition_attribute_t *attribute) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @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_condition_attributes_adjust() - * @see f_thread_condition_attributes_decimate_by() - */ -#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) - extern f_status_t private_f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_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 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_condition_attributes_decrease_by() - * @see f_thread_condition_attributes_increase() - * @see f_thread_condition_attributes_increase_by() - */ -#if !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) - extern f_status_t private_f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) - -/** - * Private implementation for deleting (and destroying). - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param conditions - * The conditions to adjust. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_cond_destroy() - * - * @see f_thread_condition_delete() - * @see f_thread_conditions_adjust() - * @see f_thread_conditions_decimate_by() - * @see f_thread_conditions_decrease() - * @see f_thread_conditions_decrease_by() - * @see f_thread_conditions_increase() - * @see f_thread_conditions_increase_by() - * @see f_thread_conditions_resize() - */ -#if !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !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_) || !defined(_di_f_thread_conditions_resize_) - extern f_status_t private_f_thread_condition_delete(f_thread_condition_t *condition) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !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_) || !defined(_di_f_thread_conditions_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param conditions - * The conditions to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_conditions_adjust() - * @see f_thread_conditions_decimate_by() - */ -#if !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) - extern f_status_t private_f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_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 conditions - * The conditions to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_conditions_decrease_by() - * @see f_thread_conditions_increase() - * @see f_thread_conditions_increase_by() - */ -#if !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) - extern f_status_t private_f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) F_attribute_visibility_internal_d; -#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_number_unsigned_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_number_unsigned_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. - * - * @param key - * The keys to delete. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_key_destroy() - * - * @see f_thread_keys_adjust() - * @see f_thread_keys_decimate_by() - * @see f_thread_keys_decrease() - * @see f_thread_keys_decrease_by() - * @see f_thread_keys_increase() - * @see f_thread_keys_increase_by() - * @see f_thread_keys_resize() - */ -#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_) - extern f_status_t private_f_thread_key_delete(f_thread_key_t *key) F_attribute_visibility_internal_d; -#endif // !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_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param keys - * The keys to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_keys_adjust() - * @see f_thread_keys_decimate_by() - */ -#if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) - extern f_status_t private_f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const keys) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_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 keys - * The keys to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_keys_decrease_by() - * @see f_thread_keys_increase() - * @see f_thread_keys_increase_by() - */ -#if !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) - extern f_status_t private_f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const keys) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_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. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_rwlockattr_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() - */ -#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. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @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_lock_attributes_adjust() - * @see f_thread_lock_attributes_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_number_unsigned_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. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @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_lock_attributes_decrease_by() - * @see f_thread_lock_attributes_increase() - * @see f_thread_lock_attributes_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_number_unsigned_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 lock - * The locks to delete. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_rwlock_destroy() - * - * @see f_thread_lock_delete() - * @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_delete_) || !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_lock_delete_) || !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. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @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_locks_adjust() - * @see f_thread_locks_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_number_unsigned_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. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @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_locks_decrease_by() - * @see f_thread_locks_increase() - * @see f_thread_locks_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_number_unsigned_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). - * - * Intended to be shared to each of the different implementation variations. - * - * @param attribute - * The attribute to delete. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_mutexattr_destroy() - * - * @see f_thread_mutex_attributes_adjust() - * @see f_thread_mutex_attributes_decimate_by() - * @see f_thread_mutex_attributes_decrease() - * @see f_thread_mutex_attributes_decrease_by() - * @see f_thread_mutex_attributes_increase() - * @see f_thread_mutex_attributes_increase_by() - * @see f_thread_mutex_attributes_resize() - */ -#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_) - extern f_status_t private_f_thread_mutex_attribute_delete(f_thread_mutex_attribute_t *attribute) F_attribute_visibility_internal_d; -#endif // !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_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @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_mutex_attributes_adjust() - * @see f_thread_mutex_attributes_decimate_by() - */ -#if !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) - extern f_status_t private_f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_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 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_mutex_attributes_decrease_by() - * @see f_thread_mutex_attributes_increase() - * @see f_thread_mutex_attributes_increase_by() - */ -#if !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) - extern f_status_t private_f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) - -/** - * Private implementation for deleting (and destroying). - * - * Intended to be shared to each of the different implementation variations. - * - * @param mutex - * The mutexs to delete. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_mutex_destroy() - * - * @see f_thread_mutex_delete() - * @see f_thread_mutexs_adjust() - * @see f_thread_mutexs_decimate_by() - * @see f_thread_mutexs_decrease() - * @see f_thread_mutexs_decrease_by() - * @see f_thread_mutexs_increase() - * @see f_thread_mutexs_increase_by() - * @see f_thread_mutexs_resize() - */ -#if !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !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_) || !defined(_di_f_thread_mutexs_resize_) - extern f_status_t private_f_thread_mutex_delete(f_thread_mutex_t *mutex) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !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_) || !defined(_di_f_thread_mutexs_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param mutexs - * The mutexs to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_mutexs_adjust() - * @see f_thread_mutexs_decimate_by() - */ -#if !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) - extern f_status_t private_f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_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 mutexs - * The mutexs to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_mutexs_decrease_by() - * @see f_thread_mutexs_increase() - * @see f_thread_mutexs_increase_by() - */ -#if !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) - extern f_status_t private_f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) F_attribute_visibility_internal_d; -#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_number_unsigned_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_number_unsigned_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. - * - * @param semaphore - * The semaphores to delete. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see sem_destroy() - * - * @see f_thread_semaphores_adjust() - * @see f_thread_semaphores_decimate_by() - * @see f_thread_semaphores_decrease() - * @see f_thread_semaphores_decrease_by() - * @see f_thread_semaphores_increase() - * @see f_thread_semaphores_increase_by() - * @see f_thread_semaphores_resize() - */ -#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_) - extern f_status_t private_f_thread_semaphore_delete(f_thread_semaphore_t *semaphore) F_attribute_visibility_internal_d; -#endif // !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_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param semaphores - * The semaphores to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_semaphores_adjust() - * @see f_thread_semaphores_decimate_by() - */ -#if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) - extern f_status_t private_f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_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 semaphores - * The semaphores to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_semaphores_decrease_by() - * @see f_thread_semaphores_increase() - * @see f_thread_semaphores_increase_by() - */ -#if !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) - extern f_status_t private_f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_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 sets - * The sets to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_sets_adjust() - * @see f_thread_sets_decimate_by() - */ -#if !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) - extern f_status_t private_f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const sets) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_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 sets - * The sets to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_sets_decrease_by() - * @see f_thread_sets_increase() - * @see f_thread_sets_increase_by() - */ -#if !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) - extern f_status_t private_f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const sets) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) - -/** - * Private implementation for deleting (and destroying). - * - * Intended to be shared to each of the different implementation variations. - * - * @param spin - * The spins to delete. - * - * @return - * F_none on success. - * - * F_busy (with error bit) if the lock is busy. - * F_failure (with error bit) on error. - * F_parameter (with error bit) if a parameter is invalid. - * - * @see pthread_spin_destroy() - * - * @see f_thread_spins_adjust() - * @see f_thread_spins_decimate_by() - * @see f_thread_spins_decrease() - * @see f_thread_spins_decrease_by() - * @see f_thread_spins_increase() - * @see f_thread_spins_increase_by() - * @see f_thread_spins_resize() - */ -#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) - extern f_status_t private_f_thread_spin_delete(f_thread_spin_t *spin) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param spins - * The spins to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_thread_spins_adjust() - * @see f_thread_spins_decimate_by() - */ -#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) - extern f_status_t private_f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const spins) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_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 spins - * The spins to resize. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_resize(). - * - * @see f_memory_resize() - * @see f_thread_spins_decrease_by() - * @see f_thread_spins_increase() - * @see f_thread_spins_increase_by() - */ -#if !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) - extern f_status_t private_f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const spins) F_attribute_visibility_internal_d; -#endif // !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_thread_h diff --git a/level_0/f_thread/c/thread.c b/level_0/f_thread/c/thread.c index c57b6d9..12eee62 100644 --- a/level_0/f_thread/c/thread.c +++ b/level_0/f_thread/c/thread.c @@ -1,5 +1,15 @@ #include "thread.h" -#include "private-thread.h" +#include "thread/private-attribute.h" +#include "thread/private-barrier_attribute.h" +#include "thread/private-condition.h" +#include "thread/private-condition_attribute.h" +#include "thread/private-key.h" +#include "thread/private-lock.h" +#include "thread/private-lock_attribute.h" +#include "thread/private-mutex.h" +#include "thread/private-mutex_attribute.h" +#include "thread/private-semaphore.h" +#include "thread/private-spin.h" #ifdef __cplusplus extern "C" { diff --git a/level_0/f_thread/c/thread/attribute.c b/level_0/f_thread/c/thread/attribute.c index c31f367..19866d2 100644 --- a/level_0/f_thread/c/thread/attribute.c +++ b/level_0/f_thread/c/thread/attribute.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-attribute.h" #include "attribute.h" #ifdef __cplusplus @@ -24,11 +24,7 @@ extern "C" { if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_attributes_adjust(attributes->size - amount, attributes); - } - - return private_f_thread_attributes_adjust(0, attributes); + return private_f_thread_attributes_adjust((attributes->size > amount) ? attributes->size - amount : 0, attributes); } #endif // _di_f_thread_attributes_decimate_by_ @@ -40,11 +36,7 @@ extern "C" { if (!amount) return F_data_not; - if (attributes->size > amount) { - return private_f_thread_attributes_resize(attributes->size - amount, attributes); - } - - return private_f_thread_attributes_resize(0, attributes); + return private_f_thread_attributes_resize((attributes->size > amount) ? attributes->size - amount : 0, attributes); } #endif // _di_f_thread_attributes_decrease_by_ diff --git a/level_0/f_thread/c/thread/barrier.c b/level_0/f_thread/c/thread/barrier.c index cbae0f3..e7a0a80 100644 --- a/level_0/f_thread/c/thread/barrier.c +++ b/level_0/f_thread/c/thread/barrier.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-barrier.h" #include "barrier.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/barrier_attribute.c b/level_0/f_thread/c/thread/barrier_attribute.c index 467a8b9..2e23288 100644 --- a/level_0/f_thread/c/thread/barrier_attribute.c +++ b/level_0/f_thread/c/thread/barrier_attribute.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-barrier_attribute.h" #include "barrier_attribute.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/condition.c b/level_0/f_thread/c/thread/condition.c index 3087bed..523b63f 100644 --- a/level_0/f_thread/c/thread/condition.c +++ b/level_0/f_thread/c/thread/condition.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-condition.h" #include "condition.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/condition_attribute.c b/level_0/f_thread/c/thread/condition_attribute.c index 2e01272..740c503 100644 --- a/level_0/f_thread/c/thread/condition_attribute.c +++ b/level_0/f_thread/c/thread/condition_attribute.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-condition_attribute.h" #include "condition_attribute.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/id.c b/level_0/f_thread/c/thread/id.c index f998aab..2bc8abd 100644 --- a/level_0/f_thread/c/thread/id.c +++ b/level_0/f_thread/c/thread/id.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-id.h" #include "id.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/key.c b/level_0/f_thread/c/thread/key.c index 841c8f2..f053118 100644 --- a/level_0/f_thread/c/thread/key.c +++ b/level_0/f_thread/c/thread/key.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-key.h" #include "key.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/lock.c b/level_0/f_thread/c/thread/lock.c index d09388a..fef1541 100644 --- a/level_0/f_thread/c/thread/lock.c +++ b/level_0/f_thread/c/thread/lock.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-lock.h" #include "lock.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/lock_attribute.c b/level_0/f_thread/c/thread/lock_attribute.c index 12e7aef..60ac6cd 100644 --- a/level_0/f_thread/c/thread/lock_attribute.c +++ b/level_0/f_thread/c/thread/lock_attribute.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-lock_attribute.h" #include "lock_attribute.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/mutex.c b/level_0/f_thread/c/thread/mutex.c index 200310b..8a29002 100644 --- a/level_0/f_thread/c/thread/mutex.c +++ b/level_0/f_thread/c/thread/mutex.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-mutex.h" #include "mutex.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/mutex_attribute.c b/level_0/f_thread/c/thread/mutex_attribute.c index 0c5e358..ea3ee60 100644 --- a/level_0/f_thread/c/thread/mutex_attribute.c +++ b/level_0/f_thread/c/thread/mutex_attribute.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-mutex_attribute.h" #include "mutex_attribute.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/once.c b/level_0/f_thread/c/thread/once.c index 6373936..93e0e8e 100644 --- a/level_0/f_thread/c/thread/once.c +++ b/level_0/f_thread/c/thread/once.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-once.h" #include "once.h" #ifdef __cplusplus diff --git a/level_0/f_thread/c/thread/private-attribute.c b/level_0/f_thread/c/thread/private-attribute.c new file mode 100644 index 0000000..e2491f3 --- /dev/null +++ b/level_0/f_thread/c/thread/private-attribute.c @@ -0,0 +1,51 @@ +#include "../thread.h" +#include "private-attribute.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_attributes_resize_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !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_) || !defined(_di_f_thread_sets_resize_) + f_status_t private_f_thread_attribute_delete(f_thread_attribute_t *attribute) { + + if (pthread_attr_destroy(attribute)) return F_status_set_error(F_failure); + + attribute = 0; + + return F_none; + } +#endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_attributes_resize_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !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_) || !defined(_di_f_thread_sets_resize_) + +#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) + f_status_t private_f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) + +#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_number_unsigned_t length, f_thread_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#endif // !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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-attribute.h b/level_0/f_thread/c/thread/private-attribute.h new file mode 100644 index 0000000..3926891 --- /dev/null +++ b/level_0/f_thread/c/thread/private-attribute.h @@ -0,0 +1,341 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_attribute_h +#define _PRIVATE_F_thread_attribute_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param attributes + * The attributes to adjust. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_attr_destroy() + * + * @see f_thread_attributes_adjust() + * @see f_thread_attributes_decimate_by() + * @see f_thread_attributes_decrease() + * @see f_thread_attributes_decrease_by() + * @see f_thread_attributes_increase() + * @see f_thread_attributes_increase_by() + * @see f_thread_attributes_resize() + * @see f_thread_sets_adjust() + * @see f_thread_sets_decimate_by() + * @see f_thread_sets_decrease() + * @see f_thread_sets_decrease_by() + * @see f_thread_sets_increase() + * @see f_thread_sets_increase_by() + * @see f_thread_sets_resize() + */ +#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_attributes_resize_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !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_) || !defined(_di_f_thread_sets_resize_) + extern f_status_t private_f_thread_attribute_delete(f_thread_attribute_t *attribute) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) || !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_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_attributes_adjust() + * @see f_thread_attributes_decimate_by() + */ +#if !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_decimate_by_) + extern f_status_t private_f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_attributes_adjust_) || !defined(_di_f_thread_attributes_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 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_attributes_decrease_by() + * @see f_thread_attributes_increase() + * @see f_thread_attributes_increase_by() + */ +#if !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_) + extern f_status_t private_f_thread_attributes_resize(const f_number_unsigned_t length, f_thread_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_attributes_decrease_by_) || !defined(_di_f_thread_attributes_increase_) || !defined(_di_f_thread_attributes_increase_by_) + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param barriers + * The barriers to adjust. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_attr_destroy() + * + * @see f_thread_barriers_adjust() + * @see f_thread_barriers_decimate_by() + * @see f_thread_barriers_decrease() + * @see f_thread_barriers_decrease_by() + * @see f_thread_barriers_increase() + * @see f_thread_barriers_increase_by() + * @see f_thread_barriers_resize() + */ +#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) + extern f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *barrier) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param barriers + * The barriers to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_thread_barriers_adjust() + * @see f_thread_barriers_decimate_by() + */ +#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) + extern f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_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 barriers + * The barriers to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_thread_barriers_decrease_by() + * @see f_thread_barriers_increase() + * @see f_thread_barriers_increase_by() + */ +#if !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) + extern f_status_t private_f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param attributes + * The attributes to adjust. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_attr_destroy() + * + * @see f_thread_barrier_attributes_adjust() + * @see f_thread_barrier_attributes_decimate_by() + * @see f_thread_barrier_attributes_decrease() + * @see f_thread_barrier_attributes_decrease_by() + * @see f_thread_barrier_attributes_increase() + * @see f_thread_barrier_attributes_increase_by() + * @see f_thread_barrier_attributes_resize() + */ +#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) + extern f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *attribute) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_barrier_attributes_adjust() + * @see f_thread_barrier_attributes_decimate_by() + */ +#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) + extern f_status_t private_f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_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 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_barrier_attributes_decrease_by() + * @see f_thread_barrier_attributes_increase() + * @see f_thread_barrier_attributes_increase_by() + */ +#if !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) + extern f_status_t private_f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param attribute + * The attribute to adjust. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_condattr_destroy() + * + * @see f_thread_condition_attributes_adjust() + * @see f_thread_condition_attributes_decimate_by() + * @see f_thread_condition_attributes_decrease() + * @see f_thread_condition_attributes_decrease_by() + * @see f_thread_condition_attributes_increase() + * @see f_thread_condition_attributes_increase_by() + * @see f_thread_condition_attributes_resize() + */ +#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) + extern f_status_t private_f_thread_condition_attribute_delete(f_thread_condition_attribute_t *attribute) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_condition_attributes_adjust() + * @see f_thread_condition_attributes_decimate_by() + */ +#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) + extern f_status_t private_f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_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 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_condition_attributes_decrease_by() + * @see f_thread_condition_attributes_increase() + * @see f_thread_condition_attributes_increase_by() + */ +#if !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) + extern f_status_t private_f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_attribute_h diff --git a/level_0/f_thread/c/thread/private-barrier.c b/level_0/f_thread/c/thread/private-barrier.c new file mode 100644 index 0000000..895804e --- /dev/null +++ b/level_0/f_thread/c/thread/private-barrier.c @@ -0,0 +1,58 @@ +#include "../thread.h" +#include "private-barrier.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) + f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *barrier) { + + const int error = pthread_barrier_destroy(barrier); + + if (error) { + if (error == EBUSY) return F_status_set_error(F_busy); + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + barrier = 0; + + return F_none; + } +#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) + +#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) + f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < barriers->size; ++i) { + + status = private_f_thread_barrier_delete(&barriers->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_barrier_t), (void **) &barriers->array, &barriers->used, &barriers->size); + } +#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) + +#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_number_unsigned_t length, f_thread_barriers_t * const barriers) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < barriers->size; ++i) { + + status = private_f_thread_barrier_delete(&barriers->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_barrier_t), (void **) &barriers->array, &barriers->used, &barriers->size); + } +#endif // !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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-barrier.h b/level_0/f_thread/c/thread/private-barrier.h new file mode 100644 index 0000000..7a13de5 --- /dev/null +++ b/level_0/f_thread/c/thread/private-barrier.h @@ -0,0 +1,100 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_barrier_h +#define _PRIVATE_F_thread_barrier_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param barriers + * The barriers to adjust. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_attr_destroy() + * + * @see f_thread_barriers_adjust() + * @see f_thread_barriers_decimate_by() + * @see f_thread_barriers_decrease() + * @see f_thread_barriers_decrease_by() + * @see f_thread_barriers_increase() + * @see f_thread_barriers_increase_by() + * @see f_thread_barriers_resize() + */ +#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) + extern f_status_t private_f_thread_barrier_delete(f_thread_barrier_t *barrier) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) || !defined(_di_f_thread_barriers_decrease_) || !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) || !defined(_di_f_thread_barriers_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param barriers + * The barriers to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_thread_barriers_adjust() + * @see f_thread_barriers_decimate_by() + */ +#if !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_decimate_by_) + extern f_status_t private_f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barriers_adjust_) || !defined(_di_f_thread_barriers_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 barriers + * The barriers to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_thread_barriers_decrease_by() + * @see f_thread_barriers_increase() + * @see f_thread_barriers_increase_by() + */ +#if !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) + extern f_status_t private_f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const barriers) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barriers_decrease_by_) || !defined(_di_f_thread_barriers_increase_) || !defined(_di_f_thread_barriers_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_barrier_h diff --git a/level_0/f_thread/c/thread/private-barrier_attribute.c b/level_0/f_thread/c/thread/private-barrier_attribute.c new file mode 100644 index 0000000..2545b86 --- /dev/null +++ b/level_0/f_thread/c/thread/private-barrier_attribute.c @@ -0,0 +1,51 @@ +#include "../thread.h" +#include "private-barrier_attribute.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) + f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *attribute) { + + if (pthread_barrierattr_destroy(attribute)) return F_status_set_error(F_failure); + + attribute = 0; + + return F_none; + } +#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) + +#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_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_barrier_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_barrier_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) + +#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_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_barrier_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_barrier_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#endif // !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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-barrier_attribute.h b/level_0/f_thread/c/thread/private-barrier_attribute.h new file mode 100644 index 0000000..8ee63fd --- /dev/null +++ b/level_0/f_thread/c/thread/private-barrier_attribute.h @@ -0,0 +1,100 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_barrier_attribute_h +#define _PRIVATE_F_thread_barrier_attribute_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param attributes + * The attributes to adjust. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_attr_destroy() + * + * @see f_thread_barrier_attributes_adjust() + * @see f_thread_barrier_attributes_decimate_by() + * @see f_thread_barrier_attributes_decrease() + * @see f_thread_barrier_attributes_decrease_by() + * @see f_thread_barrier_attributes_increase() + * @see f_thread_barrier_attributes_increase_by() + * @see f_thread_barrier_attributes_resize() + */ +#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) + extern f_status_t private_f_thread_barrier_attribute_delete(f_thread_barrier_attribute_t *attribute) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_barrier_attributes_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_barrier_attributes_adjust() + * @see f_thread_barrier_attributes_decimate_by() + */ +#if !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_decimate_by_) + extern f_status_t private_f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barrier_attributes_adjust_) || !defined(_di_f_thread_barrier_attributes_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 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_barrier_attributes_decrease_by() + * @see f_thread_barrier_attributes_increase() + * @see f_thread_barrier_attributes_increase_by() + */ +#if !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) + extern f_status_t private_f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_barrier_attributes_decrease_by_) || !defined(_di_f_thread_barrier_attributes_increase_) || !defined(_di_f_thread_barrier_attributes_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_barrier_attribute_h diff --git a/level_0/f_thread/c/thread/private-condition.c b/level_0/f_thread/c/thread/private-condition.c new file mode 100644 index 0000000..24d45e6 --- /dev/null +++ b/level_0/f_thread/c/thread/private-condition.c @@ -0,0 +1,56 @@ +#include "../thread.h" +#include "private-condition.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !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_) || !defined(_di_f_thread_conditions_resize_) + f_status_t private_f_thread_condition_delete(f_thread_condition_t *condition) { + + const int error = pthread_cond_destroy(condition); + + if (error) { + if (error == EBUSY) return F_status_set_error(F_busy); + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !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_) || !defined(_di_f_thread_conditions_resize_) + +#if !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) + f_status_t private_f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < conditions->size; ++i) { + + status = private_f_thread_condition_delete(&conditions->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_condition_t), (void **) &conditions->array, &conditions->used, &conditions->size); + } +#endif // !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) + +#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_number_unsigned_t length, f_thread_conditions_t * const conditions) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < conditions->size; ++i) { + + status = private_f_thread_condition_delete(&conditions->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_condition_t), (void **) &conditions->array, &conditions->used, &conditions->size); + } +#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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-condition.h b/level_0/f_thread/c/thread/private-condition.h new file mode 100644 index 0000000..0441ba8 --- /dev/null +++ b/level_0/f_thread/c/thread/private-condition.h @@ -0,0 +1,101 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_condition_h +#define _PRIVATE_F_thread_condition_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param conditions + * The conditions to adjust. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_cond_destroy() + * + * @see f_thread_condition_delete() + * @see f_thread_conditions_adjust() + * @see f_thread_conditions_decimate_by() + * @see f_thread_conditions_decrease() + * @see f_thread_conditions_decrease_by() + * @see f_thread_conditions_increase() + * @see f_thread_conditions_increase_by() + * @see f_thread_conditions_resize() + */ +#if !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !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_) || !defined(_di_f_thread_conditions_resize_) + extern f_status_t private_f_thread_condition_delete(f_thread_condition_t *condition) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_condition_delete_) || !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) || !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_) || !defined(_di_f_thread_conditions_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param conditions + * The conditions to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_thread_conditions_adjust() + * @see f_thread_conditions_decimate_by() + */ +#if !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_decimate_by_) + extern f_status_t private_f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_conditions_adjust_) || !defined(_di_f_thread_conditions_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 conditions + * The conditions to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_thread_conditions_decrease_by() + * @see f_thread_conditions_increase() + * @see f_thread_conditions_increase_by() + */ +#if !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) + extern f_status_t private_f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const conditions) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_conditions_decrease_by_) || !defined(_di_f_thread_conditions_increase_) || !defined(_di_f_thread_conditions_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_condition_h diff --git a/level_0/f_thread/c/thread/private-condition_attribute.c b/level_0/f_thread/c/thread/private-condition_attribute.c new file mode 100644 index 0000000..218411a --- /dev/null +++ b/level_0/f_thread/c/thread/private-condition_attribute.c @@ -0,0 +1,56 @@ +#include "../thread.h" +#include "private-condition_attribute.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) + f_status_t private_f_thread_condition_attribute_delete(f_thread_condition_attribute_t * const attribute) { + + const int error = pthread_condattr_destroy(attribute); + + if (error) { + if (error == EBUSY) return F_status_set_error(F_busy); + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) + +#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_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_condition_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_condition_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) + +#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_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_condition_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_condition_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#endif // !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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-condition_attribute.h b/level_0/f_thread/c/thread/private-condition_attribute.h new file mode 100644 index 0000000..fdefb9b --- /dev/null +++ b/level_0/f_thread/c/thread/private-condition_attribute.h @@ -0,0 +1,100 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_condition_attribute_h +#define _PRIVATE_F_thread_condition_attribute_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param attribute + * The attribute to adjust. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_condattr_destroy() + * + * @see f_thread_condition_attributes_adjust() + * @see f_thread_condition_attributes_decimate_by() + * @see f_thread_condition_attributes_decrease() + * @see f_thread_condition_attributes_decrease_by() + * @see f_thread_condition_attributes_increase() + * @see f_thread_condition_attributes_increase_by() + * @see f_thread_condition_attributes_resize() + */ +#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) + extern f_status_t private_f_thread_condition_attribute_delete(f_thread_condition_attribute_t *attribute) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) || !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_) || !defined(_di_f_thread_condition_attributes_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_condition_attributes_adjust() + * @see f_thread_condition_attributes_decimate_by() + */ +#if !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_decimate_by_) + extern f_status_t private_f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_condition_attributes_adjust_) || !defined(_di_f_thread_condition_attributes_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 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_condition_attributes_decrease_by() + * @see f_thread_condition_attributes_increase() + * @see f_thread_condition_attributes_increase_by() + */ +#if !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) + extern f_status_t private_f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_condition_attributes_decrease_by_) || !defined(_di_f_thread_condition_attributes_increase_) || !defined(_di_f_thread_condition_attributes_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_condition_attribute_h diff --git a/level_0/f_thread/c/thread/private-id.c b/level_0/f_thread/c/thread/private-id.c new file mode 100644 index 0000000..3a37e91 --- /dev/null +++ b/level_0/f_thread/c/thread/private-id.c @@ -0,0 +1,28 @@ +#include "../thread.h" +#include "private-id.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_ids_adjust_) || !defined(_di_f_thread_ids_decimate_by_) + f_status_t private_f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const ids) { + + if (ids->size) { + memset(ids->array, 0, sizeof(f_thread_id_t) * ids->size); + } + + return f_memory_array_adjust(length, sizeof(f_thread_id_t), (void **) &ids->array, &ids->used, &ids->size); + } +#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_number_unsigned_t length, f_thread_ids_t * const ids) { + + return f_memory_array_resize(length, sizeof(f_thread_id_t), (void **) &ids->array, &ids->used, &ids->size); + } +#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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-id.h b/level_0/f_thread/c/thread/private-id.h new file mode 100644 index 0000000..5bd9a38 --- /dev/null +++ b/level_0/f_thread/c/thread/private-id.h @@ -0,0 +1,69 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_id_h +#define _PRIVATE_F_thread_id_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * 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_number_unsigned_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_number_unsigned_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_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_id_h diff --git a/level_0/f_thread/c/thread/private-key.c b/level_0/f_thread/c/thread/private-key.c new file mode 100644 index 0000000..df4feaa --- /dev/null +++ b/level_0/f_thread/c/thread/private-key.c @@ -0,0 +1,51 @@ +#include "../thread.h" +#include "private-key.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#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 (pthread_key_delete(*key)) return F_status_set_error(F_failure); + + *key = 0; + + return F_none; + } +#endif // !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_) + +#if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) + f_status_t private_f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const keys) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < keys->size; ++i) { + + status = private_f_thread_key_delete(&keys->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_key_t), (void **) &keys->array, &keys->used, &keys->size); + } +#endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) + +#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_number_unsigned_t length, f_thread_keys_t * const keys) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < keys->size; ++i) { + + status = private_f_thread_key_delete(&keys->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_key_t), (void **) &keys->array, &keys->used, &keys->size); + } +#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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-key.h b/level_0/f_thread/c/thread/private-key.h new file mode 100644 index 0000000..0595175 --- /dev/null +++ b/level_0/f_thread/c/thread/private-key.h @@ -0,0 +1,98 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_key_h +#define _PRIVATE_F_thread_key_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param key + * The keys to delete. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_key_destroy() + * + * @see f_thread_keys_adjust() + * @see f_thread_keys_decimate_by() + * @see f_thread_keys_decrease() + * @see f_thread_keys_decrease_by() + * @see f_thread_keys_increase() + * @see f_thread_keys_increase_by() + * @see f_thread_keys_resize() + */ +#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_) + extern f_status_t private_f_thread_key_delete(f_thread_key_t *key) F_attribute_visibility_internal_d; +#endif // !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_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param keys + * The keys to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_thread_keys_adjust() + * @see f_thread_keys_decimate_by() + */ +#if !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_decimate_by_) + extern f_status_t private_f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const keys) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_keys_adjust_) || !defined(_di_f_thread_keys_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 keys + * The keys to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_thread_keys_decrease_by() + * @see f_thread_keys_increase() + * @see f_thread_keys_increase_by() + */ +#if !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) + extern f_status_t private_f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const keys) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_keys_decrease_by_) || !defined(_di_f_thread_keys_increase_) || !defined(_di_f_thread_keys_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_key_h diff --git a/level_0/f_thread/c/thread/private-lock.c b/level_0/f_thread/c/thread/private-lock.c new file mode 100644 index 0000000..96293c8 --- /dev/null +++ b/level_0/f_thread/c/thread/private-lock.c @@ -0,0 +1,56 @@ +#include "../thread.h" +#include "private-lock.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_lock_delete_) || !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_rwlock_destroy(lock); + + if (error) { + if (error == EBUSY) return F_status_set_error(F_busy); + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // !defined(_di_f_thread_lock_delete_) || !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_number_unsigned_t length, f_thread_locks_t * const locks) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < locks->size; ++i) { + + status = private_f_thread_lock_delete(&locks->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_lock_t), (void **) &locks->array, &locks->used, &locks->size); + } +#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_number_unsigned_t length, f_thread_locks_t * const locks) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < locks->size; ++i) { + + status = private_f_thread_lock_delete(&locks->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) &locks->array, &locks->used, &locks->size); + } +#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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-lock.h b/level_0/f_thread/c/thread/private-lock.h new file mode 100644 index 0000000..7532111 --- /dev/null +++ b/level_0/f_thread/c/thread/private-lock.h @@ -0,0 +1,99 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_lock_h +#define _PRIVATE_F_thread_lock_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param lock + * The locks to delete. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_rwlock_destroy() + * + * @see f_thread_lock_delete() + * @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_delete_) || !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_lock_delete_) || !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. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_locks_adjust() + * @see f_thread_locks_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_number_unsigned_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. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_locks_decrease_by() + * @see f_thread_locks_increase() + * @see f_thread_locks_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_number_unsigned_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_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_lock_h diff --git a/level_0/f_thread/c/thread/private-lock_attribute.c b/level_0/f_thread/c/thread/private-lock_attribute.c new file mode 100644 index 0000000..42d3ed2 --- /dev/null +++ b/level_0/f_thread/c/thread/private-lock_attribute.c @@ -0,0 +1,56 @@ +#include "../thread.h" +#include "private-lock_attribute.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#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_rwlockattr_destroy(attribute); + + if (error) { + if (error == EBUSY) return F_status_set_error(F_busy); + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + 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_) + +#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_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_lock_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_lock_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#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_number_unsigned_t length, f_thread_lock_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_lock_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_lock_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-lock_attribute.h b/level_0/f_thread/c/thread/private-lock_attribute.h new file mode 100644 index 0000000..e0f8cd3 --- /dev/null +++ b/level_0/f_thread/c/thread/private-lock_attribute.h @@ -0,0 +1,98 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_lock_attribute_h +#define _PRIVATE_F_thread_lock_attribute_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param attribute + * The attribute to delete. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_rwlockattr_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() + */ +#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. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_lock_attributes_adjust() + * @see f_thread_lock_attributes_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_number_unsigned_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. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_lock_attributes_decrease_by() + * @see f_thread_lock_attributes_increase() + * @see f_thread_lock_attributes_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_number_unsigned_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_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_lock_attribute_h diff --git a/level_0/f_thread/c/thread/private-mutex.c b/level_0/f_thread/c/thread/private-mutex.c new file mode 100644 index 0000000..3beab4c --- /dev/null +++ b/level_0/f_thread/c/thread/private-mutex.c @@ -0,0 +1,56 @@ +#include "../thread.h" +#include "private-mutex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !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_) || !defined(_di_f_thread_mutexs_resize_) + f_status_t private_f_thread_mutex_delete(f_thread_mutex_t *mutex) { + + const int error = pthread_mutex_destroy(mutex); + + if (error) { + if (error == EBUSY) return F_status_set_error(F_busy); + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !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_) || !defined(_di_f_thread_mutexs_resize_) + +#if !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) + f_status_t private_f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < mutexs->size; ++i) { + + status = private_f_thread_mutex_delete(&mutexs->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_mutex_t), (void **) &mutexs->array, &mutexs->used, &mutexs->size); + } +#endif // !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) + +#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_number_unsigned_t length, f_thread_mutexs_t * const mutexs) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < mutexs->size; ++i) { + + status = private_f_thread_mutex_delete(&mutexs->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_mutex_t), (void **) &mutexs->array, &mutexs->used, &mutexs->size); + } +#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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-mutex.h b/level_0/f_thread/c/thread/private-mutex.h new file mode 100644 index 0000000..f0a2a05 --- /dev/null +++ b/level_0/f_thread/c/thread/private-mutex.h @@ -0,0 +1,99 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_mutex_h +#define _PRIVATE_F_thread_mutex_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param mutex + * The mutexs to delete. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_mutex_destroy() + * + * @see f_thread_mutex_delete() + * @see f_thread_mutexs_adjust() + * @see f_thread_mutexs_decimate_by() + * @see f_thread_mutexs_decrease() + * @see f_thread_mutexs_decrease_by() + * @see f_thread_mutexs_increase() + * @see f_thread_mutexs_increase_by() + * @see f_thread_mutexs_resize() + */ +#if !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !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_) || !defined(_di_f_thread_mutexs_resize_) + extern f_status_t private_f_thread_mutex_delete(f_thread_mutex_t *mutex) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_mutex_delete_) || !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) || !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_) || !defined(_di_f_thread_mutexs_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mutexs + * The mutexs to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_thread_mutexs_adjust() + * @see f_thread_mutexs_decimate_by() + */ +#if !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_decimate_by_) + extern f_status_t private_f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_mutexs_adjust_) || !defined(_di_f_thread_mutexs_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 mutexs + * The mutexs to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_thread_mutexs_decrease_by() + * @see f_thread_mutexs_increase() + * @see f_thread_mutexs_increase_by() + */ +#if !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) + extern f_status_t private_f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const mutexs) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_mutexs_decrease_by_) || !defined(_di_f_thread_mutexs_increase_) || !defined(_di_f_thread_mutexs_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_mutex_h diff --git a/level_0/f_thread/c/thread/private-mutex_attribute.c b/level_0/f_thread/c/thread/private-mutex_attribute.c new file mode 100644 index 0000000..9b7c448 --- /dev/null +++ b/level_0/f_thread/c/thread/private-mutex_attribute.c @@ -0,0 +1,56 @@ +#include "../thread.h" +#include "private-mutex_attribute.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#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) { + + const int error = pthread_mutexattr_destroy(attribute); + + if (error) { + if (error == EBUSY) return F_status_set_error(F_busy); + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // !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_) + +#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_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_mutex_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_mutex_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) + +#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_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < attributes->size; ++i) { + + status = private_f_thread_mutex_attribute_delete(&attributes->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_mutex_attribute_t), (void **) &attributes->array, &attributes->used, &attributes->size); + } +#endif // !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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-mutex_attribute.h b/level_0/f_thread/c/thread/private-mutex_attribute.h new file mode 100644 index 0000000..74e90b5 --- /dev/null +++ b/level_0/f_thread/c/thread/private-mutex_attribute.h @@ -0,0 +1,98 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_mutex_attribute_h +#define _PRIVATE_F_thread_mutex_attribute_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param attribute + * The attribute to delete. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_mutexattr_destroy() + * + * @see f_thread_mutex_attributes_adjust() + * @see f_thread_mutex_attributes_decimate_by() + * @see f_thread_mutex_attributes_decrease() + * @see f_thread_mutex_attributes_decrease_by() + * @see f_thread_mutex_attributes_increase() + * @see f_thread_mutex_attributes_increase_by() + * @see f_thread_mutex_attributes_resize() + */ +#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_) + extern f_status_t private_f_thread_mutex_attribute_delete(f_thread_mutex_attribute_t *attribute) F_attribute_visibility_internal_d; +#endif // !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_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @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_mutex_attributes_adjust() + * @see f_thread_mutex_attributes_decimate_by() + */ +#if !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_decimate_by_) + extern f_status_t private_f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_mutex_attributes_adjust_) || !defined(_di_f_thread_mutex_attributes_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 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_mutex_attributes_decrease_by() + * @see f_thread_mutex_attributes_increase() + * @see f_thread_mutex_attributes_increase_by() + */ +#if !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) + extern f_status_t private_f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const attributes) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_mutex_attributes_decrease_by_) || !defined(_di_f_thread_mutex_attributes_increase_) || !defined(_di_f_thread_mutex_attributes_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_mutex_attribute_h diff --git a/level_0/f_thread/c/thread/private-once.c b/level_0/f_thread/c/thread/private-once.c new file mode 100644 index 0000000..80aaa24 --- /dev/null +++ b/level_0/f_thread/c/thread/private-once.c @@ -0,0 +1,28 @@ +#include "../thread.h" +#include "private-once.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_onces_adjust_) || !defined(_di_f_thread_onces_decimate_by_) + f_status_t private_f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const onces) { + + if (onces->size) { + memset(onces->array, 0, sizeof(f_thread_once_t) * onces->size); + } + + return f_memory_array_adjust(length, sizeof(f_thread_once_t), (void **) &onces->array, &onces->used, &onces->size); + } +#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_number_unsigned_t length, f_thread_onces_t * const onces) { + + return f_memory_array_resize(length, sizeof(f_thread_once_t), (void **) &onces->array, &onces->used, &onces->size); + } +#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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-once.h b/level_0/f_thread/c/thread/private-once.h new file mode 100644 index 0000000..ecc8bd3 --- /dev/null +++ b/level_0/f_thread/c/thread/private-once.h @@ -0,0 +1,69 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_once_h +#define _PRIVATE_F_thread_once_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * 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_number_unsigned_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_number_unsigned_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_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_once_h diff --git a/level_0/f_thread/c/thread/private-semaphore.c b/level_0/f_thread/c/thread/private-semaphore.c new file mode 100644 index 0000000..c69bda7 --- /dev/null +++ b/level_0/f_thread/c/thread/private-semaphore.c @@ -0,0 +1,55 @@ +#include "../thread.h" +#include "private-semaphore.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#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) { + + const int result = sem_destroy(semaphore); + + if (result == -1) { + if (errno == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // !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_) + +#if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) + f_status_t private_f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < semaphores->size; ++i) { + + status = private_f_thread_semaphore_delete(&semaphores->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_semaphore_t), (void **) &semaphores->array, &semaphores->used, &semaphores->size); + } +#endif // !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) + +#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_number_unsigned_t length, f_thread_semaphores_t * const semaphores) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < semaphores->size; ++i) { + + status = private_f_thread_semaphore_delete(&semaphores->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_semaphore_t), (void **) &semaphores->array, &semaphores->used, &semaphores->size); + } +#endif // !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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-semaphore.h b/level_0/f_thread/c/thread/private-semaphore.h new file mode 100644 index 0000000..abe7f48 --- /dev/null +++ b/level_0/f_thread/c/thread/private-semaphore.h @@ -0,0 +1,98 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_semaphore_h +#define _PRIVATE_F_thread_semaphore_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param semaphore + * The semaphores to delete. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see sem_destroy() + * + * @see f_thread_semaphores_adjust() + * @see f_thread_semaphores_decimate_by() + * @see f_thread_semaphores_decrease() + * @see f_thread_semaphores_decrease_by() + * @see f_thread_semaphores_increase() + * @see f_thread_semaphores_increase_by() + * @see f_thread_semaphores_resize() + */ +#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_) + extern f_status_t private_f_thread_semaphore_delete(f_thread_semaphore_t *semaphore) F_attribute_visibility_internal_d; +#endif // !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_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param semaphores + * The semaphores to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_thread_semaphores_adjust() + * @see f_thread_semaphores_decimate_by() + */ +#if !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_decimate_by_) + extern f_status_t private_f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_semaphores_adjust_) || !defined(_di_f_thread_semaphores_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 semaphores + * The semaphores to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_thread_semaphores_decrease_by() + * @see f_thread_semaphores_increase() + * @see f_thread_semaphores_increase_by() + */ +#if !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) + extern f_status_t private_f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const semaphores) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_semaphores_decrease_by_) || !defined(_di_f_thread_semaphores_increase_) || !defined(_di_f_thread_semaphores_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_semaphore_h diff --git a/level_0/f_thread/c/thread/private-set.c b/level_0/f_thread/c/thread/private-set.c new file mode 100644 index 0000000..30e15f7 --- /dev/null +++ b/level_0/f_thread/c/thread/private-set.c @@ -0,0 +1,41 @@ +#include "../thread.h" +#include "private-attribute.h" +#include "private-set.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) + f_status_t private_f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const sets) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < sets->size; ++i) { + + status = private_f_thread_attribute_delete(&sets->array[i].attribute); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_set_t), (void **) &sets->array, &sets->used, &sets->size); + } +#endif // !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) + +#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_number_unsigned_t length, f_thread_sets_t * const sets) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < sets->size; ++i) { + + status = private_f_thread_attribute_delete(&sets->array[i].attribute); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_set_t), (void **) &sets->array, &sets->used, &sets->size); + } +#endif // !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_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-set.h b/level_0/f_thread/c/thread/private-set.h new file mode 100644 index 0000000..ab8eb20 --- /dev/null +++ b/level_0/f_thread/c/thread/private-set.h @@ -0,0 +1,69 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_set_h +#define _PRIVATE_F_thread_set_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param sets + * The sets to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_thread_sets_adjust() + * @see f_thread_sets_decimate_by() + */ +#if !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_decimate_by_) + extern f_status_t private_f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const sets) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_sets_adjust_) || !defined(_di_f_thread_sets_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 sets + * The sets to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_thread_sets_decrease_by() + * @see f_thread_sets_increase() + * @see f_thread_sets_increase_by() + */ +#if !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) + extern f_status_t private_f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const sets) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_sets_decrease_by_) || !defined(_di_f_thread_sets_increase_) || !defined(_di_f_thread_sets_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_set_h diff --git a/level_0/f_thread/c/thread/private-spin.c b/level_0/f_thread/c/thread/private-spin.c new file mode 100644 index 0000000..d5de418 --- /dev/null +++ b/level_0/f_thread/c/thread/private-spin.c @@ -0,0 +1,56 @@ +#include "../thread.h" +#include "private-spin.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) + f_status_t private_f_thread_spin_delete(f_thread_spin_t *spin) { + + const int error = pthread_spin_destroy(spin); + + if (error) { + if (error == EBUSY) return F_status_set_error(F_busy); + if (error == EINVAL) return F_status_set_error(F_parameter); + + return F_status_set_error(F_failure); + } + + return F_none; + } +#endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) + +#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) + f_status_t private_f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const spins) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < spins->size; ++i) { + + status = private_f_thread_spin_delete(&spins->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_adjust(length, sizeof(f_thread_spin_t), (void **) &spins->array, &spins->used, &spins->size); + } +#endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) + +#if !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) + f_status_t private_f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const spins) { + + f_status_t status = F_none; + + for (f_number_unsigned_t i = length; i < spins->size; ++i) { + + status = private_f_thread_spin_delete(&spins->array[i]); + if (F_status_is_error(status)) return status; + } // for + + return f_memory_array_resize(length, sizeof(f_thread_spin_t), (void **) &spins->array, &spins->used, &spins->size); + } +#endif // !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/c/thread/private-spin.h b/level_0/f_thread/c/thread/private-spin.h new file mode 100644 index 0000000..a49ac72 --- /dev/null +++ b/level_0/f_thread/c/thread/private-spin.h @@ -0,0 +1,98 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * These are provided for internal reduction in redundant code. + * These should not be exposed/used outside of this project. + */ +#ifndef _PRIVATE_F_thread_spin_h +#define _PRIVATE_F_thread_spin_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Private implementation for deleting (and destroying). + * + * Intended to be shared to each of the different implementation variations. + * + * @param spin + * The spins to delete. + * + * @return + * F_none on success. + * + * F_busy (with error bit) if the lock is busy. + * F_failure (with error bit) on error. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see pthread_spin_destroy() + * + * @see f_thread_spins_adjust() + * @see f_thread_spins_decimate_by() + * @see f_thread_spins_decrease() + * @see f_thread_spins_decrease_by() + * @see f_thread_spins_increase() + * @see f_thread_spins_increase_by() + * @see f_thread_spins_resize() + */ +#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) + extern f_status_t private_f_thread_spin_delete(f_thread_spin_t *spin) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) || !defined(_di_f_thread_spins_decrease_) || !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) || !defined(_di_f_thread_spins_resize_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param spins + * The spins to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_thread_spins_adjust() + * @see f_thread_spins_decimate_by() + */ +#if !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_decimate_by_) + extern f_status_t private_f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const spins) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_spins_adjust_) || !defined(_di_f_thread_spins_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 spins + * The spins to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_thread_spins_decrease_by() + * @see f_thread_spins_increase() + * @see f_thread_spins_increase_by() + */ +#if !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) + extern f_status_t private_f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const spins) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_thread_spins_decrease_by_) || !defined(_di_f_thread_spins_increase_) || !defined(_di_f_thread_spins_increase_by_) + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _PRIVATE_F_thread_spin_h diff --git a/level_0/f_thread/c/thread/semaphore.c b/level_0/f_thread/c/thread/semaphore.c index 85ea697..9eb802e 100644 --- a/level_0/f_thread/c/thread/semaphore.c +++ b/level_0/f_thread/c/thread/semaphore.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-semaphore.h" #include "semaphore.h" #ifdef __cplusplus @@ -24,11 +24,7 @@ extern "C" { if (!amount) return F_data_not; - if (semaphores->size > amount) { - return private_f_thread_semaphores_adjust(semaphores->size - amount, semaphores); - } - - return private_f_thread_semaphores_adjust(0, semaphores); + return private_f_thread_semaphores_adjust((semaphores->size > amount) ? semaphores->size - amount : 0, semaphores); } #endif // _di_f_thread_semaphores_decimate_by_ @@ -40,11 +36,7 @@ extern "C" { if (!amount) return F_data_not; - if (semaphores->size > amount) { - return private_f_thread_semaphores_resize(semaphores->size - amount, semaphores); - } - - return private_f_thread_semaphores_resize(0, semaphores); + return private_f_thread_semaphores_resize((semaphores->size > amount) ? semaphores->size - amount : 0, semaphores); } #endif // _di_f_thread_semaphores_decrease_by_ @@ -58,9 +50,7 @@ extern "C" { f_number_unsigned_t size = semaphores->used + step; if (size > F_number_t_size_unsigned_d) { - if (semaphores->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (semaphores->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_thread/c/thread/set.c b/level_0/f_thread/c/thread/set.c index a0e55a9..d2fd766 100644 --- a/level_0/f_thread/c/thread/set.c +++ b/level_0/f_thread/c/thread/set.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-set.h" #include "set.h" #ifdef __cplusplus @@ -24,11 +24,7 @@ extern "C" { if (!amount) return F_data_not; - if (sets->size > amount) { - return private_f_thread_sets_adjust(sets->size - amount, sets); - } - - return private_f_thread_sets_adjust(0, sets); + return private_f_thread_sets_adjust((sets->size > amount) ? sets->size - amount : 0, sets); } #endif // _di_f_thread_sets_decimate_by_ @@ -40,11 +36,7 @@ extern "C" { if (!amount) return F_data_not; - if (sets->size > amount) { - return private_f_thread_sets_resize(sets->size - amount, sets); - } - - return private_f_thread_sets_resize(0, sets); + return private_f_thread_sets_resize((sets->size > amount) ? sets->size - amount : 0, sets); } #endif // _di_f_thread_sets_decrease_by_ @@ -58,9 +50,7 @@ extern "C" { f_number_unsigned_t size = sets->used + step; if (size > F_number_t_size_unsigned_d) { - if (sets->used + 1 > F_number_t_size_unsigned_d) { - return F_status_set_error(F_array_too_large); - } + if (sets->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); size = F_number_t_size_unsigned_d; } diff --git a/level_0/f_thread/c/thread/spin.c b/level_0/f_thread/c/thread/spin.c index 81258cf..a74a2f5 100644 --- a/level_0/f_thread/c/thread/spin.c +++ b/level_0/f_thread/c/thread/spin.c @@ -1,5 +1,5 @@ #include "../thread.h" -#include "../private-thread.h" +#include "private-spin.h" #include "spin.h" #ifdef __cplusplus @@ -24,11 +24,7 @@ extern "C" { if (!amount) return F_data_not; - if (spins->size > amount) { - return private_f_thread_spins_adjust(spins->size - amount, spins); - } - - return private_f_thread_spins_adjust(0, spins); + return private_f_thread_spins_adjust((spins->size > amount) ? spins->size - amount : 0, spins); } #endif // _di_f_thread_spins_decimate_by_ @@ -40,11 +36,7 @@ extern "C" { if (!amount) return F_data_not; - if (spins->size > amount) { - return private_f_thread_spins_resize(spins->size - amount, spins); - } - - return private_f_thread_spins_resize(0, spins); + return private_f_thread_spins_resize((spins->size > amount) ? spins->size - amount : 0, spins); } #endif // _di_f_thread_spins_decrease_by_ diff --git a/level_0/f_thread/data/build/settings b/level_0/f_thread/data/build/settings index 7a58ba0..efe26df 100644 --- a/level_0/f_thread/data/build/settings +++ b/level_0/f_thread/data/build/settings @@ -34,7 +34,8 @@ build_language c build_libraries -lc build_libraries-individual -lf_memory -lf_string -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_library 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_library thread/private-attribute.c thread/private-barrier.c thread/private-barrier_attribute.c thread/private-condition.c thread/private-condition_attribute.c thread/private-id.c thread/private-key.c thread/private-lock.c thread/private-lock_attribute.c thread/private-mutex.c thread/private-mutex_attribute.c thread/private-once.c thread/private-semaphore.c thread/private-set.c thread/private-spin.c 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 diff --git a/level_0/f_thread/data/build/settings-mocks b/level_0/f_thread/data/build/settings-mocks index b155676..11105da 100644 --- a/level_0/f_thread/data/build/settings-mocks +++ b/level_0/f_thread/data/build/settings-mocks @@ -30,7 +30,8 @@ build_language c build_libraries -pthread -lc build_libraries-individual -lf_memory -lf_string -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 ../../tests/unit/c/mock-thread.c +build_sources_library 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 ../../tests/unit/c/mock-thread.c +build_sources_library thread/private-attribute.c thread/private-barrier.c thread/private-barrier_attribute.c thread/private-condition.c thread/private-condition_attribute.c thread/private-id.c thread/private-key.c thread/private-lock.c thread/private-lock_attribute.c thread/private-mutex.c thread/private-mutex_attribute.c thread/private-once.c thread/private-semaphore.c thread/private-set.c thread/private-spin.c 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 -- 1.8.3.1