General system helper functions. More...
#include <system.h>
Public Types | |
enum | CPU_ExtensionPPC { altivec } |
enum | CPU_ExtensionX86 { mmx, mmx_ex, _3d_now, _3d_now_ex, sse, sse2, sse3, ssse3, sse4_a, sse4_1, sse4_2, xop, avx, aes, fma3, fma4 } |
Static Public Member Functions | |
static void * | aligned_alloc (size_t size, size_t alignment=16) |
Allocates aligned memory. More... | |
static void | aligned_free (void *ptr) |
Frees aligned memory. More... | |
static int | capture_stack_trace (int frames_to_skip, int max_frames, void **out_frames, unsigned int *out_hash=nullptr) |
Captures a stack back trace by walking up the stack and recording the information for each frame. More... | |
static bool | detect_cpu_extension (CPU_ExtensionX86 ext) |
static bool | detect_cpu_extension (CPU_ExtensionPPC ext) |
static std::string | exe_path () |
Returns the full dirname of the executable that started this. More... | |
static int64_t | microseconds () |
Get the current time microseconds. More... | |
static int | num_cores () |
Return the number of CPU cores. More... | |
static void | pause (int millis) |
Pause for 'millis' milliseconds. More... | |
static void | sleep (int millis) |
Sleep for 'millis' milliseconds. More... | |
static std::vector< std::string > | stack_frames_text (void **frames, int num_frames) |
Returns the function names and lines for the specified stack frame addresses. More... | |
static int64_t | time () |
Get the current time (since system boot), in milliseconds. More... | |
General system helper functions.
|
static |
Allocates aligned memory.
|
static |
Frees aligned memory.
|
static |
Captures a stack back trace by walking up the stack and recording the information for each frame.
|
static |
|
static |
|
static |
Returns the full dirname of the executable that started this.
process (aka argv[0])
This is necessary since when programms are started from the PATH there is no clean and simple way to figure out the location of the data files, thus information is read from /proc/self/exe
under GNU/Linux and from GetModuleFileName() on Win32.
|
static |
Get the current time microseconds.
|
static |
Return the number of CPU cores.
|
static |
Pause for 'millis' milliseconds.
This function acts as sleep, but the function "may" perform a spinlock on some operating systems to give a more accurate pause. This may have a side effect of causing 100% cpu usage. If you do not require an accurate pause, use sleep instead.
|
static |
Sleep for 'millis' milliseconds.
It is possible for this function to sleep for more than millis, depending on the OS scheduler. If you require a more accurate sleep, consider pause.
|
static |
Returns the function names and lines for the specified stack frame addresses.
On Linux, to obtain function names, remember to link with the -rdynamic flag
|
static |
Get the current time (since system boot), in milliseconds.