From dfc59c94cc48f6f2b157cb2a172e260dada27b79 Mon Sep 17 00:00:00 2001 From: falkTX Date: Thu, 26 May 2022 14:00:20 +0100 Subject: [PATCH] Do not use alignas on macOS Signed-off-by: falkTX --- include/engine/Port.hpp | 9 ++++++++- include/simd/Vector.hpp | 13 +++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/engine/Port.hpp b/include/engine/Port.hpp index b518870..12eb136 100644 --- a/include/engine/Port.hpp +++ b/include/engine/Port.hpp @@ -32,6 +32,13 @@ #include +/** NOTE alignas is required in some systems in order to allow SSE usage. */ +#ifndef ARCH_MAC +#define SIMD_ALIGN alignas(32) +#else +#define SIMD_ALIGN +#endif + namespace rack { namespace engine { @@ -48,7 +55,7 @@ struct Port { /** Voltage of the port. */ /** NOTE alignas is required in order to allow SSE usage. Consecutive data (like in a vector) would otherwise pack Ports in a way that breaks SSE. */ - union alignas(32) { + union SIMD_ALIGN { /** Unstable API. Use getVoltage() and setVoltage() instead. */ float voltages[PORT_MAX_CHANNELS] = {}; /** DEPRECATED. Unstable API. Use getVoltage() and setVoltage() instead. */ diff --git a/include/simd/Vector.hpp b/include/simd/Vector.hpp index b1640cd..7dd77ad 100644 --- a/include/simd/Vector.hpp +++ b/include/simd/Vector.hpp @@ -30,6 +30,13 @@ #include #include +/** NOTE alignas is required in some systems in order to allow SSE usage. */ +#ifndef ARCH_MAC +#define SIMD_ALIGN alignas(32) +#else +#define SIMD_ALIGN +#endif + namespace rack { @@ -62,8 +69,7 @@ struct Vector { using type = float; constexpr static int size = 4; - /** NOTE alignas is required in order to allow SSE usage. */ - union alignas(32) { + union SIMD_ALIGN { __m128 v; /** Accessing this array of scalars is slow and defeats the purpose of vectorizing. */ @@ -137,8 +143,7 @@ struct Vector { using type = int32_t; constexpr static int size = 4; - /** NOTE alignas is required in order to allow SSE usage. */ - union alignas(32) { + union SIMD_ALIGN { __m128i v; int32_t s[4]; };