Define `_di_f_thread_mutex_attribute_d_` such that the mutex attributes like `PTHREAD_MUTEX_NORMAL` have a mapped define.
The mutex lock and try lock are no longer missing the handling of `ENOTRECOVERABLE` and `EOWNERDEAD` errors.
#define _di_f_thread_mutex_attribute_protocol_set_
#define _di_f_thread_mutex_attribute_shared_get_
#define _di_f_thread_mutex_attribute_shared_set_
+#define _di_f_thread_mutex_attribute_d_
#define _di_f_thread_mutex_attribute_t_
#define _di_f_thread_mutex_attribute_type_get_
#define _di_f_thread_mutex_attribute_type_set_
#define _di_f_thread_mutex_attribute_protocol_set_
#define _di_f_thread_mutex_attribute_shared_get_
#define _di_f_thread_mutex_attribute_shared_set_
+#define _di_f_thread_mutex_attribute_d_
#define _di_f_thread_mutex_attribute_t_
#define _di_f_thread_mutex_attribute_type_get_
#define _di_f_thread_mutex_attribute_type_set_
#define _di_f_thread_mutex_attribute_protocol_set_
#define _di_f_thread_mutex_attribute_shared_get_
#define _di_f_thread_mutex_attribute_shared_set_
+#define _di_f_thread_mutex_attribute_d_
#define _di_f_thread_mutex_attribute_t_
#define _di_f_thread_mutex_attribute_type_get_
#define _di_f_thread_mutex_attribute_type_set_
#define _di_f_thread_mutex_attribute_protocol_set_
#define _di_f_thread_mutex_attribute_shared_get_
#define _di_f_thread_mutex_attribute_shared_set_
+#define _di_f_thread_mutex_attribute_d_
#define _di_f_thread_mutex_attribute_t_
#define _di_f_thread_mutex_attribute_type_get_
#define _di_f_thread_mutex_attribute_type_set_
#define _di_f_thread_mutex_attribute_protocol_set_
#define _di_f_thread_mutex_attribute_shared_get_
#define _di_f_thread_mutex_attribute_shared_set_
+#define _di_f_thread_mutex_attribute_d_
#define _di_f_thread_mutex_attribute_t_
#define _di_f_thread_mutex_attribute_type_get_
#define _di_f_thread_mutex_attribute_type_set_
#define _di_f_thread_mutex_attribute_protocol_set_
#define _di_f_thread_mutex_attribute_shared_get_
#define _di_f_thread_mutex_attribute_shared_set_
+#define _di_f_thread_mutex_attribute_d_
#define _di_f_thread_mutex_attribute_t_
#define _di_f_thread_mutex_attribute_type_get_
#define _di_f_thread_mutex_attribute_type_set_
if (error == EAGAIN) return F_status_set_error(F_resource_not);
if (error == EDEADLK) return F_status_set_error(F_deadlock);
if (error == EINVAL) return F_status_set_error(F_parameter);
+ if (error == ENOTRECOVERABLE) return F_status_set_error(F_recover_not);
+ if (error == EOWNERDEAD) return F_status_set_error(F_dead);
return F_status_set_error(F_failure);
}
if (error == EAGAIN) return F_status_set_error(F_resource_not);
if (error == EBUSY) return F_busy;
if (error == EINVAL) return F_status_set_error(F_parameter);
+ if (error == ENOTRECOVERABLE) return F_status_set_error(F_recover_not);
+ if (error == EOWNERDEAD) return F_status_set_error(F_dead);
return F_status_set_error(F_failure);
}
* @return
* F_okay on success.
*
+ * F_dead (with error bit) if the owning thread terminated while holding the mutex lock (thread is dead).
* F_deadlock (with error bit) if operation would cause a deadlock.
* F_parameter (with error bit) if a parameter is invalid.
+ * F_recover_not (with error bit) if the state protected by the mutex is not recoverable.
* F_resource_not (with error bit) if max mutex locks is reached.
*
* F_failure (with error bit) on any other error.
* F_okay on success.
* F_time if the timeout was reached before obtaining the lock.
*
+ * F_dead (with error bit) if the owning thread terminated while holding the mutex lock (thread is dead).
* F_deadlock (with error bit) if operation would cause a deadlock.
* F_parameter (with error bit) if a parameter is invalid.
* F_prohibited (with error bit) if not allowed to perform the operation.
* F_recover_not (with error bit) if the state protected by the mutex is not recoverable.
* F_resource_not (with error bit) if max mutex locks is reached.
- * F_dead (with error bit) if the owning thread terminated while holding the mutex lock (thread is dead).
*
* F_failure (with error bit) on any other error.
*
* F_okay on success.
* F_busy on success, but the mutex is already locked.
*
+ * F_dead (with error bit) if the owning thread terminated while holding the mutex lock (thread is dead).
* F_parameter (with error bit) if a parameter is invalid.
+ * F_recover_not (with error bit) if the state protected by the mutex is not recoverable.
* F_resource_not (with error bit) if max mutex locks is reached.
*
* F_failure (with error bit) on any other error.
#endif
/**
+ * Mutex attribute defines.
+ *
+ * f_thread_mutex_attribute_*_d:
+ * - error_check: Handle deadlock and ownership detection and return on error.
+ * - normal: The normal mutex type (also the default type and is the POSIX standard compliant version of PTHREAD_MUTEX_DEFAULT).
+ * - recursive: Recursive lock (uses a count on locks, mutexs become unlocked when count is 0).
+ */
+#ifndef _di_f_thread_mutex_attribute_d_
+ #define f_thread_mutex_attribute_error_check_d PTHREAD_MUTEX_ERRORCHECK
+ #define f_thread_mutex_attribute_normal_d PTHREAD_MUTEX_RECURSIVE
+ #define f_thread_mutex_attribute_recursive_d PTHREAD_MUTEX_NORMAL
+#endif // _di_f_thread_mutex_attribute_d_
+
+/**
* A typedef representing pthread_mutex_attribute_t.
*/
#ifndef _di_f_thread_mutex_attribute_t_
EAGAIN,
EDEADLK,
EINVAL,
+ ENOTRECOVERABLE,
+ EOWNERDEAD,
mock_errno_generic,
};
F_resource_not,
F_deadlock,
F_parameter,
+ F_recover_not,
+ F_dead,
F_failure,
};
- for (uint8_t i = 0; i < 4; ++i) {
+ for (uint8_t i = 0; i < 6; ++i) {
will_return(__wrap_pthread_mutex_lock, true);
will_return(__wrap_pthread_mutex_lock, errnos[i]);
EAGAIN,
EBUSY,
EINVAL,
+ ENOTRECOVERABLE,
+ EOWNERDEAD,
mock_errno_generic,
};
F_status_set_error(F_resource_not),
F_busy,
F_status_set_error(F_parameter),
+ F_status_set_error(F_recover_not),
+ F_status_set_error(F_dead),
F_status_set_error(F_failure),
};
- for (uint8_t i = 0; i < 4; ++i) {
+ for (uint8_t i = 0; i < 6; ++i) {
will_return(__wrap_pthread_mutex_trylock, true);
will_return(__wrap_pthread_mutex_trylock, errnos[i]);