|
ReXGlue SDK
|
Classes | |
| struct | CrashReporterOptions |
| class | DynamicLibrary |
| class | Event |
| class | Exception |
| class | ExceptionHandler |
| class | Fence |
| struct | Fiber |
| class | HighResolutionTimer |
| class | HostCallDepth |
| class | HostThreadContext |
| class | InstanceLock |
| class | Mutant |
| struct | OpenFileLimit |
| class | Profiler |
| class | RankedMutex |
| class | RankedSharedMutex |
| struct | SEHScope |
| struct | SEHThreadState |
| class | Semaphore |
| class | Socket |
| struct | SocketWait |
| class | Thread |
| struct | ThreadPriority |
| class | Timer |
| struct | TimerQueueWaitItem |
| struct | VectorRegister |
| class | WaitHandle |
Typedefs | |
| using | LockOrderHandler = void (*)(LockRank held, LockRank acquiring) |
| using | CrashAddressDescriber = u32 (*)(u64 host_address, std::span<char> out) |
| using | SocketHandle = i64 |
| using | TLSHandle = u32 |
Enumerations | |
| enum class | SymbolResolution : u8 { kLazy , kImmediate } |
| enum class | ARM64Register : u8 { kX0 , kX1 , kX2 , kX3 , kX4 , kX5 , kX6 , kX7 , kX8 , kX9 , kX10 , kX11 , kX12 , kX13 , kX14 , kX15 , kX16 , kX17 , kX18 , kX19 , kX20 , kX21 , kX22 , kX23 , kX24 , kX25 , kX26 , kX27 , kX28 , kX29 , kX30 , kSP , kPC , kPstate , kFpsr , kFpcr , kV0 , kV1 , kV2 , kV3 , kV4 , kV5 , kV6 , kV7 , kV8 , kV9 , kV10 , kV11 , kV12 , kV13 , kV14 , kV15 , kV16 , kV17 , kV18 , kV19 , kV20 , kV21 , kV22 , kV23 , kV24 , kV25 , kV26 , kV27 , kV28 , kV29 , kV30 , kV31 } |
| enum class | HostRegister |
| enum class | ARM64LoadStoreOp : u32 { kSTRBW = UINT32_C(0x00000000) , kSTRHW = UINT32_C(0x40000000) , kSTRW = UINT32_C(0x80000000) , kSTRX = UINT32_C(0xC0000000) , kLDRBW = UINT32_C(0x00400000) , kLDRHW = UINT32_C(0x40400000) , kLDRW = UINT32_C(0x80400000) , kLDRX = UINT32_C(0xC0400000) , kLDRSBX = UINT32_C(0x00800000) , kLDRSHX = UINT32_C(0x40800000) , kLDRSWX = UINT32_C(0x80800000) , kLDRSBW = UINT32_C(0x00C00000) , kLDRSHW = UINT32_C(0x40C00000) , kSTRB = UINT32_C(0x04000000) , kSTRH = UINT32_C(0x44000000) , kSTRS = UINT32_C(0x84000000) , kSTRD = UINT32_C(0xC4000000) , kSTRQ = UINT32_C(0x04800000) , kLDRB = UINT32_C(0x04400000) , kLDRH = UINT32_C(0x44400000) , kLDRS = UINT32_C(0x84400000) , kLDRD = UINT32_C(0xC4400000) , kLDRQ = UINT32_C(0x04C00000) , kPRFM = UINT32_C(0xC0800000) } |
| enum class | ARM64LoadStoreOffsetFixed : u32 { kUnscaledOffset = UINT32_C(0x38000000) , kPostIndex = UINT32_C(0x38000400) , kPreIndex = UINT32_C(0x38000C00) , kRegisterOffset = UINT32_C(0x38200800) } |
| enum class | LockRank : u8 { kLeaf = 0xFF } |
| enum class | CounterID : u8 { kFrameTimeUs , kFps } |
| enum class | CounterType : u8 { kAccumulator , kGauge } |
| enum class | SocketReady : u8 { kNone = 0 , kRead = 1 << 0 , kWrite = 1 << 1 , kExcept = 1 << 2 } |
| enum class | WaitResult : u8 { kSuccess , kUserCallback , kTimeout , kAbandoned , kFailed } |
| enum class | SleepResult : u8 { kSuccess , kAlerted } |
Functions | |
| bool | IsARM64LoadPrefetchStore (u32 instruction, bool &is_store_out) |
| u64 | SignalPC (void *signal_context) |
| void | ReportFatalSignal (int signal_number, siginfo_t *info, void *signal_context) |
| void | ForwardSignal (struct sigaction &original, int signal_number, siginfo_t *info, void *signal_context) |
| void | DieWithDefaultDisposition (int signal_number) |
| std::filesystem::path | GetExecutablePath () |
| std::filesystem::path | GetExecutableFolder () |
| std::filesystem::path | GetLibraryFolder () |
| std::filesystem::path | GetUserFolder () |
| bool | IsPackagedApp () |
| std::filesystem::path | GetUserConfigFolder (std::string_view app_name) |
| std::filesystem::path | GetAppRoot (std::string_view app_name) |
| bool | IsDirectoryWritable (const std::filesystem::path &dir) |
| std::string | SanitizeFolderName (std::string_view name, std::string_view fallback="default") |
| Result< std::vector< u8 > > | ReadHostFile (const std::filesystem::path &path, u64 offset=0, u64 length=0) |
| Result< void > | WriteHostFile (const std::filesystem::path &path, std::span< const u8 > data) |
| Result< void > | WriteHostFile (const std::filesystem::path &path, std::string_view text) |
| std::filesystem::path | ResolveEntryCase (const std::filesystem::path &parent, std::string_view name) |
| bool | OpenStorageFile (std::fstream &file, const std::filesystem::path &path) |
| u64 | GetStorageFileSize (const std::filesystem::path &path) |
| size_t | ReadStorageFile (std::fstream &file, void *data, size_t size) |
| void | AppendStorageFile (std::fstream &file, const void *data, size_t size) |
| void | ResetStorageFile (std::fstream &file, const std::filesystem::path &path, u64 length) |
| LockOrderHandler | SetLockOrderHandler (LockOrderHandler handler) |
| void | PushLockRank (LockRank rank) |
| void | PopLockRank (LockRank rank) |
| Result< CounterID > | RegisterCounter (const char *name, CounterType type=CounterType::kAccumulator) |
| std::optional< CounterID > | FindCounter (std::string_view name) |
| const char * | GetCounterName (CounterID id) |
| void | SetCounter (CounterID id, i64 value) |
| void | IncrementCounter (CounterID id, i64 delta=1) |
| i64 | GetCounter (CounterID id) |
| void | ResetFrameCounters () |
| i64 | GetSnapshotCounter (CounterID id) |
| void | InitCounters () |
| void | SetCSVLogPath (const std::string &path) |
| void | WriteCSVFrame () |
| void | CloseCSV () |
| Result< void > | Relaunch (std::span< const std::string > args) |
| Result< void > | Relaunch (const std::filesystem::path &exe, std::span< const std::string > args, const std::filesystem::path &working_directory={}) |
| bool | CanRelaunch () |
| Result< OpenFileLimit > | RaiseOpenFileLimit () |
| std::string | DescribeResourceUse () |
| bool | IsTerminal (FILE *stream) |
| bool | EnableANSIEscapes (FILE *stream) |
| void | SetUTF8OutputCodePage () |
| bool | IsDebuggerAttached () |
| void | Break () |
| std::optional< std::string > | GetEnvironmentValue (std::string_view name) |
| bool | SetEnvironmentValue (std::string_view name, std::string_view value) |
| bool | UnsetEnvironmentValue (std::string_view name) |
| std::vector< std::pair< std::string, std::string > > | EnumerateEnvironment () |
| Result< void > | InstallCrashReporter (const CrashReporterOptions &options) |
| void | UninstallCrashReporter () |
| void | SetCrashAddressDescriber (CrashAddressDescriber describer) |
| void | PrepareThreadForCrash () |
| int | SocketClose (SocketHandle handle) |
| int | SocketIOCTL (SocketHandle handle, u32 cmd, u8 *arg) |
| int | SocketPrepare (SocketHandle handle, WaitHandle *event) |
| bool | IsSocketWouldBlock () |
| u32 | GetSocketError () |
| int | PollSockets (std::span< const SocketWait > sockets, std::span< SocketReady > ready) |
| WaitResult | WaitSockets (std::span< const SocketWait > sockets, bool alertable, std::chrono::milliseconds timeout) |
| WaitResult | Wait (WaitHandle *wait_handle, bool is_alertable, std::chrono::milliseconds timeout=std::chrono::milliseconds::max()) |
| WaitResult | SignalAndWait (WaitHandle *wait_handle_to_signal, WaitHandle *wait_handle_to_wait_on, bool is_alertable, std::chrono::milliseconds timeout=std::chrono::milliseconds::max()) |
| std::pair< WaitResult, size_t > | WaitMultiple (WaitHandle *wait_handles[], size_t wait_handle_count, bool wait_all, bool is_alertable, std::chrono::milliseconds timeout=std::chrono::milliseconds::max()) |
| WaitResult | WaitAll (WaitHandle *wait_handles[], size_t wait_handle_count, bool is_alertable, std::chrono::milliseconds timeout=std::chrono::milliseconds::max()) |
| WaitResult | WaitAll (std::vector< WaitHandle * > wait_handles, bool is_alertable, std::chrono::milliseconds timeout=std::chrono::milliseconds::max()) |
| std::pair< WaitResult, size_t > | WaitAny (WaitHandle *wait_handles[], size_t wait_handle_count, bool is_alertable, std::chrono::milliseconds timeout=std::chrono::milliseconds::max()) |
| std::pair< WaitResult, size_t > | WaitAny (std::vector< WaitHandle * > wait_handles, bool is_alertable, std::chrono::milliseconds timeout=std::chrono::milliseconds::max()) |
| u32 | GetLogicalProcessorCount () |
| void | WidenProcessAffinity () |
| u32 | GetCallerSystemThreadID () |
| u32 | GetCallerThreadID () |
| void | SetCallerThreadID (u32 id) |
| void | SetCurrentThreadName (const std::string_view name) |
| void | SetCurrentThreadPriority (i32 priority) |
| void | MaybeYield () |
| void | SyncMemory () |
| void | SleepFor (std::chrono::microseconds duration) |
| template<typename Rep, typename Period> | |
| void | SleepFor (std::chrono::duration< Rep, Period > duration) |
| std::chrono::milliseconds | GetCurrentThreadCPUTime () |
| SleepResult | AlertableSleep (std::chrono::microseconds duration) |
| template<typename Rep, typename Period> | |
| SleepResult | AlertableSleep (std::chrono::duration< Rep, Period > duration) |
| TLSHandle | AllocateTLSHandle () |
| bool | FreeTLSHandle (TLSHandle handle) |
| uintptr_t | GetTLSValue (TLSHandle handle) |
| bool | SetTLSValue (TLSHandle handle, uintptr_t value) |
| template<typename F> | |
| std::jthread | Spawn (std::string_view name, F &&fn) |
| std::weak_ptr< TimerQueueWaitItem > | QueueTimerOnce (std::function< void(void *)> callback, void *userdata, TimerQueueWaitItem::clock::time_point due) |
| std::weak_ptr< TimerQueueWaitItem > | QueueTimerRecurring (std::function< void(void *)> callback, void *userdata, TimerQueueWaitItem::clock::time_point due, TimerQueueWaitItem::clock::duration interval) |
| REX_PPC_API SEHThreadState & | GetSEHThreadState () |
| REX_PPC_API int | SEHFilter (u32 code, void *exception_pointers) |
| REX_PPC_API void | SEHRethrow () |
| REX_PPC_API void | SEHInitialize () |
| void | SEHEnter (SEHScope &scope) |
| void | SEHLeave (SEHScope &scope) |
Variables | |
| constexpr bool | kWindows = REX_PLATFORM_WIN32 |
| constexpr bool | kLinux = REX_PLATFORM_LINUX |
| constexpr bool | kMac = REX_PLATFORM_MAC |
| constexpr bool | kPosix = kLinux || kMac |
| constexpr char | kPathSeparator = '/' |
| constexpr u32 | kARM64LoadLiteralFMask = UINT32_C(0x3B000000) |
| constexpr u32 | kARM64LoadLiteralFixed = UINT32_C(0x18000000) |
| constexpr u32 | kARM64LoadStoreAnyFMask = UINT32_C(0x0A000000) |
| constexpr u32 | kARM64LoadStoreAnyFixed = UINT32_C(0x08000000) |
| constexpr u32 | kARM64LoadStorePairAnyFMask = UINT32_C(0x3A000000) |
| constexpr u32 | kARM64LoadStorePairAnyFixed = UINT32_C(0x28000000) |
| constexpr u32 | kARM64LoadStorePairLoadBit = UINT32_C(1) << 22 |
| constexpr u32 | kARM64LoadStoreMask = UINT32_C(0xC4C00000) |
| constexpr u32 | kARM64LoadStoreOffsetFMask = UINT32_C(0x3B200C00) |
| constexpr u32 | kARM64LoadStoreUnsignedOffsetFMask = UINT32_C(0x3B000000) |
| constexpr u32 | kARM64LoadStoreUnsignedOffsetFixed = UINT32_C(0x39000000) |
| constexpr size_t | kMaxCounters = 64 |
| constexpr SocketHandle | kInvalidSocket = -1 |
| constexpr TLSHandle | kInvalidTLSHandle = UINT_MAX |
Host threads, events, timers and other platform primitives.
| using rex::platform::CrashAddressDescriber = u32 (*)(u64 host_address, std::span<char> out) |
Writes a host fault address as title terms, such as a guest address or a register. Runs in a signal handler, so it must not allocate or lock.
| host_address | The fault address, or 0 when there is none. |
| out | Buffer for the text. |
| using rex::platform::LockOrderHandler = void (*)(LockRank held, LockRank acquiring) |
Receives an order violation in a debug build.
| held | The rank on top of the held stack. |
| acquiring | The rank being taken. |
| using rex::platform::SocketHandle = i64 |
Native socket handle widened to 64 bits, a SOCKET on Windows or a file descriptor on POSIX.
|
strong |
|
strong |
Single register load and store operations under kARM64LoadStoreMask.
|
strong |
|
strong |
Performance counter slots. A module registers its own counters with RegisterCounter.
|
strong |
|
strong |
Register enumeration of the host architecture, empty on other architectures.
|
strong |
A lock may be taken only when its rank is greater than every rank the thread holds. Modules define lower ranks as values of this type, for example LockRank kObjectTable{3};.
| Enumerator | |
|---|---|
| kLeaf | The highest rank. Nothing may be taken while it is held. |
|
strong |
|
strong |
|
strong |
|
strong |
| SleepResult rex::platform::AlertableSleep | ( | std::chrono::duration< Rep, Period > | duration | ) |
Sleeps the calling thread in an alertable state.
| SleepResult rex::platform::AlertableSleep | ( | std::chrono::microseconds | duration | ) |
Sleeps the calling thread in an alertable state. A queued user callback ends the sleep early.
| void rex::platform::Break | ( | ) |
Breaks into the attached debugger. Without one, POSIX raises SIGTRAP.
| bool rex::platform::CanRelaunch | ( | ) |
Reports whether the platform allows starting a new process.
|
nodiscard |
Reports the host resources this process uses, for logging when something runs out.
| void rex::platform::DieWithDefaultDisposition | ( | int | signal_number | ) |
Ends the process through the default disposition of a signal.
| bool rex::platform::EnableANSIEscapes | ( | FILE * | stream | ) |
Turns on ANSI escape sequence handling for a stream. Does nothing on POSIX.
| stream | Stream to configure, may be null. |
| std::vector< std::pair< std::string, std::string > > rex::platform::EnumerateEnvironment | ( | ) |
Lists every environment variable of the process.
| std::optional< CounterID > rex::platform::FindCounter | ( | std::string_view | name | ) |
Finds a registered counter.
| void rex::platform::ForwardSignal | ( | struct sigaction & | original, |
| int | signal_number, | ||
| siginfo_t * | info, | ||
| void * | signal_context ) |
Passes a signal no SDK handler claimed to the action it replaced. A default or ignored action, or the same fault 64 times in a row, ends in a report and the default disposition.
| original | The replaced action. Cleared to the default when it carries SA_RESETHAND. |
|
nodiscard |
Returns the folder an application keeps its writable files in, such as logs. Creates nothing. It is the executable folder, or GetUserConfigFolder when IsPackagedApp is true or the executable folder is not writable. It is empty when neither folder is usable.
| app_name | Application name used for the fallback folder. |
| u32 rex::platform::GetCallerSystemThreadID | ( | ) |
Returns the OS thread ID of the calling thread. For logs and diagnostics only.
| u32 rex::platform::GetCallerThreadID | ( | ) |
Equals GetCallerSystemThreadID() until SetCallerThreadID overrides it. Guest threads set it to their guest thread handle.
| i64 rex::platform::GetCounter | ( | CounterID | id | ) |
Returns the live value of a counter.
| const char * rex::platform::GetCounterName | ( | CounterID | id | ) |
| std::chrono::milliseconds rex::platform::GetCurrentThreadCPUTime | ( | ) |
Returns the CPU time the calling thread has used. It is kernel plus user time.
| std::optional< std::string > rex::platform::GetEnvironmentValue | ( | std::string_view | name | ) |
Reads an environment variable.
| name | Variable name, UTF-8. |
| std::filesystem::path rex::platform::GetExecutableFolder | ( | ) |
| std::filesystem::path rex::platform::GetExecutablePath | ( | ) |
| std::filesystem::path rex::platform::GetLibraryFolder | ( | ) |
Returns the folder the rexbase shared library was loaded from, which is where the SDK keeps its libraries and modules. It is the lib folder of an installed SDK on Linux and macOS, and the bin folder on Windows.
| REX_PPC_API SEHThreadState & rex::platform::GetSEHThreadState | ( | ) |
Returns the SEH state of the calling thread.
| i64 rex::platform::GetSnapshotCounter | ( | CounterID | id | ) |
Returns the value of a counter from the last snapshot, which stays stable between frames.
| u32 rex::platform::GetSocketError | ( | ) |
Returns the last socket error of the calling thread. WSAEINVAL when the host error has no WSA equivalent.
|
inline |
| uintptr_t rex::platform::GetTLSValue | ( | TLSHandle | handle | ) |
Reads the value the calling thread holds in a slot.
|
nodiscard |
Returns the host folder for per user configuration of an application. It is under roaming application data on Windows, Application Support on macOS, or XDG_CONFIG_HOME elsewhere with .config as the fallback. It is empty when no folder is found.
| app_name | The application name, passed through SanitizeFolderName. |
| std::filesystem::path rex::platform::GetUserFolder | ( | ) |
| void rex::platform::IncrementCounter | ( | CounterID | id, |
| i64 | delta = 1 ) |
Atomically adds to the live value of a counter.
| delta | The signed amount to add. |
| void rex::platform::InitCounters | ( | ) |
Zeroes every live and snapshot value.
|
nodiscard |
Installs the crash reporter, or replaces its options when installed. Prepares the calling thread.
| bool rex::platform::IsARM64LoadPrefetchStore | ( | u32 | instruction, |
| bool & | is_store_out ) |
Classifies an ARM64 instruction as a load, prefetch or store.
| instruction | The instruction word. |
| is_store_out | True for a store. Unchanged for a PC relative literal load or a false return. |
| bool rex::platform::IsDebuggerAttached | ( | ) |
Reports whether a debugger is attached. The check is expensive.
|
nodiscard |
Reports whether a file can be created in a folder.
|
nodiscard |
Reports whether the application runs from a read only package.
| bool rex::platform::IsSocketWouldBlock | ( | ) |
Reports whether the last socket call of the calling thread failed only because it would block.
| bool rex::platform::IsTerminal | ( | FILE * | stream | ) |
Reports whether a stream is attached to a terminal.
| stream | Stream to test, may be null. |
| void rex::platform::MaybeYield | ( | ) |
Yields the calling thread to the scheduler and issues a full memory barrier.
| bool rex::platform::OpenStorageFile | ( | std::fstream & | file, |
| const std::filesystem::path & | path ) |
Opens a storage file for reading and writing, creating it when missing.
| int rex::platform::PollSockets | ( | std::span< const SocketWait > | sockets, |
| std::span< SocketReady > | ready ) |
Reports the readiness of each socket without waiting.
| ready | Receives, for each socket, the requested readiness that is currently set. |
| void rex::platform::PrepareThreadForCrash | ( | ) |
Reserves the stack a report needs on the calling thread, so stack overflow reports work.
| void rex::platform::PushLockRank | ( | LockRank | rank | ) |
Pushes the rank of a lock being taken and reports an order violation in a debug build.
| std::weak_ptr< TimerQueueWaitItem > rex::platform::QueueTimerOnce | ( | std::function< void(void *)> | callback, |
| void * | userdata, | ||
| TimerQueueWaitItem::clock::time_point | due ) |
Queues a callback that runs once.
| callback | Function called on the dispatch thread. |
| std::weak_ptr< TimerQueueWaitItem > rex::platform::QueueTimerRecurring | ( | std::function< void(void *)> | callback, |
| void * | userdata, | ||
| TimerQueueWaitItem::clock::time_point | due, | ||
| TimerQueueWaitItem::clock::duration | interval ) |
Queues a callback that runs at due and then after each interval.
| callback | Function called on the dispatch thread. |
| interval | Repeat interval, 0 for a single run. |
|
nodiscard |
Raises the soft open file limit to the hard limit, or to 10240 when the hard limit is unlimited or refused. Windows has no such limit, gives zeros and changes nothing.
|
nodiscard |
Reads a host file into memory.
| offset | The first byte to read. An offset at the end gives an empty vector. |
| length | The byte count, 0 for all. A length past the end is a short read. |
| size_t rex::platform::ReadStorageFile | ( | std::fstream & | file, |
| void * | data, | ||
| size_t | size ) |
Reads bytes at the current read position.
|
nodiscard |
Registers a counter, or finds the one registered under the name. CSV columns follow registration order.
| name | The snake case name, shorter than 48 characters. |
| type | How ResetFrameCounters treats the counter. A repeated name keeps its first type. |
|
nodiscard |
Starts an executable as a new process and returns without waiting.
| args | Arguments after the executable. |
| working_directory | The start directory of the new process, the current one when empty. |
|
nodiscard |
Starts this executable again as a new process and returns without waiting.
| void rex::platform::ReportFatalSignal | ( | int | signal_number, |
| siginfo_t * | info, | ||
| void * | signal_context ) |
Writes a report for a fatal signal when the reporter is installed and no report has run.
| info | The signal info, or null. |
| signal_context | The ucontext of the fault, or null. |
| void rex::platform::ResetFrameCounters | ( | ) |
Copies every live value into the snapshot and zeroes the accumulators. Gauges keep theirs.
| void rex::platform::ResetStorageFile | ( | std::fstream & | file, |
| const std::filesystem::path & | path, | ||
| u64 | length ) |
Truncates a storage file and reopens it positioned at the end.
| file | Storage stream, closed and reopened in place. |
|
nodiscard |
Joins a name onto a folder, keeping the case of an existing entry that matches ignoring case.
| name | The entry name, a single path component. |
|
nodiscard |
Turns a name into a folder name that is safe on every host. Removes control characters and reserved punctuation, trims spaces and dots, and appends an underscore to Windows device names such as CON or COM1.
| fallback | The result when nothing is left of the name. |
|
inline |
Links a scope into the chain of the calling thread.
| scope | The scope REX_SEH_TRY opens. |
| REX_PPC_API int rex::platform::SEHFilter | ( | u32 | code, |
| void * | exception_pointers ) |
Filter for the Windows __except clause that captures the exception. Always 0 on POSIX.
| REX_PPC_API void rex::platform::SEHInitialize | ( | ) |
Installs the SIGSEGV, SIGBUS, SIGFPE and SIGILL handlers once on POSIX. No effect on Windows.
|
inline |
Unlinks a scope when it is still the innermost one.
| scope | The scope REX_SEH_TRY opened. |
| REX_PPC_API void rex::platform::SEHRethrow | ( | ) |
Raises the captured exception again. On POSIX it resumes the next open scope or ends the process.
| void rex::platform::SetCallerThreadID | ( | u32 | id | ) |
Overrides the ID GetCallerThreadID returns on the calling thread.
| void rex::platform::SetCrashAddressDescriber | ( | CrashAddressDescriber | describer | ) |
Sets the function the report calls to write the fault address as title terms.
| describer | The describer, or null for none. |
| void rex::platform::SetCSVLogPath | ( | const std::string & | path | ) |
Closes any open CSV log and opens a new one with a header row of counter names.
| path | The CSV file path. Empty closes logging. |
| void rex::platform::SetCurrentThreadName | ( | const std::string_view | name | ) |
Names the calling thread for debuggers and OS tools.
| name | Thread name, UTF-8. |
| void rex::platform::SetCurrentThreadPriority | ( | i32 | priority | ) |
Sets the priority of the calling thread, with the same mapping as Thread::SetPriority. A failure is logged and leaves the priority unchanged.
| priority | Usually a ThreadPriority value. |
| bool rex::platform::SetEnvironmentValue | ( | std::string_view | name, |
| std::string_view | value ) |
Sets an environment variable, replacing any existing value.
| name | Variable name, UTF-8. |
| value | New value, UTF-8. |
| LockOrderHandler rex::platform::SetLockOrderHandler | ( | LockOrderHandler | handler | ) |
Replaces the violation handler. The default handler asserts.
| handler | The new handler, or null to restore the default. |
| bool rex::platform::SetTLSValue | ( | TLSHandle | handle, |
| uintptr_t | value ) |
Writes the value the calling thread holds in a slot.
| void rex::platform::SetUTF8OutputCodePage | ( | ) |
Switches the process console output code page to UTF-8. Does nothing on POSIX.
| WaitResult rex::platform::SignalAndWait | ( | WaitHandle * | wait_handle_to_signal, |
| WaitHandle * | wait_handle_to_wait_on, | ||
| bool | is_alertable, | ||
| std::chrono::milliseconds | timeout = std::chrono::milliseconds::max() ) |
Signals an object and waits on another as one operation. A timeout of 0 polls and max() waits forever.
| is_alertable | True to let a queued user callback end the wait. |
| u64 rex::platform::SignalPC | ( | void * | signal_context | ) |
Returns the instruction pointer a signal interrupted.
| signal_context | The ucontext_t the signal handler receives. |
| void rex::platform::SleepFor | ( | std::chrono::microseconds | duration | ) |
Sleeps the calling thread for at least the duration. A duration of 0 yields.
| int rex::platform::SocketClose | ( | SocketHandle | handle | ) |
Closes a socket.
| int rex::platform::SocketIOCTL | ( | SocketHandle | handle, |
| u32 | cmd, | ||
| u8 * | arg ) |
Runs an ioctl request on a socket.
| arg | The argument buffer, read and written in place. |
| int rex::platform::SocketPrepare | ( | SocketHandle | handle, |
| WaitHandle * | event ) |
Makes a socket nonblocking and binds an event to its waits. On Windows the socket sets the event when it becomes ready.
| event | A manual reset event whose Set ends a WaitSockets on the socket. |
| std::jthread rex::platform::Spawn | ( | std::string_view | name, |
| F && | fn ) |
Starts a host thread the SDK tracks until it exits.
| F | Callable taking a std::stop_token. |
| name | Thread name shown in debuggers and logs. |
| void rex::platform::SyncMemory | ( | ) |
Issues a full memory barrier.
| void rex::platform::UninstallCrashReporter | ( | ) |
Removes the crash reporter and restores the handlers it replaced.
| bool rex::platform::UnsetEnvironmentValue | ( | std::string_view | name | ) |
Removes an environment variable.
| name | Variable name, UTF-8. |
| WaitResult rex::platform::Wait | ( | WaitHandle * | wait_handle, |
| bool | is_alertable, | ||
| std::chrono::milliseconds | timeout = std::chrono::milliseconds::max() ) |
Waits on one object. A timeout of 0 polls and max() waits forever.
| is_alertable | True to let a queued user callback end the wait. |
|
inline |
Waits until every object is signaled. A timeout of 0 polls and max() waits forever.
| is_alertable | True to let a queued user callback end the wait. |
|
inline |
Waits until every object is signaled. A timeout of 0 polls and max() waits forever.
| is_alertable | True to let a queued user callback end the wait. |
|
inline |
Waits until any object is signaled. A timeout of 0 polls and max() waits forever.
| is_alertable | True to let a queued user callback end the wait. |
|
inline |
Waits until any object is signaled. A timeout of 0 polls and max() waits forever.
| is_alertable | True to let a queued user callback end the wait. |
| std::pair< WaitResult, size_t > rex::platform::WaitMultiple | ( | WaitHandle * | wait_handles[], |
| size_t | wait_handle_count, | ||
| bool | wait_all, | ||
| bool | is_alertable, | ||
| std::chrono::milliseconds | timeout = std::chrono::milliseconds::max() ) |
Waits on several objects. A timeout of 0 polls and max() waits forever.
| is_alertable | True to let a queued user callback end the wait. |
| WaitResult rex::platform::WaitSockets | ( | std::span< const SocketWait > | sockets, |
| bool | alertable, | ||
| std::chrono::milliseconds | timeout ) |
Waits until a socket may be ready.
| alertable | True when a queued user callback ends the wait. |
| timeout | The longest wait, milliseconds::max() for no limit. |
| void rex::platform::WidenProcessAffinity | ( | ) |
Widens the process affinity to every processor. Does nothing on POSIX.
| void rex::platform::WriteCSVFrame | ( | ) |
Appends a row of snapshot values to the CSV log. The file is flushed every 60 rows.
|
nodiscard |
Replaces a host file atomically through a temporary file and a rename. Creates missing parent folders.
|
nodiscard |
Replaces a host file with text, as the span form does.
|
constexpr |
Mask for PC relative literal loads, which include PRFM_lit.
|
constexpr |
Selects the ARM64LoadStoreOp bits of a load or store.
|
constexpr |
Mask for the load and store offset addressing modes.
|
constexpr |
Bit set on the load form of a load or store pair.
|
constexpr |
Mask for the unsigned immediate offset addressing mode.
|
inlineconstexpr |
The number of counter slots, registered counters included.