From 138b0ef79450476f09820b4520a068996e7e72c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Mon, 22 Jul 2013 08:09:49 +0000 Subject: [PATCH] avoid gcc warnings (and potential errors) when strict aliasing is on --- BaS_gcc/include/MCF5475.h | 2 ++ BaS_gcc/include/MCF5475_MMU.h | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/BaS_gcc/include/MCF5475.h b/BaS_gcc/include/MCF5475.h index fa08e81..fca2361 100644 --- a/BaS_gcc/include/MCF5475.h +++ b/BaS_gcc/include/MCF5475.h @@ -23,6 +23,8 @@ * linker symbols must be defined in the linker command file. */ +typedef uint32_t __attribute__((__may_alias__)) uint32_t_a; + extern uint8_t _MBAR[]; extern uint8_t _MMUBAR[]; extern uint8_t _RAMBAR0[]; diff --git a/BaS_gcc/include/MCF5475_MMU.h b/BaS_gcc/include/MCF5475_MMU.h index a865fd8..16794da 100644 --- a/BaS_gcc/include/MCF5475_MMU.h +++ b/BaS_gcc/include/MCF5475_MMU.h @@ -24,7 +24,9 @@ *********************************************************************/ /* Register read/write macros */ -#define MCF_MMU_MMUCR (*(volatile uint32_t*)(&_MMUBAR[0])) + +/* note the uint32_t_a - this is to avoid gcc warnings about pointer aliasing */ +#define MCF_MMU_MMUCR (*(volatile uint32_t_a*)(&_MMUBAR[0])) #define MCF_MMU_MMUOR (*(volatile uint32_t*)(&_MMUBAR[0x4])) #define MCF_MMU_MMUSR (*(volatile uint32_t*)(&_MMUBAR[0x8])) #define MCF_MMU_MMUAR (*(volatile uint32_t*)(&_MMUBAR[0x10]))