aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp/api/plat
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2022-10-14 11:07:07 +0300
committerMatias Elo <matias.elo@nokia.com>2022-10-14 15:04:24 +0300
commit59291e7573c5c7f6cae9f50b370c529ff9fe17d4 (patch)
tree84b49877548a278fcc36bf10b9c1f5c80b46b596 /platform/linux-generic/include/odp/api/plat
parentc368aeebfb903bda602cb450eabf9e73e9697d11 (diff)
linux-gen: spinlock_recursive: add debug asserts
Add debug asserts for detecting recursion count wraparounds and invalid odp_spinlock_recursive_unlock() calls. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'platform/linux-generic/include/odp/api/plat')
-rw-r--r--platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h b/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h
index 2dd846fe9..e795353f4 100644
--- a/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h
+++ b/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h
@@ -13,6 +13,10 @@
#include <odp/api/abi/spinlock_recursive.h>
+#include <odp/api/plat/debug_inlines.h>
+
+#include <stdint.h>
+
/** @cond _ODP_HIDE_FROM_DOXYGEN_ */
#ifndef _ODP_NO_INLINE
@@ -43,6 +47,7 @@ _ODP_INLINE void odp_spinlock_recursive_lock(odp_spinlock_recursive_t *rlock)
int thr = odp_thread_id();
if (rlock->owner == thr) {
+ _ODP_ASSERT(rlock->cnt < UINT32_MAX);
rlock->cnt++;
return;
}
@@ -57,6 +62,7 @@ _ODP_INLINE int odp_spinlock_recursive_trylock(odp_spinlock_recursive_t *rlock)
int thr = odp_thread_id();
if (rlock->owner == thr) {
+ _ODP_ASSERT(rlock->cnt < UINT32_MAX);
rlock->cnt++;
return 1;
}
@@ -72,6 +78,7 @@ _ODP_INLINE int odp_spinlock_recursive_trylock(odp_spinlock_recursive_t *rlock)
_ODP_INLINE void odp_spinlock_recursive_unlock(odp_spinlock_recursive_t *rlock)
{
+ _ODP_ASSERT(rlock->cnt);
rlock->cnt--;
if (rlock->cnt > 0)