r6:Define:INLINE

From liblfds.org
Jump to navigation Jump to search

Source File

/inc/liblfds.h

Define

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

#define INLINE   extern __forceinline

With gcc, there exists the keyword inline.

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

#define INLINE   inline

See Also