GCC build

This commit is contained in:
Tom Lally 2022-08-25 03:45:02 +01:00
parent be0f062de8
commit c8c9fad128
48 changed files with 327 additions and 273 deletions

4
build.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=release -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
cd ..

View file

@ -21,8 +21,9 @@ if(MSVC)
# _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
elseif(UNIX)
add_definitions(-fms-extensions)
add_definitions(-fms-compatibility-version=19.14)
add_definitions(-fdelayed-template-parsing)
# add_definitions(-fms-compatibility-version=19.14)
# add_definitions(-fdelayed-template-parsing)
add_definitions(-fpermissive)
add_definitions(-DVK_USE_PLATFORM_XLIB_KHR) # legacy. Do we need to support XLIB surfaces?
add_definitions(-DVK_USE_PLATFORM_XCB_KHR)
add_definitions(-maes)

View file

@ -1,10 +1,16 @@
project(CemuCafe)
include_directories(".")
if((CMAKE_C_COMPILER_ID MATCHES "GNU") OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
add_compile_options(-mssse3 -mavx2)
endif()
file(GLOB_RECURSE CPP_FILES *.cpp)
file(GLOB_RECURSE H_FILES *.h)
add_library(CemuCafe ${CPP_FILES} ${H_FILES})
set_property(TARGET CemuCafe PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_precompile_headers(CemuCafe PRIVATE ../Common/precompiled.h)
@ -23,7 +29,6 @@ target_link_libraries(CemuCafe glslang SPIRV)
target_link_libraries(CemuCafe ih264d zarchive)
#target_link_libraries(CemuCafe zstd::libzstd_static)
IF(WIN32)
target_link_libraries(CemuCafe iphlpapi)
ENDIF()

View file

@ -282,7 +282,7 @@ struct
static_assert(sizeof(SharedDataEntry) == 0x1C);
__declspec(dllexport) uint32 loadSharedData()
DLLEXPORT uint32 loadSharedData()
{
// check if font files are dumped
bool hasAllShareddataFiles = true;

View file

@ -22,7 +22,7 @@ struct gameProfileBooleanOption_t
* If the option exists, true is returned.
* The boolean is stored in *optionValue
*/
__declspec(dllexport) bool gameProfile_loadBooleanOption(IniParser* iniParser, char* optionName, gameProfileBooleanOption_t* option)
DLLEXPORT bool gameProfile_loadBooleanOption(IniParser* iniParser, char* optionName, gameProfileBooleanOption_t* option)
{
auto option_value = iniParser->FindOption(optionName);
option->isPresent = false;
@ -81,7 +81,7 @@ bool gameProfile_loadBooleanOption2(IniParser& iniParser, const char* optionName
* Attempts to load a integer option
* Allows to specify min and max value (error is logged if out of range and default value is picked)
*/
__declspec(dllexport) bool gameProfile_loadIntegerOption(IniParser* iniParser, const char* optionName, gameProfileIntegerOption_t* option, sint32 defaultValue, sint32 minVal, sint32 maxVal)
DLLEXPORT bool gameProfile_loadIntegerOption(IniParser* iniParser, const char* optionName, gameProfileIntegerOption_t* option, sint32 defaultValue, sint32 minVal, sint32 maxVal)
{
auto option_value = iniParser->FindOption(optionName);
option->isPresent = false;
@ -167,7 +167,7 @@ bool gameProfile_loadEnumOption(IniParser& iniParser, const char* optionName, st
}
#pragma optimize( "", off )
__declspec(dllexport) __declspec(noinline) void gameProfile_categoryBegin(IniParser* iniParser)
DLLEXPORT NOINLINE void gameProfile_categoryBegin(IniParser* iniParser)
{
// do nothing
}
@ -381,11 +381,11 @@ void GameProfile::Reset()
}
// legacy code for Cemuhook
__declspec(dllexport) char* gameProfile_loadStringOption(IniParser* iniParser, char* optionName)
DLLEXPORT char* gameProfile_loadStringOption(IniParser* iniParser, char* optionName)
{
return nullptr;
}
__declspec(dllexport) char* gameProfile_getCurrentCategoryName(IniParser* iniParser)
DLLEXPORT char* gameProfile_getCurrentCategoryName(IniParser* iniParser)
{
return nullptr;
}
@ -396,7 +396,7 @@ struct gpNamedOptionEntry_t
sint32 value;
};
__declspec(dllexport) bool gameProfile_loadIntegerNamedOption(IniParser* iniParser, char* optionName, gameProfileIntegerOption_t* option, sint32 defaultValue, const gpNamedOptionEntry_t* nameValues, sint32 numNameValues)
DLLEXPORT bool gameProfile_loadIntegerNamedOption(IniParser* iniParser, char* optionName, gameProfileIntegerOption_t* option, sint32 defaultValue, const gpNamedOptionEntry_t* nameValues, sint32 numNameValues)
{
return false;
}

View file

@ -65,4 +65,4 @@ private:
};
extern std::unique_ptr<GameProfile> g_current_game_profile;
__declspec(dllexport) void gameProfile_load();
DLLEXPORT void gameProfile_load();

View file

@ -10,7 +10,7 @@ typedef struct
}graphicPack_t;
// scans the graphic pack directory for shaders
__declspec(dllexport) void graphicPack_loadGraphicPackShaders(graphicPack_t* gp, wchar_t* graphicPackPath)
DLLEXPORT void graphicPack_loadGraphicPackShaders(graphicPack_t* gp, wchar_t* graphicPackPath)
{
// this function is part of the deprecated/removed v1 graphic pack code
// as of Cemuhook 0.5.7.3 this function must exist with a minimum length for detour
@ -21,7 +21,7 @@ __declspec(dllexport) void graphicPack_loadGraphicPackShaders(graphicPack_t* gp,
}
// for cemuhook compatibility only
__declspec(dllexport) bool config_isGraphicPackEnabled(uint64 id)
DLLEXPORT bool config_isGraphicPackEnabled(uint64 id)
{
forceLog_printf("STUB4");
forceLog_printf("STUB5");

View file

@ -601,13 +601,13 @@ void GraphicPack2::LoadShaders()
#pragma optimize( "", off )
DLLEXPORT __declspec(noinline) void GraphicPack2_notifyActivate(GraphicPack2* gp, ExpressionParser* ep)
DLLEXPORT NOINLINE void GraphicPack2_notifyActivate(GraphicPack2* gp, ExpressionParser* ep)
{
// for Cemuhook
int placeholder = 0xDEADDEAD;
}
DLLEXPORT __declspec(noinline) void GraphicPack2_notifyDeactivate(GraphicPack2* gp)
DLLEXPORT NOINLINE void GraphicPack2_notifyDeactivate(GraphicPack2* gp)
{
// for Cemuhook
int placeholder = 0xDEADDEAD;

View file

@ -166,8 +166,8 @@ public:
static bool DeactivateGraphicPack(const std::shared_ptr<GraphicPack2>& graphic_pack);
static void ClearGraphicPacks();
private:
__declspec(dllexport) bool Activate();
__declspec(dllexport) bool Deactivate();
DLLEXPORT bool Activate();
DLLEXPORT bool Deactivate();
static std::vector<std::shared_ptr<GraphicPack2>> s_graphic_packs;
static std::vector<std::shared_ptr<GraphicPack2>> s_active_graphic_packs;

View file

@ -34,7 +34,7 @@ PPCInterpreter_t* PPCInterpreter_getCurrentInstance()
return ppcInterpreterCurrentInstance;
}
__declspec(noinline) uint64 PPCInterpreter_getMainCoreCycleCounter()
NOINLINE uint64 PPCInterpreter_getMainCoreCycleCounter()
{
return PPCTimer_getFromRDTSC();
}

View file

@ -100,7 +100,7 @@ PPCInterpreter_t* PPCCore_executeCallbackInternal(uint32 functionMPTR)
return hCPU;
}
__declspec(dllexport) void PPCCore_executeCallback(uint32 functionMPTR)
DLLEXPORT void PPCCore_executeCallback(uint32 functionMPTR)
{
PPCCore_executeCallbackInternal(functionMPTR);
}

View file

@ -7,9 +7,11 @@
#if BOOST_OS_LINUX > 0
static __inline__
unsigned __int64 _umul128(unsigned __int64,
unsigned __int64,
unsigned __int64*);
uint64 _umul128(uint64 multiplier, uint64 multiplicand, uint64 *highProduct) {
unsigned __int128 x = (unsigned __int128)multiplier * (unsigned __int128)multiplicand;
*highProduct = (x >> 64);
return x & 0xFFFFFFFFFFFFFFFF;
}
#endif
uint64 _rdtscLastMeasure = 0;
@ -49,7 +51,7 @@ uint64 PPCTimer_estimateRDTSCFrequency()
forceLog_printf("Invariant TSC not supported");
_mm_mfence();
unsigned __int64 tscStart = __rdtsc();
uint64 tscStart = __rdtsc();
unsigned int startTime = GetTickCount();
HRTick startTick = HighResolutionTimer::now().getTick();
// wait roughly 3 seconds
@ -61,7 +63,7 @@ uint64 PPCTimer_estimateRDTSCFrequency()
}
_mm_mfence();
HRTick stopTick = HighResolutionTimer::now().getTick();
unsigned __int64 tscEnd = __rdtsc();
uint64 tscEnd = __rdtsc();
// derive frequency approximation from measured time difference
uint64 tsc_diff = tscEnd - tscStart;
uint64 hrtFreq = 0;

View file

@ -580,7 +580,7 @@ void PPCRecompiler_init()
__cpuid(cpuInfo, 0x1);
hasMOVBESupport = ((cpuInfo[2] >> 22) & 1) != 0;
hasAVXSupport = ((cpuInfo[2] >> 28) & 1) != 0;
__cpuidex(cpuInfo, 0x7, 0);
__cpuidex1(cpuInfo, 0x7, 0);
hasBMI2Support = ((cpuInfo[1] >> 8) & 1) != 0;
forceLog_printf("Recompiler initialized. CPU extensions: %s%s%s", hasLZCNTSupport ? "LZCNT " : "", hasMOVBESupport ? "MOVBE " : "", hasAVXSupport ? "AVX " : "");

View file

@ -345,20 +345,20 @@ typedef struct
PPCRecFunction_t* ppcRecompilerFuncTable[PPC_REC_ALIGN_TO_4MB(PPC_REC_CODE_AREA_SIZE/4)]; // one virtual-function pointer for each potential ppc instruction
PPCREC_JUMP_ENTRY ppcRecompilerDirectJumpTable[PPC_REC_ALIGN_TO_4MB(PPC_REC_CODE_AREA_SIZE/4)]; // lookup table for ppc offset to native code function
// x64 data
uint64 __declspec(align(16)) _x64XMM_xorNegateMaskBottom[2];
uint64 __declspec(align(16)) _x64XMM_xorNegateMaskPair[2];
uint64 __declspec(align(16)) _x64XMM_xorNOTMask[2];
uint64 __declspec(align(16)) _x64XMM_andAbsMaskBottom[2];
uint64 __declspec(align(16)) _x64XMM_andAbsMaskPair[2];
uint32 __declspec(align(16)) _x64XMM_andFloatAbsMaskBottom[4];
uint64 __declspec(align(16)) _x64XMM_singleWordMask[2];
double __declspec(align(16)) _x64XMM_constDouble1_1[2];
double __declspec(align(16)) _x64XMM_constDouble0_0[2];
float __declspec(align(16)) _x64XMM_constFloat0_0[2];
float __declspec(align(16)) _x64XMM_constFloat1_1[2];
float __declspec(align(16)) _x64XMM_constFloatMin[2];
uint32 __declspec(align(16)) _x64XMM_flushDenormalMask1[4];
uint32 __declspec(align(16)) _x64XMM_flushDenormalMaskResetSignBits[4];
uint64 ALIGN(16) _x64XMM_xorNegateMaskBottom[2];
uint64 ALIGN(16) _x64XMM_xorNegateMaskPair[2];
uint64 ALIGN(16) _x64XMM_xorNOTMask[2];
uint64 ALIGN(16) _x64XMM_andAbsMaskBottom[2];
uint64 ALIGN(16) _x64XMM_andAbsMaskPair[2];
uint32 ALIGN(16) _x64XMM_andFloatAbsMaskBottom[4];
uint64 ALIGN(16) _x64XMM_singleWordMask[2];
double ALIGN(16) _x64XMM_constDouble1_1[2];
double ALIGN(16) _x64XMM_constDouble0_0[2];
float ALIGN(16) _x64XMM_constFloat0_0[2];
float ALIGN(16) _x64XMM_constFloat1_1[2];
float ALIGN(16) _x64XMM_constFloatMin[2];
uint32 ALIGN(16) _x64XMM_flushDenormalMask1[4];
uint32 ALIGN(16) _x64XMM_flushDenormalMaskResetSignBits[4];
// PSQ load/store scale tables
double _psq_ld_scale_ps0_ps1[64 * 2];
double _psq_ld_scale_ps0_1[64 * 2];
@ -369,10 +369,10 @@ typedef struct
uint32 _x64XMM_mxCsr_ftzOff;
}PPCRecompilerInstanceData_t;
extern __declspec(dllexport) PPCRecompilerInstanceData_t* ppcRecompilerInstanceData;
extern DLLEXPORT PPCRecompilerInstanceData_t* ppcRecompilerInstanceData;
extern bool ppcRecompilerEnabled;
__declspec(dllexport) void PPCRecompiler_init();
DLLEXPORT void PPCRecompiler_init();
void PPCRecompiler_allocateRange(uint32 startAddress, uint32 size);
@ -385,10 +385,10 @@ extern void ATTR_MS_ABI (*PPCRecompiler_leaveRecompilerCode_unvisited)();
#define PPC_REC_INVALID_FUNCTION ((PPCRecFunction_t*)-1)
// CPUID
extern __declspec(dllexport) bool hasLZCNTSupport;
extern __declspec(dllexport) bool hasMOVBESupport;
extern __declspec(dllexport) bool hasBMI2Support;
extern __declspec(dllexport) bool hasAVXSupport;
extern DLLEXPORT bool hasLZCNTSupport;
extern DLLEXPORT bool hasMOVBESupport;
extern DLLEXPORT bool hasBMI2Support;
extern DLLEXPORT bool hasAVXSupport;
// todo - move some of the stuff above into PPCRecompilerInternal.h

View file

@ -2221,7 +2221,10 @@ void PPCRecompilerX64Gen_imlInstruction_r_name(PPCRecFunction_t* PPCRecFunction,
else if (sprIndex == SPR_XER)
x64Emit_mov_reg64_mem32(x64GenContext, tempToRealRegister(imlInstruction->op_r_name.registerIndex), REG_RSP, offsetof(PPCInterpreter_t, spr.XER));
else if (sprIndex >= SPR_UGQR0 && sprIndex <= SPR_UGQR7)
x64Emit_mov_reg64_mem32(x64GenContext, tempToRealRegister(imlInstruction->op_r_name.registerIndex), REG_RSP, offsetof(PPCInterpreter_t, spr.UGQR[sprIndex - SPR_UGQR0]));
{
sint32 memOffset = offsetof(PPCInterpreter_t, spr.UGQR) + sizeof(PPCInterpreter_t::spr.UGQR[0]) * (sprIndex - SPR_UGQR0);
x64Emit_mov_reg64_mem32(x64GenContext, tempToRealRegister(imlInstruction->op_r_name.registerIndex), REG_RSP, memOffset);
}
else
assert_dbg();
//x64Emit_mov_reg64_mem32(x64GenContext, tempToRealRegister(imlInstruction->op_r_name.registerIndex), REG_RSP, offsetof(PPCInterpreter_t, spr)+sizeof(uint32)*(name-PPCREC_NAME_SPR0));
@ -2239,7 +2242,7 @@ void PPCRecompilerX64Gen_imlInstruction_name_r(PPCRecFunction_t* PPCRecFunction,
}
else if( name >= PPCREC_NAME_SPR0 && name < PPCREC_NAME_SPR0+999 )
{
uint32 sprIndex = (name - PPCREC_NAME_SPR0);
const uint32 sprIndex = (name - PPCREC_NAME_SPR0);
if (sprIndex == SPR_LR)
x64Emit_mov_mem32_reg64(x64GenContext, REG_RSP, offsetof(PPCInterpreter_t, spr.LR), tempToRealRegister(imlInstruction->op_r_name.registerIndex));
else if (sprIndex == SPR_CTR)
@ -2247,7 +2250,10 @@ void PPCRecompilerX64Gen_imlInstruction_name_r(PPCRecFunction_t* PPCRecFunction,
else if (sprIndex == SPR_XER)
x64Emit_mov_mem32_reg64(x64GenContext, REG_RSP, offsetof(PPCInterpreter_t, spr.XER), tempToRealRegister(imlInstruction->op_r_name.registerIndex));
else if (sprIndex >= SPR_UGQR0 && sprIndex <= SPR_UGQR7)
x64Emit_mov_mem32_reg64(x64GenContext, REG_RSP, offsetof(PPCInterpreter_t, spr.UGQR[sprIndex-SPR_UGQR0]), tempToRealRegister(imlInstruction->op_r_name.registerIndex));
{
sint32 memOffset = offsetof(PPCInterpreter_t, spr.UGQR) + sizeof(PPCInterpreter_t::spr.UGQR[0]) * (sprIndex - SPR_UGQR0);
x64Emit_mov_mem32_reg64(x64GenContext, REG_RSP, memOffset, tempToRealRegister(imlInstruction->op_r_name.registerIndex));
}
else
assert_dbg();
}

View file

@ -516,7 +516,7 @@ void LatteOverlay_translateScreenPosition(ScreenPosition pos, const Vector2f& wi
direction = -1;
break;
default:
__assume(false);
ASSUME(false);
}
}

View file

@ -430,7 +430,7 @@ void LatteTC_UnloadAllTextures()
/*
* Asynchronous way to invalidate textures
*/
__declspec(dllexport) void gpu7Texture_forceInvalidateByImagePtr(MPTR imagePtr)
DLLEXPORT void gpu7Texture_forceInvalidateByImagePtr(MPTR imagePtr)
{
// deprecated. Texture cache heuristics are now good enough to detect moving frames
}

View file

@ -124,7 +124,7 @@ struct LatteDecompilerCFInstruction
LatteDecompilerCFInstruction(LatteDecompilerCFInstruction&& mE) = default;
#else
LatteDecompilerCFInstruction(const LatteDecompilerCFInstruction& mE) = default;
LatteDecompilerCFInstruction(const LatteDecompilerCFInstruction&& mE) = default;
constexpr LatteDecompilerCFInstruction(LatteDecompilerCFInstruction&& mE) = default;
#endif
LatteDecompilerCFInstruction& operator=(LatteDecompilerCFInstruction&& mE) = default;
};

View file

@ -1458,7 +1458,7 @@ void OpenGLRenderer::shader_bind(RendererShader* shader)
prevGeometryShaderProgram = program;
break;
default:
__assume(false);
ASSUME(false);
}
catchOpenGLError();
@ -1489,7 +1489,7 @@ void OpenGLRenderer::shader_unbind(RendererShader::ShaderType shaderType)
prevGeometryShaderProgram = -1;
break;
default:
__assume(false);
ASSUME(false);
}
}

View file

@ -270,7 +270,7 @@ void RendererShaderGL::ShaderCacheLoading_begin(uint64 cacheTitleId)
usePrecompiled = false;
break;
default:
__assume(false);
ASSUME(false);
}
forceLog_printf("Using precompiled shaders: %s", usePrecompiled ? "true" : "false");

View file

@ -1,7 +1,7 @@
#pragma once
#include "Cafe/HW/Latte/Renderer/RendererShader.h"
#include "Common\GLInclude\GLInclude.h"
#include "Common/GLInclude/GLInclude.h"
class RendererShaderGL : public RendererShader
{

View file

@ -7,7 +7,7 @@
#endif
#include <glslang/Public/ShaderLang.h>
#if GLSLANG_VERSION_LESS_OR_EQUAL_TO(11, 0, 0)
#if 1 //GLSLANG_VERSION_LESS_OR_EQUAL_TO(11, 0, 0)
#include <glslang/SPIRV/GlslangToSpv.h>
#else
#include <SPIRV/Logger.h>
@ -131,7 +131,7 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .maxDualSourceDrawBuffersEXT = */ 1,
#endif
/* .limits = */ {
/* .limits = */
/* .nonInductiveForLoops = */ 1,
/* .whileLoops = */ 1,
/* .doWhileLoops = */ 1,
@ -141,7 +141,6 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .generalSamplerIndexing = */ 1,
/* .generalVariableIndexing = */ 1,
/* .generalConstantMatrixVectorIndexing = */ 1,
}
};
class _ShaderVkThreadPool
@ -470,4 +469,4 @@ void RendererShaderVk::ShaderCacheLoading_end()
{
// keep g_spirvCache open since we will write to it while the game is running
s_isLoadingShadersVk = false;
}
}

View file

@ -3409,7 +3409,7 @@ VkDescriptorSetInfo::~VkDescriptorSetInfo()
break;
}
default:
__assume(false);
ASSUME(false);
}
// update global stats
performanceMonitor.vk.numDescriptorSamplerTextures.decrement(statsNumSamplerTextures);

View file

@ -528,7 +528,7 @@ uint64 VulkanRenderer::GetDescriptorSetStateHash(LatteDecompilerShader* shader)
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS;
break;
default:
__assume(false);
ASSUME(false);
}
auto texture = m_state.boundTexture[hostTextureUnit];
@ -590,7 +590,7 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo*
break;
}
default:
__assume(false);
ASSUME(false);
}
// create new descriptor set
@ -646,7 +646,7 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo*
texUnitRegIndex += Latte::REGADDR::SQ_TEX_RESOURCE_WORD0_N_GS;
break;
default:
__assume(false);
ASSUME(false);
}
auto textureView = m_state.boundTexture[hostTextureUnit];
@ -996,7 +996,7 @@ VkDescriptorSetInfo* VulkanRenderer::draw_getOrCreateDescriptorSet(PipelineInfo*
break;
}
default:
__assume(false);
ASSUME(false);
}
return dsInfo;

View file

@ -389,7 +389,7 @@ uint8 memory_readU8(uint32 address)
return *(uint8*)(memory_getPointerFromVirtualOffset(address));
}
__declspec(dllexport) void* memory_getBase()
DLLEXPORT void* memory_getBase()
{
return memory_base;
}

View file

@ -46,8 +46,8 @@ ChunkedFlatAllocator<64 * 1024> g_heapTrampolineArea;
std::vector<rplDependency_t*> rplDependencyList = std::vector<rplDependency_t*>();
__declspec(dllexport) RPLModule* rplModuleList[256];
__declspec(dllexport) sint32 rplModuleCount = 0;
DLLEXPORT RPLModule* rplModuleList[256];
DLLEXPORT sint32 rplModuleCount = 0;
uint32 _currentTLSModuleIndex = 1; // value 0 is reserved

View file

@ -14,7 +14,7 @@ MPTR RPLLoader_AllocateCodeSpace(uint32 size, uint32 alignment);
uint32 RPLLoader_GetMaxCodeOffset();
uint32 RPLLoader_GetDataAllocatorAddr();
__declspec(dllexport) RPLModule* rpl_loadFromMem(uint8* rplData, sint32 size, char* name);
DLLEXPORT RPLModule* rpl_loadFromMem(uint8* rplData, sint32 size, char* name);
uint32 rpl_mapHLEImport(RPLModule* rplLoaderContext, const char* rplName, const char* funcName, bool functionMustExist);
void RPLLoader_Link();
@ -52,4 +52,4 @@ uint32 RPLLoader_MakePPCCallable(void(*ppcCallableExport)(struct PPCInterpreter_
// elf loader
uint32 ELF_LoadFromMemory(uint8* elfData, sint32 size, const char* name);
uint32 ELF_LoadFromMemory(uint8* elfData, sint32 size, const char* name);

View file

@ -99,7 +99,7 @@ void osLib_addFunctionInternal(const char* libraryName, const char* functionName
s_osFunctionTable->emplace_back(libHashA, libHashB, funcHashA, funcHashB, fmt::format("{}.{}", libraryName, functionName), PPCInterpreter_registerHLECall(osFunction));
}
__declspec(dllexport) void osLib_registerHLEFunction(const char* libraryName, const char* functionName, void(*osFunction)(PPCInterpreter_t* hCPU))
DLLEXPORT void osLib_registerHLEFunction(const char* libraryName, const char* functionName, void(*osFunction)(PPCInterpreter_t* hCPU))
{
osLib_addFunctionInternal(libraryName, functionName, osFunction);
}

View file

@ -398,7 +398,7 @@ namespace coreinit
else
track = (MEMBlockHeapTrackDEPR*)memory_getPointerFromVirtualOffsetAllowNull(_swapEndianU32(blockHeapHead->headBlock));
cemu_assert_debug(__popcnt(alignment) == 1); // not a supported alignment value
cemu_assert_debug(POPCNT(alignment) == 1); // not a supported alignment value
while (track)
{
if (track->isFree != _swapEndianU32(0))

View file

@ -45,8 +45,8 @@ namespace coreinit
bool g_isMulticoreMode;
__declspec(thread) uint32 t_assignedCoreIndex;
__declspec(thread) Fiber* t_schedulerFiber;
THREAD_LOCAL uint32 t_assignedCoreIndex;
THREAD_LOCAL Fiber* t_schedulerFiber;
struct OSHostThread
{

View file

@ -28,7 +28,7 @@ namespace coreinit
osLib_returnFromFunction64(hCPU, osTime);
}
__declspec(noinline) uint64 coreinit_getTimeBase_dummy()
NOINLINE uint64 coreinit_getTimeBase_dummy()
{
return __rdtsc();
}

View file

@ -201,8 +201,8 @@ static_assert(sizeof(CURLMsg_t) <= 0xC, "sizeof(CURLMsg_t)");
size_t header_callback(char* buffer, size_t size, size_t nitems, void* userdata);
__declspec(thread) PPCConcurrentQueue<QueueMsg_t>* g_callerQueue;
__declspec(thread) ConcurrentQueue<QueueMsg_t>* g_threadQueue;
THREAD_LOCAL PPCConcurrentQueue<QueueMsg_t>* g_callerQueue;
THREAD_LOCAL ConcurrentQueue<QueueMsg_t>* g_threadQueue;
void CurlWorkerThread(CURL_t* curl, PPCConcurrentQueue<QueueMsg_t>* callerQueue, ConcurrentQueue<QueueMsg_t>* threadQueue)
{
g_callerQueue = callerQueue;

View file

@ -174,7 +174,7 @@ std::unique_ptr<uint8[]> MetaInfo::GetIcon(uint32& size) const
return nullptr;
}
default:
__assume(false);
ASSUME(false);
}
return nullptr;
}

View file

@ -243,7 +243,7 @@ void cafeLog_logW(uint32 type, const wchar_t* format, ...)
LoggingWindow::Log(it->second, logTempStr);
}
__declspec(dllexport) void cemuLog_log()
DLLEXPORT void cemuLog_log()
{
typedef void(*VoidFunc)();
const VoidFunc func = (VoidFunc)cafeLog_log;

View file

@ -1,6 +1,7 @@
#pragma once
#include <vector>
uint32 coreinit_allocFromSysArea(uint32 size, uint32 alignment);
class SysAllocatorBase;
@ -195,4 +196,4 @@ private:
MEMPTR<T> m_sysMem;
T m_tempData;
};
};

View file

@ -16,8 +16,8 @@ void (__cpuid)(int __cpuVal[4], unsigned int __leaf)
}
#undef __cpuid
void __cpuidex (int __cpuid_info[4], int __leaf, int __subleaf)
void __cpuidex1(int __cpuid_info[4], int __leaf, int __subleaf)
{
__cpuid_count (__leaf, __subleaf, __cpuid_info[0], __cpuid_info[1],
__cpuid_info[2], __cpuid_info[3]);
}
}

View file

@ -45,7 +45,7 @@ inline uint32_t GetExceptionError()
// cpu id (somewhat hacky, reorganize later)
void (__cpuid)(int __cpuVal[4], unsigned int __leaf);
void __cpuidex (int __cpuid_info[4], int __leaf, int __subleaf);
void __cpuidex1 (int __cpuid_info[4], int __leaf, int __subleaf);
// placeholder
uint32_t GetTickCount();

View file

@ -166,6 +166,16 @@ inline sint16 _swapEndianS16(sint16 v)
return (sint16)(((uint16)v >> 8) | ((uint16)v << 8));
}
inline uint64 _rotl64 (uint64 x, sint8 r)
{
return (x << r) | (x >> (64 - r));
}
inline uint64 _rotr64 (uint64 x, sint8 r)
{
return (x >> r) | (x << (64 - r));
}
typedef uint8_t BYTE;
typedef uint32_t DWORD;
typedef int32_t LONG;
@ -200,11 +210,26 @@ typedef union _LARGE_INTEGER {
// macros
#if BOOST_OS_WINDOWS
#define DLLEXPORT __declspec(dllexport)
#define DLLEXPORT __declspec(dllexport)
#define DLLIMPORT __declspec(dllimport)
#define DEBUG_BREAK __debugbreak()
#define ALIGN(N) __declspec(align(N))
#define NOINLINE __declspec(noinline)
#define ASSUME(X) __assume((X)
#define THREAD_LOCAL __declspec(thread)
#define POPCNT(X) __popcnt((X))
#else
#define DLLEXPORT __declspec(dllexport)
#define DLLEXPORT
#define DLLIMPORT
#define DEBUG_BREAK
#define ALIGN(N) __attribute__((aligned (N)))
#define NOINLINE __attribute__((noinline))
#define ASSUME(X)
#define THREAD_LOCAL __thread
#define POPCNT(X) __builtin_popcount((X))
#endif
template <typename T1, typename T2>
constexpr bool HAS_FLAG(T1 flags, T2 test_flag) { return (flags & (T1)test_flag) == (T1)test_flag; }
template <typename T1, typename T2>
@ -286,7 +311,7 @@ inline void cemu_assert(bool _condition)
{
if ((_condition) == false)
{
__debugbreak();
DEBUG_BREAK;
}
}
@ -307,32 +332,32 @@ inline void cemu_assert_suspicious()
inline void cemu_assert_error()
{
__debugbreak();
DEBUG_BREAK;
}
#else
inline void cemu_assert_debug(bool _condition)
{
if ((_condition) == false)
__debugbreak();
DEBUG_BREAK;
}
inline void cemu_assert_unimplemented()
{
__debugbreak();
DEBUG_BREAK;
}
inline void cemu_assert_suspicious()
{
__debugbreak();
DEBUG_BREAK;
}
inline void cemu_assert_error()
{
__debugbreak();
DEBUG_BREAK;
}
#endif
#define assert_dbg() __debugbreak() // old style unconditional generic assert
#define assert_dbg() DEBUG_BREAK // old style unconditional generic assert
// Some string conversion helpers because C++20 std::u8string is too cumbersome to use in practice
// mixing string types generally causes loads of issues and many of the libraries we use dont expose interfaces for u8string
@ -383,7 +408,7 @@ public:
template<typename T>
bool future_is_ready(std::future<T>& f)
{
#ifdef __clang__
#if defined(__clang__) || defined(__GNUC__)
return f.wait_for(std::chrono::nanoseconds(0)) == std::future_status::ready;
#else
return f._Is_ready();
@ -399,7 +424,7 @@ std::atomic<T>* _rawPtrToAtomic(T* ptr)
return reinterpret_cast<std::atomic<T>*>(ptr);
}
#if __clang__
#if defined(__clang__) || defined(__GNUC__)
#define ATTR_MS_ABI __attribute__((ms_abi))
#else
#define ATTR_MS_ABI
@ -420,7 +445,7 @@ inline uint32 GetTitleIdLow(uint64 titleId)
return titleId & 0xFFFFFFFF;
}
#ifdef __clang__
#if defined(__clang__) || defined(__GNUC__)
#define memcpy_dwords(__dest, __src, __numDwords) memcpy((__dest), (__src), (__numDwords) * sizeof(uint32))
#define memcpy_qwords(__dest, __src, __numQwords) memcpy((__dest), (__src), (__numQwords) * sizeof(uint64))
#else

View file

@ -31,28 +31,28 @@
#define CHECK_FOR_WX_EVT_STRING(strVar, strConst) if (strcmp(strVar, #strConst) == 0){ return static_cast<int>(strConst); }
__declspec(dllexport) wxEvtHandler* wxEvtHandler_Initialize(uint8_t* allocMemory)
DLLEXPORT wxEvtHandler* wxEvtHandler_Initialize(uint8_t* allocMemory)
{
wxEvtHandler* handler = new (allocMemory) wxEvtHandler();
return handler;
}
__declspec(dllexport) void wxEvtHandler_Connect(wxEvtHandler* eventSource, int id, int lastId, int eventType, wxObjectEventFunction func, wxObject* userData, wxEvtHandler* eventSink)
DLLEXPORT void wxEvtHandler_Connect(wxEvtHandler* eventSource, int id, int lastId, int eventType, wxObjectEventFunction func, wxObject* userData, wxEvtHandler* eventSink)
{
eventSource->Connect(id, lastId, eventType, func, userData, eventSink);
}
__declspec(dllexport) void wxEvtHandler_Disconnect(wxEvtHandler* eventSource, int id, int lastId, int eventType, wxObjectEventFunction func, wxObject* userData, wxEvtHandler* eventSink)
DLLEXPORT void wxEvtHandler_Disconnect(wxEvtHandler* eventSource, int id, int lastId, int eventType, wxObjectEventFunction func, wxObject* userData, wxEvtHandler* eventSink)
{
eventSource->Disconnect(id, lastId, eventType, func, userData, eventSink);
}
__declspec(dllexport) const wchar_t* GetTranslationWChar(const wchar_t* text)
DLLEXPORT const wchar_t* GetTranslationWChar(const wchar_t* text)
{
return wxGetTranslation(text).wc_str();
}
__declspec(dllexport) int wxGetEventByName(const char* eventName)
DLLEXPORT int wxGetEventByName(const char* eventName)
{
#define PROCESS_OWN_WXEVT(EventVarName,EventHookId) if (!strcmp(eventName,#EventVarName)){ return static_cast<int>(EventVarName); }
#include "wxEvtHook.inl"
@ -95,7 +95,7 @@ void FixupWxEvtIdsToMatchCemuHook()
// these I added on my own since they might be useful
__declspec(dllexport) void coreinitAPI_OSYieldThread()
DLLEXPORT void coreinitAPI_OSYieldThread()
{
PPCCore_switchToScheduler();
}

View file

@ -148,49 +148,41 @@ public:
return default_value;
}
template <>
bool value(bool default_value)
{
return m_current_element ? m_current_element->BoolText(default_value) : default_value;
}
template <>
float value(float default_value)
{
return m_current_element ? m_current_element->FloatText(default_value) : default_value;
}
template <>
double value(double default_value)
{
return m_current_element ? m_current_element->DoubleText(default_value) : default_value;
}
template <>
uint32 value(uint32 default_value)
{
return m_current_element ? m_current_element->UnsignedText(default_value) : default_value;
}
template <>
sint32 value(sint32 default_value)
{
return m_current_element ? m_current_element->IntText(default_value) : default_value;
}
template <>
uint64 value(uint64 default_value)
{
return m_current_element ? (uint64)m_current_element->Int64Text(default_value) : default_value;
}
template <>
sint64 value(sint64 default_value)
{
return m_current_element ? m_current_element->Int64Text(default_value) : default_value;
}
template <>
const char* value(const char* default_value)
{
if (m_current_element)
@ -243,7 +235,6 @@ public:
set(name, value.load());
}
template <>
void set(const char* name, uint64 value)
{
set(name, (sint64)value);
@ -300,7 +291,6 @@ public:
return set_attribute(name, value.GetValue());
}
template <>
XMLConfigParser& set_attribute(const char* name, const std::string& value)
{
return set_attribute(name, value.c_str());

View file

@ -70,7 +70,7 @@ void unused_translation_dummy()
#pragma optimize( "", off )
DLLEXPORT _declspec(noinline) wxTopLevelWindow* wxMainWindowCreated(wxTopLevelWindow* wndPtr, uint32 magicConstant, CemuApp* appPointer)
DLLEXPORT NOINLINE wxTopLevelWindow* wxMainWindowCreated(wxTopLevelWindow* wndPtr, uint32 magicConstant, CemuApp* appPointer)
{
return wndPtr;
}

View file

@ -72,9 +72,6 @@ private:
return iss && iss.eof();
}
template <>
bool ConvertStringToType(const char* inValue, sint8& outValue) const;
using ListType_t = std::vector<MEMPTR<void>>;
ListType_t SearchValues(SearchDataType type, void* ptr, uint32 size)
{
@ -197,6 +194,10 @@ wxDECLARE_EVENT_TABLE();
bool m_clear_state = false;
};
template <>
bool MemorySearcherTool::ConvertStringToType(const char* inValue, sint8& outValue) const;

View file

@ -941,7 +941,7 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu
//return wxStringFormat2("{}", entry.format);
}
default:
__assume(false);
ASSUME(false);
}
return wxEmptyString;

View file

@ -39,11 +39,14 @@
#define _putenv(__s) putenv((char*)(__s))
#endif
#if BOOST_OS_WINDOWS > 0
extern "C"
{
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
DLLEXPORT int AmdPowerXpressRequestHighPerformance = 1;
DLLEXPORT DWORD NvOptimusEnablement = 0x00000001;
}
#endif
#endif
bool _cpuExtension_SSSE3 = false;
bool _cpuExtension_SSE4_1 = false;
@ -51,7 +54,9 @@ bool _cpuExtension_AVX2 = false;
std::atomic_bool g_isGPUInitFinished = false;
#if BOOST_OS_WINDOWS > 0
std::wstring executablePath;
#endif
bool g_cemuhook_loaded = false;
bool IsCemuhookLoaded()
@ -236,7 +241,7 @@ void mainEmulatorCommonInit()
_cpuExtension_SSSE3 = ((cpuInfo[2] >> 9) & 1) != 0;
_cpuExtension_SSE4_1 = ((cpuInfo[2] >> 19) & 1) != 0;
__cpuidex(cpuInfo, 0x7, 0);
__cpuidex1(cpuInfo, 0x7, 0);
_cpuExtension_AVX2 = ((cpuInfo[1] >> 5) & 1) != 0;
#if BOOST_OS_WINDOWS > 0
@ -426,7 +431,7 @@ int main(int argc, char *argv[])
#pragma optimize("",off)
__declspec(dllexport) void gameMeta_loadForCurrent()
DLLEXPORT void gameMeta_loadForCurrent()
{
int placeholderA = 0x11223344;
int placeholderB = 0x55667788;
@ -434,7 +439,7 @@ __declspec(dllexport) void gameMeta_loadForCurrent()
#pragma optimize("",on)
__declspec(dllexport) uint64 gameMeta_getTitleId()
DLLEXPORT uint64 gameMeta_getTitleId()
{
return CafeSystem::GetForegroundTitleId();
}

View file

@ -759,7 +759,7 @@ void AESNI128_CBC_decryptWithExpandedKey(const unsigned char *in,
void __aesni__AES128_CBC_decrypt(uint8* output, uint8* input, uint32 length, const uint8* key, const uint8* iv)
{
__declspec(align(16)) uint8 expandedKey[11 * 16];
ALIGN(16) uint8 expandedKey[11 * 16];
AESNI128_KeyExpansionDecrypt(key, expandedKey);
if (iv)
{
@ -774,7 +774,7 @@ void __aesni__AES128_CBC_decrypt(uint8* output, uint8* input, uint32 length, con
void __aesni__AES128_ECB_encrypt(uint8* input, const uint8* key, uint8* output)
{
__declspec(align(16)) uint8 expandedKey[11 * 16];
ALIGN(16) uint8 expandedKey[11 * 16];
AESNI128_KeyExpansionEncrypt(key, expandedKey);
// encrypt single ECB block
__m128i feedback;

View file

@ -0,0 +1,162 @@
#include "Serializer.h"
template<>
uint8 MemStreamReader::readBE()
{
if (!reserveReadLength(sizeof(uint8)))
return 0;
uint8 v = m_data[m_cursorPos];
m_cursorPos += sizeof(uint8);
return v;
}
template<>
uint16 MemStreamReader::readBE()
{
if (!reserveReadLength(sizeof(uint16)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint16 v;
std::memcpy(&v, p, sizeof(v));
v = _BE(v);
m_cursorPos += sizeof(uint16);
return v;
}
template<>
uint32 MemStreamReader::readBE()
{
if (!reserveReadLength(sizeof(uint32)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint32 v;
std::memcpy(&v, p, sizeof(v));
v = _BE(v);
m_cursorPos += sizeof(uint32);
return v;
}
template<>
uint64 MemStreamReader::readBE()
{
if (!reserveReadLength(sizeof(uint64)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint64 v;
std::memcpy(&v, p, sizeof(v));
v = _BE(v);
m_cursorPos += sizeof(uint64);
return v;
}
template<>
std::string MemStreamReader::readBE()
{
std::string s;
uint32 stringSize = readBE<uint32>();
if (hasError())
return s;
if (stringSize >= (32 * 1024 * 1024))
{
// out of bounds read or suspiciously large string
m_hasError = true;
return std::string();
}
s.resize(stringSize);
readData(s.data(), stringSize);
return s;
}
template<>
uint8 MemStreamReader::readLE()
{
return readBE<uint8>();
}
template<>
uint32 MemStreamReader::readLE()
{
if (!reserveReadLength(sizeof(uint32)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint32 v;
std::memcpy(&v, p, sizeof(v));
v = _LE(v);
m_cursorPos += sizeof(uint32);
return v;
}
template<>
uint64 MemStreamReader::readLE()
{
if (!reserveReadLength(sizeof(uint64)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint64 v;
std::memcpy(&v, p, sizeof(v));
v = _LE(v);
m_cursorPos += sizeof(uint64);
return v;
}
template<>
void MemStreamWriter::writeBE<uint64>(const uint64& v)
{
m_buffer.resize(m_buffer.size() + 8);
uint8* p = m_buffer.data() + m_buffer.size() - 8;
uint64 tmp = _BE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<>
void MemStreamWriter::writeBE<uint32>(const uint32& v)
{
m_buffer.resize(m_buffer.size() + 4);
uint8* p = m_buffer.data() + m_buffer.size() - 4;
uint32 tmp = _BE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<>
void MemStreamWriter::writeBE<uint16>(const uint16& v)
{
m_buffer.resize(m_buffer.size() + 2);
uint8* p = m_buffer.data() + m_buffer.size() - 2;
uint16 tmp = _BE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<>
void MemStreamWriter::writeBE<uint8>(const uint8& v)
{
m_buffer.emplace_back(v);
}
template<>
void MemStreamWriter::writeBE<std::string>(const std::string& v)
{
writeBE<uint32>((uint32)v.size());
writeData(v.data(), v.size());
}
template<>
void MemStreamWriter::writeLE<uint64>(const uint64& v)
{
m_buffer.resize(m_buffer.size() + 8);
uint8* p = m_buffer.data() + m_buffer.size() - 8;
uint64 tmp = _LE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<>
void MemStreamWriter::writeLE<uint32>(const uint32& v)
{
m_buffer.resize(m_buffer.size() + 4);
uint8* p = m_buffer.data() + m_buffer.size() - 4;
uint32 tmp = _LE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}

View file

@ -11,97 +11,6 @@ public:
template<typename T> T readBE();
template<typename T> T readLE();
template<> uint8 readBE()
{
if (!reserveReadLength(sizeof(uint8)))
return 0;
uint8 v = m_data[m_cursorPos];
m_cursorPos += sizeof(uint8);
return v;
}
template<> uint16 readBE()
{
if (!reserveReadLength(sizeof(uint16)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint16 v;
std::memcpy(&v, p, sizeof(v));
v = _BE(v);
m_cursorPos += sizeof(uint16);
return v;
}
template<> uint32 readBE()
{
if (!reserveReadLength(sizeof(uint32)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint32 v;
std::memcpy(&v, p, sizeof(v));
v = _BE(v);
m_cursorPos += sizeof(uint32);
return v;
}
template<> uint64 readBE()
{
if (!reserveReadLength(sizeof(uint64)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint64 v;
std::memcpy(&v, p, sizeof(v));
v = _BE(v);
m_cursorPos += sizeof(uint64);
return v;
}
template<> std::string readBE()
{
std::string s;
uint32 stringSize = readBE<uint32>();
if (hasError())
return s;
if (stringSize >= (32 * 1024 * 1024))
{
// out of bounds read or suspiciously large string
m_hasError = true;
return std::string();
}
s.resize(stringSize);
readData(s.data(), stringSize);
return s;
}
template<> uint8 readLE()
{
return readBE<uint8>();
}
template<> uint32 readLE()
{
if (!reserveReadLength(sizeof(uint32)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint32 v;
std::memcpy(&v, p, sizeof(v));
v = _LE(v);
m_cursorPos += sizeof(uint32);
return v;
}
template<> uint64 readLE()
{
if (!reserveReadLength(sizeof(uint64)))
return 0;
const uint8* p = m_data + m_cursorPos;
uint64 v;
std::memcpy(&v, p, sizeof(v));
v = _LE(v);
m_cursorPos += sizeof(uint64);
return v;
}
template<typename T>
std::vector<T> readPODVector()
{
@ -224,6 +133,7 @@ private:
bool m_hasError{ false };
};
class MemStreamWriter
{
public:
@ -243,67 +153,8 @@ public:
}
template<typename T> void writeBE(const T& v);
template<>
void writeBE<uint64>(const uint64& v)
{
m_buffer.resize(m_buffer.size() + 8);
uint8* p = m_buffer.data() + m_buffer.size() - 8;
uint64 tmp = _BE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<>
void writeBE<uint32>(const uint32& v)
{
m_buffer.resize(m_buffer.size() + 4);
uint8* p = m_buffer.data() + m_buffer.size() - 4;
uint32 tmp = _BE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<>
void writeBE<uint16>(const uint16& v)
{
m_buffer.resize(m_buffer.size() + 2);
uint8* p = m_buffer.data() + m_buffer.size() - 2;
uint16 tmp = _BE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<>
void writeBE<uint8>(const uint8& v)
{
m_buffer.emplace_back(v);
}
template<>
void writeBE<std::string>(const std::string& v)
{
writeBE<uint32>((uint32)v.size());
writeData(v.data(), v.size());
}
template<typename T> void writeLE(const T& v);
template<>
void writeLE<uint64>(const uint64& v)
{
m_buffer.resize(m_buffer.size() + 8);
uint8* p = m_buffer.data() + m_buffer.size() - 8;
uint64 tmp = _LE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<>
void writeLE<uint32>(const uint32& v)
{
m_buffer.resize(m_buffer.size() + 4);
uint8* p = m_buffer.data() + m_buffer.size() - 4;
uint32 tmp = _LE(v);
std::memcpy(p, &tmp, sizeof(tmp));
}
template<typename T>
void writePODVector(const std::vector<T>& v)
{
@ -328,6 +179,7 @@ private:
std::vector<uint8> m_buffer;
};
class SerializerHelper
{
public:

View file

@ -6,7 +6,8 @@ template<typename T, uint32 elements, typename P = uint32>
class RingBuffer
{
public:
RingBuffer<T, elements, P>();
//RingBuffer<T, elements, P>();
RingBuffer();
bool Push(const T& v);