mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-31 14:35:19 +00:00
resolve suggestions
- `using` definition replacement for AppHeapAPI - linux uses heap_malloc, windows uses std::malloc
This commit is contained in:
parent
03bf26f091
commit
70fa3cadcc
@ -305,6 +305,7 @@ void* Linker::TlsGetAddr(u64 module_index, u64 offset) {
|
|||||||
// Module was just loaded by above code. Allocate TLS block for it.
|
// Module was just loaded by above code. Allocate TLS block for it.
|
||||||
Module* module = m_modules[module_index - 1].get();
|
Module* module = m_modules[module_index - 1].get();
|
||||||
const u32 init_image_size = module->tls.init_image_size;
|
const u32 init_image_size = module->tls.init_image_size;
|
||||||
|
// TODO: Determine if Windows will crash from this
|
||||||
u8* dest = reinterpret_cast<u8*>(heap_api->heap_malloc(module->tls.image_size));
|
u8* dest = reinterpret_cast<u8*>(heap_api->heap_malloc(module->tls.image_size));
|
||||||
const u8* src = reinterpret_cast<const u8*>(module->tls.image_virtual_addr);
|
const u8* src = reinterpret_cast<const u8*>(module->tls.image_virtual_addr);
|
||||||
std::memcpy(dest, src, init_image_size);
|
std::memcpy(dest, src, init_image_size);
|
||||||
@ -336,9 +337,13 @@ void Linker::InitTlsForThread(bool is_primary) {
|
|||||||
ASSERT_MSG(ret == 0, "Unable to allocate TLS+TCB for the primary thread");
|
ASSERT_MSG(ret == 0, "Unable to allocate TLS+TCB for the primary thread");
|
||||||
} else {
|
} else {
|
||||||
if (heap_api) {
|
if (heap_api) {
|
||||||
|
#ifndef WIN32
|
||||||
|
addr_out = heap_api->heap_malloc(total_tls_size);
|
||||||
|
} else {
|
||||||
|
addr_out = std::malloc(total_tls_size);
|
||||||
|
#else
|
||||||
|
// TODO: Windows tls malloc replacement, refer to rtld_tls_block_malloc
|
||||||
LOG_ERROR(Core_Linker, "TLS user malloc called, using std::malloc");
|
LOG_ERROR(Core_Linker, "TLS user malloc called, using std::malloc");
|
||||||
// TODO: ref rtld_tls_block_malloc, tls malloc replacement
|
|
||||||
// addr_out = heap_api->heap_malloc(total_tls_size);
|
|
||||||
addr_out = std::malloc(total_tls_size);
|
addr_out = std::malloc(total_tls_size);
|
||||||
if (!addr_out) {
|
if (!addr_out) {
|
||||||
auto pth_id = pthread_self();
|
auto pth_id = pthread_self();
|
||||||
@ -347,6 +352,7 @@ void Linker::InitTlsForThread(bool is_primary) {
|
|||||||
"Cannot allocate TLS block defined for handle=%x, index=%d size=%d",
|
"Cannot allocate TLS block defined for handle=%x, index=%d size=%d",
|
||||||
handle, pth_id, total_tls_size);
|
handle, pth_id, total_tls_size);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ struct HeapAPI {
|
|||||||
PS4_SYSV_ABI size_t (*heap_malloc_usable_size)(void*);
|
PS4_SYSV_ABI size_t (*heap_malloc_usable_size)(void*);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef HeapAPI* AppHeapAPI;
|
using AppHeapAPI = HeapAPI*;
|
||||||
|
|
||||||
class Linker {
|
class Linker {
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user