diff --git a/src/include/sof/common.h b/src/include/sof/common.h index 8db626b178a5..03dd886ad4a1 100644 --- a/src/include/sof/common.h +++ b/src/include/sof/common.h @@ -77,7 +77,12 @@ #endif -#define ALIGN ALIGN_UP +/* This most basic ALIGN() must be used in header files that are + * included in both C and assembly code. memory.h files require this + * exact spelling matching the linker function because memory.h values + * are _also_ copied unprocessed to the .x[.in] linker script + */ +#define ALIGN(val, align) ALIGN_UP_INTERNAL(val, align) #define DIV_ROUND_UP(val, div) (((val) + (div) - 1) / (div)) #if !defined(__ASSEMBLER__) diff --git a/src/lib/alloc.c b/src/lib/alloc.c index bde1633ebb61..3705b7719787 100644 --- a/src/lib/alloc.c +++ b/src/lib/alloc.c @@ -197,7 +197,7 @@ static void *align_ptr(struct mm_heap *heap, uint32_t alignment, if (alignment <= 1) return ptr; - return (void *)ALIGN((uintptr_t)ptr, alignment); + return (void *)ALIGN_UP((uintptr_t)ptr, alignment); } /* allocate single block */ @@ -290,7 +290,7 @@ static void *alloc_cont_blocks(struct mm_heap *heap, int level, /* Check if we can start a sequence here */ if (alignment) { - aligned = ALIGN(blk_start, alignment); + aligned = ALIGN_UP(blk_start, alignment); if (blk_start & (alignment - 1) && aligned >= blk_start + map->block_size) @@ -881,7 +881,7 @@ static void *alloc_heap_buffer(struct mm_heap *heap, uint32_t flags, if (hdr->used) continue; - aligned = ALIGN(free_start, alignment); + aligned = ALIGN_UP(free_start, alignment); if (aligned + bytes > free_start + map->block_size) continue; diff --git a/src/platform/intel/cavs/lib/pm_memory.c b/src/platform/intel/cavs/lib/pm_memory.c index 1af986c0ed3f..967e62aaa4f3 100644 --- a/src/platform/intel/cavs/lib/pm_memory.c +++ b/src/platform/intel/cavs/lib/pm_memory.c @@ -38,7 +38,7 @@ static void memory_banks_get(void *start, void *end, uint32_t base, * or end for end address */ if ((uintptr_t)start % SRAM_BANK_SIZE) - start = (void *)ALIGN((uintptr_t)start, SRAM_BANK_SIZE); + start = (void *)ALIGN_UP((uintptr_t)start, SRAM_BANK_SIZE); if ((uintptr_t)end % SRAM_BANK_SIZE) end = (void *)ALIGN_DOWN((uintptr_t)end, SRAM_BANK_SIZE);