mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 23:00:17 +02:00
Previously: Would keep one clone thread's stack active for teardown delaying. With aggressive cloning and teardown, this was unsafe. Only reap the stack when told it is safe to do so.
38 lines
981 B
C++
38 lines
981 B
C++
// SPDX-License-Identifier: MIT
|
|
#pragma once
|
|
|
|
#include <cstddef>
|
|
|
|
namespace FEX::LinuxEmulation::Threads {
|
|
/**
|
|
* @brief Size of the stack that this interface creates.
|
|
*/
|
|
constexpr size_t STACK_SIZE = 8 * 1024 * 1024;
|
|
|
|
/**
|
|
* @brief Allocates a stack object from the internally managed stack pool.
|
|
*/
|
|
void *AllocateStackObject();
|
|
|
|
/**
|
|
* @brief Deallocates a stack from the internally managed stack pool.
|
|
*
|
|
* Will not free the memory immediately, instead saving for reuse temporarily to solve race conditions on stack usage while stack tears down.
|
|
*
|
|
* @param Ptr The stack base from `AllocateStackObject`
|
|
* @param Status The status to pass to the exit syscall.
|
|
*/
|
|
[[noreturn]]
|
|
void DeallocateStackObjectAndExit(void *Ptr, int Status);
|
|
|
|
/**
|
|
* @brief Registers thread creation handlers with FEXCore.
|
|
*/
|
|
void SetupThreadHandlers();
|
|
|
|
/**
|
|
* @brief Cleans up any remaining stack objects in the pools.
|
|
*/
|
|
void Shutdown();
|
|
}
|