From 8aa716d4376203b633bb6c1764844fd7e43ccdcc Mon Sep 17 00:00:00 2001 From: Violet Purcell Date: Thu, 21 Sep 2023 21:09:30 -0400 Subject: [PATCH] Backport VST3 libc++ fix on linux LLVM libc++ does not have the ext/atomicity.h header. This fix is copied from the upstream vst3_pluginterfaces repo. Signed-off-by: Violet Purcell --- libs/vst3/pluginterfaces/base/funknown.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libs/vst3/pluginterfaces/base/funknown.cpp b/libs/vst3/pluginterfaces/base/funknown.cpp index 09d5d27836..738889a332 100644 --- a/libs/vst3/pluginterfaces/base/funknown.cpp +++ b/libs/vst3/pluginterfaces/base/funknown.cpp @@ -44,13 +44,23 @@ #endif #if SMTG_OS_LINUX +#if !defined (SMTG_USE_STDATOMIC_H) +#if defined (_LIBCPP_VERSION) +#define SMTG_USE_STDATOMIC_H 1 +#else #include +#endif +#endif /* UUID */ #include #include #include #endif +#if defined (SMTG_USE_STDATOMIC_H) && SMTG_USE_STDATOMIC_H +#include +#endif + namespace Steinberg { //------------------------------------------------------------------------ @@ -79,7 +89,9 @@ namespace FUnknownPrivate { //------------------------------------------------------------------------ int32 PLUGIN_API atomicAdd (int32& var, int32 d) { -#if SMTG_OS_WINDOWS +#if SMTG_USE_STDATOMIC_H + return atomic_fetch_add (reinterpret_cast (&var), d) +d; +#elif SMTG_OS_WINDOWS return InterlockedExchangeAdd ((volatile long int*)&var, d) + d; #elif SMTG_OS_MACOS return OSAtomicAdd32Barrier (d, (int32_t*)&var);