diff --git a/src/arch/arm/linux/linux.hh b/src/arch/arm/linux/linux.hh index 5fd6cdc0c0..ad773cd3b5 100644 --- a/src/arch/arm/linux/linux.hh +++ b/src/arch/arm/linux/linux.hh @@ -43,6 +43,7 @@ #define __ARCH_ARM_LINUX_LINUX_HH__ #include "arch/arm/utility.hh" +#include "base/compiler.hh" #include "kern/linux/linux.hh" class ArmLinux : public Linux @@ -219,9 +220,9 @@ class ArmLinux32 : public ArmLinux uint32_t st_gid; uint64_t st_rdev; uint8_t __pad3[4]; - int64_t __attribute__ ((aligned (8))) st_size; + M5_ALIGNED(8) int64_t st_size; uint32_t st_blksize; - uint64_t __attribute__ ((aligned (8))) st_blocks; + M5_ALIGNED(8) uint64_t st_blocks; uint32_t st_atimeX; uint32_t st_atime_nsec; uint32_t st_mtimeX; diff --git a/src/arch/mips/linux/aligned.hh b/src/arch/mips/linux/aligned.hh index db4896afa9..84157a2d80 100644 --- a/src/arch/mips/linux/aligned.hh +++ b/src/arch/mips/linux/aligned.hh @@ -30,18 +30,8 @@ #define __ARCH_MIPS_LINUX_ALIGNED_HH__ -/* GCC 3.3.X has a bug in which attributes+typedefs don't work. 3.2.X is fine - * as in 3.4.X, but the bug is marked will not fix in 3.3.X so here is - * the work around. - */ -#if (__GNUC__ == 3 && __GNUC_MINOR__ != 3) || __GNUC__ > 3 -typedef uint64_t uint64_ta __attribute__ ((aligned (8))) ; -typedef int64_t int64_ta __attribute__ ((aligned (8))) ; -typedef Addr Addr_a __attribute__ ((aligned (8))) ; -#else -#define uint64_ta uint64_t __attribute__ ((aligned (8))) -#define int64_ta int64_t __attribute__ ((aligned (8))) -#define Addr_a Addr __attribute__ ((aligned (8))) -#endif /* __GNUC__ __GNUC_MINOR__ */ +typedef M5_ALIGNED(8) uint64_t uint64_ta; +typedef M5_ALIGNED(8) int64_t int64_ta; +typedef M5_ALIGNED(8) Addr Addr_a; #endif /* __ARCH_MIPS_LINUX_ALIGNED_HH__ */ diff --git a/src/base/compiler.hh b/src/base/compiler.hh index 4565143b11..643352cd05 100644 --- a/src/base/compiler.hh +++ b/src/base/compiler.hh @@ -99,6 +99,9 @@ # define M5_LOCAL [[gnu::visibility("hidden")]] # define M5_WEAK [[gnu::weak]] +// Force an alignment for a variable. +# define M5_ALIGNED(alignment) [[gnu::aligned(alignment)]] + // Marker for what should be an unreachable point in the code. # define M5_UNREACHABLE __builtin_unreachable() diff --git a/src/base/statistics.hh b/src/base/statistics.hh index c66454053c..2c1b1a1218 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -657,7 +657,7 @@ class ScalarBase : public DataWrap protected: /** The storage of this stat. */ - char storage[sizeof(Storage)] __attribute__ ((aligned (8))); + M5_ALIGNED(8) char storage[sizeof(Storage)]; protected: /** @@ -1878,7 +1878,7 @@ class DistBase : public DataWrap protected: /** The storage for this stat. */ - char storage[sizeof(Storage)] __attribute__ ((aligned (8))); + M5_ALIGNED(8) char storage[sizeof(Storage)]; protected: /**