mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-29 22:20:48 +00:00
Implement _sys_qsort in sys_libc_.cpp (#4176)
This commit is contained in:
parent
7c0fd5094e
commit
1b26ec56ed
@ -12,6 +12,8 @@ extern fs::file g_tty;
|
|||||||
|
|
||||||
// cfmt implementation (TODO)
|
// cfmt implementation (TODO)
|
||||||
|
|
||||||
|
using qsortcmp = s32(vm::cptr<void> e1, vm::cptr<void> e2);
|
||||||
|
|
||||||
struct ps3_fmt_src
|
struct ps3_fmt_src
|
||||||
{
|
{
|
||||||
ppu_thread* ctx;
|
ppu_thread* ctx;
|
||||||
@ -452,9 +454,17 @@ s32 _sys_vsprintf()
|
|||||||
fmt::throw_exception("Unimplemented" HERE);
|
fmt::throw_exception("Unimplemented" HERE);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _sys_qsort()
|
void _sys_qsort(vm::ptr<void> base, u32 nelem, u32 size, vm::ptr<qsortcmp> cmp)
|
||||||
{
|
{
|
||||||
fmt::throw_exception("Unimplemented" HERE);
|
sysPrxForUser.warning("_sys_qsort(base=*0x%x, nelem=%d, size=0x%x, cmp=*0x%x)", base, nelem, size, cmp);
|
||||||
|
|
||||||
|
static thread_local decltype(cmp) g_tls_cmp;
|
||||||
|
g_tls_cmp = cmp;
|
||||||
|
|
||||||
|
std::qsort(base.get_ptr(), nelem, size, [](const void* a, const void* b) -> s32
|
||||||
|
{
|
||||||
|
return g_tls_cmp(static_cast<ppu_thread&>(*get_current_cpu_thread()), vm::get_addr(a), vm::get_addr(b));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void sysPrxForUser_sys_libc_init()
|
void sysPrxForUser_sys_libc_init()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user