r6.0.1:LFDS601_ALIGN
Source File
/liblfds601/inc/liblfds601.h
Prototype
#define LFDS601_ALIGN(alignment) [compiler stack alignment directive]
Parameters
alignment
- Alignment in bytes.
Return Value
No return value.
Notes
Atomic instructions require the variables they operate upon to meet certain memory alignment requirements. In liblfds, heap allocations for variables which will be used with the atomic instructions are aligned using lfds601_abstraction_aligned_malloc, which provides access to the local aligned memory allocation function. However, in some places, variables which will be used with the atomic instructions are declared on the stack. To align these variables, compilers provide a keyword which permits the specification of alignment. This macro is the mechanism by which the compiler specific keyword for stack alignment is provided to liblfds.
Examples
On Windows, with the Microsoft C compiler, there exists the keyword __declspec. This keyword takes a number of arguments which indicate its particular function.
As such, the implementation of LFDS601_ALIGN on Windows with the Microsoft C compiler looks like this;
#define LFDS601_ALIGN(alignment) __declspec( align(alignment) )
On Linux, with gcc, there exists the keyword __attribute__. This keyword takes a number of arguments which indicate its particular function.
As such, the implementation of LFDS601_ALIGN with gcc looks like this;
#define LFDS601_ALIGN(alignment) __attribute__( aligned(alignment) )