From 064ec944c12194c1bde793c14259904049e9bd26 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Tue, 23 Aug 2022 01:01:48 +0800 Subject: [PATCH] util: Add extern "C" guard in simple_mtx.h This is a header that can be accessed both in C/C++, And when remove the usage of _MTX_INITIALIZER_NP in latter commits, it's need implement simple_mtx_init in .c file, so for ABI consistence Add the extern "C" for cpp files Also add comment for #endif guard for code readability Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Reviewed-by: Jason Ekstrand Part-of: --- src/util/simple_mtx.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/util/simple_mtx.h b/src/util/simple_mtx.h index e9988e01bb2..3b7426e8cec 100644 --- a/src/util/simple_mtx.h +++ b/src/util/simple_mtx.h @@ -40,6 +40,14 @@ # define HG(x) #endif +#endif /* UTIL_FUTEX_SUPPORTED */ + +#ifdef __cplusplus +extern "C" { +#endif + +#if UTIL_FUTEX_SUPPORTED + /* mtx_t - Fast, simple mutex * * While modern pthread mutexes are very fast (implemented using futex), they @@ -135,7 +143,7 @@ simple_mtx_assert_locked(simple_mtx_t *mtx) assert(mtx->val); } -#else +#else /* !UTIL_FUTEX_SUPPORTED */ typedef mtx_t simple_mtx_t; @@ -181,6 +189,10 @@ simple_mtx_assert_locked(simple_mtx_t *mtx) #endif } +#endif /* UTIL_FUTEX_SUPPORTED */ + +#ifdef __cplusplus +} #endif -#endif +#endif /* _SIMPLE_MTX_H */