From a6da8cbf0fb4ba6fd9480bec01496a0e21a5fcdb Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 13 Jul 2024 00:13:54 -0500 Subject: [PATCH] Update: Add F_lock_spin and F_lock_spin_not to status codes. I overlooked spin locks when I added the mutex and the read and write lock status codes. --- level_0/f_status/c/status.h | 2 ++ level_0/f_status_string/c/status_string.c | 12 ++++++++++++ level_0/f_status_string/c/status_string.h | 6 ++++++ level_0/f_status_string/tests/unit/c/test-status_string-to.c | 6 +++++- level_0/f_thread/c/thread.c | 2 -- level_0/f_thread/c/thread.h | 1 - level_1/fl_status_string/c/status_string.c | 12 ++++++++++++ .../fl_status_string/tests/unit/c/test-status_string-from.c | 4 ++++ 8 files changed, 41 insertions(+), 4 deletions(-) diff --git a/level_0/f_status/c/status.h b/level_0/f_status/c/status.h index 4f023e3..e8a37c4 100644 --- a/level_0/f_status/c/status.h +++ b/level_0/f_status/c/status.h @@ -368,6 +368,8 @@ extern "C" { F_lock_not, F_lock_read, F_lock_read_not, + F_lock_spin, + F_lock_spin_not, F_lock_write, F_lock_write_not, F_loop, diff --git a/level_0/f_status_string/c/status_string.c b/level_0/f_status_string/c/status_string.c index ca210ff..b69b100 100644 --- a/level_0/f_status_string/c/status_string.c +++ b/level_0/f_status_string/c/status_string.c @@ -236,6 +236,8 @@ extern "C" { const f_string_static_t f_status_lock_not_s = macro_f_string_static_t_initialize_1(F_status_lock_not_s, 0, F_status_lock_not_s_length); const f_string_static_t f_status_lock_read_s = macro_f_string_static_t_initialize_1(F_status_lock_read_s, 0, F_status_lock_read_s_length); const f_string_static_t f_status_lock_read_not_s = macro_f_string_static_t_initialize_1(F_status_lock_read_not_s, 0, F_status_lock_read_not_s_length); + const f_string_static_t f_status_lock_spin_s = macro_f_string_static_t_initialize_1(F_status_lock_spin_s, 0, F_status_lock_spin_s_length); + const f_string_static_t f_status_lock_spin_not_s = macro_f_string_static_t_initialize_1(F_status_lock_spin_not_s, 0, F_status_lock_spin_not_s_length); const f_string_static_t f_status_lock_write_s = macro_f_string_static_t_initialize_1(F_status_lock_write_s, 0, F_status_lock_write_s_length); const f_string_static_t f_status_lock_write_not_s = macro_f_string_static_t_initialize_1(F_status_lock_write_not_s, 0, F_status_lock_write_not_s_length); const f_string_static_t f_status_loop_s = macro_f_string_static_t_initialize_1(F_status_loop_s, 0, F_status_loop_s_length); @@ -1849,6 +1851,16 @@ extern "C" { break; + case F_lock_spin: + *name = f_status_lock_spin_s; + + break; + + case F_lock_spin_not: + *name = f_status_lock_spin_not_s; + + break; + case F_lock_write: *name = f_status_lock_write_s; diff --git a/level_0/f_status_string/c/status_string.h b/level_0/f_status_string/c/status_string.h index 4d82018..9dbf5b8 100644 --- a/level_0/f_status_string/c/status_string.h +++ b/level_0/f_status_string/c/status_string.h @@ -396,6 +396,8 @@ extern "C" { #define F_status_lock_not_s "F_lock_not" #define F_status_lock_read_s "F_lock_read" #define F_status_lock_read_not_s "F_lock_read_not" + #define F_status_lock_spin_s "F_lock_spin" + #define F_status_lock_spin_not_s "F_lock_spin_not" #define F_status_lock_write_s "F_lock_write" #define F_status_lock_write_not_s "F_lock_write_not" #define F_status_loop_s "F_loop" @@ -738,6 +740,8 @@ extern "C" { #define F_status_lock_not_s_length 10 #define F_status_lock_read_s_length 11 #define F_status_lock_read_not_s_length 15 + #define F_status_lock_spin_s_length 11 + #define F_status_lock_spin_not_s_length 15 #define F_status_lock_write_s_length 12 #define F_status_lock_write_not_s_length 16 #define F_status_loop_s_length 6 @@ -1082,6 +1086,8 @@ extern "C" { extern const f_string_static_t f_status_lock_not_s; extern const f_string_static_t f_status_lock_read_s; extern const f_string_static_t f_status_lock_read_not_s; + extern const f_string_static_t f_status_lock_spin_s; + extern const f_string_static_t f_status_lock_spin_not_s; extern const f_string_static_t f_status_lock_write_s; extern const f_string_static_t f_status_lock_write_not_s; extern const f_string_static_t f_status_loop_s; diff --git a/level_0/f_status_string/tests/unit/c/test-status_string-to.c b/level_0/f_status_string/tests/unit/c/test-status_string-to.c index 69bb7ad..194b0f4 100644 --- a/level_0/f_status_string/tests/unit/c/test-status_string-to.c +++ b/level_0/f_status_string/tests/unit/c/test-status_string-to.c @@ -262,6 +262,8 @@ void test__f_status_string_to__works(void **state) { F_lock_not, F_lock_read, F_lock_read_not, + F_lock_spin, + F_lock_spin_not, F_lock_write, F_lock_write_not, F_loop, @@ -909,6 +911,8 @@ void test__f_status_string_to__works(void **state) { f_status_lock_not_s, f_status_lock_read_s, f_status_lock_read_not_s, + f_status_lock_spin_s, + f_status_lock_spin_not_s, f_status_lock_write_s, f_status_lock_write_not_s, f_status_loop_s, @@ -1323,7 +1327,7 @@ void test__f_status_string_to__works(void **state) { f_status_status_code_last_s, }; - for (uint16_t i = 0; i < 644; ++i) { + for (uint16_t i = 0; i < 646; ++i) { f_string_static_t result = f_string_static_t_initialize; diff --git a/level_0/f_thread/c/thread.c b/level_0/f_thread/c/thread.c index a680544..2a9a6c2 100644 --- a/level_0/f_thread/c/thread.c +++ b/level_0/f_thread/c/thread.c @@ -1711,8 +1711,6 @@ extern "C" { const int error = pthread_mutex_unlock(mutex); if (error) { - if (error == EAGAIN) return F_status_set_error(F_resource_not); - if (error == EBUSY) return F_status_set_error(F_busy); if (error == EINVAL) return F_status_set_error(F_parameter); if (error == EPERM) return F_status_set_error(F_prohibited); diff --git a/level_0/f_thread/c/thread.h b/level_0/f_thread/c/thread.h index 3cb1cca..9ccc0dc 100644 --- a/level_0/f_thread/c/thread.h +++ b/level_0/f_thread/c/thread.h @@ -2187,7 +2187,6 @@ extern "C" { * * F_parameter (with error bit) if a parameter is invalid. * F_prohibited (with error bit) if not allowed to perform the operation (possibly because mutex is not owned by current thread). - * F_resource_not (with error bit) if max mutex locks is reached. * * F_failure (with error bit) on any other error. * diff --git a/level_1/fl_status_string/c/status_string.c b/level_1/fl_status_string/c/status_string.c index feef49f..4756c2b 100644 --- a/level_1/fl_status_string/c/status_string.c +++ b/level_1/fl_status_string/c/status_string.c @@ -1413,6 +1413,18 @@ extern "C" { return F_okay; } + if (f_compare_dynamic(name, f_status_lock_spin_s) == F_equal_to) { + *code = F_lock_spin; + + return F_okay; + } + + if (f_compare_dynamic(name, f_status_lock_spin_not_s) == F_equal_to) { + *code = F_lock_spin_not; + + return F_okay; + } + if (f_compare_dynamic(name, f_status_lock_write_s) == F_equal_to) { *code = F_lock_write; diff --git a/level_1/fl_status_string/tests/unit/c/test-status_string-from.c b/level_1/fl_status_string/tests/unit/c/test-status_string-from.c index 3b6a224..ad0cd40 100644 --- a/level_1/fl_status_string/tests/unit/c/test-status_string-from.c +++ b/level_1/fl_status_string/tests/unit/c/test-status_string-from.c @@ -278,6 +278,8 @@ void test__fl_status_string_from__works(void **state) { F_lock_not, F_lock_read, F_lock_read_not, + F_lock_spin, + F_lock_spin_not, F_lock_write, F_lock_write_not, F_loop, @@ -925,6 +927,8 @@ void test__fl_status_string_from__works(void **state) { f_status_lock_not_s, f_status_lock_read_s, f_status_lock_read_not_s, + f_status_lock_spin_s, + f_status_lock_spin_not_s, f_status_lock_write_s, f_status_lock_write_not_s, f_status_loop_s, -- 1.8.3.1