This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 667de7be3260dee9dc7154395387a00904d5a871 Author: yinshengkai <[email protected]> AuthorDate: Wed Jul 3 15:21:57 2024 +0800 mutex: add nxrmutex_is_recursive api Signed-off-by: yinshengkai <[email protected]> --- include/nuttx/mutex.h | 16 ++++++++++++++++ libs/libc/misc/lib_mutex.c | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/nuttx/mutex.h b/include/nuttx/mutex.h index 1ad8bfe4ef..6299fd35e3 100644 --- a/include/nuttx/mutex.h +++ b/include/nuttx/mutex.h @@ -392,6 +392,22 @@ int nxrmutex_destroy(FAR rmutex_t *rmutex); bool nxrmutex_is_hold(FAR rmutex_t *rmutex); +/**************************************************************************** + * Name: nxrmutex_is_recursive + * + * Description: + * This function check whether the recursive mutex is recursive + * + * Parameters: + * rmutex - Recursive mutex descriptor. + * + * Return Value: + * If rmutex has returned to True recursively, otherwise returns false. + * + ****************************************************************************/ + +bool nxrmutex_is_recursive(FAR rmutex_t *rmutex); + /**************************************************************************** * Name: nxrmutex_get_holder * diff --git a/libs/libc/misc/lib_mutex.c b/libs/libc/misc/lib_mutex.c index 3e3d8341f2..a00df061fe 100644 --- a/libs/libc/misc/lib_mutex.c +++ b/libs/libc/misc/lib_mutex.c @@ -553,6 +553,25 @@ bool nxrmutex_is_hold(FAR rmutex_t *rmutex) return nxmutex_is_hold(&rmutex->mutex); } +/**************************************************************************** + * Name: nxrmutex_is_recursive + * + * Description: + * This function check whether the recursive mutex is recursive + * + * Parameters: + * rmutex - Recursive mutex descriptor. + * + * Return Value: + * If rmutex has returned to True recursively, otherwise returns false. + * + ****************************************************************************/ + +bool nxrmutex_is_recursive(FAR rmutex_t *rmutex) +{ + return rmutex->count > 1; +} + /**************************************************************************** * Name: nxrmutex_get_holder *
