MPMT v1.8.0
atomic.h File Reference

Atomic operations. More...

#include <intrin.h>
#include <windows.h>

Macros

#define atomic_int8   volatile CHAR
 Integer type for atomic operations. (int8)
#define atomic_int16   volatile SHORT
 Integer type for atomic operations. (int16)
#define atomic_int32   volatile LONG
 Integer type for atomic operations. (int32)
#define atomic_int64   volatile LONG64
 Integer type for atomic operations. (int64)
#define atomicExchange8(memory, value)
 Atomically exchanges the value of the variable that memory points to.
#define atomicExchange16(memory, value)
 Atomically exchanges the value of the variable that memory points to.
#define atomicExchange32(memory, value)
 Atomically exchanges the value of the variable that memory points to.
#define atomicExchange64(memory, value)
 Atomically exchanges the value of the variable that memory points to.
#define atomicFetchAnd8(memory, value)
 Atomically performs AND operation to the variable that memory points to.
#define atomicFetchAnd16(memory, value)
 Atomically performs AND operation to the variable that memory points to.
#define atomicFetchAnd32(memory, value)
 Atomically performs AND operation to the variable that memory points to.
#define atomicFetchAnd64(memory, value)
 Atomically performs AND operation to the variable that memory points to.
#define atomicFetchOr8(memory, value)
 Atomically performs OR operation to the variable that memory points to.
#define atomicFetchOr16(memory, value)
 Atomically performs OR operation to the variable that memory points to.
#define atomicFetchOr32(memory, value)
 Atomically performs OR operation to the variable that memory points to.
#define atomicFetchOr64(memory, value)
 Atomically performs OR operation to the variable that memory points to.
#define atomicFetchXor8(memory, value)
 Atomically performs XOR operation to the variable that memory points to.
#define atomicFetchXor16(memory, value)
 Atomically performs XOR operation to the variable that memory points to.
#define atomicFetchXor32(memory, value)
 Atomically performs XOR operation to the variable that memory points to.
#define atomicFetchXor64(memory, value)
 Atomically performs XOR operation to the variable that memory points to.
#define atomicFetchAdd8(memory, value)
 Atomically adds the value to the variable that memory points to.
#define atomicFetchAdd16(memory, value)
 Atomically adds the value to the variable that memory points to.
#define atomicFetchAdd32(memory, value)
 Atomically adds the value to the variable that memory points to.
#define atomicFetchAdd64(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

◆ atomicExchange8

#define atomicExchange8 ( memory,
value )
Value:
_InterlockedExchange8(memory, value)

Atomically exchanges the value of the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the value is to be written
valuevariable whose value is to be written to the variable that memory points to

◆ atomicExchange16

#define atomicExchange16 ( memory,
value )
Value:
_InterlockedExchange16(memory, value)

Atomically exchanges the value of the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the value is to be written
valuevariable whose value is to be written to the variable that memory points to

◆ atomicExchange32

#define atomicExchange32 ( memory,
value )
Value:
_InterlockedExchange(memory, value)

Atomically exchanges the value of the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the value is to be written
valuevariable whose value is to be written to the variable that memory points to

◆ atomicExchange64

#define atomicExchange64 ( memory,
value )
Value:
_InterlockedExchange64(memory, value)

Atomically exchanges the value of the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the value is to be written
valuevariable whose value is to be written to the variable that memory points to

◆ atomicFetchAnd8

#define atomicFetchAnd8 ( memory,
value )
Value:
_InterlockedAnd8(memory, value)

Atomically performs AND operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the AND operation is to be performed
valuevariable whose value is to be used for an AND operation

◆ atomicFetchAnd16

#define atomicFetchAnd16 ( memory,
value )
Value:
_InterlockedAnd16(memory, value)

Atomically performs AND operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the AND operation is to be performed
valuevariable whose value is to be used for an AND operation

◆ atomicFetchAnd32

#define atomicFetchAnd32 ( memory,
value )
Value:
_InterlockedAnd(memory, value)

Atomically performs AND operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the AND operation is to be performed
valuevariable whose value is to be used for an AND operation

◆ atomicFetchAnd64

#define atomicFetchAnd64 ( memory,
value )
Value:
_InterlockedAnd64(memory, value)

Atomically performs AND operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the AND operation is to be performed
valuevariable whose value is to be used for an AND operation

◆ atomicFetchOr8

#define atomicFetchOr8 ( memory,
value )
Value:
_InterlockedOr8(memory, value)

Atomically performs OR operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the OR operation is to be performed
valuevariable whose value is to be used for an OR operation

◆ atomicFetchOr16

#define atomicFetchOr16 ( memory,
value )
Value:
_InterlockedOr16(memory, value)

Atomically performs OR operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the OR operation is to be performed
valuevariable whose value is to be used for an OR operation

◆ atomicFetchOr32

#define atomicFetchOr32 ( memory,
value )
Value:
_InterlockedOr(memory, value)

Atomically performs OR operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the OR operation is to be performed
valuevariable whose value is to be used for an OR operation

◆ atomicFetchOr64

#define atomicFetchOr64 ( memory,
value )
Value:
_InterlockedOr64(memory, value)

Atomically performs OR operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the OR operation is to be performed
valuevariable whose value is to be used for an OR operation

◆ atomicFetchXor8

#define atomicFetchXor8 ( memory,
value )
Value:
_InterlockedXor8(memory, value)

Atomically performs XOR operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the XOR operation is to be performed
valuevariable whose value is to be used for an XOR operation

◆ atomicFetchXor16

#define atomicFetchXor16 ( memory,
value )
Value:
_InterlockedXor16(memory, value)

Atomically performs XOR operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the XOR operation is to be performed
valuevariable whose value is to be used for an XOR operation

◆ atomicFetchXor32

#define atomicFetchXor32 ( memory,
value )
Value:
_InterlockedXor(memory, value)

Atomically performs XOR operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the XOR operation is to be performed
valuevariable whose value is to be used for an XOR operation

◆ atomicFetchXor64

#define atomicFetchXor64 ( memory,
value )
Value:
_InterlockedXor64(memory, value)

Atomically performs XOR operation to the variable that memory points to.

Returns
The current value of the variable that memory points to.
Parameters
[in,out]memorypointer of a variable to which the XOR operation is to be performed
valuevariable whose value is to be used for an XOR operation

◆ atomicFetchAdd8

#define atomicFetchAdd8 ( memory,
value )
Value:
_InterlockedExchangeAdd8(memory, value)

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

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

◆ atomicFetchAdd16

#define atomicFetchAdd16 ( memory,
value )
Value:
_InterlockedExchangeAdd16(memory, value)

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

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

◆ atomicFetchAdd32

#define atomicFetchAdd32 ( memory,
value )
Value:
_InterlockedExchangeAdd(memory, value)

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

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

◆ atomicFetchAdd64

#define atomicFetchAdd64 ( memory,
value )
Value:
_InterlockedExchangeAdd64(memory, value)

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

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