Skip to content

Commit

Permalink
Do not use alignas on macOS
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <falktx@falktx.com>
  • Loading branch information
falkTX committed May 26, 2022
1 parent b3d68d9 commit dfc59c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
9 changes: 8 additions & 1 deletion include/engine/Port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@

#include <list>

/** 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 {
Expand All @@ -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. */
Expand Down
13 changes: 9 additions & 4 deletions include/simd/Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
#include <cstring>
#include <pmmintrin.h>

/** 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 {

Expand Down Expand Up @@ -62,8 +69,7 @@ struct Vector<float, 4> {
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.
*/
Expand Down Expand Up @@ -137,8 +143,7 @@ struct Vector<int32_t, 4> {
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];
};
Expand Down

0 comments on commit dfc59c9

Please sign in to comment.