Skip to content

Volatile

Spice
import "std/os/volatile";

Functions

volatileLoad

Spice
public inline f<T> volatileLoad<T>(const T* ptr)

Read the value behind the given pointer with a volatile load. The optimizer never elides, duplicates or reorders it against other volatile accesses, e.g. for reading memory-mapped I/O registers. Note: This is no synchronization primitive. Use std/os/atomic or std/os/mutex for sharing data between threads.

Parameters

Name Type Description
ptr const T* Pointer to a value of primitive, enum or pointer type

Returns: T — Loaded value

volatileStore

Spice
public inline p volatileStore<T>(T* ptr, T value)

Write the given value to the given pointer with a volatile store. The optimizer never elides, duplicates or reorders it against other volatile accesses, e.g. for writing memory-mapped I/O registers. Note: This is no synchronization primitive. Use std/os/atomic or std/os/mutex for sharing data between threads.

Parameters

Name Type Description
ptr T* Pointer to a value of primitive, enum or pointer type
value T Value to store