r6.1.0:LFDS610_ALIGN

From liblfds.org
Revision as of 14:07, 4 January 2015 by Admin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Source File

/liblfds610/inc/liblfds610.h

Prototype

#define LFDS610_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 lfds610_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 LFDS610_ALIGN on Windows with the Microsoft C compiler looks like this;

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

#define LFDS610_ALIGN(alignment)   __attribute__( aligned(alignment) )

See Also