mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
add Linux support
This commit is contained in:
@@ -3,13 +3,13 @@
|
||||
#include "Kyty/Core/String.h"
|
||||
#include "Kyty/Core/Threads.h"
|
||||
#include "Kyty/Core/Vector.h"
|
||||
#include "Kyty/Core/VirtualMemory.h"
|
||||
#include "Kyty/Sys/SysDbg.h"
|
||||
|
||||
#include "Emulator/Common.h"
|
||||
#include "Emulator/Kernel/Memory.h"
|
||||
#include "Emulator/Libs/Libs.h"
|
||||
#include "Emulator/Loader/SymbolDatabase.h"
|
||||
#include "Emulator/Loader/VirtualMemory.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -68,8 +68,8 @@ static void AllocShadow(uintptr_t min_addr, uintptr_t max_addr)
|
||||
|
||||
auto size = max_shadow - min_shadow + page_size;
|
||||
|
||||
printf("\t shadow = %016" PRIx64 "\n", reinterpret_cast<uint64_t>(min_shadow));
|
||||
printf("\t size = %016" PRIx64 "\n", reinterpret_cast<uint64_t>(size));
|
||||
printf("\t shadow = %016" PRIx64 "\n", static_cast<uint64_t>(min_shadow));
|
||||
printf("\t size = %016" PRIx64 "\n", static_cast<uint64_t>(size));
|
||||
|
||||
for (uintptr_t page = min_shadow; page <= max_shadow; page += page_size)
|
||||
{
|
||||
@@ -78,7 +78,7 @@ static void AllocShadow(uintptr_t min_addr, uintptr_t max_addr)
|
||||
g_ctx->shadows[index].count++;
|
||||
} else
|
||||
{
|
||||
if (!Loader::VirtualMemory::AllocFixed(page, page_size, Loader::VirtualMemory::Mode::ReadWrite))
|
||||
if (!Core::VirtualMemory::AllocFixed(page, page_size, Core::VirtualMemory::Mode::ReadWrite))
|
||||
{
|
||||
EXIT("can't allocate shadow memory\n");
|
||||
}
|
||||
@@ -104,8 +104,8 @@ static void FreeShadow(uintptr_t min_addr, uintptr_t max_addr)
|
||||
|
||||
auto size = max_shadow - min_shadow + page_size;
|
||||
|
||||
printf("\t shadow = %016" PRIx64 "\n", reinterpret_cast<uint64_t>(min_shadow));
|
||||
printf("\t size = %016" PRIx64 "\n", reinterpret_cast<uint64_t>(size));
|
||||
printf("\t shadow = %016" PRIx64 "\n", static_cast<uint64_t>(min_shadow));
|
||||
printf("\t size = %016" PRIx64 "\n", static_cast<uint64_t>(size));
|
||||
|
||||
for (uintptr_t page = min_shadow; page <= max_shadow; page += page_size)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ static void FreeShadow(uintptr_t min_addr, uintptr_t max_addr)
|
||||
|
||||
if (g_ctx->shadows[index].count <= 0)
|
||||
{
|
||||
if (!Loader::VirtualMemory::Free(page))
|
||||
if (!Core::VirtualMemory::Free(page))
|
||||
{
|
||||
EXIT("can't free shadow memory\n");
|
||||
}
|
||||
@@ -147,7 +147,11 @@ static void KYTY_SYSV_ABI asan_init()
|
||||
sys_dbg_stack_info_t s {};
|
||||
sys_stack_usage(s);
|
||||
|
||||
#if KYTY_PLATFORM == KYTY_PLATFORM_LINUX
|
||||
AllocShadow(s.addr, reinterpret_cast<uintptr_t>(&s));
|
||||
#else
|
||||
AllocShadow(s.reserved_addr, reinterpret_cast<uintptr_t>(&s));
|
||||
#endif
|
||||
|
||||
LibKernel::Memory::RegisterCallbacks(KernelAlloc, KernelFree);
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ static size_t _etoa(out_fct_type out, Vector<char>* buffer, size_t idx, size_t m
|
||||
int expval = static_cast<int>(0.1760912590558 + exp2 * 0.301029995663981 + (conv.F - 1.5) * 0.289529654602168);
|
||||
// now we want to compute 10^expval but we want to be sure it won't overflow
|
||||
// exp2 = static_cast<int>(expval * 3.321928094887362 + 0.5);
|
||||
exp2 = lround(expval * 3.321928094887362);
|
||||
exp2 = static_cast<int>(lround(expval * 3.321928094887362));
|
||||
const double z = expval * 2.302585092994046 - exp2 * 0.6931471805599453;
|
||||
const double z2 = z * z;
|
||||
conv.U = static_cast<uint64_t>(exp2 + 1023) << 52U;
|
||||
|
||||
Reference in New Issue
Block a user