mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
add support of clang 14.0.3
This commit is contained in:
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
private:
|
||||
Id() = default;
|
||||
static Id Invalid() { return Id(); }
|
||||
static Id Invalid() { return {}; }
|
||||
static Id Create(int audio_id)
|
||||
{
|
||||
Id r;
|
||||
@@ -710,15 +710,15 @@ static void draw_fake_frame(uint32_t width, uint32_t height, void* data, float l
|
||||
{
|
||||
constexpr int STRIPS_NUM = 5;
|
||||
|
||||
uint32_t luma_width = width;
|
||||
uint32_t luma_height = height;
|
||||
uint32_t chroma_width = luma_width / 2;
|
||||
uint32_t chroma_height = luma_height / 2;
|
||||
auto* buffer = static_cast<uint8_t*>(data);
|
||||
auto* luma = buffer;
|
||||
auto* chroma = buffer + luma_width * luma_height;
|
||||
uint32_t luma_strip_size = luma_height / STRIPS_NUM;
|
||||
uint32_t chroma_strip_size = chroma_height / STRIPS_NUM;
|
||||
size_t luma_width = width;
|
||||
size_t luma_height = height;
|
||||
size_t chroma_width = luma_width / 2;
|
||||
size_t chroma_height = luma_height / 2;
|
||||
auto* buffer = static_cast<uint8_t*>(data);
|
||||
auto* luma = buffer;
|
||||
auto* chroma = buffer + luma_width * luma_height;
|
||||
size_t luma_strip_size = luma_height / STRIPS_NUM;
|
||||
size_t chroma_strip_size = chroma_height / STRIPS_NUM;
|
||||
|
||||
uint8_t color[STRIPS_NUM][3] = {};
|
||||
|
||||
@@ -728,9 +728,9 @@ static void draw_fake_frame(uint32_t width, uint32_t height, void* data, float l
|
||||
rgb_to_yuv(0, 0, 0, &color[3][0], &color[3][1], &color[3][2]);
|
||||
rgb_to_yuv(l, l, l, &color[4][0], &color[4][1], &color[4][2]);
|
||||
|
||||
for (uint32_t y = 0; y < luma_strip_size; y++)
|
||||
for (size_t y = 0; y < luma_strip_size; y++)
|
||||
{
|
||||
for (uint32_t x = 0; x < luma_width; x++)
|
||||
for (size_t x = 0; x < luma_width; x++)
|
||||
{
|
||||
for (int si = 0; si < STRIPS_NUM; si++)
|
||||
{
|
||||
@@ -738,9 +738,9 @@ static void draw_fake_frame(uint32_t width, uint32_t height, void* data, float l
|
||||
}
|
||||
}
|
||||
}
|
||||
for (uint32_t y = 0; y < chroma_strip_size; y++)
|
||||
for (size_t y = 0; y < chroma_strip_size; y++)
|
||||
{
|
||||
for (uint32_t x = 0; x < chroma_width; x++)
|
||||
for (size_t x = 0; x < chroma_width; x++)
|
||||
{
|
||||
for (int si = 0; si < STRIPS_NUM; si++)
|
||||
{
|
||||
|
||||
@@ -379,7 +379,8 @@ void Elf64::DbgDump(const String& folder)
|
||||
}
|
||||
|
||||
char str[512];
|
||||
sprintf(str, "phdr_%03d", i);
|
||||
int s = snprintf(str, 512, "phdr_%03d", i);
|
||||
EXIT_NOT_IMPLEMENTED(s >= 512);
|
||||
|
||||
Core::File fout;
|
||||
fout.Create(folder_str + str);
|
||||
@@ -406,7 +407,8 @@ void Elf64::DbgDump(const String& folder)
|
||||
}
|
||||
|
||||
char str[512];
|
||||
sprintf(str, "shdr_%03d", i);
|
||||
int s = snprintf(str, 512, "shdr_%03d", i);
|
||||
EXIT_NOT_IMPLEMENTED(s >= 512);
|
||||
|
||||
Core::File fout;
|
||||
fout.Create(folder_str + str);
|
||||
|
||||
@@ -149,7 +149,7 @@ int KYTY_SYSV_ABI GraphicsSetPsShader(uint32_t* cmd, uint64_t size, const uint32
|
||||
printf("\t ps_regs.m_cbShaderMask = %08" PRIx32 "\n", ps_regs[11]);
|
||||
|
||||
cmd[0] = KYTY_PM4(size, Pm4::IT_NOP, Pm4::R_PS);
|
||||
memcpy(&cmd[1], ps_regs, 12 * 4);
|
||||
memcpy(&cmd[1], ps_regs, static_cast<size_t>(12) * 4);
|
||||
}
|
||||
|
||||
return OK;
|
||||
@@ -190,7 +190,7 @@ int KYTY_SYSV_ABI GraphicsSetPsShader350(uint32_t* cmd, uint64_t size, const uin
|
||||
printf("\t ps_regs.m_cbShaderMask = %08" PRIx32 "\n", ps_regs[11]);
|
||||
|
||||
cmd[0] = KYTY_PM4(size, Pm4::IT_NOP, Pm4::R_PS);
|
||||
memcpy(&cmd[1], ps_regs, 12 * 4);
|
||||
memcpy(&cmd[1], ps_regs, static_cast<size_t>(12) * 4);
|
||||
}
|
||||
|
||||
// printf("ok\n");
|
||||
@@ -222,7 +222,7 @@ int KYTY_SYSV_ABI GraphicsUpdatePsShader(uint32_t* cmd, uint64_t size, const uin
|
||||
printf("\t ps_regs.m_cbShaderMask = %08" PRIx32 "\n", ps_regs[11]);
|
||||
|
||||
cmd[0] = KYTY_PM4(size, Pm4::IT_NOP, Pm4::R_PS_UPDATE);
|
||||
memcpy(&cmd[1], ps_regs, 12 * 4);
|
||||
memcpy(&cmd[1], ps_regs, static_cast<size_t>(12) * 4);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ int KYTY_SYSV_ABI GraphicsUpdatePsShader350(uint32_t* cmd, uint64_t size, const
|
||||
printf("\t ps_regs.m_cbShaderMask = %08" PRIx32 "\n", ps_regs[11]);
|
||||
|
||||
cmd[0] = KYTY_PM4(size, Pm4::IT_NOP, Pm4::R_PS_UPDATE);
|
||||
memcpy(&cmd[1], ps_regs, 12 * 4);
|
||||
memcpy(&cmd[1], ps_regs, static_cast<size_t>(12) * 4);
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -276,7 +276,7 @@ int KYTY_SYSV_ABI GraphicsSetCsShaderWithModifier(uint32_t* cmd, uint64_t size,
|
||||
|
||||
cmd[0] = KYTY_PM4(size, Pm4::IT_NOP, Pm4::R_CS);
|
||||
cmd[1] = shader_modifier;
|
||||
memcpy(&cmd[2], cs_regs, 7 * 4);
|
||||
memcpy(&cmd[2], cs_regs, static_cast<size_t>(7) * 4);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Emulator/Graphics/GraphicsRender.h"
|
||||
|
||||
#include "Kyty/Core/Common.h"
|
||||
#include "Kyty/Core/DbgAssert.h"
|
||||
#include "Kyty/Core/File.h"
|
||||
#include "Kyty/Core/Hash.h"
|
||||
@@ -49,6 +50,7 @@ struct VulkanDescriptor
|
||||
VkDescriptorSet descriptor_set = nullptr;
|
||||
};
|
||||
|
||||
// Pack structs to guarantee the uniquess of object representation
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct PipelineStencilStaticState
|
||||
@@ -1813,11 +1815,11 @@ static VulkanPipeline* CreatePipelineInternal(VkRenderPass render_pass, const Sh
|
||||
create_info.pNext = nullptr;
|
||||
create_info.flags = 0;
|
||||
|
||||
create_info.codeSize = vs_shader.Size() * 4;
|
||||
create_info.codeSize = static_cast<size_t>(vs_shader.Size()) * 4;
|
||||
create_info.pCode = vs_shader.GetDataConst();
|
||||
vkCreateShaderModule(gctx->device, &create_info, nullptr, &vert_shader_module);
|
||||
|
||||
create_info.codeSize = ps_shader.Size() * 4;
|
||||
create_info.codeSize = static_cast<size_t>(ps_shader.Size()) * 4;
|
||||
create_info.pCode = ps_shader.GetDataConst();
|
||||
vkCreateShaderModule(gctx->device, &create_info, nullptr, &frag_shader_module);
|
||||
|
||||
@@ -2169,7 +2171,7 @@ static VulkanPipeline* CreatePipelineInternal(const ShaderComputeInputInfo* inpu
|
||||
create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
create_info.pNext = nullptr;
|
||||
create_info.flags = 0;
|
||||
create_info.codeSize = cs_shader.Size() * 4;
|
||||
create_info.codeSize = static_cast<size_t>(cs_shader.Size()) * 4;
|
||||
create_info.pCode = cs_shader.GetDataConst();
|
||||
vkCreateShaderModule(gctx->device, &create_info, nullptr, &comp_shader_module);
|
||||
|
||||
@@ -2231,6 +2233,7 @@ static VulkanPipeline* CreatePipelineInternal(const ShaderComputeInputInfo* inpu
|
||||
|
||||
bool PipelineStaticParameters::operator==(const PipelineStaticParameters& other) const
|
||||
{
|
||||
// NOLINTNEXTLINE(bugprone-suspicious-memory-comparison,cert-exp42-c,cert-flp37-c)
|
||||
return (0 == memcmp(this, &other, sizeof(struct PipelineStaticParameters)));
|
||||
}
|
||||
|
||||
@@ -4162,7 +4165,7 @@ static void PrepareGdsPointers(const ShaderGdsResources& gds_pointers, uint32_t*
|
||||
|
||||
if (gds_pointers.pointers_num > 0)
|
||||
{
|
||||
(*sgprs) += 4 * ((gds_pointers.pointers_num - 1) / 4 + 1);
|
||||
(*sgprs) += static_cast<ptrdiff_t>(4 * ((gds_pointers.pointers_num - 1) / 4 + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4351,11 +4354,11 @@ void GraphicsRenderDrawIndex(uint64_t submit_id, CommandBuffer* buffer, HW::Hard
|
||||
{
|
||||
case 0:
|
||||
index_type = VK_INDEX_TYPE_UINT16;
|
||||
index_size = 2 * index_count;
|
||||
index_size = 2 * static_cast<uint64_t>(index_count);
|
||||
break;
|
||||
case 1:
|
||||
index_type = VK_INDEX_TYPE_UINT32;
|
||||
index_size = 4 * index_count;
|
||||
index_size = 4 * static_cast<uint64_t>(index_count);
|
||||
break;
|
||||
default: EXIT("unknown index_type_and_size: %u\n", index_type_and_size);
|
||||
}
|
||||
@@ -4395,7 +4398,7 @@ void GraphicsRenderDrawIndex(uint64_t submit_id, CommandBuffer* buffer, HW::Hard
|
||||
{
|
||||
const auto& b = vs_input_info.buffers[i];
|
||||
uint64_t addr = b.addr;
|
||||
uint64_t size = b.stride * b.num_records;
|
||||
uint64_t size = static_cast<uint64_t>(b.stride) * b.num_records;
|
||||
|
||||
auto* vertices = static_cast<VulkanBuffer*>(
|
||||
GpuMemoryCreateObject(submit_id, g_render_ctx->GetGraphicCtx(), nullptr, addr, size, VertexBufferGpuObject()));
|
||||
@@ -4520,7 +4523,7 @@ void GraphicsRenderDrawIndexAuto(uint64_t submit_id, CommandBuffer* buffer, HW::
|
||||
{
|
||||
const auto& b = vs_input_info.buffers[i];
|
||||
uint64_t addr = b.addr;
|
||||
uint64_t size = b.stride * b.num_records;
|
||||
uint64_t size = static_cast<uint64_t>(b.stride) * b.num_records;
|
||||
|
||||
auto* vertices = static_cast<VulkanBuffer*>(
|
||||
GpuMemoryCreateObject(submit_id, g_render_ctx->GetGraphicCtx(), nullptr, addr, size, VertexBufferGpuObject()));
|
||||
|
||||
@@ -616,18 +616,18 @@ void CommandProcessor::WriteConstRam(uint32_t offset, const uint32_t* src, uint3
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
memcpy(m_const_ram + offset / 4, src, dw_num * 4);
|
||||
memcpy(m_const_ram + offset / 4, src, static_cast<size_t>(dw_num) * 4);
|
||||
}
|
||||
|
||||
void CommandProcessor::DumpConstRam(uint32_t* dst, uint32_t offset, uint32_t dw_num)
|
||||
{
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
GpuMemoryCheckAccessViolation(reinterpret_cast<uint64_t>(dst), dw_num * 4);
|
||||
GpuMemoryCheckAccessViolation(reinterpret_cast<uint64_t>(dst), static_cast<size_t>(dw_num) * 4);
|
||||
|
||||
memcpy(dst, m_const_ram + offset / 4, dw_num * 4);
|
||||
memcpy(dst, m_const_ram + offset / 4, static_cast<size_t>(dw_num) * 4);
|
||||
|
||||
GraphicsRenderMemoryFlush(reinterpret_cast<uint64_t>(dst), dw_num * 4);
|
||||
GraphicsRenderMemoryFlush(reinterpret_cast<uint64_t>(dst), static_cast<size_t>(dw_num) * 4);
|
||||
}
|
||||
|
||||
void CommandProcessor::WaitRegMem(uint32_t func, bool me, bool mem, const uint32_t* addr, uint32_t ref, uint32_t mask, uint32_t poll)
|
||||
@@ -651,11 +651,11 @@ void CommandProcessor::WriteData(uint32_t* dst, const uint32_t* src, uint32_t dw
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(write_control != 0x04100500);
|
||||
|
||||
GpuMemoryCheckAccessViolation(reinterpret_cast<uint64_t>(dst), dw_num * 4);
|
||||
GpuMemoryCheckAccessViolation(reinterpret_cast<uint64_t>(dst), static_cast<size_t>(dw_num) * 4);
|
||||
|
||||
memcpy(dst, src, dw_num * 4);
|
||||
memcpy(dst, src, static_cast<size_t>(dw_num) * 4);
|
||||
|
||||
GraphicsRenderMemoryFlush(reinterpret_cast<uint64_t>(dst), dw_num * 4);
|
||||
GraphicsRenderMemoryFlush(reinterpret_cast<uint64_t>(dst), static_cast<size_t>(dw_num) * 4);
|
||||
}
|
||||
|
||||
void GraphicsRing::Submit(uint32_t* cmd_draw_buffer, uint32_t num_draw_dw, uint32_t* cmd_const_buffer, uint32_t num_const_dw, int handle,
|
||||
@@ -940,7 +940,7 @@ void CommandProcessor::Run(uint32_t* data, uint32_t num_dw)
|
||||
|
||||
if (num_dw > 0)
|
||||
{
|
||||
GraphicsRenderMemoryFree(reinterpret_cast<uint64_t>(data), num_dw * 4);
|
||||
GraphicsRenderMemoryFree(reinterpret_cast<uint64_t>(data), static_cast<size_t>(num_dw) * 4);
|
||||
}
|
||||
|
||||
auto* cmd = data;
|
||||
@@ -1596,7 +1596,7 @@ KYTY_HW_CTX_PARSER(hw_ctx_set_aa_sample_control)
|
||||
|
||||
HW::AaSampleControl r;
|
||||
|
||||
memcpy(r.locations, buffer, 16 * 4);
|
||||
memcpy(r.locations, buffer, static_cast<size_t>(16) * 4);
|
||||
|
||||
r.centroid_priority = static_cast<uint64_t>(buffer[18]) | (static_cast<uint64_t>(buffer[19]) << 32u);
|
||||
|
||||
|
||||
@@ -59,13 +59,10 @@ static OverlapType GetOverlapType(uint64_t vaddr_a, uint64_t size_a, uint64_t va
|
||||
return OverlapType::Equals;
|
||||
}
|
||||
|
||||
uint64_t vaddr_last_a = vaddr_a + size_a - 1;
|
||||
uint64_t vaddr_last_b = vaddr_b + size_b - 1;
|
||||
|
||||
bool a_b = addr_in_block(vaddr_a, size_a, vaddr_b);
|
||||
bool a_lb = addr_in_block(vaddr_a, size_a, vaddr_last_b);
|
||||
bool a_lb = addr_in_block(vaddr_a, size_a, vaddr_b + size_b - 1);
|
||||
bool b_a = addr_in_block(vaddr_b, size_b, vaddr_a);
|
||||
bool b_la = addr_in_block(vaddr_b, size_b, vaddr_last_a);
|
||||
bool b_la = addr_in_block(vaddr_b, size_b, vaddr_a + size_a - 1);
|
||||
|
||||
if (a_b && a_lb)
|
||||
{
|
||||
|
||||
@@ -2144,8 +2144,11 @@ static bool SpirvDisassemble(const uint32_t* src_binary, size_t src_binary_size,
|
||||
|
||||
std::string disassembly;
|
||||
if (!core.Disassemble(src_binary, src_binary_size, &disassembly,
|
||||
uint32_t(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER) | SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES |
|
||||
SPV_BINARY_TO_TEXT_OPTION_COMMENT | SPV_BINARY_TO_TEXT_OPTION_INDENT | SPV_BINARY_TO_TEXT_OPTION_COLOR))
|
||||
static_cast<uint32_t>(SPV_BINARY_TO_TEXT_OPTION_NO_HEADER) |
|
||||
static_cast<uint32_t>(SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES) |
|
||||
static_cast<uint32_t>(SPV_BINARY_TO_TEXT_OPTION_COMMENT) |
|
||||
static_cast<uint32_t>(SPV_BINARY_TO_TEXT_OPTION_INDENT) |
|
||||
static_cast<uint32_t>(SPV_BINARY_TO_TEXT_OPTION_COLOR)))
|
||||
{
|
||||
*dst_disassembly = disassembly.c_str();
|
||||
|
||||
@@ -2242,7 +2245,7 @@ static const ShaderBinaryInfo* GetBinaryInfo(const uint32_t* code)
|
||||
|
||||
if (code[0] == 0xBEEB03FF)
|
||||
{
|
||||
return reinterpret_cast<const ShaderBinaryInfo*>(code + (code[1] + 1) * 2);
|
||||
return reinterpret_cast<const ShaderBinaryInfo*>(code + static_cast<size_t>(code[1] + 1) * 2);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
||||
@@ -162,8 +162,8 @@ public:
|
||||
|
||||
if (tile_bytes > 512)
|
||||
{
|
||||
tile_split_slice = element_offset / (512 * 8);
|
||||
element_offset %= (512 * 8);
|
||||
tile_split_slice = element_offset / (static_cast<uint64_t>(512) * 8);
|
||||
element_offset %= (static_cast<uint64_t>(512) * 8);
|
||||
tile_bytes = 512;
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ static void Detile32(const Tiler32* t, uint32_t width, uint32_t height, uint32_t
|
||||
uint32_t start_y = p->start_y;
|
||||
uint32_t width = p->width;
|
||||
uint32_t height = p->height;
|
||||
uint32_t dst_pitch = p->dst_pitch;
|
||||
uint64_t dst_pitch = p->dst_pitch;
|
||||
bool neo = p->neo;
|
||||
|
||||
for (uint32_t y = start_y; y < height; y++)
|
||||
@@ -359,7 +359,7 @@ static void Detile32(const Tiler1d* t, uint32_t width, uint32_t height, uint32_t
|
||||
for (uint32_t y = 0; y < height; y++)
|
||||
{
|
||||
uint32_t x = 0;
|
||||
uint64_t linear_offset = y * dst_pitch * 4;
|
||||
uint64_t linear_offset = y * static_cast<uint64_t>(dst_pitch) * 4;
|
||||
|
||||
for (; x + 1 < width; x += 2)
|
||||
{
|
||||
@@ -382,7 +382,7 @@ static void Detile64(const Tiler1d* t, uint32_t width, uint32_t height, uint32_t
|
||||
for (uint32_t y = 0; y < height; y++)
|
||||
{
|
||||
uint32_t x = 0;
|
||||
uint64_t linear_offset = y * dst_pitch * 8;
|
||||
uint64_t linear_offset = y * static_cast<uint64_t>(dst_pitch) * 8;
|
||||
|
||||
for (; x + 1 < width; x += 2)
|
||||
{
|
||||
@@ -405,7 +405,7 @@ static void Detile128(const Tiler1d* t, uint32_t width, uint32_t height, uint32_
|
||||
for (uint32_t y = 0; y < height; y++)
|
||||
{
|
||||
uint32_t x = 0;
|
||||
uint64_t linear_offset = y * dst_pitch * 16;
|
||||
uint64_t linear_offset = y * static_cast<uint64_t>(dst_pitch) * 16;
|
||||
|
||||
for (; x + 1 < width; x += 2)
|
||||
{
|
||||
|
||||
@@ -138,7 +138,8 @@ KYTY_SCRIPT_FUNC(kyty_init_func)
|
||||
|
||||
print_system_info();
|
||||
|
||||
atexit(kyty_close);
|
||||
int ok = atexit(kyty_close);
|
||||
EXIT_NOT_IMPLEMENTED(ok != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,9 @@ static KYTY_SYSV_ABI int atexit(void (*func)())
|
||||
|
||||
::printf("func = %" PRIx64 "\n", reinterpret_cast<uint64_t>(func));
|
||||
|
||||
::atexit(func);
|
||||
int ok = ::atexit(func);
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(ok != 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,9 @@ int KYTY_SYSV_ABI SaveDataMount(const SaveDataMount* mount, SaveDataMountResult*
|
||||
mount_result->mount_status = 1;
|
||||
}
|
||||
|
||||
snprintf(mount_result->mount_point.data, 16, "%s", mount_point.C_Str());
|
||||
int s = snprintf(mount_result->mount_point.data, 16, "%s", mount_point.C_Str());
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(s >= 16);
|
||||
|
||||
mount_result->required_blocks = 0;
|
||||
|
||||
@@ -234,7 +236,9 @@ int KYTY_SYSV_ABI SaveDataMount2(const SaveDataMount2* mount, SaveDataMountResul
|
||||
mount_result->mount_status = 1;
|
||||
}
|
||||
|
||||
snprintf(mount_result->mount_point.data, 16, "%s", mount_point.C_Str());
|
||||
int s = snprintf(mount_result->mount_point.data, 16, "%s", mount_point.C_Str());
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(s >= 16);
|
||||
|
||||
mount_result->required_blocks = 0;
|
||||
|
||||
|
||||
@@ -89,7 +89,9 @@ static KYTY_SYSV_ABI int UserServiceGetUserName(int user_id, char* name, size_t
|
||||
EXIT_NOT_IMPLEMENTED(user_id != 1);
|
||||
EXIT_NOT_IMPLEMENTED(size < 5);
|
||||
|
||||
snprintf(name, size, "%s", "Kyty");
|
||||
int s = snprintf(name, size, "%s", "Kyty");
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(static_cast<size_t>(s) >= size);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Emulator/Libs/Printf.h"
|
||||
|
||||
#include "Kyty/Core/Common.h"
|
||||
#include "Kyty/Core/DbgAssert.h"
|
||||
#include "Kyty/Core/Vector.h"
|
||||
|
||||
#include "Emulator/Common.h"
|
||||
@@ -15,7 +16,6 @@
|
||||
|
||||
#include <cfloat>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
|
||||
#ifdef KYTY_EMU_ENABLED
|
||||
|
||||
@@ -856,7 +856,8 @@ static int kyty_printf_internal(bool sn, char* sn_s, size_t sn_n, const char* fo
|
||||
|
||||
if (sn)
|
||||
{
|
||||
snprintf(sn_s, sn_n, "%s", buffer.GetDataConst());
|
||||
int s = snprintf(sn_s, sn_n, "%s", buffer.GetDataConst());
|
||||
EXIT_NOT_IMPLEMENTED(static_cast<size_t>(s) >= sn_n);
|
||||
} else
|
||||
{
|
||||
printf(FG_BRIGHT_MAGENTA "%s" DEFAULT, buffer.GetDataConst());
|
||||
|
||||
@@ -11,10 +11,12 @@
|
||||
#include "Emulator/Config.h"
|
||||
|
||||
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
|
||||
#include <windows.h>
|
||||
#include <windows.h> // IWYU pragma: keep
|
||||
// IWYU pragma: no_include <handleapi.h>
|
||||
// IWYU pragma: no_include <minwindef.h>
|
||||
// IWYU pragma: no_include <processenv.h>
|
||||
// IWYU pragma: no_include <winbase.h>
|
||||
// IWYU pragma: no_include <wincon.h>
|
||||
#endif
|
||||
|
||||
#ifdef KYTY_EMU_ENABLED
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
private:
|
||||
Id() = default;
|
||||
static Id Invalid() { return Id(); }
|
||||
static Id Invalid() { return {}; }
|
||||
static Id Create(int net_id, Type type)
|
||||
{
|
||||
Id r;
|
||||
@@ -1226,7 +1226,10 @@ int KYTY_SYSV_ABI NpGetNpId(int user_id, NpId* np_id)
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(np_id == nullptr);
|
||||
|
||||
snprintf(np_id->handle.data, 16, "Kyty");
|
||||
int s = snprintf(np_id->handle.data, 16, "Kyty");
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(s >= 16);
|
||||
|
||||
np_id->handle.term = 0;
|
||||
|
||||
return OK;
|
||||
@@ -1240,7 +1243,10 @@ int KYTY_SYSV_ABI NpGetOnlineId(int user_id, NpOnlineId* online_id)
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(online_id == nullptr);
|
||||
|
||||
snprintf(online_id->data, 16, "Kyty");
|
||||
int s = snprintf(online_id->data, 16, "Kyty");
|
||||
|
||||
EXIT_NOT_IMPLEMENTED(s >= 16);
|
||||
|
||||
online_id->term = 0;
|
||||
|
||||
return OK;
|
||||
|
||||
@@ -171,7 +171,7 @@ static void KYTY_SYSV_ABI stackwalk_x86(uint64_t rbp, void** stack, int* depth,
|
||||
|
||||
for (; i < d; i++)
|
||||
{
|
||||
if (!(uintptr_t(frame) >= stack_addr && uintptr_t(frame) < stack_addr + stack_size))
|
||||
if (!(reinterpret_cast<uintptr_t>(frame) >= stack_addr && reinterpret_cast<uintptr_t>(frame) < stack_addr + stack_size))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -765,22 +765,6 @@ void RuntimeLinker::SaveProgram(Program* program, const String& elf_name)
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeLinker::Clear()
|
||||
{
|
||||
// EXIT_NOT_IMPLEMENTED(!Core::Thread::IsMainThread());
|
||||
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
for (auto* p: m_programs)
|
||||
{
|
||||
DeleteProgram(p);
|
||||
}
|
||||
m_programs.Clear();
|
||||
delete m_symbols;
|
||||
m_symbols = nullptr;
|
||||
m_relocated = false;
|
||||
}
|
||||
|
||||
void RuntimeLinker::Execute()
|
||||
{
|
||||
KYTY_PROFILER_THREAD("Thread_Main");
|
||||
@@ -797,7 +781,7 @@ void RuntimeLinker::Execute()
|
||||
// Reserve some stack. There may be jumps over guard page. To prevent segfault we need to expand committed area.
|
||||
|
||||
size_t expanded_size = 0;
|
||||
size_t expanded_max = 256 * 1024;
|
||||
size_t expanded_max = static_cast<size_t>(256) * 1024;
|
||||
|
||||
while (expanded_size < expanded_max)
|
||||
{
|
||||
@@ -819,6 +803,22 @@ void RuntimeLinker::Execute()
|
||||
}
|
||||
}
|
||||
|
||||
void RuntimeLinker::Clear()
|
||||
{
|
||||
// EXIT_NOT_IMPLEMENTED(!Core::Thread::IsMainThread());
|
||||
|
||||
Core::LockGuard lock(m_mutex);
|
||||
|
||||
for (auto* p: m_programs)
|
||||
{
|
||||
DeleteProgram(p);
|
||||
}
|
||||
m_programs.Clear();
|
||||
delete m_symbols;
|
||||
m_symbols = nullptr;
|
||||
m_relocated = false;
|
||||
}
|
||||
|
||||
void RuntimeLinker::Resolve(const String& name, SymbolType type, Program* program, SymbolRecord* out_info, bool* bind_self)
|
||||
{
|
||||
KYTY_PROFILER_FUNCTION();
|
||||
@@ -1117,7 +1117,7 @@ void RuntimeLinker::LoadProgramToMemory(Program* program)
|
||||
EXIT_IF(phdr == nullptr || ehdr == nullptr);
|
||||
|
||||
program->base_size = calc_base_size(ehdr, phdr);
|
||||
program->base_size_aligned = (program->base_size & ~(uint64_t(0x1000) - 1)) + 0x1000;
|
||||
program->base_size_aligned = (program->base_size & ~(static_cast<uint64_t>(0x1000) - 1)) + 0x1000;
|
||||
|
||||
uint64_t exception_handler_size = VirtualMemory::ExceptionHandler::GetSize();
|
||||
uint64_t tls_handler_size = is_shared ? 0 : Jit::SafeCall::GetSize();
|
||||
@@ -1360,7 +1360,7 @@ static void InstallRelocateHandler(Program* program)
|
||||
KYTY_PROFILER_FUNCTION();
|
||||
|
||||
uint64_t pltgot_vaddr = program->dynamic_info->pltgot_vaddr + program->base_vaddr;
|
||||
uint64_t pltgot_size = 3 * 8;
|
||||
uint64_t pltgot_size = static_cast<uint64_t>(3) * 8;
|
||||
void** pltgot = reinterpret_cast<void**>(pltgot_vaddr);
|
||||
|
||||
VirtualMemory::Mode old_mode {};
|
||||
|
||||
@@ -64,7 +64,7 @@ void SymbolDatabase::DbgDump(const String& folder, const String& file_name)
|
||||
|
||||
const SymbolRecord* SymbolDatabase::Find(const SymbolResolve& s) const
|
||||
{
|
||||
auto index = m_map.Get(GenerateName(s), uint32_t(-1));
|
||||
auto index = m_map.Get(GenerateName(s), decltype(m_symbols)::INVALID_INDEX);
|
||||
if (!m_symbols.IndexValid(index))
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
// IWYU pragma: no_include <wtypes.h>
|
||||
// IWYU pragma: no_include <minwinbase.h>
|
||||
// IWYU pragma: no_include <apisetcconv.h>
|
||||
// IWYU pragma: no_include <winbase.h>
|
||||
|
||||
//#include <memoryapi.h>
|
||||
|
||||
@@ -169,7 +170,7 @@ ExceptionHandler::~ExceptionHandler()
|
||||
|
||||
uint64_t ExceptionHandler::GetSize()
|
||||
{
|
||||
return (sizeof(ExceptionHandlerPrivate::HandlerInfo) & ~(uint64_t(0x1000) - 1)) + 0x1000;
|
||||
return (sizeof(ExceptionHandlerPrivate::HandlerInfo) & ~(static_cast<uint64_t>(0x1000) - 1)) + 0x1000;
|
||||
}
|
||||
|
||||
bool ExceptionHandler::Install(uint64_t base_address, uint64_t handler_addr, uint64_t image_size, handler_func_t func)
|
||||
|
||||
Reference in New Issue
Block a user