Misc: Remove custom countof macros in favor of std::size

This commit is contained in:
TellowKrinkle 2021-08-30 19:43:40 -05:00 committed by tellowkrinkle
parent 7435f76609
commit 2351431d71
44 changed files with 177 additions and 202 deletions

View File

@ -37,13 +37,6 @@
// Use this in those situations
#define OFFSETOF(a, b) (reinterpret_cast<size_t>(&(static_cast<a*>(0)->b)))
// Renamed ARRAYSIZE to ArraySize -- looks nice and gets rid of Windows.h conflicts (air)
// Notes: I'd have used ARRAY_SIZE instead but ran into cross-platform lib conflicts with
// that as well. >_<
#ifndef ArraySize
#define ArraySize(x) (sizeof(x) / sizeof((x)[0]))
#endif
// --------------------------------------------------------------------------------------
// Dev / Debug conditionals - Consts for using if() statements instead of uglier #ifdef.
// --------------------------------------------------------------------------------------

View File

@ -48,7 +48,7 @@ bool ChdFileReader::Open2(const wxString& fileName)
// TODO: Unicode correctness on Windows
while (CHDERR_REQUIRES_PARENT == (error = chd_open(chds[chd_depth].c_str(), CHD_OPEN_READ, NULL, &child)))
{
if (chd_depth >= static_cast<int>(ArraySize(chds) - 1))
if (chd_depth >= static_cast<int>(std::size(chds) - 1))
{
Console.Error(L"CDVD: chd_open hit recursion limit searching for parents");
return false;

View File

@ -134,13 +134,13 @@ void ThreadedFileReader::Loop()
ThreadedFileReader::Buffer* ThreadedFileReader::GetBlockPtr(const Chunk& block)
{
for (int i = 0; i < static_cast<int>(ArraySize(m_buffer)); i++)
for (int i = 0; i < static_cast<int>(std::size(m_buffer)); i++)
{
u32 size = m_buffer[i].size.load(std::memory_order_relaxed);
u64 offset = m_buffer[i].offset;
if (size && offset <= block.offset && offset + size >= block.offset + block.length)
{
m_nextBuffer = (i + 1) % ArraySize(m_buffer);
m_nextBuffer = (i + 1) % std::size(m_buffer);
return m_buffer + i;
}
}
@ -166,7 +166,7 @@ ThreadedFileReader::Buffer* ThreadedFileReader::GetBlockPtr(const Chunk& block)
{
buf.offset = block.offset;
buf.size.store(size, std::memory_order_release);
m_nextBuffer = (m_nextBuffer + 1) % ArraySize(m_buffer);
m_nextBuffer = (m_nextBuffer + 1) % std::size(m_buffer);
return &buf;
}
return nullptr;
@ -214,9 +214,9 @@ bool ThreadedFileReader::TryCachedRead(void*& buffer, u64& offset, u32& size, co
m_amtRead = 0;
u64 end = 0;
bool allDone = false;
for (int i = 0; i < static_cast<int>(ArraySize(m_buffer) * 2); i++)
for (int i = 0; i < static_cast<int>(std::size(m_buffer) * 2); i++)
{
Buffer& buf = m_buffer[i % ArraySize(m_buffer)];
Buffer& buf = m_buffer[i % std::size(m_buffer)];
u32 bufsize = buf.size.load(std::memory_order_acquire);
if (!bufsize)
continue;

View File

@ -280,7 +280,7 @@ public:
m_dns2_address .save(config.DNS2, config.AutoDNS2);
config.hddEnable = m_hdd_enable->GetValue();
wxStrncpy(config.Hdd, m_hdd_file->GetPath(), ArraySize(config.Hdd) - 1);
wxStrncpy(config.Hdd, m_hdd_file->GetPath(), std::size(config.Hdd) - 1);
config.HddSize = m_hdd_size_spin->GetValue() * 1024;
}

View File

@ -128,7 +128,7 @@ void iDumpRegisters(u32 startpc, u32 temp)
__Log("ipu %x %x %x %x; bp: %x %x %x %x", psHu32(0x2000), psHu32(0x2010), psHu32(0x2020), psHu32(0x2030), g_BP.BP, g_BP.bufferhasnew, g_BP.FP, g_BP.IFC);
__Log("gif: %x %x %x", psHu32(0x3000), psHu32(0x3010), psHu32(0x3020));
for(i = 0; i < ArraySize(dmacs); ++i) {
for(i = 0; i < std::size(dmacs); ++i) {
DMACh* p = (DMACh*)(&eeHw[dmacs[i]]);
__Log("dma%d c%x m%x q%x t%x s%x", i, p->chcr._u32, p->madr, p->qwc, p->tadr, p->sadr);
}
@ -297,7 +297,7 @@ void iDumpBlock( int startpc, u8 * ptr )
memzero(used);
numused = 0;
for(uint i = 0; i < ArraySize(s_pInstCache->regs); ++i) {
for(uint i = 0; i < std::size(s_pInstCache->regs); ++i) {
if( s_pInstCache->regs[i] & EEINST_USED ) {
used[i] = 1;
numused++;
@ -306,7 +306,7 @@ void iDumpBlock( int startpc, u8 * ptr )
memzero(fpuused);
fpunumused = 0;
for(uint i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) {
for(uint i = 0; i < std::size(s_pInstCache->fpuregs); ++i) {
if( s_pInstCache->fpuregs[i] & EEINST_USED ) {
fpuused[i] = 1;
fpunumused++;
@ -314,11 +314,11 @@ void iDumpBlock( int startpc, u8 * ptr )
}
eff.Printf( " " );
for(uint i = 0; i < ArraySize(s_pInstCache->regs); ++i) {
for(uint i = 0; i < std::size(s_pInstCache->regs); ++i) {
if( used[i] ) eff.Printf( "%2d ", i );
}
eff.Printf( "\n" );
for(uint i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) {
for(uint i = 0; i < std::size(s_pInstCache->fpuregs); ++i) {
if( fpuused[i] ) eff.Printf( "%2d ", i );
}
@ -330,10 +330,10 @@ void iDumpBlock( int startpc, u8 * ptr )
int count;
EEINST* pcur;
for(uint i = 0; i < ArraySize(s_pInstCache->regs); ++i) {
for(uint i = 0; i < std::size(s_pInstCache->regs); ++i) {
if( used[i] ) fprintf(f, "%s ", disRNameGPR[i]);
}
for(uint i = 0; i < ArraySize(s_pInstCache->fpuregs); ++i) {
for(uint i = 0; i < std::size(s_pInstCache->fpuregs); ++i) {
if( fpuused[i] ) fprintf(f, "%s ", i<32?"FR":"FA");
}
fprintf(f, "\n");
@ -343,14 +343,14 @@ void iDumpBlock( int startpc, u8 * ptr )
fprintf(f, "%2d: %2.2x ", i+1, pcur->info);
count = 1;
for(uint j = 0; j < ArraySize(s_pInstCache->regs); j++) {
for(uint j = 0; j < std::size(s_pInstCache->regs); j++) {
if( used[j] ) {
fprintf(f, "%2.2x%s", pcur->regs[j], ((count%8)&&count<numused)?"_":" ");
++count;
}
}
count = 1;
for(uint j = 0; j < ArraySize(s_pInstCache->fpuregs); j++) {
for(uint j = 0; j < std::size(s_pInstCache->fpuregs); j++) {
if( fpuused[j] ) {
fprintf(f, "%2.2x%s", pcur->fpuregs[j], ((count%8)&&count<fpunumused)?"_":" ");
++count;

View File

@ -752,9 +752,9 @@ void* fifo_alloc(size_t size, size_t repeat)
{
ASSERT(s_fh == NULL);
if (repeat >= countof(s_Next))
if (repeat >= std::size(s_Next))
{
fprintf(stderr, "Memory mapping overflow (%zu >= %u)\n", repeat, static_cast<unsigned>(countof(s_Next)));
fprintf(stderr, "Memory mapping overflow (%zu >= %u)\n", repeat, static_cast<unsigned>(std::size(s_Next)));
return vmalloc(size * repeat, false); // Fallback to default vmalloc
}
@ -808,7 +808,7 @@ void fifo_free(void* ptr, size_t size, size_t repeat)
UnmapViewOfFile(ptr);
for (size_t i = 1; i < countof(s_Next); i++)
for (size_t i = 1; i < std::size(s_Next); i++)
{
if (s_Next[i] != 0)
{
@ -1375,12 +1375,12 @@ std::string GSApp::GetConfigS(const char* entry)
if (def != m_default_configuration.end())
{
GetIniString(m_section.c_str(), entry, def->second.c_str(), buff, countof(buff), m_ini.c_str());
GetIniString(m_section.c_str(), entry, def->second.c_str(), buff, std::size(buff), m_ini.c_str());
}
else
{
fprintf(stderr, "Option %s doesn't have a default value\n", entry);
GetIniString(m_section.c_str(), entry, "", buff, countof(buff), m_ini.c_str());
GetIniString(m_section.c_str(), entry, "", buff, std::size(buff), m_ini.c_str());
}
return {buff};

View File

@ -136,8 +136,6 @@
#endif
#define countof(a) (sizeof(a) / sizeof(a[0]))
#ifndef RESTRICT
#ifdef __INTEL_COMPILER

View File

@ -17,7 +17,7 @@
#include "GS.h"
#include "GSCrc.h"
CRC::Game CRC::m_games[] =
const CRC::Game CRC::m_games[] =
{
// Note: IDs 0x7ACF7E03, 0x7D4EA48F, 0x37C53760 - shouldn't be added as it's from the multiloaders when packing games.
{0x00000000, NoTitle, NoRegion, 0},
@ -505,7 +505,7 @@ CRC::Game CRC::m_games[] =
{0xB1BE3E51, Whiplash, EU, 0},
};
std::map<uint32, CRC::Game*> CRC::m_map;
std::map<uint32, const CRC::Game*> CRC::m_map;
std::string ToLower(std::string str)
{
@ -524,7 +524,7 @@ bool IsCrcExcluded(std::string exclusionList, uint32 crc)
return exclusionList.find(target) != std::string::npos || exclusionList.find("all") != std::string::npos;
}
CRC::Game CRC::Lookup(uint32 crc)
const CRC::Game& CRC::Lookup(uint32 crc)
{
printf("GS Lookup CRC:%08X\n", crc);
if (m_map.empty())
@ -533,20 +533,20 @@ CRC::Game CRC::Lookup(uint32 crc)
if (exclusions.length() != 0)
printf("GS: CrcHacksExclusions: %s\n", exclusions.c_str());
int crcDups = 0;
for (size_t i = 0; i < countof(m_games); i++)
for (const Game& game : m_games)
{
if (!IsCrcExcluded(exclusions, m_games[i].crc))
if (!IsCrcExcluded(exclusions, game.crc))
{
if (m_map[m_games[i].crc])
if (m_map[game.crc])
{
printf("[FIXME] GS: Duplicate CRC: 0x%08X: (game-id/region-id) %d/%d overrides %d/%d\n", m_games[i].crc, m_games[i].title, m_games[i].region, m_map[m_games[i].crc]->title, m_map[m_games[i].crc]->region);
printf("[FIXME] GS: Duplicate CRC: 0x%08X: (game-id/region-id) %d/%d overrides %d/%d\n", game.crc, game.title, game.region, m_map[game.crc]->title, m_map[game.crc]->region);
crcDups++;
}
m_map[m_games[i].crc] = &m_games[i];
m_map[game.crc] = &game;
}
//else
// printf( "GS: excluding CRC hack for 0x%08x\n", m_games[i].crc );
// printf( "GS: excluding CRC hack for 0x%08x\n", game.crc );
}
if (crcDups)
printf("[FIXME] GS: Duplicate CRC: Overall: %d\n", crcDups);

View File

@ -177,9 +177,9 @@ public:
};
private:
static Game m_games[];
static std::map<uint32, Game*> m_map;
static const Game m_games[];
static std::map<uint32, const Game*> m_map;
public:
static Game Lookup(uint32 crc);
static const Game& Lookup(uint32 crc);
};

View File

@ -86,28 +86,28 @@ GSLocalMemory::GSLocalMemory()
memset(m_vm8, 0, m_vmsize);
for (size_t i = 0; i < countof(m_psm); i++)
for (psm_t& psm : m_psm)
{
m_psm[i].info = GSLocalMemory::swizzle32;
m_psm[i].rp = &GSLocalMemory::ReadPixel32;
m_psm[i].rpa = &GSLocalMemory::ReadPixel32;
m_psm[i].wp = &GSLocalMemory::WritePixel32;
m_psm[i].wpa = &GSLocalMemory::WritePixel32;
m_psm[i].rt = &GSLocalMemory::ReadTexel32;
m_psm[i].rta = &GSLocalMemory::ReadTexel32;
m_psm[i].wfa = &GSLocalMemory::WritePixel32;
m_psm[i].wi = &GSLocalMemory::WriteImage<PSM_PSMCT32, 8, 8, 32>;
m_psm[i].ri = &GSLocalMemory::ReadImageX; // TODO
m_psm[i].rtx = &GSLocalMemory::ReadTexture32;
m_psm[i].rtxP = &GSLocalMemory::ReadTexture32;
m_psm[i].rtxb = &GSLocalMemory::ReadTextureBlock32;
m_psm[i].rtxbP = &GSLocalMemory::ReadTextureBlock32;
m_psm[i].bpp = m_psm[i].trbpp = 32;
m_psm[i].pal = 0;
m_psm[i].bs = GSVector2i(8, 8);
m_psm[i].pgs = GSVector2i(64, 32);
m_psm[i].msk = 0xff;
m_psm[i].depth = 0;
psm.info = GSLocalMemory::swizzle32;
psm.rp = &GSLocalMemory::ReadPixel32;
psm.rpa = &GSLocalMemory::ReadPixel32;
psm.wp = &GSLocalMemory::WritePixel32;
psm.wpa = &GSLocalMemory::WritePixel32;
psm.rt = &GSLocalMemory::ReadTexel32;
psm.rta = &GSLocalMemory::ReadTexel32;
psm.wfa = &GSLocalMemory::WritePixel32;
psm.wi = &GSLocalMemory::WriteImage<PSM_PSMCT32, 8, 8, 32>;
psm.ri = &GSLocalMemory::ReadImageX; // TODO
psm.rtx = &GSLocalMemory::ReadTexture32;
psm.rtxP = &GSLocalMemory::ReadTexture32;
psm.rtxb = &GSLocalMemory::ReadTextureBlock32;
psm.rtxbP = &GSLocalMemory::ReadTextureBlock32;
psm.bpp = psm.trbpp = 32;
psm.pal = 0;
psm.bs = GSVector2i(8, 8);
psm.pgs = GSVector2i(64, 32);
psm.msk = 0xff;
psm.depth = 0;
}
m_psm[PSM_PSGPU24].info = GSLocalMemory::swizzle16;
@ -289,8 +289,8 @@ GSLocalMemory::GSLocalMemory()
m_psm[PSM_PSMT8].pal = m_psm[PSM_PSMT8H].pal = 256;
m_psm[PSM_PSMT4].pal = m_psm[PSM_PSMT4HL].pal = m_psm[PSM_PSMT4HH].pal = 16;
for (size_t i = 0; i < countof(m_psm); i++)
m_psm[i].fmt = 3;
for (psm_t& psm : m_psm)
psm.fmt = 3;
m_psm[PSM_PSMCT32].fmt = m_psm[PSM_PSMZ32].fmt = 0;
m_psm[PSM_PSMCT24].fmt = m_psm[PSM_PSMZ24].fmt = 1;
m_psm[PSM_PSMCT16].fmt = m_psm[PSM_PSMZ16].fmt = 2;

View File

@ -66,7 +66,7 @@ void GSPerfMon::Update()
#ifndef DISABLE_PERF_MON
if (m_count > 0)
{
for (size_t i = 0; i < countof(m_counters); i++)
for (size_t i = 0; i < std::size(m_counters); i++)
{
m_stats[i] = m_counters[i] / m_count;
}

View File

@ -128,7 +128,7 @@ GSState::GSState()
m_sssize += sizeof(m_tr.x);
m_sssize += sizeof(m_tr.y);
m_sssize += m_mem.m_vmsize;
m_sssize += (sizeof(m_path[0].tag) + sizeof(m_path[0].reg)) * countof(m_path);
m_sssize += (sizeof(m_path[0].tag) + sizeof(m_path[0].reg)) * std::size(m_path);
m_sssize += sizeof(m_q);
PRIM = &m_env.PRIM;
@ -187,7 +187,7 @@ void GSState::Reset()
{
// FIXME: bios logo not shown cut in half after reset, missing graphics in GoW after first FMV
// memset(m_mem.m_vm8, 0, m_mem.m_vmsize);
memset(&m_path[0], 0, sizeof(m_path[0]) * countof(m_path));
memset(&m_path, 0, sizeof(m_path));
memset(&m_v, 0, sizeof(m_v));
m_env.Reset();
@ -221,8 +221,7 @@ void GSState::Reset()
void GSState::ResetHandlers()
{
for (size_t i = 0; i < countof(m_fpGIFPackedRegHandlers); i++)
m_fpGIFPackedRegHandlers[i] = &GSState::GIFPackedRegHandlerNull;
std::fill(std::begin(m_fpGIFPackedRegHandlers), std::end(m_fpGIFPackedRegHandlers), &GSState::GIFPackedRegHandlerNull);
m_fpGIFPackedRegHandlers[GIF_REG_PRIM] = (GIFPackedRegHandler)(GIFRegHandler)&GSState::GIFRegHandlerPRIM;
m_fpGIFPackedRegHandlers[GIF_REG_RGBA] = &GSState::GIFPackedRegHandlerRGBA;
@ -271,8 +270,7 @@ void GSState::ResetHandlers()
SetHandlerXYZ(GS_INVALID, false);
}
for (size_t i = 0; i < countof(m_fpGIFRegHandlers); i++)
m_fpGIFRegHandlers[i] = &GSState::GIFRegHandlerNull;
std::fill(std::begin(m_fpGIFRegHandlers), std::end(m_fpGIFRegHandlers), &GSState::GIFRegHandlerNull);
m_fpGIFRegHandlers[GIF_A_D_REG_PRIM] = &GSState::GIFRegHandlerPRIM;
m_fpGIFRegHandlers[GIF_A_D_REG_RGBAQ] = &GSState::GIFRegHandlerRGBAQ;
@ -2054,19 +2052,19 @@ int GSState::Freeze(freezeData* fd, bool sizeonly)
WriteState(data, &m_tr.y);
WriteState(data, m_mem.m_vm8, m_mem.m_vmsize);
for (size_t i = 0; i < countof(m_path); i++)
for (GIFPath& path : m_path)
{
m_path[i].tag.NREG = m_path[i].nreg;
m_path[i].tag.NLOOP = m_path[i].nloop;
m_path[i].tag.REGS = 0;
path.tag.NREG = path.nreg;
path.tag.NLOOP = path.nloop;
path.tag.REGS = 0;
for (size_t j = 0; j < countof(m_path[i].regs.u8); j++)
for (size_t j = 0; j < std::size(path.regs.u8); j++)
{
m_path[i].tag.u32[2 + (j >> 3)] |= m_path[i].regs.u8[j] << ((j & 7) << 2);
path.tag.u32[2 + (j >> 3)] |= path.regs.u8[j] << ((j & 7) << 2);
}
WriteState(data, &m_path[i].tag);
WriteState(data, &m_path[i].reg);
WriteState(data, &path.tag);
WriteState(data, &path.reg);
}
WriteState(data, &m_q);
@ -2162,12 +2160,12 @@ int GSState::Defrost(const freezeData* fd)
m_tr.total = 0; // TODO: restore transfer state
for (size_t i = 0; i < countof(m_path); i++)
for (GIFPath& path : m_path)
{
ReadState(&m_path[i].tag, data);
ReadState(&m_path[i].reg, data);
ReadState(&path.tag, data);
ReadState(&path.reg, data);
m_path[i].SetTag(&m_path[i].tag); // expand regs
path.SetTag(&path.tag); // expand regs
}
ReadState(&m_q, data);

View File

@ -167,11 +167,11 @@ bool GSUtil::CheckSSE()
#endif
};
for (size_t i = 0; i < countof(checks); i++)
for (const ISA& check : checks)
{
if (!g_cpu.has(checks[i].type))
if (!g_cpu.has(check.type))
{
fprintf(stderr, "This CPU does not support %s\n", checks[i].name);
fprintf(stderr, "This CPU does not support %s\n", check.name);
status = false;
}

View File

@ -201,7 +201,7 @@ GSVector4i GSVector4i::fit(int preset) const
{
GSVector4i r;
if (preset > 0 && preset < (int)countof(s_ar))
if (preset > 0 && preset < (int)std::size(s_ar))
{
r = fit(s_ar[preset][0], s_ar[preset][1]);
}

View File

@ -242,7 +242,7 @@ void GSDevice::Merge(GSTexture* sTex[3], GSVector4* sRect, GSVector4* dRect, con
{
GSTexture* tex[3] = {NULL, NULL, NULL};
for (size_t i = 0; i < countof(tex); i++)
for (size_t i = 0; i < std::size(tex); i++)
{
if (sTex[i] != NULL)
{
@ -252,7 +252,7 @@ void GSDevice::Merge(GSTexture* sTex[3], GSVector4* sRect, GSVector4* dRect, con
DoMerge(tex, sRect, m_merge, dRect, PMODE, EXTBUF, c);
for (size_t i = 0; i < countof(tex); i++)
for (size_t i = 0; i < std::size(tex); i++)
{
if (tex[i] != sTex[i])
{

View File

@ -212,7 +212,7 @@ void GSOsdManager::Log(const char* utf8)
#if __GNUC__ < 5 || (__GNUC__ == 5 && __GNUC_MINOR__ < 4)
char32_t buffer[256];
dumb_utf8_to_utf32(utf8, buffer, countof(buffer));
dumb_utf8_to_utf32(utf8, buffer, std::size(buffer));
for (char32_t* c = buffer; *c; ++c)
AddGlyph(*c);
#else
@ -238,8 +238,8 @@ void GSOsdManager::Monitor(const char* key, const char* value)
{
#if __GNUC__ < 5 || (__GNUC__ == 5 && __GNUC_MINOR__ < 4)
char32_t buffer[256], vbuffer[256];
dumb_utf8_to_utf32(key, buffer, countof(buffer));
dumb_utf8_to_utf32(value, vbuffer, countof(vbuffer));
dumb_utf8_to_utf32(key, buffer, std::size(buffer));
dumb_utf8_to_utf32(value, vbuffer, std::size(vbuffer));
for (char32_t* c = buffer; *c; ++c)
AddGlyph(*c);
for (char32_t* c = vbuffer; *c; ++c)
@ -263,7 +263,7 @@ void GSOsdManager::Monitor(const char* key, const char* value)
{
#if __GNUC__ < 5 || (__GNUC__ == 5 && __GNUC_MINOR__ < 4)
char32_t buffer[256];
dumb_utf8_to_utf32(key, buffer, countof(buffer));
dumb_utf8_to_utf32(key, buffer, std::size(buffer));
#else
#if _MSC_VER == 1900
std::wstring_convert<std::codecvt_utf8<unsigned int>, unsigned int> conv;

View File

@ -452,7 +452,7 @@ void GSRenderer::VSync(int field)
std::lock_guard<std::mutex> lock(m_pGSsetTitle_Crit);
strncpy(m_GStitleInfoBuffer, s.c_str(), countof(m_GStitleInfoBuffer) - 1);
strncpy(m_GStitleInfoBuffer, s.c_str(), std::size(m_GStitleInfoBuffer) - 1);
m_GStitleInfoBuffer[sizeof(m_GStitleInfoBuffer) - 1] = 0; // make sure null terminated even if text overflows
}

View File

@ -26,9 +26,9 @@ public:
GSVertexList()
: m_count(0)
{
m_base = _aligned_malloc(sizeof(Vertex) * countof(m_v), 32);
m_base = _aligned_malloc(sizeof(Vertex) * std::size(m_v), 32);
for (size_t i = 0; i < countof(m_v); i++)
for (size_t i = 0; i < std::size(m_v); i++)
{
m_v[i] = &((Vertex*)m_base)[i];
}

View File

@ -228,14 +228,14 @@ bool GSDevice11::Create(const WindowInfo& wi)
std::vector<char> shader;
theApp.LoadResource(IDR_CONVERT_FX, shader);
CreateShader(shader, "convert.fx", nullptr, "vs_main", sm_model.GetPtr(), &m_convert.vs, il_convert, countof(il_convert), m_convert.il.put());
CreateShader(shader, "convert.fx", nullptr, "vs_main", sm_model.GetPtr(), &m_convert.vs, il_convert, std::size(il_convert), m_convert.il.put());
ShaderMacro sm_convert(m_shader.model);
sm_convert.AddMacro("PS_SCALE_FACTOR", std::max(1, m_upscale_multiplier));
D3D_SHADER_MACRO* sm_convert_ptr = sm_convert.GetPtr();
for (size_t i = 0; i < countof(m_convert.ps); i++)
for (size_t i = 0; i < std::size(m_convert.ps); i++)
{
CreateShader(shader, "convert.fx", nullptr, format("ps_main%d", i).c_str(), sm_convert_ptr, m_convert.ps[i].put());
}
@ -267,7 +267,7 @@ bool GSDevice11::Create(const WindowInfo& wi)
m_dev->CreateBuffer(&bd, nullptr, m_merge.cb.put());
theApp.LoadResource(IDR_MERGE_FX, shader);
for (size_t i = 0; i < countof(m_merge.ps); i++)
for (size_t i = 0; i < std::size(m_merge.ps); i++)
{
CreateShader(shader, "merge.fx", nullptr, format("ps_main%d", i).c_str(), sm_model.GetPtr(), m_merge.ps[i].put());
}
@ -296,7 +296,7 @@ bool GSDevice11::Create(const WindowInfo& wi)
m_dev->CreateBuffer(&bd, nullptr, m_interlace.cb.put());
theApp.LoadResource(IDR_INTERLACE_FX, shader);
for (size_t i = 0; i < countof(m_interlace.ps); i++)
for (size_t i = 0; i < std::size(m_interlace.ps); i++)
{
CreateShader(shader, "interlace.fx", nullptr, format("ps_main%d", i).c_str(), sm_model.GetPtr(), m_interlace.ps[i].put());
}
@ -776,7 +776,7 @@ void GSDevice11::StretchRect(GSTexture* sTex, const GSVector4& sRect, GSTexture*
IASetVertexBuffer(vertices, sizeof(vertices[0]), countof(vertices));
IASetVertexBuffer(vertices, sizeof(vertices[0]), std::size(vertices));
IASetInputLayout(m_convert.il.get());
IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
@ -1294,7 +1294,7 @@ void GSDevice11::PSSetShader(ID3D11PixelShader* ps, ID3D11Buffer* ps_cb)
void GSDevice11::PSUpdateShaderState()
{
m_ctx->PSSetShaderResources(0, m_state.ps_sr_views.size(), m_state.ps_sr_views.data());
m_ctx->PSSetSamplers(0, countof(m_state.ps_ss), m_state.ps_ss);
m_ctx->PSSetSamplers(0, std::size(m_state.ps_ss), m_state.ps_ss);
}
void GSDevice11::OMSetDepthStencilState(ID3D11DepthStencilState* dss, uint8 sref)

View File

@ -117,7 +117,7 @@ void GSDevice11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
std::vector<char> shader;
theApp.LoadResource(IDR_TFX_FX, shader);
CreateShader(shader, "tfx.fx", nullptr, "vs_main", sm.GetPtr(), &vs.vs, layout, countof(layout), vs.il.put());
CreateShader(shader, "tfx.fx", nullptr, "vs_main", sm.GetPtr(), &vs.vs, layout, std::size(layout), vs.il.put());
m_vs[sel] = vs;

View File

@ -2148,9 +2148,9 @@ void GSTextureCache::SourceMap::RemoveAll()
m_surfaces.clear();
for (size_t i = 0; i < countof(m_map); i++)
for (FastList<Source*>& item : m_map)
{
m_map[i].clear();
item.clear();
}
}

View File

@ -77,10 +77,8 @@ namespace GLState
rt = 0;
ds = 0;
for (size_t i = 0; i < countof(tex_unit); i++)
tex_unit[i] = 0;
for (size_t i = 0; i < countof(tex_handle); i++)
tex_handle[i] = 0;
std::fill(std::begin(tex_unit), std::end(tex_unit), 0);
std::fill(std::begin(tex_handle), std::end(tex_handle), 0);
ps = 0;
gs = 0;

View File

@ -143,10 +143,10 @@ GSDeviceOGL::~GSDeviceOGL()
m_ps.clear();
glDeleteSamplers(countof(m_ps_ss), m_ps_ss);
glDeleteSamplers(std::size(m_ps_ss), m_ps_ss);
for (uint32 key = 0; key < countof(m_om_dss); key++)
delete m_om_dss[key];
for (GSDepthStencilOGL* ds : m_om_dss)
delete ds;
PboPool::Destroy();
@ -210,11 +210,7 @@ void GSDeviceOGL::GenerateProfilerData()
uint32 time_repartition[16] = {0};
for (auto t : times)
{
uint32 slot = (uint32)(t / 2.0);
if (slot >= countof(time_repartition))
{
slot = countof(time_repartition) - 1;
}
size_t slot = std::min<size_t>(t / 2.0, std::size(time_repartition) - 1);
time_repartition[slot]++;
}
@ -225,7 +221,7 @@ void GSDeviceOGL::GenerateProfilerData()
fprintf(stderr, "SD %4.2f ms\n", sd);
fprintf(stderr, "\n");
fprintf(stderr, "Frame Repartition\n");
for (uint32 i = 0; i < countof(time_repartition); i++)
for (uint32 i = 0; i < std::size(time_repartition); i++)
{
fprintf(stderr, "%3u ms => %3u ms\t%4u\n", 2 * i, 2 * (i + 1), time_repartition[i]);
}
@ -343,7 +339,7 @@ bool GSDeviceOGL::Create(const WindowInfo& wi)
glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, NULL, true);
// Useless info message on Nvidia driver
GLuint ids[] = {0x20004};
glDebugMessageControl(GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DONT_CARE, countof(ids), ids, false);
glDebugMessageControl(GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, GL_DONT_CARE, std::size(ids), ids, false);
}
#endif
@ -424,7 +420,7 @@ bool GSDeviceOGL::Create(const WindowInfo& wi)
{
GL_PUSH("GSDeviceOGL::Sampler");
for (uint32 key = 0; key < countof(m_ps_ss); key++)
for (uint32 key = 0; key < std::size(m_ps_ss); key++)
{
m_ps_ss[key] = CreateSampler(PSSamplerSelector(key));
}
@ -450,7 +446,7 @@ bool GSDeviceOGL::Create(const WindowInfo& wi)
vs = m_shader->Compile("convert.glsl", "vs_main", GL_VERTEX_SHADER, shader.data());
m_convert.vs = vs;
for (size_t i = 0; i < countof(m_convert.ps); i++)
for (size_t i = 0; i < std::size(m_convert.ps); i++)
{
ps = m_shader->Compile("convert.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, shader.data());
std::string pretty_name = "Convert pipe " + std::to_string(i);
@ -480,7 +476,7 @@ bool GSDeviceOGL::Create(const WindowInfo& wi)
theApp.LoadResource(IDR_MERGE_GLSL, shader);
for (size_t i = 0; i < countof(m_merge_obj.ps); i++)
for (size_t i = 0; i < std::size(m_merge_obj.ps); i++)
{
ps = m_shader->Compile("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, shader.data());
std::string pretty_name = "Merge pipe " + std::to_string(i);
@ -498,7 +494,7 @@ bool GSDeviceOGL::Create(const WindowInfo& wi)
theApp.LoadResource(IDR_INTERLACE_GLSL, shader);
for (size_t i = 0; i < countof(m_interlace.ps); i++)
for (size_t i = 0; i < std::size(m_interlace.ps); i++)
{
ps = m_shader->Compile("interlace.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, shader.data());
std::string pretty_name = "Interlace pipe " + std::to_string(i);
@ -658,14 +654,14 @@ void GSDeviceOGL::CreateTextureFX()
m_gs[2] = CompileGS(GSSelector(2));
m_gs[4] = CompileGS(GSSelector(4));
for (uint32 key = 0; key < countof(m_vs); key++)
for (uint32 key = 0; key < std::size(m_vs); key++)
m_vs[key] = CompileVS(VSSelector(key));
// Enable all bits for stencil operations. Technically 1 bit is
// enough but buffer is polluted with noise. Clear will be limited
// to the mask.
glStencilMask(0xFF);
for (uint32 key = 0; key < countof(m_om_dss); key++)
for (uint32 key = 0; key < std::size(m_om_dss); key++)
{
m_om_dss[key] = CreateDepthStencil(OMDepthStencilSelector(key));
}
@ -1758,7 +1754,7 @@ void GSDeviceOGL::IASetPrimitiveTopology(GLenum topology)
void GSDeviceOGL::PSSetShaderResource(int i, GSTexture* sr)
{
ASSERT(i < (int)countof(GLState::tex_unit));
ASSERT(i < static_cast<int>(std::size(GLState::tex_unit)));
// Note: Nvidia debgger doesn't support the id 0 (ie the NULL texture)
if (sr)
{

View File

@ -56,10 +56,7 @@ namespace PboPool
m_map = (char*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_pbo_size, map_flags);
m_offset = 0;
for (size_t i = 0; i < countof(m_fence); i++)
{
m_fence[i] = 0;
}
std::fill(std::begin(m_fence), std::end(m_fence), nullptr);
UnbindPbo();
}
@ -101,9 +98,9 @@ namespace PboPool
m_map = NULL;
m_offset = 0;
for (size_t i = 0; i < countof(m_fence); i++)
for (GLsync fence : m_fence)
{
glDeleteSync(m_fence[i]);
glDeleteSync(fence);
}
glDeleteBuffers(1, &m_buffer);
@ -121,7 +118,7 @@ namespace PboPool
if (segment_current != segment_next)
{
if (segment_next >= countof(m_fence))
if (segment_next >= std::size(m_fence))
{
segment_next = 0;
}
@ -355,10 +352,10 @@ GSTextureOGL::~GSTextureOGL()
GLState::rt = 0;
if (m_texture_id == GLState::ds)
GLState::ds = 0;
for (size_t i = 0; i < countof(GLState::tex_unit); i++)
for (GLuint& tex : GLState::tex_unit)
{
if (m_texture_id == GLState::tex_unit[i])
GLState::tex_unit[i] = 0;
if (m_texture_id == tex)
tex = 0;
}
glDeleteTextures(1, &m_texture_id);

View File

@ -38,14 +38,8 @@ GSRendererSW::GSRendererSW(int threads)
m_output = (uint8*)_aligned_malloc(1024 * 1024 * sizeof(uint32), 32);
for (uint32 i = 0; i < countof(m_fzb_pages); i++)
{
m_fzb_pages[i] = 0;
}
for (uint32 i = 0; i < countof(m_tex_pages); i++)
{
m_tex_pages[i] = 0;
}
std::fill(std::begin(m_fzb_pages), std::end(m_fzb_pages), 0);
std::fill(std::begin(m_tex_pages), std::end(m_tex_pages), 0);
#define InitCVB2(P, Q) \
m_cvb[P][0][0][Q] = &GSRendererSW::ConvertVertexBuffer<P, 0, 0, Q>; \
@ -77,9 +71,9 @@ GSRendererSW::~GSRendererSW()
{
delete m_tc;
for (size_t i = 0; i < countof(m_texture); i++)
for (GSTexture* tex : m_texture)
{
delete m_texture[i];
delete tex;
}
delete m_rl;
@ -119,7 +113,7 @@ void GSRendererSW::VSync(int field)
/*
int draw[8], sum = 0;
for(size_t i = 0; i < countof(draw); i++)
for(size_t i = 0; i < std::size(draw); i++)
{
draw[i] = m_perfmon.CPU(GSPerfMon::WorkerDraw0 + i);
sum += draw[i];
@ -142,11 +136,11 @@ void GSRendererSW::VSync(int field)
void GSRendererSW::ResetDevice()
{
for (size_t i = 0; i < countof(m_texture); i++)
for (GSTexture*& tex : m_texture)
{
delete m_texture[i];
delete tex;
m_texture[i] = NULL;
tex = NULL;
}
}

View File

@ -307,7 +307,7 @@ struct GSScanlineConstantData : public GSAlignedClass<32>
1.0f
};
for (size_t n = 0; n < countof(log2_coef); ++n)
for (size_t n = 0; n < std::size(log2_coef); ++n)
{
for (size_t i = 0; i < 4; ++i)
{

View File

@ -180,7 +180,7 @@ bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code)
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = m_hWnd;
ofn.lpstrFile = buff;
ofn.nMaxFile = countof(buff);
ofn.nMaxFile = std::size(buff);
ofn.lpstrFilter = L"Avi files (*.avi)\0*.avi\0";
ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;

View File

@ -306,7 +306,7 @@ void __fastcall _hwWrite8(u32 mem, u8 value)
sio_buffer[sio_count++] = value;
}
if ((sio_count == ArraySize(sio_buffer)-1) || (sio_count != 0 && sio_buffer[sio_count-1] == '\n'))
if ((sio_count == std::size(sio_buffer)-1) || (sio_count != 0 && sio_buffer[sio_count-1] == '\n'))
{
sio_buffer[sio_count] = 0;
eeConLog( ShiftJIS_ConvertString(sio_buffer) );

View File

@ -567,7 +567,7 @@ u64 FileMemoryCard::GetCRC(uint slot)
for (uint i = filesize; i; --i)
{
mcfp.Read(&buffer, sizeof(buffer));
for (uint t = 0; t < ArraySize(buffer); ++t)
for (uint t = 0; t < std::size(buffer); ++t)
retval ^= buffer[t];
}
}

View File

@ -28,28 +28,28 @@
void InputRecordingFileHeader::Init()
{
memset(author, 0, ArraySize(author));
memset(gameName, 0, ArraySize(gameName));
memset(author, 0, std::size(author));
memset(gameName, 0, std::size(gameName));
}
void InputRecordingFileHeader::SetEmulatorVersion()
{
wxString emuVersion = wxString::Format("%s-%d.%d.%d", pxGetAppName().c_str(), PCSX2_VersionHi, PCSX2_VersionMid, PCSX2_VersionLo);
int max = ArraySize(emu) - 1;
int max = std::size(emu) - 1;
strncpy(emu, emuVersion.c_str(), max);
emu[max] = 0;
}
void InputRecordingFileHeader::SetAuthor(wxString _author)
{
int max = ArraySize(author) - 1;
int max = std::size(author) - 1;
strncpy(author, _author.c_str(), max);
author[max] = 0;
}
void InputRecordingFileHeader::SetGameName(wxString _gameName)
{
int max = ArraySize(gameName) - 1;
int max = std::size(gameName) - 1;
strncpy(gameName, _gameName.c_str(), max);
gameName[max] = 0;
}

View File

@ -193,7 +193,7 @@ void CfgReadStr(const TCHAR* Section, const TCHAR* Name, wxString& Data, const T
{
initIni();
wchar_t workspace[512];
GetPrivateProfileString(Section, Name, L"", workspace, ArraySize(workspace), CfgFile);
GetPrivateProfileString(Section, Name, L"", workspace, std::size(workspace), CfgFile);
Data = workspace;

View File

@ -707,13 +707,14 @@ void SaveState_DownloadState(ArchiveEntryList* destlist)
internals.SetDataSize(saveme.GetCurrentPos() - internals.GetDataIndex());
destlist->Add(internals);
for (uint i = 0; i < ArraySize(SavestateEntries); ++i)
for (const std::unique_ptr<BaseSavestateEntry>& entry : SavestateEntries)
{
uint startpos = saveme.GetCurrentPos();
SavestateEntries[i]->FreezeOut(saveme);
destlist->Add(ArchiveEntry(SavestateEntries[i]->GetFilename())
.SetDataIndex(startpos)
.SetDataSize(saveme.GetCurrentPos() - startpos));
entry->FreezeOut(saveme);
destlist->Add(
ArchiveEntry(entry->GetFilename())
.SetDataIndex(startpos)
.SetDataSize(saveme.GetCurrentPos() - startpos));
}
}
@ -834,7 +835,7 @@ void SaveState_UnzipFromDisk(const wxString& filename)
//bool foundEntry[ArraySize(SavestateEntries)] = false;
std::unique_ptr<wxZipEntry> foundInternal;
std::unique_ptr<wxZipEntry> foundEntry[ArraySize(SavestateEntries)];
std::unique_ptr<wxZipEntry> foundEntry[std::size(SavestateEntries)];
while (true)
{
@ -866,7 +867,7 @@ void SaveState_UnzipFromDisk(const wxString& filename)
foundScreenshot = true;
}*/
for (uint i = 0; i < ArraySize(SavestateEntries); ++i)
for (uint i = 0; i < std::size(SavestateEntries); ++i)
{
if (entry->GetName().CmpNoCase(SavestateEntries[i]->GetFilename()) == 0)
{
@ -887,7 +888,7 @@ void SaveState_UnzipFromDisk(const wxString& filename)
// Log any parts and pieces that are missing, and then generate an exception.
bool throwIt = false;
for (uint i = 0; i < ArraySize(SavestateEntries); ++i)
for (uint i = 0; i < std::size(SavestateEntries); ++i)
{
if (foundEntry[i])
continue;
@ -907,7 +908,7 @@ void SaveState_UnzipFromDisk(const wxString& filename)
PatchesVerboseReset();
SysClearExecutionCache();
for (uint i = 0; i < ArraySize(SavestateEntries); ++i)
for (uint i = 0; i < std::size(SavestateEntries); ++i)
{
if (!foundEntry[i])
continue;

View File

@ -74,7 +74,7 @@ bool Pcsx2App::TestUserPermissionsRights( const wxDirName& testFolder, wxString&
FastFormatUnicode createme, accessme;
for (uint i=0; i<ArraySize(PermissionFolders); ++i)
for (uint i=0; i<std::size(PermissionFolders); ++i)
{
wxDirName folder( testFolder + PermissionFolders[i] );

View File

@ -351,7 +351,7 @@ void ConLog_LoadSaveSettings( IniInterface& ini )
ini.Entry( L"Devel", DevConWriterEnabled, false );
uint srcnt = ArraySize(ConLogSources);
uint srcnt = std::size(ConLogSources);
for (uint i=0; i<srcnt; ++i)
{
if (ConsoleLogSource* log = ConLogSources[i])
@ -456,7 +456,7 @@ ConsoleLogFrame::ConsoleLogFrame( MainEmuFrame *parent, const wxString& title, A
menuSources.AppendSeparator();
uint srcnt = ArraySize(ConLogSources);
uint srcnt = std::size(ConLogSources);
for (uint i=0; i<srcnt; ++i)
{
if (const BaseTraceLogSource* log = ConLogSources[i])
@ -536,7 +536,7 @@ ConsoleLogFrame::~ConsoleLogFrame()
void ConsoleLogFrame::OnEnableAllLogging(wxCommandEvent& evt)
{
uint srcnt = ArraySize(ConLogSources);
uint srcnt = std::size(ConLogSources);
for (uint i=0; i<srcnt; ++i)
{
if (ConsoleLogSource* log = ConLogSources[i])
@ -552,7 +552,7 @@ void ConsoleLogFrame::OnEnableAllLogging(wxCommandEvent& evt)
void ConsoleLogFrame::OnDisableAllLogging(wxCommandEvent& evt)
{
uint srcnt = ArraySize(ConLogSources);
uint srcnt = std::size(ConLogSources);
for (uint i=0; i<srcnt; ++i)
{
if (ConsoleLogSource* log = ConLogSources[i])
@ -568,7 +568,7 @@ void ConsoleLogFrame::OnDisableAllLogging(wxCommandEvent& evt)
void ConsoleLogFrame::OnSetDefaultLogging(wxCommandEvent& evt)
{
uint srcnt = ArraySize(ConLogSources);
uint srcnt = std::size(ConLogSources);
for (uint i = 0; i<srcnt; ++i)
{
if (ConsoleLogSource* log = ConLogSources[i])
@ -592,7 +592,7 @@ void ConsoleLogFrame::OnLoggingChanged()
if( wxMenuItem* item = GetMenuBar()->FindItem(MenuId_LogSource_CDVD_Info) )
item->Check( g_Conf->EmuOptions.CdvdVerboseReads );
uint srcnt = ArraySize(ConLogSources);
uint srcnt = std::size(ConLogSources);
for (uint i=0; i<srcnt; ++i)
{
if (const ConsoleLogSource* log = ConLogSources[i])
@ -858,7 +858,7 @@ void ConsoleLogFrame::OnToggleSource( wxCommandEvent& evt )
uint srcid = evt.GetId() - MenuId_LogSource_Start;
if (!pxAssertDev( ArraySize(ConLogSources) > srcid, "Invalid source log index (out of bounds)" )) return;
if (!pxAssertDev( std::size(ConLogSources) > srcid, "Invalid source log index (out of bounds)" )) return;
if (!pxAssertDev( ConLogSources[srcid] != NULL, "Invalid source log index (NULL pointer [separator])" )) return;
if( wxMenuItem* item = GetMenuBar()->FindItem(evt.GetId()) )

View File

@ -95,10 +95,10 @@ static wxWindowID ParseThatResult( const wxString& src, const MsgButtons& validT
wxID_ANY,
};
for( uint i=0; i<ArraySize( retvals ); ++i )
for (wxWindowID retval : retvals)
{
if( (validTypes.Allows( retvals[i] )) && (src == ResultToString(retvals[i], validTypes)) )
return retvals[i];
if( (validTypes.Allows(retval)) && (src == ResultToString(retval, validTypes)) )
return retval;
}
return wxID_NONE;

View File

@ -52,13 +52,13 @@ Panels::GSWindowSettingsPanel::GSWindowSettingsPanel(wxWindow* parent)
m_text_Zoom = CreateNumericalTextCtrl(this, 5);
m_combo_AspectRatio = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
ArraySize(aspect_ratio_labels), aspect_ratio_labels, wxCB_READONLY);
std::size(aspect_ratio_labels), aspect_ratio_labels, wxCB_READONLY);
m_combo_FMVAspectRatioSwitch = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
ArraySize(fmv_aspect_ratio_switch_labels), fmv_aspect_ratio_switch_labels, wxCB_READONLY);
std::size(fmv_aspect_ratio_switch_labels), fmv_aspect_ratio_switch_labels, wxCB_READONLY);
m_combo_vsync = new wxComboBox(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize,
ArraySize(vsync_label), vsync_label, wxCB_READONLY);
std::size(vsync_label), vsync_label, wxCB_READONLY);
m_text_WindowWidth = CreateNumericalTextCtrl(this, 5);
m_text_WindowHeight = CreateNumericalTextCtrl(this, 5);

View File

@ -166,7 +166,7 @@ static SysTraceLog * const traceLogList[] =
&SysTrace.IOP.MDEC,
};
static const uint traceLogCount = ArraySize(traceLogList);
static const uint traceLogCount = std::size(traceLogList);
void SysTraceLog_LoadSaveSettings( IniInterface& ini )
{

View File

@ -106,7 +106,7 @@ const ListViewColumnInfo& MemoryCardListView_Simple::GetDefaultColumnInfo( uint
{ _("Created on") , 80 , wxLIST_FORMAT_LEFT },
};
pxAssertDev( idx < ArraySize(columns), "ListView column index is out of bounds." );
pxAssertDev( idx < std::size(columns), "ListView column index is out of bounds." );
return columns[idx];
}

View File

@ -336,7 +336,7 @@ bool i18n_SetLanguage( wxLanguage wxLangId, const wxString& langCode )
};
bool foundone = false;
for (uint i=0; i<ArraySize(dictFiles); ++i)
for (uint i=0; i<std::size(dictFiles); ++i)
{
if (!dictFiles[i]) continue;

View File

@ -135,7 +135,7 @@ void __fastcall iopHwWrite8_Page3( u32 addr, mem8_t val )
pbuf[pidx++] = val;
}
if ((pidx == ArraySize(pbuf)-1) || (pbuf[pidx-1] == '\n'))
if ((pidx == std::size(pbuf)-1) || (pbuf[pidx-1] == '\n'))
{
pbuf[pidx] = 0;
iopConLog( ShiftJIS_ConvertString(pbuf) );

View File

@ -587,7 +587,7 @@ void vtlb_MapHandler(vtlbHandler handler, u32 start, u32 size)
verify(0==(size&VTLB_PAGE_MASK) && size>0);
u32 end = start + (size - VTLB_PAGE_SIZE);
pxAssume( (end>>VTLB_PAGE_BITS) < ArraySize(vtlbdata.pmap) );
pxAssume( (end>>VTLB_PAGE_BITS) < std::size(vtlbdata.pmap) );
while (start <= end)
{
@ -607,7 +607,7 @@ void vtlb_MapBlock(void* base, u32 start, u32 size, u32 blocksize)
sptr baseint = (sptr)base;
u32 end = start + (size - VTLB_PAGE_SIZE);
verify((end>>VTLB_PAGE_BITS) < ArraySize(vtlbdata.pmap));
verify((end>>VTLB_PAGE_BITS) < std::size(vtlbdata.pmap));
while (start <= end)
{
@ -632,7 +632,7 @@ void vtlb_Mirror(u32 new_region,u32 start,u32 size)
verify(0==(size&VTLB_PAGE_MASK) && size>0);
u32 end = start + (size-VTLB_PAGE_SIZE);
verify((end>>VTLB_PAGE_BITS) < ArraySize(vtlbdata.pmap));
verify((end>>VTLB_PAGE_BITS) < std::size(vtlbdata.pmap));
while(start <= end)
{

View File

@ -985,7 +985,7 @@ u32 _recIsRegWritten(EEINST* pinst, int size, u8 xmmtype, u8 reg)
while (size-- > 0)
{
for (size_t i = 0; i < ArraySize(pinst->writeType); ++i)
for (size_t i = 0; i < std::size(pinst->writeType); ++i)
{
if ((pinst->writeType[i] == xmmtype) && (pinst->writeReg[i] == reg))
return inst;
@ -1001,7 +1001,7 @@ void _recFillRegister(EEINST& pinst, int type, int reg, int write)
{
if (write)
{
for (size_t i = 0; i < ArraySize(pinst.writeType); ++i)
for (size_t i = 0; i < std::size(pinst.writeType); ++i)
{
if (pinst.writeType[i] == XMMTYPE_TEMP)
{
@ -1014,7 +1014,7 @@ void _recFillRegister(EEINST& pinst, int type, int reg, int write)
}
else
{
for (size_t i = 0; i < ArraySize(pinst.readType); ++i)
for (size_t i = 0; i < std::size(pinst.readType); ++i)
{
if (pinst.readType[i] == XMMTYPE_TEMP)
{

View File

@ -246,7 +246,7 @@ static void iIopDumpBlock(int startpc, u8* ptr)
memzero(used);
numused = 0;
for (i = 0; i < ArraySize(s_pInstCache->regs); ++i)
for (i = 0; i < std::size(s_pInstCache->regs); ++i)
{
if (s_pInstCache->regs[i] & EEINST_USED)
{
@ -256,7 +256,7 @@ static void iIopDumpBlock(int startpc, u8* ptr)
}
f.Printf(" ");
for (i = 0; i < ArraySize(s_pInstCache->regs); ++i)
for (i = 0; i < std::size(s_pInstCache->regs); ++i)
{
if (used[i])
f.Printf("%2d ", i);
@ -264,7 +264,7 @@ static void iIopDumpBlock(int startpc, u8* ptr)
f.Printf("\n");
f.Printf(" ");
for (i = 0; i < ArraySize(s_pInstCache->regs); ++i)
for (i = 0; i < std::size(s_pInstCache->regs); ++i)
{
if (used[i])
f.Printf("%s ", disRNameGPR[i]);
@ -277,7 +277,7 @@ static void iIopDumpBlock(int startpc, u8* ptr)
f.Printf("%2d: %2.2x ", i + 1, pcur->info);
count = 1;
for (j = 0; j < ArraySize(s_pInstCache->regs); j++)
for (j = 0; j < std::size(s_pInstCache->regs); j++)
{
if (used[j])
{
@ -1475,9 +1475,9 @@ StartRecomp:
// dump code
if (IsDebugBuild)
{
for (i = 0; i < ArraySize(s_psxrecblocks); ++i)
for (u32 recblock : s_psxrecblocks)
{
if (startpc == s_psxrecblocks[i])
if (startpc == recblock)
{
iIopDumpBlock(startpc, recPtr);
}

View File

@ -2232,9 +2232,9 @@ StartRecomp:
#ifdef PCSX2_DEBUG
// dump code
for (i = 0; i < ArraySize(s_recblocks); ++i)
for (u32 recblock : s_recblocks)
{
if (startpc == s_recblocks[i])
if (startpc == recblock)
{
iDumpBlock(startpc, recPtr);
}