From 82e63fac2e82ce286194b6d8a7caeaa3cf4016a2 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 10 Aug 2023 22:11:01 -0500 Subject: [PATCH] Progress: Continue re-designing of the memory logic. This makes a second pass around f_thread memory and addresses other bugs found. --- build/stand_alone/fake.config.h | 120 ++----- build/stand_alone/firewall.config.h | 90 ----- level_0/f_thread/c/thread/attribute.c | 120 +------ level_0/f_thread/c/thread/attribute.h | 149 ++------ level_0/f_thread/c/thread/barrier.c | 168 +-------- level_0/f_thread/c/thread/barrier.h | 149 ++------ level_0/f_thread/c/thread/barrier_attribute.c | 120 +------ level_0/f_thread/c/thread/barrier_attribute.h | 149 ++------ level_0/f_thread/c/thread/condition.c | 168 +-------- level_0/f_thread/c/thread/condition.h | 149 ++------ level_0/f_thread/c/thread/condition_attribute.c | 168 +-------- level_0/f_thread/c/thread/condition_attribute.h | 149 ++------ level_0/f_thread/c/thread/id.c | 60 ---- level_0/f_thread/c/thread/id.h | 141 -------- level_0/f_thread/c/thread/key.c | 136 +------- level_0/f_thread/c/thread/key.h | 149 ++------ level_0/f_thread/c/thread/lock.c | 168 +-------- level_0/f_thread/c/thread/lock.h | 149 ++------ level_0/f_thread/c/thread/lock_attribute.c | 168 +-------- level_0/f_thread/c/thread/lock_attribute.h | 149 ++------ level_0/f_thread/c/thread/mutex.c | 168 +-------- level_0/f_thread/c/thread/mutex.h | 149 ++------ level_0/f_thread/c/thread/mutex_attribute.c | 168 +-------- level_0/f_thread/c/thread/mutex_attribute.h | 149 ++------ level_0/f_thread/c/thread/once.c | 60 ---- level_0/f_thread/c/thread/once.h | 140 -------- level_0/f_thread/c/thread/private-once.c | 10 - level_0/f_thread/c/thread/private-once.h | 22 -- level_0/f_thread/c/thread/semaphore.c | 121 +------ level_0/f_thread/c/thread/semaphore.h | 149 ++------ level_0/f_thread/c/thread/set.c | 120 +------ level_0/f_thread/c/thread/set.h | 151 ++------ level_0/f_thread/c/thread/spin.c | 168 +-------- level_0/f_thread/c/thread/spin.h | 149 ++------ level_0/f_thread/data/build/settings-mocks | 5 +- level_0/f_thread/data/build/settings-tests | 28 +- level_0/f_thread/tests/unit/c/mock-thread.c | 26 ++ level_0/f_thread/tests/unit/c/mock-thread.h | 2 + .../tests/unit/c/test-thread-attributes_adjust.c | 42 --- .../tests/unit/c/test-thread-attributes_adjust.h | 27 -- .../c/test-thread-attributes_adjust_callback.c | 55 +++ .../c/test-thread-attributes_adjust_callback.h | 27 ++ .../unit/c/test-thread-attributes_decimate_by.c | 78 ----- .../unit/c/test-thread-attributes_decimate_by.h | 34 -- .../unit/c/test-thread-attributes_decrease_by.c | 78 ----- .../unit/c/test-thread-attributes_decrease_by.h | 34 -- .../tests/unit/c/test-thread-attributes_increase.c | 76 ---- .../tests/unit/c/test-thread-attributes_increase.h | 34 -- .../unit/c/test-thread-attributes_increase_by.c | 76 ---- .../unit/c/test-thread-attributes_increase_by.h | 34 -- .../tests/unit/c/test-thread-attributes_resize.c | 42 --- .../tests/unit/c/test-thread-attributes_resize.h | 27 -- .../c/test-thread-attributes_resize_callback.c | 55 +++ .../c/test-thread-attributes_resize_callback.h | 27 ++ .../unit/c/test-thread-barrier_attributes_adjust.c | 42 --- .../unit/c/test-thread-barrier_attributes_adjust.h | 27 -- ...est-thread-barrier_attributes_adjust_callback.c | 55 +++ ...est-thread-barrier_attributes_adjust_callback.h | 27 ++ .../c/test-thread-barrier_attributes_decimate_by.c | 78 ----- .../c/test-thread-barrier_attributes_decimate_by.h | 34 -- .../c/test-thread-barrier_attributes_decrease_by.c | 78 ----- .../c/test-thread-barrier_attributes_decrease_by.h | 34 -- .../c/test-thread-barrier_attributes_increase.c | 76 ---- .../c/test-thread-barrier_attributes_increase.h | 34 -- .../c/test-thread-barrier_attributes_increase_by.c | 76 ---- .../c/test-thread-barrier_attributes_increase_by.h | 34 -- .../unit/c/test-thread-barrier_attributes_resize.c | 42 --- .../unit/c/test-thread-barrier_attributes_resize.h | 27 -- ...est-thread-barrier_attributes_resize_callback.c | 55 +++ ...est-thread-barrier_attributes_resize_callback.h | 27 ++ .../tests/unit/c/test-thread-barriers_adjust.c | 42 --- .../tests/unit/c/test-thread-barriers_adjust.h | 27 -- .../unit/c/test-thread-barriers_adjust_callback.c | 57 +++ .../unit/c/test-thread-barriers_adjust_callback.h | 27 ++ .../unit/c/test-thread-barriers_decimate_by.c | 78 ----- .../unit/c/test-thread-barriers_decimate_by.h | 34 -- .../unit/c/test-thread-barriers_decrease_by.c | 78 ----- .../unit/c/test-thread-barriers_decrease_by.h | 34 -- .../tests/unit/c/test-thread-barriers_increase.c | 76 ---- .../tests/unit/c/test-thread-barriers_increase.h | 34 -- .../unit/c/test-thread-barriers_increase_by.c | 76 ---- .../unit/c/test-thread-barriers_increase_by.h | 34 -- .../tests/unit/c/test-thread-barriers_resize.c | 42 --- .../tests/unit/c/test-thread-barriers_resize.h | 27 -- .../unit/c/test-thread-barriers_resize_callback.c | 56 +++ .../unit/c/test-thread-barriers_resize_callback.h | 27 ++ .../c/test-thread-condition_attributes_adjust.c | 42 --- .../c/test-thread-condition_attributes_adjust.h | 27 -- ...t-thread-condition_attributes_adjust_callback.c | 57 +++ ...t-thread-condition_attributes_adjust_callback.h | 27 ++ .../test-thread-condition_attributes_decimate_by.c | 78 ----- .../test-thread-condition_attributes_decimate_by.h | 34 -- .../test-thread-condition_attributes_decrease_by.c | 78 ----- .../test-thread-condition_attributes_decrease_by.h | 34 -- .../c/test-thread-condition_attributes_increase.c | 76 ---- .../c/test-thread-condition_attributes_increase.h | 34 -- .../test-thread-condition_attributes_increase_by.c | 76 ---- .../test-thread-condition_attributes_increase_by.h | 34 -- .../c/test-thread-condition_attributes_resize.c | 42 --- .../c/test-thread-condition_attributes_resize.h | 27 -- ...t-thread-condition_attributes_resize_callback.c | 57 +++ ...t-thread-condition_attributes_resize_callback.h | 27 ++ .../tests/unit/c/test-thread-conditions_adjust.c | 42 --- .../tests/unit/c/test-thread-conditions_adjust.h | 27 -- .../c/test-thread-conditions_adjust_callback.c | 57 +++ .../c/test-thread-conditions_adjust_callback.h | 27 ++ .../unit/c/test-thread-conditions_decimate_by.c | 78 ----- .../unit/c/test-thread-conditions_decimate_by.h | 34 -- .../unit/c/test-thread-conditions_decrease_by.c | 78 ----- .../unit/c/test-thread-conditions_decrease_by.h | 34 -- .../tests/unit/c/test-thread-conditions_increase.c | 76 ---- .../tests/unit/c/test-thread-conditions_increase.h | 34 -- .../unit/c/test-thread-conditions_increase_by.c | 76 ---- .../unit/c/test-thread-conditions_increase_by.h | 34 -- .../tests/unit/c/test-thread-conditions_resize.c | 42 --- .../tests/unit/c/test-thread-conditions_resize.h | 27 -- .../c/test-thread-conditions_resize_callback.c | 57 +++ .../c/test-thread-conditions_resize_callback.h | 27 ++ .../f_thread/tests/unit/c/test-thread-ids_adjust.c | 42 --- .../f_thread/tests/unit/c/test-thread-ids_adjust.h | 27 -- .../tests/unit/c/test-thread-ids_decimate_by.c | 74 ---- .../tests/unit/c/test-thread-ids_decimate_by.h | 34 -- .../tests/unit/c/test-thread-ids_decrease_by.c | 74 ---- .../tests/unit/c/test-thread-ids_decrease_by.h | 34 -- .../tests/unit/c/test-thread-ids_increase.c | 76 ---- .../tests/unit/c/test-thread-ids_increase.h | 34 -- .../tests/unit/c/test-thread-ids_increase_by.c | 76 ---- .../tests/unit/c/test-thread-ids_increase_by.h | 34 -- .../f_thread/tests/unit/c/test-thread-ids_resize.c | 42 --- .../f_thread/tests/unit/c/test-thread-ids_resize.h | 27 -- .../tests/unit/c/test-thread-keys_adjust.c | 42 --- .../tests/unit/c/test-thread-keys_adjust.h | 27 -- .../unit/c/test-thread-keys_adjust_callback.c | 54 +++ .../unit/c/test-thread-keys_adjust_callback.h | 27 ++ .../tests/unit/c/test-thread-keys_decimate_by.c | 78 ----- .../tests/unit/c/test-thread-keys_decimate_by.h | 34 -- .../tests/unit/c/test-thread-keys_decrease_by.c | 78 ----- .../tests/unit/c/test-thread-keys_decrease_by.h | 34 -- .../tests/unit/c/test-thread-keys_increase.c | 76 ---- .../tests/unit/c/test-thread-keys_increase.h | 34 -- .../tests/unit/c/test-thread-keys_increase_by.c | 76 ---- .../tests/unit/c/test-thread-keys_increase_by.h | 34 -- .../tests/unit/c/test-thread-keys_resize.c | 42 --- .../tests/unit/c/test-thread-keys_resize.h | 27 -- .../unit/c/test-thread-keys_resize_callback.c | 54 +++ .../unit/c/test-thread-keys_resize_callback.h | 27 ++ .../unit/c/test-thread-lock_attributes_adjust.c | 42 --- .../unit/c/test-thread-lock_attributes_adjust.h | 27 -- .../test-thread-lock_attributes_adjust_callback.c | 57 +++ .../test-thread-lock_attributes_adjust_callback.h | 27 ++ .../c/test-thread-lock_attributes_decimate_by.c | 78 ----- .../c/test-thread-lock_attributes_decimate_by.h | 34 -- .../c/test-thread-lock_attributes_decrease_by.c | 78 ----- .../c/test-thread-lock_attributes_decrease_by.h | 34 -- .../unit/c/test-thread-lock_attributes_increase.c | 76 ---- .../unit/c/test-thread-lock_attributes_increase.h | 34 -- .../c/test-thread-lock_attributes_increase_by.c | 76 ---- .../c/test-thread-lock_attributes_increase_by.h | 34 -- .../unit/c/test-thread-lock_attributes_resize.c | 42 --- .../unit/c/test-thread-lock_attributes_resize.h | 27 -- .../test-thread-lock_attributes_resize_callback.c | 57 +++ .../test-thread-lock_attributes_resize_callback.h | 27 ++ .../tests/unit/c/test-thread-locks_adjust.c | 42 --- .../tests/unit/c/test-thread-locks_adjust.h | 27 -- .../unit/c/test-thread-locks_adjust_callback.c | 57 +++ .../unit/c/test-thread-locks_adjust_callback.h | 27 ++ .../tests/unit/c/test-thread-locks_decimate_by.c | 78 ----- .../tests/unit/c/test-thread-locks_decimate_by.h | 34 -- .../tests/unit/c/test-thread-locks_decrease_by.c | 78 ----- .../tests/unit/c/test-thread-locks_decrease_by.h | 34 -- .../tests/unit/c/test-thread-locks_increase.c | 76 ---- .../tests/unit/c/test-thread-locks_increase.h | 34 -- .../tests/unit/c/test-thread-locks_increase_by.c | 76 ---- .../tests/unit/c/test-thread-locks_increase_by.h | 34 -- .../tests/unit/c/test-thread-locks_resize.c | 42 --- .../tests/unit/c/test-thread-locks_resize.h | 27 -- .../unit/c/test-thread-locks_resize_callback.c | 57 +++ .../unit/c/test-thread-locks_resize_callback.h | 27 ++ .../unit/c/test-thread-mutex_attributes_adjust.c | 42 --- .../unit/c/test-thread-mutex_attributes_adjust.h | 27 -- .../test-thread-mutex_attributes_adjust_callback.c | 57 +++ .../test-thread-mutex_attributes_adjust_callback.h | 27 ++ .../c/test-thread-mutex_attributes_decimate_by.c | 78 ----- .../c/test-thread-mutex_attributes_decimate_by.h | 34 -- .../c/test-thread-mutex_attributes_decrease_by.c | 78 ----- .../c/test-thread-mutex_attributes_decrease_by.h | 34 -- .../unit/c/test-thread-mutex_attributes_increase.c | 76 ---- .../unit/c/test-thread-mutex_attributes_increase.h | 34 -- .../c/test-thread-mutex_attributes_increase_by.c | 76 ---- .../c/test-thread-mutex_attributes_increase_by.h | 34 -- .../unit/c/test-thread-mutex_attributes_resize.c | 42 --- .../unit/c/test-thread-mutex_attributes_resize.h | 27 -- .../test-thread-mutex_attributes_resize_callback.c | 57 +++ .../test-thread-mutex_attributes_resize_callback.h | 27 ++ .../tests/unit/c/test-thread-mutexs_adjust.c | 42 --- .../tests/unit/c/test-thread-mutexs_adjust.h | 27 -- .../unit/c/test-thread-mutexs_adjust_callback.c | 57 +++ .../unit/c/test-thread-mutexs_adjust_callback.h | 27 ++ .../tests/unit/c/test-thread-mutexs_decimate_by.c | 78 ----- .../tests/unit/c/test-thread-mutexs_decimate_by.h | 34 -- .../tests/unit/c/test-thread-mutexs_decrease_by.c | 78 ----- .../tests/unit/c/test-thread-mutexs_decrease_by.h | 34 -- .../tests/unit/c/test-thread-mutexs_increase.c | 76 ---- .../tests/unit/c/test-thread-mutexs_increase.h | 34 -- .../tests/unit/c/test-thread-mutexs_increase_by.c | 76 ---- .../tests/unit/c/test-thread-mutexs_increase_by.h | 34 -- .../tests/unit/c/test-thread-mutexs_resize.c | 42 --- .../tests/unit/c/test-thread-mutexs_resize.h | 27 -- .../unit/c/test-thread-mutexs_resize_callback.c | 57 +++ .../unit/c/test-thread-mutexs_resize_callback.h | 27 ++ .../tests/unit/c/test-thread-onces_adjust.c | 42 --- .../tests/unit/c/test-thread-onces_adjust.h | 27 -- .../unit/c/test-thread-onces_adjust_callback.c | 55 +++ .../unit/c/test-thread-onces_adjust_callback.h | 27 ++ .../tests/unit/c/test-thread-onces_decimate_by.c | 74 ---- .../tests/unit/c/test-thread-onces_decimate_by.h | 34 -- .../tests/unit/c/test-thread-onces_decrease_by.c | 74 ---- .../tests/unit/c/test-thread-onces_decrease_by.h | 34 -- .../tests/unit/c/test-thread-onces_increase.c | 76 ---- .../tests/unit/c/test-thread-onces_increase.h | 34 -- .../tests/unit/c/test-thread-onces_increase_by.c | 76 ---- .../tests/unit/c/test-thread-onces_increase_by.h | 34 -- .../tests/unit/c/test-thread-onces_resize.c | 42 --- .../tests/unit/c/test-thread-onces_resize.h | 27 -- .../unit/c/test-thread-onces_resize_callback.c | 55 +++ .../unit/c/test-thread-onces_resize_callback.h | 27 ++ .../tests/unit/c/test-thread-semaphores_adjust.c | 42 --- .../tests/unit/c/test-thread-semaphores_adjust.h | 27 -- .../c/test-thread-semaphores_adjust_callback.c | 55 +++ .../c/test-thread-semaphores_adjust_callback.h | 27 ++ .../unit/c/test-thread-semaphores_decimate_by.c | 78 ----- .../unit/c/test-thread-semaphores_decimate_by.h | 34 -- .../unit/c/test-thread-semaphores_decrease_by.c | 78 ----- .../unit/c/test-thread-semaphores_decrease_by.h | 34 -- .../tests/unit/c/test-thread-semaphores_increase.c | 76 ---- .../tests/unit/c/test-thread-semaphores_increase.h | 34 -- .../unit/c/test-thread-semaphores_increase_by.c | 76 ---- .../unit/c/test-thread-semaphores_increase_by.h | 34 -- .../tests/unit/c/test-thread-semaphores_resize.c | 42 --- .../tests/unit/c/test-thread-semaphores_resize.h | 27 -- .../c/test-thread-semaphores_resize_callback.c | 55 +++ .../c/test-thread-semaphores_resize_callback.h | 27 ++ .../tests/unit/c/test-thread-sets_adjust.c | 42 --- .../tests/unit/c/test-thread-sets_adjust.h | 27 -- .../unit/c/test-thread-sets_adjust_callback.c | 55 +++ .../unit/c/test-thread-sets_adjust_callback.h | 27 ++ .../tests/unit/c/test-thread-sets_decimate_by.c | 78 ----- .../tests/unit/c/test-thread-sets_decimate_by.h | 34 -- .../tests/unit/c/test-thread-sets_decrease_by.c | 78 ----- .../tests/unit/c/test-thread-sets_decrease_by.h | 34 -- .../tests/unit/c/test-thread-sets_increase.c | 76 ---- .../tests/unit/c/test-thread-sets_increase.h | 34 -- .../tests/unit/c/test-thread-sets_increase_by.c | 76 ---- .../tests/unit/c/test-thread-sets_increase_by.h | 34 -- .../tests/unit/c/test-thread-sets_resize.c | 42 --- .../tests/unit/c/test-thread-sets_resize.h | 27 -- .../unit/c/test-thread-sets_resize_callback.c | 55 +++ .../unit/c/test-thread-sets_resize_callback.h | 27 ++ .../tests/unit/c/test-thread-spins_adjust.c | 42 --- .../tests/unit/c/test-thread-spins_adjust.h | 27 -- .../unit/c/test-thread-spins_adjust_callback.c | 57 +++ .../unit/c/test-thread-spins_adjust_callback.h | 27 ++ .../tests/unit/c/test-thread-spins_decimate_by.c | 78 ----- .../tests/unit/c/test-thread-spins_decimate_by.h | 34 -- .../tests/unit/c/test-thread-spins_decrease_by.c | 78 ----- .../tests/unit/c/test-thread-spins_decrease_by.h | 34 -- .../tests/unit/c/test-thread-spins_increase.c | 76 ---- .../tests/unit/c/test-thread-spins_increase.h | 34 -- .../tests/unit/c/test-thread-spins_increase_by.c | 76 ---- .../tests/unit/c/test-thread-spins_increase_by.h | 34 -- .../tests/unit/c/test-thread-spins_resize.c | 42 --- .../tests/unit/c/test-thread-spins_resize.h | 27 -- .../unit/c/test-thread-spins_resize_callback.c | 57 +++ .../unit/c/test-thread-spins_resize_callback.h | 27 ++ level_0/f_thread/tests/unit/c/test-thread.c | 385 ++++++--------------- level_0/f_thread/tests/unit/c/test-thread.h | 116 ++----- level_0/f_type_array/c/type_array/cell.c | 8 +- level_0/f_type_array/c/type_array/cell.h | 12 +- level_0/f_type_array/c/type_array/file.c | 8 +- level_0/f_type_array/c/type_array/file.h | 12 +- level_0/f_type_array/c/type_array/fll_id.c | 8 +- level_0/f_type_array/c/type_array/fll_id.h | 12 +- level_0/f_type_array/c/type_array/int128.c | 8 +- level_0/f_type_array/c/type_array/int128.h | 12 +- level_0/f_type_array/c/type_array/int16.c | 8 +- level_0/f_type_array/c/type_array/int16.h | 12 +- level_0/f_type_array/c/type_array/int32.c | 8 +- level_0/f_type_array/c/type_array/int32.h | 12 +- level_0/f_type_array/c/type_array/int64.c | 8 +- level_0/f_type_array/c/type_array/int64.h | 12 +- level_0/f_type_array/c/type_array/int8.c | 8 +- level_0/f_type_array/c/type_array/int8.h | 12 +- .../f_type_array/c/type_array/number_unsigned.c | 8 +- .../f_type_array/c/type_array/number_unsigned.h | 12 +- level_0/f_type_array/c/type_array/poll.c | 8 +- level_0/f_type_array/c/type_array/poll.h | 12 +- level_0/f_type_array/c/type_array/state.c | 8 +- level_0/f_type_array/c/type_array/state.h | 12 +- level_0/f_type_array/c/type_array/status.c | 8 +- level_0/f_type_array/c/type_array/status.h | 12 +- level_0/f_type_array/c/type_array/uint128.c | 8 +- level_0/f_type_array/c/type_array/uint128.h | 12 +- level_0/f_type_array/c/type_array/uint16.c | 8 +- level_0/f_type_array/c/type_array/uint16.h | 12 +- level_0/f_type_array/c/type_array/uint32.c | 8 +- level_0/f_type_array/c/type_array/uint32.h | 12 +- level_0/f_type_array/c/type_array/uint64.c | 8 +- level_0/f_type_array/c/type_array/uint64.h | 12 +- level_0/f_type_array/c/type_array/uint8.c | 8 +- level_0/f_type_array/c/type_array/uint8.h | 12 +- .../f_type_array/tests/unit/c/mock-type_array.c | 30 +- .../f_type_array/tests/unit/c/mock-type_array.h | 2 +- 312 files changed, 3304 insertions(+), 13212 deletions(-) delete mode 100644 level_0/f_thread/c/thread/private-once.c delete mode 100644 level_0/f_thread/c/thread/private-once.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-attributes_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-barriers_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-conditions_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_adjust.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-ids_resize.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-keys_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-locks_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-mutexs_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-onces_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-semaphores_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-sets_resize_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_adjust.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_adjust.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_adjust_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_adjust_callback.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_increase.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_increase.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.h delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_resize.c delete mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_resize.h create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_resize_callback.c create mode 100644 level_0/f_thread/tests/unit/c/test-thread-spins_resize_callback.h diff --git a/build/stand_alone/fake.config.h b/build/stand_alone/fake.config.h index 1d824a9..80dfa1b 100644 --- a/build/stand_alone/fake.config.h +++ b/build/stand_alone/fake.config.h @@ -1627,7 +1627,6 @@ #define _di_f_thread_attribute_detach_set_ #define _di_f_thread_attribute_guard_get_ #define _di_f_thread_attribute_guard_set_ -#define _di_f_thread_attributes_adjust_ #define _di_f_thread_attribute_scheduler_inherit_get_ #define _di_f_thread_attribute_scheduler_inherit_set_ #define _di_f_thread_attribute_scheduler_parameter_get_ @@ -1636,11 +1635,8 @@ #define _di_f_thread_attribute_scheduler_policy_set_ #define _di_f_thread_attribute_scope_get_ #define _di_f_thread_attribute_scope_set_ -#define _di_f_thread_attributes_decimate_by_ -#define _di_f_thread_attributes_decrease_by_ -#define _di_f_thread_attributes_increase_ -#define _di_f_thread_attributes_increase_by_ -#define _di_f_thread_attributes_resize_ +#define _di_f_thread_attributes_adjust_callback_ +#define _di_f_thread_attributes_resize_callback_ #define _di_f_thread_attributes_t_ #define _di_f_thread_attribute_stack_get_ #define _di_f_thread_attribute_stack_set_ @@ -1649,24 +1645,16 @@ //#define _di_f_thread_attribute_t_ #define _di_f_thread_barrier_attribute_create_ #define _di_f_thread_barrier_attribute_delete_ -#define _di_f_thread_barrier_attributes_adjust_ -#define _di_f_thread_barrier_attributes_decimate_by_ -#define _di_f_thread_barrier_attributes_decrease_by_ #define _di_f_thread_barrier_attribute_shared_get_ #define _di_f_thread_barrier_attribute_shared_set_ -#define _di_f_thread_barrier_attributes_increase_ -#define _di_f_thread_barrier_attributes_increase_by_ -#define _di_f_thread_barrier_attributes_resize_ +#define _di_f_thread_barrier_attributes_adjust_callback_ +#define _di_f_thread_barrier_attributes_resize_callback_ #define _di_f_thread_barrier_attributes_t_ #define _di_f_thread_barrier_attribute_t_ #define _di_f_thread_barrier_create_ #define _di_f_thread_barrier_delete_ -#define _di_f_thread_barriers_adjust_ -#define _di_f_thread_barriers_decimate_by_ -#define _di_f_thread_barriers_decrease_by_ -#define _di_f_thread_barriers_increase_ -#define _di_f_thread_barriers_increase_by_ -#define _di_f_thread_barriers_resize_ +#define _di_f_thread_barriers_adjust_callback_ +#define _di_f_thread_barriers_resize_callback_ #define _di_f_thread_barriers_t_ #define _di_f_thread_barrier_t_ #define _di_f_thread_barrier_wait_ @@ -1681,26 +1669,18 @@ #define _di_f_thread_condition_attribute_clock_set_ #define _di_f_thread_condition_attribute_create_ #define _di_f_thread_condition_attribute_delete_ -#define _di_f_thread_condition_attributes_adjust_ -#define _di_f_thread_condition_attributes_decimate_by_ -#define _di_f_thread_condition_attributes_decrease_by_ #define _di_f_thread_condition_attribute_shared_get_ #define _di_f_thread_condition_attribute_shared_set_ -#define _di_f_thread_condition_attributes_increase_ -#define _di_f_thread_condition_attributes_increase_by_ -#define _di_f_thread_condition_attributes_resize_ +#define _di_f_thread_condition_attributes_adjust_callback_ +#define _di_f_thread_condition_attributes_resize_callback_ #define _di_f_thread_condition_attributes_t_ #define _di_f_thread_condition_attribute_t_ #define _di_f_thread_condition_create_ #define _di_f_thread_condition_delete_ -#define _di_f_thread_conditions_adjust_ -#define _di_f_thread_conditions_decimate_by_ -#define _di_f_thread_conditions_decrease_by_ #define _di_f_thread_condition_signal_ #define _di_f_thread_condition_signal_all_ -#define _di_f_thread_conditions_increase_ -#define _di_f_thread_conditions_increase_by_ -#define _di_f_thread_conditions_resize_ +#define _di_f_thread_conditions_adjust_callback_ +#define _di_f_thread_conditions_resize_callback_ #define _di_f_thread_conditions_t_ #define _di_f_thread_condition_t_ #define _di_f_thread_condition_wait_ @@ -1708,12 +1688,6 @@ //#define _di_f_thread_create_ #define _di_f_thread_detach_ #define _di_f_thread_exit_ -#define _di_f_thread_ids_adjust_ -#define _di_f_thread_ids_decimate_by_ -#define _di_f_thread_ids_decrease_by_ -#define _di_f_thread_ids_increase_ -#define _di_f_thread_ids_increase_by_ -#define _di_f_thread_ids_resize_ #define _di_f_thread_ids_t_ //#define _di_f_thread_id_t_ //#define _di_f_thread_join_ @@ -1722,25 +1696,19 @@ #define _di_f_thread_key_create_ #define _di_f_thread_key_delete_ #define _di_f_thread_key_get_ -#define _di_f_thread_keys_adjust_ -#define _di_f_thread_keys_decimate_by_ -#define _di_f_thread_keys_decrease_by_ #define _di_f_thread_key_set_ -#define _di_f_thread_keys_increase_ -#define _di_f_thread_keys_increase_by_ -#define _di_f_thread_keys_resize_ +#define _di_f_thread_keys_adjust_callback_ +#define _di_f_thread_keys_resize_callback_ #define _di_f_thread_keys_t_ #define _di_f_thread_key_t_ +#define _di_f_thread_lock_attribute_adjust_callback_ #define _di_f_thread_lock_attribute_create_ #define _di_f_thread_lock_attribute_delete_ -#define _di_f_thread_lock_attributes_adjust_ -#define _di_f_thread_lock_attributes_decimate_by_ -#define _di_f_thread_lock_attributes_decrease_by_ +#define _di_f_thread_lock_attribute_resize_callback_ #define _di_f_thread_lock_attribute_shared_get_ #define _di_f_thread_lock_attribute_shared_set_ -#define _di_f_thread_lock_attributes_increase_ -#define _di_f_thread_lock_attributes_increase_by_ -#define _di_f_thread_lock_attributes_resize_ +#define _di_f_thread_lock_attributes_adjust_callback_ +#define _di_f_thread_lock_attributes_resize_callback_ #define _di_f_thread_lock_attributes_t_ #define _di_f_thread_lock_attribute_t_ #define _di_f_thread_lock_create_ @@ -1748,31 +1716,25 @@ #define _di_f_thread_lock_read_ #define _di_f_thread_lock_read_timed_ #define _di_f_thread_lock_read_try_ -#define _di_f_thread_locks_adjust_ -#define _di_f_thread_locks_decimate_by_ -#define _di_f_thread_locks_decrease_by_ -#define _di_f_thread_locks_increase_ -#define _di_f_thread_locks_increase_by_ -#define _di_f_thread_locks_resize_ +#define _di_f_thread_locks_adjust_callback_ +#define _di_f_thread_locks_resize_callback_ #define _di_f_thread_locks_t_ #define _di_f_thread_lock_t_ #define _di_f_thread_lock_write_ #define _di_f_thread_lock_write_timed_ #define _di_f_thread_lock_write_try_ +#define _di_f_thread_mutex_attribute_adjust_callback_ #define _di_f_thread_mutex_attribute_create_ #define _di_f_thread_mutex_attribute_delete_ #define _di_f_thread_mutex_attribute_priority_ceiling_get_ #define _di_f_thread_mutex_attribute_priority_ceiling_set_ #define _di_f_thread_mutex_attribute_protocol_get_ #define _di_f_thread_mutex_attribute_protocol_set_ -#define _di_f_thread_mutex_attributes_adjust_ -#define _di_f_thread_mutex_attributes_decimate_by_ -#define _di_f_thread_mutex_attributes_decrease_by_ +#define _di_f_thread_mutex_attribute_resize_callback_ #define _di_f_thread_mutex_attribute_shared_get_ #define _di_f_thread_mutex_attribute_shared_set_ -#define _di_f_thread_mutex_attributes_increase_ -#define _di_f_thread_mutex_attributes_increase_by_ -#define _di_f_thread_mutex_attributes_resize_ +#define _di_f_thread_mutex_attributes_adjust_callback_ +#define _di_f_thread_mutex_attributes_resize_callback_ #define _di_f_thread_mutex_attributes_t_ #define _di_f_thread_mutex_attribute_t_ #define _di_f_thread_mutex_attribute_type_get_ @@ -1784,22 +1746,12 @@ #define _di_f_thread_mutex_lock_try_ #define _di_f_thread_mutex_priority_ceiling_get_ #define _di_f_thread_mutex_priority_ceiling_set_ -#define _di_f_thread_mutexs_adjust_ -#define _di_f_thread_mutexs_decimate_by_ -#define _di_f_thread_mutexs_decrease_by_ -#define _di_f_thread_mutexs_increase_ -#define _di_f_thread_mutexs_increase_by_ -#define _di_f_thread_mutexs_resize_ +#define _di_f_thread_mutexs_adjust_callback_ +#define _di_f_thread_mutexs_resize_callback_ #define _di_f_thread_mutexs_t_ #define _di_f_thread_mutex_t_ #define _di_f_thread_mutex_unlock_ #define _di_f_thread_once_ -#define _di_f_thread_onces_adjust_ -#define _di_f_thread_onces_decimate_by_ -#define _di_f_thread_onces_decrease_by_ -#define _di_f_thread_onces_increase_ -#define _di_f_thread_onces_increase_by_ -#define _di_f_thread_onces_resize_ #define _di_f_thread_onces_t_ #define _di_f_thread_once_t_ #define _di_f_thread_scheduler_parameter_get_ @@ -1813,22 +1765,14 @@ #define _di_f_thread_semaphore_lock_ #define _di_f_thread_semaphore_lock_timed_ #define _di_f_thread_semaphore_lock_try_ -#define _di_f_thread_semaphores_adjust_ -#define _di_f_thread_semaphores_decimate_by_ -#define _di_f_thread_semaphores_decrease_by_ -#define _di_f_thread_semaphores_increase_ -#define _di_f_thread_semaphores_increase_by_ -#define _di_f_thread_semaphores_resize_ +#define _di_f_thread_semaphores_adjust_callback_ +#define _di_f_thread_semaphores_resize_callback_ #define _di_f_thread_semaphores_t_ #define _di_f_thread_semaphore_t_ #define _di_f_thread_semaphore_unlock_ #define _di_f_thread_semaphore_value_get_ -#define _di_f_thread_sets_adjust_ -#define _di_f_thread_sets_decimate_by_ -#define _di_f_thread_sets_decrease_by_ -#define _di_f_thread_sets_increase_ -#define _di_f_thread_sets_increase_by_ -#define _di_f_thread_sets_resize_ +#define _di_f_thread_sets_adjust_callback_ +#define _di_f_thread_sets_resize_callback_ #define _di_f_thread_sets_t_ #define _di_f_thread_set_t_ //#define _di_f_thread_signal_mask_ @@ -1838,12 +1782,8 @@ #define _di_f_thread_spin_delete_ #define _di_f_thread_spin_lock_ #define _di_f_thread_spin_lock_try_ -#define _di_f_thread_spins_adjust_ -#define _di_f_thread_spins_decimate_by_ -#define _di_f_thread_spins_decrease_by_ -#define _di_f_thread_spins_increase_ -#define _di_f_thread_spins_increase_by_ -#define _di_f_thread_spins_resize_ +#define _di_f_thread_spins_adjust_callback_ +#define _di_f_thread_spins_resize_callback_ #define _di_f_thread_spins_t_ #define _di_f_thread_spin_t_ #define _di_f_thread_spin_unlock_ diff --git a/build/stand_alone/firewall.config.h b/build/stand_alone/firewall.config.h index 428e4b9..bd25c5c 100644 --- a/build/stand_alone/firewall.config.h +++ b/build/stand_alone/firewall.config.h @@ -758,7 +758,6 @@ #define _di_f_thread_attribute_detach_set_ #define _di_f_thread_attribute_guard_get_ #define _di_f_thread_attribute_guard_set_ -#define _di_f_thread_attributes_adjust_ #define _di_f_thread_attribute_scheduler_inherit_get_ #define _di_f_thread_attribute_scheduler_inherit_set_ #define _di_f_thread_attribute_scheduler_parameter_get_ @@ -767,11 +766,6 @@ #define _di_f_thread_attribute_scheduler_policy_set_ #define _di_f_thread_attribute_scope_get_ #define _di_f_thread_attribute_scope_set_ -#define _di_f_thread_attributes_decimate_by_ -#define _di_f_thread_attributes_decrease_by_ -#define _di_f_thread_attributes_increase_ -#define _di_f_thread_attributes_increase_by_ -#define _di_f_thread_attributes_resize_ //#define _di_f_thread_attributes_t_ #define _di_f_thread_attribute_stack_get_ #define _di_f_thread_attribute_stack_set_ @@ -780,24 +774,12 @@ //#define _di_f_thread_attribute_t_ #define _di_f_thread_barrier_attribute_create_ #define _di_f_thread_barrier_attribute_delete_ -#define _di_f_thread_barrier_attributes_adjust_ -#define _di_f_thread_barrier_attributes_decimate_by_ -#define _di_f_thread_barrier_attributes_decrease_by_ #define _di_f_thread_barrier_attribute_shared_get_ #define _di_f_thread_barrier_attribute_shared_set_ -#define _di_f_thread_barrier_attributes_increase_ -#define _di_f_thread_barrier_attributes_increase_by_ -#define _di_f_thread_barrier_attributes_resize_ //#define _di_f_thread_barrier_attributes_t_ //#define _di_f_thread_barrier_attribute_t_ #define _di_f_thread_barrier_create_ #define _di_f_thread_barrier_delete_ -#define _di_f_thread_barriers_adjust_ -#define _di_f_thread_barriers_decimate_by_ -#define _di_f_thread_barriers_decrease_by_ -#define _di_f_thread_barriers_increase_ -#define _di_f_thread_barriers_increase_by_ -#define _di_f_thread_barriers_resize_ //#define _di_f_thread_barriers_t_ //#define _di_f_thread_barrier_t_ #define _di_f_thread_barrier_wait_ @@ -812,26 +794,14 @@ #define _di_f_thread_condition_attribute_clock_set_ #define _di_f_thread_condition_attribute_create_ #define _di_f_thread_condition_attribute_delete_ -#define _di_f_thread_condition_attributes_adjust_ -#define _di_f_thread_condition_attributes_decimate_by_ -#define _di_f_thread_condition_attributes_decrease_by_ #define _di_f_thread_condition_attribute_shared_get_ #define _di_f_thread_condition_attribute_shared_set_ -#define _di_f_thread_condition_attributes_increase_ -#define _di_f_thread_condition_attributes_increase_by_ -#define _di_f_thread_condition_attributes_resize_ //#define _di_f_thread_condition_attributes_t_ //#define _di_f_thread_condition_attribute_t_ #define _di_f_thread_condition_create_ #define _di_f_thread_condition_delete_ -#define _di_f_thread_conditions_adjust_ -#define _di_f_thread_conditions_decimate_by_ -#define _di_f_thread_conditions_decrease_by_ #define _di_f_thread_condition_signal_ #define _di_f_thread_condition_signal_all_ -#define _di_f_thread_conditions_increase_ -#define _di_f_thread_conditions_increase_by_ -#define _di_f_thread_conditions_resize_ //#define _di_f_thread_conditions_t_ //#define _di_f_thread_condition_t_ #define _di_f_thread_condition_wait_ @@ -839,12 +809,6 @@ #define _di_f_thread_create_ #define _di_f_thread_detach_ #define _di_f_thread_exit_ -#define _di_f_thread_ids_adjust_ -#define _di_f_thread_ids_decimate_by_ -#define _di_f_thread_ids_decrease_by_ -#define _di_f_thread_ids_increase_ -#define _di_f_thread_ids_increase_by_ -#define _di_f_thread_ids_resize_ //#define _di_f_thread_ids_t_ //#define _di_f_thread_id_t_ #define _di_f_thread_join_ @@ -853,25 +817,13 @@ #define _di_f_thread_key_create_ #define _di_f_thread_key_delete_ #define _di_f_thread_key_get_ -#define _di_f_thread_keys_adjust_ -#define _di_f_thread_keys_decimate_by_ -#define _di_f_thread_keys_decrease_by_ #define _di_f_thread_key_set_ -#define _di_f_thread_keys_increase_ -#define _di_f_thread_keys_increase_by_ -#define _di_f_thread_keys_resize_ //#define _di_f_thread_keys_t_ //#define _di_f_thread_key_t_ #define _di_f_thread_lock_attribute_create_ #define _di_f_thread_lock_attribute_delete_ -#define _di_f_thread_lock_attributes_adjust_ -#define _di_f_thread_lock_attributes_decimate_by_ -#define _di_f_thread_lock_attributes_decrease_by_ #define _di_f_thread_lock_attribute_shared_get_ #define _di_f_thread_lock_attribute_shared_set_ -#define _di_f_thread_lock_attributes_increase_ -#define _di_f_thread_lock_attributes_increase_by_ -#define _di_f_thread_lock_attributes_resize_ //#define _di_f_thread_lock_attributes_t_ //#define _di_f_thread_lock_attribute_t_ #define _di_f_thread_lock_create_ @@ -879,12 +831,6 @@ #define _di_f_thread_lock_read_ #define _di_f_thread_lock_read_timed_ #define _di_f_thread_lock_read_try_ -#define _di_f_thread_locks_adjust_ -#define _di_f_thread_locks_decimate_by_ -#define _di_f_thread_locks_decrease_by_ -#define _di_f_thread_locks_increase_ -#define _di_f_thread_locks_increase_by_ -#define _di_f_thread_locks_resize_ //#define _di_f_thread_locks_t_ //#define _di_f_thread_lock_t_ #define _di_f_thread_lock_write_ @@ -896,14 +842,8 @@ #define _di_f_thread_mutex_attribute_priority_ceiling_set_ #define _di_f_thread_mutex_attribute_protocol_get_ #define _di_f_thread_mutex_attribute_protocol_set_ -#define _di_f_thread_mutex_attributes_adjust_ -#define _di_f_thread_mutex_attributes_decimate_by_ -#define _di_f_thread_mutex_attributes_decrease_by_ #define _di_f_thread_mutex_attribute_shared_get_ #define _di_f_thread_mutex_attribute_shared_set_ -#define _di_f_thread_mutex_attributes_increase_ -#define _di_f_thread_mutex_attributes_increase_by_ -#define _di_f_thread_mutex_attributes_resize_ //#define _di_f_thread_mutex_attributes_t_ //#define _di_f_thread_mutex_attribute_t_ #define _di_f_thread_mutex_attribute_type_get_ @@ -915,22 +855,10 @@ #define _di_f_thread_mutex_lock_try_ #define _di_f_thread_mutex_priority_ceiling_get_ #define _di_f_thread_mutex_priority_ceiling_set_ -#define _di_f_thread_mutexs_adjust_ -#define _di_f_thread_mutexs_decimate_by_ -#define _di_f_thread_mutexs_decrease_by_ -#define _di_f_thread_mutexs_increase_ -#define _di_f_thread_mutexs_increase_by_ -#define _di_f_thread_mutexs_resize_ //#define _di_f_thread_mutexs_t_ //#define _di_f_thread_mutex_t_ #define _di_f_thread_mutex_unlock_ #define _di_f_thread_once_ -#define _di_f_thread_onces_adjust_ -#define _di_f_thread_onces_decimate_by_ -#define _di_f_thread_onces_decrease_by_ -#define _di_f_thread_onces_increase_ -#define _di_f_thread_onces_increase_by_ -#define _di_f_thread_onces_resize_ //#define _di_f_thread_onces_t_ //#define _di_f_thread_once_t_ #define _di_f_thread_scheduler_parameter_get_ @@ -944,22 +872,10 @@ #define _di_f_thread_semaphore_lock_ #define _di_f_thread_semaphore_lock_timed_ #define _di_f_thread_semaphore_lock_try_ -#define _di_f_thread_semaphores_adjust_ -#define _di_f_thread_semaphores_decimate_by_ -#define _di_f_thread_semaphores_decrease_by_ -#define _di_f_thread_semaphores_increase_ -#define _di_f_thread_semaphores_increase_by_ -#define _di_f_thread_semaphores_resize_ //#define _di_f_thread_semaphores_t_ //#define _di_f_thread_semaphore_t_ #define _di_f_thread_semaphore_unlock_ #define _di_f_thread_semaphore_value_get_ -#define _di_f_thread_sets_adjust_ -#define _di_f_thread_sets_decimate_by_ -#define _di_f_thread_sets_decrease_by_ -#define _di_f_thread_sets_increase_ -#define _di_f_thread_sets_increase_by_ -#define _di_f_thread_sets_resize_ //#define _di_f_thread_sets_t_ //#define _di_f_thread_set_t_ //#define _di_f_thread_signal_mask_ @@ -969,12 +885,6 @@ #define _di_f_thread_spin_delete_ #define _di_f_thread_spin_lock_ #define _di_f_thread_spin_lock_try_ -#define _di_f_thread_spins_adjust_ -#define _di_f_thread_spins_decimate_by_ -#define _di_f_thread_spins_decrease_by_ -#define _di_f_thread_spins_increase_ -#define _di_f_thread_spins_increase_by_ -#define _di_f_thread_spins_resize_ //#define _di_f_thread_spins_t_ //#define _di_f_thread_spin_t_ #define _di_f_thread_spin_unlock_ diff --git a/level_0/f_thread/c/thread/attribute.c b/level_0/f_thread/c/thread/attribute.c index 4a41d3d..e368a3c 100644 --- a/level_0/f_thread/c/thread/attribute.c +++ b/level_0/f_thread/c/thread/attribute.c @@ -5,121 +5,35 @@ extern "C" { #endif -#ifndef _di_f_thread_attributes_adjust_ - f_status_t f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_attributes_adjust_callback_ + f_status_t f_thread_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for + { + f_thread_attributes_t * const array = (f_thread_attributes_t *) void_array; - return f_memory_array_adjust(length, sizeof(f_thread_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_attributes_adjust_ - -#ifndef _di_f_thread_attributes_decimate_by_ - f_status_t f_thread_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for - - return f_memory_array_adjust(length, sizeof(f_thread_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_attributes_decimate_by_ - -#ifndef _di_f_thread_attributes_decrease_by_ - f_status_t f_thread_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for - - return f_memory_array_adjust(length, sizeof(f_thread_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_attributes_decrease_by_ - -#ifndef _di_f_thread_attributes_increase_ - f_status_t f_thread_attributes_increase(const f_number_unsigned_t step, f_thread_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i])) return F_status_set_error(F_failure); + for (f_number_unsigned_t i = start; i < stop; ++i) { + if (pthread_attr_destroy(&array->array[i])) return F_status_set_error(F_failure); } // for - - return f_memory_array_adjust(length, sizeof(f_thread_attribute_t), (void **) &structure->array, &structure->used, &structure->size); } - return F_data_not; + return F_none; } -#endif // _di_f_thread_attributes_increase_ - -#ifndef _di_f_thread_attributes_increase_by_ - f_status_t f_thread_attributes_increase_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); +#endif // _di_f_thread_attributes_adjust_callback_ - const f_number_unsigned_t length = structure->used + amount; +#ifndef _di_f_thread_attributes_resize_callback_ + f_status_t f_thread_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_thread_attributes_t * const array = (f_thread_attributes_t *) void_array; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for - - return f_memory_array_adjust(length, sizeof(f_thread_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } + for (f_number_unsigned_t i = start; i < stop; ++i) { + if (pthread_attr_destroy(&array->array[i])) return F_status_set_error(F_failure); + } // for } - return F_data_not; - } -#endif // _di_f_thread_attributes_increase_by_ - -#ifndef _di_f_thread_attributes_resize_ - f_status_t f_thread_attributes_resize(const f_number_unsigned_t length, f_thread_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_attribute_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_attributes_resize_ +#endif // _di_f_thread_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/attribute.h b/level_0/f_thread/c/thread/attribute.h index 8453a18..1bdad17 100644 --- a/level_0/f_thread/c/thread/attribute.h +++ b/level_0/f_thread/c/thread/attribute.h @@ -28,8 +28,6 @@ extern "C" { // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)). #define macro_f_thread_attribute_t_clear(attribute) attribute.__align = 0; - - #define macro_f_thread_attribute_t_delete_simple(attribute) f_thread_attribute_delete(&attribute); #endif // _di_f_thread_attribute_t_ /** @@ -52,148 +50,61 @@ extern "C" { #define macro_f_thread_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_attributes_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_attributes_t_resize(status, attributes, length) status = f_thread_attributes_resize(length, &attributes); - #define macro_f_thread_attributes_t_adjust(status, attributes, length) status = f_thread_attributes_adjust(length, &attributes); - - #define macro_f_thread_attributes_t_delete_simple(attributes) f_thread_attributes_resize(0, &attributes); - #define macro_f_thread_attributes_t_destroy_simple(attributes) f_thread_attributes_adjust(0, &attributes); - - #define macro_f_thread_attributes_t_increase(status, step, attributes) status = f_thread_attributes_increase(step, attributes); - #define macro_f_thread_attributes_t_increase_by(status, attributes, amount) status = f_thread_attributes_increase_by(amount, attributes); - #define macro_f_thread_attributes_t_decrease_by(status, attributes, amount) status = f_thread_attributes_decrease_by(amount, attributes); - #define macro_f_thread_attributes_t_decimate_by(status, attributes, amount) status = f_thread_attributes_decimate_by(amount, attributes); #endif // _di_f_thread_attributes_t_ /** - * Resize the thread attributes array. - * - * @param length - * The new size to use. - * @param structure - * The thread attributes array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_attributes_adjust_ - extern f_status_t f_thread_attributes_adjust(const f_number_unsigned_t length, f_thread_attributes_t * const structure); -#endif // _di_f_thread_attributes_adjust_ - -/** - * Resize the thread attributes array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread attributes array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_attributes_decimate_by_ - extern f_status_t f_thread_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure); -#endif // _di_f_thread_attributes_decimate_by_ - -/** - * Resize the thread attributes array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_attributess_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_attributes_decrease_by_ - extern f_status_t f_thread_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure); -#endif // _di_f_thread_attributes_decrease_by_ - -/** - * Increase the size of the thread attributes array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread attributes array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_attributes_increase_ - extern f_status_t f_thread_attributes_increase(const f_number_unsigned_t step, f_thread_attributes_t * const structure); -#endif // _di_f_thread_attributes_increase_ +#ifndef _di_f_thread_attributes_adjust_callback_ + extern f_status_t f_thread_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_attributes_adjust_callback_ /** - * Resize the thread attributes array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_attributess_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_attributes_increase_by_ - extern f_status_t f_thread_attributes_increase_by(const f_number_unsigned_t amount, f_thread_attributes_t * const structure); -#endif // _di_f_thread_attributes_increase_by_ - -/** - * Resize the thread attributes array. * - * @param length - * The new size to use. - * @param structure - * The thread attributes array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_attributes_resize_ - extern f_status_t f_thread_attributes_resize(const f_number_unsigned_t length, f_thread_attributes_t * const structure); -#endif // _di_f_thread_attributes_resize_ +#ifndef _di_f_thread_attributes_resize_callback_ + extern f_status_t f_thread_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/barrier.c b/level_0/f_thread/c/thread/barrier.c index 7679950..6c8d462 100644 --- a/level_0/f_thread/c/thread/barrier.c +++ b/level_0/f_thread/c/thread/barrier.c @@ -5,18 +5,16 @@ extern "C" { #endif -#ifndef _di_f_thread_barriers_adjust_ - f_status_t f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_barriers_adjust_callback_ + f_status_t f_thread_barriers_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_barriers_t * const array = (f_thread_barriers_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_barrier_destroy(&structure->array[i]); + error = pthread_barrier_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -27,56 +25,20 @@ extern "C" { } // for } - return f_memory_array_adjust(length, sizeof(f_thread_barrier_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_barriers_adjust_ +#endif // _di_f_thread_barriers_adjust_callback_ -#ifndef _di_f_thread_barriers_decimate_by_ - f_status_t f_thread_barriers_decimate_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_barrier_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_adjust(length, sizeof(f_thread_barrier_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_barriers_decimate_by_ - -#ifndef _di_f_thread_barriers_decrease_by_ - f_status_t f_thread_barriers_decrease_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; +#ifndef _di_f_thread_barriers_resize_callback_ + f_status_t f_thread_barriers_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_barriers_t * const array = (f_thread_barriers_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_barrier_destroy(&structure->array[i]); + error = pthread_barrier_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -87,111 +49,9 @@ extern "C" { } // for } - return f_memory_array_resize(length, sizeof(f_thread_barrier_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_barriers_decrease_by_ - -#ifndef _di_f_thread_barriers_increase_ - f_status_t f_thread_barriers_increase(const f_number_unsigned_t step, f_thread_barriers_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_barrier_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_barrier_t), (void **) &structure->array, &structure->used, &structure->size); - } - - return F_data_not; - } -#endif // _di_f_thread_barriers_increase_ - -#ifndef _di_f_thread_barriers_increase_by_ - f_status_t f_thread_barriers_increase_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = structure->used + amount; - - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_barrier_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_barrier_t), (void **) &structure->array, &structure->used, &structure->size); - } - } - - return F_data_not; - } -#endif // _di_f_thread_barriers_increase_by_ - -#ifndef _di_f_thread_barriers_resize_ - f_status_t f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_barrier_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_barrier_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_barriers_resize_ +#endif // _di_f_thread_barriers_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/barrier.h b/level_0/f_thread/c/thread/barrier.h index 2bb8a56..5db9f56 100644 --- a/level_0/f_thread/c/thread/barrier.h +++ b/level_0/f_thread/c/thread/barrier.h @@ -27,8 +27,6 @@ extern "C" { #define macro_f_thread_barrier_t_initialize_1(barrier) barrier #define macro_f_thread_barrier_t_clear(barrier) barrier = 0; - - #define macro_f_thread_barrier_t_delete_simple(barrier) f_thread_barrier_delete(&barrier); #endif // _di_f_thread_barrier_t_ /** @@ -51,148 +49,61 @@ extern "C" { #define macro_f_thread_barriers_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_barriers_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_barriers_t_resize(status, barriers, length) status = f_thread_barriers_resize(length, &barriers); - #define macro_f_thread_barriers_t_adjust(status, barriers, length) status = f_thread_barriers_adjust(length, &barriers); - - #define macro_f_thread_barriers_t_delete_simple(barriers) f_thread_barriers_resize(0, &barriers); - #define macro_f_thread_barriers_t_destroy_simple(barriers) f_thread_barriers_adjust(0, &barriers); - - #define macro_f_thread_barriers_t_increase(status, step, barriers) status = f_thread_barriers_increase(step, barriers); - #define macro_f_thread_barriers_t_increase_by(status, barriers, amount) status = f_thread_barriers_increase_by(amount, barriers); - #define macro_f_thread_barriers_t_decrease_by(status, barriers, amount) status = f_thread_barriers_decrease_by(amount, barriers); - #define macro_f_thread_barriers_t_decimate_by(status, barriers, amount) status = f_thread_barriers_decimate_by(amount, barriers); #endif // _di_f_thread_barriers_t_ /** - * Resize the thread barriers array. - * - * @param length - * The new size to use. - * @param structure - * The thread barriers array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_barriers_adjust_ - extern f_status_t f_thread_barriers_adjust(const f_number_unsigned_t length, f_thread_barriers_t * const structure); -#endif // _di_f_thread_barriers_adjust_ - -/** - * Resize the thread barriers array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread barriers array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_barriers_decimate_by_ - extern f_status_t f_thread_barriers_decimate_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure); -#endif // _di_f_thread_barriers_decimate_by_ - -/** - * Resize the thread barriers array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_barrierss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread barriers array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_barriers_decrease_by_ - extern f_status_t f_thread_barriers_decrease_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure); -#endif // _di_f_thread_barriers_decrease_by_ - -/** - * Increase the size of the thread barriers array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread barriers array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_barriers_increase_ - extern f_status_t f_thread_barriers_increase(const f_number_unsigned_t step, f_thread_barriers_t * const structure); -#endif // _di_f_thread_barriers_increase_ +#ifndef _di_f_thread_barriers_adjust_callback_ + extern f_status_t f_thread_barriers_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_barriers_adjust_callback_ /** - * Resize the thread barriers array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_barrierss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread barriers array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_barriers_increase_by_ - extern f_status_t f_thread_barriers_increase_by(const f_number_unsigned_t amount, f_thread_barriers_t * const structure); -#endif // _di_f_thread_barriers_increase_by_ - -/** - * Resize the thread barriers array. * - * @param length - * The new size to use. - * @param structure - * The thread barriers array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_barriers_resize_ - extern f_status_t f_thread_barriers_resize(const f_number_unsigned_t length, f_thread_barriers_t * const structure); -#endif // _di_f_thread_barriers_resize_ +#ifndef _di_f_thread_barriers_resize_callback_ + extern f_status_t f_thread_barriers_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_barriers_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/barrier_attribute.c b/level_0/f_thread/c/thread/barrier_attribute.c index bed0c32..d631255 100644 --- a/level_0/f_thread/c/thread/barrier_attribute.c +++ b/level_0/f_thread/c/thread/barrier_attribute.c @@ -5,121 +5,35 @@ extern "C" { #endif -#ifndef _di_f_thread_barrier_attributes_adjust_ - f_status_t f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_barrier_attributes_adjust_callback_ + f_status_t f_thread_barrier_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_barrierattr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for + { + f_thread_barrier_attributes_t * const array = (f_thread_barrier_attributes_t *) void_array; - return f_memory_array_adjust(length, sizeof(f_thread_barrier_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_barrier_attributes_adjust_ - -#ifndef _di_f_thread_barrier_attributes_decimate_by_ - f_status_t f_thread_barrier_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_barrierattr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for - - return f_memory_array_adjust(length, sizeof(f_thread_barrier_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_barrier_attributes_decimate_by_ - -#ifndef _di_f_thread_barrier_attributes_decrease_by_ - f_status_t f_thread_barrier_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_barrierattr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_barrier_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_barrier_attributes_decrease_by_ - -#ifndef _di_f_thread_barrier_attributes_increase_ - f_status_t f_thread_barrier_attributes_increase(const f_number_unsigned_t step, f_thread_barrier_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_barrierattr_destroy(&structure->array[i])) return F_status_set_error(F_failure); + for (f_number_unsigned_t i = start; i < stop; ++i) { + if (pthread_barrierattr_destroy(&array->array[i])) return F_status_set_error(F_failure); } // for - - return f_memory_array_resize(length, sizeof(f_thread_barrier_attribute_t), (void **) &structure->array, &structure->used, &structure->size); } - return F_data_not; + return F_none; } -#endif // _di_f_thread_barrier_attributes_increase_ - -#ifndef _di_f_thread_barrier_attributes_increase_by_ - f_status_t f_thread_barrier_attributes_increase_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); +#endif // _di_f_thread_barrier_attributes_adjust_callback_ - const f_number_unsigned_t length = structure->used + amount; +#ifndef _di_f_thread_barrier_attributes_resize_callback_ + f_status_t f_thread_barrier_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_thread_barrier_attributes_t * const array = (f_thread_barrier_attributes_t *) void_array; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_barrierattr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_barrier_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } + for (f_number_unsigned_t i = start; i < stop; ++i) { + if (pthread_barrierattr_destroy(&array->array[i])) return F_status_set_error(F_failure); + } // for } - return F_data_not; - } -#endif // _di_f_thread_barrier_attributes_increase_by_ - -#ifndef _di_f_thread_barrier_attributes_resize_ - f_status_t f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_barrierattr_destroy(&structure->array[i])) return F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_barrier_attribute_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_barrier_attributes_resize_ +#endif // _di_f_thread_barrier_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/barrier_attribute.h b/level_0/f_thread/c/thread/barrier_attribute.h index 0d7b577..ae74d7e 100644 --- a/level_0/f_thread/c/thread/barrier_attribute.h +++ b/level_0/f_thread/c/thread/barrier_attribute.h @@ -28,8 +28,6 @@ extern "C" { // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)). #define macro_f_thread_barrier_attribute_t_clear(attribute) attribute.__align = 0; - - #define macro_f_thread_barrier_attribute_t_delete_simple(attribute) f_thread_barrier_attribute_delete(&attribute); #endif // _di_f_thread_barrier_attribute_t_ /** @@ -52,148 +50,61 @@ extern "C" { #define macro_f_thread_barrier_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_barrier_attributes_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_barrier_attributes_t_resize(status, barrier_attributes, length) status = f_thread_barrier_attributes_resize(length, &barrier_attributes); - #define macro_f_thread_barrier_attributes_t_adjust(status, barrier_attributes, length) status = f_thread_barrier_attributes_adjust(length, &barrier_attributes); - - #define macro_f_thread_barrier_attributes_t_delete_simple(barrier_attributes) f_thread_barrier_attributes_resize(0, &barrier_attributes); - #define macro_f_thread_barrier_attributes_t_destroy_simple(barrier_attributes) f_thread_barrier_attributes_adjust(0, &barrier_attributes); - - #define macro_f_thread_barrier_attributes_t_increase(status, step, barrier_attributes) status = f_thread_barrier_attributes_increase(step, barrier_attributes); - #define macro_f_thread_barrier_attributes_t_increase_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_increase_by(amount, barrier_attributes); - #define macro_f_thread_barrier_attributes_t_decrease_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_decrease_by(amount, barrier_attributes); - #define macro_f_thread_barrier_attributes_t_decimate_by(status, barrier_attributes, amount) status = f_thread_barrier_attributes_decimate_by(amount, barrier_attributes); #endif // _di_f_thread_barrier_attributes_t_ /** - * Resize the thread barrier_attributes array. - * - * @param length - * The new size to use. - * @param structure - * The thread barrier_attributes array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_barrier_attributes_adjust_ - extern f_status_t f_thread_barrier_attributes_adjust(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure); -#endif // _di_f_thread_barrier_attributes_adjust_ - -/** - * Resize the thread barrier_attributes array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread barrier_attributes array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_barrier_attributes_decimate_by_ - extern f_status_t f_thread_barrier_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure); -#endif // _di_f_thread_barrier_attributes_decimate_by_ - -/** - * Resize the thread barrier_attributes array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_barrier_attributess_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread barrier_attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_barrier_attributes_decrease_by_ - extern f_status_t f_thread_barrier_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure); -#endif // _di_f_thread_barrier_attributes_decrease_by_ - -/** - * Increase the size of the thread barrier_attributes array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread barrier_attributes array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_barrier_attributes_increase_ - extern f_status_t f_thread_barrier_attributes_increase(const f_number_unsigned_t step, f_thread_barrier_attributes_t * const structure); -#endif // _di_f_thread_barrier_attributes_increase_ +#ifndef _di_f_thread_barrier_attributes_adjust_callback_ + extern f_status_t f_thread_barrier_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_barrier_attributes_adjust_callback_ /** - * Resize the thread barrier_attributes array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_barrier_attributess_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread barrier_attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_barrier_attributes_increase_by_ - extern f_status_t f_thread_barrier_attributes_increase_by(const f_number_unsigned_t amount, f_thread_barrier_attributes_t * const structure); -#endif // _di_f_thread_barrier_attributes_increase_by_ - -/** - * Resize the thread barrier_attributes array. * - * @param length - * The new size to use. - * @param structure - * The thread barrier_attributes array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_barrier_attributes_resize_ - extern f_status_t f_thread_barrier_attributes_resize(const f_number_unsigned_t length, f_thread_barrier_attributes_t * const structure); -#endif // _di_f_thread_barrier_attributes_resize_ +#ifndef _di_f_thread_barrier_attributes_resize_callback_ + extern f_status_t f_thread_barrier_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_barrier_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/condition.c b/level_0/f_thread/c/thread/condition.c index 7fe5170..fe9da2b 100644 --- a/level_0/f_thread/c/thread/condition.c +++ b/level_0/f_thread/c/thread/condition.c @@ -5,18 +5,16 @@ extern "C" { #endif -#ifndef _di_f_thread_conditions_adjust_ - f_status_t f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_conditions_adjust_callback_ + f_status_t f_thread_conditions_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_conditions_t * const array = (f_thread_conditions_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_cond_destroy(&structure->array[i]); + error = pthread_cond_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -27,158 +25,20 @@ extern "C" { } // for } - return f_memory_array_adjust(length, sizeof(f_thread_condition_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_conditions_adjust_ +#endif // _di_f_thread_conditions_adjust_callback_ -#ifndef _di_f_thread_conditions_decimate_by_ - f_status_t f_thread_conditions_decimate_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_cond_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_adjust(length, sizeof(f_thread_condition_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_conditions_decimate_by_ - -#ifndef _di_f_thread_conditions_decrease_by_ - f_status_t f_thread_conditions_decrease_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_cond_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_condition_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_conditions_decrease_by_ - -#ifndef _di_f_thread_conditions_increase_ - f_status_t f_thread_conditions_increase(const f_number_unsigned_t step, f_thread_conditions_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_cond_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_condition_t), (void **) &structure->array, &structure->used, &structure->size); - } - - return F_data_not; - } -#endif // _di_f_thread_conditions_increase_ - -#ifndef _di_f_thread_conditions_increase_by_ - f_status_t f_thread_conditions_increase_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = structure->used + amount; - - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_cond_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_condition_t), (void **) &structure->array, &structure->used, &structure->size); - } - } - - return F_data_not; - } -#endif // _di_f_thread_conditions_increase_by_ - -#ifndef _di_f_thread_conditions_resize_ - f_status_t f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_conditions_resize_callback_ + f_status_t f_thread_conditions_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_conditions_t * const array = (f_thread_conditions_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_cond_destroy(&structure->array[i]); + error = pthread_cond_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -189,9 +49,9 @@ extern "C" { } // for } - return f_memory_array_resize(length, sizeof(f_thread_condition_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_conditions_resize_ +#endif // _di_f_thread_conditions_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/condition.h b/level_0/f_thread/c/thread/condition.h index fc87fae..e90dc45 100644 --- a/level_0/f_thread/c/thread/condition.h +++ b/level_0/f_thread/c/thread/condition.h @@ -28,8 +28,6 @@ extern "C" { #define f_thread_condition_t_initialize PTHREAD_COND_INITIALIZER #define macro_f_thread_condition_t_initialize_1(condition) { condition } - - #define macro_f_thread_condition_t_delete_simple(condition) f_thread_condition_delete(&condition); #endif // _di_f_thread_condition_t_ /** @@ -52,148 +50,61 @@ extern "C" { #define macro_f_thread_conditions_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_conditions_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_conditions_t_resize(status, conditions, length) status = f_thread_conditions_resize(length, &conditions); - #define macro_f_thread_conditions_t_adjust(status, conditions, length) status = f_thread_conditions_adjust(length, &conditions); - - #define macro_f_thread_conditions_t_delete_simple(conditions) f_thread_conditions_resize(0, &conditions); - #define macro_f_thread_conditions_t_destroy_simple(conditions) f_thread_conditions_adjust(0, &conditions); - - #define macro_f_thread_conditions_t_increase(status, step, conditions) status = f_thread_conditions_increase(step, conditions); - #define macro_f_thread_conditions_t_increase_by(status, conditions, amount) status = f_thread_conditions_increase_by(amount, conditions); - #define macro_f_thread_conditions_t_decrease_by(status, conditions, amount) status = f_thread_conditions_decrease_by(amount, conditions); - #define macro_f_thread_conditions_t_decimate_by(status, conditions, amount) status = f_thread_conditions_decimate_by(amount, conditions); #endif // _di_f_thread_conditions_t_ /** - * Resize the thread conditions array. - * - * @param length - * The new size to use. - * @param structure - * The thread conditions array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_conditions_adjust_ - extern f_status_t f_thread_conditions_adjust(const f_number_unsigned_t length, f_thread_conditions_t * const structure); -#endif // _di_f_thread_conditions_adjust_ - -/** - * Resize the thread conditions array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread conditions array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_conditions_decimate_by_ - extern f_status_t f_thread_conditions_decimate_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure); -#endif // _di_f_thread_conditions_decimate_by_ - -/** - * Resize the thread conditions array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_conditionss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread conditions array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_conditions_decrease_by_ - extern f_status_t f_thread_conditions_decrease_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure); -#endif // _di_f_thread_conditions_decrease_by_ - -/** - * Increase the size of the thread conditions array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread conditions array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_conditions_increase_ - extern f_status_t f_thread_conditions_increase(const f_number_unsigned_t step, f_thread_conditions_t * const structure); -#endif // _di_f_thread_conditions_increase_ +#ifndef _di_f_thread_conditions_adjust_callback_ + extern f_status_t f_thread_conditions_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_conditions_adjust_callback_ /** - * Resize the thread conditions array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_conditionss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread conditions array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_conditions_increase_by_ - extern f_status_t f_thread_conditions_increase_by(const f_number_unsigned_t amount, f_thread_conditions_t * const structure); -#endif // _di_f_thread_conditions_increase_by_ - -/** - * Resize the thread conditions array. * - * @param length - * The new size to use. - * @param structure - * The thread conditions array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_conditions_resize_ - extern f_status_t f_thread_conditions_resize(const f_number_unsigned_t length, f_thread_conditions_t * const structure); -#endif // _di_f_thread_conditions_resize_ +#ifndef _di_f_thread_conditions_resize_callback_ + extern f_status_t f_thread_conditions_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_conditions_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/condition_attribute.c b/level_0/f_thread/c/thread/condition_attribute.c index ebca2de..266b2eb 100644 --- a/level_0/f_thread/c/thread/condition_attribute.c +++ b/level_0/f_thread/c/thread/condition_attribute.c @@ -5,18 +5,16 @@ extern "C" { #endif -#ifndef _di_f_thread_condition_attributes_adjust_ - f_status_t f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_condition_attributes_adjust_callback_ + f_status_t f_thread_condition_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_condition_attributes_t * const array = (f_thread_condition_attributes_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_condattr_destroy(&structure->array[i]); + error = pthread_condattr_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -27,158 +25,20 @@ extern "C" { } // for } - return f_memory_array_adjust(length, sizeof(f_thread_condition_attribute_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_condition_attributes_adjust_ +#endif // _di_f_thread_condition_attributes_adjust_callback_ -#ifndef _di_f_thread_condition_attributes_decimate_by_ - f_status_t f_thread_condition_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_condattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_adjust(length, sizeof(f_thread_condition_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_condition_attributes_decimate_by_ - -#ifndef _di_f_thread_condition_attributes_decrease_by_ - f_status_t f_thread_condition_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_condattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_condition_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_condition_attributes_decrease_by_ - -#ifndef _di_f_thread_condition_attributes_increase_ - f_status_t f_thread_condition_attributes_increase(const f_number_unsigned_t step, f_thread_condition_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_condattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_condition_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } - - return F_data_not; - } -#endif // _di_f_thread_condition_attributes_increase_ - -#ifndef _di_f_thread_condition_attributes_increase_by_ - f_status_t f_thread_condition_attributes_increase_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = structure->used + amount; - - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_condattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_condition_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } - } - - return F_data_not; - } -#endif // _di_f_thread_condition_attributes_increase_by_ - -#ifndef _di_f_thread_condition_attributes_resize_ - f_status_t f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_condition_attributes_resize_callback_ + f_status_t f_thread_condition_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_condition_attributes_t * const array = (f_thread_condition_attributes_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_condattr_destroy(&structure->array[i]); + error = pthread_condattr_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -189,9 +49,9 @@ extern "C" { } // for } - return f_memory_array_resize(length, sizeof(f_thread_condition_attribute_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_condition_attributes_resize_ +#endif // _di_f_thread_condition_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/condition_attribute.h b/level_0/f_thread/c/thread/condition_attribute.h index cf2659d..9b3afcf 100644 --- a/level_0/f_thread/c/thread/condition_attribute.h +++ b/level_0/f_thread/c/thread/condition_attribute.h @@ -28,8 +28,6 @@ extern "C" { // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)). #define macro_f_thread_condition_attribute_t_clear(attribute) attribute.__align = 0; - - #define macro_f_thread_condition_attribute_t_delete_simple(attribute) f_thread_condition_attribute_delete(&attribute); #endif // _di_f_thread_condition_attribute_t_ /** @@ -52,148 +50,61 @@ extern "C" { #define macro_f_thread_condition_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_condition_attributes_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_condition_attributes_t_resize(status, attributes, length) status = f_thread_condition_attributes_resize(length, &attributes); - #define macro_f_thread_condition_attributes_t_adjust(status, attributes, length) status = f_thread_condition_attributes_adjust(length, &attributes); - - #define macro_f_thread_condition_attributes_t_delete_simple(attributes) f_thread_condition_attributes_resize(0, &condition_attributes); - #define macro_f_thread_condition_attributes_t_destroy_simple(attributes) f_thread_condition_attributes_adjust(0, &condition_attributes); - - #define macro_f_thread_condition_attributes_t_increase(status, step, attributes) status = f_thread_condition_attributes_increase(step, attributes); - #define macro_f_thread_condition_attributes_t_increase_by(status, attributes, amount) status = f_thread_condition_attributes_increase_by(amount, attributes); - #define macro_f_thread_condition_attributes_t_decrease_by(status, attributes, amount) status = f_thread_condition_attributes_decrease_by(amount, attributes); - #define macro_f_thread_condition_attributes_t_decimate_by(status, attributes, amount) status = f_thread_condition_attributes_decimate_by(amount, attributes); #endif // _di_f_thread_condition_attributes_t_ /** - * Resize the thread condition_attributes array. - * - * @param length - * The new size to use. - * @param structure - * The thread condition_attributes array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_condition_attributes_adjust_ - extern f_status_t f_thread_condition_attributes_adjust(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure); -#endif // _di_f_thread_condition_attributes_adjust_ - -/** - * Resize the thread condition_attributes array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread condition_attributes array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_condition_attributes_decimate_by_ - extern f_status_t f_thread_condition_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure); -#endif // _di_f_thread_condition_attributes_decimate_by_ - -/** - * Resize the thread condition_attributes array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_condition_attributess_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread condition_attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_condition_attributes_decrease_by_ - extern f_status_t f_thread_condition_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure); -#endif // _di_f_thread_condition_attributes_decrease_by_ - -/** - * Increase the size of the thread condition_attributes array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread condition_attributes array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_condition_attributes_increase_ - extern f_status_t f_thread_condition_attributes_increase(const f_number_unsigned_t step, f_thread_condition_attributes_t * const structure); -#endif // _di_f_thread_condition_attributes_increase_ +#ifndef _di_f_thread_condition_attributes_adjust_callback_ + extern f_status_t f_thread_condition_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_condition_attributes_adjust_callback_ /** - * Resize the thread condition_attributes array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_condition_attributess_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread condition_attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_condition_attributes_increase_by_ - extern f_status_t f_thread_condition_attributes_increase_by(const f_number_unsigned_t amount, f_thread_condition_attributes_t * const structure); -#endif // _di_f_thread_condition_attributes_increase_by_ - -/** - * Resize the thread condition_attributes array. * - * @param length - * The new size to use. - * @param structure - * The thread condition_attributes array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_condition_attributes_resize_ - extern f_status_t f_thread_condition_attributes_resize(const f_number_unsigned_t length, f_thread_condition_attributes_t * const structure); -#endif // _di_f_thread_condition_attributes_resize_ +#ifndef _di_f_thread_condition_attributes_resize_callback_ + extern f_status_t f_thread_condition_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_condition_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/id.c b/level_0/f_thread/c/thread/id.c index 9068235..ed47439 100644 --- a/level_0/f_thread/c/thread/id.c +++ b/level_0/f_thread/c/thread/id.c @@ -5,66 +5,6 @@ extern "C" { #endif -#ifndef _di_f_thread_ids_adjust_ - f_status_t f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_adjust(length, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_ids_adjust_ - -#ifndef _di_f_thread_ids_decimate_by_ - f_status_t f_thread_ids_decimate_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decrease_by(amount, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_ids_decimate_by_ - -#ifndef _di_f_thread_ids_decrease_by_ - f_status_t f_thread_ids_decrease_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decrease_by(amount, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_ids_decrease_by_ - -#ifndef _di_f_thread_ids_increase_ - f_status_t f_thread_ids_increase(const f_number_unsigned_t step, f_thread_ids_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_ids_increase_ - -#ifndef _di_f_thread_ids_increase_by_ - f_status_t f_thread_ids_increase_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase_by(amount, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_ids_increase_by_ - -#ifndef _di_f_thread_ids_resize_ - f_status_t f_thread_ids_resize(const f_number_unsigned_t length, f_thread_ids_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_resize(length, sizeof(f_thread_id_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_ids_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/id.h b/level_0/f_thread/c/thread/id.h index ad92ae0..f98a070 100644 --- a/level_0/f_thread/c/thread/id.h +++ b/level_0/f_thread/c/thread/id.h @@ -47,149 +47,8 @@ extern "C" { #define macro_f_thread_ids_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_ids_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_ids_t_resize(status, attributes, length) status = f_thread_ids_resize(length, &attributes); - #define macro_f_thread_ids_t_adjust(status, attributes, length) status = f_thread_ids_adjust(length, &attributes); - - #define macro_f_thread_ids_t_delete_simple(attributes) f_thread_ids_resize(0, &ids); - #define macro_f_thread_ids_t_destroy_simple(attributes) f_thread_ids_adjust(0, &ids); - - #define macro_f_thread_ids_t_increase(status, step, attributes) status = f_thread_ids_increase(step, attributes); - #define macro_f_thread_ids_t_increase_by(status, attributes, amount) status = f_thread_ids_increase_by(amount, attributes); - #define macro_f_thread_ids_t_decrease_by(status, attributes, amount) status = f_thread_ids_decrease_by(amount, attributes); - #define macro_f_thread_ids_t_decimate_by(status, attributes, amount) status = f_thread_ids_decimate_by(amount, attributes); #endif // _di_f_thread_ids_t_ -/** - * Resize the thread ids array. - * - * @param length - * The new size to use. - * @param structure - * The thread ids array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_ids_adjust_ - extern f_status_t f_thread_ids_adjust(const f_number_unsigned_t length, f_thread_ids_t * const structure); -#endif // _di_f_thread_ids_adjust_ - -/** - * Resize the thread ids array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread ids array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_ids_decimate_by_ - extern f_status_t f_thread_ids_decimate_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure); -#endif // _di_f_thread_ids_decimate_by_ - -/** - * Resize the thread ids array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread ids array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_ids_decrease_by_ - extern f_status_t f_thread_ids_decrease_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure); -#endif // _di_f_thread_ids_decrease_by_ - -/** - * Increase the size of the thread ids array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread ids array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_ids_increase_ - extern f_status_t f_thread_ids_increase(const f_number_unsigned_t step, f_thread_ids_t * const structure); -#endif // _di_f_thread_ids_increase_ - -/** - * Resize the thread ids array to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread ids array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_ids_increase_by_ - extern f_status_t f_thread_ids_increase_by(const f_number_unsigned_t amount, f_thread_ids_t * const structure); -#endif // _di_f_thread_ids_increase_by_ - -/** - * Resize the thread ids array. - * - * @param length - * The new size to use. - * @param structure - * The thread ids array to adjust. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_ids_resize_ - extern f_status_t f_thread_ids_resize(const f_number_unsigned_t length, f_thread_ids_t * const structure); -#endif // _di_f_thread_ids_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/key.c b/level_0/f_thread/c/thread/key.c index 156501a..087277a 100644 --- a/level_0/f_thread/c/thread/key.c +++ b/level_0/f_thread/c/thread/key.c @@ -5,139 +5,41 @@ extern "C" { #endif -#ifndef _di_f_thread_keys_adjust_ - f_status_t f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_keys_adjust_callback_ + f_status_t f_thread_keys_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + { + f_thread_keys_t * const array = (f_thread_keys_t *) void_array; - if (pthread_key_delete(structure->array[i])) return F_status_set_error(F_failure); + for (f_number_unsigned_t i = start; i < stop; ++i) { - structure->array[i] = 0; - } // for + if (pthread_key_delete(array->array[i])) return F_status_set_error(F_failure); - return f_memory_array_adjust(length, sizeof(f_thread_key_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_keys_adjust_ - -#ifndef _di_f_thread_keys_decimate_by_ - f_status_t f_thread_keys_decimate_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - if (pthread_key_delete(structure->array[i])) return F_status_set_error(F_failure); - - structure->array[i] = 0; - } // for - - return f_memory_array_adjust(length, sizeof(f_thread_key_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_keys_decimate_by_ - -#ifndef _di_f_thread_keys_decrease_by_ - f_status_t f_thread_keys_decrease_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - if (pthread_key_delete(structure->array[i])) return F_status_set_error(F_failure); - - structure->array[i] = 0; - } // for - - return f_memory_array_resize(length, sizeof(f_thread_key_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_keys_decrease_by_ - -#ifndef _di_f_thread_keys_increase_ - f_status_t f_thread_keys_increase(const f_number_unsigned_t step, f_thread_keys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - if (pthread_key_delete(structure->array[i])) return F_status_set_error(F_failure); - - structure->array[i] = 0; + array->array[i] = 0; } // for - - return f_memory_array_resize(length, sizeof(f_thread_key_t), (void **) &structure->array, &structure->used, &structure->size); } - return F_data_not; + return F_none; } -#endif // _di_f_thread_keys_increase_ - -#ifndef _di_f_thread_keys_increase_by_ - f_status_t f_thread_keys_increase_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); +#endif // _di_f_thread_keys_adjust_callback_ - const f_number_unsigned_t length = structure->used + amount; +#ifndef _di_f_thread_keys_resize_callback_ + f_status_t f_thread_keys_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_thread_keys_t * const array = (f_thread_keys_t *) void_array; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - if (pthread_key_delete(structure->array[i])) return F_status_set_error(F_failure); + if (pthread_key_delete(array->array[i])) return F_status_set_error(F_failure); - structure->array[i] = 0; - } // for - - return f_memory_array_resize(length, sizeof(f_thread_key_t), (void **) &structure->array, &structure->used, &structure->size); - } + array->array[i] = 0; + } // for } - return F_data_not; - } -#endif // _di_f_thread_keys_increase_by_ - -#ifndef _di_f_thread_keys_resize_ - f_status_t f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - if (pthread_key_delete(structure->array[i])) return F_status_set_error(F_failure); - - structure->array[i] = 0; - } // for - - return f_memory_array_resize(length, sizeof(f_thread_key_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_keys_resize_ +#endif // _di_f_thread_keys_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/key.h b/level_0/f_thread/c/thread/key.h index 48211ce..2f5d41b 100644 --- a/level_0/f_thread/c/thread/key.h +++ b/level_0/f_thread/c/thread/key.h @@ -27,8 +27,6 @@ extern "C" { #define macro_f_thread_key_t_initialize_1(key) key #define macro_f_thread_key_t_clear(key) key = 0; - - #define macro_f_thread_key_t_delete_simple(key) f_thread_key_delete(&key); #endif // _di_f_thread_key_t_ /** @@ -51,148 +49,61 @@ extern "C" { #define macro_f_thread_keys_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_keys_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_keys_t_resize(status, keys, length) status = f_thread_keys_resize(length, &keys); - #define macro_f_thread_keys_t_adjust(status, keys, length) status = f_thread_keys_adjust(length, &keys); - - #define macro_f_thread_keys_t_delete_simple(keys) f_thread_keys_resize(0, &keys); - #define macro_f_thread_keys_t_destroy_simple(keys) f_thread_keys_adjust(0, &keys); - - #define macro_f_thread_keys_t_increase(status, step, keys) status = f_thread_keys_increase(step, keys); - #define macro_f_thread_keys_t_increase_by(status, keys, amount) status = f_thread_keys_increase_by(amount, keys); - #define macro_f_thread_keys_t_decrease_by(status, keys, amount) status = f_thread_keys_decrease_by(amount, keys); - #define macro_f_thread_keys_t_decimate_by(status, keys, amount) status = f_thread_keys_decimate_by(amount, keys); #endif // _di_f_thread_keys_t_ /** - * Resize the thread keys array. - * - * @param length - * The new size to use. - * @param structure - * The thread keys array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_keys_adjust_ - extern f_status_t f_thread_keys_adjust(const f_number_unsigned_t length, f_thread_keys_t * const structure); -#endif // _di_f_thread_keys_adjust_ - -/** - * Resize the thread keys array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread keys array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_keys_decimate_by_ - extern f_status_t f_thread_keys_decimate_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure); -#endif // _di_f_thread_keys_decimate_by_ - -/** - * Resize the thread keys array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_keyss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread keys array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_keys_decrease_by_ - extern f_status_t f_thread_keys_decrease_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure); -#endif // _di_f_thread_keys_decrease_by_ - -/** - * Increase the size of the thread keys array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread keys array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_keys_increase_ - extern f_status_t f_thread_keys_increase(const f_number_unsigned_t step, f_thread_keys_t * const structure); -#endif // _di_f_thread_keys_increase_ +#ifndef _di_f_thread_keys_adjust_callback_ + extern f_status_t f_thread_keys_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_keys_adjust_callback_ /** - * Resize the thread keys array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_keyss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread keys array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_keys_increase_by_ - extern f_status_t f_thread_keys_increase_by(const f_number_unsigned_t amount, f_thread_keys_t * const structure); -#endif // _di_f_thread_keys_increase_by_ - -/** - * Resize the thread keys array. * - * @param length - * The new size to use. - * @param structure - * The thread keys array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_keys_resize_ - extern f_status_t f_thread_keys_resize(const f_number_unsigned_t length, f_thread_keys_t * const structure); -#endif // _di_f_thread_keys_resize_ +#ifndef _di_f_thread_keys_resize_callback_ + extern f_status_t f_thread_keys_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_keys_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/lock.c b/level_0/f_thread/c/thread/lock.c index f0ba7bf..84d6fc5 100644 --- a/level_0/f_thread/c/thread/lock.c +++ b/level_0/f_thread/c/thread/lock.c @@ -5,18 +5,16 @@ extern "C" { #endif -#ifndef _di_f_thread_locks_adjust_ - f_status_t f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_locks_adjust_callback_ + f_status_t f_thread_locks_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_locks_t * const array = (f_thread_locks_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_rwlock_destroy(&structure->array[i]); + error = pthread_rwlock_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -27,158 +25,20 @@ extern "C" { } // for } - return f_memory_array_adjust(length, sizeof(f_thread_lock_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_locks_adjust_ +#endif // _di_f_thread_locks_adjust_callback_ -#ifndef _di_f_thread_locks_decimate_by_ - f_status_t f_thread_locks_decimate_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_rwlock_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_adjust(length, sizeof(f_thread_lock_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_locks_decimate_by_ - -#ifndef _di_f_thread_locks_decrease_by_ - f_status_t f_thread_locks_decrease_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_rwlock_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_locks_decrease_by_ - -#ifndef _di_f_thread_locks_increase_ - f_status_t f_thread_locks_increase(const f_number_unsigned_t step, f_thread_locks_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_rwlock_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) &structure->array, &structure->used, &structure->size); - } - - return F_data_not; - } -#endif // _di_f_thread_locks_increase_ - -#ifndef _di_f_thread_locks_increase_by_ - f_status_t f_thread_locks_increase_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = structure->used + amount; - - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_rwlock_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) &structure->array, &structure->used, &structure->size); - } - } - - return F_data_not; - } -#endif // _di_f_thread_locks_increase_by_ - -#ifndef _di_f_thread_locks_resize_ - f_status_t f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_locks_resize_callback_ + f_status_t f_thread_locks_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_locks_t * const array = (f_thread_locks_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_rwlock_destroy(&structure->array[i]); + error = pthread_rwlock_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -189,9 +49,9 @@ extern "C" { } // for } - return f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_locks_resize_ +#endif // _di_f_thread_locks_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/lock.h b/level_0/f_thread/c/thread/lock.h index 2cae518..1501904 100644 --- a/level_0/f_thread/c/thread/lock.h +++ b/level_0/f_thread/c/thread/lock.h @@ -28,8 +28,6 @@ extern "C" { #define f_thread_lock_t_initialize PTHREAD_RWLOCK_INITIALIZER #define macro_f_thread_lock_t_initialize_1(lock) lock - - #define macro_f_thread_lock_t_delete_simple(lock) f_thread_lock_delete(&lock); #endif // _di_f_thread_lock_t_ /** @@ -52,148 +50,61 @@ extern "C" { #define macro_f_thread_locks_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_locks_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_locks_t_adjust(status, locks, length) status = f_memory_array_adjust(length, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - #define macro_f_thread_locks_t_resize(status, locks, length) status = f_memory_array_resize(length, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - - #define macro_f_thread_locks_t_delete_simple(locks) f_memory_array_resize(0, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - #define macro_f_thread_locks_t_destroy_simple(locks) f_memory_array_adjust(0, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - - #define macro_f_thread_locks_t_increase(status, step, locks) status = f_memory_array_increase(step, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - #define macro_f_thread_locks_t_increase_by(status, locks, amount) status = f_memory_array_increase_by(amount, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - #define macro_f_thread_locks_t_decrease_by(status, locks, amount) status = f_memory_array_decrease_by(amount, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) - #define macro_f_thread_locks_t_decimate_by(status, locks, amount) status = f_memory_array_decimate_by(amount, sizeof(f_thread_lock_t), (void **) & locks.array, locks.used, locks.size) #endif // _di_f_thread_locks_t_ /** - * Resize the thread locks array. - * - * @param length - * The new size to use. - * @param structure - * The thread locks array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_locks_adjust_ - extern f_status_t f_thread_locks_adjust(const f_number_unsigned_t length, f_thread_locks_t * const structure); -#endif // _di_f_thread_locks_adjust_ - -/** - * Resize the thread locks array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread locks array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_locks_decimate_by_ - extern f_status_t f_thread_locks_decimate_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure); -#endif // _di_f_thread_locks_decimate_by_ - -/** - * Resize the thread locks array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_lockss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread locks array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_locks_decrease_by_ - extern f_status_t f_thread_locks_decrease_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure); -#endif // _di_f_thread_locks_decrease_by_ - -/** - * Increase the size of the thread locks array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread locks array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_locks_increase_ - extern f_status_t f_thread_locks_increase(const f_number_unsigned_t step, f_thread_locks_t * const structure); -#endif // _di_f_thread_locks_increase_ +#ifndef _di_f_thread_locks_adjust_callback_ + extern f_status_t f_thread_locks_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_locks_adjust_callback_ /** - * Resize the thread locks array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_lockss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread locks array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_locks_increase_by_ - extern f_status_t f_thread_locks_increase_by(const f_number_unsigned_t amount, f_thread_locks_t * const structure); -#endif // _di_f_thread_locks_increase_by_ - -/** - * Resize the thread locks array. * - * @param length - * The new size to use. - * @param structure - * The thread locks array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_locks_resize_ - extern f_status_t f_thread_locks_resize(const f_number_unsigned_t length, f_thread_locks_t * const structure); -#endif // _di_f_thread_locks_resize_ +#ifndef _di_f_thread_locks_resize_callback_ + extern f_status_t f_thread_locks_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_locks_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/lock_attribute.c b/level_0/f_thread/c/thread/lock_attribute.c index 9e9c7c3..ddd1e7f 100644 --- a/level_0/f_thread/c/thread/lock_attribute.c +++ b/level_0/f_thread/c/thread/lock_attribute.c @@ -5,18 +5,16 @@ extern "C" { #endif -#ifndef _di_f_thread_lock_attributes_adjust_ - f_status_t f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_lock_attributes_adjust_callback_ + f_status_t f_thread_lock_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_lock_attributes_t * const array = (f_thread_lock_attributes_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_rwlockattr_destroy(&structure->array[i]); + error = pthread_rwlockattr_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -27,158 +25,20 @@ extern "C" { } // for } - return f_memory_array_adjust(length, sizeof(f_thread_lock_attribute_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_lock_attributes_adjust_ +#endif // _di_f_thread_lock_attributes_adjust_callback_ -#ifndef _di_f_thread_lock_attributes_decimate_by_ - f_status_t f_thread_lock_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_rwlockattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_adjust(length, sizeof(f_thread_lock_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_lock_attributes_decimate_by_ - -#ifndef _di_f_thread_lock_attributes_decrease_by_ - f_status_t f_thread_lock_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_rwlockattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_lock_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_lock_attributes_decrease_by_ - -#ifndef _di_f_thread_lock_attributes_increase_ - f_status_t f_thread_lock_attributes_increase(const f_number_unsigned_t step, f_thread_lock_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_rwlockattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_lock_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } - - return F_data_not; - } -#endif // _di_f_thread_lock_attributes_increase_ - -#ifndef _di_f_thread_lock_attributes_increase_by_ - f_status_t f_thread_lock_attributes_increase_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = structure->used + amount; - - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_rwlockattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_lock_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } - } - - return F_data_not; - } -#endif // _di_f_thread_lock_attributes_increase_by_ - -#ifndef _di_f_thread_lock_attributes_resize_ - f_status_t f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_lock_attributes_resize_callback_ + f_status_t f_thread_lock_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_lock_attributes_t * const array = (f_thread_lock_attributes_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_rwlockattr_destroy(&structure->array[i]); + error = pthread_rwlockattr_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -189,9 +49,9 @@ extern "C" { } // for } - return f_memory_array_resize(length, sizeof(f_thread_lock_attribute_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_lock_attributes_resize_ +#endif // _di_f_thread_lock_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/lock_attribute.h b/level_0/f_thread/c/thread/lock_attribute.h index 96ec164..3566a3b 100644 --- a/level_0/f_thread/c/thread/lock_attribute.h +++ b/level_0/f_thread/c/thread/lock_attribute.h @@ -28,8 +28,6 @@ extern "C" { // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)). #define macro_f_thread_lock_attribute_t_clear(attribute) attribute.__align = 0; - - #define macro_f_thread_lock_attribute_t_delete_simple(attribute) f_thread_lock_attribute_delete(&attribute); #endif // _di_f_thread_lock_attribute_t_ /** @@ -52,148 +50,61 @@ extern "C" { #define macro_f_thread_lock_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_lock_attributes_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_lock_attributes_t_resize(status, attributes, length) status = f_thread_lock_attributes_resize(length, &attributes); - #define macro_f_thread_lock_attributes_t_adjust(status, attributes, length) status = f_thread_lock_attributes_adjust(length, &attributes); - - #define macro_f_thread_lock_attributes_t_delete_simple(attributes) f_thread_lock_attributes_resize(0, &attributes); - #define macro_f_thread_lock_attributes_t_destroy_simple(attributes) f_thread_lock_attributes_adjust(0, &attributes); - - #define macro_f_thread_lock_attributes_t_increase(status, step, attributes) status = f_thread_lock_attributes_increase(step, attributes); - #define macro_f_thread_lock_attributes_t_increase_by(status, attributes, amount) status = f_thread_lock_attributes_increase_by(amount, attributes); - #define macro_f_thread_lock_attributes_t_decrease_by(status, attributes, amount) status = f_thread_lock_attributes_decrease_by(amount, attributes); - #define macro_f_thread_lock_attributes_t_decimate_by(status, attributes, amount) status = f_thread_lock_attributes_decimate_by(amount, attributes); #endif // _di_f_thread_lock_attributes_t_ /** - * Resize the thread lock_attributes array. - * - * @param length - * The new size to use. - * @param structure - * The thread lock_attributes array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_lock_attributes_adjust_ - extern f_status_t f_thread_lock_attributes_adjust(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure); -#endif // _di_f_thread_lock_attributes_adjust_ - -/** - * Resize the thread lock_attributes array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread lock_attributes array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_lock_attributes_decimate_by_ - extern f_status_t f_thread_lock_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure); -#endif // _di_f_thread_lock_attributes_decimate_by_ - -/** - * Resize the thread lock_attributes array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_lock_attributess_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread lock_attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_lock_attributes_decrease_by_ - extern f_status_t f_thread_lock_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure); -#endif // _di_f_thread_lock_attributes_decrease_by_ - -/** - * Increase the size of the thread lock_attributes array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread lock_attributes array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_lock_attributes_increase_ - extern f_status_t f_thread_lock_attributes_increase(const f_number_unsigned_t step, f_thread_lock_attributes_t * const structure); -#endif // _di_f_thread_lock_attributes_increase_ +#ifndef _di_f_thread_lock_attributes_adjust_callback_ + extern f_status_t f_thread_lock_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_lock_attributes_adjust_callback_ /** - * Resize the thread lock_attributes array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_lock_attributess_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread lock_attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_lock_attributes_increase_by_ - extern f_status_t f_thread_lock_attributes_increase_by(const f_number_unsigned_t amount, f_thread_lock_attributes_t * const structure); -#endif // _di_f_thread_lock_attributes_increase_by_ - -/** - * Resize the thread lock_attributes array. * - * @param length - * The new size to use. - * @param structure - * The thread lock_attributes array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_lock_attributes_resize_ - extern f_status_t f_thread_lock_attributes_resize(const f_number_unsigned_t length, f_thread_lock_attributes_t * const structure); -#endif // _di_f_thread_lock_attributes_resize_ +#ifndef _di_f_thread_lock_attributes_resize_callback_ + extern f_status_t f_thread_lock_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_lock_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/mutex.c b/level_0/f_thread/c/thread/mutex.c index bbf6fe5..d3154d0 100644 --- a/level_0/f_thread/c/thread/mutex.c +++ b/level_0/f_thread/c/thread/mutex.c @@ -5,18 +5,16 @@ extern "C" { #endif -#ifndef _di_f_thread_mutexs_adjust_ - f_status_t f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_mutexs_adjust_callback_ + f_status_t f_thread_mutexs_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_mutexs_t * const array = (f_thread_mutexs_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_mutex_destroy(&structure->array[i]); + error = pthread_mutex_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -27,158 +25,20 @@ extern "C" { } // for } - return f_memory_array_adjust(length, sizeof(f_thread_mutex_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_mutexs_adjust_ +#endif // _di_f_thread_mutexs_adjust_callback_ -#ifndef _di_f_thread_mutexs_decimate_by_ - f_status_t f_thread_mutexs_decimate_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_mutex_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_adjust(length, sizeof(f_thread_mutex_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_mutexs_decimate_by_ - -#ifndef _di_f_thread_mutexs_decrease_by_ - f_status_t f_thread_mutexs_decrease_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_mutex_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_mutex_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_mutexs_decrease_by_ - -#ifndef _di_f_thread_mutexs_increase_ - f_status_t f_thread_mutexs_increase(const f_number_unsigned_t step, f_thread_mutexs_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_mutex_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_mutex_t), (void **) &structure->array, &structure->used, &structure->size); - } - - return F_data_not; - } -#endif // _di_f_thread_mutexs_increase_ - -#ifndef _di_f_thread_mutexs_increase_by_ - f_status_t f_thread_mutexs_increase_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = structure->used + amount; - - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_mutex_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_mutex_t), (void **) &structure->array, &structure->used, &structure->size); - } - } - - return F_data_not; - } -#endif // _di_f_thread_mutexs_increase_by_ - -#ifndef _di_f_thread_mutexs_resize_ - f_status_t f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_mutexs_resize_callback_ + f_status_t f_thread_mutexs_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_mutexs_t * const array = (f_thread_mutexs_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_mutex_destroy(&structure->array[i]); + error = pthread_mutex_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -189,9 +49,9 @@ extern "C" { } // for } - return f_memory_array_resize(length, sizeof(f_thread_mutex_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_mutexs_resize_ +#endif // _di_f_thread_mutexs_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/mutex.h b/level_0/f_thread/c/thread/mutex.h index cacf0aa..57d203d 100644 --- a/level_0/f_thread/c/thread/mutex.h +++ b/level_0/f_thread/c/thread/mutex.h @@ -30,8 +30,6 @@ extern "C" { #define f_thread_mutex_t_initialize PTHREAD_MUTEX_INITIALIZER #define macro_f_thread_mutex_t_initialize_1(mutex) mutex - - #define macro_f_thread_mutex_t_delete_simple(mutex) f_thread_mutex_delete(&mutex); #endif // _di_f_thread_mutex_t_ /** @@ -54,148 +52,61 @@ extern "C" { #define macro_f_thread_mutexs_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_mutexs_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_mutexs_t_resize(status, mutexs, length) status = f_thread_mutexs_resize(length, &mutexs); - #define macro_f_thread_mutexs_t_adjust(status, mutexs, length) status = f_thread_mutexs_adjust(length, &mutexs); - - #define macro_f_thread_mutexs_t_delete_simple(mutexs) f_thread_mutexs_resize(0, &mutexs); - #define macro_f_thread_mutexs_t_destroy_simple(mutexs) f_thread_mutexs_adjust(0, &mutexs); - - #define macro_f_thread_mutexs_t_increase(status, step, mutexs) status = f_thread_mutexs_increase(step, mutexs); - #define macro_f_thread_mutexs_t_increase_by(status, mutexs, amount) status = f_thread_mutexs_increase_by(amount, mutexs); - #define macro_f_thread_mutexs_t_decrease_by(status, mutexs, amount) status = f_thread_mutexs_decrease_by(amount, mutexs); - #define macro_f_thread_mutexs_t_decimate_by(status, mutexs, amount) status = f_thread_mutexs_decimate_by(amount, mutexs); #endif // _di_f_thread_mutexs_t_ /** - * Resize the thread mutexs array. - * - * @param length - * The new size to use. - * @param structure - * The thread mutexs array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_mutexs_adjust_ - extern f_status_t f_thread_mutexs_adjust(const f_number_unsigned_t length, f_thread_mutexs_t * const structure); -#endif // _di_f_thread_mutexs_adjust_ - -/** - * Resize the thread mutexs array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread mutexs array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_mutexs_decimate_by_ - extern f_status_t f_thread_mutexs_decimate_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure); -#endif // _di_f_thread_mutexs_decimate_by_ - -/** - * Resize the thread mutexs array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_mutexss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread mutexs array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_mutexs_decrease_by_ - extern f_status_t f_thread_mutexs_decrease_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure); -#endif // _di_f_thread_mutexs_decrease_by_ - -/** - * Increase the size of the thread mutexs array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread mutexs array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_mutexs_increase_ - extern f_status_t f_thread_mutexs_increase(const f_number_unsigned_t step, f_thread_mutexs_t * const structure); -#endif // _di_f_thread_mutexs_increase_ +#ifndef _di_f_thread_mutexs_adjust_callback_ + extern f_status_t f_thread_mutexs_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_mutexs_adjust_callback_ /** - * Resize the thread mutexs array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_mutexss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread mutexs array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_mutexs_increase_by_ - extern f_status_t f_thread_mutexs_increase_by(const f_number_unsigned_t amount, f_thread_mutexs_t * const structure); -#endif // _di_f_thread_mutexs_increase_by_ - -/** - * Resize the thread mutexs array. * - * @param length - * The new size to use. - * @param structure - * The thread mutexs array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_mutexs_resize_ - extern f_status_t f_thread_mutexs_resize(const f_number_unsigned_t length, f_thread_mutexs_t * const structure); -#endif // _di_f_thread_mutexs_resize_ +#ifndef _di_f_thread_mutexs_resize_callback_ + extern f_status_t f_thread_mutexs_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_mutexs_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/mutex_attribute.c b/level_0/f_thread/c/thread/mutex_attribute.c index 82257fd..f7dd39f6 100644 --- a/level_0/f_thread/c/thread/mutex_attribute.c +++ b/level_0/f_thread/c/thread/mutex_attribute.c @@ -5,18 +5,16 @@ extern "C" { #endif -#ifndef _di_f_thread_mutex_attributes_adjust_ - f_status_t f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_mutex_attributes_adjust_callback_ + f_status_t f_thread_mutex_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_mutex_attributes_t * const array = (f_thread_mutex_attributes_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_mutexattr_destroy(&structure->array[i]); + error = pthread_mutexattr_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -27,158 +25,20 @@ extern "C" { } // for } - return f_memory_array_adjust(length, sizeof(f_thread_mutex_attribute_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_mutex_attributes_adjust_ +#endif // _di_f_thread_mutex_attributes_adjust_callback_ -#ifndef _di_f_thread_mutex_attributes_decimate_by_ - f_status_t f_thread_mutex_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_mutexattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_adjust(length, sizeof(f_thread_mutex_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_mutex_attributes_decimate_by_ - -#ifndef _di_f_thread_mutex_attributes_decrease_by_ - f_status_t f_thread_mutex_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_mutexattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_mutex_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_mutex_attributes_decrease_by_ - -#ifndef _di_f_thread_mutex_attributes_increase_ - f_status_t f_thread_mutex_attributes_increase(const f_number_unsigned_t step, f_thread_mutex_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_mutexattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_mutex_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } - - return F_data_not; - } -#endif // _di_f_thread_mutex_attributes_increase_ - -#ifndef _di_f_thread_mutex_attributes_increase_by_ - f_status_t f_thread_mutex_attributes_increase_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = structure->used + amount; - - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_mutexattr_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_mutex_attribute_t), (void **) &structure->array, &structure->used, &structure->size); - } - } - - return F_data_not; - } -#endif // _di_f_thread_mutex_attributes_increase_by_ - -#ifndef _di_f_thread_mutex_attributes_resize_ - f_status_t f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_mutex_attributes_resize_callback_ + f_status_t f_thread_mutex_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_mutex_attributes_t * const array = (f_thread_mutex_attributes_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_mutexattr_destroy(&structure->array[i]); + error = pthread_mutexattr_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -189,9 +49,9 @@ extern "C" { } // for } - return f_memory_array_resize(length, sizeof(f_thread_mutex_attribute_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_mutex_attributes_resize_ +#endif // _di_f_thread_mutex_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/mutex_attribute.h b/level_0/f_thread/c/thread/mutex_attribute.h index f3d06ef..dd24c04 100644 --- a/level_0/f_thread/c/thread/mutex_attribute.h +++ b/level_0/f_thread/c/thread/mutex_attribute.h @@ -28,8 +28,6 @@ extern "C" { // This does not clear the thread.attributes.__size array (may need to memset() against a sizeof(pthread_attr_t)). #define macro_f_thread_mutex_attribute_t_clear(attribute) attribute.__align = 0; - - #define macro_f_thread_mutex_attribute_t_delete_simple(attribute) f_thread_mutex_attribute_delete(&attribute); #endif // _di_f_thread_mutex_attribute_t_ /** @@ -52,148 +50,61 @@ extern "C" { #define macro_f_thread_mutex_attributes_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_mutex_attributes_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_mutex_attributes_t_resize(status, attributes, length) status = f_thread_mutex_attributes_resize(length, &attributes); - #define macro_f_thread_mutex_attributes_t_adjust(status, attributes, length) status = f_thread_mutex_attributes_adjust(length, &attributes); - - #define macro_f_thread_mutex_attributes_t_delete_simple(attributes) f_thread_mutex_attributes_resize(0, &attributes); - #define macro_f_thread_mutex_attributes_t_destroy_simple(attributes) f_thread_mutex_attributes_adjust(0, &attributes); - - #define macro_f_thread_mutex_attributes_t_increase(status, step, attributes) status = f_thread_mutex_attributes_increase(step, attributes); - #define macro_f_thread_mutex_attributes_t_increase_by(status, attributes, amount) status = f_thread_mutex_attributes_increase_by(amount, attributes); - #define macro_f_thread_mutex_attributes_t_decrease_by(status, attributes, amount) status = f_thread_mutex_attributes_decrease_by(amount, attributes); - #define macro_f_thread_mutex_attributes_t_decimate_by(status, attributes, amount) status = f_thread_mutex_attributes_decimate_by(amount, attributes); #endif // _di_f_thread_mutex_attributes_t_ /** - * Resize the thread mutex_attributes array. - * - * @param length - * The new size to use. - * @param structure - * The thread mutex_attributes array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_mutex_attributes_adjust_ - extern f_status_t f_thread_mutex_attributes_adjust(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure); -#endif // _di_f_thread_mutex_attributes_adjust_ - -/** - * Resize the thread mutex_attributes array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread mutex_attributes array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_mutex_attributes_decimate_by_ - extern f_status_t f_thread_mutex_attributes_decimate_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure); -#endif // _di_f_thread_mutex_attributes_decimate_by_ - -/** - * Resize the thread mutex_attributes array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_mutex_attributess_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread mutex_attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_mutex_attributes_decrease_by_ - extern f_status_t f_thread_mutex_attributes_decrease_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure); -#endif // _di_f_thread_mutex_attributes_decrease_by_ - -/** - * Increase the size of the thread mutex_attributes array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread mutex_attributes array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_mutex_attributes_increase_ - extern f_status_t f_thread_mutex_attributes_increase(const f_number_unsigned_t step, f_thread_mutex_attributes_t * const structure); -#endif // _di_f_thread_mutex_attributes_increase_ +#ifndef _di_f_thread_mutex_attributes_adjust_callback_ + extern f_status_t f_thread_mutex_attributes_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_mutex_attributes_adjust_callback_ /** - * Resize the thread mutex_attributes array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_mutex_attributess_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread mutex_attributes array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_mutex_attributes_increase_by_ - extern f_status_t f_thread_mutex_attributes_increase_by(const f_number_unsigned_t amount, f_thread_mutex_attributes_t * const structure); -#endif // _di_f_thread_mutex_attributes_increase_by_ - -/** - * Resize the thread mutex_attributes array. * - * @param length - * The new size to use. - * @param structure - * The thread mutex_attributes array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_mutex_attributes_resize_ - extern f_status_t f_thread_mutex_attributes_resize(const f_number_unsigned_t length, f_thread_mutex_attributes_t * const structure); -#endif // _di_f_thread_mutex_attributes_resize_ +#ifndef _di_f_thread_mutex_attributes_resize_callback_ + extern f_status_t f_thread_mutex_attributes_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_mutex_attributes_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/once.c b/level_0/f_thread/c/thread/once.c index 6f98338..a5326ed 100644 --- a/level_0/f_thread/c/thread/once.c +++ b/level_0/f_thread/c/thread/once.c @@ -5,66 +5,6 @@ extern "C" { #endif -#ifndef _di_f_thread_onces_adjust_ - f_status_t f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_adjust(length, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_onces_adjust_ - -#ifndef _di_f_thread_onces_decimate_by_ - f_status_t f_thread_onces_decimate_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decimate_by(amount, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_onces_decimate_by_ - -#ifndef _di_f_thread_onces_decrease_by_ - f_status_t f_thread_onces_decrease_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_decrease_by(amount, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_onces_decrease_by_ - -#ifndef _di_f_thread_onces_increase_ - f_status_t f_thread_onces_increase(const f_number_unsigned_t step, f_thread_onces_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase(step, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_onces_increase_ - -#ifndef _di_f_thread_onces_increase_by_ - f_status_t f_thread_onces_increase_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_increase_by(amount, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_onces_increase_by_ - -#ifndef _di_f_thread_onces_resize_ - f_status_t f_thread_onces_resize(const f_number_unsigned_t length, f_thread_onces_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return f_memory_array_resize(length, sizeof(f_thread_once_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_onces_resize_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/once.h b/level_0/f_thread/c/thread/once.h index 52c55aa..700470d 100644 --- a/level_0/f_thread/c/thread/once.h +++ b/level_0/f_thread/c/thread/once.h @@ -52,148 +52,8 @@ extern "C" { #define macro_f_thread_onces_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_onces_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_onces_t_resize(status, onces, length) status = f_thread_onces_resize(length, &onces); - #define macro_f_thread_onces_t_adjust(status, onces, length) status = f_thread_onces_adjust(length, &onces); - - #define macro_f_thread_onces_t_delete_simple(onces) f_thread_onces_resize(0, &onces); - #define macro_f_thread_onces_t_destroy_simple(onces) f_thread_onces_adjust(0, &onces); - - #define macro_f_thread_onces_t_increase(status, step, onces) status = f_thread_onces_increase(step, onces); - #define macro_f_thread_onces_t_increase_by(status, onces, amount) status = f_thread_onces_increase_by(amount, onces); - #define macro_f_thread_onces_t_decrease_by(status, onces, amount) status = f_thread_onces_decrease_by(amount, onces); - #define macro_f_thread_onces_t_decimate_by(status, onces, amount) status = f_thread_onces_decimate_by(amount, onces); #endif // _di_f_thread_onces_t_ -/** - * Resize the thread onces array. - * - * @param length - * The new size to use. - * @param structure - * The thread onces array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_onces_adjust_ - extern f_status_t f_thread_onces_adjust(const f_number_unsigned_t length, f_thread_onces_t * const structure); -#endif // _di_f_thread_onces_adjust_ - -/** - * Resize the thread onces array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread onces array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_onces_decimate_by_ - extern f_status_t f_thread_onces_decimate_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure); -#endif // _di_f_thread_onces_decimate_by_ - -/** - * Resize the thread onces array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread onces array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_onces_decrease_by_ - extern f_status_t f_thread_onces_decrease_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure); -#endif // _di_f_thread_onces_decrease_by_ - -/** - * Increase the size of the thread onces array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread onces array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_onces_increase_ - extern f_status_t f_thread_onces_increase(const f_number_unsigned_t step, f_thread_onces_t * const structure); -#endif // _di_f_thread_onces_increase_ - -/** - * Resize the thread onces array to a larger size. - * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread onces array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_onces_increase_by_ - extern f_status_t f_thread_onces_increase_by(const f_number_unsigned_t amount, f_thread_onces_t * const structure); -#endif // _di_f_thread_onces_increase_by_ - -/** - * Resize the thread onces array. - * - * @param length - * The new size to use. - * @param structure - * The thread onces array to adjust. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_onces_resize_ - extern f_status_t f_thread_onces_resize(const f_number_unsigned_t length, f_thread_onces_t * const structure); -#endif // _di_f_thread_onces_resize_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/private-once.c b/level_0/f_thread/c/thread/private-once.c deleted file mode 100644 index 34c1509..0000000 --- a/level_0/f_thread/c/thread/private-once.c +++ /dev/null @@ -1,10 +0,0 @@ -#include "../thread.h" -#include "private-once.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#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 deleted file mode 100644 index 06504d6..0000000 --- a/level_0/f_thread/c/thread/private-once.h +++ /dev/null @@ -1,22 +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_once_h -#define _PRIVATE_F_thread_once_h - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _PRIVATE_F_thread_once_h diff --git a/level_0/f_thread/c/thread/semaphore.c b/level_0/f_thread/c/thread/semaphore.c index 484c923..9e21eae 100644 --- a/level_0/f_thread/c/thread/semaphore.c +++ b/level_0/f_thread/c/thread/semaphore.c @@ -5,122 +5,35 @@ extern "C" { #endif -#ifndef _di_f_thread_semaphores_adjust_ - f_status_t f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_semaphores_adjust_callback_ + f_status_t f_thread_semaphores_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (sem_destroy(&structure->array[i]) == -1) return (errno == EINVAL) ? F_status_set_error(F_parameter) : F_status_set_error(F_failure); - } // for + { + f_thread_semaphores_t * const array = (f_thread_semaphores_t *) void_array; - return f_memory_array_adjust(length, sizeof(f_thread_semaphore_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_semaphores_adjust_ - -#ifndef _di_f_thread_semaphores_decimate_by_ - f_status_t f_thread_semaphores_decimate_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (sem_destroy(&structure->array[i]) == -1) return (errno == EINVAL) ? F_status_set_error(F_parameter) : F_status_set_error(F_failure); - } // for - - return f_memory_array_adjust(length, sizeof(f_thread_semaphore_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_semaphores_decimate_by_ - -#ifndef _di_f_thread_semaphores_decrease_by_ - f_status_t f_thread_semaphores_decrease_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (sem_destroy(&structure->array[i]) == -1) return (errno == EINVAL) ? F_status_set_error(F_parameter) : F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_semaphore_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_semaphores_decrease_by_ - -#ifndef _di_f_thread_semaphores_increase_ - f_status_t f_thread_semaphores_increase(const f_number_unsigned_t step, f_thread_semaphores_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (sem_destroy(&structure->array[i]) == -1) return (errno == EINVAL) ? F_status_set_error(F_parameter) : F_status_set_error(F_failure); + for (f_number_unsigned_t i = start; i < stop; ++i) { + if (sem_destroy(&array->array[i]) == -1) return (errno == EINVAL) ? F_status_set_error(F_parameter) : F_status_set_error(F_failure); } // for - - return f_memory_array_resize(length, sizeof(f_thread_semaphore_t), (void **) &structure->array, &structure->used, &structure->size); } - return F_data_not; + return F_none; } -#endif // _di_f_thread_semaphores_increase_ - -#ifndef _di_f_thread_semaphores_increase_by_ - f_status_t f_thread_semaphores_increase_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); +#endif // _di_f_thread_semaphores_adjust_callback_ - const f_number_unsigned_t length = structure->used + amount; +#ifndef _di_f_thread_semaphores_resize_callback_ + f_status_t f_thread_semaphores_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_thread_semaphores_t * const array = (f_thread_semaphores_t *) void_array; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (sem_destroy(&structure->array[i]) == -1) return (errno == EINVAL) ? F_status_set_error(F_parameter) : F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_semaphore_t), (void **) &structure->array, &structure->used, &structure->size); - } + for (f_number_unsigned_t i = start; i < stop; ++i) { + if (sem_destroy(&array->array[i]) == -1) return (errno == EINVAL) ? F_status_set_error(F_parameter) : F_status_set_error(F_failure); + } // for } - return F_data_not; + return F_none; } -#endif // _di_f_thread_semaphores_increase_by_ - -#ifndef _di_f_thread_semaphores_resize_ - f_status_t f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (sem_destroy(&structure->array[i]) == -1) return (errno == EINVAL) ? F_status_set_error(F_parameter) : F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_semaphore_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_semaphores_resize_ - +#endif // _di_f_thread_semaphores_resize_callback_ #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_thread/c/thread/semaphore.h b/level_0/f_thread/c/thread/semaphore.h index 1f622fe..b439014 100644 --- a/level_0/f_thread/c/thread/semaphore.h +++ b/level_0/f_thread/c/thread/semaphore.h @@ -29,8 +29,6 @@ extern "C" { #define f_thread_semaphore_t_initialize { (long) 0 } #define macro_f_thread_semaphore_t_initialize_1(semaphore) semaphore - - #define macro_f_thread_semaphore_t_delete_simple(semaphore) f_thread_semaphore_delete(&semaphore); #endif // _di_f_thread_semaphore_t_ /** @@ -53,148 +51,61 @@ extern "C" { #define macro_f_thread_semaphores_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_semaphores_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_semaphores_t_resize(status, semaphores, length) status = f_thread_semaphores_resize(length, &semaphores); - #define macro_f_thread_semaphores_t_adjust(status, semaphores, length) status = f_thread_semaphores_adjust(length, &semaphores); - - #define macro_f_thread_semaphores_t_delete_simple(semaphores) f_thread_semaphores_resize(0, &semaphores); - #define macro_f_thread_semaphores_t_destroy_simple(semaphores) f_thread_semaphores_adjust(0, &semaphores); - - #define macro_f_thread_semaphores_t_increase(status, step, semaphores) status = f_thread_semaphores_increase(step, semaphores); - #define macro_f_thread_semaphores_t_increase_by(status, semaphores, amount) status = f_thread_semaphores_increase_by(amount, semaphores); - #define macro_f_thread_semaphores_t_decrease_by(status, semaphores, amount) status = f_thread_semaphores_decrease_by(amount, semaphores); - #define macro_f_thread_semaphores_t_decimate_by(status, semaphores, amount) status = f_thread_semaphores_decimate_by(amount, semaphores); #endif // _di_f_thread_semaphores_t_ /** - * Resize the thread semaphores array. - * - * @param length - * The new size to use. - * @param structure - * The thread semaphores array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_semaphores_adjust_ - extern f_status_t f_thread_semaphores_adjust(const f_number_unsigned_t length, f_thread_semaphores_t * const structure); -#endif // _di_f_thread_semaphores_adjust_ - -/** - * Resize the thread semaphores array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread semaphores array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_semaphores_decimate_by_ - extern f_status_t f_thread_semaphores_decimate_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure); -#endif // _di_f_thread_semaphores_decimate_by_ - -/** - * Resize the thread semaphores array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_semaphoress_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread semaphores array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_semaphores_decrease_by_ - extern f_status_t f_thread_semaphores_decrease_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure); -#endif // _di_f_thread_semaphores_decrease_by_ - -/** - * Increase the size of the thread semaphores array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread semaphores array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_semaphores_increase_ - extern f_status_t f_thread_semaphores_increase(const f_number_unsigned_t step, f_thread_semaphores_t * const structure); -#endif // _di_f_thread_semaphores_increase_ +#ifndef _di_f_thread_semaphores_adjust_callback_ + extern f_status_t f_thread_semaphores_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_semaphores_adjust_callback_ /** - * Resize the thread semaphores array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_semaphoress_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread semaphores array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_semaphores_increase_by_ - extern f_status_t f_thread_semaphores_increase_by(const f_number_unsigned_t amount, f_thread_semaphores_t * const structure); -#endif // _di_f_thread_semaphores_increase_by_ - -/** - * Resize the thread semaphores array. * - * @param length - * The new size to use. - * @param structure - * The thread semaphores array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_semaphores_resize_ - extern f_status_t f_thread_semaphores_resize(const f_number_unsigned_t length, f_thread_semaphores_t * const structure); -#endif // _di_f_thread_semaphores_resize_ +#ifndef _di_f_thread_semaphores_resize_callback_ + extern f_status_t f_thread_semaphores_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_semaphores_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/set.c b/level_0/f_thread/c/thread/set.c index f0eb8a7..182049b 100644 --- a/level_0/f_thread/c/thread/set.c +++ b/level_0/f_thread/c/thread/set.c @@ -5,121 +5,35 @@ extern "C" { #endif -#ifndef _di_f_thread_sets_adjust_ - f_status_t f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_sets_adjust_callback_ + f_status_t f_thread_sets_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i].attribute)) return F_status_set_error(F_failure); - } // for + { + f_thread_sets_t * const array = (f_thread_sets_t *) void_array; - return f_memory_array_adjust(length, sizeof(f_thread_set_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_sets_adjust_ - -#ifndef _di_f_thread_sets_decimate_by_ - f_status_t f_thread_sets_decimate_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i].attribute)) return F_status_set_error(F_failure); - } // for - - return f_memory_array_adjust(length, sizeof(f_thread_set_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_sets_decimate_by_ - -#ifndef _di_f_thread_sets_decrease_by_ - f_status_t f_thread_sets_decrease_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i].attribute)) return F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_set_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_sets_decrease_by_ - -#ifndef _di_f_thread_sets_increase_ - f_status_t f_thread_sets_increase(const f_number_unsigned_t step, f_thread_sets_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i].attribute)) return F_status_set_error(F_failure); + for (f_number_unsigned_t i = start; i < stop; ++i) { + if (pthread_attr_destroy(&array->array[i].attribute)) return F_status_set_error(F_failure); } // for - - return f_memory_array_resize(length, sizeof(f_thread_set_t), (void **) &structure->array, &structure->used, &structure->size); } - return F_data_not; + return F_none; } -#endif // _di_f_thread_sets_increase_ - -#ifndef _di_f_thread_sets_increase_by_ - f_status_t f_thread_sets_increase_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); +#endif // _di_f_thread_sets_adjust_callback_ - const f_number_unsigned_t length = structure->used + amount; +#ifndef _di_f_thread_sets_resize_callback_ + f_status_t f_thread_sets_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); + { + f_thread_sets_t * const array = (f_thread_sets_t *) void_array; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i].attribute)) return F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_set_t), (void **) &structure->array, &structure->used, &structure->size); - } + for (f_number_unsigned_t i = start; i < stop; ++i) { + if (pthread_attr_destroy(&array->array[i].attribute)) return F_status_set_error(F_failure); + } // for } - return F_data_not; - } -#endif // _di_f_thread_sets_increase_by_ - -#ifndef _di_f_thread_sets_resize_ - f_status_t f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - if (pthread_attr_destroy(&structure->array[i].attribute)) return F_status_set_error(F_failure); - } // for - - return f_memory_array_resize(length, sizeof(f_thread_set_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_sets_resize_ +#endif // _di_f_thread_sets_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/set.h b/level_0/f_thread/c/thread/set.h index 539f630..5eb8fa4 100644 --- a/level_0/f_thread/c/thread/set.h +++ b/level_0/f_thread/c/thread/set.h @@ -31,7 +31,7 @@ extern "C" { int result; } f_thread_set_t; - #define f_thread_set_t_initialize { f_thread_attribute_t_initialize, f_thread_id_t_initialize, 0 } + #define f_thread_set_t_initialize { 0 } #define macro_f_thread_set_t_initialize_1(attribute, id, result) { attribute, id, result } @@ -39,8 +39,6 @@ extern "C" { macro_f_thread_attribute_t_clear(thread.attribute) \ macro_f_thread_id_t_clear(thread.id) \ result = 0; - - #define macro_f_thread_set_t_delete_simple(set) macro_f_thread_attribute_t_delete_simple(set.attribute) #endif // _di_f_thread_set_t_ /** @@ -63,148 +61,61 @@ extern "C" { #define macro_f_thread_sets_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_sets_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_sets_t_resize(status, sets, length) status = f_thread_sets_resize(length, &sets); - #define macro_f_thread_sets_t_adjust(status, sets, length) status = f_thread_sets_adjust(length, &sets); - - #define macro_f_thread_sets_t_delete_simple(sets) f_thread_sets_resize(0, &sets); - #define macro_f_thread_sets_t_destroy_simple(sets) f_thread_sets_adjust(0, &sets); - - #define macro_f_thread_sets_t_increase(status, step, sets) status = f_thread_sets_increase(step, sets); - #define macro_f_thread_sets_t_increase_by(status, sets, amount) status = f_thread_sets_increase_by(amount, sets); - #define macro_f_thread_sets_t_decrease_by(status, sets, amount) status = f_thread_sets_decrease_by(amount, sets); - #define macro_f_thread_sets_t_decimate_by(status, sets, amount) status = f_thread_sets_decimate_by(amount, sets); #endif // _di_f_thread_sets_t_ /** - * Resize the thread sets array. - * - * @param length - * The new size to use. - * @param structure - * The thread sets array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_sets_adjust_ - extern f_status_t f_thread_sets_adjust(const f_number_unsigned_t length, f_thread_sets_t * const structure); -#endif // _di_f_thread_sets_adjust_ - -/** - * Resize the thread sets array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread sets array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_sets_decimate_by_ - extern f_status_t f_thread_sets_decimate_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure); -#endif // _di_f_thread_sets_decimate_by_ - -/** - * Resize the thread sets array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_setss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread sets array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_sets_decrease_by_ - extern f_status_t f_thread_sets_decrease_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure); -#endif // _di_f_thread_sets_decrease_by_ - -/** - * Increase the size of the thread sets array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread sets array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_sets_increase_ - extern f_status_t f_thread_sets_increase(const f_number_unsigned_t step, f_thread_sets_t * const structure); -#endif // _di_f_thread_sets_increase_ +#ifndef _di_f_thread_sets_adjust_callback_ + extern f_status_t f_thread_sets_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_sets_adjust_callback_ /** - * Resize the thread sets array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_setss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread sets array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_sets_increase_by_ - extern f_status_t f_thread_sets_increase_by(const f_number_unsigned_t amount, f_thread_sets_t * const structure); -#endif // _di_f_thread_sets_increase_by_ - -/** - * Resize the thread sets array. * - * @param length - * The new size to use. - * @param structure - * The thread sets array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_sets_resize_ - extern f_status_t f_thread_sets_resize(const f_number_unsigned_t length, f_thread_sets_t * const structure); -#endif // _di_f_thread_sets_resize_ +#ifndef _di_f_thread_sets_resize_callback_ + extern f_status_t f_thread_sets_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_sets_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/spin.c b/level_0/f_thread/c/thread/spin.c index 6f2f08d..030d1df 100644 --- a/level_0/f_thread/c/thread/spin.c +++ b/level_0/f_thread/c/thread/spin.c @@ -5,18 +5,16 @@ extern "C" { #endif -#ifndef _di_f_thread_spins_adjust_ - f_status_t f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_spins_adjust_callback_ + f_status_t f_thread_spins_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_spins_t * const array = (f_thread_spins_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_spin_destroy(&structure->array[i]); + error = pthread_spin_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -27,158 +25,20 @@ extern "C" { } // for } - return f_memory_array_adjust(length, sizeof(f_thread_spin_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_spins_adjust_ +#endif // _di_f_thread_spins_adjust_callback_ -#ifndef _di_f_thread_spins_decimate_by_ - f_status_t f_thread_spins_decimate_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_spin_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_adjust(length, sizeof(f_thread_spin_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_spins_decimate_by_ - -#ifndef _di_f_thread_spins_decrease_by_ - f_status_t f_thread_spins_decrease_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!amount) return F_data_not; - - const f_number_unsigned_t length = (structure->size > amount) ? structure->size - amount : 0; - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_spin_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_spin_t), (void **) &structure->array, &structure->used, &structure->size); - } -#endif // _di_f_thread_spins_decrease_by_ - -#ifndef _di_f_thread_spins_increase_ - f_status_t f_thread_spins_increase(const f_number_unsigned_t step, f_thread_spins_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (step && structure->used + 1 > structure->size) { - f_number_unsigned_t length = structure->used + step; - - if (length > F_number_t_size_unsigned_d) { - if (structure->used + 1 > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - length = F_number_t_size_unsigned_d; - } - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_spin_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_spin_t), (void **) &structure->array, &structure->used, &structure->size); - } - - return F_data_not; - } -#endif // _di_f_thread_spins_increase_ - -#ifndef _di_f_thread_spins_increase_by_ - f_status_t f_thread_spins_increase_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (amount) { - if (structure->used >= F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - const f_number_unsigned_t length = structure->used + amount; - - if (length > structure->size) { - if (length > F_number_t_size_unsigned_d) return F_status_set_error(F_array_too_large); - - { - int error = 0; - - for (f_number_unsigned_t i = length; i < structure->size; ++i) { - - error = pthread_spin_destroy(&structure->array[i]); - - 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); - } - } // for - } - - return f_memory_array_resize(length, sizeof(f_thread_spin_t), (void **) &structure->array, &structure->used, &structure->size); - } - } - - return F_data_not; - } -#endif // _di_f_thread_spins_increase_by_ - -#ifndef _di_f_thread_spins_resize_ - f_status_t f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const structure) { - #ifndef _di_level_0_parameter_checking_ - if (!structure) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ +#ifndef _di_f_thread_spins_resize_callback_ + f_status_t f_thread_spins_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { + f_thread_spins_t * const array = (f_thread_spins_t *) void_array; int error = 0; - for (f_number_unsigned_t i = length; i < structure->size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { - error = pthread_spin_destroy(&structure->array[i]); + error = pthread_spin_destroy(&array->array[i]); if (error) { if (error == EBUSY) return F_status_set_error(F_busy); @@ -189,9 +49,9 @@ extern "C" { } // for } - return f_memory_array_resize(length, sizeof(f_thread_spin_t), (void **) &structure->array, &structure->used, &structure->size); + return F_none; } -#endif // _di_f_thread_spins_resize_ +#endif // _di_f_thread_spins_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/c/thread/spin.h b/level_0/f_thread/c/thread/spin.h index fd67e6f..be235b4 100644 --- a/level_0/f_thread/c/thread/spin.h +++ b/level_0/f_thread/c/thread/spin.h @@ -27,8 +27,6 @@ extern "C" { #define f_thread_spin_t_initialize ((pthread_spinlock_t) 0xFFFFFFFF) #define macro_f_thread_spin_t_initialize_1(spin) spin - - #define macro_f_thread_spin_t_delete_simple(spin) f_thread_spin_delete(&spin); #endif // _di_f_thread_spin_t_ /** @@ -51,148 +49,61 @@ extern "C" { #define macro_f_thread_spins_t_initialize_1(array, size, used) { array, size, used } #define macro_f_thread_spins_t_initialize_2(array, length) { array, length, length } - - #define macro_f_thread_spins_t_resize(status, spins, length) status = f_thread_spins_resize(length, &spins); - #define macro_f_thread_spins_t_adjust(status, spins, length) status = f_thread_spins_adjust(length, &spins); - - #define macro_f_thread_spins_t_delete_simple(spins) f_thread_spins_resize(0, &spins); - #define macro_f_thread_spins_t_destroy_simple(spins) f_thread_spins_adjust(0, &spins); - - #define macro_f_thread_spins_t_increase(status, step, spins) status = f_thread_spins_increase(step, spins); - #define macro_f_thread_spins_t_increase_by(status, spins, amount) status = f_thread_spins_increase_by(amount, spins); - #define macro_f_thread_spins_t_decrease_by(status, spins, amount) status = f_thread_spins_decrease_by(amount, spins); - #define macro_f_thread_spins_t_decimate_by(status, spins, amount) status = f_thread_spins_decimate_by(amount, spins); #endif // _di_f_thread_spins_t_ /** - * Resize the thread spins array. - * - * @param length - * The new size to use. - * @param structure - * The thread spins array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_spins_adjust_ - extern f_status_t f_thread_spins_adjust(const f_number_unsigned_t length, f_thread_spins_t * const structure); -#endif // _di_f_thread_spins_adjust_ - -/** - * Resize the thread spins array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param structure - * The thread spins array to resize. - * - * @return - * F_none on success. - * F_data_not if amount is 0. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_spins_decimate_by_ - extern f_status_t f_thread_spins_decimate_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure); -#endif // _di_f_thread_spins_decimate_by_ - -/** - * Resize the thread spins array to a smaller size. + * A callback intended to be passed to f_memory_arrays_adjust() for an f_thread_spinss_t structure. * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to decrease the size by. - * @param structure - * The thread spins array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not if amount is 0. * - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_spins_decrease_by_ - extern f_status_t f_thread_spins_decrease_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure); -#endif // _di_f_thread_spins_decrease_by_ - -/** - * Increase the size of the thread spins array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param structure - * The thread spins array to resize. + * Errors (with error bit) from: f_memory_array_adjust(). * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_adjust() + * @see f_memory_arrays_adjust() */ -#ifndef _di_f_thread_spins_increase_ - extern f_status_t f_thread_spins_increase(const f_number_unsigned_t step, f_thread_spins_t * const structure); -#endif // _di_f_thread_spins_increase_ +#ifndef _di_f_thread_spins_adjust_callback_ + extern f_status_t f_thread_spins_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_spins_adjust_callback_ /** - * Resize the thread spins array to a larger size. + * A callback intended to be passed to f_memory_arrays_resize() for an f_thread_spinss_t structure. * - * This will resize making the array larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (F_number_t_size_unsigned_d). - * If already set to the maximum buffer size, then the resize will fail. + * This does not do parameter checking. * - * @param amount - * A positive number representing how much to increase the size by. - * @param structure - * The thread spins array to resize. + * @param start + * The inclusive start position in the array to start deleting. + * @param stop + * The exclusive stop position in the array to stop deleting. + * @param array + * The array structure to delete all values of. + * Must not be NULL. * * @return * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). * - * F_array_too_large (with error bit) if the new array length is too large. - * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_thread_spins_increase_by_ - extern f_status_t f_thread_spins_increase_by(const f_number_unsigned_t amount, f_thread_spins_t * const structure); -#endif // _di_f_thread_spins_increase_by_ - -/** - * Resize the thread spins array. * - * @param length - * The new size to use. - * @param structure - * The thread spins array to adjust. + * Errors (with error bit) from: f_memory_array_resize(). * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. + * @see f_memory_array_resize() + * @see f_memory_arrays_resize() */ -#ifndef _di_f_thread_spins_resize_ - extern f_status_t f_thread_spins_resize(const f_number_unsigned_t length, f_thread_spins_t * const structure); -#endif // _di_f_thread_spins_resize_ +#ifndef _di_f_thread_spins_resize_callback_ + extern f_status_t f_thread_spins_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); +#endif // _di_f_thread_spins_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_thread/data/build/settings-mocks b/level_0/f_thread/data/build/settings-mocks index e09a69d..d1fb85c 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 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 +build_sources_library ../../tests/unit/c/mock-thread.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 @@ -64,6 +65,8 @@ flags-coverage --coverage -fprofile-abs-path -fprofile-dir=build/coverage/ flags_library -fPIC # Inject mocks. +flags -Wl,--wrap=f_memory_array_adjust +flags -Wl,--wrap=f_memory_array_resize flags -Wl,--wrap=pthread_atfork flags -Wl,--wrap=pthread_attr_destroy flags -Wl,--wrap=pthread_attr_getaffinity_np diff --git a/level_0/f_thread/data/build/settings-tests b/level_0/f_thread/data/build/settings-tests index ef1c26f..7d6fe4c 100644 --- a/level_0/f_thread/data/build/settings-tests +++ b/level_0/f_thread/data/build/settings-tests @@ -25,21 +25,19 @@ build_language c build_libraries -lc -lcmocka build_libraries-individual -lf_memory -lf_string -lf_thread -build_sources_program test-thread-attributes_adjust.c test-thread-attributes_decimate_by.c test-thread-attributes_decrease_by.c test-thread-attributes_increase.c test-thread-attributes_increase_by.c test-thread-attributes_resize.c -build_sources_program test-thread-barrier_attributes_adjust.c test-thread-barrier_attributes_decimate_by.c test-thread-barrier_attributes_decrease_by.c test-thread-barrier_attributes_increase.c test-thread-barrier_attributes_increase_by.c test-thread-barrier_attributes_resize.c -build_sources_program test-thread-barriers_adjust.c test-thread-barriers_decimate_by.c test-thread-barriers_decrease_by.c test-thread-barriers_increase.c test-thread-barriers_increase_by.c test-thread-barriers_resize.c -build_sources_program test-thread-condition_attributes_adjust.c test-thread-condition_attributes_decimate_by.c test-thread-condition_attributes_decrease_by.c test-thread-condition_attributes_increase.c test-thread-condition_attributes_increase_by.c test-thread-condition_attributes_resize.c -build_sources_program test-thread-conditions_adjust.c test-thread-conditions_decimate_by.c test-thread-conditions_decrease_by.c test-thread-conditions_increase.c test-thread-conditions_increase_by.c test-thread-conditions_resize.c -build_sources_program test-thread-ids_adjust.c test-thread-ids_decimate_by.c test-thread-ids_decrease_by.c test-thread-ids_increase.c test-thread-ids_increase_by.c test-thread-ids_resize.c -build_sources_program test-thread-keys_adjust.c test-thread-keys_decimate_by.c test-thread-keys_decrease_by.c test-thread-keys_increase.c test-thread-keys_increase_by.c test-thread-keys_resize.c -build_sources_program test-thread-lock_attributes_adjust.c test-thread-lock_attributes_decimate_by.c test-thread-lock_attributes_decrease_by.c test-thread-lock_attributes_increase.c test-thread-lock_attributes_increase_by.c test-thread-lock_attributes_resize.c -build_sources_program test-thread-locks_adjust.c test-thread-locks_decimate_by.c test-thread-locks_decrease_by.c test-thread-locks_increase.c test-thread-locks_increase_by.c test-thread-locks_resize.c -build_sources_program test-thread-mutex_attributes_adjust.c test-thread-mutex_attributes_decimate_by.c test-thread-mutex_attributes_decrease_by.c test-thread-mutex_attributes_increase.c test-thread-mutex_attributes_increase_by.c test-thread-mutex_attributes_resize.c -build_sources_program test-thread-mutexs_adjust.c test-thread-mutexs_decimate_by.c test-thread-mutexs_decrease_by.c test-thread-mutexs_increase.c test-thread-mutexs_increase_by.c test-thread-mutexs_resize.c -build_sources_program test-thread-onces_adjust.c test-thread-onces_decimate_by.c test-thread-onces_decrease_by.c test-thread-onces_increase.c test-thread-onces_increase_by.c test-thread-onces_resize.c -build_sources_program test-thread-semaphores_adjust.c test-thread-semaphores_decimate_by.c test-thread-semaphores_decrease_by.c test-thread-semaphores_increase.c test-thread-semaphores_increase_by.c test-thread-semaphores_resize.c -build_sources_program test-thread-sets_adjust.c test-thread-sets_decimate_by.c test-thread-sets_decrease_by.c test-thread-sets_increase.c test-thread-sets_increase_by.c test-thread-sets_resize.c -build_sources_program test-thread-spins_adjust.c test-thread-spins_decimate_by.c test-thread-spins_decrease_by.c test-thread-spins_increase.c test-thread-spins_increase_by.c test-thread-spins_resize.c +build_sources_program test-thread-attributes_adjust_callback.c test-thread-attributes_resize_callback.c +build_sources_program test-thread-barriers_adjust_callback.c test-thread-barriers_resize_callback.c +build_sources_program test-thread-barrier_attributes_adjust_callback.c test-thread-barrier_attributes_resize_callback.c +build_sources_program test-thread-conditions_adjust_callback.c test-thread-conditions_resize_callback.c +build_sources_program test-thread-condition_attributes_adjust_callback.c test-thread-condition_attributes_resize_callback.c +build_sources_program test-thread-keys_adjust_callback.c test-thread-keys_resize_callback.c +build_sources_program test-thread-locks_adjust_callback.c test-thread-locks_resize_callback.c +build_sources_program test-thread-lock_attributes_adjust_callback.c test-thread-lock_attributes_resize_callback.c +build_sources_program test-thread-mutexs_adjust_callback.c test-thread-mutexs_resize_callback.c +build_sources_program test-thread-mutex_attributes_adjust_callback.c test-thread-mutex_attributes_resize_callback.c +build_sources_program test-thread-semaphores_adjust_callback.c test-thread-semaphores_resize_callback.c +build_sources_program test-thread-sets_adjust_callback.c test-thread-sets_resize_callback.c +build_sources_program test-thread-spins_adjust_callback.c test-thread-spins_resize_callback.c build_sources_program test-thread-at_fork.c build_sources_program test-thread-attribute_affinity_get.c test-thread-attribute_affinity_set.c diff --git a/level_0/f_thread/tests/unit/c/mock-thread.c b/level_0/f_thread/tests/unit/c/mock-thread.c index 26f4aaf..c674e2a 100644 --- a/level_0/f_thread/tests/unit/c/mock-thread.c +++ b/level_0/f_thread/tests/unit/c/mock-thread.c @@ -4,6 +4,32 @@ extern "C" { #endif +f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { + + if (!array || !used || !size) return F_status_set_error(F_parameter_not); + + const bool failure = mock_type(bool); + + if (failure) return mock_type(f_status_t); + + *size = length; + + return mock_type(f_status_t); +} + +f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { + + if (!array || !used || !size) return F_status_set_error(F_parameter_not); + + const bool failure = mock_type(bool); + + if (failure) return mock_type(f_status_t); + + *size = length; + + return mock_type(f_status_t); +} + int __wrap_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) { const bool failure = mock_type(bool); diff --git a/level_0/f_thread/tests/unit/c/mock-thread.h b/level_0/f_thread/tests/unit/c/mock-thread.h index 92e6f7c..80c7bc2 100644 --- a/level_0/f_thread/tests/unit/c/mock-thread.h +++ b/level_0/f_thread/tests/unit/c/mock-thread.h @@ -29,6 +29,8 @@ extern "C" { const static int mock_errno_generic = 32767; +extern f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); +extern f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); extern int __wrap_pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); extern int __wrap_pthread_attr_destroy(pthread_attr_t *attr); extern int __wrap_pthread_attr_getaffinity_np(const pthread_attr_t *attr, size_t cpusetsize, cpu_set_t *cpuset); diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.c deleted file mode 100644 index e8c1a2d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-attributes_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_attributes_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_attributes_adjust__works(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.h deleted file mode 100644 index e9cb0fd..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_attributes_adjust -#define _TEST__F_thread__thread_attributes_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_attributes_adjust() - */ -extern void test__f_thread_attributes_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_attributes_adjust() - */ -extern void test__f_thread_attributes_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust_callback.c new file mode 100644 index 0000000..00c6157 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-attributes_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attributes_adjust_callback__fails(void **state) { + + f_thread_attribute_t data = f_thread_attribute_t_initialize; + f_thread_attribute_t data_array[] = { data }; + f_thread_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_attributes_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_destroy, true); + will_return(__wrap_pthread_attr_destroy, errnos[i]); + + const f_status_t status = f_thread_attributes_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_attributes_adjust_callback__works(void **state) { + + f_thread_attribute_t data = f_thread_attribute_t_initialize; + f_thread_attribute_t data_array[] = { data }; + f_thread_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_attr_destroy, false); + + const f_status_t status = f_thread_attributes_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust_callback.h new file mode 100644 index 0000000..ba2b2c9 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__attributes_adjust_callback +#define _TEST__F_thread__attributes_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_attributes_adjust_callback_() + */ +extern void test__f_thread_attributes_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_attributes_adjust_callback_() + */ +extern void test__f_thread_attributes_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__attributes_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.c deleted file mode 100644 index 713cf52..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-attributes_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_attributes_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_attributes_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_attributes_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_attributes_decimate_by__works(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_attr_destroy, false); - } // for - - const f_status_t status = f_thread_attributes_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.h deleted file mode 100644 index 1e22f8c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_attributes_decimate_by -#define _TEST__F_thread__thread_attributes_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_attributes_decimate_by() - */ -extern void test__f_thread_attributes_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_attributes_decimate_by() - */ -extern void test__f_thread_attributes_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_attributes_decimate_by() - */ -extern void test__f_thread_attributes_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.c deleted file mode 100644 index 6e650bc..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-attributes_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_attributes_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_attributes_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_attributes_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_attributes_decrease_by__works(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_attr_destroy, false); - } // for - - const f_status_t status = f_thread_attributes_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.h deleted file mode 100644 index 8e4418e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_attributes_decrease_by -#define _TEST__F_thread__thread_attributes_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_attributes_decrease_by() - */ -extern void test__f_thread_attributes_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_attributes_decrease_by() - */ -extern void test__f_thread_attributes_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_attributes_decrease_by() - */ -extern void test__f_thread_attributes_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.c deleted file mode 100644 index 134b72d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-attributes_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_attributes_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_attributes_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_attributes_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_attributes_increase__works(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_attributes_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.h deleted file mode 100644 index 0ea2031..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_attributes_increase -#define _TEST__F_thread__thread_attributes_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_attributes_increase() - */ -extern void test__f_thread_attributes_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_attributes_increase() - */ -extern void test__f_thread_attributes_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_attributes_increase() - */ -extern void test__f_thread_attributes_increase__works(void **state); - -#endif // _TEST__F_thread__thread_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.c deleted file mode 100644 index 98cb6ed..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-attributes_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_attributes_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_attributes_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_attributes_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_attributes_increase_by__works(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_attributes_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.h deleted file mode 100644 index 86a8d2e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_attributes_increase_by -#define _TEST__F_thread__thread_attributes_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_attributes_increase_by() - */ -extern void test__f_thread_attributes_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_attributes_increase_by() - */ -extern void test__f_thread_attributes_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_attributes_increase_by() - */ -extern void test__f_thread_attributes_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.c deleted file mode 100644 index 5bca614..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-attributes_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_attributes_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_attributes_resize__works(void **state) { - - const int length = 5; - f_thread_attributes_t data = f_thread_attributes_t_initialize; - - { - const f_status_t status = f_thread_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.h deleted file mode 100644 index ed0cc60..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-attributes_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_attributes_resize -#define _TEST__F_thread__thread_attributes_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_attributes_resize() - */ -extern void test__f_thread_attributes_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_attributes_resize() - */ -extern void test__f_thread_attributes_resize__works(void **state); - -#endif // _TEST__F_thread__thread_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize_callback.c new file mode 100644 index 0000000..17c4c59 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-attributes_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_attributes_resize_callback__fails(void **state) { + + f_thread_attribute_t data = f_thread_attribute_t_initialize; + f_thread_attribute_t data_array[] = { data }; + f_thread_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_attributes_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_destroy, true); + will_return(__wrap_pthread_attr_destroy, errnos[i]); + + const f_status_t status = f_thread_attributes_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_attributes_resize_callback__works(void **state) { + + f_thread_attribute_t data = f_thread_attribute_t_initialize; + f_thread_attribute_t data_array[] = { data }; + f_thread_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_attr_destroy, false); + + const f_status_t status = f_thread_attributes_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-attributes_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize_callback.h new file mode 100644 index 0000000..b7e9d73 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-attributes_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__attributes_resize_callback +#define _TEST__F_thread__attributes_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_attributes_resize_callback_() + */ +extern void test__f_thread_attributes_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_attributes_resize_callback_() + */ +extern void test__f_thread_attributes_resize_callback__works(void **state); + +#endif // _TEST__F_thread__attributes_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.c deleted file mode 100644 index d1c47f3..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barrier_attributes_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barrier_attributes_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barrier_attributes_adjust__works(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.h deleted file mode 100644 index e745db0..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barrier_attributes_adjust -#define _TEST__F_thread__thread_barrier_attributes_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barrier_attributes_adjust() - */ -extern void test__f_thread_barrier_attributes_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barrier_attributes_adjust() - */ -extern void test__f_thread_barrier_attributes_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_barrier_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust_callback.c new file mode 100644 index 0000000..1265c66 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-barrier_attributes_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barrier_attributes_adjust_callback__fails(void **state) { + + f_thread_barrier_attribute_t data = f_thread_barrier_attribute_t_initialize; + f_thread_barrier_attribute_t data_array[] = { data }; + f_thread_barrier_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_barrier_attributes_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_barrierattr_destroy, true); + will_return(__wrap_pthread_barrierattr_destroy, errnos[i]); + + const f_status_t status = f_thread_barrier_attributes_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_barrier_attributes_adjust_callback__works(void **state) { + + f_thread_barrier_attribute_t data = f_thread_barrier_attribute_t_initialize; + f_thread_barrier_attribute_t data_array[] = { data }; + f_thread_barrier_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_barrier_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_barrierattr_destroy, false); + + const f_status_t status = f_thread_barrier_attributes_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust_callback.h new file mode 100644 index 0000000..b8a7b13 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__barrier_attributes_adjust_callback +#define _TEST__F_thread__barrier_attributes_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_barrier_attributes_adjust_callback_() + */ +extern void test__f_thread_barrier_attributes_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barrier_attributes_adjust_callback_() + */ +extern void test__f_thread_barrier_attributes_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__barrier_attributes_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.c deleted file mode 100644 index 0117a97..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barrier_attributes_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barrier_attributes_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barrier_attributes_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_barrier_attributes_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_barrier_attributes_decimate_by__works(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_barrierattr_destroy, false); - } // for - - const f_status_t status = f_thread_barrier_attributes_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.h deleted file mode 100644 index 5951459..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barrier_attributes_decimate_by -#define _TEST__F_thread__thread_barrier_attributes_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barrier_attributes_decimate_by() - */ -extern void test__f_thread_barrier_attributes_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_barrier_attributes_decimate_by() - */ -extern void test__f_thread_barrier_attributes_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barrier_attributes_decimate_by() - */ -extern void test__f_thread_barrier_attributes_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_barrier_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.c deleted file mode 100644 index a87ad3e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barrier_attributes_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barrier_attributes_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barrier_attributes_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_barrier_attributes_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_barrier_attributes_decrease_by__works(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_barrierattr_destroy, false); - } // for - - const f_status_t status = f_thread_barrier_attributes_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.h deleted file mode 100644 index cd71547..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barrier_attributes_decrease_by -#define _TEST__F_thread__thread_barrier_attributes_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barrier_attributes_decrease_by() - */ -extern void test__f_thread_barrier_attributes_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_barrier_attributes_decrease_by() - */ -extern void test__f_thread_barrier_attributes_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barrier_attributes_decrease_by() - */ -extern void test__f_thread_barrier_attributes_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_barrier_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.c deleted file mode 100644 index a51e3da..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barrier_attributes_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barrier_attributes_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_barrier_attributes_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_barrier_attributes_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_barrier_attributes_increase__works(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_barrier_attributes_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.h deleted file mode 100644 index d8068fb..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barrier_attributes_increase -#define _TEST__F_thread__thread_barrier_attributes_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barrier_attributes_increase() - */ -extern void test__f_thread_barrier_attributes_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_barrier_attributes_increase() - */ -extern void test__f_thread_barrier_attributes_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barrier_attributes_increase() - */ -extern void test__f_thread_barrier_attributes_increase__works(void **state); - -#endif // _TEST__F_thread__thread_barrier_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.c deleted file mode 100644 index 30382ab..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barrier_attributes_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barrier_attributes_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barrier_attributes_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_barrier_attributes_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_barrier_attributes_increase_by__works(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_barrier_attributes_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.h deleted file mode 100644 index 800d330..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barrier_attributes_increase_by -#define _TEST__F_thread__thread_barrier_attributes_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barrier_attributes_increase_by() - */ -extern void test__f_thread_barrier_attributes_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_barrier_attributes_increase_by() - */ -extern void test__f_thread_barrier_attributes_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barrier_attributes_increase_by() - */ -extern void test__f_thread_barrier_attributes_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_barrier_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.c deleted file mode 100644 index 8255c02..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barrier_attributes_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barrier_attributes_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barrier_attributes_resize__works(void **state) { - - const int length = 5; - f_thread_barrier_attributes_t data = f_thread_barrier_attributes_t_initialize; - - { - const f_status_t status = f_thread_barrier_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.h deleted file mode 100644 index be3af2d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barrier_attributes_resize -#define _TEST__F_thread__thread_barrier_attributes_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barrier_attributes_resize() - */ -extern void test__f_thread_barrier_attributes_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barrier_attributes_resize() - */ -extern void test__f_thread_barrier_attributes_resize__works(void **state); - -#endif // _TEST__F_thread__thread_barrier_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize_callback.c new file mode 100644 index 0000000..8472f8c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-barrier_attributes_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barrier_attributes_resize_callback__fails(void **state) { + + f_thread_barrier_attribute_t data = f_thread_barrier_attribute_t_initialize; + f_thread_barrier_attribute_t data_array[] = { data }; + f_thread_barrier_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_barrier_attributes_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_barrierattr_destroy, true); + will_return(__wrap_pthread_barrierattr_destroy, errnos[i]); + + const f_status_t status = f_thread_barrier_attributes_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_barrier_attributes_resize_callback__works(void **state) { + + f_thread_barrier_attribute_t data = f_thread_barrier_attribute_t_initialize; + f_thread_barrier_attribute_t data_array[] = { data }; + f_thread_barrier_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_barrier_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_barrierattr_destroy, false); + + const f_status_t status = f_thread_barrier_attributes_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize_callback.h new file mode 100644 index 0000000..5b636f8 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barrier_attributes_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__barrier_attributes_resize_callback +#define _TEST__F_thread__barrier_attributes_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_barrier_attributes_resize_callback_() + */ +extern void test__f_thread_barrier_attributes_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barrier_attributes_resize_callback_() + */ +extern void test__f_thread_barrier_attributes_resize_callback__works(void **state); + +#endif // _TEST__F_thread__barrier_attributes_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.c deleted file mode 100644 index 75dd228..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barriers_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barriers_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barriers_adjust__works(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.h deleted file mode 100644 index 90ab39b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barriers_adjust -#define _TEST__F_thread__thread_barriers_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barriers_adjust() - */ -extern void test__f_thread_barriers_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barriers_adjust() - */ -extern void test__f_thread_barriers_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_barriers_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust_callback.c new file mode 100644 index 0000000..1712b0d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-barriers_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barriers_adjust_callback__fails(void **state) { + + f_thread_barrier_t data = f_thread_barrier_t_initialize; + f_thread_barrier_t data_array[] = { data }; + f_thread_barriers_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_barriers_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_barrier_destroy, true); + will_return(__wrap_pthread_barrier_destroy, errnos[i]); + + const f_status_t status = f_thread_barriers_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_barriers_adjust_callback__works(void **state) { + + f_thread_barrier_t data = f_thread_barrier_t_initialize; + f_thread_barrier_t data_array[] = { data }; + f_thread_barriers_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_barriers_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_barrier_destroy, false); + + const f_status_t status = f_thread_barriers_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust_callback.h new file mode 100644 index 0000000..b17f657 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__barriers_adjust_callback +#define _TEST__F_thread__barriers_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_barriers_adjust_callback_() + */ +extern void test__f_thread_barriers_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barriers_adjust_callback_() + */ +extern void test__f_thread_barriers_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__barriers_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.c deleted file mode 100644 index ac22ea8..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barriers_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barriers_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barriers_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_barriers_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_barriers_decimate_by__works(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_barrier_destroy, F_false); - } // for - - const f_status_t status = f_thread_barriers_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.h deleted file mode 100644 index 3d7cf14..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barriers_decimate_by -#define _TEST__F_thread__thread_barriers_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barriers_decimate_by() - */ -extern void test__f_thread_barriers_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_barriers_decimate_by() - */ -extern void test__f_thread_barriers_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barriers_decimate_by() - */ -extern void test__f_thread_barriers_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_barriers_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.c deleted file mode 100644 index 0af5a54..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barriers_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barriers_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barriers_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_barriers_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_barriers_decrease_by__works(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_barrier_destroy, F_false); - } // for - - const f_status_t status = f_thread_barriers_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.h deleted file mode 100644 index d76a072..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barriers_decrease_by -#define _TEST__F_thread__thread_barriers_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barriers_decrease_by() - */ -extern void test__f_thread_barriers_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_barriers_decrease_by() - */ -extern void test__f_thread_barriers_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barriers_decrease_by() - */ -extern void test__f_thread_barriers_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_barriers_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.c deleted file mode 100644 index f70549b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barriers_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barriers_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_barriers_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_barriers_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_barriers_increase__works(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_barriers_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.h deleted file mode 100644 index 282d369..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barriers_increase -#define _TEST__F_thread__thread_barriers_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barriers_increase() - */ -extern void test__f_thread_barriers_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_barriers_increase() - */ -extern void test__f_thread_barriers_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barriers_increase() - */ -extern void test__f_thread_barriers_increase__works(void **state); - -#endif // _TEST__F_thread__thread_barriers_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.c deleted file mode 100644 index 478e3dc..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barriers_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barriers_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barriers_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_barriers_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_barriers_increase_by__works(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_barriers_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.h deleted file mode 100644 index a81cd8b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barriers_increase_by -#define _TEST__F_thread__thread_barriers_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barriers_increase_by() - */ -extern void test__f_thread_barriers_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_barriers_increase_by() - */ -extern void test__f_thread_barriers_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barriers_increase_by() - */ -extern void test__f_thread_barriers_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_barriers_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.c deleted file mode 100644 index 1c617e2..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-barriers_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_barriers_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_barriers_resize__works(void **state) { - - const int length = 5; - f_thread_barriers_t data = f_thread_barriers_t_initialize; - - { - const f_status_t status = f_thread_barriers_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.h deleted file mode 100644 index 17e277b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-barriers_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_barriers_resize -#define _TEST__F_thread__thread_barriers_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_barriers_resize() - */ -extern void test__f_thread_barriers_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_barriers_resize() - */ -extern void test__f_thread_barriers_resize__works(void **state); - -#endif // _TEST__F_thread__thread_barriers_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize_callback.c new file mode 100644 index 0000000..1bb278a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize_callback.c @@ -0,0 +1,56 @@ +#include "test-thread.h" +#include "test-thread-barriers_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_barriers_resize_callback__fails(void **state) { + + f_thread_barrier_t data = f_thread_barrier_t_initialize; + f_thread_barrier_t data_array[] = { data }; + f_thread_barriers_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_barriers_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + will_return(__wrap_pthread_barrier_destroy, true); + will_return(__wrap_pthread_barrier_destroy, errnos[i]); + + const f_status_t status = f_thread_barriers_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_barriers_resize_callback__works(void **state) { + + f_thread_barrier_t data = f_thread_barrier_t_initialize; + f_thread_barrier_t data_array[] = { data }; + f_thread_barriers_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_barriers_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_barrier_destroy, false); + + const f_status_t status = f_thread_barriers_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-barriers_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize_callback.h new file mode 100644 index 0000000..3f62b4b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-barriers_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__barriers_resize_callback +#define _TEST__F_thread__barriers_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_barriers_resize_callback_() + */ +extern void test__f_thread_barriers_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_barriers_resize_callback_() + */ +extern void test__f_thread_barriers_resize_callback__works(void **state); + +#endif // _TEST__F_thread__barriers_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.c deleted file mode 100644 index 5751d5c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-condition_attributes_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_condition_attributes_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_condition_attributes_adjust__works(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.h deleted file mode 100644 index 9f1fc47..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_condition_attributes_adjust -#define _TEST__F_thread__thread_condition_attributes_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_condition_attributes_adjust() - */ -extern void test__f_thread_condition_attributes_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_condition_attributes_adjust() - */ -extern void test__f_thread_condition_attributes_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_condition_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust_callback.c new file mode 100644 index 0000000..f7c00d5 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-condition_attributes_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_condition_attributes_adjust_callback__fails(void **state) { + + f_thread_condition_attribute_t data = f_thread_condition_attribute_t_initialize; + f_thread_condition_attribute_t data_array[] = { data }; + f_thread_condition_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_condition_attributes_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_condattr_destroy, true); + will_return(__wrap_pthread_condattr_destroy, errnos[i]); + + const f_status_t status = f_thread_condition_attributes_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_condition_attributes_adjust_callback__works(void **state) { + + f_thread_condition_attribute_t data = f_thread_condition_attribute_t_initialize; + f_thread_condition_attribute_t data_array[] = { data }; + f_thread_condition_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_condition_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_condattr_destroy, false); + + const f_status_t status = f_thread_condition_attributes_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust_callback.h new file mode 100644 index 0000000..181edfb --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__condition_attributes_adjust_callback +#define _TEST__F_thread__condition_attributes_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_condition_attributes_adjust_callback_() + */ +extern void test__f_thread_condition_attributes_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_condition_attributes_adjust_callback_() + */ +extern void test__f_thread_condition_attributes_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__condition_attributes_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.c deleted file mode 100644 index 114c55e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-condition_attributes_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_condition_attributes_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_condition_attributes_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_condition_attributes_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_condition_attributes_decimate_by__works(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_condattr_destroy, false); - } // for - - const f_status_t status = f_thread_condition_attributes_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.h deleted file mode 100644 index 93fcf5a..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_condition_attributes_decimate_by -#define _TEST__F_thread__thread_condition_attributes_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_condition_attributes_decimate_by() - */ -extern void test__f_thread_condition_attributes_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_condition_attributes_decimate_by() - */ -extern void test__f_thread_condition_attributes_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_condition_attributes_decimate_by() - */ -extern void test__f_thread_condition_attributes_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_condition_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.c deleted file mode 100644 index d6efaf1..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-condition_attributes_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_condition_attributes_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_condition_attributes_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_condition_attributes_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_condition_attributes_decrease_by__works(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_condattr_destroy, false); - } // for - - const f_status_t status = f_thread_condition_attributes_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.h deleted file mode 100644 index bd8fcff..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_condition_attributes_decrease_by -#define _TEST__F_thread__thread_condition_attributes_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_condition_attributes_decrease_by() - */ -extern void test__f_thread_condition_attributes_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_condition_attributes_decrease_by() - */ -extern void test__f_thread_condition_attributes_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_condition_attributes_decrease_by() - */ -extern void test__f_thread_condition_attributes_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_condition_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.c deleted file mode 100644 index 6ab17e6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-condition_attributes_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_condition_attributes_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_condition_attributes_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_condition_attributes_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_condition_attributes_increase__works(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_condition_attributes_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.h deleted file mode 100644 index ee0c022..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_condition_attributes_increase -#define _TEST__F_thread__thread_condition_attributes_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_condition_attributes_increase() - */ -extern void test__f_thread_condition_attributes_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_condition_attributes_increase() - */ -extern void test__f_thread_condition_attributes_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_condition_attributes_increase() - */ -extern void test__f_thread_condition_attributes_increase__works(void **state); - -#endif // _TEST__F_thread__thread_condition_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.c deleted file mode 100644 index 10f3398..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-condition_attributes_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_condition_attributes_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_condition_attributes_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_condition_attributes_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_condition_attributes_increase_by__works(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_condition_attributes_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.h deleted file mode 100644 index 04778dc..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_condition_attributes_increase_by -#define _TEST__F_thread__thread_condition_attributes_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_condition_attributes_increase_by() - */ -extern void test__f_thread_condition_attributes_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_condition_attributes_increase_by() - */ -extern void test__f_thread_condition_attributes_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_condition_attributes_increase_by() - */ -extern void test__f_thread_condition_attributes_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_condition_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.c deleted file mode 100644 index 3bfd003..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-condition_attributes_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_condition_attributes_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_condition_attributes_resize__works(void **state) { - - const int length = 5; - f_thread_condition_attributes_t data = f_thread_condition_attributes_t_initialize; - - { - const f_status_t status = f_thread_condition_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.h deleted file mode 100644 index a39c5de..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_condition_attributes_resize -#define _TEST__F_thread__thread_condition_attributes_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_condition_attributes_resize() - */ -extern void test__f_thread_condition_attributes_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_condition_attributes_resize() - */ -extern void test__f_thread_condition_attributes_resize__works(void **state); - -#endif // _TEST__F_thread__thread_condition_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize_callback.c new file mode 100644 index 0000000..87e174c --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-condition_attributes_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_condition_attributes_resize_callback__fails(void **state) { + + f_thread_condition_attribute_t data = f_thread_condition_attribute_t_initialize; + f_thread_condition_attribute_t data_array[] = { data }; + f_thread_condition_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_condition_attributes_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_condattr_destroy, true); + will_return(__wrap_pthread_condattr_destroy, errnos[i]); + + const f_status_t status = f_thread_condition_attributes_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_condition_attributes_resize_callback__works(void **state) { + + f_thread_condition_attribute_t data = f_thread_condition_attribute_t_initialize; + f_thread_condition_attribute_t data_array[] = { data }; + f_thread_condition_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_condition_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_condattr_destroy, false); + + const f_status_t status = f_thread_condition_attributes_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize_callback.h new file mode 100644 index 0000000..dd63a80 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-condition_attributes_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__condition_attributes_resize_callback +#define _TEST__F_thread__condition_attributes_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_condition_attributes_resize_callback_() + */ +extern void test__f_thread_condition_attributes_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_condition_attributes_resize_callback_() + */ +extern void test__f_thread_condition_attributes_resize_callback__works(void **state); + +#endif // _TEST__F_thread__condition_attributes_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.c deleted file mode 100644 index 69f85a3..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-conditions_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_conditions_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_conditions_adjust__works(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.h deleted file mode 100644 index 206fe19..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_conditions_adjust -#define _TEST__F_thread__thread_conditions_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_conditions_adjust() - */ -extern void test__f_thread_conditions_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_conditions_adjust() - */ -extern void test__f_thread_conditions_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_conditions_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust_callback.c new file mode 100644 index 0000000..9876422 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-conditions_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_conditions_adjust_callback__fails(void **state) { + + f_thread_condition_t data = f_thread_condition_t_initialize; + f_thread_condition_t data_array[] = { data }; + f_thread_conditions_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_conditions_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_cond_destroy, true); + will_return(__wrap_pthread_cond_destroy, errnos[i]); + + const f_status_t status = f_thread_conditions_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_conditions_adjust_callback__works(void **state) { + + f_thread_condition_t data = f_thread_condition_t_initialize; + f_thread_condition_t data_array[] = { data }; + f_thread_conditions_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_conditions_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_cond_destroy, false); + + const f_status_t status = f_thread_conditions_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust_callback.h new file mode 100644 index 0000000..dfa578e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__conditions_adjust_callback +#define _TEST__F_thread__conditions_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_conditions_adjust_callback_() + */ +extern void test__f_thread_conditions_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_conditions_adjust_callback_() + */ +extern void test__f_thread_conditions_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__conditions_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.c deleted file mode 100644 index 3b16379..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-conditions_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_conditions_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_conditions_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_conditions_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_conditions_decimate_by__works(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_cond_destroy, false); - } // for - - const f_status_t status = f_thread_conditions_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.h deleted file mode 100644 index 95c4e7f..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_conditions_decimate_by -#define _TEST__F_thread__thread_conditions_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_conditions_decimate_by() - */ -extern void test__f_thread_conditions_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_conditions_decimate_by() - */ -extern void test__f_thread_conditions_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_conditions_decimate_by() - */ -extern void test__f_thread_conditions_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_conditions_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.c deleted file mode 100644 index dca2d1d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-conditions_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_conditions_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_conditions_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_conditions_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_conditions_decrease_by__works(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_cond_destroy, false); - } // for - - const f_status_t status = f_thread_conditions_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.h deleted file mode 100644 index 51a98cb..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_conditions_decrease_by -#define _TEST__F_thread__thread_conditions_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_conditions_decrease_by() - */ -extern void test__f_thread_conditions_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_conditions_decrease_by() - */ -extern void test__f_thread_conditions_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_conditions_decrease_by() - */ -extern void test__f_thread_conditions_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_conditions_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.c deleted file mode 100644 index 640b590..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-conditions_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_conditions_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_conditions_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_conditions_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_conditions_increase__works(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_conditions_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.h deleted file mode 100644 index 540a223..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_conditions_increase -#define _TEST__F_thread__thread_conditions_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_conditions_increase() - */ -extern void test__f_thread_conditions_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_conditions_increase() - */ -extern void test__f_thread_conditions_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_conditions_increase() - */ -extern void test__f_thread_conditions_increase__works(void **state); - -#endif // _TEST__F_thread__thread_conditions_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.c deleted file mode 100644 index 1b7772e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-conditions_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_conditions_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_conditions_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_conditions_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_conditions_increase_by__works(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_conditions_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.h deleted file mode 100644 index 681e467..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_conditions_increase_by -#define _TEST__F_thread__thread_conditions_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_conditions_increase_by() - */ -extern void test__f_thread_conditions_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_conditions_increase_by() - */ -extern void test__f_thread_conditions_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_conditions_increase_by() - */ -extern void test__f_thread_conditions_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_conditions_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.c deleted file mode 100644 index b630119..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-conditions_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_conditions_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_conditions_resize__works(void **state) { - - const int length = 5; - f_thread_conditions_t data = f_thread_conditions_t_initialize; - - { - const f_status_t status = f_thread_conditions_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.h deleted file mode 100644 index 786e9cf..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-conditions_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_conditions_resize -#define _TEST__F_thread__thread_conditions_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_conditions_resize() - */ -extern void test__f_thread_conditions_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_conditions_resize() - */ -extern void test__f_thread_conditions_resize__works(void **state); - -#endif // _TEST__F_thread__thread_conditions_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize_callback.c new file mode 100644 index 0000000..ad6d92f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-conditions_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_conditions_resize_callback__fails(void **state) { + + f_thread_condition_t data = f_thread_condition_t_initialize; + f_thread_condition_t data_array[] = { data }; + f_thread_conditions_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_conditions_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_cond_destroy, true); + will_return(__wrap_pthread_cond_destroy, errnos[i]); + + const f_status_t status = f_thread_conditions_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_conditions_resize_callback__works(void **state) { + + f_thread_condition_t data = f_thread_condition_t_initialize; + f_thread_condition_t data_array[] = { data }; + f_thread_conditions_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_conditions_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_cond_destroy, false); + + const f_status_t status = f_thread_conditions_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-conditions_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize_callback.h new file mode 100644 index 0000000..61b23fa --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-conditions_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__conditions_resize_callback +#define _TEST__F_thread__conditions_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_conditions_resize_callback_() + */ +extern void test__f_thread_conditions_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_conditions_resize_callback_() + */ +extern void test__f_thread_conditions_resize_callback__works(void **state); + +#endif // _TEST__F_thread__conditions_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.c deleted file mode 100644 index 2ce2fc3..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-ids_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_ids_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_ids_adjust__works(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.h deleted file mode 100644 index 43a593f..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_ids_adjust -#define _TEST__F_thread__thread_ids_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_ids_adjust() - */ -extern void test__f_thread_ids_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_ids_adjust() - */ -extern void test__f_thread_ids_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_ids_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.c deleted file mode 100644 index d55dfb6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-thread.h" -#include "test-thread-ids_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_ids_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_ids_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_ids_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_ids_decimate_by__works(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_ids_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.h deleted file mode 100644 index cc66223..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_ids_decimate_by -#define _TEST__F_thread__thread_ids_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_ids_decimate_by() - */ -extern void test__f_thread_ids_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_ids_decimate_by() - */ -extern void test__f_thread_ids_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_ids_decimate_by() - */ -extern void test__f_thread_ids_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_ids_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.c deleted file mode 100644 index c7d0bf7..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-thread.h" -#include "test-thread-ids_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_ids_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_ids_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_ids_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_ids_decrease_by__works(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_ids_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.h deleted file mode 100644 index 617e75e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_ids_decrease_by -#define _TEST__F_thread__thread_ids_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_ids_decrease_by() - */ -extern void test__f_thread_ids_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_ids_decrease_by() - */ -extern void test__f_thread_ids_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_ids_decrease_by() - */ -extern void test__f_thread_ids_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_ids_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_increase.c b/level_0/f_thread/tests/unit/c/test-thread-ids_increase.c deleted file mode 100644 index cc6d6eb..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-ids_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_ids_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_ids_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_ids_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_ids_increase__works(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_ids_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_increase.h b/level_0/f_thread/tests/unit/c/test-thread-ids_increase.h deleted file mode 100644 index 5ed6c70..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_ids_increase -#define _TEST__F_thread__thread_ids_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_ids_increase() - */ -extern void test__f_thread_ids_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_ids_increase() - */ -extern void test__f_thread_ids_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_ids_increase() - */ -extern void test__f_thread_ids_increase__works(void **state); - -#endif // _TEST__F_thread__thread_ids_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.c deleted file mode 100644 index 55195d6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-ids_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_ids_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_ids_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_ids_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_ids_increase_by__works(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_ids_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.h deleted file mode 100644 index 1b253f7..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_ids_increase_by -#define _TEST__F_thread__thread_ids_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_ids_increase_by() - */ -extern void test__f_thread_ids_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_ids_increase_by() - */ -extern void test__f_thread_ids_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_ids_increase_by() - */ -extern void test__f_thread_ids_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_ids_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_resize.c b/level_0/f_thread/tests/unit/c/test-thread-ids_resize.c deleted file mode 100644 index e2f5ccc..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-ids_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_ids_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_ids_resize__works(void **state) { - - const int length = 5; - f_thread_ids_t data = f_thread_ids_t_initialize; - - { - const f_status_t status = f_thread_ids_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-ids_resize.h b/level_0/f_thread/tests/unit/c/test-thread-ids_resize.h deleted file mode 100644 index 4843405..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-ids_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_ids_resize -#define _TEST__F_thread__thread_ids_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_ids_resize() - */ -extern void test__f_thread_ids_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_ids_resize() - */ -extern void test__f_thread_ids_resize__works(void **state); - -#endif // _TEST__F_thread__thread_ids_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.c deleted file mode 100644 index 5527b06..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-keys_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_keys_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_keys_adjust__works(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.h deleted file mode 100644 index cd3101a..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_keys_adjust -#define _TEST__F_thread__thread_keys_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_keys_adjust() - */ -extern void test__f_thread_keys_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_keys_adjust() - */ -extern void test__f_thread_keys_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_keys_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust_callback.c new file mode 100644 index 0000000..d84bf35 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust_callback.c @@ -0,0 +1,54 @@ +#include "test-thread.h" +#include "test-thread-keys_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_keys_adjust_callback__fails(void **state) { + + f_thread_key_t data = f_thread_key_t_initialize; + f_thread_key_t data_array[] = { data }; + f_thread_keys_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_keys_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_key_delete, errnos[i]); + + const f_status_t status = f_thread_keys_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_keys_adjust_callback__works(void **state) { + + f_thread_key_t data = f_thread_key_t_initialize; + f_thread_key_t data_array[] = { data }; + f_thread_keys_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_keys_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_key_delete, false); + + const f_status_t status = f_thread_keys_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust_callback.h new file mode 100644 index 0000000..f9c1984 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__keys_adjust_callback +#define _TEST__F_thread__keys_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_keys_adjust_callback_() + */ +extern void test__f_thread_keys_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_keys_adjust_callback_() + */ +extern void test__f_thread_keys_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__keys_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.c deleted file mode 100644 index 460f57b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-keys_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_keys_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_keys_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_keys_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_keys_decimate_by__works(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_key_delete, F_false); - } // for - - const f_status_t status = f_thread_keys_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.h deleted file mode 100644 index 28df2d3..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_keys_decimate_by -#define _TEST__F_thread__thread_keys_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_keys_decimate_by() - */ -extern void test__f_thread_keys_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_keys_decimate_by() - */ -extern void test__f_thread_keys_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_keys_decimate_by() - */ -extern void test__f_thread_keys_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_keys_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.c deleted file mode 100644 index 229ce77..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-keys_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_keys_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_keys_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_keys_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_keys_decrease_by__works(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_key_delete, F_false); - } // for - - const f_status_t status = f_thread_keys_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.h deleted file mode 100644 index 25548fd..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_keys_decrease_by -#define _TEST__F_thread__thread_keys_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_keys_decrease_by() - */ -extern void test__f_thread_keys_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_keys_decrease_by() - */ -extern void test__f_thread_keys_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_keys_decrease_by() - */ -extern void test__f_thread_keys_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_keys_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_increase.c b/level_0/f_thread/tests/unit/c/test-thread-keys_increase.c deleted file mode 100644 index 7a78b0e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-keys_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_keys_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_keys_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_keys_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_keys_increase__works(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_keys_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_increase.h b/level_0/f_thread/tests/unit/c/test-thread-keys_increase.h deleted file mode 100644 index d7242b1..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_keys_increase -#define _TEST__F_thread__thread_keys_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_keys_increase() - */ -extern void test__f_thread_keys_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_keys_increase() - */ -extern void test__f_thread_keys_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_keys_increase() - */ -extern void test__f_thread_keys_increase__works(void **state); - -#endif // _TEST__F_thread__thread_keys_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.c deleted file mode 100644 index 3a4bfcf..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-keys_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_keys_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_keys_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_keys_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_keys_increase_by__works(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_keys_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.h deleted file mode 100644 index 70d7218..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_keys_increase_by -#define _TEST__F_thread__thread_keys_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_keys_increase_by() - */ -extern void test__f_thread_keys_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_keys_increase_by() - */ -extern void test__f_thread_keys_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_keys_increase_by() - */ -extern void test__f_thread_keys_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_keys_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_resize.c b/level_0/f_thread/tests/unit/c/test-thread-keys_resize.c deleted file mode 100644 index a5c290c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-keys_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_keys_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_keys_resize__works(void **state) { - - const int length = 5; - f_thread_keys_t data = f_thread_keys_t_initialize; - - { - const f_status_t status = f_thread_keys_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_resize.h b/level_0/f_thread/tests/unit/c/test-thread-keys_resize.h deleted file mode 100644 index ebcbfa0..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-keys_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_keys_resize -#define _TEST__F_thread__thread_keys_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_keys_resize() - */ -extern void test__f_thread_keys_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_keys_resize() - */ -extern void test__f_thread_keys_resize__works(void **state); - -#endif // _TEST__F_thread__thread_keys_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-keys_resize_callback.c new file mode 100644 index 0000000..6e84644 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_resize_callback.c @@ -0,0 +1,54 @@ +#include "test-thread.h" +#include "test-thread-keys_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_keys_resize_callback__fails(void **state) { + + f_thread_key_t data = f_thread_key_t_initialize; + f_thread_key_t data_array[] = { data }; + f_thread_keys_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_keys_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_key_delete, errnos[i]); + + const f_status_t status = f_thread_keys_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_keys_resize_callback__works(void **state) { + + f_thread_key_t data = f_thread_key_t_initialize; + f_thread_key_t data_array[] = { data }; + f_thread_keys_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_keys_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_key_delete, false); + + const f_status_t status = f_thread_keys_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-keys_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-keys_resize_callback.h new file mode 100644 index 0000000..142f33b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-keys_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__keys_resize_callback +#define _TEST__F_thread__keys_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_keys_resize_callback_() + */ +extern void test__f_thread_keys_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_keys_resize_callback_() + */ +extern void test__f_thread_keys_resize_callback__works(void **state); + +#endif // _TEST__F_thread__keys_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.c deleted file mode 100644 index 9c93521..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-lock_attributes_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_lock_attributes_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_lock_attributes_adjust__works(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.h deleted file mode 100644 index 935d9f0..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_lock_attributes_adjust -#define _TEST__F_thread__thread_lock_attributes_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_lock_attributes_adjust() - */ -extern void test__f_thread_lock_attributes_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_lock_attributes_adjust() - */ -extern void test__f_thread_lock_attributes_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_lock_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust_callback.c new file mode 100644 index 0000000..83be29a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-lock_attributes_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_lock_attributes_adjust_callback__fails(void **state) { + + f_thread_lock_attribute_t data = f_thread_lock_attribute_t_initialize; + f_thread_lock_attribute_t data_array[] = { data }; + f_thread_lock_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_lock_attributes_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_rwlockattr_destroy, true); + will_return(__wrap_pthread_rwlockattr_destroy, errnos[i]); + + const f_status_t status = f_thread_lock_attributes_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_lock_attributes_adjust_callback__works(void **state) { + + f_thread_lock_attribute_t data = f_thread_lock_attribute_t_initialize; + f_thread_lock_attribute_t data_array[] = { data }; + f_thread_lock_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_lock_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_rwlockattr_destroy, false); + + const f_status_t status = f_thread_lock_attributes_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust_callback.h new file mode 100644 index 0000000..40d1b9a --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__lock_attributes_adjust_callback +#define _TEST__F_thread__lock_attributes_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_lock_attributes_adjust_callback_() + */ +extern void test__f_thread_lock_attributes_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_lock_attributes_adjust_callback_() + */ +extern void test__f_thread_lock_attributes_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__lock_attributes_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.c deleted file mode 100644 index 1c5330f..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-lock_attributes_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_lock_attributes_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_lock_attributes_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_lock_attributes_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_lock_attributes_decimate_by__works(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_rwlockattr_destroy, false); - } // for - - const f_status_t status = f_thread_lock_attributes_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.h deleted file mode 100644 index d57a4f0..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_lock_attributes_decimate_by -#define _TEST__F_thread__thread_lock_attributes_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_lock_attributes_decimate_by() - */ -extern void test__f_thread_lock_attributes_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_lock_attributes_decimate_by() - */ -extern void test__f_thread_lock_attributes_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_lock_attributes_decimate_by() - */ -extern void test__f_thread_lock_attributes_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_lock_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.c deleted file mode 100644 index 0ab8f5a..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-lock_attributes_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_lock_attributes_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_lock_attributes_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_lock_attributes_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_lock_attributes_decrease_by__works(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_rwlockattr_destroy, false); - } // for - - const f_status_t status = f_thread_lock_attributes_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.h deleted file mode 100644 index a5e720e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_lock_attributes_decrease_by -#define _TEST__F_thread__thread_lock_attributes_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_lock_attributes_decrease_by() - */ -extern void test__f_thread_lock_attributes_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_lock_attributes_decrease_by() - */ -extern void test__f_thread_lock_attributes_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_lock_attributes_decrease_by() - */ -extern void test__f_thread_lock_attributes_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_lock_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.c deleted file mode 100644 index 4600307..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-lock_attributes_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_lock_attributes_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_lock_attributes_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_lock_attributes_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_lock_attributes_increase__works(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_lock_attributes_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.h deleted file mode 100644 index abca646..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_lock_attributes_increase -#define _TEST__F_thread__thread_lock_attributes_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_lock_attributes_increase() - */ -extern void test__f_thread_lock_attributes_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_lock_attributes_increase() - */ -extern void test__f_thread_lock_attributes_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_lock_attributes_increase() - */ -extern void test__f_thread_lock_attributes_increase__works(void **state); - -#endif // _TEST__F_thread__thread_lock_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.c deleted file mode 100644 index c217c6f..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-lock_attributes_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_lock_attributes_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_lock_attributes_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_lock_attributes_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_lock_attributes_increase_by__works(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_lock_attributes_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.h deleted file mode 100644 index d58cb61..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_lock_attributes_increase_by -#define _TEST__F_thread__thread_lock_attributes_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_lock_attributes_increase_by() - */ -extern void test__f_thread_lock_attributes_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_lock_attributes_increase_by() - */ -extern void test__f_thread_lock_attributes_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_lock_attributes_increase_by() - */ -extern void test__f_thread_lock_attributes_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_lock_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.c deleted file mode 100644 index 5f2f839..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-lock_attributes_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_lock_attributes_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_lock_attributes_resize__works(void **state) { - - const int length = 5; - f_thread_lock_attributes_t data = f_thread_lock_attributes_t_initialize; - - { - const f_status_t status = f_thread_lock_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.h deleted file mode 100644 index 20df50c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_lock_attributes_resize -#define _TEST__F_thread__thread_lock_attributes_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_lock_attributes_resize() - */ -extern void test__f_thread_lock_attributes_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_lock_attributes_resize() - */ -extern void test__f_thread_lock_attributes_resize__works(void **state); - -#endif // _TEST__F_thread__thread_lock_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize_callback.c new file mode 100644 index 0000000..37dc6bd --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-lock_attributes_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_lock_attributes_resize_callback__fails(void **state) { + + f_thread_lock_attribute_t data = f_thread_lock_attribute_t_initialize; + f_thread_lock_attribute_t data_array[] = { data }; + f_thread_lock_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_lock_attributes_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_rwlockattr_destroy, true); + will_return(__wrap_pthread_rwlockattr_destroy, errnos[i]); + + const f_status_t status = f_thread_lock_attributes_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_lock_attributes_resize_callback__works(void **state) { + + f_thread_lock_attribute_t data = f_thread_lock_attribute_t_initialize; + f_thread_lock_attribute_t data_array[] = { data }; + f_thread_lock_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_lock_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_rwlockattr_destroy, false); + + const f_status_t status = f_thread_lock_attributes_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize_callback.h new file mode 100644 index 0000000..5854895 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-lock_attributes_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__lock_attributes_resize_callback +#define _TEST__F_thread__lock_attributes_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_lock_attributes_resize_callback_() + */ +extern void test__f_thread_lock_attributes_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_lock_attributes_resize_callback_() + */ +extern void test__f_thread_lock_attributes_resize_callback__works(void **state); + +#endif // _TEST__F_thread__lock_attributes_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.c deleted file mode 100644 index 3494da4..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-locks_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_locks_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_locks_adjust__works(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.h deleted file mode 100644 index e0590fb..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_locks_adjust -#define _TEST__F_thread__thread_locks_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_locks_adjust() - */ -extern void test__f_thread_locks_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_locks_adjust() - */ -extern void test__f_thread_locks_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_locks_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust_callback.c new file mode 100644 index 0000000..ae1d1cc --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-locks_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_locks_adjust_callback__fails(void **state) { + + f_thread_lock_t data = f_thread_lock_t_initialize; + f_thread_lock_t data_array[] = { data }; + f_thread_locks_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_locks_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_rwlock_destroy, true); + will_return(__wrap_pthread_rwlock_destroy, errnos[i]); + + const f_status_t status = f_thread_locks_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_locks_adjust_callback__works(void **state) { + + f_thread_lock_t data = f_thread_lock_t_initialize; + f_thread_lock_t data_array[] = { data }; + f_thread_locks_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_locks_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_rwlock_destroy, false); + + const f_status_t status = f_thread_locks_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust_callback.h new file mode 100644 index 0000000..d3a3e48 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__locks_adjust_callback +#define _TEST__F_thread__locks_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_locks_adjust_callback_() + */ +extern void test__f_thread_locks_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_locks_adjust_callback_() + */ +extern void test__f_thread_locks_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__locks_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.c deleted file mode 100644 index 56423a4..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-locks_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_locks_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_locks_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_locks_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_locks_decimate_by__works(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_rwlock_destroy, false); - } // for - - const f_status_t status = f_thread_locks_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.h deleted file mode 100644 index 66426a8..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_locks_decimate_by -#define _TEST__F_thread__thread_locks_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_locks_decimate_by() - */ -extern void test__f_thread_locks_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_locks_decimate_by() - */ -extern void test__f_thread_locks_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_locks_decimate_by() - */ -extern void test__f_thread_locks_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_locks_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.c deleted file mode 100644 index c64948d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-locks_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_locks_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_locks_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_locks_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_locks_decrease_by__works(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_rwlock_destroy, false); - } // for - - const f_status_t status = f_thread_locks_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.h deleted file mode 100644 index 02dfafd..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_locks_decrease_by -#define _TEST__F_thread__thread_locks_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_locks_decrease_by() - */ -extern void test__f_thread_locks_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_locks_decrease_by() - */ -extern void test__f_thread_locks_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_locks_decrease_by() - */ -extern void test__f_thread_locks_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_locks_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_increase.c b/level_0/f_thread/tests/unit/c/test-thread-locks_increase.c deleted file mode 100644 index 9863205..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-locks_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_locks_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_locks_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_locks_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_locks_increase__works(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_locks_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_increase.h b/level_0/f_thread/tests/unit/c/test-thread-locks_increase.h deleted file mode 100644 index e1692c4..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_locks_increase -#define _TEST__F_thread__thread_locks_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_locks_increase() - */ -extern void test__f_thread_locks_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_locks_increase() - */ -extern void test__f_thread_locks_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_locks_increase() - */ -extern void test__f_thread_locks_increase__works(void **state); - -#endif // _TEST__F_thread__thread_locks_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.c deleted file mode 100644 index 29d428a..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-locks_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_locks_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_locks_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_locks_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_locks_increase_by__works(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_locks_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.h deleted file mode 100644 index a14772f..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_locks_increase_by -#define _TEST__F_thread__thread_locks_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_locks_increase_by() - */ -extern void test__f_thread_locks_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_locks_increase_by() - */ -extern void test__f_thread_locks_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_locks_increase_by() - */ -extern void test__f_thread_locks_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_locks_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_resize.c b/level_0/f_thread/tests/unit/c/test-thread-locks_resize.c deleted file mode 100644 index 195dfdd..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-locks_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_locks_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_locks_resize__works(void **state) { - - const int length = 5; - f_thread_locks_t data = f_thread_locks_t_initialize; - - { - const f_status_t status = f_thread_locks_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_resize.h b/level_0/f_thread/tests/unit/c/test-thread-locks_resize.h deleted file mode 100644 index aebb72b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-locks_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_locks_resize -#define _TEST__F_thread__thread_locks_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_locks_resize() - */ -extern void test__f_thread_locks_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_locks_resize() - */ -extern void test__f_thread_locks_resize__works(void **state); - -#endif // _TEST__F_thread__thread_locks_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-locks_resize_callback.c new file mode 100644 index 0000000..a036c91 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_resize_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-locks_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_locks_resize_callback__fails(void **state) { + + f_thread_lock_t data = f_thread_lock_t_initialize; + f_thread_lock_t data_array[] = { data }; + f_thread_locks_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_locks_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_rwlock_destroy, true); + will_return(__wrap_pthread_rwlock_destroy, errnos[i]); + + const f_status_t status = f_thread_locks_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_locks_resize_callback__works(void **state) { + + f_thread_lock_t data = f_thread_lock_t_initialize; + f_thread_lock_t data_array[] = { data }; + f_thread_locks_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_locks_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_rwlock_destroy, false); + + const f_status_t status = f_thread_locks_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-locks_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-locks_resize_callback.h new file mode 100644 index 0000000..bd5bd5f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-locks_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__locks_resize_callback +#define _TEST__F_thread__locks_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_locks_resize_callback_() + */ +extern void test__f_thread_locks_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_locks_resize_callback_() + */ +extern void test__f_thread_locks_resize_callback__works(void **state); + +#endif // _TEST__F_thread__locks_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.c deleted file mode 100644 index 6cf1b7e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutex_attributes_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutex_attributes_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutex_attributes_adjust__works(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.h deleted file mode 100644 index baae21c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutex_attributes_adjust -#define _TEST__F_thread__thread_mutex_attributes_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutex_attributes_adjust() - */ -extern void test__f_thread_mutex_attributes_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutex_attributes_adjust() - */ -extern void test__f_thread_mutex_attributes_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_mutex_attributes_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust_callback.c new file mode 100644 index 0000000..8600d9b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-mutex_attributes_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutex_attributes_adjust_callback__fails(void **state) { + + f_thread_mutex_attribute_t data = f_thread_mutex_attribute_t_initialize; + f_thread_mutex_attribute_t data_array[] = { data }; + f_thread_mutex_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_mutex_attributes_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_mutexattr_destroy, true); + will_return(__wrap_pthread_mutexattr_destroy, errnos[i]); + + const f_status_t status = f_thread_mutex_attributes_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_mutex_attributes_adjust_callback__works(void **state) { + + f_thread_mutex_attribute_t data = f_thread_mutex_attribute_t_initialize; + f_thread_mutex_attribute_t data_array[] = { data }; + f_thread_mutex_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_mutex_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_mutexattr_destroy, false); + + const f_status_t status = f_thread_mutex_attributes_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust_callback.h new file mode 100644 index 0000000..d9f9a2d --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__mutex_attributes_adjust_callback +#define _TEST__F_thread__mutex_attributes_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_mutex_attributes_adjust_callback_() + */ +extern void test__f_thread_mutex_attributes_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutex_attributes_adjust_callback_() + */ +extern void test__f_thread_mutex_attributes_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__mutex_attributes_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.c deleted file mode 100644 index 5e5fe16..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutex_attributes_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutex_attributes_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutex_attributes_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_mutex_attributes_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_mutex_attributes_decimate_by__works(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_mutexattr_destroy, false); - } // for - - const f_status_t status = f_thread_mutex_attributes_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.h deleted file mode 100644 index 1e2fda3..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutex_attributes_decimate_by -#define _TEST__F_thread__thread_mutex_attributes_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutex_attributes_decimate_by() - */ -extern void test__f_thread_mutex_attributes_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_mutex_attributes_decimate_by() - */ -extern void test__f_thread_mutex_attributes_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutex_attributes_decimate_by() - */ -extern void test__f_thread_mutex_attributes_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_mutex_attributes_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.c deleted file mode 100644 index 7289522..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutex_attributes_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutex_attributes_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutex_attributes_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_mutex_attributes_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_mutex_attributes_decrease_by__works(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_mutexattr_destroy, false); - } // for - - const f_status_t status = f_thread_mutex_attributes_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.h deleted file mode 100644 index d5eb3bd..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutex_attributes_decrease_by -#define _TEST__F_thread__thread_mutex_attributes_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutex_attributes_decrease_by() - */ -extern void test__f_thread_mutex_attributes_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_mutex_attributes_decrease_by() - */ -extern void test__f_thread_mutex_attributes_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutex_attributes_decrease_by() - */ -extern void test__f_thread_mutex_attributes_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_mutex_attributes_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.c deleted file mode 100644 index daac9e5..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutex_attributes_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutex_attributes_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_mutex_attributes_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_mutex_attributes_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_mutex_attributes_increase__works(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_mutex_attributes_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.h deleted file mode 100644 index e557d6c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutex_attributes_increase -#define _TEST__F_thread__thread_mutex_attributes_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutex_attributes_increase() - */ -extern void test__f_thread_mutex_attributes_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_mutex_attributes_increase() - */ -extern void test__f_thread_mutex_attributes_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutex_attributes_increase() - */ -extern void test__f_thread_mutex_attributes_increase__works(void **state); - -#endif // _TEST__F_thread__thread_mutex_attributes_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.c deleted file mode 100644 index 3e7725e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutex_attributes_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutex_attributes_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutex_attributes_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_mutex_attributes_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_mutex_attributes_increase_by__works(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_mutex_attributes_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.h deleted file mode 100644 index 72f5c5c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutex_attributes_increase_by -#define _TEST__F_thread__thread_mutex_attributes_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutex_attributes_increase_by() - */ -extern void test__f_thread_mutex_attributes_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_mutex_attributes_increase_by() - */ -extern void test__f_thread_mutex_attributes_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutex_attributes_increase_by() - */ -extern void test__f_thread_mutex_attributes_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_mutex_attributes_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.c deleted file mode 100644 index 4d0fc65..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutex_attributes_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutex_attributes_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutex_attributes_resize__works(void **state) { - - const int length = 5; - f_thread_mutex_attributes_t data = f_thread_mutex_attributes_t_initialize; - - { - const f_status_t status = f_thread_mutex_attributes_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.h deleted file mode 100644 index 84d297c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutex_attributes_resize -#define _TEST__F_thread__thread_mutex_attributes_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutex_attributes_resize() - */ -extern void test__f_thread_mutex_attributes_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutex_attributes_resize() - */ -extern void test__f_thread_mutex_attributes_resize__works(void **state); - -#endif // _TEST__F_thread__thread_mutex_attributes_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize_callback.c new file mode 100644 index 0000000..4fe73e8 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-mutex_attributes_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutex_attributes_resize_callback__fails(void **state) { + + f_thread_mutex_attribute_t data = f_thread_mutex_attribute_t_initialize; + f_thread_mutex_attribute_t data_array[] = { data }; + f_thread_mutex_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_mutex_attributes_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_mutexattr_destroy, true); + will_return(__wrap_pthread_mutexattr_destroy, errnos[i]); + + const f_status_t status = f_thread_mutex_attributes_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_mutex_attributes_resize_callback__works(void **state) { + + f_thread_mutex_attribute_t data = f_thread_mutex_attribute_t_initialize; + f_thread_mutex_attribute_t data_array[] = { data }; + f_thread_mutex_attributes_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_mutex_attributes_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_mutexattr_destroy, false); + + const f_status_t status = f_thread_mutex_attributes_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize_callback.h new file mode 100644 index 0000000..ac25fd1 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutex_attributes_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__mutex_attributes_resize_callback +#define _TEST__F_thread__mutex_attributes_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_mutex_attributes_resize_callback_() + */ +extern void test__f_thread_mutex_attributes_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutex_attributes_resize_callback_() + */ +extern void test__f_thread_mutex_attributes_resize_callback__works(void **state); + +#endif // _TEST__F_thread__mutex_attributes_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.c deleted file mode 100644 index 5b8d6e6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutexs_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutexs_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutexs_adjust__works(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.h deleted file mode 100644 index 674947f..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutexs_adjust -#define _TEST__F_thread__thread_mutexs_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutexs_adjust() - */ -extern void test__f_thread_mutexs_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutexs_adjust() - */ -extern void test__f_thread_mutexs_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_mutexs_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust_callback.c new file mode 100644 index 0000000..4513def --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-mutexs_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutexs_adjust_callback__fails(void **state) { + + f_thread_mutex_t data = f_thread_mutex_t_initialize; + f_thread_mutex_t data_array[] = { data }; + f_thread_mutexs_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_mutexs_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_mutex_destroy, true); + will_return(__wrap_pthread_mutex_destroy, errnos[i]); + + const f_status_t status = f_thread_mutexs_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_mutexs_adjust_callback__works(void **state) { + + f_thread_mutex_t data = f_thread_mutex_t_initialize; + f_thread_mutex_t data_array[] = { data }; + f_thread_mutexs_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_mutexs_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_mutex_destroy, false); + + const f_status_t status = f_thread_mutexs_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust_callback.h new file mode 100644 index 0000000..fcd4c45 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__mutexs_adjust_callback +#define _TEST__F_thread__mutexs_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_mutexs_adjust_callback_() + */ +extern void test__f_thread_mutexs_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutexs_adjust_callback_() + */ +extern void test__f_thread_mutexs_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__mutexs_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.c deleted file mode 100644 index 8026da5..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutexs_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutexs_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutexs_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_mutexs_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_mutexs_decimate_by__works(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_mutex_destroy, false); - } // for - - const f_status_t status = f_thread_mutexs_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.h deleted file mode 100644 index 47ccbf9..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutexs_decimate_by -#define _TEST__F_thread__thread_mutexs_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutexs_decimate_by() - */ -extern void test__f_thread_mutexs_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_mutexs_decimate_by() - */ -extern void test__f_thread_mutexs_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutexs_decimate_by() - */ -extern void test__f_thread_mutexs_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_mutexs_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.c deleted file mode 100644 index 3a73069..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutexs_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutexs_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutexs_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_mutexs_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_mutexs_decrease_by__works(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_mutex_destroy, false); - } // for - - const f_status_t status = f_thread_mutexs_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.h deleted file mode 100644 index 7551f86..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutexs_decrease_by -#define _TEST__F_thread__thread_mutexs_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutexs_decrease_by() - */ -extern void test__f_thread_mutexs_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_mutexs_decrease_by() - */ -extern void test__f_thread_mutexs_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutexs_decrease_by() - */ -extern void test__f_thread_mutexs_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_mutexs_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.c deleted file mode 100644 index af1186e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutexs_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutexs_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_mutexs_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_mutexs_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_mutexs_increase__works(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_mutexs_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.h deleted file mode 100644 index fe7dc0a..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutexs_increase -#define _TEST__F_thread__thread_mutexs_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutexs_increase() - */ -extern void test__f_thread_mutexs_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_mutexs_increase() - */ -extern void test__f_thread_mutexs_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutexs_increase() - */ -extern void test__f_thread_mutexs_increase__works(void **state); - -#endif // _TEST__F_thread__thread_mutexs_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.c deleted file mode 100644 index d5f41d8..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutexs_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutexs_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutexs_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_mutexs_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_mutexs_increase_by__works(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_mutexs_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.h deleted file mode 100644 index ea7ad30..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutexs_increase_by -#define _TEST__F_thread__thread_mutexs_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutexs_increase_by() - */ -extern void test__f_thread_mutexs_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_mutexs_increase_by() - */ -extern void test__f_thread_mutexs_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutexs_increase_by() - */ -extern void test__f_thread_mutexs_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_mutexs_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.c deleted file mode 100644 index 1b98c29..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-mutexs_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_mutexs_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_mutexs_resize__works(void **state) { - - const int length = 5; - f_thread_mutexs_t data = f_thread_mutexs_t_initialize; - - { - const f_status_t status = f_thread_mutexs_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.h deleted file mode 100644 index d2634aa..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_mutexs_resize -#define _TEST__F_thread__thread_mutexs_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_mutexs_resize() - */ -extern void test__f_thread_mutexs_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_mutexs_resize() - */ -extern void test__f_thread_mutexs_resize__works(void **state); - -#endif // _TEST__F_thread__thread_mutexs_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize_callback.c new file mode 100644 index 0000000..5cf9357 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-mutexs_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_mutexs_resize_callback__fails(void **state) { + + f_thread_mutex_t data = f_thread_mutex_t_initialize; + f_thread_mutex_t data_array[] = { data }; + f_thread_mutexs_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_mutexs_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_mutex_destroy, true); + will_return(__wrap_pthread_mutex_destroy, errnos[i]); + + const f_status_t status = f_thread_mutexs_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_mutexs_resize_callback__works(void **state) { + + f_thread_mutex_t data = f_thread_mutex_t_initialize; + f_thread_mutex_t data_array[] = { data }; + f_thread_mutexs_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_mutexs_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_mutex_destroy, false); + + const f_status_t status = f_thread_mutexs_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize_callback.h new file mode 100644 index 0000000..7a1bb26 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-mutexs_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__mutexs_resize_callback +#define _TEST__F_thread__mutexs_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_mutexs_resize_callback_() + */ +extern void test__f_thread_mutexs_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_mutexs_resize_callback_() + */ +extern void test__f_thread_mutexs_resize_callback__works(void **state); + +#endif // _TEST__F_thread__mutexs_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.c deleted file mode 100644 index 7635ddd..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-onces_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_onces_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_onces_adjust__works(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.h deleted file mode 100644 index 0538d8c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_onces_adjust -#define _TEST__F_thread__thread_onces_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_onces_adjust() - */ -extern void test__f_thread_onces_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_onces_adjust() - */ -extern void test__f_thread_onces_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_onces_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust_callback.c new file mode 100644 index 0000000..10e99da --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-onces_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_onces_adjust_callback__fails(void **state) { + + f_thread_once_t data = f_thread_once_t_initialize; + f_thread_once_t data_array[] = { data }; + f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_onces_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_destroy, true); + will_return(__wrap_pthread_attr_destroy, errnos[i]); + + const f_status_t status = f_thread_onces_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_onces_adjust_callback__works(void **state) { + + f_thread_once_t data = f_thread_once_t_initialize; + f_thread_once_t data_array[] = { data }; + f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_onces_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_attr_destroy, false); + + const f_status_t status = f_thread_onces_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust_callback.h new file mode 100644 index 0000000..fe51cd7 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__onces_adjust_callback +#define _TEST__F_thread__onces_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_onces_adjust_callback_() + */ +extern void test__f_thread_onces_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_onces_adjust_callback_() + */ +extern void test__f_thread_onces_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__onces_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.c deleted file mode 100644 index 3b8bae4..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-thread.h" -#include "test-thread-onces_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_onces_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_onces_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_onces_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_onces_decimate_by__works(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_onces_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.h deleted file mode 100644 index 54c3f04..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_onces_decimate_by -#define _TEST__F_thread__thread_onces_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_onces_decimate_by() - */ -extern void test__f_thread_onces_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_onces_decimate_by() - */ -extern void test__f_thread_onces_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_onces_decimate_by() - */ -extern void test__f_thread_onces_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_onces_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.c deleted file mode 100644 index 4af8293..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.c +++ /dev/null @@ -1,74 +0,0 @@ -#include "test-thread.h" -#include "test-thread-onces_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_onces_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_onces_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_onces_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_onces_decrease_by__works(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_onces_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.h deleted file mode 100644 index 045607b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_onces_decrease_by -#define _TEST__F_thread__thread_onces_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_onces_decrease_by() - */ -extern void test__f_thread_onces_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_onces_decrease_by() - */ -extern void test__f_thread_onces_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_onces_decrease_by() - */ -extern void test__f_thread_onces_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_onces_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_increase.c b/level_0/f_thread/tests/unit/c/test-thread-onces_increase.c deleted file mode 100644 index e527b0e..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-onces_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_onces_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_onces_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_onces_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_onces_increase__works(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_onces_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_increase.h b/level_0/f_thread/tests/unit/c/test-thread-onces_increase.h deleted file mode 100644 index e37b16f..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_onces_increase -#define _TEST__F_thread__thread_onces_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_onces_increase() - */ -extern void test__f_thread_onces_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_onces_increase() - */ -extern void test__f_thread_onces_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_onces_increase() - */ -extern void test__f_thread_onces_increase__works(void **state); - -#endif // _TEST__F_thread__thread_onces_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.c deleted file mode 100644 index 7cc6803..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-onces_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_onces_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_onces_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_onces_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_onces_increase_by__works(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_onces_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.h deleted file mode 100644 index 478527a..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_onces_increase_by -#define _TEST__F_thread__thread_onces_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_onces_increase_by() - */ -extern void test__f_thread_onces_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_onces_increase_by() - */ -extern void test__f_thread_onces_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_onces_increase_by() - */ -extern void test__f_thread_onces_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_onces_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_resize.c b/level_0/f_thread/tests/unit/c/test-thread-onces_resize.c deleted file mode 100644 index 1f7a4d6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-onces_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_onces_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_onces_resize__works(void **state) { - - const int length = 5; - f_thread_onces_t data = f_thread_onces_t_initialize; - - { - const f_status_t status = f_thread_onces_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_resize.h b/level_0/f_thread/tests/unit/c/test-thread-onces_resize.h deleted file mode 100644 index 8a56330..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-onces_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_onces_resize -#define _TEST__F_thread__thread_onces_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_onces_resize() - */ -extern void test__f_thread_onces_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_onces_resize() - */ -extern void test__f_thread_onces_resize__works(void **state); - -#endif // _TEST__F_thread__thread_onces_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-onces_resize_callback.c new file mode 100644 index 0000000..d2fea77 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_resize_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-onces_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_onces_resize_callback__fails(void **state) { + + f_thread_once_t data = f_thread_once_t_initialize; + f_thread_once_t data_array[] = { data }; + f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_onces_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_destroy, true); + will_return(__wrap_pthread_attr_destroy, errnos[i]); + + const f_status_t status = f_thread_onces_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_onces_resize_callback__works(void **state) { + + f_thread_once_t data = f_thread_once_t_initialize; + f_thread_once_t data_array[] = { data }; + f_thread_onces_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_onces_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_attr_destroy, false); + + const f_status_t status = f_thread_onces_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-onces_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-onces_resize_callback.h new file mode 100644 index 0000000..a9f7b3b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-onces_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__onces_resize_callback +#define _TEST__F_thread__onces_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_onces_resize_callback_() + */ +extern void test__f_thread_onces_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_onces_resize_callback_() + */ +extern void test__f_thread_onces_resize_callback__works(void **state); + +#endif // _TEST__F_thread__onces_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.c deleted file mode 100644 index d848ddb..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-semaphores_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_semaphores_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_semaphores_adjust__works(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.h deleted file mode 100644 index 7292d62..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_semaphores_adjust -#define _TEST__F_thread__thread_semaphores_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_semaphores_adjust() - */ -extern void test__f_thread_semaphores_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_semaphores_adjust() - */ -extern void test__f_thread_semaphores_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_semaphores_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust_callback.c new file mode 100644 index 0000000..edbd177 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-semaphores_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_semaphores_adjust_callback__fails(void **state) { + + f_thread_semaphore_t data = f_thread_semaphore_t_initialize; + f_thread_semaphore_t data_array[] = { data }; + f_thread_semaphores_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_semaphores_t datass_array[] = { datas }; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_sem_destroy, true); + will_return(__wrap_sem_destroy, errnos[i]); + + const f_status_t status = f_thread_semaphores_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_semaphores_adjust_callback__works(void **state) { + + f_thread_semaphore_t data = f_thread_semaphore_t_initialize; + f_thread_semaphore_t data_array[] = { data }; + f_thread_semaphores_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_semaphores_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_sem_destroy, false); + + const f_status_t status = f_thread_semaphores_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust_callback.h new file mode 100644 index 0000000..063653b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__semaphores_adjust_callback +#define _TEST__F_thread__semaphores_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_semaphores_adjust_callback_() + */ +extern void test__f_thread_semaphores_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_semaphores_adjust_callback_() + */ +extern void test__f_thread_semaphores_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__semaphores_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.c deleted file mode 100644 index 1c1cba4..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-semaphores_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_semaphores_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_semaphores_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_semaphores_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_semaphores_decimate_by__works(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_sem_destroy, false); - } // for - - const f_status_t status = f_thread_semaphores_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.h deleted file mode 100644 index 41a9791..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_semaphores_decimate_by -#define _TEST__F_thread__thread_semaphores_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_semaphores_decimate_by() - */ -extern void test__f_thread_semaphores_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_semaphores_decimate_by() - */ -extern void test__f_thread_semaphores_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_semaphores_decimate_by() - */ -extern void test__f_thread_semaphores_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_semaphores_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.c deleted file mode 100644 index 3d4133b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-semaphores_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_semaphores_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_semaphores_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_semaphores_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_semaphores_decrease_by__works(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_sem_destroy, false); - } // for - - const f_status_t status = f_thread_semaphores_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.h deleted file mode 100644 index 34df8c5..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_semaphores_decrease_by -#define _TEST__F_thread__thread_semaphores_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_semaphores_decrease_by() - */ -extern void test__f_thread_semaphores_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_semaphores_decrease_by() - */ -extern void test__f_thread_semaphores_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_semaphores_decrease_by() - */ -extern void test__f_thread_semaphores_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_semaphores_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.c deleted file mode 100644 index 42a101d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-semaphores_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_semaphores_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_semaphores_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_semaphores_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_semaphores_increase__works(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_semaphores_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.h deleted file mode 100644 index 2ebc2a0..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_semaphores_increase -#define _TEST__F_thread__thread_semaphores_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_semaphores_increase() - */ -extern void test__f_thread_semaphores_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_semaphores_increase() - */ -extern void test__f_thread_semaphores_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_semaphores_increase() - */ -extern void test__f_thread_semaphores_increase__works(void **state); - -#endif // _TEST__F_thread__thread_semaphores_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.c deleted file mode 100644 index 1ece24a..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-semaphores_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_semaphores_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_semaphores_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_semaphores_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_semaphores_increase_by__works(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_semaphores_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.h deleted file mode 100644 index 11abcb2..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_semaphores_increase_by -#define _TEST__F_thread__thread_semaphores_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_semaphores_increase_by() - */ -extern void test__f_thread_semaphores_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_semaphores_increase_by() - */ -extern void test__f_thread_semaphores_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_semaphores_increase_by() - */ -extern void test__f_thread_semaphores_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_semaphores_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.c deleted file mode 100644 index 46d4275..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-semaphores_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_semaphores_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_semaphores_resize__works(void **state) { - - const int length = 5; - f_thread_semaphores_t data = f_thread_semaphores_t_initialize; - - { - const f_status_t status = f_thread_semaphores_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.h deleted file mode 100644 index a41a3e1..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_semaphores_resize -#define _TEST__F_thread__thread_semaphores_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_semaphores_resize() - */ -extern void test__f_thread_semaphores_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_semaphores_resize() - */ -extern void test__f_thread_semaphores_resize__works(void **state); - -#endif // _TEST__F_thread__thread_semaphores_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize_callback.c new file mode 100644 index 0000000..5e32c3e --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-semaphores_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_semaphores_resize_callback__fails(void **state) { + + f_thread_semaphore_t data = f_thread_semaphore_t_initialize; + f_thread_semaphore_t data_array[] = { data }; + f_thread_semaphores_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_semaphores_t datass_array[] = { datas }; + + int errnos[] = { + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_sem_destroy, true); + will_return(__wrap_sem_destroy, errnos[i]); + + const f_status_t status = f_thread_semaphores_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_semaphores_resize_callback__works(void **state) { + + f_thread_semaphore_t data = f_thread_semaphore_t_initialize; + f_thread_semaphore_t data_array[] = { data }; + f_thread_semaphores_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_semaphores_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_sem_destroy, false); + + const f_status_t status = f_thread_semaphores_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize_callback.h new file mode 100644 index 0000000..d8d12f3 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-semaphores_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__semaphores_resize_callback +#define _TEST__F_thread__semaphores_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_semaphores_resize_callback_() + */ +extern void test__f_thread_semaphores_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_semaphores_resize_callback_() + */ +extern void test__f_thread_semaphores_resize_callback__works(void **state); + +#endif // _TEST__F_thread__semaphores_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.c deleted file mode 100644 index 9ada163..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-sets_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_sets_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_sets_adjust__works(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.h deleted file mode 100644 index adbefb2..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_sets_adjust -#define _TEST__F_thread__thread_sets_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_sets_adjust() - */ -extern void test__f_thread_sets_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_sets_adjust() - */ -extern void test__f_thread_sets_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_sets_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust_callback.c new file mode 100644 index 0000000..7c11734 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-sets_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_sets_adjust_callback__fails(void **state) { + + f_thread_set_t data = f_thread_set_t_initialize; + f_thread_set_t data_array[] = { data }; + f_thread_sets_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_sets_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_destroy, true); + will_return(__wrap_pthread_attr_destroy, errnos[i]); + + const f_status_t status = f_thread_sets_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_sets_adjust_callback__works(void **state) { + + f_thread_set_t data = f_thread_set_t_initialize; + f_thread_set_t data_array[] = { data }; + f_thread_sets_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_sets_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_attr_destroy, false); + + const f_status_t status = f_thread_sets_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust_callback.h new file mode 100644 index 0000000..6af7dff --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__sets_adjust_callback +#define _TEST__F_thread__sets_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_sets_adjust_callback_() + */ +extern void test__f_thread_sets_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_sets_adjust_callback_() + */ +extern void test__f_thread_sets_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__sets_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.c deleted file mode 100644 index 58f5a61..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-sets_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_sets_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_sets_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_sets_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_sets_decimate_by__works(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_attr_destroy, false); - } // for - - const f_status_t status = f_thread_sets_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.h deleted file mode 100644 index b10a23d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_sets_decimate_by -#define _TEST__F_thread__thread_sets_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_sets_decimate_by() - */ -extern void test__f_thread_sets_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_sets_decimate_by() - */ -extern void test__f_thread_sets_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_sets_decimate_by() - */ -extern void test__f_thread_sets_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_sets_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.c deleted file mode 100644 index 252d4b6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-sets_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_sets_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_sets_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_sets_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_sets_decrease_by__works(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_attr_destroy, false); - } // for - - const f_status_t status = f_thread_sets_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.h deleted file mode 100644 index 9745191..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_sets_decrease_by -#define _TEST__F_thread__thread_sets_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_sets_decrease_by() - */ -extern void test__f_thread_sets_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_sets_decrease_by() - */ -extern void test__f_thread_sets_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_sets_decrease_by() - */ -extern void test__f_thread_sets_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_sets_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_increase.c b/level_0/f_thread/tests/unit/c/test-thread-sets_increase.c deleted file mode 100644 index c06b768..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-sets_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_sets_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_sets_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_sets_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_sets_increase__works(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_sets_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_increase.h b/level_0/f_thread/tests/unit/c/test-thread-sets_increase.h deleted file mode 100644 index 3643e48..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_sets_increase -#define _TEST__F_thread__thread_sets_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_sets_increase() - */ -extern void test__f_thread_sets_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_sets_increase() - */ -extern void test__f_thread_sets_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_sets_increase() - */ -extern void test__f_thread_sets_increase__works(void **state); - -#endif // _TEST__F_thread__thread_sets_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.c deleted file mode 100644 index bea0a6d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-sets_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_sets_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_sets_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_sets_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_sets_increase_by__works(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_sets_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.h deleted file mode 100644 index dea34d8..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_sets_increase_by -#define _TEST__F_thread__thread_sets_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_sets_increase_by() - */ -extern void test__f_thread_sets_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_sets_increase_by() - */ -extern void test__f_thread_sets_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_sets_increase_by() - */ -extern void test__f_thread_sets_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_sets_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_resize.c b/level_0/f_thread/tests/unit/c/test-thread-sets_resize.c deleted file mode 100644 index e690f5c..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-sets_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_sets_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_sets_resize__works(void **state) { - - const int length = 5; - f_thread_sets_t data = f_thread_sets_t_initialize; - - { - const f_status_t status = f_thread_sets_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_resize.h b/level_0/f_thread/tests/unit/c/test-thread-sets_resize.h deleted file mode 100644 index a0c0ee6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-sets_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_sets_resize -#define _TEST__F_thread__thread_sets_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_sets_resize() - */ -extern void test__f_thread_sets_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_sets_resize() - */ -extern void test__f_thread_sets_resize__works(void **state); - -#endif // _TEST__F_thread__thread_sets_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-sets_resize_callback.c new file mode 100644 index 0000000..efe84c1 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_resize_callback.c @@ -0,0 +1,55 @@ +#include "test-thread.h" +#include "test-thread-sets_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_sets_resize_callback__fails(void **state) { + + f_thread_set_t data = f_thread_set_t_initialize; + f_thread_set_t data_array[] = { data }; + f_thread_sets_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_sets_t datass_array[] = { datas }; + + int errnos[] = { + 1, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_failure), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 2; ++i) { + + will_return(__wrap_pthread_attr_destroy, true); + will_return(__wrap_pthread_attr_destroy, errnos[i]); + + const f_status_t status = f_thread_sets_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_sets_resize_callback__works(void **state) { + + f_thread_set_t data = f_thread_set_t_initialize; + f_thread_set_t data_array[] = { data }; + f_thread_sets_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_sets_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_attr_destroy, false); + + const f_status_t status = f_thread_sets_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-sets_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-sets_resize_callback.h new file mode 100644 index 0000000..44f0d39 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-sets_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__sets_resize_callback +#define _TEST__F_thread__sets_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_sets_resize_callback_() + */ +extern void test__f_thread_sets_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_sets_resize_callback_() + */ +extern void test__f_thread_sets_resize_callback__works(void **state); + +#endif // _TEST__F_thread__sets_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.c b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.c deleted file mode 100644 index b7d39b7..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-spins_adjust.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_spins_adjust__parameter_checking(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_adjust(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_spins_adjust__works(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_adjust(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.h b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.h deleted file mode 100644 index 9ed73af..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_adjust.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_spins_adjust -#define _TEST__F_thread__thread_spins_adjust - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_spins_adjust() - */ -extern void test__f_thread_spins_adjust__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_spins_adjust() - */ -extern void test__f_thread_spins_adjust__works(void **state); - -#endif // _TEST__F_thread__thread_spins_adjust diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_adjust_callback.c b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust_callback.c new file mode 100644 index 0000000..aca7456 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-spins_adjust_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_spins_adjust_callback__fails(void **state) { + + f_thread_spin_t data = f_thread_spin_t_initialize; + f_thread_spin_t data_array[] = { data }; + f_thread_spins_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_spins_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_spin_destroy, true); + will_return(__wrap_pthread_spin_destroy, errnos[i]); + + const f_status_t status = f_thread_spins_adjust_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_spins_adjust_callback__works(void **state) { + + f_thread_spin_t data = f_thread_spin_t_initialize; + f_thread_spin_t data_array[] = { data }; + f_thread_spins_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_spins_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_spin_destroy, false); + + const f_status_t status = f_thread_spins_adjust_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_adjust_callback.h b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust_callback.h new file mode 100644 index 0000000..5c41d2b --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_adjust_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__spins_adjust_callback +#define _TEST__F_thread__spins_adjust_callback + +/** + * Test that the function fails. + * + * @see f_thread_spins_adjust_callback_() + */ +extern void test__f_thread_spins_adjust_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_spins_adjust_callback_() + */ +extern void test__f_thread_spins_adjust_callback__works(void **state); + +#endif // _TEST__F_thread__spins_adjust_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.c b/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.c deleted file mode 100644 index 508474b..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-spins_decimate_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_spins_decimate_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_decimate_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_spins_decimate_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_spins_decimate_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_spins_decimate_by__works(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_spin_destroy, false); - } // for - - const f_status_t status = f_thread_spins_decimate_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.h b/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.h deleted file mode 100644 index 31cecf0..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_decimate_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_spins_decimate_by -#define _TEST__F_thread__thread_spins_decimate_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_spins_decimate_by() - */ -extern void test__f_thread_spins_decimate_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_spins_decimate_by() - */ -extern void test__f_thread_spins_decimate_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_spins_decimate_by() - */ -extern void test__f_thread_spins_decimate_by__works(void **state); - -#endif // _TEST__F_thread__thread_spins_decimate_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.c b/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.c deleted file mode 100644 index d7277f4..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.c +++ /dev/null @@ -1,78 +0,0 @@ -#include "test-thread.h" -#include "test-thread-spins_decrease_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_spins_decrease_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_decrease_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_spins_decrease_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_spins_decrease_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_spins_decrease_by__works(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - for (uint8_t i = 0; i < length; ++i) { - will_return(__wrap_pthread_spin_destroy, false); - } // for - - const f_status_t status = f_thread_spins_decrease_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.h b/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.h deleted file mode 100644 index ef610d6..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_decrease_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_spins_decrease_by -#define _TEST__F_thread__thread_spins_decrease_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_spins_decrease_by() - */ -extern void test__f_thread_spins_decrease_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_spins_decrease_by() - */ -extern void test__f_thread_spins_decrease_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_spins_decrease_by() - */ -extern void test__f_thread_spins_decrease_by__works(void **state); - -#endif // _TEST__F_thread__thread_spins_decrease_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_increase.c b/level_0/f_thread/tests/unit/c/test-thread-spins_increase.c deleted file mode 100644 index daf465f..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_increase.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-spins_increase.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_spins_increase__parameter_checking(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_increase(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - free((void *) data.array); -} - -void test__f_thread_spins_increase__returns_data_not(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_spins_increase(length, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_spins_increase__works(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_spins_increase(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_in_range(data.size, length + 1, length + 1 + F_memory_default_allocation_small_d); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_increase.h b/level_0/f_thread/tests/unit/c/test-thread-spins_increase.h deleted file mode 100644 index dc7566d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_increase.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_spins_increase -#define _TEST__F_thread__thread_spins_increase - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_spins_increase() - */ -extern void test__f_thread_spins_increase__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_spins_increase() - */ -extern void test__f_thread_spins_increase__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_spins_increase() - */ -extern void test__f_thread_spins_increase__works(void **state); - -#endif // _TEST__F_thread__thread_spins_increase diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.c b/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.c deleted file mode 100644 index 7d404c2..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "test-thread.h" -#include "test-thread-spins_increase_by.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_spins_increase_by__parameter_checking(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_increase_by(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_spins_increase_by__returns_data_not(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - const f_status_t status = f_thread_spins_increase_by(0, &data); - - assert_int_equal(status, F_data_not); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -void test__f_thread_spins_increase_by__works(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - { - data.used = length; - - const f_status_t status = f_thread_spins_increase_by(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, length); - assert_int_equal(data.size, length * 2); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.h b/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.h deleted file mode 100644 index 1e33bda..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_increase_by.h +++ /dev/null @@ -1,34 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_spins_increase_by -#define _TEST__F_thread__thread_spins_increase_by - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_spins_increase_by() - */ -extern void test__f_thread_spins_increase_by__parameter_checking(void **state); - -/** - * Test that the function returns F_data_not. - * - * @see f_thread_spins_increase_by() - */ -extern void test__f_thread_spins_increase_by__returns_data_not(void **state); - -/** - * Test that the function works. - * - * @see f_thread_spins_increase_by() - */ -extern void test__f_thread_spins_increase_by__works(void **state); - -#endif // _TEST__F_thread__thread_spins_increase_by diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_resize.c b/level_0/f_thread/tests/unit/c/test-thread-spins_resize.c deleted file mode 100644 index 0d5b60a..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_resize.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "test-thread.h" -#include "test-thread-spins_resize.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void test__f_thread_spins_resize__parameter_checking(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, 0); - - assert_int_equal(status, F_status_set_error(F_parameter)); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, 0); - } - - assert_null(data.array); -} - -void test__f_thread_spins_resize__works(void **state) { - - const int length = 5; - f_thread_spins_t data = f_thread_spins_t_initialize; - - { - const f_status_t status = f_thread_spins_resize(length, &data); - - assert_int_equal(status, F_none); - assert_int_equal(data.used, 0); - assert_int_equal(data.size, length); - } - - free((void *) data.array); -} - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_resize.h b/level_0/f_thread/tests/unit/c/test-thread-spins_resize.h deleted file mode 100644 index 4fa350d..0000000 --- a/level_0/f_thread/tests/unit/c/test-thread-spins_resize.h +++ /dev/null @@ -1,27 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: Thread - * API Version: 0.7 - * Licenses: lgpl-2.1-or-later - * - * Test the array types in the thread project. - */ -#ifndef _TEST__F_thread__thread_spins_resize -#define _TEST__F_thread__thread_spins_resize - -/** - * Test that the function correctly fails on invalid parameter. - * - * @see f_thread_spins_resize() - */ -extern void test__f_thread_spins_resize__parameter_checking(void **state); - -/** - * Test that the function works. - * - * @see f_thread_spins_resize() - */ -extern void test__f_thread_spins_resize__works(void **state); - -#endif // _TEST__F_thread__thread_spins_resize diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_resize_callback.c b/level_0/f_thread/tests/unit/c/test-thread-spins_resize_callback.c new file mode 100644 index 0000000..321515f --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_resize_callback.c @@ -0,0 +1,57 @@ +#include "test-thread.h" +#include "test-thread-spins_resize_callback.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void test__f_thread_spins_resize_callback__fails(void **state) { + + f_thread_spin_t data = f_thread_spin_t_initialize; + f_thread_spin_t data_array[] = { data }; + f_thread_spins_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_spins_t datass_array[] = { datas }; + + int errnos[] = { + EBUSY, + EINVAL, + mock_errno_generic, + }; + + f_status_t statuss[] = { + F_status_set_error(F_busy), + F_status_set_error(F_parameter), + F_status_set_error(F_failure), + }; + + for (uint8_t i = 0; i < 3; ++i) { + + will_return(__wrap_pthread_spin_destroy, true); + will_return(__wrap_pthread_spin_destroy, errnos[i]); + + const f_status_t status = f_thread_spins_resize_callback(0, 1, (void *) datass_array); + + assert_int_equal(status, statuss[i]); + } // for +} + +void test__f_thread_spins_resize_callback__works(void **state) { + + f_thread_spin_t data = f_thread_spin_t_initialize; + f_thread_spin_t data_array[] = { data }; + f_thread_spins_t datas = { .array = data_array, .used = 1, .size = 1 }; + f_thread_spins_t datass_array[] = { datas }; + const f_number_unsigned_t length = 1; + + { + will_return(__wrap_pthread_spin_destroy, false); + + const f_status_t status = f_thread_spins_resize_callback(0, length, (void *) datass_array); + + assert_int_equal(status, F_none); + } +} + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_thread/tests/unit/c/test-thread-spins_resize_callback.h b/level_0/f_thread/tests/unit/c/test-thread-spins_resize_callback.h new file mode 100644 index 0000000..4876ff4 --- /dev/null +++ b/level_0/f_thread/tests/unit/c/test-thread-spins_resize_callback.h @@ -0,0 +1,27 @@ +/** + * FLL - Level 0 + * + * Project: Thread + * API Version: 0.7 + * Licenses: lgpl-2.1-or-later + * + * Test the array types in the type project. + */ +#ifndef _TEST__F_thread__spins_resize_callback +#define _TEST__F_thread__spins_resize_callback + +/** + * Test that the function fails. + * + * @see f_thread_spins_resize_callback_() + */ +extern void test__f_thread_spins_resize_callback__fails(void **state); + +/** + * Test that the function works. + * + * @see f_thread_spins_resize_callback_() + */ +extern void test__f_thread_spins_resize_callback__works(void **state); + +#endif // _TEST__F_thread__spins_resize_callback diff --git a/level_0/f_thread/tests/unit/c/test-thread.c b/level_0/f_thread/tests/unit/c/test-thread.c index 944b87d..c7a8519 100644 --- a/level_0/f_thread/tests/unit/c/test-thread.c +++ b/level_0/f_thread/tests/unit/c/test-thread.c @@ -19,185 +19,70 @@ int setdown(void **state) { int main(void) { const struct CMUnitTest tests[] = { - cmocka_unit_test(test__f_thread_attributes_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_attributes_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_attributes_increase__returns_data_not), - cmocka_unit_test(test__f_thread_attributes_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_attributes_adjust__works), - cmocka_unit_test(test__f_thread_attributes_decimate_by__works), - cmocka_unit_test(test__f_thread_attributes_decrease_by__works), - cmocka_unit_test(test__f_thread_attributes_increase__works), - cmocka_unit_test(test__f_thread_attributes_increase_by__works), - cmocka_unit_test(test__f_thread_attributes_resize__works), - - cmocka_unit_test(test__f_thread_barrier_attributes_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_barrier_attributes_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_barrier_attributes_increase__returns_data_not), - cmocka_unit_test(test__f_thread_barrier_attributes_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_barrier_attributes_adjust__works), - cmocka_unit_test(test__f_thread_barrier_attributes_decimate_by__works), - cmocka_unit_test(test__f_thread_barrier_attributes_decrease_by__works), - cmocka_unit_test(test__f_thread_barrier_attributes_increase__works), - cmocka_unit_test(test__f_thread_barrier_attributes_increase_by__works), - cmocka_unit_test(test__f_thread_barrier_attributes_resize__works), - - cmocka_unit_test(test__f_thread_barriers_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_barriers_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_barriers_increase__returns_data_not), - cmocka_unit_test(test__f_thread_barriers_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_barriers_adjust__works), - cmocka_unit_test(test__f_thread_barriers_decimate_by__works), - cmocka_unit_test(test__f_thread_barriers_decrease_by__works), - cmocka_unit_test(test__f_thread_barriers_increase__works), - cmocka_unit_test(test__f_thread_barriers_increase_by__works), - cmocka_unit_test(test__f_thread_barriers_resize__works), - - cmocka_unit_test(test__f_thread_condition_attributes_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_condition_attributes_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_condition_attributes_increase__returns_data_not), - cmocka_unit_test(test__f_thread_condition_attributes_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_condition_attributes_adjust__works), - cmocka_unit_test(test__f_thread_condition_attributes_decimate_by__works), - cmocka_unit_test(test__f_thread_condition_attributes_decrease_by__works), - cmocka_unit_test(test__f_thread_condition_attributes_increase__works), - cmocka_unit_test(test__f_thread_condition_attributes_increase_by__works), - cmocka_unit_test(test__f_thread_condition_attributes_resize__works), - - cmocka_unit_test(test__f_thread_conditions_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_conditions_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_conditions_increase__returns_data_not), - cmocka_unit_test(test__f_thread_conditions_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_conditions_adjust__works), - cmocka_unit_test(test__f_thread_conditions_decimate_by__works), - cmocka_unit_test(test__f_thread_conditions_decrease_by__works), - cmocka_unit_test(test__f_thread_conditions_increase__works), - cmocka_unit_test(test__f_thread_conditions_increase_by__works), - cmocka_unit_test(test__f_thread_conditions_resize__works), - - cmocka_unit_test(test__f_thread_ids_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_ids_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_ids_increase__returns_data_not), - cmocka_unit_test(test__f_thread_ids_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_ids_adjust__works), - cmocka_unit_test(test__f_thread_ids_decimate_by__works), - cmocka_unit_test(test__f_thread_ids_decrease_by__works), - cmocka_unit_test(test__f_thread_ids_increase__works), - cmocka_unit_test(test__f_thread_ids_increase_by__works), - cmocka_unit_test(test__f_thread_ids_resize__works), - - cmocka_unit_test(test__f_thread_keys_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_keys_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_keys_increase__returns_data_not), - cmocka_unit_test(test__f_thread_keys_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_keys_adjust__works), - cmocka_unit_test(test__f_thread_keys_decimate_by__works), - cmocka_unit_test(test__f_thread_keys_decrease_by__works), - cmocka_unit_test(test__f_thread_keys_increase__works), - cmocka_unit_test(test__f_thread_keys_increase_by__works), - cmocka_unit_test(test__f_thread_keys_resize__works), - - cmocka_unit_test(test__f_thread_lock_attributes_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_lock_attributes_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_lock_attributes_increase__returns_data_not), - cmocka_unit_test(test__f_thread_lock_attributes_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_lock_attributes_adjust__works), - cmocka_unit_test(test__f_thread_lock_attributes_decimate_by__works), - cmocka_unit_test(test__f_thread_lock_attributes_decrease_by__works), - cmocka_unit_test(test__f_thread_lock_attributes_increase__works), - cmocka_unit_test(test__f_thread_lock_attributes_increase_by__works), - cmocka_unit_test(test__f_thread_lock_attributes_resize__works), - - cmocka_unit_test(test__f_thread_locks_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_locks_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_locks_increase__returns_data_not), - cmocka_unit_test(test__f_thread_locks_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_locks_adjust__works), - cmocka_unit_test(test__f_thread_locks_decimate_by__works), - cmocka_unit_test(test__f_thread_locks_decrease_by__works), - cmocka_unit_test(test__f_thread_locks_increase__works), - cmocka_unit_test(test__f_thread_locks_increase_by__works), - cmocka_unit_test(test__f_thread_locks_resize__works), - - cmocka_unit_test(test__f_thread_mutex_attributes_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_mutex_attributes_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_mutex_attributes_increase__returns_data_not), - cmocka_unit_test(test__f_thread_mutex_attributes_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_mutex_attributes_adjust__works), - cmocka_unit_test(test__f_thread_mutex_attributes_decimate_by__works), - cmocka_unit_test(test__f_thread_mutex_attributes_decrease_by__works), - cmocka_unit_test(test__f_thread_mutex_attributes_increase__works), - cmocka_unit_test(test__f_thread_mutex_attributes_increase_by__works), - cmocka_unit_test(test__f_thread_mutex_attributes_resize__works), - - cmocka_unit_test(test__f_thread_mutexs_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_mutexs_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_mutexs_increase__returns_data_not), - cmocka_unit_test(test__f_thread_mutexs_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_mutexs_adjust__works), - cmocka_unit_test(test__f_thread_mutexs_decimate_by__works), - cmocka_unit_test(test__f_thread_mutexs_decrease_by__works), - cmocka_unit_test(test__f_thread_mutexs_increase__works), - cmocka_unit_test(test__f_thread_mutexs_increase_by__works), - cmocka_unit_test(test__f_thread_mutexs_resize__works), - - cmocka_unit_test(test__f_thread_onces_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_onces_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_onces_increase__returns_data_not), - cmocka_unit_test(test__f_thread_onces_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_onces_adjust__works), - cmocka_unit_test(test__f_thread_onces_decimate_by__works), - cmocka_unit_test(test__f_thread_onces_decrease_by__works), - cmocka_unit_test(test__f_thread_onces_increase__works), - cmocka_unit_test(test__f_thread_onces_increase_by__works), - cmocka_unit_test(test__f_thread_onces_resize__works), - - cmocka_unit_test(test__f_thread_semaphores_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_semaphores_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_semaphores_increase__returns_data_not), - cmocka_unit_test(test__f_thread_semaphores_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_semaphores_adjust__works), - cmocka_unit_test(test__f_thread_semaphores_decimate_by__works), - cmocka_unit_test(test__f_thread_semaphores_decrease_by__works), - cmocka_unit_test(test__f_thread_semaphores_increase__works), - cmocka_unit_test(test__f_thread_semaphores_increase_by__works), - cmocka_unit_test(test__f_thread_semaphores_resize__works), - - cmocka_unit_test(test__f_thread_sets_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_sets_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_sets_increase__returns_data_not), - cmocka_unit_test(test__f_thread_sets_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_sets_adjust__works), - cmocka_unit_test(test__f_thread_sets_decimate_by__works), - cmocka_unit_test(test__f_thread_sets_decrease_by__works), - cmocka_unit_test(test__f_thread_sets_increase__works), - cmocka_unit_test(test__f_thread_sets_increase_by__works), - cmocka_unit_test(test__f_thread_sets_resize__works), - - cmocka_unit_test(test__f_thread_spins_decimate_by__returns_data_not), - cmocka_unit_test(test__f_thread_spins_decrease_by__returns_data_not), - cmocka_unit_test(test__f_thread_spins_increase__returns_data_not), - cmocka_unit_test(test__f_thread_spins_increase_by__returns_data_not), - - cmocka_unit_test(test__f_thread_spins_adjust__works), - cmocka_unit_test(test__f_thread_spins_decimate_by__works), - cmocka_unit_test(test__f_thread_spins_decrease_by__works), - cmocka_unit_test(test__f_thread_spins_increase__works), - cmocka_unit_test(test__f_thread_spins_increase_by__works), - cmocka_unit_test(test__f_thread_spins_resize__works), + cmocka_unit_test(test__f_thread_attributes_adjust_callback__fails), + cmocka_unit_test(test__f_thread_attributes_resize_callback__fails), + cmocka_unit_test(test__f_thread_attributes_adjust_callback__works), + cmocka_unit_test(test__f_thread_attributes_resize_callback__works), + + cmocka_unit_test(test__f_thread_barriers_adjust_callback__fails), + cmocka_unit_test(test__f_thread_barriers_resize_callback__fails), + cmocka_unit_test(test__f_thread_barriers_adjust_callback__works), + cmocka_unit_test(test__f_thread_barriers_resize_callback__works), + + cmocka_unit_test(test__f_thread_barrier_attributes_adjust_callback__fails), + cmocka_unit_test(test__f_thread_barrier_attributes_resize_callback__fails), + cmocka_unit_test(test__f_thread_barrier_attributes_adjust_callback__works), + cmocka_unit_test(test__f_thread_barrier_attributes_resize_callback__works), + + cmocka_unit_test(test__f_thread_conditions_adjust_callback__fails), + cmocka_unit_test(test__f_thread_conditions_resize_callback__fails), + cmocka_unit_test(test__f_thread_conditions_adjust_callback__works), + cmocka_unit_test(test__f_thread_conditions_resize_callback__works), + + cmocka_unit_test(test__f_thread_condition_attributes_adjust_callback__fails), + cmocka_unit_test(test__f_thread_condition_attributes_resize_callback__fails), + cmocka_unit_test(test__f_thread_condition_attributes_adjust_callback__works), + cmocka_unit_test(test__f_thread_condition_attributes_resize_callback__works), + + cmocka_unit_test(test__f_thread_keys_adjust_callback__fails), + cmocka_unit_test(test__f_thread_keys_resize_callback__fails), + cmocka_unit_test(test__f_thread_keys_adjust_callback__works), + cmocka_unit_test(test__f_thread_keys_resize_callback__works), + + cmocka_unit_test(test__f_thread_locks_adjust_callback__fails), + cmocka_unit_test(test__f_thread_locks_resize_callback__fails), + cmocka_unit_test(test__f_thread_locks_adjust_callback__works), + cmocka_unit_test(test__f_thread_locks_resize_callback__works), + + cmocka_unit_test(test__f_thread_lock_attributes_adjust_callback__fails), + cmocka_unit_test(test__f_thread_lock_attributes_resize_callback__fails), + cmocka_unit_test(test__f_thread_lock_attributes_adjust_callback__works), + cmocka_unit_test(test__f_thread_lock_attributes_resize_callback__works), + + cmocka_unit_test(test__f_thread_mutexs_adjust_callback__fails), + cmocka_unit_test(test__f_thread_mutexs_resize_callback__fails), + cmocka_unit_test(test__f_thread_mutexs_adjust_callback__works), + cmocka_unit_test(test__f_thread_mutexs_resize_callback__works), + + cmocka_unit_test(test__f_thread_mutex_attributes_adjust_callback__fails), + cmocka_unit_test(test__f_thread_mutex_attributes_resize_callback__fails), + cmocka_unit_test(test__f_thread_mutex_attributes_adjust_callback__works), + cmocka_unit_test(test__f_thread_mutex_attributes_resize_callback__works), + + cmocka_unit_test(test__f_thread_semaphores_adjust_callback__fails), + cmocka_unit_test(test__f_thread_semaphores_resize_callback__fails), + cmocka_unit_test(test__f_thread_semaphores_adjust_callback__works), + cmocka_unit_test(test__f_thread_semaphores_resize_callback__works), + + cmocka_unit_test(test__f_thread_sets_adjust_callback__fails), + cmocka_unit_test(test__f_thread_sets_resize_callback__fails), + cmocka_unit_test(test__f_thread_sets_adjust_callback__works), + cmocka_unit_test(test__f_thread_sets_resize_callback__works), + + cmocka_unit_test(test__f_thread_spins_adjust_callback__fails), + cmocka_unit_test(test__f_thread_spins_resize_callback__fails), + cmocka_unit_test(test__f_thread_spins_adjust_callback__works), + cmocka_unit_test(test__f_thread_spins_resize_callback__works), cmocka_unit_test(test__f_thread_at_fork__fails), cmocka_unit_test(test__f_thread_at_fork__works), @@ -522,110 +407,44 @@ int main(void) { cmocka_unit_test(test__f_thread_spin_unlock__works), #ifndef _di_level_0_parameter_checking_ - cmocka_unit_test(test__f_thread_attributes_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_attributes_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_attributes_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_attributes_increase__parameter_checking), - cmocka_unit_test(test__f_thread_attributes_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_attributes_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_barrier_attributes_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_barrier_attributes_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_barrier_attributes_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_barrier_attributes_increase__parameter_checking), - cmocka_unit_test(test__f_thread_barrier_attributes_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_barrier_attributes_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_barriers_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_barriers_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_barriers_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_barriers_increase__parameter_checking), - cmocka_unit_test(test__f_thread_barriers_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_barriers_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_condition_attributes_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_condition_attributes_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_condition_attributes_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_condition_attributes_increase__parameter_checking), - cmocka_unit_test(test__f_thread_condition_attributes_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_condition_attributes_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_conditions_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_conditions_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_conditions_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_conditions_increase__parameter_checking), - cmocka_unit_test(test__f_thread_conditions_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_conditions_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_ids_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_ids_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_ids_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_ids_increase__parameter_checking), - cmocka_unit_test(test__f_thread_ids_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_ids_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_keys_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_keys_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_keys_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_keys_increase__parameter_checking), - cmocka_unit_test(test__f_thread_keys_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_keys_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_lock_attributes_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_lock_attributes_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_lock_attributes_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_lock_attributes_increase__parameter_checking), - cmocka_unit_test(test__f_thread_lock_attributes_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_lock_attributes_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_locks_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_locks_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_locks_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_locks_increase__parameter_checking), - cmocka_unit_test(test__f_thread_locks_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_locks_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_mutex_attributes_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_mutex_attributes_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_mutex_attributes_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_mutex_attributes_increase__parameter_checking), - cmocka_unit_test(test__f_thread_mutex_attributes_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_mutex_attributes_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_mutexs_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_mutexs_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_mutexs_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_mutexs_increase__parameter_checking), - cmocka_unit_test(test__f_thread_mutexs_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_mutexs_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_onces_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_onces_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_onces_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_onces_increase__parameter_checking), - cmocka_unit_test(test__f_thread_onces_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_onces_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_semaphores_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_semaphores_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_semaphores_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_semaphores_increase__parameter_checking), - cmocka_unit_test(test__f_thread_semaphores_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_semaphores_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_sets_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_sets_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_sets_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_sets_increase__parameter_checking), - cmocka_unit_test(test__f_thread_sets_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_sets_resize__parameter_checking), - - cmocka_unit_test(test__f_thread_spins_adjust__parameter_checking), - cmocka_unit_test(test__f_thread_spins_decimate_by__parameter_checking), - cmocka_unit_test(test__f_thread_spins_decrease_by__parameter_checking), - cmocka_unit_test(test__f_thread_spins_increase__parameter_checking), - cmocka_unit_test(test__f_thread_spins_increase_by__parameter_checking), - cmocka_unit_test(test__f_thread_spins_resize__parameter_checking), + // f_thread_attributes_adjust_callback() doesn't use parameter checking. + // f_thread_attributes_resize_callback() doesn't use parameter checking. + + // f_thread_barriers_adjust_callback() doesn't use parameter checking. + // f_thread_barriers_resize_callback() doesn't use parameter checking. + + // f_thread_barrier_attributes_adjust_callback() doesn't use parameter checking. + // f_thread_barrier_attributes_resize_callback() doesn't use parameter checking. + + // f_thread_conditions_adjust_callback() doesn't use parameter checking. + // f_thread_conditions_resize_callback() doesn't use parameter checking. + + // f_thread_condition_attributes_adjust_callback() doesn't use parameter checking. + // f_thread_condition_attributes_resize_callback() doesn't use parameter checking. + + // f_thread_keys_adjust_callback() doesn't use parameter checking. + // f_thread_keys_resize_callback() doesn't use parameter checking. + + // f_thread_locks_adjust_callback() doesn't use parameter checking. + // f_thread_locks_resize_callback() doesn't use parameter checking. + + // f_thread_lock_attributes_adjust_callback() doesn't use parameter checking. + // f_thread_lock_attributes_resize_callback() doesn't use parameter checking. + + // f_thread_mutexs_adjust_callback() doesn't use parameter checking. + // f_thread_mutexs_resize_callback() doesn't use parameter checking. + + // f_thread_mutex_attributes_adjust_callback() doesn't use parameter checking. + // f_thread_mutex_attributes_resize_callback() doesn't use parameter checking. + + // f_thread_semaphores_adjust_callback() doesn't use parameter checking. + // f_thread_semaphores_resize_callback() doesn't use parameter checking. + + // f_thread_sets_adjust_callback() doesn't use parameter checking. + // f_thread_sets_resize_callback() doesn't use parameter checking. + + // f_thread_spins_adjust_callback() doesn't use parameter checking. + // f_thread_spins_resize_callback() doesn't use parameter checking. cmocka_unit_test(test__f_thread_at_fork__parameter_checking), diff --git a/level_0/f_thread/tests/unit/c/test-thread.h b/level_0/f_thread/tests/unit/c/test-thread.h index 90734eb..ed17025 100644 --- a/level_0/f_thread/tests/unit/c/test-thread.h +++ b/level_0/f_thread/tests/unit/c/test-thread.h @@ -27,96 +27,32 @@ #include "mock-thread.h" // Test includes. -#include "test-thread-attributes_adjust.h" -#include "test-thread-attributes_decimate_by.h" -#include "test-thread-attributes_decrease_by.h" -#include "test-thread-attributes_increase.h" -#include "test-thread-attributes_increase_by.h" -#include "test-thread-attributes_resize.h" -#include "test-thread-barriers_adjust.h" -#include "test-thread-barriers_decimate_by.h" -#include "test-thread-barriers_decrease_by.h" -#include "test-thread-barriers_increase.h" -#include "test-thread-barriers_increase_by.h" -#include "test-thread-barriers_resize.h" -#include "test-thread-barrier_attributes_adjust.h" -#include "test-thread-barrier_attributes_decimate_by.h" -#include "test-thread-barrier_attributes_decrease_by.h" -#include "test-thread-barrier_attributes_increase.h" -#include "test-thread-barrier_attributes_increase_by.h" -#include "test-thread-barrier_attributes_resize.h" -#include "test-thread-conditions_adjust.h" -#include "test-thread-conditions_decimate_by.h" -#include "test-thread-conditions_decrease_by.h" -#include "test-thread-conditions_increase.h" -#include "test-thread-conditions_increase_by.h" -#include "test-thread-conditions_resize.h" -#include "test-thread-condition_attributes_adjust.h" -#include "test-thread-condition_attributes_decimate_by.h" -#include "test-thread-condition_attributes_decrease_by.h" -#include "test-thread-condition_attributes_increase.h" -#include "test-thread-condition_attributes_increase_by.h" -#include "test-thread-condition_attributes_resize.h" -#include "test-thread-ids_adjust.h" -#include "test-thread-ids_decimate_by.h" -#include "test-thread-ids_decrease_by.h" -#include "test-thread-ids_increase.h" -#include "test-thread-ids_increase_by.h" -#include "test-thread-ids_resize.h" -#include "test-thread-keys_adjust.h" -#include "test-thread-keys_decimate_by.h" -#include "test-thread-keys_decrease_by.h" -#include "test-thread-keys_increase.h" -#include "test-thread-keys_increase_by.h" -#include "test-thread-keys_resize.h" -#include "test-thread-locks_adjust.h" -#include "test-thread-locks_decimate_by.h" -#include "test-thread-locks_decrease_by.h" -#include "test-thread-locks_increase.h" -#include "test-thread-locks_increase_by.h" -#include "test-thread-locks_resize.h" -#include "test-thread-lock_attributes_adjust.h" -#include "test-thread-lock_attributes_decimate_by.h" -#include "test-thread-lock_attributes_decrease_by.h" -#include "test-thread-lock_attributes_increase.h" -#include "test-thread-lock_attributes_increase_by.h" -#include "test-thread-lock_attributes_resize.h" -#include "test-thread-mutexs_adjust.h" -#include "test-thread-mutexs_decimate_by.h" -#include "test-thread-mutexs_decrease_by.h" -#include "test-thread-mutexs_increase.h" -#include "test-thread-mutexs_increase_by.h" -#include "test-thread-mutexs_resize.h" -#include "test-thread-mutex_attributes_adjust.h" -#include "test-thread-mutex_attributes_decimate_by.h" -#include "test-thread-mutex_attributes_decrease_by.h" -#include "test-thread-mutex_attributes_increase.h" -#include "test-thread-mutex_attributes_increase_by.h" -#include "test-thread-mutex_attributes_resize.h" -#include "test-thread-onces_adjust.h" -#include "test-thread-onces_decimate_by.h" -#include "test-thread-onces_decrease_by.h" -#include "test-thread-onces_increase.h" -#include "test-thread-onces_increase_by.h" -#include "test-thread-onces_resize.h" -#include "test-thread-semaphores_adjust.h" -#include "test-thread-semaphores_decimate_by.h" -#include "test-thread-semaphores_decrease_by.h" -#include "test-thread-semaphores_increase.h" -#include "test-thread-semaphores_increase_by.h" -#include "test-thread-semaphores_resize.h" -#include "test-thread-sets_adjust.h" -#include "test-thread-sets_decimate_by.h" -#include "test-thread-sets_decrease_by.h" -#include "test-thread-sets_increase.h" -#include "test-thread-sets_increase_by.h" -#include "test-thread-sets_resize.h" -#include "test-thread-spins_adjust.h" -#include "test-thread-spins_decimate_by.h" -#include "test-thread-spins_decrease_by.h" -#include "test-thread-spins_increase.h" -#include "test-thread-spins_increase_by.h" -#include "test-thread-spins_resize.h" +#include "test-thread-attributes_adjust_callback.h" +#include "test-thread-attributes_resize_callback.h" +#include "test-thread-barriers_adjust_callback.h" +#include "test-thread-barriers_resize_callback.h" +#include "test-thread-barrier_attributes_adjust_callback.h" +#include "test-thread-barrier_attributes_resize_callback.h" +#include "test-thread-conditions_adjust_callback.h" +#include "test-thread-conditions_resize_callback.h" +#include "test-thread-condition_attributes_adjust_callback.h" +#include "test-thread-condition_attributes_resize_callback.h" +#include "test-thread-keys_adjust_callback.h" +#include "test-thread-keys_resize_callback.h" +#include "test-thread-locks_adjust_callback.h" +#include "test-thread-locks_resize_callback.h" +#include "test-thread-lock_attributes_adjust_callback.h" +#include "test-thread-lock_attributes_resize_callback.h" +#include "test-thread-mutexs_adjust_callback.h" +#include "test-thread-mutexs_resize_callback.h" +#include "test-thread-mutex_attributes_adjust_callback.h" +#include "test-thread-mutex_attributes_resize_callback.h" +#include "test-thread-semaphores_adjust_callback.h" +#include "test-thread-semaphores_resize_callback.h" +#include "test-thread-sets_adjust_callback.h" +#include "test-thread-sets_resize_callback.h" +#include "test-thread-spins_adjust_callback.h" +#include "test-thread-spins_resize_callback.h" #include "test-thread-at_fork.h" #include "test-thread-attribute_affinity_get.h" diff --git a/level_0/f_type_array/c/type_array/cell.c b/level_0/f_type_array/c/type_array/cell.c index e9f6edc..b3752ef 100644 --- a/level_0/f_type_array/c/type_array/cell.c +++ b/level_0/f_type_array/c/type_array/cell.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_cells_adjust_callback_ - f_status_t f_cells_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_cells_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_cells_t * const array = (f_cells_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_cell_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_cells_adjust_callback_ #ifndef _di_f_cells_resize_callback_ - f_status_t f_cells_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_cells_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_cells_t * const array = (f_cells_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_cell_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/cell.h b/level_0/f_type_array/c/type_array/cell.h index 78ec658..5c4b5e1 100644 --- a/level_0/f_type_array/c/type_array/cell.h +++ b/level_0/f_type_array/c/type_array/cell.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_cells_adjust_callback_ - extern f_status_t f_cells_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_cells_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_cells_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_cells_resize_callback_ - extern f_status_t f_cells_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_cells_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_cells_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/file.c b/level_0/f_type_array/c/type_array/file.c index cfa1ae8..39a1d9e 100644 --- a/level_0/f_type_array/c/type_array/file.c +++ b/level_0/f_type_array/c/type_array/file.c @@ -7,13 +7,13 @@ extern "C" { #endif #ifndef _di_f_files_adjust_callback_ - f_status_t f_files_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_files_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_files_t * const array = (f_files_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_file_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -25,13 +25,13 @@ extern "C" { #endif // _di_f_files_adjust_callback_ #ifndef _di_f_files_resize_callback_ - f_status_t f_files_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_files_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_files_t * const array = (f_files_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_file_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/file.h b/level_0/f_type_array/c/type_array/file.h index aa0a9b4..4c18383 100644 --- a/level_0/f_type_array/c/type_array/file.h +++ b/level_0/f_type_array/c/type_array/file.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_files_adjust_callback_ - extern f_status_t f_files_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_files_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_files_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_files_resize_callback_ - extern f_status_t f_files_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_files_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_files_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/fll_id.c b/level_0/f_type_array/c/type_array/fll_id.c index 1440c80..d19777a 100644 --- a/level_0/f_type_array/c/type_array/fll_id.c +++ b/level_0/f_type_array/c/type_array/fll_id.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_fll_ids_adjust_callback_ - f_status_t f_fll_ids_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_fll_ids_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_fll_ids_t * const array = (f_fll_ids_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_fll_id_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_fll_ids_adjust_callback_ #ifndef _di_f_fll_ids_resize_callback_ - f_status_t f_fll_ids_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_fll_ids_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_fll_ids_t * const array = (f_fll_ids_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_fll_id_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/fll_id.h b/level_0/f_type_array/c/type_array/fll_id.h index 09bea22..35b85b3 100644 --- a/level_0/f_type_array/c/type_array/fll_id.h +++ b/level_0/f_type_array/c/type_array/fll_id.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_fll_ids_adjust_callback_ - extern f_status_t f_fll_ids_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_fll_ids_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_fll_ids_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_fll_ids_resize_callback_ - extern f_status_t f_fll_ids_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_fll_ids_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_fll_ids_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int128.c b/level_0/f_type_array/c/type_array/int128.c index a3416b5..9dcaa40 100644 --- a/level_0/f_type_array/c/type_array/int128.c +++ b/level_0/f_type_array/c/type_array/int128.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_int128s_adjust_callback_ - f_status_t f_int128s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int128s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int128s_t * const array = (f_int128s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_int128_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_int128s_adjust_callback_ #ifndef _di_f_int128s_resize_callback_ - f_status_t f_int128s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int128s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int128s_t * const array = (f_int128s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_int128_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/int128.h b/level_0/f_type_array/c/type_array/int128.h index e0122eb..a2a714d 100644 --- a/level_0/f_type_array/c/type_array/int128.h +++ b/level_0/f_type_array/c/type_array/int128.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_int128s_adjust_callback_ - extern f_status_t f_int128s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int128s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int128s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_int128s_resize_callback_ - extern f_status_t f_int128s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int128s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int128s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int16.c b/level_0/f_type_array/c/type_array/int16.c index 446baf3..224c8a0 100644 --- a/level_0/f_type_array/c/type_array/int16.c +++ b/level_0/f_type_array/c/type_array/int16.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_int16s_adjust_callback_ - f_status_t f_int16s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int16s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int16s_t * const array = (f_int16s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(int16_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_int16s_adjust_callback_ #ifndef _di_f_int16s_resize_callback_ - f_status_t f_int16s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int16s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int16s_t * const array = (f_int16s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(int16_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/int16.h b/level_0/f_type_array/c/type_array/int16.h index bccde67..cb6a90b 100644 --- a/level_0/f_type_array/c/type_array/int16.h +++ b/level_0/f_type_array/c/type_array/int16.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_int16s_adjust_callback_ - extern f_status_t f_int16s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int16s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int16s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_int16s_resize_callback_ - extern f_status_t f_int16s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int16s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int16s_resize_callback_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_type_array/c/type_array/int32.c b/level_0/f_type_array/c/type_array/int32.c index 4561c61..bdbd6ae 100644 --- a/level_0/f_type_array/c/type_array/int32.c +++ b/level_0/f_type_array/c/type_array/int32.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_int32s_adjust_callback_ - f_status_t f_int32s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int32s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int32s_t * const array = (f_int32s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(int32_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_int32s_adjust_callback_ #ifndef _di_f_int32s_resize_callback_ - f_status_t f_int32s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int32s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int32s_t * const array = (f_int32s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(int32_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/int32.h b/level_0/f_type_array/c/type_array/int32.h index 2cc3699..0fb6de6 100644 --- a/level_0/f_type_array/c/type_array/int32.h +++ b/level_0/f_type_array/c/type_array/int32.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_int32s_adjust_callback_ - extern f_status_t f_int32s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int32s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int32s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_int32s_resize_callback_ - extern f_status_t f_int32s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int32s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int32s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int64.c b/level_0/f_type_array/c/type_array/int64.c index 358375c..2cb85dd 100644 --- a/level_0/f_type_array/c/type_array/int64.c +++ b/level_0/f_type_array/c/type_array/int64.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_int64s_adjust_callback_ - f_status_t f_int64s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int64s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int64s_t * const array = (f_int64s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(int64_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_int64s_adjust_callback_ #ifndef _di_f_int64s_resize_callback_ - f_status_t f_int64s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int64s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int64s_t * const array = (f_int64s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(int64_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/int64.h b/level_0/f_type_array/c/type_array/int64.h index 87b9b8f..6cb81c0 100644 --- a/level_0/f_type_array/c/type_array/int64.h +++ b/level_0/f_type_array/c/type_array/int64.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_int64s_adjust_callback_ - extern f_status_t f_int64s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int64s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int64s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_int64s_resize_callback_ - extern f_status_t f_int64s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int64s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int64s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/int8.c b/level_0/f_type_array/c/type_array/int8.c index e362f13..44f1479 100644 --- a/level_0/f_type_array/c/type_array/int8.c +++ b/level_0/f_type_array/c/type_array/int8.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_int8s_adjust_callback_ - f_status_t f_int8s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int8s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int8s_t * const array = (f_int8s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(int8_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_int8s_adjust_callback_ #ifndef _di_f_int8s_resize_callback_ - f_status_t f_int8s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_int8s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_int8s_t * const array = (f_int8s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(int8_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/int8.h b/level_0/f_type_array/c/type_array/int8.h index fc6f0ab..6478f18 100644 --- a/level_0/f_type_array/c/type_array/int8.h +++ b/level_0/f_type_array/c/type_array/int8.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_int8s_adjust_callback_ - extern f_status_t f_int8s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int8s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int8s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_int8s_resize_callback_ - extern f_status_t f_int8s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_int8s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_int8s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/number_unsigned.c b/level_0/f_type_array/c/type_array/number_unsigned.c index 966a6cf..80207ee 100644 --- a/level_0/f_type_array/c/type_array/number_unsigned.c +++ b/level_0/f_type_array/c/type_array/number_unsigned.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_number_unsigneds_adjust_callback_ - f_status_t f_number_unsigneds_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_number_unsigneds_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_number_unsigneds_t * const array = (f_number_unsigneds_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_number_unsigned_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_number_unsigneds_adjust_callback_ #ifndef _di_f_number_unsigneds_resize_callback_ - f_status_t f_number_unsigneds_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_number_unsigneds_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_number_unsigneds_t * const array = (f_number_unsigneds_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_number_unsigned_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/number_unsigned.h b/level_0/f_type_array/c/type_array/number_unsigned.h index 99ac11e..b480f37 100644 --- a/level_0/f_type_array/c/type_array/number_unsigned.h +++ b/level_0/f_type_array/c/type_array/number_unsigned.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_number_unsigneds_adjust_callback_ - extern f_status_t f_number_unsigneds_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_number_unsigneds_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_number_unsigneds_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_number_unsigneds_resize_callback_ - extern f_status_t f_number_unsigneds_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_number_unsigneds_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_number_unsigneds_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/poll.c b/level_0/f_type_array/c/type_array/poll.c index 756bdaa..356bdd1 100644 --- a/level_0/f_type_array/c/type_array/poll.c +++ b/level_0/f_type_array/c/type_array/poll.c @@ -7,13 +7,13 @@ extern "C" { #endif #ifndef _di_f_polls_adjust_callback_ - f_status_t f_polls_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_polls_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_polls_t * const array = (f_polls_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_poll_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -25,13 +25,13 @@ extern "C" { #endif // _di_f_polls_adjust_callback_ #ifndef _di_f_polls_resize_callback_ - f_status_t f_polls_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_polls_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_polls_t * const array = (f_polls_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_poll_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/poll.h b/level_0/f_type_array/c/type_array/poll.h index bf2d72c..cf65de3 100644 --- a/level_0/f_type_array/c/type_array/poll.h +++ b/level_0/f_type_array/c/type_array/poll.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_polls_adjust_callback_ - extern f_status_t f_polls_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_polls_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_polls_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_polls_resize_callback_ - extern f_status_t f_polls_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_polls_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_polls_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/state.c b/level_0/f_type_array/c/type_array/state.c index eee580c..238116b 100644 --- a/level_0/f_type_array/c/type_array/state.c +++ b/level_0/f_type_array/c/type_array/state.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_states_adjust_callback_ - f_status_t f_states_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_states_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_states_t * const array = (f_states_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_state_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_states_adjust_callback_ #ifndef _di_f_states_resize_callback_ - f_status_t f_states_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_states_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_states_t * const array = (f_states_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_state_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/state.h b/level_0/f_type_array/c/type_array/state.h index 061b05f..9bde006 100644 --- a/level_0/f_type_array/c/type_array/state.h +++ b/level_0/f_type_array/c/type_array/state.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_states_adjust_callback_ - extern f_status_t f_states_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_states_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_states_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_states_resize_callback_ - extern f_status_t f_states_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_states_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_states_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/status.c b/level_0/f_type_array/c/type_array/status.c index c64c2cd..eb5ad0d 100644 --- a/level_0/f_type_array/c/type_array/status.c +++ b/level_0/f_type_array/c/type_array/status.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_statuss_adjust_callback_ - f_status_t f_statuss_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_statuss_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_statuss_t * const array = (f_statuss_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_status_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_statuss_adjust_callback_ #ifndef _di_f_statuss_resize_callback_ - f_status_t f_statuss_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_statuss_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_statuss_t * const array = (f_statuss_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_status_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/status.h b/level_0/f_type_array/c/type_array/status.h index dbbb40f..8f4ab6a 100644 --- a/level_0/f_type_array/c/type_array/status.h +++ b/level_0/f_type_array/c/type_array/status.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_statuss_adjust_callback_ - extern f_status_t f_statuss_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_statuss_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_statuss_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_statuss_resize_callback_ - extern f_status_t f_statuss_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_statuss_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_statuss_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint128.c b/level_0/f_type_array/c/type_array/uint128.c index d24084d..3aa63bb 100644 --- a/level_0/f_type_array/c/type_array/uint128.c +++ b/level_0/f_type_array/c/type_array/uint128.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_uint128s_adjust_callback_ - f_status_t f_uint128s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint128s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint128s_t * const array = (f_uint128s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(f_uint128_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_uint128s_adjust_callback_ #ifndef _di_f_uint128s_resize_callback_ - f_status_t f_uint128s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint128s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint128s_t * const array = (f_uint128s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(f_uint128_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/uint128.h b/level_0/f_type_array/c/type_array/uint128.h index a46b8be..f3c9a0d 100644 --- a/level_0/f_type_array/c/type_array/uint128.h +++ b/level_0/f_type_array/c/type_array/uint128.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_uint128s_adjust_callback_ - extern f_status_t f_uint128s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint128s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint128s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_uint128s_resize_callback_ - extern f_status_t f_uint128s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint128s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint128s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint16.c b/level_0/f_type_array/c/type_array/uint16.c index 076ba67..4775275 100644 --- a/level_0/f_type_array/c/type_array/uint16.c +++ b/level_0/f_type_array/c/type_array/uint16.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_uint16s_adjust_callback_ - f_status_t f_uint16s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint16s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint16s_t * const array = (f_uint16s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(uint16_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_uint16s_adjust_callback_ #ifndef _di_f_uint16s_resize_callback_ - f_status_t f_uint16s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint16s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint16s_t * const array = (f_uint16s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(uint16_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/uint16.h b/level_0/f_type_array/c/type_array/uint16.h index c110cac..b8f952e 100644 --- a/level_0/f_type_array/c/type_array/uint16.h +++ b/level_0/f_type_array/c/type_array/uint16.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_uint16s_adjust_callback_ - extern f_status_t f_uint16s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint16s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint16s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_uint16s_resize_callback_ - extern f_status_t f_uint16s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint16s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint16s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint32.c b/level_0/f_type_array/c/type_array/uint32.c index 25de94b..4a76c45 100644 --- a/level_0/f_type_array/c/type_array/uint32.c +++ b/level_0/f_type_array/c/type_array/uint32.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_uint32s_adjust_callback_ - f_status_t f_uint32s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint32s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint32s_t * const array = (f_uint32s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(uint32_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_uint32s_adjust_callback_ #ifndef _di_f_uint32s_resize_callback_ - f_status_t f_uint32s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint32s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint32s_t * const array = (f_uint32s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(uint32_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/uint32.h b/level_0/f_type_array/c/type_array/uint32.h index 4f3e54e..59f889d 100644 --- a/level_0/f_type_array/c/type_array/uint32.h +++ b/level_0/f_type_array/c/type_array/uint32.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_uint32s_adjust_callback_ - extern f_status_t f_uint32s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint32s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint32s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_uint32s_resize_callback_ - extern f_status_t f_uint32s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint32s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint32s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint64.c b/level_0/f_type_array/c/type_array/uint64.c index cc436cb..d3ca294 100644 --- a/level_0/f_type_array/c/type_array/uint64.c +++ b/level_0/f_type_array/c/type_array/uint64.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_uint64s_adjust_callback_ - f_status_t f_uint64s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint64s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint64s_t * const array = (f_uint64s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(uint64_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_uint64s_adjust_callback_ #ifndef _di_f_uint64s_resize_callback_ - f_status_t f_uint64s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint64s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint64s_t * const array = (f_uint64s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(uint64_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/uint64.h b/level_0/f_type_array/c/type_array/uint64.h index 5d59fff..e3fcfeb 100644 --- a/level_0/f_type_array/c/type_array/uint64.h +++ b/level_0/f_type_array/c/type_array/uint64.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_uint64s_adjust_callback_ - extern f_status_t f_uint64s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint64s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint64s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_uint64s_resize_callback_ - extern f_status_t f_uint64s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint64s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint64s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/c/type_array/uint8.c b/level_0/f_type_array/c/type_array/uint8.c index eed0283..c10f751 100644 --- a/level_0/f_type_array/c/type_array/uint8.c +++ b/level_0/f_type_array/c/type_array/uint8.c @@ -6,13 +6,13 @@ extern "C" { #endif #ifndef _di_f_uint8s_adjust_callback_ - f_status_t f_uint8s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint8s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint8s_t * const array = (f_uint8s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_adjust(0, sizeof(uint8_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; @@ -24,13 +24,13 @@ extern "C" { #endif // _di_f_uint8s_adjust_callback_ #ifndef _di_f_uint8s_resize_callback_ - f_status_t f_uint8s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const void_array) { + f_status_t f_uint8s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const void_array) { { f_uint8s_t * const array = (f_uint8s_t *) void_array; f_status_t status = F_none; - for (f_number_unsigned_t i = start; i < size; ++i) { + for (f_number_unsigned_t i = start; i < stop; ++i) { status = f_memory_array_resize(0, sizeof(uint8_t), (void **) &array[i].array, &array[i].used, &array[i].size); if (F_status_is_error(status)) return status; diff --git a/level_0/f_type_array/c/type_array/uint8.h b/level_0/f_type_array/c/type_array/uint8.h index 9ecab86..c786cf7 100644 --- a/level_0/f_type_array/c/type_array/uint8.h +++ b/level_0/f_type_array/c/type_array/uint8.h @@ -22,9 +22,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -40,7 +40,7 @@ extern "C" { * @see f_memory_arrays_adjust() */ #ifndef _di_f_uint8s_adjust_callback_ - extern f_status_t f_uint8s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint8s_adjust_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint8s_adjust_callback_ /** @@ -49,9 +49,9 @@ extern "C" { * This does not do parameter checking. * * @param start - * The start position in the array to start deleting. + * The inclusive start position in the array to start deleting. * @param stop - * The stop in the array to stop deleting. + * The exclusive stop position in the array to stop deleting. * @param array * The array structure to delete all values of. * Must not be NULL. @@ -67,7 +67,7 @@ extern "C" { * @see f_memory_arrays_resize() */ #ifndef _di_f_uint8s_resize_callback_ - extern f_status_t f_uint8s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t size, void * const array); + extern f_status_t f_uint8s_resize_callback(const f_number_unsigned_t start, const f_number_unsigned_t stop, void * const array); #endif // _di_f_uint8s_resize_callback_ #ifdef __cplusplus diff --git a/level_0/f_type_array/tests/unit/c/mock-type_array.c b/level_0/f_type_array/tests/unit/c/mock-type_array.c index 771cdc3..02f61f7 100644 --- a/level_0/f_type_array/tests/unit/c/mock-type_array.c +++ b/level_0/f_type_array/tests/unit/c/mock-type_array.c @@ -4,21 +4,6 @@ extern "C" { #endif -int __wrap_poll(f_poll_t *fds, nfds_t nfds, int timeout) { - - const bool failure = mock_type(bool); - - if (failure) { - errno = mock_type(int); - - return -1; - } - - fds->revents = mock_type(short); - - return mock_type(int); -} - f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size) { if (!array || !used || !size) return F_status_set_error(F_parameter_not); @@ -45,6 +30,21 @@ f_status_t __wrap_f_memory_array_resize(const f_number_unsigned_t length, const return mock_type(f_status_t); } +int __wrap_poll(f_poll_t *fds, nfds_t nfds, int timeout) { + + const bool failure = mock_type(bool); + + if (failure) { + errno = mock_type(int); + + return -1; + } + + fds->revents = mock_type(short); + + return mock_type(int); +} + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type_array/tests/unit/c/mock-type_array.h b/level_0/f_type_array/tests/unit/c/mock-type_array.h index c903920..92441e0 100644 --- a/level_0/f_type_array/tests/unit/c/mock-type_array.h +++ b/level_0/f_type_array/tests/unit/c/mock-type_array.h @@ -30,9 +30,9 @@ extern "C" { const static int mock_errno_generic = 32767; -extern int __wrap_poll(f_poll_t *fds, nfds_t nfds, int timeout); extern f_status_t __wrap_f_memory_array_adjust(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); extern f_status_t __wrap_f_memory_array_resizze(const f_number_unsigned_t length, const size_t width, void ** array, f_number_unsigned_t * const used, f_number_unsigned_t * const size); +extern int __wrap_poll(f_poll_t *fds, nfds_t nfds, int timeout); #ifdef __cplusplus } // extern "C" -- 1.8.3.1