orbis: implement initial guest signals support

This commit is contained in:
DH 2025-09-21 08:46:28 +03:00
parent 36b9e969c2
commit 70fa577a7b
12 changed files with 239 additions and 51 deletions

View file

@ -73,6 +73,7 @@ struct ProcessOps {
SysResult (*thr_kill2)(Thread *thread, pid_t pid, slong id, sint sig);
SysResult (*thr_suspend)(Thread *thread, ptr<const timespec> timeout);
SysResult (*thr_wake)(Thread *thread, slong id);
SysResult (*sigreturn)(Thread *thread, ptr<UContext> context);
SysResult (*thr_set_name)(Thread *thread, slong id, ptr<const char> name);
SysResult (*unmount)(Thread *thread, ptr<char> path, sint flags);

View file

@ -41,6 +41,8 @@ struct Thread {
kvector<SigInfo> queuedSignals;
shared_atomic32 suspendFlags{0};
utils::shared_atomic32 interruptedMtx{ 0 };
std::int64_t hostTid = -1;
lwpid_t tid = -1;
unsigned unblocked = 0;
@ -64,13 +66,14 @@ struct Thread {
// Print backtrace
void where();
void unblock();
void block();
bool unblock();
bool block();
void suspend();
void resume();
void sendSignal(int signo);
void notifyUnblockedSignal(int signo);
void setSigMask(SigSet newSigMask);
// FIXME: implement thread destruction
void incRef() {}

View file

@ -162,4 +162,10 @@ struct SigInfo {
} spare;
} reason;
};
struct SigFrame {
uint64_t handler;
UContext context;
SigInfo info;
};
} // namespace orbis

View file

@ -23,7 +23,7 @@ static constexpr auto kRelaxSpinCount = 12;
static constexpr auto kSpinCount = 16;
inline namespace utils {
inline thread_local void (*g_scopedUnblock)(bool) = nullptr;
inline thread_local bool (*g_scopedUnblock)(bool) = nullptr;
bool try_spin_wait(auto &&pred) {
for (std::size_t i = 0; i < kSpinCount; ++i) {