define LFDS711_PAL_BARRIER_COMPILER_FULL

From liblfds.org
Jump to navigation Jump to search

Source File

└───liblfds711
    └───inc
        └───liblfds711
                lfds711_porting_abstraction_layer_compiler.h

Define

#define LFDS711_PAL_BARRIER_COMPILER_FULL  [compiler full compiler barrier directive]

Example

#define LFDS711_PAL_BARRIER_COMPILER_FULL  _ReadWriteBarrier()

Optionality

This define is not mandatory, the library will compile without it, but if it is actually needed, and not provided, then things can go wrong (they might not, but it would be purely by chance). If this define is not implemented in the porting abstraction layer, it must be absent. There are however some platforms where compiler barriers are built into the compiler atomic instrinsics and in this case, this define is inherently provided by the atomic intrinsics. In this case, the define must be absent, but the define LFDS711_PAL_COMPILER_BARRIERS_MISSING_PRESUMED_HAVING_A_GOOD_TIME must be given.

Notes

Compilers typically are able to re-order the flow of instructions, where this re-ordering is only guaranteed to be valid within the context of a single thread; e.g. if thread A performs an operation and then raises a flag, where thread B is waiting on the flag, the compiler will in its re-ordering only take into account that the behaviour of the thread being re-ordered remains valid, such that in this case we might see in thread A the flag being raised before the operation is performed, since the compiler isn't taking into account that thread B is written on the assumption the flag will be raised after the operation.

Compilers typically offer a directive which acts as a full compiler barrier, where a full compiler barrier the prevents the compiler re-ordering operations below the barrier to be above the barrier and prevents the compiler re-ordering operations above the barrier to below the barrier.

The only known cases where this define can properly and safely be omitted is when the compiler specifies that its atomic instrincs issue a compiler barrier. This is the case for GCC versions 4.7.3 and greater, and so for that compiler, this define is not set, but the LFDS711_PAL_COMPILER_BARRIERS_MISSING_PRESUMED_HAVING_A_GOOD_TIME define is set.

See Also