From 8518f55df7b7fbeb968eb545f142537d6e839fdf Mon Sep 17 00:00:00 2001 From: "Emilio G. Cota" Date: Sat, 24 Feb 2018 17:32:36 -0500 Subject: [PATCH] compiler.h: add QEMU_ALIGNED() to enforce struct alignment Backports commit 911a4d2215b05267b16925503218f49d607c6b29 from qemu --- qemu/include/qemu/compiler.h | 4 ++-- qemu/target-i386/cpu.h | 2 +- qemu/tcg/tcg.c | 8 ++++---- qemu/tcg/tcg.h | 2 +- qemu/translate-all.c | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/qemu/include/qemu/compiler.h b/qemu/include/qemu/compiler.h index e3ffdb64..ff65f3af 100644 --- a/qemu/include/qemu/compiler.h +++ b/qemu/include/qemu/compiler.h @@ -52,7 +52,7 @@ static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}}; #define QEMU_ARTIFICIAL #define QEMU_PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) ) -#define QEMU_ALIGN(A, B) __declspec(align(A)) B +#define QEMU_ALIGNED(A, B) __declspec(align(A)) B #define cat(x,y) x ## y #define cat2(x,y) cat(x,y) @@ -101,7 +101,7 @@ static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}}; # define QEMU_PACK( __Declaration__ ) __Declaration__ __attribute__((packed)) #endif -#define QEMU_ALIGN(A, B) B __attribute__((aligned(A))) +#define QEMU_ALIGNED(A, B) B __attribute__((aligned(A))) #ifndef glue #define xglue(x, y) x ## y diff --git a/qemu/target-i386/cpu.h b/qemu/target-i386/cpu.h index 621fddd8..c2fb33f4 100644 --- a/qemu/target-i386/cpu.h +++ b/qemu/target-i386/cpu.h @@ -803,7 +803,7 @@ typedef struct BNDCSReg { #define MMX_Q(n) _q_MMXReg[n] typedef union { - floatx80 QEMU_ALIGN(16, d); + floatx80 QEMU_ALIGNED(16, d); MMXReg mmx; } FPReg; diff --git a/qemu/tcg/tcg.c b/qemu/tcg/tcg.c index a8d4ba47..50c8a9e7 100644 --- a/qemu/tcg/tcg.c +++ b/qemu/tcg/tcg.c @@ -70,8 +70,8 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, /* The CIE and FDE header definitions will be common to all hosts. */ typedef struct { - //uint32_t QEMU_ALIGN(sizeof(void *), len); - uint32_t QEMU_ALIGN(8, len); + //uint32_t QEMU_ALIGNED(sizeof(void *), len); + uint32_t QEMU_ALIGNED(8, len); uint32_t id; uint8_t version; char augmentation[1]; @@ -81,8 +81,8 @@ typedef struct { } DebugFrameCIE; QEMU_PACK( typedef struct { -// uint32_t QEMU_ALIGN(sizeof(void *), len); - uint32_t QEMU_ALIGN(8, len); +// uint32_t QEMU_ALIGNED(sizeof(void *), len); + uint32_t QEMU_ALIGNED(8, len); uint32_t cie_offset; uintptr_t func_start; uintptr_t func_len; diff --git a/qemu/tcg/tcg.h b/qemu/tcg/tcg.h index 1630b8fc..07a68c43 100644 --- a/qemu/tcg/tcg.h +++ b/qemu/tcg/tcg.h @@ -214,7 +214,7 @@ typedef struct TCGLabel { typedef struct TCGPool { struct TCGPool *next; int size; - uint8_t QEMU_ALIGN(8, data[0]); + uint8_t QEMU_ALIGNED(8, data[0]); } TCGPool; #define TCG_POOL_CHUNK_SIZE 32768 diff --git a/qemu/translate-all.c b/qemu/translate-all.c index eb6f14ec..c40d8ffc 100644 --- a/qemu/translate-all.c +++ b/qemu/translate-all.c @@ -544,7 +544,7 @@ static inline void *split_cross_256mb(struct uc_struct *uc, void *buf1, size_t s #endif #ifdef USE_STATIC_CODE_GEN_BUFFER -static uint8_t QEMU_ALIGN(CODE_GEN_ALIGN, static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE]); +static uint8_t QEMU_ALIGNED(CODE_GEN_ALIGN, static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE]); void free_code_gen_buffer(struct uc_struct *uc) {