Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/35976 )
Change subject: misc: Wrap __attribute__((aligned())) in a macro in
compiler.hh.
......................................................................
misc: Wrap __attribute__((aligned())) in a macro in compiler.hh.
This attribute is gcc specific (also implemented by clang for
compatibility), and so should be behind a level of abstraction to make
using different compilers easier.
Change-Id: I7495f011f617268dd7a589dc0bcf1b3b7f515046
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/35976
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Maintainer: Gabe Black <gabebl...@google.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/arch/arm/linux/linux.hh
M src/arch/mips/linux/aligned.hh
M src/base/compiler.hh
M src/base/statistics.hh
4 files changed, 11 insertions(+), 17 deletions(-)
Approvals:
Daniel Carvalho: Looks good to me, approved
Gabe Black: Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/arch/arm/linux/linux.hh b/src/arch/arm/linux/linux.hh
index 5fd6cdc..ad773cd 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 @@
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 db4896a..84157a2 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 4565143..643352c 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 c664540..2c1b1a1 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -657,7 +657,7 @@
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 @@
protected:
/** The storage for this stat. */
- char storage[sizeof(Storage)] __attribute__ ((aligned (8)));
+ M5_ALIGNED(8) char storage[sizeof(Storage)];
protected:
/**
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/35976
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I7495f011f617268dd7a589dc0bcf1b3b7f515046
Gerrit-Change-Number: 35976
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Gabe Black <gabebl...@google.com>
Gerrit-Reviewer: Nikos Nikoleris <nikos.nikole...@arm.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-CC: Jason Lowe-Power <power...@gmail.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s