ChibiOS/RT  6.0.3
Memory Alignment
Collaboration diagram for Memory Alignment:

Detailed Description

Memory Alignment services.

Memory alignment support macros

#define MEM_ALIGN_MASK(a)   ((size_t)(a) - 1U)
 Alignment mask constant. More...
 
#define MEM_ALIGN_PREV(p, a)
 Aligns to the previous aligned memory address. More...
 
#define MEM_ALIGN_NEXT(p, a)
 Aligns to the next aligned memory address. More...
 
#define MEM_IS_ALIGNED(p, a)   (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)
 Returns whatever a pointer or memory size is aligned. More...
 
#define MEM_IS_VALID_ALIGNMENT(a)   (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))
 Returns whatever a constant is a valid alignment. More...
 

Macro Definition Documentation

#define MEM_ALIGN_MASK (   a)    ((size_t)(a) - 1U)

Alignment mask constant.

Parameters
[in]aalignment, must be a power of two

Definition at line 60 of file chalign.h.

#define MEM_ALIGN_PREV (   p,
 
)
Value:
/*lint -save -e9033 [10.8] The cast is safe.*/ \
((size_t)(p) & ~MEM_ALIGN_MASK(a)) \
/*lint -restore*/
#define MEM_ALIGN_MASK(a)
Alignment mask constant.
Definition: chalign.h:60

Aligns to the previous aligned memory address.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 68 of file chalign.h.

#define MEM_ALIGN_NEXT (   p,
 
)
Value:
/*lint -save -e9033 [10.8] The cast is safe.*/ \
MEM_ALIGN_PREV((size_t)(p) + MEM_ALIGN_MASK(a), (a)) \
/*lint -restore*/
#define MEM_ALIGN_MASK(a)
Alignment mask constant.
Definition: chalign.h:60
#define MEM_ALIGN_PREV(p, a)
Aligns to the previous aligned memory address.
Definition: chalign.h:68

Aligns to the next aligned memory address.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 79 of file chalign.h.

Referenced by chCoreAllocAlignedWithOffsetI(), chHeapAllocAligned(), chHeapFree(), chHeapObjectInit(), chThdCreateStatic(), and chThdCreateSuspendedI().

#define MEM_IS_ALIGNED (   p,
 
)    (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)

Returns whatever a pointer or memory size is aligned.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 90 of file chalign.h.

Referenced by chHeapFree(), chPoolAllocI(), chPoolFreeI(), chThdCreateStatic(), and chThdCreateSuspendedI().

#define MEM_IS_VALID_ALIGNMENT (   a)    (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))

Returns whatever a constant is a valid alignment.

Valid alignments are powers of two.

Parameters
[in]aalignment to be checked, must be a constant

Definition at line 98 of file chalign.h.

Referenced by chCoreAllocAlignedWithOffsetI(), chHeapAllocAligned(), and chPoolObjectInitAligned().