]> Kevux Git Server - fll/commitdiff
Update: Add F_lock_spin and F_lock_spin_not to status codes.
authorKevin Day <Kevin@kevux.org>
Sat, 13 Jul 2024 05:13:54 +0000 (00:13 -0500)
committerKevin Day <Kevin@kevux.org>
Sat, 13 Jul 2024 05:13:54 +0000 (00:13 -0500)
I overlooked spin locks when I added the mutex and the read and write lock status codes.

level_0/f_status/c/status.h
level_0/f_status_string/c/status_string.c
level_0/f_status_string/c/status_string.h
level_0/f_status_string/tests/unit/c/test-status_string-to.c
level_0/f_thread/c/thread.c
level_0/f_thread/c/thread.h
level_1/fl_status_string/c/status_string.c
level_1/fl_status_string/tests/unit/c/test-status_string-from.c

index 4f023e3fcf52b13ff882fd57bea13cf774b23b65..e8a37c45600a8d1066e6e5e12667342f701e4d1b 100644 (file)
@@ -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,
index ca210ffeb7a074cdfe42666b907c748923807bf3..b69b10091c633f052bcae03fcc1f49ce5ccd5833 100644 (file)
@@ -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;
 
index 4d82018414f6b6114c548c45cdead9cf66d14589..9dbf5b831e9ac0ef23b962a0b7e57cf0efb54619 100644 (file)
@@ -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;
index 69bb7adee40d04fe26c361f477d13b93b58f3a3c..194b0f484c5768b907c5b16761d58af7a8a654d7 100644 (file)
@@ -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;
 
index a680544e9b5a856b95f46c653cac15c0f46a3cd4..2a9a6c261d96b7309efb877985c42de1dd790f88 100644 (file)
@@ -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);
 
index 3cb1cca090feff84d3acaa4614df0b52a9c5eb8c..9ccc0dc777c7b658b28007530aba6058fe7328ce 100644 (file)
@@ -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.
  *
index feef49fee190bffa5b5672d3e14e1f31ec6bc852..4756c2b733ec5f2099a7c1bb230266f679e55eb5 100644 (file)
@@ -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;
 
index 3b6a224b9eae50ac3802aa81c0933e5b6ecfe2e0..ad0cd4074392484d0cadedfaae9591a177d6cd69 100644 (file)
@@ -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,