diff --git a/stepmania/src/archutils/Darwin/DarwinThreadHelpers.cpp b/stepmania/src/archutils/Darwin/DarwinThreadHelpers.cpp new file mode 100644 index 0000000000..10fdf0e827 --- /dev/null +++ b/stepmania/src/archutils/Darwin/DarwinThreadHelpers.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include "Backtrace.h" + +bool SuspendThread(uint64_t threadHandle) +{ + return !thread_suspend(thread_act_t(threadHandle)); +} + +bool ResumeThread(uint64_t threadHandle) +{ + return !thread_resume(thread_act_t(threadHandle)); +} + +uint64_t GetCurrentThreadId() +{ + return mach_thread_self(); +} + +bool GetThreadBacktraceContext(int iCrashHandle, BacktraceContext *ctx) +{ + thread_act_t thread = thread_act_t(iCrashHandle); + ppc_thread_state state; + mach_msg_type_number_t count = PPC_THREAD_STATE_COUNT; + + if (thread_get_state(thread, PPC_THREAD_STATE, thread_state_t(&state), + &count)) + return false; + ctx->FramePtr = (void *)state.r1; + ctx->PC = (void *)state.srr0; + return true; +} + diff --git a/stepmania/src/archutils/Darwin/DarwinThreadHelpers.h b/stepmania/src/archutils/Darwin/DarwinThreadHelpers.h new file mode 100644 index 0000000000..be61e62a21 --- /dev/null +++ b/stepmania/src/archutils/Darwin/DarwinThreadHelpers.h @@ -0,0 +1,8 @@ +#ifndef DARWIN_THREAD_HELPERS_H +#define DARWIN_THREAD_HELPERS_H + +bool SuspendThread(uint64_t threadHandle); +bool ResumeThread(uint64_t threadHandle); +uint64_t GetCurrentThreadId(); + +#endif