Volatile Intrinsics (The GNU D Compiler)

#### 2.5.5 Volatile Intrinsics ¶

The following functions are a collection of intrinsics for volatile operations, available by importing the `core.volatile` module.

Calls to them are guaranteed to not be removed (as dead assignment elimination or presumed to have no effect) or reordered in the same thread.

These reordering guarantees are only made with regards to other operations done through these functions; the compiler is free to reorder regular loads/stores with regards to loads/stores done through these functions.

This is useful when dealing with memory-mapped I/O (MMIO) where a store can have an effect other than just writing a value, or where sequential loads with no intervening stores can retrieve different values from the same location due to external stores to the location.

These functions will, when possible, do the load/store as a single operation. In general, this is possible when the size of the operation is less than or equal to `(void*).sizeof`, although some targets may support larger operations. If the load/store cannot be done as a single operation, multiple smaller operations will be used.

These are not to be conflated with atomic operations. They do not guarantee any atomicity. This may be provided by coincidence as a result of the instructions used on the target, but this should not be relied on for portable programs. Further, no memory fences are implied by these functions. They should not be used for communication between threads. They may be used to guarantee a write or read cycle occurs at a specified address.

Function: `ubyte` core.volatile.volatileLoad `(ubyte* ptr)` ¶
Function: `ushort` core.volatile.volatileLoad `(ushort* ptr)` ¶
Function: `uint` core.volatile.volatileLoad `(uint* ptr)` ¶
Function: `ulong` core.volatile.volatileLoad `(ulong* ptr)` ¶

  Read value from the memory location indicated by ptr.

Function: `ubyte` core.volatile.volatileStore `(ubyte* ptr, ubyte value)` ¶
Function: `ushort` core.volatile.volatileStore `(ushort* ptr, ushort value)` ¶
Function: `uint` core.volatile.volatileStore `(uint* ptr, uint value)` ¶
Function: `ulong` core.volatile.volatileStore `(ulong* ptr, ulong value)` ¶

  Write value to the memory location indicated by ptr.