r6.0.0:LFDS600_ALIGN

From liblfds.org
Jump to navigation Jump to search

Source File

/liblfds600/inc/liblfds600.h

Prototype

#define LFDS600_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 lfds600_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 LFDS600_ALIGN on Windows with the Microsoft C compiler looks like this;

#define LFDS600_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 LFDS600_ALIGN with gcc looks like this;

#define LFDS600_ALIGN(alignment)   __attribute__( aligned(alignment) )

See Also