summaryrefslogtreecommitdiff
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.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)
755 return; 755 return;
756 756
757 /* Align to desired storage alignment */ 757 /* Align to desired storage alignment */
758 alignment_pad = (h->offset - (size_t)(&buffer[h->start])) 758 alignment_pad = STORAGE_OVERLAP(h->offset - (size_t)(&buffer[h->start]));
759 & STORAGE_ALIGN_MASK;
760 h->ridx = h->widx = h->data = ringbuf_add(h->start, alignment_pad); 759 h->ridx = h->widx = h->data = ringbuf_add(h->start, alignment_pad);
761 760
762 if (h == cur_handle) 761 if (h == cur_handle)
@@ -1022,8 +1021,8 @@ int bufopen(const char *file, size_t offset, enum data_type type,
1022 adjusted_offset = 0; 1021 adjusted_offset = 0;
1023 1022
1024 /* Reserve extra space because alignment can move data forward */ 1023 /* Reserve extra space because alignment can move data forward */
1025 struct memory_handle *h = add_handle(size-adjusted_offset+STORAGE_ALIGN_MASK, 1024 size_t padded_size = STORAGE_PAD(size-adjusted_offset);
1026 can_wrap, false); 1025 struct memory_handle *h = add_handle(padded_size, can_wrap, false);
1027 if (!h) 1026 if (!h)
1028 { 1027 {
1029 DEBUGF("%s(): failed to add handle\n", __func__); 1028 DEBUGF("%s(): failed to add handle\n", __func__);
@@ -1045,8 +1044,7 @@ int bufopen(const char *file, size_t offset, enum data_type type,
1045 h->start = buf_widx; 1044 h->start = buf_widx;
1046 1045
1047 /* Align to desired storage alignment */ 1046 /* Align to desired storage alignment */
1048 alignment_pad = (adjusted_offset - (size_t)(&buffer[buf_widx])) 1047 alignment_pad = STORAGE_OVERLAP(adjusted_offset - (size_t)(&buffer[buf_widx]));
1049 & STORAGE_ALIGN_MASK;
1050 buf_widx = ringbuf_add(buf_widx, alignment_pad); 1048 buf_widx = ringbuf_add(buf_widx, alignment_pad);
1051 } 1049 }
1052 1050
@@ -1582,7 +1580,7 @@ bool buffering_reset(char *buf, size_t buflen)
1582 1580
1583 buffer = buf; 1581 buffer = buf;
1584 /* Preserve alignment when wrapping around */ 1582 /* Preserve alignment when wrapping around */
1585 buffer_len = buflen & ~STORAGE_ALIGN_MASK; 1583 buffer_len = STORAGE_ALIGN_DOWN(buflen);
1586 guard_buffer = buf + buflen; 1584 guard_buffer = buf + buflen;
1587 1585
1588 buf_widx = 0; 1586 buf_widx = 0;