summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2011-05-08 16:41:23 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2011-05-08 16:41:23 +0000
commite720724b9545bcfaf5a98b8a76b145a97a88b9f1 (patch)
tree3bdfc814ed3198bd51d67ca50ea933d962ffcb03
parent9c33dca6479d41d1745e6007bca97fe11c9b8db1 (diff)
downloadrockbox-e720724b9545bcfaf5a98b8a76b145a97a88b9f1.tar.gz
rockbox-e720724b9545bcfaf5a98b8a76b145a97a88b9f1.tar.bz2
rockbox-e720724b9545bcfaf5a98b8a76b145a97a88b9f1.zip
Use MEM_ALIGN_ATTR and CACHEALIGN_SIZE in oggmalloc to ensure optimal alignment.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29833 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/libtremor/oggmalloc.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/codecs/libtremor/oggmalloc.c b/apps/codecs/libtremor/oggmalloc.c
index 3d60370641..3a5fecf910 100644
--- a/apps/codecs/libtremor/oggmalloc.c
+++ b/apps/codecs/libtremor/oggmalloc.c
@@ -61,7 +61,7 @@ void ogg_free(void* ptr)
}
/* Allocate IRAM buffer */
-static unsigned char iram_buff[IRAM_IBSS_SIZE] IBSS_ATTR __attribute__ ((aligned (16)));
+static unsigned char iram_buff[IRAM_IBSS_SIZE] IBSS_ATTR MEM_ALIGN_ATTR;
static size_t iram_remain;
void iram_malloc_init(void){
@@ -70,14 +70,13 @@ void iram_malloc_init(void){
void *iram_malloc(size_t size){
void* x;
-
- /* always ensure 16-byte aligned */
- if(size&0x0f)
- size=(size-(size&0x0f))+16;
-
+
+ /* always ensure alignment to CACHEALIGN_SIZE byte */
+ size = (size + (CACHEALIGN_SIZE-1)) & ~(CACHEALIGN_SIZE-1);
+
if(size>iram_remain)
return NULL;
-
+
x = &iram_buff[IRAM_IBSS_SIZE-iram_remain];
iram_remain-=size;