From 54e3f15dcef2d5ed96cc3f2099e4786155fa3031 Mon Sep 17 00:00:00 2001 From: Kamil Rakoczy Date: Tue, 18 Oct 2022 11:15:33 +0200 Subject: [PATCH] Internals: Add attribute when using clang to VL_MT_SAFE and VL_MT_UNSAFE (#3685) --- include/verilatedos.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/verilatedos.h b/include/verilatedos.h index d4d64ea96..de89e822e 100644 --- a/include/verilatedos.h +++ b/include/verilatedos.h @@ -163,14 +163,22 @@ // Comment tag that Function is pure (and thus also VL_MT_SAFE) #define VL_PURE // Comment tag that function is threadsafe when VL_THREADED -#define VL_MT_SAFE +#if defined(__clang__) +# define VL_MT_SAFE __attribute__((annotate("MT_SAFE"))) +#else +# define VL_MT_SAFE +#endif // Comment tag that function is threadsafe when VL_THREADED, only // during normal operation (post-init) #define VL_MT_SAFE_POSTINIT // Attribute that function is clang threadsafe and uses given mutex #define VL_MT_SAFE_EXCLUDES(mutex) VL_EXCLUDES(mutex) // Comment tag that function is not threadsafe when VL_THREADED -#define VL_MT_UNSAFE +#if defined(__clang__) +# define VL_MT_UNSAFE __attribute__((annotate("MT_UNSAFE"))) +#else +# define VL_MT_UNSAFE +#endif // Comment tag that function is not threadsafe when VL_THREADED, // protected to make sure single-caller #define VL_MT_UNSAFE_ONE