Pyrogenesis  trunk
Namespaces | Functions | Variables
cpu.h File Reference
#include "lib/sysdep/compiler.h"
Include dependency graph for cpu.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 ERR
 

Introduction


 

Functions

const char * cpu_IdentifierString ()
 
intptr_t cpu_AtomicAdd (volatile intptr_t *location, intptr_t increment)
 add a signed value to a variable without the possibility of interference from other threads/CPUs. More...
 
bool cpu_CAS (volatile intptr_t *location, intptr_t expected, intptr_t newValue)
 atomic "compare and swap". More...
 
bool cpu_CAS64 (volatile i64 *location, i64 expected, i64 newValue)
 
template<typename T >
bool cpu_CAS (volatile T *location, T expected, T new_value)
 specialization of cpu_CAS for pointer types. More...
 
void cpu_Test ()
 
void cpu_Pause ()
 pause in spin-wait loops, as a performance optimisation. More...
 

Variables

const Status ERR::CPU_FEATURE_MISSING = -130000
 
const Status ERR::CPU_UNKNOWN_OPCODE = -130001
 
const Status ERR::CPU_UNKNOWN_VENDOR = -130002
 

Function Documentation

◆ cpu_AtomicAdd()

intptr_t cpu_AtomicAdd ( volatile intptr_t *  location,
intptr_t  increment 
)

add a signed value to a variable without the possibility of interference from other threads/CPUs.

Returns
the previous value.

add a signed value to a variable without the possibility of interference from other threads/CPUs.

◆ cpu_CAS() [1/2]

bool cpu_CAS ( volatile intptr_t *  location,
intptr_t  expected,
intptr_t  newValue 
)

atomic "compare and swap".

Parameters
locationaddress of the word to compare and possibly overwrite
expectedits expected value
newValuethe value with which to replace it
Returns
false if the target word doesn't match the expected value, otherwise true (also overwriting the contents of location)

◆ cpu_CAS() [2/2]

template<typename T >
bool cpu_CAS ( volatile T location,
T  expected,
T  new_value 
)
inline

specialization of cpu_CAS for pointer types.

this avoids error-prone casting in user code.

◆ cpu_CAS64()

bool cpu_CAS64 ( volatile i64 location,
i64  expected,
i64  newValue 
)

◆ cpu_IdentifierString()

const char* cpu_IdentifierString ( )
Returns
string identifying the CPU (usually a cleaned-up version of the brand string)

◆ cpu_Pause()

void cpu_Pause ( )
inline

pause in spin-wait loops, as a performance optimisation.

◆ cpu_Test()

void cpu_Test ( )