mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-07 11:13:15 +00:00
thread: Configure stack and guard on POSIX hosts. (#1664)
This commit is contained in:
parent
920acb8d8b
commit
c019b54fec
3 changed files with 9 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "libraries/kernel/threads/pthread.h"
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef _WIN64
|
||||
|
@ -15,7 +16,7 @@ Thread::Thread() : native_handle{0} {}
|
|||
|
||||
Thread::~Thread() {}
|
||||
|
||||
int Thread::Create(ThreadFunc func, void* arg) {
|
||||
int Thread::Create(ThreadFunc func, void* arg, const ::Libraries::Kernel::PthreadAttr* attr) {
|
||||
#ifdef _WIN64
|
||||
native_handle = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, nullptr);
|
||||
return native_handle ? 0 : -1;
|
||||
|
@ -23,6 +24,7 @@ int Thread::Create(ThreadFunc func, void* arg) {
|
|||
pthread_t* pthr = reinterpret_cast<pthread_t*>(&native_handle);
|
||||
pthread_attr_t pattr;
|
||||
pthread_attr_init(&pattr);
|
||||
pthread_attr_setstack(&pattr, attr->stackaddr_attr, attr->stacksize_attr);
|
||||
return pthread_create(pthr, &pattr, (PthreadFunc)func, arg);
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue