define LFDS710_PAL_BARRIER_COMPILER_LOAD

From liblfds.org
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Source File

└───liblfds710
    └───inc
        └───liblfds710
                lfds710_porting_abstraction_layer_compiler.h

Define

#define LFDS710_PAL_BARRIER_COMPILER_LOAD  [compiler load barrier directive]

Example

#define LFDS710_PAL_BARRIER_COMPILER_LOAD  _ReadBarrier()

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 LFDS710_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 compiler load barrier, where a compiler load barrier the prevents the compiler re-ordering load operations below the barrier to be above the barrier and prevents the compiler re-ordering load 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 LFDS710_PAL_COMPILER_BARRIERS_MISSING_PRESUMED_HAVING_A_GOOD_TIME define is set.

See Also