MPMT v1.7.4
atomic.h File Reference

Atomic operations. More...

#include <stdint.h>
#include <windows.h>

Macros

#define atomic_int32   volatile int32_t
 Integer type for atomic operations. (int32)
 
#define atomic_int64   volatile int64_t
 Integer type for atomic operations. (int64)
 
#define atomicFetchAdd32(memory, value)   InterlockedExchangeAdd(memory, value)
 Atomically adds the value to the variable that memory points to.
 
#define atomicFetchAdd64(memory, value)   InterlockedExchangeAdd64(memory, value)
 Atomically adds the value to the variable that memory points to.
 

Detailed Description

Atomic operations.

Atomic operations are used to perform certain operations in a way that is guaranteed to be indivisible and not subject to interruption by other threads. This is particularly useful in multithreaded programming to avoid race conditions and ensure correct behavior when multiple threads are concurrently accessing shared data.

Macro Definition Documentation

◆ atomicFetchAdd32

#define atomicFetchAdd32 ( memory,
value )   InterlockedExchangeAdd(memory, value)

Atomically adds the value to the variable that memory points to.

Result is stored in the address that is specified by memory.

Parameters
[in]memorypointer of a variable to which value is to be added.
valuevariable whose value is to be added to the variable that memory points to.
Returns
The initial value of the variable that memory points to.

◆ atomicFetchAdd64

#define atomicFetchAdd64 ( memory,
value )   InterlockedExchangeAdd64(memory, value)

Atomically adds the value to the variable that memory points to.

Result is stored in the address that is specified by memory.

Parameters
[in]memorypointer of a variable to which value is to be added.
valuevariable whose value is to be added to the variable that memory points to.
Returns
The initial value of the variable that memory points to.