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
This commit is contained in:
parent
677848cf80
commit
469866b6c9
1 changed files with 5 additions and 3 deletions
|
@ -47,9 +47,11 @@ struct vo_data
|
||||||
#if NUM_CORES > 1
|
#if NUM_CORES > 1
|
||||||
/* Cache aligned and padded to avoid clobbering other processors' cacheable
|
/* Cache aligned and padded to avoid clobbering other processors' cacheable
|
||||||
* data */
|
* data */
|
||||||
static uint8_t __vo_data[CACHEALIGN_UP(sizeof(struct vo_data))]
|
static union {
|
||||||
CACHEALIGN_ATTR;
|
uint8_t __vo_data[CACHEALIGN_UP(sizeof(struct vo_data))];
|
||||||
#define vo (*((struct vo_data *)__vo_data))
|
struct vo_data vo;
|
||||||
|
} vo_raw CACHEALIGN_ATTR;
|
||||||
|
#define vo vo_raw.vo
|
||||||
#else
|
#else
|
||||||
static struct vo_data vo;
|
static struct vo_data vo;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue