summaryrefslogtreecommitdiffstats
path: root/apps/buffering.c
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2010-03-25 23:01:56 +0000
committerRafaël Carré <rafael.carre@gmail.com>2010-03-25 23:01:56 +0000
commita8d1690ffec4a67fdcb0836fd91989fd1dbf5a7a (patch)
treeffd2e99e3a61d03641e663c5574ed0adf30d8df0 /apps/buffering.c
parent43bc2e586ae3194541bc5a835803750fcd2c1c0d (diff)
downloadrockbox-a8d1690ffec4a67fdcb0836fd91989fd1dbf5a7a.tar.gz
rockbox-a8d1690ffec4a67fdcb0836fd91989fd1dbf5a7a.tar.bz2
rockbox-a8d1690ffec4a67fdcb0836fd91989fd1dbf5a7a.zip
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
Diffstat (limited to 'apps/buffering.c')
-rw-r--r--apps/buffering.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/apps/buffering.c b/apps/buffering.c
index 664a178db0..afc7c7ad6b 100644
--- a/apps/buffering.c
+++ b/apps/buffering.c
@@ -755,8 +755,7 @@ static void reset_handle(int handle_id)
return;
/* Align to desired storage alignment */
- alignment_pad = (h->offset - (size_t)(&buffer[h->start]))
- & STORAGE_ALIGN_MASK;
+ alignment_pad = STORAGE_OVERLAP(h->offset - (size_t)(&buffer[h->start]));
h->ridx = h->widx = h->data = ringbuf_add(h->start, alignment_pad);
if (h == cur_handle)
@@ -1022,8 +1021,8 @@ int bufopen(const char *file, size_t offset, enum data_type type,
adjusted_offset = 0;
/* Reserve extra space because alignment can move data forward */
- struct memory_handle *h = add_handle(size-adjusted_offset+STORAGE_ALIGN_MASK,
- can_wrap, false);
+ size_t padded_size = STORAGE_PAD(size-adjusted_offset);
+ struct memory_handle *h = add_handle(padded_size, can_wrap, false);
if (!h)
{
DEBUGF("%s(): failed to add handle\n", __func__);
@@ -1045,8 +1044,7 @@ int bufopen(const char *file, size_t offset, enum data_type type,
h->start = buf_widx;
/* Align to desired storage alignment */
- alignment_pad = (adjusted_offset - (size_t)(&buffer[buf_widx]))
- & STORAGE_ALIGN_MASK;
+ alignment_pad = STORAGE_OVERLAP(adjusted_offset - (size_t)(&buffer[buf_widx]));
buf_widx = ringbuf_add(buf_widx, alignment_pad);
}
@@ -1582,7 +1580,7 @@ bool buffering_reset(char *buf, size_t buflen)
buffer = buf;
/* Preserve alignment when wrapping around */
- buffer_len = buflen & ~STORAGE_ALIGN_MASK;
+ buffer_len = STORAGE_ALIGN_DOWN(buflen);
guard_buffer = buf + buflen;
buf_widx = 0;