mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-02-17 19:10:07 +00:00
thread: Configure stack and guard on POSIX hosts. (#1664)
This commit is contained in:
parent
920acb8d8b
commit
c019b54fec
src/core
|
@ -281,7 +281,7 @@ int PS4_SYSV_ABI posix_pthread_create_name_np(PthreadT* thread, const PthreadAtt
|
||||||
|
|
||||||
/* Create thread */
|
/* Create thread */
|
||||||
new_thread->native_thr = Core::Thread();
|
new_thread->native_thr = Core::Thread();
|
||||||
int ret = new_thread->native_thr.Create(RunThread, new_thread);
|
int ret = new_thread->native_thr.Create(RunThread, new_thread, &new_thread->attr);
|
||||||
ASSERT_MSG(ret == 0, "Failed to create thread with error {}", ret);
|
ASSERT_MSG(ret == 0, "Failed to create thread with error {}", ret);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
*thread = nullptr;
|
*thread = nullptr;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "libraries/kernel/threads/pthread.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
|
@ -15,7 +16,7 @@ Thread::Thread() : native_handle{0} {}
|
||||||
|
|
||||||
Thread::~Thread() {}
|
Thread::~Thread() {}
|
||||||
|
|
||||||
int Thread::Create(ThreadFunc func, void* arg) {
|
int Thread::Create(ThreadFunc func, void* arg, const ::Libraries::Kernel::PthreadAttr* attr) {
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
native_handle = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, nullptr);
|
native_handle = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, nullptr);
|
||||||
return native_handle ? 0 : -1;
|
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_t* pthr = reinterpret_cast<pthread_t*>(&native_handle);
|
||||||
pthread_attr_t pattr;
|
pthread_attr_t pattr;
|
||||||
pthread_attr_init(&pattr);
|
pthread_attr_init(&pattr);
|
||||||
|
pthread_attr_setstack(&pattr, attr->stackaddr_attr, attr->stacksize_attr);
|
||||||
return pthread_create(pthr, &pattr, (PthreadFunc)func, arg);
|
return pthread_create(pthr, &pattr, (PthreadFunc)func, arg);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
|
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
|
namespace Libraries::Kernel {
|
||||||
|
struct PthreadAttr;
|
||||||
|
} // namespace Libraries::Kernel
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class Thread {
|
class Thread {
|
||||||
|
@ -15,7 +19,7 @@ public:
|
||||||
Thread();
|
Thread();
|
||||||
~Thread();
|
~Thread();
|
||||||
|
|
||||||
int Create(ThreadFunc func, void* arg);
|
int Create(ThreadFunc func, void* arg, const ::Libraries::Kernel::PthreadAttr* attr);
|
||||||
void Exit();
|
void Exit();
|
||||||
|
|
||||||
uintptr_t GetHandle() {
|
uintptr_t GetHandle() {
|
||||||
|
|
Loading…
Reference in a new issue