Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/include/sof/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
6 changes: 3 additions & 3 deletions src/lib/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/intel/cavs/lib/pm_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down