Skip to content

Commit

Permalink
Merge pull request #26069 from hpvb/align-variant
Browse files Browse the repository at this point in the history
Align the Variant data member
  • Loading branch information
akien-mga authored Feb 20, 2019
2 parents 1f257d3 + b6b113c commit 75c89aa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ typedef PoolVector<Vector2> PoolVector2Array;
typedef PoolVector<Vector3> PoolVector3Array;
typedef PoolVector<Color> PoolColorArray;

// Temporary workaround until c++11 alignas()
#ifdef __GNUC__
#define GCC_ALIGNED_8 __attribute__((aligned(8)))
#else
#define GCC_ALIGNED_8
#endif

class Variant {
public:
// If this changes the table in variant_op must be updated
Expand Down Expand Up @@ -132,7 +139,6 @@ class Variant {
_FORCE_INLINE_ const ObjData &_get_obj() const;

union {

bool _bool;
int64_t _int;
double _real;
Expand All @@ -142,7 +148,7 @@ class Variant {
Transform *_transform;
void *_ptr; //generic pointer
uint8_t _mem[sizeof(ObjData) > (sizeof(real_t) * 4) ? sizeof(ObjData) : (sizeof(real_t) * 4)];
} _data;
} _data GCC_ALIGNED_8;

void reference(const Variant &p_variant);
void clear();
Expand Down

0 comments on commit 75c89aa

Please sign in to comment.