1 #include "lfds610_abstraction_internal_body.h"
7 /****************************************************************************/
8 #if (defined _WIN32 && defined _MSC_VER)
10 /* TRD : 64 bit and 32 bit Windows (user-mode or kernel) on any CPU with the Microsoft C compiler
12 _WIN32 indicates 64-bit or 32-bit Windows
13 _MSC_VER indicates Microsoft C compiler
16 static LFDS610_INLINE lfds610_atom_t lfds610_abstraction_cas( volatile lfds610_atom_t *destination, lfds610_atom_t exchange, lfds610_atom_t compare )
18 assert( destination != NULL );
19 // TRD : exchange can be any value in its range
20 // TRD : compare can be any value in its range
22 return( (lfds610_atom_t) _InterlockedCompareExchangePointer((void * volatile *) destination, (void *) exchange, (void *) compare) );
31 /****************************************************************************/
32 #if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 1 && __GNUC_PATCHLEVEL__ >= 0)
34 /* TRD : any OS on any CPU with GCC 4.1.0 or better
36 GCC 4.1.0 introduced the __sync_*() atomic intrinsics
38 __GNUC__ / __GNUC_MINOR__ / __GNUC_PATCHLEVEL__ indicates GCC and which version
41 static LFDS610_INLINE lfds610_atom_t lfds610_abstraction_cas( volatile lfds610_atom_t *destination, lfds610_atom_t exchange, lfds610_atom_t compare )
43 assert( destination != NULL );
44 // TRD : exchange can be any value in its range
45 // TRD : compare can be any value in its range
47 // TRD : note the different argument order for the GCC instrinsic to the MSVC instrinsic
49 return( (lfds610_atom_t) __sync_val_compare_and_swap(destination, compare, exchange) );