pub unsafe extern "C" fn CPLAtomicCompareAndExchange(
    ptr: *mut c_int,
    oldval: c_int,
    newval: c_int
) -> c_int
Expand description

Compares *ptr with oldval. If *ptr == oldval, then *ptr is assigned newval and TRUE is returned. Otherwise nothing is done, and FALSE is returned.

Current platforms/architectures where an efficient implementation exists are MacOSX, MS Windows, i386/x86_64 with GCC and platforms supported by GCC 4.1 or higher. For other platforms supporting the pthread library, and when GDAL is configured with thread-support, the atomicity will be done with a mutex, but with reduced efficiency. For the remaining platforms, a simple compare and exchange with no locking will be done…

@param ptr a pointer to an integer (aligned on 32bit boundary). @param oldval old value @param newval new value @return TRUE if the exchange has been done