From 2fbf09752d385af861279af195d68f920859202d Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Tue, 13 Jan 2009 13:48:26 +0000 Subject: remove align_buffer from firmare/general.c, replacing with ALIGN_BUFFER macro, and replace all uses of it (only resize.c in core, and pictureflow and mpegplayer plugins), remove it from plugin_api, and remove wrapper for it from plugin.h git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19758 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/general.h | 2 -- firmware/export/system.h | 16 +++++++++++++--- firmware/general.c | 20 -------------------- 3 files changed, 13 insertions(+), 25 deletions(-) (limited to 'firmware') diff --git a/firmware/export/general.h b/firmware/export/general.h index 7bcd08da00..d1bd14558c 100644 --- a/firmware/export/general.h +++ b/firmware/export/general.h @@ -37,6 +37,4 @@ int make_list_from_caps32(unsigned long src_mask, unsigned long caps_mask, unsigned long *caps_list); -size_t align_buffer(void **start, size_t size, size_t align); - #endif /* GENERAL_H */ diff --git a/firmware/export/system.h b/firmware/export/system.h index 8ebd30ac4e..cc2a08db2e 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h @@ -110,6 +110,17 @@ int get_cpu_boost_counter(void); #define ALIGN_DOWN(n, a) ((n)/(a)*(a)) #define ALIGN_UP(n, a) ALIGN_DOWN((n)+((a)-1),a) +/* align start and end of buffer to nearest integer multiple of a */ +#define ALIGN_BUFFER(ptr,len,align) \ +{\ + uintptr_t tmp_ptr1 = (uintptr_t)ptr; \ + uintptr_t tmp_ptr2 = tmp_ptr1 + len;\ + tmp_ptr1 = ALIGN_UP(tmp_ptr1,align); \ + tmp_ptr2 = ALIGN_DOWN(tmp_ptr2,align); \ + len = tmp_ptr2 - tmp_ptr1; \ + ptr = (typeof(ptr))tmp_ptr1; \ +} + /* live endianness conversion */ #ifdef ROCKBOX_LITTLE_ENDIAN #define letoh16(x) (x) @@ -275,7 +286,7 @@ static inline uint32_t swap_odd_even32(uint32_t value) __attribute__((aligned(CACHEALIGN_UP(x)))) /* Aligns a buffer pointer and size to proper boundaries */ #define CACHEALIGN_BUFFER(start, size) \ - ({ align_buffer(PUN_PTR(void **, (start)), (size), CACHEALIGN_SIZE); }) + ALIGN_BUFFER((start), (size), CACHEALIGN_SIZE) #else /* ndef PROC_NEEDS_CACHEALIGN */ @@ -286,8 +297,7 @@ static inline uint32_t swap_odd_even32(uint32_t value) #define CACHEALIGN_UP(x) (x) #define CACHEALIGN_DOWN(x) (x) /* Make no adjustments */ -#define CACHEALIGN_BUFFER(start, size) \ - ({ (void)(start); (size); }) +#define CACHEALIGN_BUFFER(start, size) #endif /* PROC_NEEDS_CACHEALIGN */ diff --git a/firmware/general.c b/firmware/general.c index 1c2abe1256..ff6594086e 100644 --- a/firmware/general.c +++ b/firmware/general.c @@ -78,23 +78,3 @@ int make_list_from_caps32(unsigned long src_mask, return count; } /* make_list_from_caps32 */ - -/* Align a buffer and size to a size boundary while remaining within - * the original boundaries */ -size_t align_buffer(void **start, size_t size, size_t align) -{ - void *newstart = *start; - void *newend = newstart + size; - - /* Align the end down and the start up */ - newend = (void *)ALIGN_DOWN((intptr_t)newend, align); - newstart = (void *)ALIGN_UP((intptr_t)newstart, align); - - /* Hmmm - too small for this */ - if (newend <= newstart) - return 0; - - /* Return adjusted pointer and size */ - *start = newstart; - return newend - newstart; -} -- cgit v1.2.3