r6.0.1:LFDS601_INLINE

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

/liblfds601/inc/liblfds601.h

Define

#define LFDS601_INLINE   [compiler inline directive]

Parameters

No parameters.

Return Value

No return value.

Notes

The atomic instructions used by liblfds in the end always come down to a single machine instruction. Part of the reason for using lock-free data structures is performance. As such, it is important to indicate to the compiler that it should if at all possible avoid the overhead of a function call every time one of the atomic instructions is called. To achieve this, compilers provide a keyword which permits the code author to indicate that a given function should be inlined. 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 __forceinline. Note that the Microsoft C compiler gives inlined functions static linkage unless they are specifically given external linkage and so in this case, we also need to add the extern keyword.

As such, the implementation of LFDS601_INLINE on Windows with the Microsoft C compiler looks like this;

#define LFDS601_INLINE   extern __forceinline

With gcc, there exists the keyword inline.

As such, the implementation of LFDS601_INLINE on GCC looks like this;

#define LFDS601_INLINE   inline

See Also