Revision as of 12:13, 29 May 2016 by Admin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Source File



#define LFDS710_PAL_BARRIER_COMPILER_LOAD  [compiler load barrier directive]


#define LFDS710_PAL_BARRIER_COMPILER_LOAD  _ReadBarrier()


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.


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