summaryrefslogtreecommitdiff
path: root/src/drivers/ao_trng_send.c
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-12-17 20:58:36 -0800
committerKeith Packard <keithp@keithp.com>2016-12-17 21:04:33 -0800
commit89ecc32b90565ace078c4a84d4406a4d1f86821a (patch)
tree3b32f1d922380b3dfd25db75552a30dc84c24d41 /src/drivers/ao_trng_send.c
parentf650211f9e99e1d3d0ae13ae559dd1c082f71545 (diff)
altos/arm: Align data so that gcc 5.4 doesn't do byte-accesses. Add -Wcast-align
Gcc 5.4.1 tracks alignment of data through assignments, so that a uint32_t pointer which comes from byte-aligned uint8_t data: extern uint8_t foo[]; uint32_t *q = (void *) foo; Fetches and stores through this pointer are done bytewise. This is slow (meh), but if q references a device register, things to bad very quickly. This patch works around this bug in the compiler by adding __attribute__((aligned(4))) tags to some variables, or changing them from uint8_t to uint32_t. Places doing this will now be caught as I've added -Wcast-align to the compiler flags. That required adding (void *) casts, after the relevant code was checked to make sure the compiler could tell that the addresses were aligned. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/drivers/ao_trng_send.c')
-rw-r--r--src/drivers/ao_trng_send.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/drivers/ao_trng_send.c b/src/drivers/ao_trng_send.c
index 85034efd..b1227aaa 100644
--- a/src/drivers/ao_trng_send.c
+++ b/src/drivers/ao_trng_send.c
@@ -104,7 +104,7 @@ ao_trng_get_cooked(uint16_t *buf)
{
uint16_t i;
uint16_t t;
- uint32_t *rnd = (uint32_t *) ao_adc_ring;
+ uint32_t *rnd = (uint32_t *) (void *) ao_adc_ring;
uint8_t mismatch = 0;
t = ao_adc_get(AO_USB_IN_SIZE) >> 1; /* one 16-bit value per output byte */