Embedded Artistry Framework
Embedded Systems C++ Framework
Macros | Functions
posix_memalign.c File Reference
#include <aligned_malloc.h>
#include <assert.h>
#include <errno.h>
#include <stddef.h>
Include dependency graph for posix_memalign.c:

Macros

#define IS_POWER_2(x)   (!((x) & ((x)-1)))
 

Functions

int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
 Posix Memory Alignment Extension. More...
 

Macro Definition Documentation

◆ IS_POWER_2

#define IS_POWER_2 (   x)    (!((x) & ((x)-1)))

Function Documentation

◆ posix_memalign()

int posix_memalign ( void **  memptr,
size_t  alignment,
size_t  size 
)

Posix Memory Alignment Extension.

Generated aligned memory. This function forwards the request to aligned malloc. Allocated memory must be freed with aligned_free().

Parameters
memptrA pointer to the pointer which will store the aligned memory. The memory must be freed with aligned_free(). memptr must not be NULL.
alignmentThe target alignment for the memory. Must be a power of 2.
sizeThe size of the allocation. Must be > 0.
Precondition
memptr is not NULL. alignment is power-of-2. size > 0.
Returns
ENOMEM if memory could not be allocated, EINVAL if alignment is not a power-of-2, and 0 on successful allocation.

References aligned_malloc(), assert, EINVAL, ENOMEM, IS_POWER_2, NULL, and r.

Referenced by posix_memalign_test().

Here is the caller graph for this function: