summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2020-07-24 22:46:05 -0400
committerSolomon Peachy <pizza@shaftnet.org>2020-07-25 02:57:35 +0000
commit469866b6c90c1de8a8581347a357e33a3dfd908c (patch)
tree7a2c90cb606260d171822ac04fbecd0c8cae62ed
parent677848cf80a06a2ffacbc99ef8fed4ff9e4ef6d7 (diff)
downloadrockbox-469866b6c90c1de8a8581347a357e33a3dfd908c.tar.gz
rockbox-469866b6c90c1de8a8581347a357e33a3dfd908c.tar.bz2
rockbox-469866b6c90c1de8a8581347a357e33a3dfd908c.zip
mpegplayer: Fix aliasing rules violation on multi-core targets
As the PP series has no sense of cache coherency between its multiple cores, we need to ensure the vo_data structure does not share cachelines with anything else. This was previously done by defining a uint8_t array and trying to access it via typecasting hell, triggering a large pile of aliasing violation warnings on newer toolchains and/or higher optimization levels. Instead of violating the C spec in an undefined-behaviour-sort-of-way, create a union of the right size and alignment, and make one of its members the structure we care about. Voila, everyone is happy. Change-Id: Iad78f8132225437cd4aa10e6e5f6ae58ba996c19
-rw-r--r--apps/plugins/mpegplayer/video_out_rockbox.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/apps/plugins/mpegplayer/video_out_rockbox.c b/apps/plugins/mpegplayer/video_out_rockbox.c
index b05a229083..ee5c3400c5 100644
--- a/apps/plugins/mpegplayer/video_out_rockbox.c
+++ b/apps/plugins/mpegplayer/video_out_rockbox.c
@@ -47,9 +47,11 @@ struct vo_data
#if NUM_CORES > 1
/* Cache aligned and padded to avoid clobbering other processors' cacheable
* data */
-static uint8_t __vo_data[CACHEALIGN_UP(sizeof(struct vo_data))]
- CACHEALIGN_ATTR;
-#define vo (*((struct vo_data *)__vo_data))
+static union {
+ uint8_t __vo_data[CACHEALIGN_UP(sizeof(struct vo_data))];
+ struct vo_data vo;
+} vo_raw CACHEALIGN_ATTR;
+#define vo vo_raw.vo
#else
static struct vo_data vo;
#endif