From 8a162d65ea7f9b84c6b895d0cebf8e6193f4f725 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sat, 30 Nov 2013 09:12:10 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6515 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/OTGv1/usb_lld.c | 6 +++--- os/nil/ports/ARMCMx/compilers/GCC/niltypes.h | 5 +++++ os/rt/ports/ARMCMx/compilers/GCC/chtypes.h | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/os/hal/ports/STM32/OTGv1/usb_lld.c b/os/hal/ports/STM32/OTGv1/usb_lld.c index 39464b367..433a75802 100644 --- a/os/hal/ports/STM32/OTGv1/usb_lld.c +++ b/os/hal/ports/STM32/OTGv1/usb_lld.c @@ -230,7 +230,7 @@ static uint8_t *otg_do_push(volatile uint32_t *fifop, uint8_t *buf, size_t n) { while (n > 0) { /* Note, this line relies on the Cortex-M3/M4 ability to perform unaligned word accesses and on the LSB-first memory organization.*/ - *fifop = *((uint32_t *)buf); + *fifop = *((PACKED_VAR uint32_t *)buf); buf += 4; n--; } @@ -328,7 +328,7 @@ static uint8_t *otg_do_pop(volatile uint32_t *fifop, uint8_t *buf, size_t n) { uint32_t w = *fifop; /* Note, this line relies on the Cortex-M3/M4 ability to perform unaligned word accesses and on the LSB-first memory organization.*/ - *((uint32_t *)buf) = w; + *((PACKED_VAR uint32_t *)buf) = w; buf += 4; n--; } @@ -357,7 +357,7 @@ static void otg_fifo_read_to_buffer(volatile uint32_t *fifop, if (max) { /* Note, this line relies on the Cortex-M3/M4 ability to perform unaligned word accesses and on the LSB-first memory organization.*/ - *((uint32_t *)buf) = w; + *((PACKED_VAR uint32_t *)buf) = w; buf += 4; max--; } diff --git a/os/nil/ports/ARMCMx/compilers/GCC/niltypes.h b/os/nil/ports/ARMCMx/compilers/GCC/niltypes.h index 8b206cb1d..5c4781909 100644 --- a/os/nil/ports/ARMCMx/compilers/GCC/niltypes.h +++ b/os/nil/ports/ARMCMx/compilers/GCC/niltypes.h @@ -77,6 +77,11 @@ typedef uint32_t ucnt_t; /**< Generic unsigned counter. */ #define PORT_THD_FUNCTION(tname, arg) \ __attribute__((noreturn)) void tname(void *arg) +/** + * @brief Packed variable specifier. + */ +#define PACKED_VAR __attribute__((packed)) + #endif /* _NILTYPES_H_ */ /** @} */ diff --git a/os/rt/ports/ARMCMx/compilers/GCC/chtypes.h b/os/rt/ports/ARMCMx/compilers/GCC/chtypes.h index 690b817a6..8acbbfa4e 100644 --- a/os/rt/ports/ARMCMx/compilers/GCC/chtypes.h +++ b/os/rt/ports/ARMCMx/compilers/GCC/chtypes.h @@ -101,6 +101,11 @@ typedef uint32_t ucnt_t; /**< Generic unsigned counter. */ */ #define PORT_THD_FUNCTION(tname, arg) msg_t tname(void *arg) +/** + * @brief Packed variable specifier. + */ +#define PACKED_VAR __attribute__((packed)) + #endif /* _CHTYPES_H_ */ /** @} */