13
0

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 <vimproved@inventati.org>
This commit is contained in:
Violet Purcell 2023-09-21 21:09:30 -04:00 committed by Robin Gareus
parent 22e15b135e
commit 8aa716d437
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -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 <ext/atomicity.h>
#endif
#endif
/* UUID */
#include <string>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#endif
#if defined (SMTG_USE_STDATOMIC_H) && SMTG_USE_STDATOMIC_H
#include <stdatomic.h>
#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<atomic_int_least32_t*> (&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);