\r\n

51Degrees Device Detection C/C++  4.4

A device detection library that is used natively or by 51Degrees products

fiftyoneDegreesInterlockDoubleWidth Struct Reference

Detailed Description

Double width (64 or 128 depending on the architecture) compare and exchange.

Replaces the destination value with the exchange value, only if the destination value matched the comparand. Returns true if the value was exchanged.

Windows: Either InterlockedCompareExchange128 or InterlockedCompareExchange64 is used, depending on whether the source is compiled in 32 or 64 bit. InterlockedCompareExchange128 will use the cmpxchg16b instruction on modern Intel and AMD CPUs.

see: https://docs.microsoft.com/en-us/cpp/intrinsics/interlockedcompareexchange128?view=msvc-160

Linux: __atomic_compare_exchange is used regardless of architecture. The size of fiftyoneDegreesInterlockDoubleWidth dictates whether __atomic_compare_exchange_8 or __atomic_compare_exchange_16 will be called. The underlying implementation will depend on the hardware - either the compiler intrinsic will be used, or a library function if that is not available.

__atomic_compare_exchange_16 will use the cmpxchg16b on modern Intel and AMD CPUs. However, most ARM chips will not support this, so the fallback library function may not offer the same performance. Falling back to a library function may mean that the operation is not lock free. To check, see the FIFTYONE_DEGREES_IS_LOCK_FREE macro.

see: https://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_concurrency_impl.html

Parameters
d - the destination to swap
e - the exchange value
c - the comparand

Data Fields

int64_t  value

The documentation for this struct was generated from the following file:
  • /home/runner/work/device-detection-cxx/device-detection-cxx/common/device-detection-cxx/src/common-cxx/threading.h
On This Page