Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/coreclr/ToolBox/superpmi/superpmi/jitdebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ HRESULT GetCurrentModuleFileName(__out_ecount(*pcchBuffer) LPWSTR pBuffer, __ino
// Get the appname to look up in the exclusion or inclusion list.
WCHAR appPath[MAX_PATH + 2];

DWORD ret = WszGetModuleFileName(NULL, appPath, NumItems(appPath));
DWORD ret = WszGetModuleFileName(NULL, appPath, ARRAY_SIZE(appPath));

if ((ret == NumItems(appPath)) || (ret == 0))
if ((ret == ARRAY_SIZE(appPath)) || (ret == 0))
{
// The module file name exceeded maxpath, or GetModuleFileName failed.
return E_UNEXPECTED;
Expand Down Expand Up @@ -201,7 +201,7 @@ BOOL IsCurrentModuleFileNameInAutoExclusionList()
}

WCHAR wszAppName[MAX_PATH];
DWORD cchAppName = NumItems(wszAppName);
DWORD cchAppName = ARRAY_SIZE(wszAppName);

// Get the appname to look up in the exclusion or inclusion list.
if (GetCurrentModuleFileName(wszAppName, &cchAppName) != S_OK)
Expand Down Expand Up @@ -320,7 +320,7 @@ HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString,

// Get the appname to look up in DebugApplications key.
WCHAR wzAppName[MAX_PATH];
DWORD cchAppName = NumItems(wzAppName);
DWORD cchAppName = ARRAY_SIZE(wzAppName);
long iValue;

// Check DebugApplications setting
Expand All @@ -340,7 +340,7 @@ HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString,
if ((ret == ERROR_SUCCESS) && (valueType == REG_SZ) && (valueSize / sizeof(WCHAR) < MAX_PATH))
{
WCHAR wzAutoKey[MAX_PATH];
valueSize = NumItems(wzAutoKey) * sizeof(WCHAR);
valueSize = ARRAY_SIZE(wzAutoKey) * sizeof(WCHAR);
RegQueryValueExW(hKey, kUnmanagedDebuggerAutoValue, NULL, NULL, reinterpret_cast<LPBYTE>(wzAutoKey),
&valueSize);

Expand All @@ -366,7 +366,7 @@ BOOL LaunchJITDebugger()
BOOL fSuccess = FALSE;

WCHAR debugger[1000];
GetDebuggerSettingInfo(debugger, NumItems(debugger), NULL);
GetDebuggerSettingInfo(debugger, ARRAY_SIZE(debugger), NULL);

SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(sa);
Expand Down
20 changes: 10 additions & 10 deletions src/coreclr/ToolBox/superpmi/superpmi/methodstatsemitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext* mc, ULONGLONG fir
if (mc->dumpMethodMD5HashToBuffer(md5Hash, MD5_HASH_BUFFER_SIZE) != MD5_HASH_BUFFER_SIZE)
md5Hash[0] = 0;

charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%s,", md5Hash);
charCount += sprintf_s(rowData + charCount, ARRAY_SIZE(rowData) - charCount, "%s,", md5Hash);
}
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'n') != NULL || strchr(statsTypes, 'N') != NULL)
{
charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", methodNumber);
charCount += sprintf_s(rowData + charCount, ARRAY_SIZE(rowData) - charCount, "%d,", methodNumber);
}
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'i') != NULL || strchr(statsTypes, 'I') != NULL)
{
Expand All @@ -63,7 +63,7 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext* mc, ULONGLONG fir
CORINFO_OS os = CORINFO_WINNT;
mc->repCompileMethod(&info, &flags, &os);

charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", info.ILCodeSize);
charCount += sprintf_s(rowData + charCount, ARRAY_SIZE(rowData) - charCount, "%d,", info.ILCodeSize);
}
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'a') != NULL || strchr(statsTypes, 'A') != NULL)
{
Expand All @@ -76,12 +76,12 @@ void MethodStatsEmitter::Emit(int methodNumber, MethodContext* mc, ULONGLONG fir
else
codeSize = 0; // this is likely a thin mc

charCount += sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%d,", codeSize);
charCount += sprintf_s(rowData + charCount, ARRAY_SIZE(rowData) - charCount, "%d,", codeSize);
}
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 't') != NULL || strchr(statsTypes, 'T') != NULL)
{
charCount +=
sprintf_s(rowData + charCount, _countof(rowData) - charCount, "%llu,%llu,", firstTime, secondTime);
sprintf_s(rowData + charCount, ARRAY_SIZE(rowData) - charCount, "%llu,%llu,", firstTime, secondTime);
}

// get rid of the final ',' and replace it with a '\n'
Expand All @@ -106,15 +106,15 @@ void MethodStatsEmitter::SetStatsTypes(char* types)
DWORD bytesWritten = 0;

if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'h') != NULL || strchr(statsTypes, 'H') != NULL)
charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "HASH,");
charCount += sprintf_s(rowHeader + charCount, ARRAY_SIZE(rowHeader) - charCount, "HASH,");
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'n') != NULL || strchr(statsTypes, 'N') != NULL)
charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "METHOD_NUMBER,");
charCount += sprintf_s(rowHeader + charCount, ARRAY_SIZE(rowHeader) - charCount, "METHOD_NUMBER,");
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'i') != NULL || strchr(statsTypes, 'I') != NULL)
charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "IL_CODE_SIZE,");
charCount += sprintf_s(rowHeader + charCount, ARRAY_SIZE(rowHeader) - charCount, "IL_CODE_SIZE,");
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 'a') != NULL || strchr(statsTypes, 'A') != NULL)
charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "ASM_CODE_SIZE,");
charCount += sprintf_s(rowHeader + charCount, ARRAY_SIZE(rowHeader) - charCount, "ASM_CODE_SIZE,");
if (strchr(statsTypes, '*') != NULL || strchr(statsTypes, 't') != NULL || strchr(statsTypes, 'T') != NULL)
charCount += sprintf_s(rowHeader + charCount, _countof(rowHeader) - charCount, "Time1,Time2,");
charCount += sprintf_s(rowHeader + charCount, ARRAY_SIZE(rowHeader) - charCount, "Time1,Time2,");

// get rid of the final ',' and replace it with a '\n'
rowHeader[charCount - 1] = '\n';
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/debug/createdump/createdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
#define ___in _SAL1_Source_(__in, (), _In_)
#define ___out _SAL1_Source_(__out, (), _Out_)

#ifndef _countof
#define _countof(x) (sizeof(x)/sizeof(x[0]))
#endif

extern void trace_printf(const char* format, ...);
extern void trace_verbose_printf(const char* format, ...);
extern bool g_diagnostics;
Expand Down
20 changes: 10 additions & 10 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ DacInstanceManager::Add(DAC_INSTANCE* inst)
// use only one block, so improving data locality across blocks (i.e. keeping the buckets of the
// hash table together) should help.
newBlock = (HashInstanceKeyBlock*)
ClrVirtualAlloc(NULL, HASH_INSTANCE_BLOCK_ALLOC_SIZE*NumItems(m_hash), MEM_COMMIT, PAGE_READWRITE);
ClrVirtualAlloc(NULL, HASH_INSTANCE_BLOCK_ALLOC_SIZE*ARRAY_SIZE(m_hash), MEM_COMMIT, PAGE_READWRITE);
}
if (!newBlock)
{
Expand All @@ -1587,7 +1587,7 @@ DacInstanceManager::Add(DAC_INSTANCE* inst)
}
else
{
for (DWORD j = 0; j < NumItems(m_hash); j++)
for (DWORD j = 0; j < ARRAY_SIZE(m_hash); j++)
{
m_hash[j] = newBlock;
newBlock->next = NULL; // The previously allocated block
Expand Down Expand Up @@ -2029,7 +2029,7 @@ void DacInstanceManager::Flush(bool fSaveBlock)
}

#if defined(DAC_HASHTABLE)
for (int i = NumItems(m_hash) - 1; i >= 0; i--)
for (int i = STRING_LENGTH(m_hash); i >= 0; i--)
{
HashInstanceKeyBlock* block = m_hash[i];
HashInstanceKeyBlock* next;
Expand Down Expand Up @@ -2061,7 +2061,7 @@ DacInstanceManager::ClearEnumMemMarker(void)
ULONG i;
DAC_INSTANCE* inst;

for (i = 0; i < NumItems(m_hash); i++)
for (i = 0; i < ARRAY_SIZE(m_hash); i++)
{
HashInstanceKeyBlock* block = m_hash[i];
while (block)
Expand Down Expand Up @@ -2131,7 +2131,7 @@ DacInstanceManager::DumpAllInstances(
int total = 0;
#endif // #if defined(DAC_MEASURE_PERF)

for (i = 0; i < NumItems(m_hash); i++)
for (i = 0; i < ARRAY_SIZE(m_hash); i++)
{

#if defined(DAC_MEASURE_PERF)
Expand Down Expand Up @@ -6636,7 +6636,7 @@ ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
ulRvaHint,
isNGEN,
uniPath,
NumItems(uniPath)))
ARRAY_SIZE(uniPath)))
{
return NULL;
}
Expand Down Expand Up @@ -6700,24 +6700,24 @@ ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly,
imageTimestamp,
imageSize,
uniPath,
NumItems(uniPath)))
ARRAY_SIZE(uniPath)))
{
goto ErrExit;
}

#if defined(FEATURE_CORESYSTEM)
const WCHAR* ilExtension = W("dll");
WCHAR ngenImageName[MAX_LONGPATH] = {0};
if (wcscpy_s(ngenImageName, NumItems(ngenImageName), uniPath) != 0)
if (wcscpy_s(ngenImageName, ARRAY_SIZE(ngenImageName), uniPath) != 0)
{
goto ErrExit;
}
if (wcscpy_s(uniPath, NumItems(uniPath), ngenImageName) != 0)
if (wcscpy_s(uniPath, ARRAY_SIZE(uniPath), ngenImageName) != 0)
{
goto ErrExit;
}
// Transform NGEN image name into IL Image name
if (!GetILImageNameFromNgenImage(ilExtension, uniPath, NumItems(uniPath)))
if (!GetILImageNameFromNgenImage(ilExtension, uniPath, ARRAY_SIZE(uniPath)))
{
goto ErrExit;
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/inspect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2296,7 +2296,7 @@ ClrDataTypeDefinition::GetName(
if ((status =
GetFullClassNameFromMetadata(m_module->GetMDImport(),
m_token,
NumItems(classNameBuf),
ARRAY_SIZE(classNameBuf),
classNameBuf)) == S_OK)
{
status = ConvertUtf8(classNameBuf, bufLen, nameLen, nameBuf);
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ ClrDataAccess::GetRegisterName(int regNum, unsigned int count, __out_z __inout_e
if (callerFrame)
regNum = -regNum-1;

if ((unsigned int)regNum >= _countof(regs))
if ((unsigned int)regNum >= ARRAY_SIZE(regs))
return E_UNEXPECTED;


Expand Down Expand Up @@ -1371,8 +1371,8 @@ ClrDataAccess::GetMethodDescName(CLRDATA_ADDRESS methodDesc, unsigned int count,
{
WCHAR path[MAX_LONGPATH];
COUNT_T nChars = 0;
if (pModule->GetPath().DacGetUnicode(NumItems(path), path, &nChars) &&
nChars > 0 && nChars <= NumItems(path))
if (pModule->GetPath().DacGetUnicode(ARRAY_SIZE(path), path, &nChars) &&
nChars > 0 && nChars <= ARRAY_SIZE(path))
{
WCHAR* pFile = path + nChars - 1;
while ((pFile >= path) && (*pFile != W('\\')))
Expand Down Expand Up @@ -3274,7 +3274,7 @@ HRESULT ClrDataAccess::GetHandleEnum(ISOSHandleEnum **ppHandleEnum)
#endif // FEATURE_COMINTEROP
};

return GetHandleEnumForTypes(types, _countof(types), ppHandleEnum);
return GetHandleEnumForTypes(types, ARRAY_SIZE(types), ppHandleEnum);
}

HRESULT ClrDataAccess::GetHandleEnumForTypes(unsigned int types[], unsigned int count, ISOSHandleEnum **ppHandleEnum)
Expand Down Expand Up @@ -3317,7 +3317,7 @@ HRESULT ClrDataAccess::GetHandleEnumForGC(unsigned int gen, ISOSHandleEnum **ppH

DacHandleWalker *walker = new DacHandleWalker();

HRESULT hr = walker->Init(this, types, _countof(types), gen);
HRESULT hr = walker->Init(this, types, ARRAY_SIZE(types), gen);
if (SUCCEEDED(hr))
hr = walker->QueryInterface(__uuidof(ISOSHandleEnum), (void**)ppHandleEnum);

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ ClrDataFrame::ValueFromDebugInfo(MetaSig* sig,
else
{
numLocs = NativeVarLocations(varInfo[i].loc, &m_context,
NumItems(locs), locs);
ARRAY_SIZE(locs), locs);
}

if (numLocs == 1 && !locs[0].contextReg)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,7 @@ ClrDataMethodDefinition::GetName(

status = GetFullMethodNameFromMetadata(m_module->GetMDImport(),
m_token,
NumItems(methName),
ARRAY_SIZE(methName),
methName);
if (status == S_OK)
{
Expand Down Expand Up @@ -3885,7 +3885,7 @@ ClrDataMethodInstance::GetName(
wcscpy_s(name, bufLen, nameUnk);
if (nameLen != NULL)
{
*nameLen = _countof(nameUnk);
*nameLen = ARRAY_SIZE(nameUnk);
}
status = S_OK;
}
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/debug/di/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5102,11 +5102,11 @@ HRESULT CordbNativeCode::GetCallSignature(ULONG32 ILoffset, mdToken *pClass, mdT
CordbILCode *pCode = this->m_pFunction->GetILCode();
BYTE buffer[3];
ULONG32 fetched = 0;
HRESULT hr = pCode->GetCode(ILoffset, ILoffset+_countof(buffer), _countof(buffer), buffer, &fetched);
HRESULT hr = pCode->GetCode(ILoffset, ILoffset+ARRAY_SIZE(buffer), ARRAY_SIZE(buffer), buffer, &fetched);

if (FAILED(hr))
return hr;
else if (fetched != _countof(buffer))
else if (fetched != ARRAY_SIZE(buffer))
return CORDBG_E_INVALID_OPCODE;

// tail. - fe 14 (ECMA III.2.4)
Expand Down Expand Up @@ -5165,7 +5165,7 @@ HRESULT CordbNativeCode::GetReturnValueLiveOffsetImpl(Instantiation *currentInst
BYTE nativeBuffer[8];

ULONG32 fetched = 0;
IfFailRet(GetCode(pMap->nativeStartOffset, pMap->nativeStartOffset+_countof(nativeBuffer), _countof(nativeBuffer), nativeBuffer, &fetched));
IfFailRet(GetCode(pMap->nativeStartOffset, pMap->nativeStartOffset+ARRAY_SIZE(nativeBuffer), ARRAY_SIZE(nativeBuffer), nativeBuffer, &fetched));

int skipBytes = 0;

Expand All @@ -5177,12 +5177,12 @@ HRESULT CordbNativeCode::GetReturnValueLiveOffsetImpl(Instantiation *currentInst
{
skipBytes++;

for (int j = 1; j < _countof(nativeBuffer) && nativeBuffer[j] == nop_opcode; ++j)
for (int j = 1; j < ARRAY_SIZE(nativeBuffer) && nativeBuffer[j] == nop_opcode; ++j)
skipBytes++;

// We must have at least one skip byte since the outer while ensures it. Thus we always need to reread
// the buffer at the end of this loop.
IfFailRet(GetCode(pMap->nativeStartOffset+skipBytes, pMap->nativeStartOffset+skipBytes+_countof(nativeBuffer), _countof(nativeBuffer), nativeBuffer, &fetched));
IfFailRet(GetCode(pMap->nativeStartOffset+skipBytes, pMap->nativeStartOffset+skipBytes+ARRAY_SIZE(nativeBuffer), ARRAY_SIZE(nativeBuffer), nativeBuffer, &fetched));
}
#endif

Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/debug/di/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2709,15 +2709,15 @@ HRESULT CordbRefEnum::Next(ULONG celt, COR_GC_REFERENCE refs[], ULONG *pceltFetc
if (SUCCEEDED(hr))
{
DacGcReference dacRefs[32];
ULONG toFetch = _countof(dacRefs);
ULONG toFetch = ARRAY_SIZE(dacRefs);
ULONG total = 0;

for (ULONG c = 0; SUCCEEDED(hr) && c < (celt/_countof(dacRefs) + 1); ++c)
for (ULONG c = 0; SUCCEEDED(hr) && c < (celt/ARRAY_SIZE(dacRefs) + 1); ++c)
{
// Fetch 32 references at a time, the last time, only fetch the remainder (that is, if
// the user didn't fetch a multiple of 32).
if (c == celt/_countof(dacRefs))
toFetch = celt % _countof(dacRefs);
if (c == celt/ARRAY_SIZE(dacRefs))
toFetch = celt % ARRAY_SIZE(dacRefs);

ULONG fetched = 0;
hr = process->GetDAC()->WalkRefs(mRefHandle, toFetch, dacRefs, &fetched);
Expand Down Expand Up @@ -7739,7 +7739,7 @@ HRESULT CordbProcess::GetRuntimeOffsets()
m_runtimeOffsets.m_notifyRSOfSyncCompleteBPAddr,
};

const int NumFlares = NumItems(flares);
const int NumFlares = ARRAY_SIZE(flares);

// Ensure that all of the flares are unique.
for(int i = 0; i < NumFlares; i++)
Expand Down Expand Up @@ -10135,7 +10135,7 @@ HRESULT CordbRCEventThread::SendIPCEvent(CordbProcess* process,
// Note that in case of a tie (multiple handles signaled), WaitForMultipleObjects gives
// priority to the handle earlier in the array.
HANDLE waitSet[] = { process->GetEventChannel()->GetRightSideEventAckHandle(), hLSProcess, hHelperThread};
DWORD cWaitSet = NumItems(waitSet);
DWORD cWaitSet = ARRAY_SIZE(waitSet);
if (hHelperThread == NULL)
{
cWaitSet--;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/di/rsclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ HRESULT CordbClass::SetJMCStatus(BOOL fIsUserCode)
pImport = pModule->GetMetaDataImporter();
do
{
hr = pImport->EnumMethods(&phEnum, m_token, rTokens, NumItems(rTokens), &count);
hr = pImport->EnumMethods(&phEnum, m_token, rTokens, ARRAY_SIZE(rTokens), &count);
IfFailThrow(hr);

for (i = 0; i < count; i++)
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ void DoAssertOnType(DebuggerIPCEventType event, int count)
if (g_iDbgRuntimeCounter[event & 0x00ff] == count)
{
char tmpStr[256];
_snprintf_s(tmpStr, _countof(tmpStr), _TRUNCATE, "%s == %d, break now!",
_snprintf_s(tmpStr, ARRAY_SIZE(tmpStr), _TRUNCATE, "%s == %d, break now!",
IPCENames::GetName(event), count);

// fire the assertion
Expand All @@ -586,7 +586,7 @@ void DoAssertOnType(DebuggerIPCEventType event, int count)
if (g_iDbgDebuggerCounter[event & 0x00ff] == count)
{
char tmpStr[256];
_snprintf_s(tmpStr, _countof(tmpStr), _TRUNCATE, "%s == %d, break now!",
_snprintf_s(tmpStr, ARRAY_SIZE(tmpStr), _TRUNCATE, "%s == %d, break now!",
IPCENames::GetName(event), count);

// fire the assertion
Expand Down Expand Up @@ -1660,7 +1660,7 @@ void Debugger::SendRawEvent(const DebuggerIPCEvent * pManagedEvent)
EX_TRY
{
const DWORD dwFlags = 0; // continuable (eg, Debugger can continue GH)
RaiseException(CLRDBG_NOTIFICATION_EXCEPTION_CODE, dwFlags, NumItems(rgData), rgData);
RaiseException(CLRDBG_NOTIFICATION_EXCEPTION_CODE, dwFlags, ARRAY_SIZE(rgData), rgData);

// If debugger continues "GH" (DBG_CONTINUE), then we land here.
// This is the expected path for a well-behaved ICorDebug debugger.
Expand Down Expand Up @@ -1841,7 +1841,7 @@ HRESULT Debugger::Startup(void)
{
for (i = 0; i < dwRegVal; i++)
{
int iProc = GetRandomInt(NumItems(g_pStressProcs));
int iProc = GetRandomInt(ARRAY_SIZE(g_pStressProcs));
LPTHREAD_START_ROUTINE pStartRoutine = g_pStressProcs[iProc];
::CreateThread(NULL, 0, pStartRoutine, NULL, 0, &dwId);
LOG((LF_CORDB, LL_INFO1000, "Created random thread (%d) with tid=0x%x\n", i, dwId));
Expand Down
Loading