From c2e3dee6e03527baf8698698cce76b1a3174969a Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Sun, 13 Feb 2011 23:37:34 +0100 Subject: linux-user: Define target alignment size Datatype alignment can be found using following application: int main(void) { printf("alignof(short) %ld\n", __alignof__(short)); printf("alignof(int) %ld\n", __alignof__(int)); printf("alignof(long) %ld\n", __alignof__(long)); printf("alignof(long long) %ld\n", __alignof__(long long)); } This patch includes following alignments: i386 alignof(short) 2 alignof(int) 4 alignof(long) 4 alignof(long long) 8 x86_64 alignof(short) 2 alignof(int) 4 alignof(long) 8 alignof(long long) 8 arm alignof(short) 2 alignof(int) 4 alignof(long) 4 alignof(long long) 4 m68k (680x0) alignof(short) 2 alignof(int) 2 alignof(long) 2 alignof(long long) 2 mips alignof(short) 2 alignof(int) 4 alignof(long) 4 alignof(long long) 8 ppc alignof(short) 2 alignof(int) 4 alignof(long) 4 alignof(long long) 8 for other targets, use by default (2,4,4,8). Please, update for your favorite target... Signed-off-by: Laurent Vivier Signed-off-by: Riku Voipio --- cpu-defs.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'cpu-defs.h') diff --git a/cpu-defs.h b/cpu-defs.h index db809ed46..2b59fa6fb 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -37,16 +37,22 @@ #define TARGET_LONG_SIZE (TARGET_LONG_BITS / 8) +typedef int16_t target_short __attribute__ ((aligned(TARGET_SHORT_ALIGNMENT))); +typedef uint16_t target_ushort __attribute__((aligned(TARGET_SHORT_ALIGNMENT))); +typedef int32_t target_int __attribute__((aligned(TARGET_INT_ALIGNMENT))); +typedef uint32_t target_uint __attribute__((aligned(TARGET_INT_ALIGNMENT))); +typedef int64_t target_llong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); +typedef uint64_t target_ullong __attribute__((aligned(TARGET_LLONG_ALIGNMENT))); /* target_ulong is the type of a virtual address */ #if TARGET_LONG_SIZE == 4 -typedef int32_t target_long; -typedef uint32_t target_ulong; +typedef int32_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +typedef uint32_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); #define TARGET_FMT_lx "%08x" #define TARGET_FMT_ld "%d" #define TARGET_FMT_lu "%u" #elif TARGET_LONG_SIZE == 8 -typedef int64_t target_long; -typedef uint64_t target_ulong; +typedef int64_t target_long __attribute__((aligned(TARGET_LONG_ALIGNMENT))); +typedef uint64_t target_ulong __attribute__((aligned(TARGET_LONG_ALIGNMENT))); #define TARGET_FMT_lx "%016" PRIx64 #define TARGET_FMT_ld "%" PRId64 #define TARGET_FMT_lu "%" PRIu64 -- cgit v1.2.3