summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorYonggang Luo <luoyonggang@gmail.com>2022-08-23 01:01:48 +0800
committerMarge Bot <emma+marge@anholt.net>2022-08-31 15:40:20 +0000
commit064ec944c12194c1bde793c14259904049e9bd26 (patch)
treef6ca51ca0663d76e7dcf835245d83026a203094a /src/util
parent67cd0c44d23ec8d6b907f3b4966e488e2da09475 (diff)
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 <luoyonggang@gmail.com> Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17122>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/simple_mtx.h16
1 files 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
+#endif /* UTIL_FUTEX_SUPPORTED */
+#ifdef __cplusplus
+}
#endif
+
+#endif /* _SIMPLE_MTX_H */