1
0
Fork 0
forked from len0rd/rockbox

Make storage alignement use cache alignement macros

Introduce STORAGE_ALIGN_DOWN, STORAGE_PAD (using new CACHE_PAD) and
STORAGE_OVERLAP (using new CACHE_OVERLAP), make them useful only when
PROC_NEEDS_CACHEALIGN and STORAGE_NEEDS_ALIGN are defined

Modify PP and nano2g system-target.h accordingly

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25336 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Rafaël Carré 2010-03-25 23:01:56 +00:00
parent 43bc2e586a
commit a8d1690ffe
6 changed files with 33 additions and 25 deletions

View file

@ -312,6 +312,16 @@ static inline void cpucache_flush(void)
/* Aligns a buffer pointer and size to proper boundaries */
#define CACHEALIGN_BUFFER(start, size) \
ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE)
/* Pad a size so the buffer can be aligned later */
#define CACHE_PAD(x) ((x) + CACHEALIGN_SIZE - 1)
/* Number of bytes in the last cacheline assuming buffer of size x is aligned */
#define CACHE_OVERLAP(x) (x & (CACHEALIGN_SIZE - 1))
#ifdef NEEDS_STORAGE_ALIGN
#define STORAGE_ALIGN_DOWN(x) CACHEALIGN_DOWN(x)
#define STORAGE_PAD(x) CACHE_PAD(x)
#define STORAGE_OVERLAP(x) CACHE_OVERLAP(x)
#endif
#else /* ndef PROC_NEEDS_CACHEALIGN */
@ -323,9 +333,17 @@ static inline void cpucache_flush(void)
#define CACHEALIGN_DOWN(x) (x)
/* Make no adjustments */
#define CACHEALIGN_BUFFER(start, size)
#define CACHE_PAD(x) (x)
#define CACHE_OVERLAP(x) 0
#endif /* PROC_NEEDS_CACHEALIGN */
#if !defined(PROC_NEEDS_CACHEALIGN) || !defined(NEEDS_STORAGE_ALIGN)
#define STORAGE_ALIGN_DOWN(x) (x)
#define STORAGE_PAD(x) (x)
#define STORAGE_OVERLAP(x) 0
#endif
/* Double-cast to avoid 'dereferencing type-punned pointer will
* break strict aliasing rules' B.S. */
#define PUN_PTR(type, p) ((type)(intptr_t)(p))