mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-28 00:35:47 +00:00
feat(libc): forward pthread attributes in _Pad::_Launch
This commit is contained in:
1 parent
2e1c72239b
commit
1adc418e6e
4 files changed
+44
-4
No files matched your search
@@ -202,7 +202,10 @@ struct HostPadThread {
|
||||
void* result = nullptr;
|
||||
};
|
||||
|
||||
static int APS5_VABI HostPthreadCreate(void** thread, const void*, void* (APS5_VABI* entry)(void*), void* arg) {
|
||||
static const void* lastCreateAttrSlot = nullptr;
|
||||
|
||||
static int APS5_VABI HostPthreadCreate(void** thread, const void* attrSlot, void* (APS5_VABI* entry)(void*), void* arg) {
|
||||
lastCreateAttrSlot = attrSlot;
|
||||
auto* handle = new HostPadThread{};
|
||||
handle->worker = std::thread([handle, entry, arg] { handle->result = entry(arg); });
|
||||
*thread = handle;
|
||||
@@ -263,6 +266,7 @@ static void PadLaunchAndJoin() {
|
||||
_ZNSt4_Pad7_LaunchEPP7pthread_nid_postfix(reinterpret_cast<GuestPad*>(&pad), &thread);
|
||||
|
||||
Require(thread != nullptr && pad.started && pad.ran.load());
|
||||
Require(lastCreateAttrSlot == nullptr);
|
||||
_ZNSt4_PadD2Ev_nid_postfix(reinterpret_cast<GuestPad*>(&pad));
|
||||
|
||||
int code = 0;
|
||||
@@ -273,6 +277,32 @@ static void PadLaunchAndJoin() {
|
||||
RegisterPthreadJoin_nid_no_patch(nullptr);
|
||||
}
|
||||
|
||||
static void PadLaunchWithAttributes() {
|
||||
unsigned (APS5_VABI* vtable[1])(GuestPad*) = {TestPadGo};
|
||||
RegisterPthreadCreate_nid_no_patch(HostPthreadCreate);
|
||||
RegisterPthreadJoin_nid_no_patch(HostPthreadJoin);
|
||||
|
||||
TestPad pad{};
|
||||
pad.vtable = vtable;
|
||||
_ZNSt4_PadC2Ev_nid_postfix(reinterpret_cast<GuestPad*>(&pad));
|
||||
|
||||
int attribute = 0;
|
||||
void* attrSlot = &attribute;
|
||||
void* thread = nullptr;
|
||||
lastCreateAttrSlot = nullptr;
|
||||
_ZNSt4_Pad7_LaunchEPP12pthread_attrPP7pthread_nid_postfix(reinterpret_cast<GuestPad*>(&pad), &attrSlot, &thread);
|
||||
Require(thread != nullptr && pad.started && pad.ran.load());
|
||||
Require(attrSlot == &attribute);
|
||||
Require(lastCreateAttrSlot == &attrSlot);
|
||||
|
||||
_ZNSt4_PadD2Ev_nid_postfix(reinterpret_cast<GuestPad*>(&pad));
|
||||
int code = 0;
|
||||
Require(_Thrd_join_nid_postfix(thread, &code) == success && code == 42);
|
||||
|
||||
RegisterPthreadCreate_nid_no_patch(nullptr);
|
||||
RegisterPthreadJoin_nid_no_patch(nullptr);
|
||||
}
|
||||
|
||||
static void PadDetach() {
|
||||
unsigned (APS5_VABI* vtable[1])(GuestPad*) = {TestPadGo};
|
||||
RegisterPthreadDetach_nid_no_patch(nullptr);
|
||||
@@ -447,6 +477,7 @@ int main() {
|
||||
ConditionBroadcast();
|
||||
ConditionSignal();
|
||||
PadLaunchAndJoin();
|
||||
PadLaunchWithAttributes();
|
||||
PadDetach();
|
||||
ThreadHelpers();
|
||||
}
|
||||
Reference in new issue
Block a user