diff --git a/src/coreclr/ToolBox/superpmi/superpmi/jitdebugger.cpp b/src/coreclr/ToolBox/superpmi/superpmi/jitdebugger.cpp index d3956fc989529..169d0a268483b 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi/jitdebugger.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi/jitdebugger.cpp @@ -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; @@ -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) @@ -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 @@ -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(wzAutoKey), &valueSize); @@ -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); diff --git a/src/coreclr/ToolBox/superpmi/superpmi/methodstatsemitter.cpp b/src/coreclr/ToolBox/superpmi/superpmi/methodstatsemitter.cpp index 51ecfab64fb46..b8f09f921e1d6 100644 --- a/src/coreclr/ToolBox/superpmi/superpmi/methodstatsemitter.cpp +++ b/src/coreclr/ToolBox/superpmi/superpmi/methodstatsemitter.cpp @@ -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) { @@ -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) { @@ -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' @@ -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'; diff --git a/src/coreclr/debug/createdump/createdump.h b/src/coreclr/debug/createdump/createdump.h index f588867c7926f..f8bab8f320b3e 100644 --- a/src/coreclr/debug/createdump/createdump.h +++ b/src/coreclr/debug/createdump/createdump.h @@ -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; diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index 35b834542c91c..0e201dd4b812d 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -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) { @@ -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 @@ -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; @@ -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) @@ -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) @@ -6636,7 +6636,7 @@ ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly, ulRvaHint, isNGEN, uniPath, - NumItems(uniPath))) + ARRAY_SIZE(uniPath))) { return NULL; } @@ -6700,7 +6700,7 @@ ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly, imageTimestamp, imageSize, uniPath, - NumItems(uniPath))) + ARRAY_SIZE(uniPath))) { goto ErrExit; } @@ -6708,16 +6708,16 @@ ClrDataAccess::GetMetaDataFromHost(PEAssembly* pPEAssembly, #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; } diff --git a/src/coreclr/debug/daccess/inspect.cpp b/src/coreclr/debug/daccess/inspect.cpp index 28375862bd38a..21afb220103cb 100644 --- a/src/coreclr/debug/daccess/inspect.cpp +++ b/src/coreclr/debug/daccess/inspect.cpp @@ -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); diff --git a/src/coreclr/debug/daccess/request.cpp b/src/coreclr/debug/daccess/request.cpp index 4b6f3413b0df1..42b641385b5f2 100644 --- a/src/coreclr/debug/daccess/request.cpp +++ b/src/coreclr/debug/daccess/request.cpp @@ -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; @@ -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('\\'))) @@ -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) @@ -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); diff --git a/src/coreclr/debug/daccess/stack.cpp b/src/coreclr/debug/daccess/stack.cpp index 94ef49b972ad2..6ced6d60b3539 100644 --- a/src/coreclr/debug/daccess/stack.cpp +++ b/src/coreclr/debug/daccess/stack.cpp @@ -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) diff --git a/src/coreclr/debug/daccess/task.cpp b/src/coreclr/debug/daccess/task.cpp index 5c8c3d0152dcf..b8e4e4357ffa7 100644 --- a/src/coreclr/debug/daccess/task.cpp +++ b/src/coreclr/debug/daccess/task.cpp @@ -3139,7 +3139,7 @@ ClrDataMethodDefinition::GetName( status = GetFullMethodNameFromMetadata(m_module->GetMDImport(), m_token, - NumItems(methName), + ARRAY_SIZE(methName), methName); if (status == S_OK) { @@ -3885,7 +3885,7 @@ ClrDataMethodInstance::GetName( wcscpy_s(name, bufLen, nameUnk); if (nameLen != NULL) { - *nameLen = _countof(nameUnk); + *nameLen = ARRAY_SIZE(nameUnk); } status = S_OK; } diff --git a/src/coreclr/debug/di/module.cpp b/src/coreclr/debug/di/module.cpp index b48e12afc96be..9951d4a6af305 100644 --- a/src/coreclr/debug/di/module.cpp +++ b/src/coreclr/debug/di/module.cpp @@ -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) @@ -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; @@ -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 diff --git a/src/coreclr/debug/di/process.cpp b/src/coreclr/debug/di/process.cpp index c6c16d0700a85..dd90a5c8a7242 100644 --- a/src/coreclr/debug/di/process.cpp +++ b/src/coreclr/debug/di/process.cpp @@ -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); @@ -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++) @@ -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--; diff --git a/src/coreclr/debug/di/rsclass.cpp b/src/coreclr/debug/di/rsclass.cpp index 70e64b63062b8..40d886de9935e 100644 --- a/src/coreclr/debug/di/rsclass.cpp +++ b/src/coreclr/debug/di/rsclass.cpp @@ -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++) diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 0f61f8d36c78e..f26b09de180f3 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -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 @@ -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 @@ -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. @@ -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)); diff --git a/src/coreclr/debug/ee/rcthread.cpp b/src/coreclr/debug/ee/rcthread.cpp index 29d2f57fbf004..18c840edbb698 100644 --- a/src/coreclr/debug/ee/rcthread.cpp +++ b/src/coreclr/debug/ee/rcthread.cpp @@ -1756,7 +1756,7 @@ void DebuggerRCThread::DoFavor(FAVORCALLBACK fp, void * pData) GCX_PREEMP(); DWORD ret = WaitForMultipleObjectsEx( - NumItems(waitset), + ARRAY_SIZE(waitset), waitset, FALSE, INFINITE, diff --git a/src/coreclr/debug/inc/amd64/primitives.h b/src/coreclr/debug/inc/amd64/primitives.h index 9d363938519c7..290028aceb79f 100644 --- a/src/coreclr/debug/inc/amd64/primitives.h +++ b/src/coreclr/debug/inc/amd64/primitives.h @@ -80,7 +80,7 @@ constexpr CorDebugRegister g_JITToCorDbgReg[] = inline CorDebugRegister ConvertRegNumToCorDebugRegister(ICorDebugInfo::RegNum reg) { _ASSERTE(reg >= 0); - _ASSERTE(static_cast(reg) < _countof(g_JITToCorDbgReg)); + _ASSERTE(static_cast(reg) < ARRAY_SIZE(g_JITToCorDbgReg)); return g_JITToCorDbgReg[reg]; } diff --git a/src/coreclr/debug/inc/arm_primitives.h b/src/coreclr/debug/inc/arm_primitives.h index bab9608155291..0cc2dfc436aea 100644 --- a/src/coreclr/debug/inc/arm_primitives.h +++ b/src/coreclr/debug/inc/arm_primitives.h @@ -20,7 +20,7 @@ inline CorDebugRegister ConvertRegNumToCorDebugRegister(ICorDebugInfo::RegNum re { LIMITED_METHOD_CONTRACT; _ASSERTE(reg >= 0); - _ASSERTE(static_cast(reg) < _countof(g_JITToCorDbgReg)); + _ASSERTE(static_cast(reg) < ARRAY_SIZE(g_JITToCorDbgReg)); return g_JITToCorDbgReg[reg]; } diff --git a/src/coreclr/debug/shared/utils.cpp b/src/coreclr/debug/shared/utils.cpp index b9c7d72db3f70..85f17b50c44e7 100644 --- a/src/coreclr/debug/shared/utils.cpp +++ b/src/coreclr/debug/shared/utils.cpp @@ -130,7 +130,7 @@ void GetPidDecoratedName(__out_z __out_ecount(cBufSizeInChars) WCHAR * pBuf, int { const WCHAR szGlobal[] = W("Global\\"); int szGlobalLen; - szGlobalLen = NumItems(szGlobal) - 1; + szGlobalLen = STRING_LENGTH(szGlobal); // Caller should always give us a big enough buffer. _ASSERTE(cBufSizeInChars > (int) wcslen(pPrefix) + szGlobalLen); diff --git a/src/coreclr/dlls/dbgshim/dbgshim.cpp b/src/coreclr/dlls/dbgshim/dbgshim.cpp index c428707d2cf71..ac1e2d7fe189a 100644 --- a/src/coreclr/dlls/dbgshim/dbgshim.cpp +++ b/src/coreclr/dlls/dbgshim/dbgshim.cpp @@ -377,8 +377,8 @@ class RuntimeStartupHelper goto exit; } - strncpy_s(dbiPath, _countof(dbiPath), pszModulePath, pszLast - pszModulePath); - strcat_s(dbiPath, _countof(dbiPath), DIRECTORY_SEPARATOR_STR_A MAKEDLLNAME_A("mscordbi")); + strncpy_s(dbiPath, ARRAY_SIZE(dbiPath), pszModulePath, pszLast - pszModulePath); + strcat_s(dbiPath, ARRAY_SIZE(dbiPath), DIRECTORY_SEPARATOR_STR_A MAKEDLLNAME_A("mscordbi")); hMod = LoadLibraryA(dbiPath); if (hMod == NULL) @@ -580,7 +580,7 @@ class RuntimeStartupHelper { *pCoreClrExists = TRUE; - hr = CreateVersionStringFromModule(m_processId, stringArray[i], verStr, _countof(verStr), &verLen); + hr = CreateVersionStringFromModule(m_processId, stringArray[i], verStr, ARRAY_SIZE(verStr), &verLen); if (FAILED(hr)) { goto exit; diff --git a/src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp b/src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp index beb0ee71d514d..dae8b0c515fa3 100644 --- a/src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp +++ b/src/coreclr/dlls/mscorpe/ceefilegenwritertokens.cpp @@ -54,7 +54,7 @@ HRESULT CeeFileGenWriter::MapTokens( while ((hr = pImport->EnumMethods(&hEnum, mdTokenNil, &md, 1, &count)) == S_OK) { hr = pImport->GetMethodProps(md, NULL, - rcwName, lengthof(rcwName), NULL, + rcwName, ARRAY_SIZE(rcwName), NULL, &dwFlags, NULL, NULL, &MethodRVA, &iFlags); _ASSERTE(SUCCEEDED(hr)); @@ -80,7 +80,7 @@ HRESULT CeeFileGenWriter::MapTokens( while ((hr = pImport->EnumMethods(&hEnum, td, &md, 1, &count)) == S_OK) { hr = pImport->GetMethodProps(md, NULL, - rcwName, lengthof(rcwName), NULL, + rcwName, ARRAY_SIZE(rcwName), NULL, &dwFlags, NULL, NULL, &MethodRVA, &iFlags); _ASSERTE(SUCCEEDED(hr)); diff --git a/src/coreclr/dlls/mscorpe/pewriter.cpp b/src/coreclr/dlls/mscorpe/pewriter.cpp index f1efec649c459..9add4b56d13b8 100644 --- a/src/coreclr/dlls/mscorpe/pewriter.cpp +++ b/src/coreclr/dlls/mscorpe/pewriter.cpp @@ -270,7 +270,7 @@ HRESULT PEWriterSection::applyRelocs(IMAGE_NT_HEADERS * pNtHeaders, #ifdef LOGGING // Ensure that if someone adds a value to CeeSectionRelocType in cor.h, // that they also add an entry to RelocName. - static_assert_no_msg(NumItems(RelocName) == srRelocSentinel); + static_assert_no_msg(ARRAY_SIZE(RelocName) == srRelocSentinel); #ifdef _DEBUG for (unsigned int i = 0; i < srRelocSentinel; i++) { @@ -1517,7 +1517,7 @@ void PEWriter::setSectionIndex(IMAGE_SECTION_HEADER * h, unsigned sectionIndex) // static const char * const SpecialNames[] = { ".text", ".cormeta", NULL }; - enum { SPECIAL_NAMES_COUNT = NumItems(SpecialNames) }; + enum { SPECIAL_NAMES_COUNT = ARRAY_SIZE(SpecialNames) }; for (const char * const * s = SpecialNames; /**/; s++) { diff --git a/src/coreclr/gc/env/gcenv.base.h b/src/coreclr/gc/env/gcenv.base.h index 5cb2f4178ce0c..59f01879d2ff1 100644 --- a/src/coreclr/gc/env/gcenv.base.h +++ b/src/coreclr/gc/env/gcenv.base.h @@ -6,6 +6,8 @@ // Sets up basic environment for CLR GC // +#include + #ifdef _MSC_VER #include #endif // _MSC_VER @@ -94,10 +96,6 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x) #define ZeroMemory(Destination,Length) memset((Destination),0,(Length)) -#ifndef _countof -#define _countof(_array) (sizeof(_array)/sizeof(_array[0])) -#endif - #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 795688ff90c48..025524d9392c6 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -73,7 +73,7 @@ BOOL bgc_heap_walk_for_etw_p = FALSE; #define demotion_pinned_ratio_th (1) // If the survived / region_size is 90+%, we don't compact this region. #define sip_surv_ratio_th (90) -// If the survived due to cards from old generations / region_size is 90+%, +// If the survived due to cards from old generations / region_size is 90+%, // we don't compact this region, also we immediately promote it to gen2. #define sip_old_card_surv_ratio_th (90) #else @@ -474,7 +474,7 @@ void log_va_msg(const char *fmt, va_list args) pBuffer[0] = '\n'; int buffer_start = 1; - int pid_len = sprintf_s (&pBuffer[buffer_start], BUFFERSIZE - buffer_start, + int pid_len = sprintf_s (&pBuffer[buffer_start], BUFFERSIZE - buffer_start, "[%5d]", (uint32_t)GCToOSInterface::GetCurrentThreadIdForLogging()); buffer_start += pid_len; memset(&pBuffer[buffer_start], '-', BUFFERSIZE - buffer_start); @@ -490,7 +490,7 @@ void log_va_msg(const char *fmt, va_list args) { char index_str[8]; memset (index_str, '-', 8); - sprintf_s (index_str, _countof(index_str), "%d", (int)gc_buffer_index); + sprintf_s (index_str, ARRAY_SIZE(index_str), "%d", (int)gc_buffer_index); gc_log_buffer[gc_log_buffer_offset] = '\n'; memcpy (gc_log_buffer + (gc_log_buffer_offset + 1), index_str, 8); @@ -651,8 +651,8 @@ uint32_t g_num_active_processors = 0; // Note that when a join is no longer used we still keep the values here because // tooling already recognized them as having the meaning they were assigned originally. -// It doesn't break tooling if we stop using them but does if we assign a new meaning -// to them. +// It doesn't break tooling if we stop using them but does if we assign a new meaning +// to them. enum gc_join_stage { gc_join_init_cpu_mapping = 0, @@ -2789,7 +2789,7 @@ size_t gc_heap::smoothed_desired_per_heap[total_generation_count]; /* end of static initialization */ // This is for methods that need to iterate through all SOH heap segments/regions. -inline +inline int get_start_generation_index() { #ifdef USE_REGIONS @@ -2799,7 +2799,7 @@ int get_start_generation_index() #endif //USE_REGIONS } -inline +inline int get_stop_generation_index (int condemned_gen_number) { #ifdef USE_REGIONS @@ -2971,7 +2971,7 @@ void gc_heap::fire_pevents() #ifdef FEATURE_EVENT_TRACE if (!informational_event_enabled_p) return; - uint32_t count_time_info = (settings.concurrent ? max_bgc_time_type : + uint32_t count_time_info = (settings.concurrent ? max_bgc_time_type : (settings.compaction ? max_compact_time_type : max_sweep_time_type)); #ifdef BACKGROUND_GC @@ -3017,7 +3017,7 @@ void gc_heap::fire_pevents() #ifdef FEATURE_LOH_COMPACTION if (!settings.concurrent && settings.loh_compaction) { - // Not every heap will compact LOH, the ones that didn't will just have 0s + // Not every heap will compact LOH, the ones that didn't will just have 0s // in its info. FIRE_EVENT(GCLOHCompact, get_num_heaps(), @@ -3498,7 +3498,7 @@ size_t get_basic_region_index_for_address (uint8_t* address) return (basic_region_index - ((size_t)g_gc_lowest_address >> gc_heap::min_segment_size_shr)); } -// Go from a random address to its region info. The random address could be +// Go from a random address to its region info. The random address could be // in one of the basic regions of a larger region so we need to check for that. inline heap_segment* get_region_info_for_address (uint8_t* address) @@ -3574,7 +3574,7 @@ bool region_allocator::init (uint8_t* start, uint8_t* end, size_t alignment, uin memset (unit_map, 0, sizeof (uint32_t) * total_num_units); region_map_left_start = unit_map; region_map_left_end = region_map_left_start; - + region_map_right_start = unit_map + total_num_units; region_map_right_end = region_map_right_start; @@ -3583,7 +3583,7 @@ bool region_allocator::init (uint8_t* start, uint8_t* end, size_t alignment, uin (size_t)((end - start) / 1024 / 1024), (alignment / 1024 / 1024), total_num_units)); - + *lowest = global_region_start; *highest = global_region_end; } @@ -3660,7 +3660,7 @@ void region_allocator::print_map (const char* msg) count_free_units += (uint32_t)(region_map_right_start - region_map_left_end); assert(count_free_units == total_free_units); - uint32_t total_regions = (uint32_t)((global_region_end - global_region_start) / region_alignment); + uint32_t total_regions = (uint32_t)((global_region_end - global_region_start) / region_alignment); dprintf (REGIONS_LOG, ("[%s]-----end printing----[%d total, left used %d, right used %d]\n", heap_type, total_regions, (region_map_left_end - region_map_left_start), (region_map_right_end - region_map_right_start))); #endif //_DEBUG @@ -3686,7 +3686,7 @@ uint8_t* region_allocator::allocate_end (uint32_t num_units, allocate_direction global_region_left_used += num_units * region_alignment; } else - { + { assert(direction == allocate_backward); region_map_right_start -= num_units; make_busy_block (region_map_right_start, num_units); @@ -3918,14 +3918,14 @@ void region_allocator::delete_region_impl (uint8_t* region_start) if (region_end == global_region_left_used) { region_map_left_end = free_index; - dprintf (REGIONS_LOG, ("adjust global left used from %Ix to %Ix", + dprintf (REGIONS_LOG, ("adjust global left used from %Ix to %Ix", global_region_left_used, region_address_of (free_index))); global_region_left_used = region_address_of (free_index); } else if (region_start == global_region_right_used) { region_map_right_start = free_index + free_block_size; - dprintf (REGIONS_LOG, ("adjust global right used from %Ix to %Ix", + dprintf (REGIONS_LOG, ("adjust global right used from %Ix to %Ix", global_region_right_used, region_address_of (free_index + free_block_size))); global_region_right_used = region_address_of (free_index + free_block_size); } @@ -3992,7 +3992,7 @@ size_t size_seg_mapping_table_of (uint8_t* from, uint8_t* end) { from = align_lower_segment (from); end = align_on_segment (end); - dprintf (1, ("from: %Ix, end: %Ix, size: %Ix", from, end, + dprintf (1, ("from: %Ix, end: %Ix, size: %Ix", from, end, sizeof (seg_mapping)*(((size_t)(end - from) >> gc_heap::min_segment_size_shr)))); return sizeof (seg_mapping)*((size_t)(end - from) >> gc_heap::min_segment_size_shr); } @@ -4185,7 +4185,7 @@ gc_heap* seg_mapping_table_heap_of_worker (uint8_t* o) #ifdef USE_REGIONS gc_heap* hp = heap_segment_heap ((heap_segment*)entry); -#else +#else gc_heap* hp = ((o > entry->boundary) ? entry->h1 : entry->h0); dprintf (2, ("checking obj %Ix, index is %Id, entry: boundary: %Ix, h0: %Ix, seg0: %Ix, h1: %Ix, seg1: %Ix", @@ -4254,14 +4254,14 @@ heap_segment* seg_mapping_table_segment_of (uint8_t* o) seg_mapping* entry = &seg_mapping_table[index]; #ifdef USE_REGIONS - // REGIONS TODO: I think we could simplify this to having the same info for each - // basic entry in a large region so we can get it right away instead of having to go + // REGIONS TODO: I think we could simplify this to having the same info for each + // basic entry in a large region so we can get it right away instead of having to go // back some entries. ptrdiff_t first_field = (ptrdiff_t)heap_segment_allocated ((heap_segment*)entry); if (first_field == 0) { dprintf (REGIONS_LOG, ("asked for seg for %Ix, in a freed region mem: %Ix, committed %Ix", - o, heap_segment_mem ((heap_segment*)entry), + o, heap_segment_mem ((heap_segment*)entry), heap_segment_committed ((heap_segment*)entry))); return 0; } @@ -4729,7 +4729,7 @@ heap_segment* heap_segment_non_sip (heap_segment* ns) { if (heap_segment_swept_in_plan (ns)) { - dprintf (REGIONS_LOG, ("region %Ix->%Ix SIP", + dprintf (REGIONS_LOG, ("region %Ix->%Ix SIP", heap_segment_mem (ns), heap_segment_allocated (ns))); } @@ -4938,7 +4938,7 @@ BOOL gc_heap::reserve_initial_memory (size_t normal_size, size_t large_size, siz memory_details.initial_memory = new (nothrow) imemory_data[num_heaps * (total_generation_count - ephemeral_generation_count)]; if (memory_details.initial_memory == 0) { - dprintf (2, ("failed to reserve %Id bytes for imemory_data", + dprintf (2, ("failed to reserve %Id bytes for imemory_data", num_heaps * (total_generation_count - ephemeral_generation_count) * sizeof (imemory_data))); return FALSE; } @@ -5075,7 +5075,7 @@ BOOL gc_heap::reserve_initial_memory (size_t normal_size, size_t large_size, siz { numa_reserved_block * block = &memory_details.numa_reserved_block_table[numa_node]; - numa_reserved_block* pinned_block = separated_poh_p ? + numa_reserved_block* pinned_block = separated_poh_p ? &memory_details.numa_reserved_block_table[numa_node_count + numa_node] : nullptr; // if the block's size is 0, there can be no heaps on this NUMA node @@ -5145,7 +5145,7 @@ BOOL gc_heap::reserve_initial_memory (size_t normal_size, size_t large_size, siz if (separated_poh_p) { g_gc_lowest_address = min(allatonce_block, separated_poh_block); - g_gc_highest_address = max((allatonce_block + requestedMemory), + g_gc_highest_address = max((allatonce_block + requestedMemory), (separated_poh_block + separate_pinned_size)); memory_details.allocation_pattern = initial_memory_details::ALLATONCE_SEPARATED_POH; } @@ -5301,7 +5301,7 @@ void gc_heap::destroy_initial_memory() case initial_memory_details::EACH_BLOCK: { imemory_data* current_block = memory_details.initial_memory; - int total_block_count = memory_details.block_count * + int total_block_count = memory_details.block_count * (total_generation_count - ephemeral_generation_count); for (int i = 0; i < total_block_count; i++, current_block++) { @@ -6477,10 +6477,10 @@ void gc_heap::hb_log_balance_activities() if (total_entries_on_proc > 0) { int total_exec_time_ms = - (int)((double)(hb_info_proc->hb_info[total_entries_on_proc - 1].timestamp - + (int)((double)(hb_info_proc->hb_info[total_entries_on_proc - 1].timestamp - hb_info_proc->hb_info[0].timestamp) * qpf_ms); dprintf (HEAP_BALANCE_LOG, ("[p%d]-%d-%dms", - (proc_index + numa_node_index * procs_per_numa_node), + (proc_index + numa_node_index * procs_per_numa_node), total_entries_on_proc, total_exec_time_ms)); } @@ -6576,7 +6576,7 @@ void gc_heap::hb_log_new_allocation() allocated_mb); } - dprintf (HEAP_BALANCE_TEMP_LOG, ("TEMPN#%d a %dmb(%dmb)", + dprintf (HEAP_BALANCE_TEMP_LOG, ("TEMPN#%d a %dmb(%dmb)", numa_node_index, node_allocated_mb, desired_alloc_mb)); buffer_pos += sprintf_s (hb_log_buffer + buffer_pos, hb_log_buffer_size - buffer_pos, "\n"); @@ -7647,7 +7647,7 @@ void gc_heap::set_allocator_next_pin (generation* gen) (plug < generation_allocation_limit (gen))) { #ifdef USE_REGIONS - assert (region_of (generation_allocation_pointer (gen)) == + assert (region_of (generation_allocation_pointer (gen)) == region_of (generation_allocation_limit (gen) - 1)); #endif //USE_REGIONS generation_allocation_limit (gen) = pinned_plug (oldest_entry); @@ -7752,7 +7752,7 @@ bool gc_heap::is_in_condemned_gc (uint8_t* o) // REGIONS TODO - // This method can be called by GCHeap::Promote/Relocate which means // it could be in the heap range but not actually in a valid region. -// This would return true but find_object will return 0. But this +// This would return true but find_object will return 0. But this // seems counter-intuitive so we should consider a better implementation. inline bool gc_heap::is_in_condemned (uint8_t* o) @@ -8529,7 +8529,7 @@ void gc_heap::get_card_table_element_sizes (uint8_t* start, uint8_t* end, size_t if (gc_can_use_concurrent) { sizes[mark_array_element] = size_mark_array_of (start, end); - } + } #endif //BACKGROUND_GC } @@ -8538,7 +8538,7 @@ void gc_heap::get_card_table_element_layout (uint8_t* start, uint8_t* end, size_ size_t sizes[total_bookkeeping_elements]; get_card_table_element_sizes(start, end, sizes); - const size_t alignment[total_bookkeeping_elements + 1] = + const size_t alignment[total_bookkeeping_elements + 1] = { sizeof (uint32_t), // card_table_element sizeof (short), // brick_table_element @@ -9780,7 +9780,7 @@ uint8_t** gc_heap::equalize_mark_lists (size_t total_mark_list_size) if (local_mark_count[heap_number] >= this_target_mark_count) return (mark_list + this_target_mark_count); - // In the following, we try to fill the deficit in heap "deficit_heap_index" with + // In the following, we try to fill the deficit in heap "deficit_heap_index" with // surplus from "surplus_heap_index". // If there is no deficit or surplus (anymore), the indices are advanced. int surplus_heap_index = 0; @@ -9920,7 +9920,7 @@ size_t gc_heap::sort_mark_list() #ifdef WRITE_SORT_DATA char file_name[256]; - sprintf_s (file_name, _countof(file_name), "sort_data_gc%d_heap%d", settings.gc_index, heap_number); + sprintf_s (file_name, ARRAY_SIZE(file_name), "sort_data_gc%d_heap%d", settings.gc_index, heap_number); FILE* f; errno_t err = fopen_s (&f, file_name, "wb"); @@ -10153,7 +10153,7 @@ void gc_heap::merge_mark_lists (size_t total_mark_list_size) } #endif - dprintf(3, ("merge_mark_lists: heap_number = %d starts out with %Id entries", + dprintf(3, ("merge_mark_lists: heap_number = %d starts out with %Id entries", heap_number, (mark_list_index - mark_list))); int source_number = heap_number; @@ -10184,7 +10184,7 @@ void gc_heap::merge_mark_lists (size_t total_mark_list_size) { dprintf(3, ("source_number = %d ", source_number)); dprintf(3, (" source from heap %d = %Ix .. %Ix (%Id entries)", - (size_t)(source_heap[j]), (size_t)(source[j][0]), + (size_t)(source_heap[j]), (size_t)(source[j][0]), (size_t)(source_end[j][-1]), (size_t)(source_end[j] - source[j]))); // the sources should all be sorted for (uint8_t **x = source[j]; x < source_end[j] - 1; x++) @@ -10340,10 +10340,10 @@ void gc_heap::grow_mark_list () // with vectorized sorting, we can use bigger mark lists #ifdef USE_VXSORT #ifdef MULTIPLE_HEAPS - const size_t MAX_MARK_LIST_SIZE = IsSupportedInstructionSet (InstructionSet::AVX2) ? + const size_t MAX_MARK_LIST_SIZE = IsSupportedInstructionSet (InstructionSet::AVX2) ? (1000 * 1024) : (200 * 1024); #else //MULTIPLE_HEAPS - const size_t MAX_MARK_LIST_SIZE = IsSupportedInstructionSet (InstructionSet::AVX2) ? + const size_t MAX_MARK_LIST_SIZE = IsSupportedInstructionSet (InstructionSet::AVX2) ? (32 * 1024) : (16 * 1024); #endif //MULTIPLE_HEAPS #else //USE_VXSORT @@ -11059,7 +11059,7 @@ bool gc_heap::initial_make_soh_regions (gc_heap* hp) for (int i = max_generation; i >= 0; i--) { - dprintf (REGIONS_LOG, ("h%d gen%d alloc seg is %Ix, start seg is %Ix (%Ix-%Ix)", + dprintf (REGIONS_LOG, ("h%d gen%d alloc seg is %Ix, start seg is %Ix (%Ix-%Ix)", heap_number, i, generation_allocation_segment (generation_of (i)), generation_start_segment (generation_of (i)), heap_segment_mem (generation_start_segment (generation_of (i))), @@ -11086,7 +11086,7 @@ bool gc_heap::initial_make_uoh_regions (int gen, gc_heap* hp) { return false; } - uoh_region->flags |= + uoh_region->flags |= (gen == loh_generation) ? heap_segment_flags_loh : heap_segment_flags_poh; uint8_t* gen_start = heap_segment_mem (uoh_region); make_generation (gen, uoh_region, gen_start); @@ -11115,7 +11115,7 @@ void gc_heap::clear_region_info (heap_segment* region) #endif //BACKGROUND_GC } -// Note that returning a region to free does not decommit. +// Note that returning a region to free does not decommit. // REGIONS PERF TODO: should decommit if needed. void gc_heap::return_free_region (heap_segment* region) { @@ -11127,7 +11127,7 @@ void gc_heap::return_free_region (heap_segment* region) uint8_t* region_end = heap_segment_reserved (region); int num_basic_regions = (int)((region_end - region_start) >> min_segment_size_shr); - dprintf (REGIONS_LOG, ("RETURNING region %Ix (%d basic regions) to free", + dprintf (REGIONS_LOG, ("RETURNING region %Ix (%d basic regions) to free", heap_segment_mem (region), num_basic_regions)); for (int i = 0; i < num_basic_regions; i++) { @@ -11151,7 +11151,7 @@ heap_segment* gc_heap::get_free_region (int gen_number, size_t size) heap_segment* region = 0; // TODO: the update to committed_in_free is incorrect - we'd need synchorization 'cause a thread - // could be getting a small and another one could be getting a large region at the same time. + // could be getting a small and another one could be getting a large region at the same time. // This is only used for recording. if (gen_number <= max_generation) { @@ -11186,11 +11186,11 @@ heap_segment* gc_heap::get_free_region (int gen_number, size_t size) { uint8_t* region_start = get_region_start (region); uint8_t* region_end = heap_segment_reserved (region); - init_heap_segment (region, __this, region_start, + init_heap_segment (region, __this, region_start, (region_end - region_start), gen_number); - dprintf (REGIONS_LOG, ("h%d GFR get region %Ix (%Ix-%Ix) for gen%d", - heap_number, (size_t)region, + dprintf (REGIONS_LOG, ("h%d GFR get region %Ix (%Ix-%Ix) for gen%d", + heap_number, (size_t)region, region_start, region_end, gen_number)); } @@ -11282,10 +11282,10 @@ void gc_heap::set_region_plan_gen_num (heap_segment* region, int plan_gen_num) int gen_num = heap_segment_gen_num (region); int supposed_plan_gen_num = get_plan_gen_num (gen_num); dprintf (REGIONS_LOG, ("h%d setting plan gen on %Ix->%Ix(was gen%d) to %d(should be: %d) %s", - heap_number, (size_t)region, + heap_number, (size_t)region, heap_segment_mem (region), - gen_num, plan_gen_num, - supposed_plan_gen_num, + gen_num, plan_gen_num, + supposed_plan_gen_num, ((plan_gen_num < supposed_plan_gen_num) ? "DEMOTED" : "ND"))); if (plan_gen_num < supposed_plan_gen_num) { @@ -11390,7 +11390,7 @@ heap_segment* gc_heap::make_heap_segment (uint8_t* new_pages, size_t size, gc_he { gc_oh_num oh = gen_to_oh (gen_num); size_t initial_commit = SEGMENT_INITIAL_COMMIT; - int h_number = + int h_number = #ifdef MULTIPLE_HEAPS hp->heap_number; #else @@ -11403,7 +11403,7 @@ heap_segment* gc_heap::make_heap_segment (uint8_t* new_pages, size_t size, gc_he } #ifdef USE_REGIONS - dprintf (REGIONS_LOG, ("Making region %Ix->%Ix(%Idmb)", + dprintf (REGIONS_LOG, ("Making region %Ix->%Ix(%Idmb)", new_pages, (new_pages + size), (size / 1024 / 1024))); heap_segment* new_segment = get_region_info (new_pages); uint8_t* start = new_pages + sizeof (aligned_plug_and_gap); @@ -11414,7 +11414,7 @@ heap_segment* gc_heap::make_heap_segment (uint8_t* new_pages, size_t size, gc_he heap_segment_mem (new_segment) = start; heap_segment_used (new_segment) = start; heap_segment_reserved (new_segment) = new_pages + size; - heap_segment_committed (new_segment) = (use_large_pages_p ? + heap_segment_committed (new_segment) = (use_large_pages_p ? heap_segment_reserved(new_segment) : (new_pages + initial_commit)); init_heap_segment (new_segment, hp @@ -11466,8 +11466,8 @@ void gc_heap::init_heap_segment (heap_segment* seg, gc_heap* hp heap_segment* basic_region = get_region_info (basic_region_start); heap_segment_allocated (basic_region) = (uint8_t*)(ptrdiff_t)-i; dprintf (REGIONS_LOG, ("Initing basic region %Ix->%Ix(%Idmb) alloc to %Ix", - basic_region_start, (basic_region_start + basic_region_size), - (size_t)(basic_region_size / 1024 / 1024), + basic_region_start, (basic_region_start + basic_region_size), + (size_t)(basic_region_size / 1024 / 1024), heap_segment_allocated (basic_region))); heap_segment_gen_num (basic_region) = (uint8_t)gen_num_for_region; @@ -11641,11 +11641,11 @@ void gc_heap::clear_gen0_bricks() while (gen0_region) { uint8_t* clear_start = heap_segment_mem (gen0_region); -#else +#else heap_segment* gen0_region = ephemeral_heap_segment; uint8_t* clear_start = generation_allocation_start (generation_of (0)); { -#endif //USE_REGIONS +#endif //USE_REGIONS for (size_t b = brick_of (clear_start); b < brick_of (align_on_brick (heap_segment_allocated (gen0_region))); @@ -11671,7 +11671,7 @@ void gc_heap::check_gen0_bricks() while (gen0_region) { uint8_t* start = heap_segment_mem (gen0_region); -#else +#else heap_segment* gen0_region = ephemeral_heap_segment; uint8_t* start = generation_allocation_start (generation_of (0)); { @@ -12314,7 +12314,7 @@ inline void gc_heap::verify_card_bundles() dprintf (3, ("gc: %d, Card word %Ix for address %Ix set, card_bundle %Ix clear", dd_collection_count (dynamic_data_of (0)), (size_t)(card_word-&card_table[0]), - (size_t)(card_address ((size_t)(card_word-&card_table[0]) * card_word_width)), + (size_t)(card_address ((size_t)(card_word-&card_table[0]) * card_word_width)), cardb)); } @@ -12352,7 +12352,7 @@ void gc_heap::update_card_table_bundle() { size_t region_size = align_on_page (high_address) - base_address; - dprintf (3,("Probing card table pages [%Ix, %Ix[", + dprintf (3,("Probing card table pages [%Ix, %Ix[", (size_t)base_address, (size_t)(base_address + region_size))); bool success = GCToOSInterface::GetWriteWatch(false /* resetState */, base_address, @@ -12372,9 +12372,9 @@ void gc_heap::update_card_table_bundle() assert (bcardw >= card_word (card_of (g_gc_lowest_address))); // Set the card bundle bits representing the dirty card table page - card_bundles_set (cardw_card_bundle (bcardw), + card_bundles_set (cardw_card_bundle (bcardw), cardw_card_bundle (align_cardw_on_bundle (ecardw))); - dprintf (3,("Set Card bundle [%Ix, %Ix[", + dprintf (3,("Set Card bundle [%Ix, %Ix[", cardw_card_bundle (bcardw), cardw_card_bundle (align_cardw_on_bundle (ecardw)))); verify_card_bundle_bits_set(bcardw, ecardw); @@ -12406,16 +12406,16 @@ void gc_heap::reset_write_watch_for_gc_heap(void* base_address, size_t region_si } // static -void gc_heap::get_write_watch_for_gc_heap(bool reset, void *base_address, size_t region_size, - void** dirty_pages, uintptr_t* dirty_page_count_ref, +void gc_heap::get_write_watch_for_gc_heap(bool reset, void *base_address, size_t region_size, + void** dirty_pages, uintptr_t* dirty_page_count_ref, bool is_runtime_suspended) { #ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP - SoftwareWriteWatch::GetDirty(base_address, region_size, dirty_pages, dirty_page_count_ref, + SoftwareWriteWatch::GetDirty(base_address, region_size, dirty_pages, dirty_page_count_ref, reset, is_runtime_suspended); #else // !FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP UNREFERENCED_PARAMETER(is_runtime_suspended); - bool success = GCToOSInterface::GetWriteWatch(reset, base_address, region_size, dirty_pages, + bool success = GCToOSInterface::GetWriteWatch(reset, base_address, region_size, dirty_pages, dirty_page_count_ref); assert(success); #endif // FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP @@ -12440,7 +12440,7 @@ void gc_heap::reset_ww_by_chunk (uint8_t* start_address, size_t total_reset_size while (reset_size != total_reset_size) { remaining_reset_size = total_reset_size - reset_size; - next_reset_size = ((remaining_reset_size >= ww_reset_quantum) ? + next_reset_size = ((remaining_reset_size >= ww_reset_quantum) ? ww_reset_quantum : remaining_reset_size); if (next_reset_size) { @@ -12476,12 +12476,12 @@ void gc_heap::switch_on_reset (BOOL concurrent_p, size_t* current_total_reset_si void gc_heap::reset_write_watch (BOOL concurrent_p) { #ifdef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP - // Software write watch currently requires the runtime to be suspended during reset. + // Software write watch currently requires the runtime to be suspended during reset. // See SoftwareWriteWatch::ClearDirty(). assert(!concurrent_p); #endif // FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP - dprintf (2, ("bgc lowest: %Ix, bgc highest: %Ix", + dprintf (2, ("bgc lowest: %Ix, bgc highest: %Ix", background_saved_lowest_address, background_saved_highest_address)); size_t reset_size = 0; @@ -12495,7 +12495,7 @@ void gc_heap::reset_write_watch (BOOL concurrent_p) uint8_t* base_address = align_lower_page (heap_segment_mem (seg)); base_address = max (base_address, background_saved_lowest_address); - uint8_t* high_address = ((seg == ephemeral_heap_segment) ? + uint8_t* high_address = ((seg == ephemeral_heap_segment) ? alloc_allocated : heap_segment_allocated (seg)); high_address = min (high_address, background_saved_highest_address); @@ -12841,9 +12841,9 @@ HRESULT gc_heap::initialize_gc (size_t soh_segment_size, #ifdef USE_REGIONS if (regions_range) { - // REGIONS TODO: we should reserve enough space at the end of what we reserved that's - // big enough to accommodate if we were to materialize all the GC bookkeeping datastructures. - // We only need to commit what we use and just need to commit more instead of having to + // REGIONS TODO: we should reserve enough space at the end of what we reserved that's + // big enough to accommodate if we were to materialize all the GC bookkeeping datastructures. + // We only need to commit what we use and just need to commit more instead of having to // relocate the exising table and then calling copy_brick_card_table. // Right now all the non mark array portions are commmitted since I'm calling mark_card_table // on the whole range. This can be committed as needed. @@ -12852,8 +12852,8 @@ HRESULT gc_heap::initialize_gc (size_t soh_segment_size, if (!reserve_range) return E_OUTOFMEMORY; - if (!global_region_allocator.init (reserve_range, (reserve_range + reserve_size), - ((size_t)1 << min_segment_size_shr), + if (!global_region_allocator.init (reserve_range, (reserve_range + reserve_size), + ((size_t)1 << min_segment_size_shr), &g_gc_lowest_address, &g_gc_highest_address)) return E_OUTOFMEMORY; @@ -12868,11 +12868,11 @@ HRESULT gc_heap::initialize_gc (size_t soh_segment_size, return E_FAIL; } #else //USE_REGIONS - bool separated_poh_p = use_large_pages_p && - heap_hard_limit_oh[soh] && - (GCConfig::GetGCHeapHardLimitPOH() == 0) && + bool separated_poh_p = use_large_pages_p && + heap_hard_limit_oh[soh] && + (GCConfig::GetGCHeapHardLimitPOH() == 0) && (GCConfig::GetGCHeapHardLimitPOHPercent() == 0); - if (!reserve_initial_memory (soh_segment_size, loh_segment_size, poh_segment_size, number_of_heaps, + if (!reserve_initial_memory (soh_segment_size, loh_segment_size, poh_segment_size, number_of_heaps, use_large_pages_p, separated_poh_p, heap_no_to_numa_node)) return E_OUTOFMEMORY; if (separated_poh_p) @@ -13578,10 +13578,10 @@ gc_heap::init_gc_heap (int h_number) end_gen0_region_space = 0; gen0_pinned_free_space = 0; gen0_large_chunk_found = false; - // REGIONS PERF TODO: we should really allocate the POH regions together just so that + // REGIONS PERF TODO: we should really allocate the POH regions together just so that // they wouldn't prevent us from coalescing free regions to form a large virtual address // range. - if (!initial_make_soh_regions (__this) || + if (!initial_make_soh_regions (__this) || !initial_make_uoh_regions (loh_generation, __this) || !initial_make_uoh_regions (poh_generation, __this)) { @@ -14016,7 +14016,7 @@ BOOL gc_heap::grow_heap_segment (heap_segment* seg, uint8_t* high_address, bool* } inline -int gc_heap::grow_heap_segment (heap_segment* seg, uint8_t* allocated, uint8_t* old_loc, size_t size, +int gc_heap::grow_heap_segment (heap_segment* seg, uint8_t* allocated, uint8_t* old_loc, size_t size, BOOL pad_front_p REQD_ALIGN_AND_OFFSET_DCL) { BOOL already_padded = FALSE; @@ -14110,15 +14110,15 @@ void gc_heap::adjust_limit (uint8_t* start, size_t limit_size, generation* gen) #ifdef DOUBLY_LINKED_FL if (gen->gen_num == max_generation) { - // For BGC since we need to thread the max_gen's free list as a doubly linked list we need to + // For BGC since we need to thread the max_gen's free list as a doubly linked list we need to // preserve 5 ptr-sized words: SB | MT | Len | Next | Prev - // This means we cannot simply make a filler free object right after what's allocated in this + // This means we cannot simply make a filler free object right after what's allocated in this // alloc context if that's < 5-ptr sized. // if (allocated_size <= min_free_item_no_prev) { // We can't make the free object just yet. Need to record the size. - size_t* filler_free_obj_size_location = (size_t*)(generation_allocation_context_start_region (gen) + + size_t* filler_free_obj_size_location = (size_t*)(generation_allocation_context_start_region (gen) + min_free_item_no_prev); size_t filler_free_obj_size = 0; if (size >= (Align (min_free_list) + Align (min_obj_size))) @@ -14189,8 +14189,8 @@ void gc_heap::adjust_limit (uint8_t* start, size_t limit_size, generation* gen) else #endif //DOUBLY_LINKED_FL { - // TODO: this should be written the same way as the above, ie, it should check - // allocated_size first, but it doesn't need to do MAKE_FREE_OBJ_IN_COMPACT + // TODO: this should be written the same way as the above, ie, it should check + // allocated_size first, but it doesn't need to do MAKE_FREE_OBJ_IN_COMPACT // related things. if (size >= Align (min_free_list)) { @@ -14205,7 +14205,7 @@ void gc_heap::adjust_limit (uint8_t* start, size_t limit_size, generation* gen) } else { - dprintf (3, ("allocated size too small, can't put back rest on free list %Ix", + dprintf (3, ("allocated size too small, can't put back rest on free list %Ix", allocated_size)); make_free_obj (gen, hole, size); } @@ -14943,12 +14943,12 @@ void allocator::thread_sip_fl (heap_segment* region) if (num_buckets == 1) { - dprintf (REGIONS_LOG, ("threading gen%d region %Ix onto gen%d FL", + dprintf (REGIONS_LOG, ("threading gen%d region %Ix onto gen%d FL", heap_segment_gen_num (region), heap_segment_mem (region), gen_number)); alloc_list* al = &alloc_list_of (0); uint8_t*& head = al->alloc_list_head(); uint8_t*& tail = al->alloc_list_tail(); - + if (tail == 0) { assert (head == 0); @@ -14963,7 +14963,7 @@ void allocator::thread_sip_fl (heap_segment* region) } else { - dprintf (REGIONS_LOG, ("threading gen%d region %Ix onto gen%d bucketed FL", + dprintf (REGIONS_LOG, ("threading gen%d region %Ix onto gen%d bucketed FL", heap_segment_gen_num (region), heap_segment_mem (region), gen_number)); // If we have a bucketed free list we'd need to go through the region's free list. uint8_t* region_fl_item = region_fl_head; @@ -14982,8 +14982,8 @@ void allocator::thread_sip_fl (heap_segment* region) #endif //USE_REGIONS #ifdef FEATURE_EVENT_TRACE -uint16_t allocator::count_largest_items (etw_bucket_info* bucket_info, - size_t max_size, +uint16_t allocator::count_largest_items (etw_bucket_info* bucket_info, + size_t max_size, size_t max_item_count, size_t* recorded_fl_info_size) { @@ -15155,7 +15155,7 @@ void gc_heap::adjust_limit_clr (uint8_t* start, size_t limit_size, size_t size, *(PTR_PTR)clear_start = 0; } // skip the rest of the object - dprintf(3, ("zeroing optional: skipping object at %Ix->%Ix(%Id)", + dprintf(3, ("zeroing optional: skipping object at %Ix->%Ix(%Id)", clear_start, obj_end, obj_end - clear_start)); clear_start = obj_end; } @@ -15201,8 +15201,8 @@ void gc_heap::adjust_limit_clr (uint8_t* start, size_t limit_size, size_t size, if (fire_event_p) { fire_etw_allocation_event (etw_allocation_amount, gen_number, acontext->alloc_ptr, size); - } -#endif //FEATURE_EVENT_TRACE + } +#endif //FEATURE_EVENT_TRACE //this portion can be done after we release the lock if (seg == gen0_segment || @@ -15267,7 +15267,7 @@ size_t gc_heap::limit_from_size (size_t size, uint32_t flags, size_t physical_li new_physical_limit, gen_number); assert (new_limit >= (size + Align (min_obj_size, align_const))); - dprintf (3, ("h%d requested to allocate %Id bytes, actual size is %Id, phy limit: %Id", + dprintf (3, ("h%d requested to allocate %Id bytes, actual size is %Id, phy limit: %Id", heap_number, size, new_limit, physical_limit)); return new_limit; } @@ -15744,7 +15744,7 @@ void gc_heap::bgc_uoh_alloc_clr (uint8_t* alloc_start, if (fire_event_p) { fire_etw_allocation_event (etw_allocation_amount, gen_number, alloc_start, size); - } + } #endif //FEATURE_EVENT_TRACE ((void**) alloc_start)[-1] = 0; //clear the sync block @@ -15988,10 +15988,10 @@ BOOL gc_heap::a_fit_segment_end_p (int gen_number, else #endif //BACKGROUND_GC { - // In a contiguous AC case with GC_ALLOC_ZEROING_OPTIONAL, deduct unspent space from the limit to + // In a contiguous AC case with GC_ALLOC_ZEROING_OPTIONAL, deduct unspent space from the limit to // clear only what is necessary. if ((flags & GC_ALLOC_ZEROING_OPTIONAL) && - ((allocated == acontext->alloc_limit) || + ((allocated == acontext->alloc_limit) || (allocated == (acontext->alloc_limit + Align (min_obj_size, align_const))))) { assert(gen_number == 0); @@ -16186,7 +16186,7 @@ BOOL gc_heap::soh_try_fit (int gen_number, if (next_seg) { - dprintf (REGIONS_LOG, ("eph seg %Ix -> next %Ix", + dprintf (REGIONS_LOG, ("eph seg %Ix -> next %Ix", heap_segment_mem (ephemeral_heap_segment), heap_segment_mem (next_seg))); ephemeral_heap_segment = next_seg; if (new_seg) @@ -16551,10 +16551,10 @@ int gc_heap::bgc_poh_allocate_spin() size_t gc_heap::get_uoh_seg_size (size_t size) { - size_t default_seg_size = + size_t default_seg_size = #ifdef USE_REGIONS global_region_allocator.get_large_region_alignment(); -#else +#else min_uoh_segment_size; #endif //USE_REGIONS size_t align_size = default_seg_size; @@ -17854,7 +17854,7 @@ void gc_heap::add_gen_free (int gen_number, size_t free_size) (gen->gen_free_spaces[i])++; if (gen_number == max_generation) { - dprintf (3, ("Mb b%d: f+ %Id (%Id)", + dprintf (3, ("Mb b%d: f+ %Id (%Id)", i, free_size, gen->gen_free_spaces[i])); } #else @@ -17877,7 +17877,7 @@ void gc_heap::remove_gen_free (int gen_number, size_t free_size) (gen->gen_free_spaces[i])--; if (gen_number == max_generation) { - dprintf (3, ("Mb b%d: f- %Id (%Id)", + dprintf (3, ("Mb b%d: f- %Id (%Id)", i, free_size, gen->gen_free_spaces[i])); } #else @@ -17962,7 +17962,7 @@ uint8_t* gc_heap::allocate_in_older_generation (generation* gen, size_t size, BOOL check_current_sweep_p = FALSE; BOOL check_saved_sweep_p = FALSE; BOOL try_added_list_p = (gen->gen_num == max_generation); - BOOL record_free_list_allocated_p = ((gen->gen_num == max_generation) && + BOOL record_free_list_allocated_p = ((gen->gen_num == max_generation) && (current_c_gc_state == c_gc_state_planning)); #endif //DOUBLY_LINKED_FL @@ -17985,7 +17985,7 @@ uint8_t* gc_heap::allocate_in_older_generation (generation* gen, size_t size, if (! (size_fit_p (size REQD_ALIGN_AND_OFFSET_ARG, generation_allocation_pointer (gen), generation_allocation_limit (gen), old_loc, USE_PADDING_TAIL | pad_in_front))) { - for (unsigned int a_l_idx = gen_allocator->first_suitable_bucket(real_size * 2); + for (unsigned int a_l_idx = gen_allocator->first_suitable_bucket(real_size * 2); a_l_idx < gen_allocator->number_of_buckets(); a_l_idx++) { uint8_t* free_list = 0; @@ -18159,7 +18159,7 @@ uint8_t* gc_heap::allocate_in_older_generation (generation* gen, size_t size, generation_allocate_end_seg_p (gen) = TRUE; heap_segment_plan_allocated (seg) = heap_segment_committed (seg); - dprintf (3, ("seg %Ix is used for end of seg alloc after grow, %Ix", + dprintf (3, ("seg %Ix is used for end of seg alloc after grow, %Ix", heap_segment_mem (seg), heap_segment_committed (seg))); goto finished; @@ -18572,7 +18572,7 @@ heap_segment* gc_heap::get_next_alloc_seg (generation* gen) int gen_num = heap_segment_gen_num (saved_region); heap_segment* region = saved_region; - + while (1) { region = heap_segment_non_sip (region); @@ -18600,7 +18600,7 @@ heap_segment* gc_heap::get_next_alloc_seg (generation* gen) if (region != saved_region) { - dprintf (REGIONS_LOG, ("init allocate region for gen%d to %Ix(%d)", + dprintf (REGIONS_LOG, ("init allocate region for gen%d to %Ix(%d)", gen->gen_num, heap_segment_mem (region), heap_segment_gen_num (region))); init_alloc_info (gen, region); } @@ -18709,10 +18709,10 @@ uint8_t* gc_heap::allocate_in_condemned_generations (generation* gen, #ifdef USE_REGIONS // With regions it's a bit more complicated since we only set the plan_gen_num // of a region after we've planned it. This means if the pinning plug is in the - // the same seg we are planning, we haven't set its plan_gen_num yet. So we + // the same seg we are planning, we haven't set its plan_gen_num yet. So we // need to check for that first. int togn = (in_range_for_segment (plug, seg) ? to_gen_number : object_gennum_plan (plug)); -#else +#else int togn = object_gennum_plan (plug); #endif //USE_REGIONS if (frgn < togn) @@ -18757,7 +18757,7 @@ uint8_t* gc_heap::allocate_in_condemned_generations (generation* gen, dprintf (REGIONS_LOG, ("aic next: %Ix(%Ix,%Ix) -> %Ix(%Ix,%Ix)", heap_segment_mem (seg), heap_segment_allocated (seg), heap_segment_plan_allocated (seg), (next_seg ? heap_segment_mem (next_seg) : 0), - (next_seg ? heap_segment_allocated (next_seg) : 0), + (next_seg ? heap_segment_allocated (next_seg) : 0), (next_seg ? heap_segment_plan_allocated (next_seg) : 0))); assert (generation_allocation_pointer (gen)>= heap_segment_mem (seg)); @@ -19419,7 +19419,7 @@ size_t gc_heap::current_generation_size (int gen_number) #ifdef USE_REGIONS // We may need a new empty region while doing a GC so try to get one now, if we don't have any -// reserve in the free region list. +// reserve in the free region list. bool gc_heap::try_get_new_free_region() { heap_segment* region = 0; @@ -19454,7 +19454,7 @@ bool gc_heap::init_table_for_region (int gen_number, heap_segment* region) #ifdef BACKGROUND_GC if (is_bgc_in_progress()) { - dprintf (GC_TABLE_LOG, ("new seg %Ix, mark_array is %Ix", + dprintf (GC_TABLE_LOG, ("new seg %Ix, mark_array is %Ix", heap_segment_mem (region), mark_array)); if (!commit_mark_array_new_seg (__this, region)) { @@ -20257,7 +20257,7 @@ size_t gc_heap::exponential_smoothing (int gen, size_t collection_count, size_t // to avoid spikes in mem usage due to short terms fluctuations in survivorship, // apply some smoothing. size_t smoothing = min(3, collection_count); - + size_t new_smoothed_desired_per_heap = desired_per_heap / smoothing + ((smoothed_desired_per_heap[gen] / smoothing) * (smoothing - 1)); dprintf (2, ("new smoothed_desired_per_heap for gen %d = %Id, desired_per_heap = %Id", gen, new_smoothed_desired_per_heap, desired_per_heap)); smoothed_desired_per_heap[gen] = new_smoothed_desired_per_heap; @@ -21294,11 +21294,11 @@ bool gc_heap::extend_soh_for_no_gc() { size_t required = soh_allocation_no_gc; heap_segment* region = ephemeral_heap_segment; - + while (true) { - uint8_t* allocated = (region == ephemeral_heap_segment) ? - alloc_allocated : + uint8_t* allocated = (region == ephemeral_heap_segment) ? + alloc_allocated : heap_segment_allocated (region); size_t available = heap_segment_reserved (region) - allocated; size_t commit = min (available, required); @@ -21445,7 +21445,7 @@ void gc_heap::allocate_for_no_gc_after_gc() { #ifdef USE_REGIONS no_gc_oom_p = !extend_soh_for_no_gc(); -#else +#else if (((size_t)(heap_segment_reserved (ephemeral_heap_segment) - heap_segment_allocated (ephemeral_heap_segment)) < soh_allocation_no_gc) || (!grow_heap_segment (ephemeral_heap_segment, (heap_segment_allocated (ephemeral_heap_segment) + soh_allocation_no_gc)))) { @@ -22051,7 +22051,7 @@ size_t gc_heap::get_promoted_bytes() if (survived_per_region[i] > 0) { heap_segment* region = get_region_at_index (i); - dprintf (REGIONS_LOG, ("h%d region[%d] %Ix(g%d)(%s) surv: %Id(%Ix)", + dprintf (REGIONS_LOG, ("h%d region[%d] %Ix(g%d)(%s) surv: %Id(%Ix)", heap_number, i, heap_segment_mem (region), heap_segment_gen_num (region), @@ -22064,7 +22064,7 @@ size_t gc_heap::get_promoted_bytes() } #ifdef _DEBUG - dprintf (REGIONS_LOG, ("h%d global recorded %Id, regions recorded %Id", + dprintf (REGIONS_LOG, ("h%d global recorded %Id, regions recorded %Id", heap_number, promoted_bytes (heap_number), promoted)); assert (promoted_bytes (heap_number) == promoted); #endif //_DEBUG @@ -22106,7 +22106,7 @@ void gc_heap::sync_promoted_bytes() { generation* condemned_gen = hp->generation_of (gen_idx); heap_segment* current_region = heap_segment_rw (generation_start_segment (condemned_gen)); - + while (current_region) { size_t region_index = get_basic_region_index_for_address (heap_segment_mem (current_region)); @@ -22125,13 +22125,13 @@ void gc_heap::sync_promoted_bytes() heap_segment_old_card_survived (current_region) = (int)total_old_card_surv; #else heap_segment_survived (current_region) = (int)(survived_per_region[region_index]); - heap_segment_old_card_survived (current_region) = + heap_segment_old_card_survived (current_region) = (int)(old_card_survived_per_region[region_index]); #endif //MULTIPLE_HEAPS dprintf (REGIONS_LOG, ("region #%d %Ix surv %Id, old card surv %Id", region_index, - heap_segment_mem (current_region), + heap_segment_mem (current_region), heap_segment_survived (current_region), heap_segment_old_card_survived (current_region))); @@ -22792,7 +22792,7 @@ void gc_heap::mark_object_simple1 (uint8_t* oo, uint8_t* start THREAD_NUMBER_DCL // If we are doing a full GC we don't use mark list anyway so use m_boundary_fullgc that doesn't // update mark list. BOOL full_p = (settings.condemned_generation == max_generation); - int condemned_gen = + int condemned_gen = #ifdef USE_REGIONS settings.condemned_generation; #else @@ -23120,7 +23120,7 @@ gc_heap::mark_steal() if (o && start) { //steal the object - success = (Interlocked::CompareExchangePointer (&ref_mark_stack (hp, level+1), + success = (Interlocked::CompareExchangePointer (&ref_mark_stack (hp, level+1), (uint8_t*)stolen, next) == next); #ifdef SNOOP_STATS snoop_stat.interlocked_count++; @@ -23362,7 +23362,7 @@ gc_heap::ha_mark_object_simple (uint8_t** po THREAD_NUMBER_DCL) void gc_heap::mark_object_simple (uint8_t** po THREAD_NUMBER_DCL) { - int condemned_gen = + int condemned_gen = #ifdef USE_REGIONS settings.condemned_generation; #else @@ -23857,7 +23857,7 @@ void gc_heap::check_bgc_mark_stack_length() #else int total_heaps = 1; #endif //MULTIPLE_HEAPS - size_t size_based_on_heap = total_heap_size / (size_t)(100 * 100 * total_heaps * sizeof (uint8_t*)); + size_t size_based_on_heap = total_heap_size / (size_t)(100 * 100 * total_heaps * sizeof (uint8_t*)); size_t new_size = max (background_mark_stack_array_length, size_based_on_heap); @@ -23984,7 +23984,7 @@ void gc_heap::background_process_mark_overflow_internal (uint8_t* min_add, uint8 } #endif //USE_REGIONS uint8_t* o = hp->background_first_overflow (current_min_add, seg, concurrent_p, small_object_segments); - + while ((o < hp->background_seg_end (seg, concurrent_p)) && (o <= current_max_add)) { dprintf (3, ("considering %Ix", (size_t)o)); @@ -24073,7 +24073,7 @@ BOOL gc_heap::background_process_mark_overflow (BOOL concurrent_p) (background_min_overflow_address != MAX_PTR)) { #ifdef USE_REGIONS - // We don't want to step into the ephemeral regions so remember these regions and + // We don't want to step into the ephemeral regions so remember these regions and // be sure to process them later. An FGC cannot happen while we are going through // the region lists. for (int i = 0; i < max_generation; i++) @@ -24205,7 +24205,7 @@ size_t gc_heap::get_total_heap_size() { size_t total_heap_size = 0; - // It's correct to start from max_generation for this method because + // It's correct to start from max_generation for this method because // generation_sizes will return all SOH sizes when passed max_generation. #ifdef MULTIPLE_HEAPS int hn = 0; @@ -24313,13 +24313,13 @@ size_t gc_heap::committed_size() while (seg) { - total_committed += heap_segment_committed (seg) - + total_committed += heap_segment_committed (seg) - #ifdef USE_REGIONS get_region_start (seg); #else (uint8_t*)seg; #endif //USE_REGIONS - + seg = heap_segment_next (seg); } } @@ -24667,7 +24667,7 @@ size_t gc_heap::get_generation_start_size (int gen_number) #ifdef USE_REGIONS return 0; #else - return Align (size (generation_allocation_start (generation_of (gen_number))), + return Align (size (generation_allocation_start (generation_of (gen_number))), get_alignment_constant (gen_number <= max_generation)); #endif //!USE_REGIONS } @@ -24727,7 +24727,7 @@ void gc_heap::fire_mark_event (int root_type, size_t& current_promoted_bytes, si #ifdef FEATURE_EVENT_TRACE inline -void gc_heap::record_mark_time (uint64_t& mark_time, +void gc_heap::record_mark_time (uint64_t& mark_time, uint64_t& current_mark_time, uint64_t& last_mark_time) { @@ -24826,7 +24826,7 @@ void gc_heap::mark_phase (int condemned_gen_number, BOOL mark_only_p) while (gen0_region) { size_t gen0_region_size = heap_segment_allocated (gen0_region) - heap_segment_mem (gen0_region); - + if (gen0_region_size > 0) { if ((num_gen0_regions % pinning_seg_interval) == 0) @@ -26898,7 +26898,7 @@ void gc_heap::skip_pins_in_alloc_region (generation* consing_gen, int plan_gen_n dprintf (REGIONS_LOG, ("finished with alloc region %Ix, (%s) plan gen -> %d", heap_segment_mem (alloc_region), (heap_segment_swept_in_plan (alloc_region) ? "SIP" : "non SIP"), - (heap_segment_swept_in_plan (alloc_region) ? + (heap_segment_swept_in_plan (alloc_region) ? heap_segment_plan_gen_num (alloc_region) : plan_gen_num))); set_region_plan_gen_num_sip (alloc_region, plan_gen_num); heap_segment_plan_allocated (alloc_region) = generation_allocation_pointer (consing_gen); @@ -26937,13 +26937,13 @@ void gc_heap::process_last_np_surv_region (generation* consing_gen, // size of a plug at the end of the segment which makes alloc pointer/limit both reserved // on exit of that method. uint8_t* consing_gen_alloc_ptr = generation_allocation_pointer (consing_gen); - assert ((consing_gen_alloc_ptr >= heap_segment_mem (alloc_region)) && + assert ((consing_gen_alloc_ptr >= heap_segment_mem (alloc_region)) && (consing_gen_alloc_ptr <= heap_segment_reserved (alloc_region))); - dprintf (REGIONS_LOG, ("h%d next need to plan gen%d, consing alloc region: %Ix, ptr: %Ix(consing gen: %d)", - heap_number, next_plan_gen_num, + dprintf (REGIONS_LOG, ("h%d next need to plan gen%d, consing alloc region: %Ix, ptr: %Ix(consing gen: %d)", + heap_number, next_plan_gen_num, heap_segment_mem (alloc_region), - generation_allocation_pointer (consing_gen), + generation_allocation_pointer (consing_gen), consing_gen->gen_num)); if (current_plan_gen_num != next_plan_gen_num) @@ -26968,7 +26968,7 @@ void gc_heap::process_last_np_surv_region (generation* consing_gen, if (gen_num > 0) { next_region = generation_start_segment (generation_of (gen_num - 1)); - dprintf (REGIONS_LOG, ("h%d consing switching to next gen%d seg %Ix", + dprintf (REGIONS_LOG, ("h%d consing switching to next gen%d seg %Ix", heap_number, heap_segment_gen_num (next_region), heap_segment_mem (next_region))); } else @@ -26997,7 +26997,7 @@ void gc_heap::process_last_np_surv_region (generation* consing_gen, } else { - dprintf (REGIONS_LOG, ("h%d consing switching to next seg %Ix in gen%d to alloc in", + dprintf (REGIONS_LOG, ("h%d consing switching to next seg %Ix in gen%d to alloc in", heap_number, heap_segment_mem (next_region), heap_segment_gen_num (next_region))); } @@ -27005,8 +27005,8 @@ void gc_heap::process_last_np_surv_region (generation* consing_gen, { init_alloc_info (consing_gen, next_region); - dprintf (REGIONS_LOG, ("h%d consing(%d) alloc seg: %Ix(%Ix, %Ix), ptr: %Ix, planning gen%d", - heap_number, consing_gen->gen_num, + dprintf (REGIONS_LOG, ("h%d consing(%d) alloc seg: %Ix(%Ix, %Ix), ptr: %Ix, planning gen%d", + heap_number, consing_gen->gen_num, heap_segment_mem (generation_allocation_segment (consing_gen)), heap_segment_allocated (generation_allocation_segment (consing_gen)), heap_segment_plan_allocated (generation_allocation_segment (consing_gen)), @@ -27028,8 +27028,8 @@ void gc_heap::process_remaining_regions (int current_plan_gen_num, generation* c assert (pinned_plug_que_empty_p()); } - dprintf (REGIONS_LOG, ("h%d PRR: plan %d: consing alloc seg: %Ix, ptr: %Ix", - heap_number, current_plan_gen_num, + dprintf (REGIONS_LOG, ("h%d PRR: plan %d: consing alloc seg: %Ix, ptr: %Ix", + heap_number, current_plan_gen_num, heap_segment_mem (generation_allocation_segment (consing_gen)), generation_allocation_pointer (consing_gen))); @@ -27064,7 +27064,7 @@ void gc_heap::process_remaining_regions (int current_plan_gen_num, generation* c heap_number, heap_segment_mem (nseg), heap_segment_plan_allocated (nseg), generation_allocation_pointer (consing_gen), - heap_segment_plan_gen_num (nseg), + heap_segment_plan_gen_num (nseg), current_plan_gen_num)); if (!heap_segment_swept_in_plan (nseg)) { @@ -27080,7 +27080,7 @@ void gc_heap::process_remaining_regions (int current_plan_gen_num, generation* c dprintf (3, ("h%d PRR: switching to next gen%d start %Ix", heap_number, heap_segment_gen_num (next_seg), (size_t)next_seg)); } - + assert (next_seg != 0); nseg = next_seg; @@ -27095,8 +27095,8 @@ void gc_heap::process_remaining_regions (int current_plan_gen_num, generation* c set_new_pin_info (m, generation_allocation_pointer (consing_gen)); size_t free_size = pinned_len (m); update_planned_gen0_free_space (free_size, plug); - dprintf (2, ("h%d plug %Ix-%Ix(%Id), free space before %Ix-%Ix(%Id)", - heap_number, plug, (plug + len), len, + dprintf (2, ("h%d plug %Ix-%Ix(%Id), free space before %Ix-%Ix(%Id)", + heap_number, plug, (plug + len), len, generation_allocation_pointer (consing_gen), plug, free_size)); generation_allocation_pointer (consing_gen) = plug + len; @@ -27116,8 +27116,8 @@ void gc_heap::process_remaining_regions (int current_plan_gen_num, generation* c if (!heap_segment_swept_in_plan (current_region)) { heap_segment_plan_allocated (current_region) = generation_allocation_pointer (consing_gen); - dprintf (REGIONS_LOG, ("h%d setting alloc seg %Ix plan alloc to %Ix", - heap_number, heap_segment_mem (current_region), + dprintf (REGIONS_LOG, ("h%d setting alloc seg %Ix plan alloc to %Ix", + heap_number, heap_segment_mem (current_region), heap_segment_plan_allocated (current_region))); } @@ -27132,8 +27132,8 @@ void gc_heap::process_remaining_regions (int current_plan_gen_num, generation* c { set_region_plan_gen_num (region_no_pins, current_plan_gen_num); heap_segment_plan_allocated (region_no_pins) = heap_segment_mem (region_no_pins); - dprintf (REGIONS_LOG, ("h%d setting seg %Ix(no pins) plan gen to 0, plan alloc to %Ix", - heap_number, heap_segment_mem (region_no_pins), + dprintf (REGIONS_LOG, ("h%d setting seg %Ix(no pins) plan gen to 0, plan alloc to %Ix", + heap_number, heap_segment_mem (region_no_pins), heap_segment_plan_allocated (region_no_pins))); region_no_pins = heap_segment_next (region_no_pins); @@ -27199,7 +27199,7 @@ void gc_heap::update_old_card_survived() for (size_t region_index = 0; region_index < region_count; region_index++) { - old_card_survived_per_region[region_index] = survived_per_region[region_index] - + old_card_survived_per_region[region_index] = survived_per_region[region_index] - old_card_survived_per_region[region_index]; if (survived_per_region[region_index] != 0) { @@ -27217,13 +27217,13 @@ void gc_heap::update_planned_gen0_free_space (size_t free_size, uint8_t* plug) gen0_large_chunk_found = (free_size >= END_SPACE_AFTER_GC_FL); if (gen0_large_chunk_found) { - dprintf (3, ("h%d found large pin free space: %Id at %Ix", + dprintf (3, ("h%d found large pin free space: %Id at %Ix", heap_number, free_size, plug)); } } } -// REGIONS TODO: I wrote this in the same spirit as ephemeral_gen_fit_p but we really should +// REGIONS TODO: I wrote this in the same spirit as ephemeral_gen_fit_p but we really should // take committed into consideration instead of reserved. We could also avoid going through // the regions again and do this update in plan phase. void gc_heap::get_gen0_end_plan_space() @@ -27267,10 +27267,10 @@ size_t gc_heap::get_gen0_end_space() while (seg) { // TODO - - // This method can also be called concurrently by full GC notification but + // This method can also be called concurrently by full GC notification but // there's no synchronization between checking for ephemeral_heap_segment and // getting alloc_allocated so for now we just always use heap_segment_allocated. - //uint8_t* allocated = ((seg == ephemeral_heap_segment) ? + //uint8_t* allocated = ((seg == ephemeral_heap_segment) ? // alloc_allocated : heap_segment_allocated (seg)); uint8_t* allocated = heap_segment_allocated (seg); end_space += heap_segment_reserved (seg) - allocated; @@ -27290,7 +27290,7 @@ size_t gc_heap::get_gen0_end_space() inline uint8_t* gc_heap::find_next_marked (uint8_t* x, uint8_t* end, - BOOL use_mark_list, + BOOL use_mark_list, uint8_t**& mark_list_next, uint8_t** mark_list_index) { @@ -27675,8 +27675,8 @@ void gc_heap::plan_phase (int condemned_gen_number) { #ifdef USE_REGIONS regions_per_gen[condemned_gen_index1]++; - dprintf (REGIONS_LOG, ("h%d gen%d %Ix-%Ix", - heap_number, condemned_gen_index1, + dprintf (REGIONS_LOG, ("h%d gen%d %Ix-%Ix", + heap_number, condemned_gen_index1, heap_segment_mem (seg2), heap_segment_allocated (seg2))); #endif //USE_REGIONS @@ -27787,7 +27787,7 @@ void gc_heap::plan_phase (int condemned_gen_number) // We record the bucket info for the largest FL items and plugs that we have to allocate in condemned. bool record_fl_info_p = (EVENT_ENABLED (GCFitBucketInfo) && (condemned_gen_number == (max_generation - 1))); size_t recorded_fl_info_size = 0; - if (record_fl_info_p) + if (record_fl_info_p) init_bucket_info(); bool fire_pinned_plug_events_p = EVENT_ENABLED(PinPlugAtGCTime); #endif //FEATURE_EVENT_TRACE @@ -27834,7 +27834,7 @@ void gc_heap::plan_phase (int condemned_gen_number) #ifdef USE_REGIONS heap_segment_pinned_survived (seg1) = pinned_survived_region; - dprintf (REGIONS_LOG, ("h%d setting seg %Ix pin surv: %Ix", + dprintf (REGIONS_LOG, ("h%d setting seg %Ix pin surv: %Ix", heap_number, heap_segment_mem (seg1), pinned_survived_region)); pinned_survived_region = 0; if (heap_segment_mem (seg1) == heap_segment_allocated (seg1)) @@ -27865,20 +27865,20 @@ void gc_heap::plan_phase (int condemned_gen_number) else { #ifdef USE_REGIONS - // We have a few task here when we ran out of regions to go through for the + // We have a few task here when we ran out of regions to go through for the // active_old_gen_number - - // - // + decide on which pins to skip + // + // + decide on which pins to skip // + set the planned gen for the regions we process here // + set the consing gen's alloc ptr/limit // + decide on the new active_old_gen_number (which is just the current one - 1) // + decide on the new active_new_gen_number (which depends on settings.promotion) // // Important differences between process_last_np_surv_region and process_ephemeral_boundaries - // - it's guaranteed we would ask to allocate gen1 start for promotion and gen0 - // start for non promotion case. + // - it's guaranteed we would ask to allocate gen1 start for promotion and gen0 + // start for non promotion case. // - consing_gen is never changed. In fact we really don't need consing_gen, we just - // need the alloc ptr/limit pair and the alloc seg. + // need the alloc ptr/limit pair and the alloc seg. // TODO : should just get rid of consing_gen. // These make things more regular and easier to keep track of. // @@ -27892,8 +27892,8 @@ void gc_heap::plan_phase (int condemned_gen_number) if (active_old_gen_number <= (settings.promotion ? (max_generation - 1) : max_generation)) { - dprintf (REGIONS_LOG, ("h%d active old: %d, new: %d->%d, allocate_in_condemned %d->1", - heap_number, active_old_gen_number, + dprintf (REGIONS_LOG, ("h%d active old: %d, new: %d->%d, allocate_in_condemned %d->1", + heap_number, active_old_gen_number, active_new_gen_number, (active_new_gen_number - 1), allocate_in_condemned)); active_new_gen_number--; @@ -28282,7 +28282,7 @@ void gc_heap::plan_phase (int condemned_gen_number) verify_pins_with_post_plug_info("before insert node"); tree = insert_node (plug_start, ++sequence_number, tree, last_node); - dprintf (3, ("tree is %Ix (b: %Ix) after insert_node(lc: %Ix, rc: %Ix)", + dprintf (3, ("tree is %Ix (b: %Ix) after insert_node(lc: %Ix, rc: %Ix)", tree, brick_of (tree), (tree + node_left_child (tree)), (tree + node_right_child (tree)))); last_node = plug_start; @@ -28450,7 +28450,7 @@ void gc_heap::plan_phase (int condemned_gen_number) padding_size)); #ifndef USE_REGIONS - dprintf (1, ("gen%d: %Ix, %Ix(%Id)", + dprintf (1, ("gen%d: %Ix, %Ix(%Id)", gen_idx, generation_allocation_start (temp_gen), generation_plan_allocation_start (temp_gen), @@ -28542,7 +28542,7 @@ void gc_heap::plan_phase (int condemned_gen_number) #ifdef HOST_64BIT if ((!settings.concurrent) && #ifdef USE_REGIONS - !special_sweep_p && + !special_sweep_p && #endif //USE_REGIONS !provisional_mode_triggered && ((condemned_gen_number < max_generation) && @@ -28900,7 +28900,7 @@ void gc_heap::plan_phase (int condemned_gen_number) { if (bucket_index != non_zero_buckets) { - bucket_info[non_zero_buckets].set (bucket_index, + bucket_info[non_zero_buckets].set (bucket_index, bucket_info[bucket_index].count, bucket_info[bucket_index].size); } @@ -28924,15 +28924,15 @@ void gc_heap::plan_phase (int condemned_gen_number) } // We want to get an idea of the sizes of free items in the top 25% of the free list - // for gen2 (to be accurate - we stop as soon as the size we count exceeds 25%. This + // for gen2 (to be accurate - we stop as soon as the size we count exceeds 25%. This // is just so that if we have a really big free item we will still count that one). - // The idea is we want to see if they all in a few big ones or many smaller ones? - // To limit the amount of time we spend counting, we stop till we have counted the + // The idea is we want to see if they all in a few big ones or many smaller ones? + // To limit the amount of time we spend counting, we stop till we have counted the // top percentage, or exceeded max_etw_item_count items. size_t max_size_to_count = generation_free_list_space (older_gen) / 4; - non_zero_buckets = - generation_allocator (older_gen)->count_largest_items (bucket_info, - max_size_to_count, + non_zero_buckets = + generation_allocator (older_gen)->count_largest_items (bucket_info, + max_size_to_count, max_etw_item_count, &recorded_fl_info_size); if (non_zero_buckets) @@ -29129,7 +29129,7 @@ void gc_heap::plan_phase (int condemned_gen_number) } #endif //USE_REGIONS - dprintf(3,("h%d threading %Ix (%Id) before pin in gen %d", + dprintf(3,("h%d threading %Ix (%Id) before pin in gen %d", heap_number, arr, len, gen_number)); thread_gap (arr, len, gen); add_gen_free (gen_number, len); @@ -29290,14 +29290,14 @@ void gc_heap::fix_generation_bounds (int condemned_gen_number, dprintf (2, ("---- thread regions gen%d GC ----", gen_number)); #ifdef USE_REGIONS - // For ephemeral GCs, we handle up till the generation_allocation_segment as that's the last one we + // For ephemeral GCs, we handle up till the generation_allocation_segment as that's the last one we // changed in the older gen. if (settings.promotion && (condemned_gen_number < max_generation)) { int older_gen_number = condemned_gen_number + 1; generation* older_gen = generation_of (older_gen_number); heap_segment* last_alloc_region = generation_allocation_segment (older_gen); - + dprintf (REGIONS_LOG, ("fix till we see alloc region which is %Ix", heap_segment_mem (last_alloc_region))); heap_segment* region = heap_segment_rw (generation_start_segment (older_gen)); @@ -29432,21 +29432,21 @@ uint8_t* gc_heap::allocate_at_end (size_t size) } #ifdef USE_REGIONS -// Find the first non empty region and also does the following in the process - +// Find the first non empty region and also does the following in the process - // + decommit end of region if it's not a gen0 region; // + set the region gen_num to the new one; // // For empty regions, we always return empty regions to free unless it's a gen -// start region. Note that I'm returning gen0 empty regions as well, however, +// start region. Note that I'm returning gen0 empty regions as well, however, // returning a region to free does not decommit. -// +// // If this is called for a compacting GC, we know we always take the planned generation -// on the region (and set the new allocated); else this is called for sweep in which case +// on the region (and set the new allocated); else this is called for sweep in which case // it's more complicated - -// +// // + if we are in the special sweep mode, we don't change the old gen number at all // + if we are not in special sweep we need to promote all regions, including the SIP ones -// because we make the assumption that this is the case for sweep for handles. +// because we make the assumption that this is the case for sweep for handles. heap_segment* gc_heap::find_first_valid_region (heap_segment* region, bool compact_p) { check_seg_gen_num (generation_allocation_segment (generation_of (max_generation))); @@ -29455,11 +29455,11 @@ heap_segment* gc_heap::find_first_valid_region (heap_segment* region, bool compa (size_t)region, (region ? heap_segment_mem (region) : 0), (region ? heap_segment_gen_num (region) : 0))); - if (!region) + if (!region) return 0; heap_segment* current_region = region; - + do { int gen_num = heap_segment_gen_num (current_region); @@ -29478,8 +29478,8 @@ heap_segment* gc_heap::find_first_valid_region (heap_segment* region, bool compa (int)heap_segment_swept_in_plan (current_region))); } - uint8_t* allocated = (compact_p ? - heap_segment_plan_allocated (current_region) : + uint8_t* allocated = (compact_p ? + heap_segment_plan_allocated (current_region) : heap_segment_allocated (current_region)); if (heap_segment_mem (current_region) == allocated) { @@ -29500,10 +29500,10 @@ heap_segment* gc_heap::find_first_valid_region (heap_segment* region, bool compa gen_num, heap_segment_mem (current_region), heap_segment_allocated (current_region), heap_segment_plan_allocated (current_region))); - + if (heap_segment_swept_in_plan (current_region)) { - assert (heap_segment_allocated (current_region) == + assert (heap_segment_allocated (current_region) == heap_segment_plan_allocated (current_region)); } else @@ -29524,7 +29524,7 @@ heap_segment* gc_heap::find_first_valid_region (heap_segment* region, bool compa decommit_heap_segment_pages (current_region, 0); } - dprintf (REGIONS_LOG, (" set region %Ix(%Ix) gen num to %d", + dprintf (REGIONS_LOG, (" set region %Ix(%Ix) gen num to %d", current_region, heap_segment_mem (current_region), plan_gen_num)); set_region_gen_num (current_region, plan_gen_num); break; @@ -29565,7 +29565,7 @@ void gc_heap::thread_final_regions (bool compact_p) int condemned_gen_number = settings.condemned_generation; generation_region_info generation_final_regions[max_generation + 1]; memset (generation_final_regions, 0, sizeof (generation_final_regions)); - + // Step 1: we initialize all the regions for generations we are not condemning with their // current head and tail as we know these regions will for sure exist. for (int gen_idx = max_generation; gen_idx > condemned_gen_number; gen_idx--) @@ -29586,7 +29586,7 @@ void gc_heap::thread_final_regions (bool compact_p) while ((current_region = find_first_valid_region (current_region, compact_p))) { - assert (!compact_p || + assert (!compact_p || (heap_segment_plan_gen_num (current_region) == heap_segment_gen_num (current_region))); int new_gen_num = heap_segment_plan_gen_num (current_region); generation* new_gen = generation_of (new_gen_num); @@ -29620,7 +29620,7 @@ void gc_heap::thread_final_regions (bool compact_p) heap_segment_next (generation_final_regions[gen_idx].tail) = 0; //if (heap_segment_next (generation_final_regions[gen_idx].tail) != 0) //{ - // dprintf (REGIONS_LOG, ("tail->next is %Ix", + // dprintf (REGIONS_LOG, ("tail->next is %Ix", // heap_segment_next (generation_final_regions[gen_idx].tail))); // GCToOSInterface::DebugBreak(); //} @@ -29646,7 +29646,7 @@ void gc_heap::thread_final_regions (bool compact_p) } generation_tail_region (gen) = generation_final_regions[gen_idx].tail; dprintf (REGIONS_LOG, ("setting gen%d start %Ix, tail %Ix", - gen_idx, + gen_idx, heap_segment_mem (heap_segment_rw (generation_start_segment (gen))), heap_segment_mem (generation_tail_region (gen)))); } @@ -29714,7 +29714,7 @@ heap_segment* gc_heap::get_new_region (int gen_number, size_t size) generation* gen = generation_of (gen_number); heap_segment_next (generation_tail_region (gen)) = new_region; generation_tail_region (gen) = new_region; - + verify_regions (gen_number, false); } @@ -29730,7 +29730,7 @@ heap_segment* gc_heap::allocate_new_region (gc_heap* hp, int gen_num, bool uoh_p assert (uoh_p || size == 0); // REGIONS TODO: allocate POH regions on the right - bool allocated_p = (uoh_p ? + bool allocated_p = (uoh_p ? global_region_allocator.allocate_large_region (&start, &end, allocate_forward, size, on_used_changed) : global_region_allocator.allocate_basic_region (&start, &end, on_used_changed)); @@ -29746,15 +29746,15 @@ heap_segment* gc_heap::allocate_new_region (gc_heap* hp, int gen_num, bool uoh_p } void gc_heap::update_start_tail_regions (generation* gen, - heap_segment* region_to_delete, - heap_segment* prev_region, + heap_segment* region_to_delete, + heap_segment* prev_region, heap_segment* next_region) { if (region_to_delete == heap_segment_rw (generation_start_segment (gen))) { assert (!prev_region); heap_segment* tail_ro_region = generation_tail_ro_region (gen); - + if (tail_ro_region) { heap_segment_next (tail_ro_region) = next_region; @@ -29782,7 +29782,7 @@ void gc_heap::update_start_tail_regions (generation* gen, } // There's one complication with deciding whether we can make a region SIP or not - if the plan_gen_num of -// a generation is not maxgen, and if we want to make every region in that generation maxgen, we need to +// a generation is not maxgen, and if we want to make every region in that generation maxgen, we need to // make sure we can get a new region for this generation so we can guarantee each generation has at least // one region. If we can't get a new region, we need to make sure we leave at least one region in that gen // to guarantee our invariant. @@ -29809,7 +29809,7 @@ bool gc_heap::should_sweep_in_plan (heap_segment* region) set_region_plan_gen_num (region, new_gen_num); sip_p = true; } - + if ((num_condemned_regions % sip_seg_maxgen_interval) == 0) { set_region_plan_gen_num (region, max_generation); @@ -29824,10 +29824,10 @@ bool gc_heap::should_sweep_in_plan (heap_segment* region) assert (heap_segment_gen_num (region) == heap_segment_plan_gen_num (region)); int surv_ratio = (int)(((double)heap_segment_survived (region) * 100.0) / (double)basic_region_size); - dprintf (2222, ("SSIP: region %Ix surv %Id / %Id = %d%%(%d)", + dprintf (2222, ("SSIP: region %Ix surv %Id / %Id = %d%%(%d)", heap_segment_mem (region), - heap_segment_survived (region), - basic_region_size, + heap_segment_survived (region), + basic_region_size, surv_ratio, sip_surv_ratio_th)); if (surv_ratio >= sip_surv_ratio_th) { @@ -29837,12 +29837,12 @@ bool gc_heap::should_sweep_in_plan (heap_segment* region) if (new_gen_num < max_generation) { - int old_card_surv_ratio = + int old_card_surv_ratio = (int)(((double)heap_segment_old_card_survived (region) * 100.0) / (double)basic_region_size); - dprintf (2222, ("SSIP: region %Ix old card surv %Id / %Id = %d%%(%d)", + dprintf (2222, ("SSIP: region %Ix old card surv %Id / %Id = %d%%(%d)", heap_segment_mem (region), - heap_segment_old_card_survived (region), - basic_region_size, + heap_segment_old_card_survived (region), + basic_region_size, old_card_surv_ratio, sip_surv_ratio_th)); if (old_card_surv_ratio >= sip_old_card_surv_ratio_th) { @@ -29857,7 +29857,7 @@ bool gc_heap::should_sweep_in_plan (heap_segment* region) { num_sip_regions++; - if ((new_gen_num < max_generation) && + if ((new_gen_num < max_generation) && (sip_maxgen_regions_per_gen[gen_num] == regions_per_gen[gen_num])) { assert (get_region_gen_num (region) == 0); @@ -29879,7 +29879,7 @@ bool gc_heap::should_sweep_in_plan (heap_segment* region) } } - dprintf (REGIONS_LOG, ("region %Ix %s SIP", heap_segment_mem (region), + dprintf (REGIONS_LOG, ("region %Ix %s SIP", heap_segment_mem (region), (sip_p ? "is" : "is not"))); return sip_p; } @@ -29919,11 +29919,11 @@ void heap_segment::thread_free_obj (uint8_t* obj, size_t s) // + build free objects. We keep a list of them which will then be threaded onto the appropriate generation's // free list. This can be optimized, both gen0 and gen2 GCs are easy to handle - need to see how easy it is // to handle gen1 GCs as the commit/repair there is complicated. -// +// // in plan_phase we also need to make sure to not call update_brick_table when handling end of this region, // and the plan gen num is set accordingly. -void gc_heap::sweep_region_in_plan (heap_segment* region, - BOOL use_mark_list, +void gc_heap::sweep_region_in_plan (heap_segment* region, + BOOL use_mark_list, uint8_t**& mark_list_next, uint8_t** mark_list_index) { @@ -29935,7 +29935,7 @@ void gc_heap::sweep_region_in_plan (heap_segment* region, uint8_t* last_marked_obj_start = 0; uint8_t* last_marked_obj_end = 0; uint8_t* end = heap_segment_allocated (region); - dprintf (2222, ("h%d region %Ix->%Ix SIP, gen %d->%d, %s mark list(%Ix->%Ix, %Ix->%Ix)", + dprintf (2222, ("h%d region %Ix->%Ix SIP, gen %d->%d, %s mark list(%Ix->%Ix, %Ix->%Ix)", heap_number, x, end, heap_segment_gen_num (region), heap_segment_plan_gen_num (region), (use_mark_list ? "using" : "not using"), (uint8_t*)mark_list_next, (mark_list_next ? *mark_list_next : 0), @@ -30016,12 +30016,12 @@ void gc_heap::sweep_region_in_plan (heap_segment* region, if (last_marked_obj_start_b == last_marked_obj_end_b) { - set_brick (last_marked_obj_start_b, + set_brick (last_marked_obj_start_b, (last_marked_obj_start - brick_address (last_marked_obj_start_b))); } else { - set_brick (last_marked_obj_end_b, + set_brick (last_marked_obj_end_b, (last_marked_obj_start_b - last_marked_obj_end_b)); } } @@ -30032,8 +30032,8 @@ void gc_heap::sweep_region_in_plan (heap_segment* region, #ifdef _DEBUG size_t region_index = get_basic_region_index_for_address (heap_segment_mem (region)); - dprintf (REGIONS_LOG, ("region #%d %Ix survived %Id, %s recorded %Id", - region_index, heap_segment_mem (region), survived, + dprintf (REGIONS_LOG, ("region #%d %Ix survived %Id, %s recorded %Id", + region_index, heap_segment_mem (region), survived, ((survived == heap_segment_survived (region)) ? "same as" : "diff from"), heap_segment_survived (region))); #ifdef MULTIPLE_HEAPS @@ -30080,7 +30080,7 @@ heap_segment* gc_heap::relocate_advance_to_non_sip (heap_segment* region) int plan_gen_num = heap_segment_plan_gen_num (current_region); bool use_sip_demotion = (plan_gen_num > get_plan_gen_num (gen_num)); - dprintf (REGIONS_LOG, ("region %Ix is SIP, relocating, gen %d, plan gen: %d(supposed to be %d) %s", + dprintf (REGIONS_LOG, ("region %Ix is SIP, relocating, gen %d, plan gen: %d(supposed to be %d) %s", heap_segment_mem (current_region), gen_num, plan_gen_num, get_plan_gen_num (gen_num), (use_sip_demotion ? "Sd" : "d"))); uint8_t* x = heap_segment_mem (current_region); @@ -30112,7 +30112,7 @@ heap_segment* gc_heap::relocate_advance_to_non_sip (heap_segment* region) if (child) { - dprintf (4444, ("SIP %Ix(%Ix)->%Ix->%Ix(%Ix)", + dprintf (4444, ("SIP %Ix(%Ix)->%Ix->%Ix(%Ix)", x, (uint8_t*)pval, child, *pval, method_table (child))); } }); @@ -30131,7 +30131,7 @@ heap_segment* gc_heap::relocate_advance_to_non_sip (heap_segment* region) heap_segment_mem (current_region), gen_num, plan_gen_num)); return current_region; } - + current_region = heap_segment_next (current_region); } @@ -30818,7 +30818,7 @@ void gc_heap::reloc_ref_in_shortened_obj (uint8_t** address_to_set_card, uint8_t relocate_address (address_to_reloc THREAD_NUMBER_ARG); if (address_to_reloc) { - dprintf (3, ("SR %Ix: %Ix->%Ix", (uint8_t*)address_to_reloc, old_val, *address_to_reloc)); + dprintf (3, ("SR %Ix: %Ix->%Ix", (uint8_t*)address_to_reloc, old_val, *address_to_reloc)); } check_demotion_helper (address_to_reloc, (uint8_t*)address_to_set_card); @@ -31094,7 +31094,7 @@ void gc_heap::relocate_survivors_in_plug (uint8_t* plug, uint8_t* plug_end, BOOL check_last_object_p, mark* pinned_plug_entry) { - dprintf (3,("RP: [%Ix(%Ix->%Ix),%Ix(%Ix->%Ix)[", + dprintf (3,("RP: [%Ix(%Ix->%Ix),%Ix(%Ix->%Ix)[", (size_t)plug, brick_of (plug), (size_t)brick_table[brick_of (plug)], (size_t)plug_end, brick_of (plug_end), (size_t)brick_table[brick_of (plug_end)])); @@ -31182,7 +31182,7 @@ heap_segment* gc_heap::get_start_segment (generation* gen) if (current_heap_segment != start_heap_segment) { dprintf (REGIONS_LOG, ("h%d skipped gen%d SIP regions, start %Ix->%Ix", - heap_number, + heap_number, (current_heap_segment ? heap_segment_gen_num (current_heap_segment) : -1), heap_segment_mem (start_heap_segment), (current_heap_segment ? heap_segment_mem (current_heap_segment) : 0))); @@ -32533,7 +32533,7 @@ void gc_heap::verify_mark_array_cleared (uint8_t* begin, uint8_t* end, uint32_t* #ifdef USE_REGIONS heap_segment* region = region_of (addr); dprintf (1, ("The mark bits at 0x%Ix:0x%Ix(addr: 0x%Ix, r: %Ix(%Ix)) were not cleared", - markw, mark_array_addr[markw], addr, + markw, mark_array_addr[markw], addr, (size_t)region, heap_segment_mem (region))); #else dprintf (1, ("The mark bits at 0x%Ix:0x%Ix(addr: 0x%Ix) were not cleared", @@ -32552,7 +32552,7 @@ void gc_heap::verify_mark_array_cleared (uint8_t* begin, uint8_t* end, uint32_t* uint8_t* gc_heap::get_start_address (heap_segment* seg) { - uint8_t* start = + uint8_t* start = #ifdef USE_REGIONS heap_segment_mem (seg); #else @@ -32715,7 +32715,7 @@ BOOL gc_heap::commit_mark_array_bgc_init() heap_segment* seg = heap_segment_in_range (generation_start_segment (gen)); while (seg) { - dprintf (GC_TABLE_LOG, ("h%d gen%d seg: %Ix(%Ix-%Ix), flags: %Id", + dprintf (GC_TABLE_LOG, ("h%d gen%d seg: %Ix(%Ix-%Ix), flags: %Id", heap_number, i, seg, heap_segment_mem (seg), heap_segment_allocated (seg), seg->flags)); if (!(seg->flags & heap_segment_flags_ma_committed)) @@ -33029,7 +33029,7 @@ void gc_heap::background_mark_phase () disable_preemptive (true); #ifndef FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP - // When software write watch is enabled, resetting write watch is done while the runtime is + // When software write watch is enabled, resetting write watch is done while the runtime is // suspended above. The post-reset call to revisit_written_pages is only necessary for concurrent // reset_write_watch, to discard dirtied pages during the concurrent reset. #ifdef WRITE_WATCH @@ -33721,7 +33721,7 @@ void gc_heap::revisit_written_pages (BOOL concurrent_p, BOOL reset_only_p) start_gen_idx = max_generation; } #endif //USE_REGIONS - + for (int i = start_gen_idx; i < total_generation_count; i++) { heap_segment* seg = heap_segment_rw (generation_start_segment (generation_of (i))); @@ -35153,7 +35153,7 @@ void gc_heap::bgc_tuning::calc_end_bgc_fl (int gen_number) } // reduce_p is for NGC2s. we want to reduce the ki so we don't overshoot. -double gc_heap::bgc_tuning::calculate_ml_tuning (uint64_t current_available_physical, bool reduce_p, +double gc_heap::bgc_tuning::calculate_ml_tuning (uint64_t current_available_physical, bool reduce_p, ptrdiff_t* _vfl_from_kp, ptrdiff_t* _vfl_from_ki) { ptrdiff_t error = (ptrdiff_t)(current_available_physical - available_memory_goal); @@ -35946,7 +35946,7 @@ gc_heap::compute_next_boundary (int gen_number, // For regions - // n_gen means it's pointing into the condemned regions so it's incremented -// if the child object's region is <= condemned_gen. +// if the child object's region is <= condemned_gen. // cg_pointers_found means it's pointing into a lower generation so it's incremented // if the child object's region is < current_gen. inline void @@ -36224,8 +36224,8 @@ void gc_heap::mark_through_cards_for_segments (card_fn fn, BOOL relocating CARD_ generation* oldest_gen = generation_of (max_generation); int curr_gen_number = max_generation; - // Note - condemned_gen is only needed for regions and the other 2 are - // only for if USE_REGIONS is not defined, but I need to pass them to a + // Note - condemned_gen is only needed for regions and the other 2 are + // only for if USE_REGIONS is not defined, but I need to pass them to a // function inside the macro below so just assert they are the unused values. #ifdef USE_REGIONS uint8_t* low = 0; @@ -38972,9 +38972,9 @@ size_t gc_heap::generation_fragmentation (generation* gen, heap_segment_plan_allocated (seg)); dprintf (3, ("h%d g%d adding seg plan frag: %Ix-%Ix=%Id -> %Id", - heap_number, gen_num, - heap_segment_saved_allocated (seg), - heap_segment_plan_allocated (seg), + heap_number, gen_num, + heap_segment_saved_allocated (seg), + heap_segment_plan_allocated (seg), (heap_segment_saved_allocated (seg) - heap_segment_plan_allocated (seg)), frag)); @@ -39046,7 +39046,7 @@ size_t gc_heap::generation_sizes (generation* gen, bool use_saved_p) heap_segment* seg = heap_segment_in_range (generation_start_segment (generation_of (i))); while (seg) { - uint8_t* end = (use_saved_p ? + uint8_t* end = (use_saved_p ? heap_segment_saved_allocated (seg) : heap_segment_allocated (seg)); result += end - heap_segment_mem (seg); dprintf (3, ("h%d gen%d size + %Id (%Ix - %Ix) -> %Id", @@ -39082,7 +39082,7 @@ bool gc_heap::decide_on_compaction_space() { size_t gen0size = approximate_new_allocation(); - dprintf (REGIONS_LOG, ("gen0size: %Id, free: %Id", + dprintf (REGIONS_LOG, ("gen0size: %Id, free: %Id", gen0size, (num_regions_freed_in_sweep * ((size_t)1 << min_segment_size_shr)))); // If we don't compact, would we have enough space? if (sufficient_space_regions ((num_regions_freed_in_sweep * ((size_t)1 << min_segment_size_shr)), @@ -39103,7 +39103,7 @@ bool gc_heap::decide_on_compaction_space() dprintf (REGIONS_LOG, ("gen0_pinned_free_space: %Id, end_gen0_region_space: %Id, gen0size: %Id", gen0_pinned_free_space, end_gen0_region_space, gen0size)); - if (sufficient_space_regions ((gen0_pinned_free_space + end_gen0_region_space), gen0size) && + if (sufficient_space_regions ((gen0_pinned_free_space + end_gen0_region_space), gen0size) && gen0_large_chunk_found) { sufficient_gen0_space_p = TRUE; @@ -39137,9 +39137,9 @@ bool gc_heap::is_full_compacting_gc_productive() #ifdef USE_REGIONS // If we needed to grow gen2 by extending either the end of its tail region // or having to acquire more regions for gen2, then we view this as unproductive. - // + // // Note that when we freely choose which region to demote and promote, this calculation - // will need to change. + // will need to change. heap_segment* gen1_start_region = generation_start_segment (generation_of (max_generation - 1)); if (heap_segment_plan_gen_num (gen1_start_region) == max_generation) { @@ -39282,7 +39282,7 @@ BOOL gc_heap::decide_on_compacting (int condemned_gen_number, // high fragmentation - it's just enough planned fragmentation for us to // want to compact. Also the "fragmentation" we are talking about here // is different from anywhere else. - dprintf (REGIONS_LOG, ("frag: %Id, fragmentation_burden: %.3f", + dprintf (REGIONS_LOG, ("frag: %Id, fragmentation_burden: %.3f", fragmentation, fragmentation_burden)); BOOL frag_exceeded = ((fragmentation >= dd_fragmentation_limit (dd)) && (fragmentation_burden >= dd_fragmentation_burden_limit (dd))); @@ -39418,7 +39418,7 @@ bool gc_heap::sufficient_space_regions (size_t end_space, size_t end_space_requi size_t free_regions_space = (free_regions[basic_free_region].get_num_free_regions() * ((size_t)1 << min_segment_size_shr)) + global_region_allocator.get_free(); size_t total_alloc_space = end_space + free_regions_space; - dprintf (REGIONS_LOG, ("h%d required %Id, end %Id + free %Id=%Id", + dprintf (REGIONS_LOG, ("h%d required %Id, end %Id + free %Id=%Id", heap_number, end_space_required, end_space, free_regions_space, total_alloc_space)); if (total_alloc_space > end_space_required) { @@ -39893,17 +39893,17 @@ void gc_heap::background_delay_delete_uoh_segments() assert (heap_segment_rw (generation_start_segment (gen)) == generation_start_segment (gen)); if (generation_start_segment (gen) != first_remaining_region) { - dprintf (REGIONS_LOG, ("h%d gen%d start %Ix -> %Ix", + dprintf (REGIONS_LOG, ("h%d gen%d start %Ix -> %Ix", heap_number, gen->gen_num, - heap_segment_mem (generation_start_segment (gen)), + heap_segment_mem (generation_start_segment (gen)), heap_segment_mem (first_remaining_region))); generation_start_segment (gen) = first_remaining_region; } if (generation_tail_region (gen) != prev_seg) { - dprintf (REGIONS_LOG, ("h%d gen%d start %Ix -> %Ix", + dprintf (REGIONS_LOG, ("h%d gen%d start %Ix -> %Ix", heap_number, gen->gen_num, - heap_segment_mem (generation_tail_region (gen)), + heap_segment_mem (generation_tail_region (gen)), heap_segment_mem (prev_seg))); generation_tail_region (gen) = prev_seg; } @@ -39937,9 +39937,9 @@ void gc_heap::generation_delete_heap_segment (generation* gen, heap_segment* prev_seg, heap_segment* next_seg) { - dprintf (3, ("bgc sweep: deleting seg %Ix(%Ix), next %Ix(%Ix), prev %Ix(%Ix)", + dprintf (3, ("bgc sweep: deleting seg %Ix(%Ix), next %Ix(%Ix), prev %Ix(%Ix)", (size_t)seg, heap_segment_mem (seg), - (size_t)next_seg, (next_seg ? heap_segment_mem (next_seg) : 0), + (size_t)next_seg, (next_seg ? heap_segment_mem (next_seg) : 0), (size_t)prev_seg, (prev_seg ? heap_segment_mem (prev_seg) : 0))); if (gen->gen_num > max_generation) { @@ -40046,7 +40046,7 @@ void gc_heap::process_background_segment_end (heap_segment* seg, { // REGIONS TODO: start_seg doesn't matter for regions. We can get rid of it too. // Just need to update the start segment accordingly in generation_delete_heap_segment. - // Also this might leave us with no regions at all for gen2 and we should be prepared + // Also this might leave us with no regions at all for gen2 and we should be prepared // for that. One approach is to ensure at least one region per generation at the beginning // of a GC. if (seg != start_seg) @@ -40054,7 +40054,7 @@ void gc_heap::process_background_segment_end (heap_segment* seg, *delete_p = TRUE; } - dprintf (3, ("h%d seg %Ix %s be deleted", heap_number, + dprintf (3, ("h%d seg %Ix %s be deleted", heap_number, heap_segment_mem (seg), (*delete_p ? "should" : "should not"))); } @@ -40197,7 +40197,7 @@ void gc_heap::should_check_bgc_mark (heap_segment* seg, } } -// REGIONS TODO: I'm not releasing any empty ephemeral regions here the gen0 allocator is +// REGIONS TODO: I'm not releasing any empty ephemeral regions here the gen0 allocator is // iterating over these regions. We'd want to do the same as what we do with LOH segs/regions. void gc_heap::background_ephemeral_sweep() { @@ -40328,7 +40328,7 @@ void gc_heap::background_ephemeral_sweep() else { #ifndef USE_REGIONS - heap_segment_allocated (ephemeral_heap_segment) = plug_end; + heap_segment_allocated (ephemeral_heap_segment) = plug_end; heap_segment_saved_bg_allocated (ephemeral_heap_segment) = plug_end; #endif //!USE_REGIONS make_unused_array (plug_end, (end - plug_end)); @@ -40540,8 +40540,8 @@ void gc_heap::background_sweep() PREFIX_ASSUME(start_seg != NULL); heap_segment* seg = start_seg; - dprintf (2, ("bgs: sweeping gen %Ix seg %Ix->%Ix(%Ix)", gen->gen_num, - heap_segment_mem (seg), + dprintf (2, ("bgs: sweeping gen %Ix seg %Ix->%Ix(%Ix)", gen->gen_num, + heap_segment_mem (seg), heap_segment_allocated (seg), heap_segment_background_allocated (seg))); while (seg @@ -40757,7 +40757,7 @@ void gc_heap::background_sweep() } #endif //DOUBLY_LINKED_FL - dprintf (GTC_LOG, ("seg: %Ix(%Ix), next_seg: %Ix(%Ix), prev_seg: %Ix(%Ix), delete_p %d", + dprintf (GTC_LOG, ("seg: %Ix(%Ix), next_seg: %Ix(%Ix), prev_seg: %Ix(%Ix), delete_p %d", seg, (seg ? heap_segment_mem (seg) : 0), next_seg, (next_seg ? heap_segment_mem (next_seg) : 0), saved_prev_seg, (saved_prev_seg ? heap_segment_mem (saved_prev_seg) : 0), @@ -41086,7 +41086,7 @@ void gc_heap::mark_through_cards_for_uoh_objects (card_fn fn, #ifdef USE_REGIONS int condemned_gen = settings.condemned_generation; -#else +#else int condemned_gen = -1; #endif //USE_REGIONS @@ -41362,7 +41362,7 @@ void gc_heap::descr_generations_to_profiler (gen_walk_fn fn, void *context) // for heap # heap_no fn(context, curr_gen_number, heap_segment_mem (seg), heap_segment_allocated (seg), - (curr_gen_number > max_generation) ? + (curr_gen_number > max_generation) ? heap_segment_reserved (seg) : heap_segment_allocated (seg)); seg = heap_segment_next (seg); @@ -42070,7 +42070,7 @@ void gc_heap::verify_regions (int gen_number, bool can_verify_gen_num) // 2) the tail region is the same as the last region if we following the list of regions // in that generation. // 3) no region is pointing to itself. - // 4) if we can verify gen num, each region's gen_num and plan_gen_num are the same and + // 4) if we can verify gen num, each region's gen_num and plan_gen_num are the same and // they are the right generation. generation* gen = generation_of (gen_number); int num_regions_in_gen = 0; @@ -42084,14 +42084,14 @@ void gc_heap::verify_regions (int gen_number, bool can_verify_gen_num) { if (heap_segment_gen_num (seg_in_gen) != min (gen_number, max_generation)) { - dprintf (REGIONS_LOG, ("h%d gen%d region %Ix(%Ix) gen is %d!", + dprintf (REGIONS_LOG, ("h%d gen%d region %Ix(%Ix) gen is %d!", heap_number, gen_number, seg_in_gen, heap_segment_mem (seg_in_gen), heap_segment_gen_num (seg_in_gen))); FATAL_GC_ERROR(); } if (heap_segment_gen_num (seg_in_gen) != heap_segment_plan_gen_num (seg_in_gen)) { - dprintf (REGIONS_LOG, ("h%d gen%d region %Ix(%Ix) gen is %d but plan gen is %d!!", + dprintf (REGIONS_LOG, ("h%d gen%d region %Ix(%Ix) gen is %d but plan gen is %d!!", heap_number, gen_number, seg_in_gen, heap_segment_mem (seg_in_gen), heap_segment_gen_num (seg_in_gen), heap_segment_plan_gen_num (seg_in_gen))); FATAL_GC_ERROR(); @@ -42111,7 +42111,7 @@ void gc_heap::verify_regions (int gen_number, bool can_verify_gen_num) heap_segment* next_region = heap_segment_next (seg_in_gen); if (seg_in_gen == next_region) { - dprintf (REGIONS_LOG, ("h%d gen%d region %Ix(%Ix) pointing to itself!!", + dprintf (REGIONS_LOG, ("h%d gen%d region %Ix(%Ix) pointing to itself!!", heap_number, gen_number, seg_in_gen, heap_segment_mem (seg_in_gen))); FATAL_GC_ERROR(); } @@ -42126,9 +42126,9 @@ void gc_heap::verify_regions (int gen_number, bool can_verify_gen_num) if (tail_region != prev_region_in_gen) { - dprintf (REGIONS_LOG, ("h%d gen%d tail region is %Ix(%Ix), diff from last region %Ix(%Ix)!!", - heap_number, gen_number, - tail_region, heap_segment_mem (tail_region), + dprintf (REGIONS_LOG, ("h%d gen%d tail region is %Ix(%Ix), diff from last region %Ix(%Ix)!!", + heap_number, gen_number, + tail_region, heap_segment_mem (tail_region), prev_region_in_gen, heap_segment_mem (prev_region_in_gen))); FATAL_GC_ERROR(); } @@ -42145,7 +42145,7 @@ void gc_heap::verify_regions (bool can_verify_gen_num) #endif //USE_REGIONS } -BOOL gc_heap::check_need_card (uint8_t* child_obj, int gen_num_for_cards, +BOOL gc_heap::check_need_card (uint8_t* child_obj, int gen_num_for_cards, uint8_t* low, uint8_t* high) { #ifdef USE_REGIONS @@ -42545,7 +42545,7 @@ void gc_heap::verify_heap (BOOL begin_gc_p) { dprintf (1, ("Card not set, curr_object = [%Ix:%Ix, %Ix:%Ix[", card_of (curr_object), (size_t)curr_object, - card_of (curr_object+Align(s, align_const)), + card_of (curr_object+Align(s, align_const)), (size_t)(curr_object+Align(s, align_const)))); FATAL_GC_ERROR(); } @@ -42817,7 +42817,7 @@ HRESULT GCHeap::Initialize() { return CLR_E_GC_BAD_HARD_LIMIT; } - gc_heap::heap_hard_limit = gc_heap::heap_hard_limit_oh[soh] + + gc_heap::heap_hard_limit = gc_heap::heap_hard_limit_oh[soh] + gc_heap::heap_hard_limit_oh[loh] + gc_heap::heap_hard_limit_oh[poh]; } else @@ -42846,7 +42846,7 @@ HRESULT GCHeap::Initialize() gc_heap::heap_hard_limit_oh[soh] = (size_t)(gc_heap::total_physical_mem * (uint64_t)percent_of_mem_soh / (uint64_t)100); gc_heap::heap_hard_limit_oh[loh] = (size_t)(gc_heap::total_physical_mem * (uint64_t)percent_of_mem_loh / (uint64_t)100); gc_heap::heap_hard_limit_oh[poh] = (size_t)(gc_heap::total_physical_mem * (uint64_t)percent_of_mem_poh / (uint64_t)100); - gc_heap::heap_hard_limit = gc_heap::heap_hard_limit_oh[soh] + + gc_heap::heap_hard_limit = gc_heap::heap_hard_limit_oh[soh] + gc_heap::heap_hard_limit_oh[loh] + gc_heap::heap_hard_limit_oh[poh]; } } @@ -42933,7 +42933,7 @@ HRESULT GCHeap::Initialize() nhp = min (nhp, MAX_SUPPORTED_CPUS); - gc_heap::gc_thread_no_affinitize_p = (gc_heap::heap_hard_limit ? + gc_heap::gc_thread_no_affinitize_p = (gc_heap::heap_hard_limit ? !affinity_config_specified_p : (GCConfig::GetNoAffinitize() != 0)); if (!(gc_heap::gc_thread_no_affinitize_p)) @@ -42993,7 +42993,7 @@ HRESULT GCHeap::Initialize() size_t seg_size_from_config = (size_t)GCConfig::GetSegmentSize(); if (seg_size_from_config) { - size_t aligned_seg_size_config = (gc_heap::use_large_pages_p ? + size_t aligned_seg_size_config = (gc_heap::use_large_pages_p ? align_on_segment_hard_limit (seg_size) : round_up_power2 (seg_size_from_config)); aligned_seg_size = max (aligned_seg_size, aligned_seg_size_config); aligned_large_seg_size = max (aligned_large_seg_size, aligned_seg_size_config); @@ -43122,7 +43122,7 @@ HRESULT GCHeap::Initialize() #ifndef FEATURE_REDHAWK // Redhawk forces relocation a different way #if defined (STRESS_HEAP) && !defined (MULTIPLE_HEAPS) - if (GCStress::IsEnabled()) + if (GCStress::IsEnabled()) { for (int i = 0; i < GCHeap::NUM_HEAP_STRESS_OBJS; i++) { @@ -43230,7 +43230,7 @@ HRESULT GCHeap::Initialize() for (int i = 0; i < 2; i++) { size_t ro_seg_size = 1024 * 1024; - // I'm not allocating this within the normal reserved range + // I'm not allocating this within the normal reserved range // because ro segs are supposed to always be out of range // for regions. uint8_t* seg_mem = new (nothrow) uint8_t [ro_seg_size]; @@ -43307,7 +43307,7 @@ size_t GCHeap::GetPromotedBytes(int heap_index) else #endif //BACKGROUND_GC { - gc_heap* hp = + gc_heap* hp = #ifdef MULTIPLE_HEAPS gc_heap::g_heaps[heap_index]; #else @@ -43506,7 +43506,7 @@ void GCHeap::Promote(Object** ppObject, ScanContext* sc, uint32_t flags) if (!gc_heap::is_in_condemned (o)) #else //USE_REGIONS if ((o < hp->gc_low) || (o >= hp->gc_high)) -#endif //USE_REGIONS +#endif //USE_REGIONS { return; } @@ -44797,7 +44797,7 @@ void gc_heap::do_post_gc() dprintf (1, ("(%d)GC commit END #%Id: %Id (recorded: %Id=%Id-%Id), heap %Id, frag: %Id", settings.condemned_generation, (size_t)settings.gc_index, total_heap_committed, total_heap_committed_recorded, - current_total_committed, current_total_committed_bookkeeping, + current_total_committed, current_total_committed_bookkeeping, last_gc_info->heap_size, last_gc_info->fragmentation)); } #endif //TRACE_GC @@ -45546,7 +45546,7 @@ HRESULT GCHeap::GetGcCounters(int gen, gc_counters* counters) size_t GCHeap::GetValidSegmentSize(bool large_seg) { #ifdef USE_REGIONS - return (large_seg ? global_region_allocator.get_large_region_alignment() : + return (large_seg ? global_region_allocator.get_large_region_alignment() : global_region_allocator.get_region_alignment()); #else return (large_seg ? gc_heap::min_uoh_segment_size : gc_heap::soh_segment_size); @@ -46414,10 +46414,10 @@ void GCHeap::DiagGetGCSettings(EtwGCSettingsInfo* etw_settings) etw_settings->use_large_pages_p = gc_heap::use_large_pages_p; etw_settings->use_frozen_segments_p = gc_heap::use_frozen_segments_p; etw_settings->hard_limit_config_p = gc_heap::hard_limit_config_p; - etw_settings->no_affinitize_p = + etw_settings->no_affinitize_p = #ifdef MULTIPLE_HEAPS gc_heap::gc_thread_no_affinitize_p; -#else +#else true; #endif //MULTIPLE_HEAPS #endif //FEATURE_EVENT_TRACE diff --git a/src/coreclr/gc/handletablecore.cpp b/src/coreclr/gc/handletablecore.cpp index 3df14f945e70c..07f2d563cee8c 100644 --- a/src/coreclr/gc/handletablecore.cpp +++ b/src/coreclr/gc/handletablecore.cpp @@ -2181,7 +2181,7 @@ void TableFreeBulkUnpreparedHandles(HandleTable *pTable, uint32_t uType, const O OBJECTHANDLE rgStackHandles[HANDLE_HANDLES_PER_BLOCK]; OBJECTHANDLE *pScratchBuffer = rgStackHandles; OBJECTHANDLE *pLargeScratchBuffer = NULL; - uint32_t uFreeGranularity = _countof(rgStackHandles); + uint32_t uFreeGranularity = ARRAY_SIZE(rgStackHandles); // if there are more handles than we can put on the stack then try to allocate a sorting buffer if (uCount > uFreeGranularity) diff --git a/src/coreclr/gc/handletablescan.cpp b/src/coreclr/gc/handletablescan.cpp index 9fde96a2c7be9..d8620b0efd1ce 100644 --- a/src/coreclr/gc/handletablescan.cpp +++ b/src/coreclr/gc/handletablescan.cpp @@ -19,7 +19,6 @@ #include "objecthandle.h" #include "handletablepriv.h" - /**************************************************************************** * * DEFINITIONS FOR WRITE-BARRIER HANDLING @@ -1084,7 +1083,7 @@ void CALLBACK BlockQueueBlocksForAsyncScan(PTR_TableSegment pSegment, uint32_t u if (pQNode) { // we got an existing tail - is the tail node full already? - if (pQNode->uEntries >= _countof(pQNode->rgRange)) + if (pQNode->uEntries >= ARRAY_SIZE(pQNode->rgRange)) { // the node is full - is there another node in the queue? if (!pQNode->pNext) diff --git a/src/coreclr/gc/objecthandle.cpp b/src/coreclr/gc/objecthandle.cpp index cd5c1dc22db79..2465712822861 100644 --- a/src/coreclr/gc/objecthandle.cpp +++ b/src/coreclr/gc/objecthandle.cpp @@ -622,7 +622,7 @@ bool Ref_Initialize() n_slots * sizeof(HHANDLETABLE)); for (int uCPUindex = 0; uCPUindex < n_slots; uCPUindex++) { - pBucket->pTable[uCPUindex] = HndCreateHandleTable(s_rgTypeFlags, _countof(s_rgTypeFlags)); + pBucket->pTable[uCPUindex] = HndCreateHandleTable(s_rgTypeFlags, ARRAY_SIZE(s_rgTypeFlags)); if (pBucket->pTable[uCPUindex] == NULL) goto CleanupAndFail; @@ -719,7 +719,7 @@ bool Ref_InitializeHandleTableBucket(HandleTableBucket* bucket) ZeroMemory(result->pTable, n_slots * sizeof(HHANDLETABLE)); for (int uCPUindex=0; uCPUindex < n_slots; uCPUindex++) { - result->pTable[uCPUindex] = HndCreateHandleTable(s_rgTypeFlags, _countof(s_rgTypeFlags)); + result->pTable[uCPUindex] = HndCreateHandleTable(s_rgTypeFlags, ARRAY_SIZE(s_rgTypeFlags)); if (!result->pTable[uCPUindex]) return false; } @@ -1045,7 +1045,7 @@ void Ref_TraceNormalRoots(uint32_t condemned, uint32_t maxgen, ScanContext* sc, // promote objects pointed to by strong handles // during ephemeral GCs we also want to promote the ones pointed to by sizedref handles. uint32_t types[2] = {HNDTYPE_STRONG, HNDTYPE_SIZEDREF}; - uint32_t uTypeCount = (((condemned >= maxgen) && !g_theGCHeap->IsConcurrentGCInProgress()) ? 1 : _countof(types)); + uint32_t uTypeCount = (((condemned >= maxgen) && !g_theGCHeap->IsConcurrentGCInProgress()) ? 1 : ARRAY_SIZE(types)); uint32_t flags = (sc->concurrent) ? HNDGCF_ASYNC : HNDGCF_NORMAL; HandleTableMap *walk = &g_HandleTableMap; @@ -1149,7 +1149,7 @@ void Ref_CheckReachable(uint32_t condemned, uint32_t maxgen, uintptr_t lp1) { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[uCPUindex]; if (hTable) - HndScanHandlesForGC(hTable, CheckPromoted, lp1, 0, types, _countof(types), condemned, maxgen, flags); + HndScanHandlesForGC(hTable, CheckPromoted, lp1, 0, types, ARRAY_SIZE(types), condemned, maxgen, flags); } } walk = walk->pNext; @@ -1395,7 +1395,7 @@ void Ref_CheckAlive(uint32_t condemned, uint32_t maxgen, uintptr_t lp1) { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[uCPUindex]; if (hTable) - HndScanHandlesForGC(hTable, CheckPromoted, lp1, 0, types, _countof(types), condemned, maxgen, flags); + HndScanHandlesForGC(hTable, CheckPromoted, lp1, 0, types, ARRAY_SIZE(types), condemned, maxgen, flags); } } walk = walk->pNext; @@ -1454,7 +1454,7 @@ void Ref_UpdatePointers(uint32_t condemned, uint32_t maxgen, ScanContext* sc, Re { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[getSlotNumber(sc)]; if (hTable) - HndScanHandlesForGC(hTable, UpdatePointer, uintptr_t(sc), uintptr_t(fn), types, _countof(types), condemned, maxgen, flags); + HndScanHandlesForGC(hTable, UpdatePointer, uintptr_t(sc), uintptr_t(fn), types, ARRAY_SIZE(types), condemned, maxgen, flags); } walk = walk->pNext; } @@ -1505,7 +1505,7 @@ void Ref_ScanHandlesForProfilerAndETW(uint32_t maxgen, uintptr_t lp1, handle_sca { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[uCPUindex]; if (hTable) - HndScanHandlesForGC(hTable, &ScanPointerForProfilerAndETW, lp1, (uintptr_t)fn, types, _countof(types), maxgen, maxgen, flags); + HndScanHandlesForGC(hTable, &ScanPointerForProfilerAndETW, lp1, (uintptr_t)fn, types, ARRAY_SIZE(types), maxgen, maxgen, flags); } walk = walk->pNext; } @@ -1574,7 +1574,7 @@ void Ref_ScanPointers(uint32_t condemned, uint32_t maxgen, ScanContext* sc, Ref_ { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[uCPUindex]; if (hTable) - HndScanHandlesForGC(hTable, &ScanPointer, uintptr_t(sc), uintptr_t(fn), types, _countof(types), condemned, maxgen, flags); + HndScanHandlesForGC(hTable, &ScanPointer, uintptr_t(sc), uintptr_t(fn), types, ARRAY_SIZE(types), condemned, maxgen, flags); } } } @@ -1601,7 +1601,7 @@ void Ref_UpdatePinnedPointers(uint32_t condemned, uint32_t maxgen, ScanContext* { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[getSlotNumber(sc)]; if (hTable) - HndScanHandlesForGC(hTable, UpdatePointerPinned, uintptr_t(sc), uintptr_t(fn), types, _countof(types), condemned, maxgen, flags); + HndScanHandlesForGC(hTable, UpdatePointerPinned, uintptr_t(sc), uintptr_t(fn), types, ARRAY_SIZE(types), condemned, maxgen, flags); } walk = walk->pNext; } @@ -1646,7 +1646,7 @@ void Ref_AgeHandles(uint32_t condemned, uint32_t maxgen, uintptr_t lp1) { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[uCPUindex]; if (hTable) - HndScanHandlesForGC(hTable, NULL, 0, 0, types, _countof(types), condemned, maxgen, HNDGCF_AGE); + HndScanHandlesForGC(hTable, NULL, 0, 0, types, ARRAY_SIZE(types), condemned, maxgen, HNDGCF_AGE); } walk = walk->pNext; } @@ -1689,7 +1689,7 @@ void Ref_RejuvenateHandles(uint32_t condemned, uint32_t maxgen, uintptr_t lp1) { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[uCPUindex]; if (hTable) - HndResetAgeMap(hTable, types, _countof(types), condemned, maxgen, HNDGCF_NORMAL); + HndResetAgeMap(hTable, types, ARRAY_SIZE(types), condemned, maxgen, HNDGCF_NORMAL); } walk = walk->pNext; } @@ -1733,7 +1733,7 @@ void Ref_VerifyHandleTable(uint32_t condemned, uint32_t maxgen, ScanContext* sc) { HHANDLETABLE hTable = walk->pBuckets[i]->pTable[getSlotNumber(sc)]; if (hTable) - HndVerifyTable(hTable, types, _countof(types), condemned, maxgen, HNDGCF_NORMAL); + HndVerifyTable(hTable, types, ARRAY_SIZE(types), condemned, maxgen, HNDGCF_NORMAL); } } walk = walk->pNext; diff --git a/src/coreclr/gc/unix/gcenv.unix.cpp b/src/coreclr/gc/unix/gcenv.unix.cpp index a8033455917f8..8bd5037f7ebe5 100644 --- a/src/coreclr/gc/unix/gcenv.unix.cpp +++ b/src/coreclr/gc/unix/gcenv.unix.cpp @@ -79,7 +79,7 @@ extern "C" if (machret != KERN_SUCCESS) \ { \ char _szError[1024]; \ - snprintf(_szError, _countof(_szError), "%s: %u: %s", __FUNCTION__, __LINE__, _msg); \ + snprintf(_szError, ARRAY_SIZE(_szError), "%s: %u: %s", __FUNCTION__, __LINE__, _msg); \ mach_error(_szError, machret); \ abort(); \ } \ diff --git a/src/coreclr/gcdump/gcdumpnonx86.cpp b/src/coreclr/gcdump/gcdumpnonx86.cpp index 84da4592e622d..235c8bf24acb1 100644 --- a/src/coreclr/gcdump/gcdumpnonx86.cpp +++ b/src/coreclr/gcdump/gcdumpnonx86.cpp @@ -45,7 +45,7 @@ PCSTR GetRegName (UINT32 regnum) static CHAR szRegName[16]; if (regnum < 29) { - _snprintf_s(szRegName, _countof(szRegName), sizeof(szRegName), "X%u", regnum); + _snprintf_s(szRegName, ARRAY_SIZE(szRegName), sizeof(szRegName), "X%u", regnum); return szRegName; } else if(regnum == 29) @@ -67,7 +67,7 @@ PCSTR GetRegName (UINT32 regnum) return "???"; static CHAR szRegName[16]; - _snprintf_s(szRegName, _countof(szRegName), sizeof(szRegName), "r%u", regnum); + _snprintf_s(szRegName, ARRAY_SIZE(szRegName), sizeof(szRegName), "r%u", regnum); return szRegName; #endif diff --git a/src/coreclr/hosts/corerun/corerun.hpp b/src/coreclr/hosts/corerun/corerun.hpp index c453f9e5daf12..02cf63915874f 100644 --- a/src/coreclr/hosts/corerun/corerun.hpp +++ b/src/coreclr/hosts/corerun/corerun.hpp @@ -16,6 +16,7 @@ #include #include #include +#include // Class used to perform specific actions. class platform_specific_actions; @@ -95,7 +96,7 @@ namespace pal inline string_t get_exe_path() { char_t file_name[1024]; - DWORD count = ::GetModuleFileNameW(nullptr, file_name, ARRAYSIZE(file_name)); + DWORD count = ::GetModuleFileNameW(nullptr, file_name, ARRAY_SIZE(file_name)); assert(::GetLastError() != ERROR_INSUFFICIENT_BUFFER); return { file_name }; @@ -310,7 +311,7 @@ class platform_specific_actions final // CMake generated #include -#include +#include #define MAIN main #define W(str) str diff --git a/src/coreclr/hosts/coreshim/ComActivation.cpp b/src/coreclr/hosts/coreshim/ComActivation.cpp index 33d316e13cca5..bf5e2ac9e77cd 100644 --- a/src/coreclr/hosts/coreshim/ComActivation.cpp +++ b/src/coreclr/hosts/coreshim/ComActivation.cpp @@ -31,9 +31,9 @@ namespace tpaList.c_str(), }; - static_assert(ARRAYSIZE(keys) == ARRAYSIZE(values), "key/values pairs should match in length"); + static_assert(ARRAY_SIZE(keys) == ARRAY_SIZE(values), "key/values pairs should match in length"); - return inst->Initialize(ARRAYSIZE(keys), keys, values, "COMAct"); + return inst->Initialize(ARRAY_SIZE(keys), keys, values, "COMAct"); } } diff --git a/src/coreclr/hosts/coreshim/CoreShim.cpp b/src/coreclr/hosts/coreshim/CoreShim.cpp index 0648ef4f4e0ec..62ab011df1215 100644 --- a/src/coreclr/hosts/coreshim/CoreShim.cpp +++ b/src/coreclr/hosts/coreshim/CoreShim.cpp @@ -16,7 +16,7 @@ namespace PathBuffer() : DefBuffer{} , Buf{ DefBuffer } - , Len{ ARRAYSIZE(DefBuffer) } + , Len{ ARRAY_SIZE(DefBuffer) } { } void SetLength(_In_ DWORD len) @@ -277,7 +277,7 @@ HRESULT coreclr::CreateTpaList(_Inout_ std::string &tpaList, _In_opt_z_ const WC // Walk the directory for each extension separately so assembly types // are discovered in priority order - see above. - for (int extIndex = 0; extIndex < ARRAYSIZE(tpaExtensions); extIndex++) + for (int extIndex = 0; extIndex < ARRAY_SIZE(tpaExtensions); extIndex++) { const WCHAR* ext = tpaExtensions[extIndex]; size_t extLength = ::wcslen(ext); diff --git a/src/coreclr/hosts/coreshim/CoreShim.h b/src/coreclr/hosts/coreshim/CoreShim.h index 09bc0d77a109a..97b630bdb9e19 100644 --- a/src/coreclr/hosts/coreshim/CoreShim.h +++ b/src/coreclr/hosts/coreshim/CoreShim.h @@ -18,6 +18,7 @@ // CoreCLR #include #include +#include #define WCHAR wchar_t diff --git a/src/coreclr/ilasm/grammar_after.cpp b/src/coreclr/ilasm/grammar_after.cpp index a3f1fb7a21822..cb649ea338d07 100644 --- a/src/coreclr/ilasm/grammar_after.cpp +++ b/src/coreclr/ilasm/grammar_after.cpp @@ -60,14 +60,14 @@ static Keywords keywords[] = { #define NEW_INLINE_NAMES // The volatile instruction collides with the volatile keyword, so // we treat it as a keyword everywhere and modify the grammar accordingly (Yuck!) -#define OPDEF(c,s,pop,push,args,type,l,s1,s2,ctrl) { s, args, c, lengthof(s)-1 }, -#define OPALIAS(alias_c, s, c) { s, NO_VALUE, c, lengthof(s)-1 }, +#define OPDEF(c,s,pop,push,args,type,l,s1,s2,ctrl) { s, args, c, STRING_LENGTH(s) }, +#define OPALIAS(alias_c, s, c) { s, NO_VALUE, c, STRING_LENGTH(s) }, #include "opcode.def" #undef OPALIAS #undef OPDEF /* keywords */ -#define KYWD(name, sym, val) { name, sym, val, lengthof(name)-1 }, +#define KYWD(name, sym, val) { name, sym, val, STRING_LENGTH(name) }, #include "il_kywd.h" #undef KYWD diff --git a/src/coreclr/ilasm/prebuilt/asmparse.cpp b/src/coreclr/ilasm/prebuilt/asmparse.cpp index e3afe381a62f8..6c0aa7477a321 100644 --- a/src/coreclr/ilasm/prebuilt/asmparse.cpp +++ b/src/coreclr/ilasm/prebuilt/asmparse.cpp @@ -46,291 +46,291 @@ typedef union { CustomDescr* cad; unsigned short opcode; } YYSTYPE; -# define ERROR_ 257 -# define BAD_COMMENT_ 258 -# define BAD_LITERAL_ 259 -# define ID 260 -# define DOTTEDNAME 261 -# define QSTRING 262 -# define SQSTRING 263 -# define INT32 264 -# define INT64 265 -# define FLOAT64 266 -# define HEXBYTE 267 -# define TYPEDEF_T 268 -# define TYPEDEF_M 269 -# define TYPEDEF_F 270 -# define TYPEDEF_TS 271 -# define TYPEDEF_MR 272 -# define TYPEDEF_CA 273 -# define DCOLON 274 -# define ELIPSIS 275 -# define VOID_ 276 -# define BOOL_ 277 -# define CHAR_ 278 -# define UNSIGNED_ 279 -# define INT_ 280 -# define INT8_ 281 -# define INT16_ 282 -# define INT32_ 283 -# define INT64_ 284 -# define FLOAT_ 285 -# define FLOAT32_ 286 -# define FLOAT64_ 287 -# define BYTEARRAY_ 288 -# define UINT_ 289 -# define UINT8_ 290 -# define UINT16_ 291 -# define UINT32_ 292 -# define UINT64_ 293 -# define FLAGS_ 294 -# define CALLCONV_ 295 -# define MDTOKEN_ 296 -# define OBJECT_ 297 -# define STRING_ 298 -# define NULLREF_ 299 -# define DEFAULT_ 300 -# define CDECL_ 301 -# define VARARG_ 302 -# define STDCALL_ 303 -# define THISCALL_ 304 -# define FASTCALL_ 305 -# define CLASS_ 306 -# define TYPEDREF_ 307 -# define UNMANAGED_ 308 -# define FINALLY_ 309 -# define HANDLER_ 310 -# define CATCH_ 311 -# define FILTER_ 312 -# define FAULT_ 313 -# define EXTENDS_ 314 -# define IMPLEMENTS_ 315 -# define TO_ 316 -# define AT_ 317 -# define TLS_ 318 -# define TRUE_ 319 -# define FALSE_ 320 -# define _INTERFACEIMPL 321 -# define VALUE_ 322 -# define VALUETYPE_ 323 -# define NATIVE_ 324 -# define INSTANCE_ 325 -# define SPECIALNAME_ 326 -# define FORWARDER_ 327 -# define STATIC_ 328 -# define PUBLIC_ 329 -# define PRIVATE_ 330 -# define FAMILY_ 331 -# define FINAL_ 332 -# define SYNCHRONIZED_ 333 -# define INTERFACE_ 334 -# define SEALED_ 335 -# define NESTED_ 336 -# define ABSTRACT_ 337 -# define AUTO_ 338 -# define SEQUENTIAL_ 339 -# define EXPLICIT_ 340 -# define ANSI_ 341 -# define UNICODE_ 342 -# define AUTOCHAR_ 343 -# define IMPORT_ 344 -# define ENUM_ 345 -# define VIRTUAL_ 346 -# define NOINLINING_ 347 -# define AGGRESSIVEINLINING_ 348 -# define NOOPTIMIZATION_ 349 -# define AGGRESSIVEOPTIMIZATION_ 350 -# define UNMANAGEDEXP_ 351 -# define BEFOREFIELDINIT_ 352 -# define STRICT_ 353 -# define RETARGETABLE_ 354 -# define WINDOWSRUNTIME_ 355 -# define NOPLATFORM_ 356 -# define METHOD_ 357 -# define FIELD_ 358 -# define PINNED_ 359 -# define MODREQ_ 360 -# define MODOPT_ 361 -# define SERIALIZABLE_ 362 -# define PROPERTY_ 363 -# define TYPE_ 364 -# define ASSEMBLY_ 365 -# define FAMANDASSEM_ 366 -# define FAMORASSEM_ 367 -# define PRIVATESCOPE_ 368 -# define HIDEBYSIG_ 369 -# define NEWSLOT_ 370 -# define RTSPECIALNAME_ 371 -# define PINVOKEIMPL_ 372 -# define _CTOR 373 -# define _CCTOR 374 -# define LITERAL_ 375 -# define NOTSERIALIZED_ 376 -# define INITONLY_ 377 -# define REQSECOBJ_ 378 -# define CIL_ 379 -# define OPTIL_ 380 -# define MANAGED_ 381 -# define FORWARDREF_ 382 -# define PRESERVESIG_ 383 -# define RUNTIME_ 384 -# define INTERNALCALL_ 385 -# define _IMPORT 386 -# define NOMANGLE_ 387 -# define LASTERR_ 388 -# define WINAPI_ 389 -# define AS_ 390 -# define BESTFIT_ 391 -# define ON_ 392 -# define OFF_ 393 -# define CHARMAPERROR_ 394 -# define INSTR_NONE 395 -# define INSTR_VAR 396 -# define INSTR_I 397 -# define INSTR_I8 398 -# define INSTR_R 399 -# define INSTR_BRTARGET 400 -# define INSTR_METHOD 401 -# define INSTR_FIELD 402 -# define INSTR_TYPE 403 -# define INSTR_STRING 404 -# define INSTR_SIG 405 -# define INSTR_TOK 406 -# define INSTR_SWITCH 407 -# define _CLASS 408 -# define _NAMESPACE 409 -# define _METHOD 410 -# define _FIELD 411 -# define _DATA 412 -# define _THIS 413 -# define _BASE 414 -# define _NESTER 415 -# define _EMITBYTE 416 -# define _TRY 417 -# define _MAXSTACK 418 -# define _LOCALS 419 -# define _ENTRYPOINT 420 -# define _ZEROINIT 421 -# define _EVENT 422 -# define _ADDON 423 -# define _REMOVEON 424 -# define _FIRE 425 -# define _OTHER 426 -# define _PROPERTY 427 -# define _SET 428 -# define _GET 429 -# define _PERMISSION 430 -# define _PERMISSIONSET 431 -# define REQUEST_ 432 -# define DEMAND_ 433 -# define ASSERT_ 434 -# define DENY_ 435 -# define PERMITONLY_ 436 -# define LINKCHECK_ 437 -# define INHERITCHECK_ 438 -# define REQMIN_ 439 -# define REQOPT_ 440 -# define REQREFUSE_ 441 -# define PREJITGRANT_ 442 -# define PREJITDENY_ 443 -# define NONCASDEMAND_ 444 -# define NONCASLINKDEMAND_ 445 -# define NONCASINHERITANCE_ 446 -# define _LINE 447 -# define P_LINE 448 -# define _LANGUAGE 449 -# define _CUSTOM 450 -# define INIT_ 451 -# define _SIZE 452 -# define _PACK 453 -# define _VTABLE 454 -# define _VTFIXUP 455 -# define FROMUNMANAGED_ 456 -# define CALLMOSTDERIVED_ 457 -# define _VTENTRY 458 -# define RETAINAPPDOMAIN_ 459 -# define _FILE 460 -# define NOMETADATA_ 461 -# define _HASH 462 -# define _ASSEMBLY 463 -# define _PUBLICKEY 464 -# define _PUBLICKEYTOKEN 465 -# define ALGORITHM_ 466 -# define _VER 467 -# define _LOCALE 468 -# define EXTERN_ 469 -# define _MRESOURCE 470 -# define _MODULE 471 -# define _EXPORT 472 -# define LEGACY_ 473 -# define LIBRARY_ 474 -# define X86_ 475 -# define AMD64_ 476 -# define ARM_ 477 -# define ARM64_ 478 -# define MARSHAL_ 479 -# define CUSTOM_ 480 -# define SYSSTRING_ 481 -# define FIXED_ 482 -# define VARIANT_ 483 -# define CURRENCY_ 484 -# define SYSCHAR_ 485 -# define DECIMAL_ 486 -# define DATE_ 487 -# define BSTR_ 488 -# define TBSTR_ 489 -# define LPSTR_ 490 -# define LPWSTR_ 491 -# define LPTSTR_ 492 -# define OBJECTREF_ 493 -# define IUNKNOWN_ 494 -# define IDISPATCH_ 495 -# define STRUCT_ 496 -# define SAFEARRAY_ 497 -# define BYVALSTR_ 498 -# define LPVOID_ 499 -# define ANY_ 500 -# define ARRAY_ 501 -# define LPSTRUCT_ 502 -# define IIDPARAM_ 503 -# define IN_ 504 -# define OUT_ 505 -# define OPT_ 506 -# define _PARAM 507 -# define _OVERRIDE 508 -# define WITH_ 509 -# define NULL_ 510 -# define HRESULT_ 511 -# define CARRAY_ 512 -# define USERDEFINED_ 513 -# define RECORD_ 514 -# define FILETIME_ 515 -# define BLOB_ 516 -# define STREAM_ 517 -# define STORAGE_ 518 -# define STREAMED_OBJECT_ 519 -# define STORED_OBJECT_ 520 -# define BLOB_OBJECT_ 521 -# define CF_ 522 -# define CLSID_ 523 -# define VECTOR_ 524 -# define _SUBSYSTEM 525 -# define _CORFLAGS 526 -# define ALIGNMENT_ 527 -# define _IMAGEBASE 528 -# define _STACKRESERVE 529 -# define _TYPEDEF 530 -# define _TEMPLATE 531 -# define _TYPELIST 532 -# define _MSCORLIB 533 -# define P_DEFINE 534 -# define P_UNDEF 535 -# define P_IFDEF 536 -# define P_IFNDEF 537 -# define P_ELSE 538 -# define P_ENDIF 539 -# define P_INCLUDE 540 -# define CONSTRAINT_ 541 +# define ERROR_ 257 +# define BAD_COMMENT_ 258 +# define BAD_LITERAL_ 259 +# define ID 260 +# define DOTTEDNAME 261 +# define QSTRING 262 +# define SQSTRING 263 +# define INT32 264 +# define INT64 265 +# define FLOAT64 266 +# define HEXBYTE 267 +# define TYPEDEF_T 268 +# define TYPEDEF_M 269 +# define TYPEDEF_F 270 +# define TYPEDEF_TS 271 +# define TYPEDEF_MR 272 +# define TYPEDEF_CA 273 +# define DCOLON 274 +# define ELIPSIS 275 +# define VOID_ 276 +# define BOOL_ 277 +# define CHAR_ 278 +# define UNSIGNED_ 279 +# define INT_ 280 +# define INT8_ 281 +# define INT16_ 282 +# define INT32_ 283 +# define INT64_ 284 +# define FLOAT_ 285 +# define FLOAT32_ 286 +# define FLOAT64_ 287 +# define BYTEARRAY_ 288 +# define UINT_ 289 +# define UINT8_ 290 +# define UINT16_ 291 +# define UINT32_ 292 +# define UINT64_ 293 +# define FLAGS_ 294 +# define CALLCONV_ 295 +# define MDTOKEN_ 296 +# define OBJECT_ 297 +# define STRING_ 298 +# define NULLREF_ 299 +# define DEFAULT_ 300 +# define CDECL_ 301 +# define VARARG_ 302 +# define STDCALL_ 303 +# define THISCALL_ 304 +# define FASTCALL_ 305 +# define CLASS_ 306 +# define TYPEDREF_ 307 +# define UNMANAGED_ 308 +# define FINALLY_ 309 +# define HANDLER_ 310 +# define CATCH_ 311 +# define FILTER_ 312 +# define FAULT_ 313 +# define EXTENDS_ 314 +# define IMPLEMENTS_ 315 +# define TO_ 316 +# define AT_ 317 +# define TLS_ 318 +# define TRUE_ 319 +# define FALSE_ 320 +# define _INTERFACEIMPL 321 +# define VALUE_ 322 +# define VALUETYPE_ 323 +# define NATIVE_ 324 +# define INSTANCE_ 325 +# define SPECIALNAME_ 326 +# define FORWARDER_ 327 +# define STATIC_ 328 +# define PUBLIC_ 329 +# define PRIVATE_ 330 +# define FAMILY_ 331 +# define FINAL_ 332 +# define SYNCHRONIZED_ 333 +# define INTERFACE_ 334 +# define SEALED_ 335 +# define NESTED_ 336 +# define ABSTRACT_ 337 +# define AUTO_ 338 +# define SEQUENTIAL_ 339 +# define EXPLICIT_ 340 +# define ANSI_ 341 +# define UNICODE_ 342 +# define AUTOCHAR_ 343 +# define IMPORT_ 344 +# define ENUM_ 345 +# define VIRTUAL_ 346 +# define NOINLINING_ 347 +# define AGGRESSIVEINLINING_ 348 +# define NOOPTIMIZATION_ 349 +# define AGGRESSIVEOPTIMIZATION_ 350 +# define UNMANAGEDEXP_ 351 +# define BEFOREFIELDINIT_ 352 +# define STRICT_ 353 +# define RETARGETABLE_ 354 +# define WINDOWSRUNTIME_ 355 +# define NOPLATFORM_ 356 +# define METHOD_ 357 +# define FIELD_ 358 +# define PINNED_ 359 +# define MODREQ_ 360 +# define MODOPT_ 361 +# define SERIALIZABLE_ 362 +# define PROPERTY_ 363 +# define TYPE_ 364 +# define ASSEMBLY_ 365 +# define FAMANDASSEM_ 366 +# define FAMORASSEM_ 367 +# define PRIVATESCOPE_ 368 +# define HIDEBYSIG_ 369 +# define NEWSLOT_ 370 +# define RTSPECIALNAME_ 371 +# define PINVOKEIMPL_ 372 +# define _CTOR 373 +# define _CCTOR 374 +# define LITERAL_ 375 +# define NOTSERIALIZED_ 376 +# define INITONLY_ 377 +# define REQSECOBJ_ 378 +# define CIL_ 379 +# define OPTIL_ 380 +# define MANAGED_ 381 +# define FORWARDREF_ 382 +# define PRESERVESIG_ 383 +# define RUNTIME_ 384 +# define INTERNALCALL_ 385 +# define _IMPORT 386 +# define NOMANGLE_ 387 +# define LASTERR_ 388 +# define WINAPI_ 389 +# define AS_ 390 +# define BESTFIT_ 391 +# define ON_ 392 +# define OFF_ 393 +# define CHARMAPERROR_ 394 +# define INSTR_NONE 395 +# define INSTR_VAR 396 +# define INSTR_I 397 +# define INSTR_I8 398 +# define INSTR_R 399 +# define INSTR_BRTARGET 400 +# define INSTR_METHOD 401 +# define INSTR_FIELD 402 +# define INSTR_TYPE 403 +# define INSTR_STRING 404 +# define INSTR_SIG 405 +# define INSTR_TOK 406 +# define INSTR_SWITCH 407 +# define _CLASS 408 +# define _NAMESPACE 409 +# define _METHOD 410 +# define _FIELD 411 +# define _DATA 412 +# define _THIS 413 +# define _BASE 414 +# define _NESTER 415 +# define _EMITBYTE 416 +# define _TRY 417 +# define _MAXSTACK 418 +# define _LOCALS 419 +# define _ENTRYPOINT 420 +# define _ZEROINIT 421 +# define _EVENT 422 +# define _ADDON 423 +# define _REMOVEON 424 +# define _FIRE 425 +# define _OTHER 426 +# define _PROPERTY 427 +# define _SET 428 +# define _GET 429 +# define _PERMISSION 430 +# define _PERMISSIONSET 431 +# define REQUEST_ 432 +# define DEMAND_ 433 +# define ASSERT_ 434 +# define DENY_ 435 +# define PERMITONLY_ 436 +# define LINKCHECK_ 437 +# define INHERITCHECK_ 438 +# define REQMIN_ 439 +# define REQOPT_ 440 +# define REQREFUSE_ 441 +# define PREJITGRANT_ 442 +# define PREJITDENY_ 443 +# define NONCASDEMAND_ 444 +# define NONCASLINKDEMAND_ 445 +# define NONCASINHERITANCE_ 446 +# define _LINE 447 +# define P_LINE 448 +# define _LANGUAGE 449 +# define _CUSTOM 450 +# define INIT_ 451 +# define _SIZE 452 +# define _PACK 453 +# define _VTABLE 454 +# define _VTFIXUP 455 +# define FROMUNMANAGED_ 456 +# define CALLMOSTDERIVED_ 457 +# define _VTENTRY 458 +# define RETAINAPPDOMAIN_ 459 +# define _FILE 460 +# define NOMETADATA_ 461 +# define _HASH 462 +# define _ASSEMBLY 463 +# define _PUBLICKEY 464 +# define _PUBLICKEYTOKEN 465 +# define ALGORITHM_ 466 +# define _VER 467 +# define _LOCALE 468 +# define EXTERN_ 469 +# define _MRESOURCE 470 +# define _MODULE 471 +# define _EXPORT 472 +# define LEGACY_ 473 +# define LIBRARY_ 474 +# define X86_ 475 +# define AMD64_ 476 +# define ARM_ 477 +# define ARM64_ 478 +# define MARSHAL_ 479 +# define CUSTOM_ 480 +# define SYSSTRING_ 481 +# define FIXED_ 482 +# define VARIANT_ 483 +# define CURRENCY_ 484 +# define SYSCHAR_ 485 +# define DECIMAL_ 486 +# define DATE_ 487 +# define BSTR_ 488 +# define TBSTR_ 489 +# define LPSTR_ 490 +# define LPWSTR_ 491 +# define LPTSTR_ 492 +# define OBJECTREF_ 493 +# define IUNKNOWN_ 494 +# define IDISPATCH_ 495 +# define STRUCT_ 496 +# define SAFEARRAY_ 497 +# define BYVALSTR_ 498 +# define LPVOID_ 499 +# define ANY_ 500 +# define ARRAY_ 501 +# define LPSTRUCT_ 502 +# define IIDPARAM_ 503 +# define IN_ 504 +# define OUT_ 505 +# define OPT_ 506 +# define _PARAM 507 +# define _OVERRIDE 508 +# define WITH_ 509 +# define NULL_ 510 +# define HRESULT_ 511 +# define CARRAY_ 512 +# define USERDEFINED_ 513 +# define RECORD_ 514 +# define FILETIME_ 515 +# define BLOB_ 516 +# define STREAM_ 517 +# define STORAGE_ 518 +# define STREAMED_OBJECT_ 519 +# define STORED_OBJECT_ 520 +# define BLOB_OBJECT_ 521 +# define CF_ 522 +# define CLSID_ 523 +# define VECTOR_ 524 +# define _SUBSYSTEM 525 +# define _CORFLAGS 526 +# define ALIGNMENT_ 527 +# define _IMAGEBASE 528 +# define _STACKRESERVE 529 +# define _TYPEDEF 530 +# define _TEMPLATE 531 +# define _TYPELIST 532 +# define _MSCORLIB 533 +# define P_DEFINE 534 +# define P_UNDEF 535 +# define P_IFDEF 536 +# define P_IFNDEF 537 +# define P_ELSE 538 +# define P_ENDIF 539 +# define P_INCLUDE 540 +# define CONSTRAINT_ 541 #define yyclearin yychar = -1 #define yyerrok yyerrflag = 0 #ifndef YYMAXDEPTH @@ -1746,7 +1746,7 @@ YYSTATIC YYCONST short yyrecover[] = { #line 3 "F:\\NetFXDev1\\src\\tools\\devdiv\\amd64\\yypars.c" #if ! defined(YYAPI_PACKAGE) /* -** YYAPI_TOKENNAME : name used for return value of yylex +** YYAPI_TOKENNAME : name used for return value of yylex ** YYAPI_TOKENTYPE : type of the token ** YYAPI_TOKENEME(t) : the value of the token that the parser should see ** YYAPI_TOKENNONE : the representation when there is no token @@ -1758,7 +1758,7 @@ YYSTATIC YYCONST short yyrecover[] = { #define YYAPI_TOKENTYPE int #define YYAPI_TOKENEME(t) (t) #define YYAPI_TOKENNONE -1 -#define YYAPI_TOKENSTR(t) (sprintf_s(yytokbuf, _countof(yytokbuf), "%d", t), yytokbuf) +#define YYAPI_TOKENSTR(t) (sprintf_s(yytokbuf, ARRAY_SIZE(yytokbuf), "%d", t), yytokbuf) #define YYAPI_VALUENAME yylval #define YYAPI_VALUETYPE YYSTYPE #define YYAPI_VALUEOF(v) (v) @@ -2080,7 +2080,7 @@ YYLOCAL YYNEAR YYPASCAL YYPARSER() yydumpinfo(); #endif switch(yym){ - + case 3: #line 194 "asmparse.y" { PASM->EndClass(); } break; diff --git a/src/coreclr/ildasm/dasm.cpp b/src/coreclr/ildasm/dasm.cpp index 0f7de27fa21da..89db1b510160b 100644 --- a/src/coreclr/ildasm/dasm.cpp +++ b/src/coreclr/ildasm/dasm.cpp @@ -5149,7 +5149,7 @@ void DumpCodeManager(IMAGE_COR20_HEADER *CORHeader, void* GUICookie) WCHAR rcguid[128]; GUID Guid = *pcm; SwapGuid(&Guid); - StringFromGUID2(Guid, rcguid, NumItems(rcguid)); + StringFromGUID2(Guid, rcguid, ARRAY_SIZE(rcguid)); sprintf_s(szString,SZSTRING_SIZE,"// [0x%08x] %S", i, rcguid); printLine(GUICookie,szStr); pcm++; diff --git a/src/coreclr/ildasm/dis.cpp b/src/coreclr/ildasm/dis.cpp index 8ca544ebd1057..3d1286c80dce4 100644 --- a/src/coreclr/ildasm/dis.cpp +++ b/src/coreclr/ildasm/dis.cpp @@ -458,7 +458,7 @@ void dumpOneEHInfo(DasmExceptionInfoClause* ehInfo, IMDInternalImport *pImport, /* if(ehInfo->GetFlags() & ERR_OUT_OF_CODE) { - _snprintf_s(szString, _countof(szString), _TRUNCATE, "%s// WARNING: Boundary outside the method code",g_szAsmCodeIndent); + _snprintf_s(szString, ARRAY_SIZE(szString), _TRUNCATE, "%s// WARNING: Boundary outside the method code",g_szAsmCodeIndent); printLine(GUICookie,szString); } */ @@ -846,7 +846,7 @@ BOOL SourceLinesHelper(void *GUICookie, LineCodeDescr* pLCD, __out_ecount(nSize) /* BOOL fHasEmbeddedSource=FALSE; ((ISymUnmanagedDocument*)(pParam->pLCD->FileToken))->HasEmbeddedSource(&fHasEmbeddedSource); - _snprintf_s(szString, _countof(szString), _TRUNCATE, "%s// PDB has %sembedded source",g_szAsmCodeIndent, + _snprintf_s(szString, ARRAY_SIZE(szString), _TRUNCATE, "%s// PDB has %sembedded source",g_szAsmCodeIndent, fHasEmbeddedSource ? "" : "no "); printLine(pParam->GUICookie,szString); */ @@ -1614,7 +1614,7 @@ BOOL Disassemble(IMDInternalImport *pImport, BYTE *ILHeader, void *GUICookie, md else szptr+=sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr), "%-10s (%2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X %2.2X)", - pszInstrName, + pszInstrName, pCode[PC], pCode[PC+1], pCode[PC+2], pCode[PC+3], pCode[PC+4], pCode[PC+5], pCode[PC+6], pCode[PC+7]); PC += 8; diff --git a/src/coreclr/ildasm/dres.cpp b/src/coreclr/ildasm/dres.cpp index c7043fb45869c..53e1ad234b63a 100644 --- a/src/coreclr/ildasm/dres.cpp +++ b/src/coreclr/ildasm/dres.cpp @@ -279,11 +279,11 @@ DWORD DumpResourceToFile(__in __nullterminated WCHAR* wzFileName) void* GUICookie = (void*)wzFileName; BYTE* pbData; printLine(GUICookie,""); - sprintf_s(szString, _countof(szString), "// ========== Win32 Resource Entries (%d) ========",ulNumResNodes); + sprintf_s(szString, ARRAY_SIZE(szString), "// ========== Win32 Resource Entries (%d) ========",ulNumResNodes); for(i=0; i < ulNumResNodes; i++) { printLine(GUICookie,""); - sprintf_s(szString, _countof(szString), "// Res.# %d Type=0x%X Name=0x%X Lang=0x%X DataOffset=0x%X DataLength=%d", + sprintf_s(szString, ARRAY_SIZE(szString), "// Res.# %d Type=0x%X Name=0x%X Lang=0x%X DataOffset=0x%X DataLength=%d", i+1, g_prResNodePtr[i]->ResHdr.dwTypeID, g_prResNodePtr[i]->ResHdr.dwNameID, diff --git a/src/coreclr/inc/bbsweep.h b/src/coreclr/inc/bbsweep.h index decf21fa72dbd..eda1e11d2f2e1 100644 --- a/src/coreclr/inc/bbsweep.h +++ b/src/coreclr/inc/bbsweep.h @@ -22,10 +22,6 @@ #include #endif // !TARGET_UNIX -#ifndef ARRAYSIZE -#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) -#endif // !ARRAYSIZE - // The CLR headers don't allow us to use methods like SetEvent directly (instead // we need to use the host APIs). However, this file is included both in the CLR // and in the BBSweep tool, and the host API is not available in the tool. Moreover, @@ -284,7 +280,7 @@ class BBSweep GetObjectNamePrefix(processID, fromRuntime, objectNamePrefix); // if there is a non-empty name prefix, append a '\' if (objectNamePrefix[0] != '\0') - wcscat_s(objectNamePrefix, ARRAYSIZE(objectNamePrefix), W("\\")); + wcscat_s(objectNamePrefix, ARRAY_SIZE(objectNamePrefix), W("\\")); swprintf_s(objectName, MAX_LONGPATH, W("%sBBSweep_hSweepMutex"), objectNamePrefix); hSweepMutex = ::WszCreateMutex(pSecurityAttributes, false, objectName); swprintf_s(objectName, MAX_LONGPATH, W("%sBBSweep_hProfDataWriterMutex"), objectNamePrefix); diff --git a/src/coreclr/inc/clrconfignocache.h b/src/coreclr/inc/clrconfignocache.h index 46bc2182686b2..ef969b00d4639 100644 --- a/src/coreclr/inc/clrconfignocache.h +++ b/src/coreclr/inc/clrconfignocache.h @@ -7,18 +7,16 @@ // Logic for resolving configuration names. // -#ifndef StrLen -#define StrLen(STR) ((sizeof(STR) / sizeof(STR[0])) - 1) -#endif // !StrLen +#include // Config prefixes #define COMPLUS_PREFIX_A "COMPlus_" #define COMPLUS_PREFIX W("COMPlus_") -#define LEN_OF_COMPLUS_PREFIX StrLen(COMPLUS_PREFIX_A) +#define LEN_OF_COMPLUS_PREFIX STRING_LENGTH(COMPLUS_PREFIX_A) #define DOTNET_PREFIX_A "DOTNET_" #define DOTNET_PREFIX W("DOTNET_") -#define LEN_OF_DOTNET_PREFIX StrLen(DOTNET_PREFIX_A) +#define LEN_OF_DOTNET_PREFIX STRING_LENGTH(DOTNET_PREFIX_A) class CLRConfigNoCache { @@ -56,7 +54,7 @@ class CLRConfigNoCache if (noPrefix) { - if (namelen >= _countof(nameBuffer)) + if (namelen >= ARRAY_SIZE(nameBuffer)) { _ASSERTE(!"Environment variable name too long."); return {}; @@ -66,8 +64,8 @@ class CLRConfigNoCache } else { - bool dotnetValid = namelen < (size_t)(_countof(nameBuffer) - 1 - LEN_OF_DOTNET_PREFIX); - bool complusValid = namelen < (size_t)(_countof(nameBuffer) - 1 - LEN_OF_COMPLUS_PREFIX); + bool dotnetValid = namelen < (size_t)(STRING_LENGTH(nameBuffer) - LEN_OF_DOTNET_PREFIX); + bool complusValid = namelen < (size_t)(STRING_LENGTH(nameBuffer) - LEN_OF_COMPLUS_PREFIX); if (!dotnetValid || !complusValid) { _ASSERTE(!"Environment variable name too long."); @@ -75,17 +73,17 @@ class CLRConfigNoCache } // Priority order is DOTNET_ and then COMPlus_. - strcpy_s(nameBuffer, _countof(nameBuffer), DOTNET_PREFIX_A); + strcpy_s(nameBuffer, ARRAY_SIZE(nameBuffer), DOTNET_PREFIX_A); fallbackPrefix = COMPLUS_PREFIX_A; } - strcat_s(nameBuffer, _countof(nameBuffer), cfg); + strcat_s(nameBuffer, ARRAY_SIZE(nameBuffer), cfg); LPCSTR val = getEnvFptr != NULL ? getEnvFptr(nameBuffer) : getenv(nameBuffer); if (val == NULL && fallbackPrefix != NULL) { - strcpy_s(nameBuffer, _countof(nameBuffer), fallbackPrefix); - strcat_s(nameBuffer, _countof(nameBuffer), cfg); + strcpy_s(nameBuffer, ARRAY_SIZE(nameBuffer), fallbackPrefix); + strcat_s(nameBuffer, ARRAY_SIZE(nameBuffer), cfg); val = getEnvFptr != NULL ? getEnvFptr(nameBuffer) : getenv(nameBuffer); } diff --git a/src/coreclr/inc/contract.inl b/src/coreclr/inc/contract.inl index 589cafdebcdaa..53430963754a7 100644 --- a/src/coreclr/inc/contract.inl +++ b/src/coreclr/inc/contract.inl @@ -15,10 +15,6 @@ #include "contract.h" #include -#ifndef _countof -#define _countof(x) (sizeof(x)/sizeof(x[0])) -#endif - #ifdef ENABLE_CONTRACTS_IMPL inline void BaseContract::DoChecks(UINT testmask, __in_z const char *szFunction, __in_z const char *szFile, int lineNum) @@ -341,8 +337,8 @@ inline void DbgStateLockData::LockTaken(DbgStateLockType dbgStateLockType, // Are we exceeding the threshold for what we can store in m_rgTakenLockInfos? // If so, assert a warning, but we'll deal with it. - if ((cCombinedLocks <= _countof(m_rgTakenLockInfos)) && - (cCombinedLocks + cTakes > _countof(m_rgTakenLockInfos))) + if ((cCombinedLocks <= ARRAY_SIZE(m_rgTakenLockInfos)) && + (cCombinedLocks + cTakes > ARRAY_SIZE(m_rgTakenLockInfos))) { // Actually, for now we are NOT asserting until I can dedicate more time // to this. Some class loader code paths legally hold many simultaneous @@ -356,7 +352,7 @@ inline void DbgStateLockData::LockTaken(DbgStateLockType dbgStateLockType, // Remember as many of these new entrances in m_rgTakenLockInfos as we can for (UINT i = cCombinedLocks; - i < min (_countof(m_rgTakenLockInfos), cCombinedLocks + cTakes); + i < min (ARRAY_SIZE(m_rgTakenLockInfos), cCombinedLocks + cTakes); i++) { m_rgTakenLockInfos[i].m_pvLock = pvLock; @@ -381,7 +377,7 @@ inline void DbgStateLockData::LockReleased(DbgStateLockType dbgStateLockType, UI // If lock count is within range of our m_rgTakenLockInfos buffer size, then // make sure we're releasing locks in reverse order of how we took them for (UINT i = cCombinedLocks - cReleases; - i < min (_countof(m_rgTakenLockInfos), cCombinedLocks); + i < min (ARRAY_SIZE(m_rgTakenLockInfos), cCombinedLocks); i++) { if (m_rgTakenLockInfos[i].m_pvLock != pvLock) @@ -447,7 +443,7 @@ inline BOOL DbgStateLockState::IsLockRetaken(void * pvLock) // m_cLocksEnteringCannotRetakeLock records the number of locks that were taken // when CANNOT_RETAKE_LOCK contract was constructed. for (UINT i = 0; - i < min(_countof(m_pLockData->m_rgTakenLockInfos), m_cLocksEnteringCannotRetakeLock); + i < min(ARRAY_SIZE(m_pLockData->m_rgTakenLockInfos), m_cLocksEnteringCannotRetakeLock); ++i) { if (m_pLockData->m_rgTakenLockInfos[i].m_pvLock == pvLock) @@ -497,7 +493,7 @@ void CONTRACT_ASSERT(const char *szElaboration, { char Buf[512*20 + 2048 + 1024]; - sprintf_s(Buf,_countof(Buf), "CONTRACT VIOLATION by %s at \"%s\" @ %d\n\n%s\n", szFunction, szFile, lineNum, szElaboration); + sprintf_s(Buf,ARRAY_SIZE(Buf), "CONTRACT VIOLATION by %s at \"%s\" @ %d\n\n%s\n", szFunction, szFile, lineNum, szElaboration); int count = 20; ContractStackRecord *pRec = CheckClrDebugState() ? CheckClrDebugState()->GetContractStackTrace() : NULL; @@ -529,11 +525,11 @@ void CONTRACT_ASSERT(const char *szElaboration, else { // Show that some lines have been skipped - strcat_s(Buf, _countof(Buf), "\n ..."); + strcat_s(Buf, ARRAY_SIZE(Buf), "\n ..."); } - sprintf_s(tmpbuf,_countof(tmpbuf), + sprintf_s(tmpbuf,ARRAY_SIZE(tmpbuf), "\n%s %s in %s at \"%s\" @ %d", fshowconflict ? "VIOLATED-->" : " ", pRec->m_construct, @@ -542,7 +538,7 @@ void CONTRACT_ASSERT(const char *szElaboration, pRec->m_lineNum ); - strcat_s(Buf, _countof(Buf), tmpbuf); + strcat_s(Buf, ARRAY_SIZE(Buf), tmpbuf); } pRec = pRec->m_pNext; @@ -560,12 +556,12 @@ void CONTRACT_ASSERT(const char *szElaboration, if (count == 0) { - strcat_s(Buf,_countof(Buf), "\n ..."); + strcat_s(Buf,ARRAY_SIZE(Buf), "\n ..."); } if (exceptionBuildingStack) { - strcat_s(Buf,_countof(Buf), + strcat_s(Buf,ARRAY_SIZE(Buf), "\n" "\nError forming contract stack. Any contract stack displayed above is correct," "\nbut it's most probably truncated. This is probably due to a CONTRACT in a" @@ -579,17 +575,17 @@ void CONTRACT_ASSERT(const char *szElaboration, ); } - strcat_s(Buf,_countof(Buf), "\n\n"); + strcat_s(Buf,ARRAY_SIZE(Buf), "\n\n"); if (!foundconflict && count != 0) { if (whichTest == BaseContract::THROWS_No) { - strcat_s(Buf,_countof(Buf), "You can't throw here because there is no handler on the stack.\n"); + strcat_s(Buf,ARRAY_SIZE(Buf), "You can't throw here because there is no handler on the stack.\n"); } else { - strcat_s(Buf,_countof(Buf), "We can't find the violated contract. Look for an old-style non-holder-based contract.\n"); + strcat_s(Buf,ARRAY_SIZE(Buf), "We can't find the violated contract. Look for an old-style non-holder-based contract.\n"); } } diff --git a/src/coreclr/inc/corpriv.h b/src/coreclr/inc/corpriv.h index 25102cefdd1cb..d500b187493cd 100644 --- a/src/coreclr/inc/corpriv.h +++ b/src/coreclr/inc/corpriv.h @@ -283,9 +283,6 @@ typedef enum CorOpenFlagsInternal #endif // %%Classes: ---------------------------------------------------------------- -#ifndef lengthof -#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) -#endif #define COR_MODULE_CLASS "" #define COR_WMODULE_CLASS W("") diff --git a/src/coreclr/inc/metamodelpub.h b/src/coreclr/inc/metamodelpub.h index 37e77e9123b10..b1eb8b961dbc5 100644 --- a/src/coreclr/inc/metamodelpub.h +++ b/src/coreclr/inc/metamodelpub.h @@ -17,11 +17,6 @@ #include #include "contract.h" - -#ifndef lengthof -# define lengthof(x) (sizeof(x)/sizeof((x)[0])) -#endif - template inline T Align4(T p) { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/inc/sigparser.h b/src/coreclr/inc/sigparser.h index 9152727aee458..1e861c4cd3edf 100644 --- a/src/coreclr/inc/sigparser.h +++ b/src/coreclr/inc/sigparser.h @@ -13,6 +13,7 @@ #include "corhdr.h" #include "corinfo.h" #include "corpriv.h" +#include //--------------------------------------------------------------------------------------- // These macros define how arguments are mapped to the stack in the managed calling convention. @@ -27,7 +28,6 @@ #define STACK_GROWS_UP_ON_ARGS_WALK #endif - //------------------------------------------------------------------------ // Encapsulates how compressed integers and typeref tokens are encoded into // a bytestream. @@ -793,7 +793,7 @@ class CorTypeInfo } CONTRACTL_END; - if (type >= (CorElementType)_countof(info)) + if (type >= (CorElementType)ARRAY_SIZE(info)) { ThrowHR(COR_E_BADIMAGEFORMAT); } @@ -803,7 +803,7 @@ class CorTypeInfo { LIMITED_METHOD_DAC_CONTRACT; - if (type >= (CorElementType)_countof(info)) + if (type >= (CorElementType)ARRAY_SIZE(info)) { return info[ELEMENT_TYPE_END]; } @@ -830,7 +830,7 @@ class CorTypeInfo { LIMITED_METHOD_CONTRACT; - for (int i = 0; i < (int)_countof(info); i++) + for (int i = 0; i < (int)ARRAY_SIZE(info); i++) { _ASSERTE(info[i].type == i); } diff --git a/src/coreclr/inc/stdmacros.h b/src/coreclr/inc/stdmacros.h index f2417c7637545..2d0a0576172aa 100644 --- a/src/coreclr/inc/stdmacros.h +++ b/src/coreclr/inc/stdmacros.h @@ -331,12 +331,6 @@ inline ULONG RoundUpToPower2(ULONG x) #define UNIQUE_LABEL(a) UNIQUE_LABEL_DEF_X(_unique_label_##a##_, __LINE__) #endif - -#ifndef _countof -#define _countof(_array) (sizeof(_array)/sizeof(_array[0])) -#endif - - // This is temporary. LKG should provide these macros and we should then // remove STRUNCATE and _TRUNCATE from here. diff --git a/src/coreclr/inc/utilcode.h b/src/coreclr/inc/utilcode.h index 77df9dfa94d2a..bae570f3f43ce 100644 --- a/src/coreclr/inc/utilcode.h +++ b/src/coreclr/inc/utilcode.h @@ -39,6 +39,8 @@ #include "contract.h" #include "entrypoints.h" +#include + #include "clrnt.h" #include "random.h" @@ -150,17 +152,7 @@ typedef LPSTR LPUTF8; #endif #include // for offsetof - -#ifndef NumItems -// Number of elements in a fixed-size array -#define NumItems(s) (sizeof(s) / sizeof(s[0])) -#endif - -#ifndef StrLen -// Number of characters in a string literal. Excludes terminating NULL. -#define StrLen(str) (NumItems(str) - 1) -#endif - +#include #define IS_DIGIT(ch) (((ch) >= W('0')) && ((ch) <= W('9'))) #define DIGIT_TO_INT(ch) ((ch) - W('0')) @@ -647,8 +639,8 @@ class CCulturedHInstance { if (id != UICULTUREID_DONTCARE) { - wcsncpy_s(m_LangId, NumItems(m_LangId), id, NumItems(m_LangId)); - m_LangId[NumItems(m_LangId)-1] = W('\0'); + wcsncpy_s(m_LangId, ARRAY_SIZE(m_LangId), id, ARRAY_SIZE(m_LangId)); + m_LangId[STRING_LENGTH(m_LangId)] = W('\0'); } else { diff --git a/src/coreclr/interop/comwrappers.cpp b/src/coreclr/interop/comwrappers.cpp index aad3d6fa23591..f07786e580c0c 100644 --- a/src/coreclr/interop/comwrappers.cpp +++ b/src/coreclr/interop/comwrappers.cpp @@ -4,6 +4,7 @@ #include "comwrappers.hpp" #include #include +#include #ifdef _WIN32 #include // placement new @@ -398,8 +399,8 @@ HRESULT ManagedObjectWrapper::Create( curr.IID = IID_IReferenceTrackerTarget; curr.Vtable = &ManagedObjectWrapper_IReferenceTrackerTargetImpl; } - - _ASSERTE(runtimeDefinedCount <= (int) ARRAYSIZE(runtimeDefinedLocal)); + + _ASSERTE(runtimeDefinedCount <= (int) ARRAY_SIZE(runtimeDefinedLocal)); // Compute size for ManagedObjectWrapper instance. const size_t totalRuntimeDefinedSize = runtimeDefinedCount * sizeof(ABI::ComInterfaceEntry); @@ -438,7 +439,7 @@ HRESULT ManagedObjectWrapper::Create( { userDefined, userDefinedCount } }; - ABI::ComInterfaceDispatch* dispSection = ABI::PopulateDispatchSection(wrapperMem, dispatchSectionOffset, ARRAYSIZE(AllEntries), AllEntries); + ABI::ComInterfaceDispatch* dispSection = ABI::PopulateDispatchSection(wrapperMem, dispatchSectionOffset, ARRAY_SIZE(AllEntries), AllEntries); ManagedObjectWrapper* wrapper = new (wrapperMem) ManagedObjectWrapper { diff --git a/src/coreclr/interop/platform.h b/src/coreclr/interop/platform.h index 351b5ebf6ec48..64bfd76d352a6 100644 --- a/src/coreclr/interop/platform.h +++ b/src/coreclr/interop/platform.h @@ -16,10 +16,6 @@ #include #endif // _WIN32 -#ifndef ARRAYSIZE -#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) -#endif // !ARRAYSIZE - #if defined(_WIN32) || defined(HOST_UNIX) #include // COM interfaces diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index 93674f21edd6a..1ae2176674a7d 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -908,7 +908,7 @@ void Compiler::optAssertionInit(bool isLocalProp) // Note this tracks at most only 256 assertions. static const AssertionIndex countFunc[] = {64, 128, 256, 64}; static const unsigned lowerBound = 0; - static const unsigned upperBound = _countof(countFunc) - 1; + static const unsigned upperBound = ArrLen(countFunc) - 1; const unsigned codeSize = info.compILCodeSize / 512; optMaxAssertionCount = countFunc[isLocalProp ? lowerBound : min(upperBound, codeSize)]; diff --git a/src/coreclr/jit/block.cpp b/src/coreclr/jit/block.cpp index 62add7f24dd3f..e1ca9ac6e7f41 100644 --- a/src/coreclr/jit/block.cpp +++ b/src/coreclr/jit/block.cpp @@ -720,8 +720,8 @@ const char* BasicBlock::dspToString(int blockNumPadding /* = 0 */) static int nextBufferIndex = 0; auto& buffer = buffers[nextBufferIndex]; - nextBufferIndex = (nextBufferIndex + 1) % _countof(buffers); - _snprintf_s(buffer, _countof(buffer), _countof(buffer), FMT_BB "%*s [%04u]", bbNum, blockNumPadding, "", bbID); + nextBufferIndex = (nextBufferIndex + 1) % ArrLen(buffers); + _snprintf_s(buffer, ArrLen(buffer), ArrLen(buffer), FMT_BB "%*s [%04u]", bbNum, blockNumPadding, "", bbID); return buffer; } diff --git a/src/coreclr/jit/codegen.h b/src/coreclr/jit/codegen.h index bc5ea98f80ad0..6161feb05ef33 100644 --- a/src/coreclr/jit/codegen.h +++ b/src/coreclr/jit/codegen.h @@ -1475,7 +1475,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX static const GenConditionDesc& Get(GenCondition condition) { - assert(condition.GetCode() < _countof(map)); + assert(condition.GetCode() < ArrLen(map)); const GenConditionDesc& desc = map[condition.GetCode()]; assert(desc.jumpKind1 != EJ_NONE); assert((desc.oper == GT_NONE) || (desc.oper == GT_AND) || (desc.oper == GT_OR)); diff --git a/src/coreclr/jit/codegenarmarch.cpp b/src/coreclr/jit/codegenarmarch.cpp index 940d715c15b8c..22379e3c9dbed 100644 --- a/src/coreclr/jit/codegenarmarch.cpp +++ b/src/coreclr/jit/codegenarmarch.cpp @@ -549,7 +549,7 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode) { #ifdef DEBUG char message[256]; - _snprintf_s(message, _countof(message), _TRUNCATE, "NYI: Unimplemented node type %s", + _snprintf_s(message, ArrLen(message), _TRUNCATE, "NYI: Unimplemented node type %s", GenTree::OpName(treeNode->OperGet())); NYIRAW(message); #else diff --git a/src/coreclr/jit/codegenxarch.cpp b/src/coreclr/jit/codegenxarch.cpp index 8d2156ae2a386..7b50388ad3138 100644 --- a/src/coreclr/jit/codegenxarch.cpp +++ b/src/coreclr/jit/codegenxarch.cpp @@ -1852,7 +1852,7 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode) { #ifdef DEBUG char message[256]; - _snprintf_s(message, _countof(message), _TRUNCATE, "NYI: Unimplemented node type %s\n", + _snprintf_s(message, ArrLen(message), _TRUNCATE, "NYI: Unimplemented node type %s\n", GenTree::OpName(treeNode->OperGet())); NYIRAW(message); #endif diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 572970f63d06e..b88ea47970d37 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -7790,9 +7790,9 @@ CompTimeInfo::CompTimeInfo(unsigned byteCodeBytes) } #if MEASURE_CLRAPI_CALLS - assert(ARRAYSIZE(m_perClrAPIcalls) == API_ICorJitInfo_Names::API_COUNT); - assert(ARRAYSIZE(m_perClrAPIcycles) == API_ICorJitInfo_Names::API_COUNT); - assert(ARRAYSIZE(m_maxClrAPIcycles) == API_ICorJitInfo_Names::API_COUNT); + assert(ArrLen(m_perClrAPIcalls) == API_ICorJitInfo_Names::API_COUNT); + assert(ArrLen(m_perClrAPIcycles) == API_ICorJitInfo_Names::API_COUNT); + assert(ArrLen(m_maxClrAPIcycles) == API_ICorJitInfo_Names::API_COUNT); for (int i = 0; i < API_ICorJitInfo_Names::API_COUNT; i++) { m_perClrAPIcalls[i] = 0; @@ -7968,7 +7968,7 @@ void CompTimeSummaryInfo::Print(FILE* f) extraHdr2); // Ensure that at least the names array and the Phases enum have the same number of entries: - assert(_countof(PhaseNames) == PHASE_NUMBER_OF); + assert(ArrLen(PhaseNames) == PHASE_NUMBER_OF); for (int i = 0; i < PHASE_NUMBER_OF; i++) { double phase_tot_ms = (((double)m_total.m_cyclesByPhase[i]) / countsPerSec) * 1000.0; @@ -8031,7 +8031,7 @@ void CompTimeSummaryInfo::Print(FILE* f) fprintf(f, " PHASE inv/meth Mcycles time (ms) %% of total\n"); fprintf(f, " --------------------------------------------------------------------------------------\n"); // Ensure that at least the names array and the Phases enum have the same number of entries: - assert(_countof(PhaseNames) == PHASE_NUMBER_OF); + assert(ArrLen(PhaseNames) == PHASE_NUMBER_OF); for (int i = 0; i < PHASE_NUMBER_OF; i++) { double phase_tot_ms = (((double)m_filtered.m_cyclesByPhase[i]) / countsPerSec) * 1000.0; diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index d006b1633eccf..14389d8f81745 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -543,7 +543,7 @@ extern const BYTE genTypeSizes[TYP_COUNT]; template inline unsigned genTypeSize(T value) { - assert((unsigned)TypeGet(value) < _countof(genTypeSizes)); + assert((unsigned)TypeGet(value) < ArrLen(genTypeSizes)); return genTypeSizes[TypeGet(value)]; } @@ -559,7 +559,7 @@ extern const BYTE genTypeStSzs[TYP_COUNT]; template inline unsigned genTypeStSz(T value) { - assert((unsigned)TypeGet(value) < _countof(genTypeStSzs)); + assert((unsigned)TypeGet(value) < ArrLen(genTypeStSzs)); return genTypeStSzs[TypeGet(value)]; } diff --git a/src/coreclr/jit/disasm.cpp b/src/coreclr/jit/disasm.cpp index 9a91b457107d7..d92013ed80dd2 100644 --- a/src/coreclr/jit/disasm.cpp +++ b/src/coreclr/jit/disasm.cpp @@ -1102,7 +1102,7 @@ size_t DisAssembler::CbDisassemble(DIS* pdis, } wchar_t wz[MAX_CLASSNAME_LENGTH]; - pdis->CchFormatInstr(wz, _countof(wz)); + pdis->CchFormatInstr(wz, ArrLen(wz)); if (printit) { @@ -1133,7 +1133,7 @@ size_t DisAssembler::CbDisassemble(DIS* pdis, wchar_t wzBytes[MAX_CLASSNAME_LENGTH]; assert(cchBytesMax < MAX_CLASSNAME_LENGTH); - size_t cchBytes = pdis->CchFormatBytes(wzBytes, _countof(wzBytes)); + size_t cchBytes = pdis->CchFormatBytes(wzBytes, ArrLen(wzBytes)); if (cchBytes > CCH_INDENT) { @@ -1168,7 +1168,7 @@ size_t CbDisassembleWithBytes(DIS* pdis, DIS::ADDR addr, const BYTE* pb, size_t wchar_t wz[MAX_CLASSNAME_LENGTH]; - pdis->CchFormatAddr(addr, wz, _countof(wz)); + pdis->CchFormatAddr(addr, wz, ArrLen(wz)); size_t cchIndent = (size_t)fprintf(pfile, " %ls: ", wz); @@ -1190,7 +1190,7 @@ size_t CbDisassembleWithBytes(DIS* pdis, DIS::ADDR addr, const BYTE* pb, size_t } wchar_t wzBytes[64]; - size_t cchBytes = pdis->CchFormatBytes(wzBytes, _countof(wzBytes)); + size_t cchBytes = pdis->CchFormatBytes(wzBytes, ArrLen(wzBytes)); wchar_t* pwzBytes; wchar_t* pwzNext; @@ -1228,7 +1228,7 @@ size_t CbDisassembleWithBytes(DIS* pdis, DIS::ADDR addr, const BYTE* pb, size_t if (fFirst) { - pdis->CchFormatInstr(wz, _countof(wz)); + pdis->CchFormatInstr(wz, ArrLen(wz)); fprintf(pfile, "%-*ls %ls\n", cchBytesMax, pwzBytes, wz); } diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index e47d365a7f79e..e04ce885e2279 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -115,7 +115,7 @@ const char* emitter::emitIfName(unsigned f) static char errBuff[32]; - if (f < _countof(ifNames)) + if (f < ArrLen(ifNames)) { return ifNames[f]; } @@ -3356,7 +3356,7 @@ const BYTE emitter::emitFmtToOps[] = { }; #ifdef DEBUG -const unsigned emitter::emitFmtCount = _countof(emitFmtToOps); +const unsigned emitter::emitFmtCount = ArrLen(emitFmtToOps); #endif //------------------------------------------------------------------------ @@ -7352,7 +7352,7 @@ void emitter::emitDispDataSec(dataSecDsc* section) { const char* labelFormat = "%-7s"; char label[64]; - sprintf_s(label, _countof(label), "RWD%02u", offset); + sprintf_s(label, ArrLen(label), "RWD%02u", offset); printf(labelFormat, label); offset += data->dsSize; diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index ba5c0a6c638a7..4dd0d44a85638 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -1386,7 +1386,7 @@ const BYTE emitter::emitInsModeFmtTab[] = // clang-format on #ifdef DEBUG -unsigned const emitter::emitInsModeFmtCnt = _countof(emitInsModeFmtTab); +unsigned const emitter::emitInsModeFmtCnt = ArrLen(emitInsModeFmtTab); #endif /***************************************************************************** @@ -1480,7 +1480,7 @@ inline size_t insCode(instruction ins) }; // clang-format on - assert((unsigned)ins < _countof(insCodes)); + assert((unsigned)ins < ArrLen(insCodes)); assert((insCodes[ins] != BAD_CODE)); return insCodes[ins]; @@ -1513,7 +1513,7 @@ inline size_t insCodeACC(instruction ins) }; // clang-format on - assert((unsigned)ins < _countof(insCodesACC)); + assert((unsigned)ins < ArrLen(insCodesACC)); assert((insCodesACC[ins] != BAD_CODE)); return insCodesACC[ins]; @@ -1546,7 +1546,7 @@ inline size_t insCodeRR(instruction ins) }; // clang-format on - assert((unsigned)ins < _countof(insCodesRR)); + assert((unsigned)ins < ArrLen(insCodesRR)); assert((insCodesRR[ins] != BAD_CODE)); return insCodesRR[ins]; @@ -1575,7 +1575,7 @@ size_t insCodesRM[] = // Returns true iff the give CPU instruction has an RM encoding. inline bool hasCodeRM(instruction ins) { - assert((unsigned)ins < _countof(insCodesRM)); + assert((unsigned)ins < ArrLen(insCodesRM)); return ((insCodesRM[ins] != BAD_CODE)); } @@ -1586,7 +1586,7 @@ inline bool hasCodeRM(instruction ins) inline size_t insCodeRM(instruction ins) { - assert((unsigned)ins < _countof(insCodesRM)); + assert((unsigned)ins < ArrLen(insCodesRM)); assert((insCodesRM[ins] != BAD_CODE)); return insCodesRM[ins]; @@ -1615,7 +1615,7 @@ size_t insCodesMI[] = // Returns true iff the give CPU instruction has an MI encoding. inline bool hasCodeMI(instruction ins) { - assert((unsigned)ins < _countof(insCodesMI)); + assert((unsigned)ins < ArrLen(insCodesMI)); return ((insCodesMI[ins] != BAD_CODE)); } @@ -1626,7 +1626,7 @@ inline bool hasCodeMI(instruction ins) inline size_t insCodeMI(instruction ins) { - assert((unsigned)ins < _countof(insCodesMI)); + assert((unsigned)ins < ArrLen(insCodesMI)); assert((insCodesMI[ins] != BAD_CODE)); return insCodesMI[ins]; @@ -1655,7 +1655,7 @@ size_t insCodesMR[] = // Returns true iff the give CPU instruction has an MR encoding. inline bool hasCodeMR(instruction ins) { - assert((unsigned)ins < _countof(insCodesMR)); + assert((unsigned)ins < ArrLen(insCodesMR)); return ((insCodesMR[ins] != BAD_CODE)); } @@ -1666,7 +1666,7 @@ inline bool hasCodeMR(instruction ins) inline size_t insCodeMR(instruction ins) { - assert((unsigned)ins < _countof(insCodesMR)); + assert((unsigned)ins < ArrLen(insCodesMR)); assert((insCodesMR[ins] != BAD_CODE)); return insCodesMR[ins]; @@ -8210,7 +8210,7 @@ const char* emitter::emitXMMregName(unsigned reg) }; assert(reg < REG_COUNT); - assert(reg < _countof(regNames)); + assert(reg < ArrLen(regNames)); return regNames[reg]; } @@ -8228,7 +8228,7 @@ const char* emitter::emitYMMregName(unsigned reg) }; assert(reg < REG_COUNT); - assert(reg < _countof(regNames)); + assert(reg < ArrLen(regNames)); return regNames[reg]; } diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index fb722c3a8beb8..77a7e0593a6e1 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -170,7 +170,7 @@ static const char* opNames[] = { const char* GenTree::OpName(genTreeOps op) { - assert((unsigned)op < _countof(opNames)); + assert((unsigned)op < ArrLen(opNames)); return opNames[op]; } @@ -186,7 +186,7 @@ static const char* opStructNames[] = { const char* GenTree::OpStructName(genTreeOps op) { - assert((unsigned)op < _countof(opStructNames)); + assert((unsigned)op < ArrLen(opStructNames)); return opStructNames[op]; } @@ -10787,7 +10787,7 @@ int Compiler::gtGetLclVarName(unsigned lclNum, char* buf, unsigned buf_remaining char* Compiler::gtGetLclVarName(unsigned lclNum) { char buf[BUF_SIZE]; - int charsPrinted = gtGetLclVarName(lclNum, buf, _countof(buf)); + int charsPrinted = gtGetLclVarName(lclNum, buf, ArrLen(buf)); if (charsPrinted < 0) { return nullptr; @@ -10802,7 +10802,7 @@ char* Compiler::gtGetLclVarName(unsigned lclNum) void Compiler::gtDispLclVar(unsigned lclNum, bool padForBiggestDisp) { char buf[BUF_SIZE]; - int charsPrinted = gtGetLclVarName(lclNum, buf, _countof(buf)); + int charsPrinted = gtGetLclVarName(lclNum, buf, ArrLen(buf)); if (charsPrinted < 0) { diff --git a/src/coreclr/jit/gentree.h b/src/coreclr/jit/gentree.h index 8ca83d21bc1b4..78cd7cceb67b4 100644 --- a/src/coreclr/jit/gentree.h +++ b/src/coreclr/jit/gentree.h @@ -529,7 +529,7 @@ enum GenTreeFlags : unsigned int GTF_RELOP_JMP_USED = 0x40000000, // GT_ -- result of compare used for jump or ?: GTF_RELOP_ZTT = 0x08000000, // GT_ -- Loop test cloned for converting while-loops into do-while // with explicit "loop test" in the header block. - GTF_RELOP_SJUMP_OPT = 0x04000000, // GT_ -- Swap signed jl/jge with js/jns during emitter, reuses flags + GTF_RELOP_SJUMP_OPT = 0x04000000, // GT_ -- Swap signed jl/jge with js/jns during emitter, reuses flags // from previous instruction. GTF_JCMP_EQ = 0x80000000, // GTF_JCMP_EQ -- Branch on equal rather than not equal @@ -7436,7 +7436,7 @@ struct GenCondition }; // clang-format on - assert(m_code < _countof(names)); + assert(m_code < ArrLen(names)); return names[m_code]; } @@ -7527,7 +7527,7 @@ struct GenCondition }; // clang-format on - assert(condition.m_code < _countof(reverse)); + assert(condition.m_code < ArrLen(reverse)); return GenCondition(reverse[condition.m_code]); } @@ -7544,7 +7544,7 @@ struct GenCondition }; // clang-format on - assert(condition.m_code < _countof(swap)); + assert(condition.m_code < ArrLen(swap)); return GenCondition(swap[condition.m_code]); } }; diff --git a/src/coreclr/jit/instr.cpp b/src/coreclr/jit/instr.cpp index 2f5ae78bef693..bbf204c74caa8 100644 --- a/src/coreclr/jit/instr.cpp +++ b/src/coreclr/jit/instr.cpp @@ -72,7 +72,7 @@ const char* CodeGen::genInsName(instruction ins) }; // clang-format on - assert((unsigned)ins < _countof(insNames)); + assert((unsigned)ins < ArrLen(insNames)); assert(insNames[ins] != nullptr); return insNames[ins]; @@ -243,7 +243,7 @@ void CodeGen::instGen(instruction ins) // static inline bool CodeGenInterface::instIsFP(instruction ins) { - assert((unsigned)ins < _countof(instInfo)); + assert((unsigned)ins < ArrLen(instInfo)); #ifdef TARGET_XARCH return (instInfo[ins] & INS_FLAGS_x87Instr) != 0; diff --git a/src/coreclr/jit/jithashtable.h b/src/coreclr/jit/jithashtable.h index 5b95afbd899ca..85186dfb508e6 100644 --- a/src/coreclr/jit/jithashtable.h +++ b/src/coreclr/jit/jithashtable.h @@ -715,7 +715,7 @@ class JitHashTable // static JitPrimeInfo NextPrime(unsigned number) { - for (int i = 0; i < (int)(_countof(jitPrimeInfo)); i++) + for (int i = 0; i < (int)(ArrLen(jitPrimeInfo)); i++) { if (jitPrimeInfo[i].prime >= number) { diff --git a/src/coreclr/jit/jitstd/algorithm.h b/src/coreclr/jit/jitstd/algorithm.h index 9fa6fbb94dd54..7df9c8488d5b7 100644 --- a/src/coreclr/jit/jitstd/algorithm.h +++ b/src/coreclr/jit/jitstd/algorithm.h @@ -1,10 +1,10 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - - #pragma once +#include + namespace jitstd { @@ -148,7 +148,7 @@ void quick_sort(RandomAccessIterator first, RandomAccessIterator last, Less less RandomAccessIterator rightFirst = newLast + 1; RandomAccessIterator rightLast = last; - assert(depth < _countof(firstStack)); + assert(depth < ARRAY_SIZE(firstStack)); // Ideally, the 2 partitions should have the same size, that would guarantee // log2(n) stack space. If that's not the case then push the larger partition diff --git a/src/coreclr/jit/layout.cpp b/src/coreclr/jit/layout.cpp index 806ba894a33a5..d47d5ae894fc4 100644 --- a/src/coreclr/jit/layout.cpp +++ b/src/coreclr/jit/layout.cpp @@ -82,7 +82,7 @@ class ClassLayoutTable private: bool HasSmallCapacity() const { - return m_layoutCount <= _countof(m_layoutArray); + return m_layoutCount <= ArrLen(m_layoutArray); } ClassLayout* GetLayoutByIndex(unsigned index) const @@ -157,7 +157,7 @@ class ClassLayoutTable unsigned AddBlkLayout(Compiler* compiler, ClassLayout* layout) { - if (m_layoutCount < _countof(m_layoutArray)) + if (m_layoutCount < ArrLen(m_layoutArray)) { m_layoutArray[m_layoutCount] = layout; return m_layoutCount++; @@ -201,7 +201,7 @@ class ClassLayoutTable unsigned AddObjLayout(Compiler* compiler, ClassLayout* layout) { - if (m_layoutCount < _countof(m_layoutArray)) + if (m_layoutCount < ArrLen(m_layoutArray)) { m_layoutArray[m_layoutCount] = layout; return m_layoutCount++; @@ -220,7 +220,7 @@ class ClassLayoutTable unsigned newCapacity = m_layoutCount * 2; ClassLayout** newArray = alloc.allocate(newCapacity); - if (m_layoutCount <= _countof(m_layoutArray)) + if (m_layoutCount <= ArrLen(m_layoutArray)) { BlkLayoutIndexMap* blkLayoutMap = new (alloc) BlkLayoutIndexMap(alloc); ObjLayoutIndexMap* objLayoutMap = new (alloc) ObjLayoutIndexMap(alloc); diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index 21bd5d794d71b..4fb8f335883cb 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -6418,7 +6418,7 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals() alloc_order[cur] = 0; - noway_assert(cur < _countof(alloc_order)); + noway_assert(cur < ArrLen(alloc_order)); // Force first pass to happen UINT assignMore = 0xFFFFFFFF; diff --git a/src/coreclr/jit/likelyclass.cpp b/src/coreclr/jit/likelyclass.cpp index 6e1c55b4c2674..fc6028c0ac4ef 100644 --- a/src/coreclr/jit/likelyclass.cpp +++ b/src/coreclr/jit/likelyclass.cpp @@ -93,7 +93,7 @@ LikelyClassHistogram::LikelyClassHistogram(INT_PTR* histogramEntries, unsigned e if (!found) { - if (countHistogramElements >= _countof(m_histogram)) + if (countHistogramElements >= ArrLen(m_histogram)) { continue; } diff --git a/src/coreclr/jit/lsraarm.cpp b/src/coreclr/jit/lsraarm.cpp index 52651a5e85ba7..fb5ad16006dad 100644 --- a/src/coreclr/jit/lsraarm.cpp +++ b/src/coreclr/jit/lsraarm.cpp @@ -818,7 +818,7 @@ int LinearScan::BuildNode(GenTree* tree) default: #ifdef DEBUG char message[256]; - _snprintf_s(message, _countof(message), _TRUNCATE, "NYI: Unimplemented node type %s", + _snprintf_s(message, ArrLen(message), _TRUNCATE, "NYI: Unimplemented node type %s", GenTree::OpName(tree->OperGet())); NYIRAW(message); #endif diff --git a/src/coreclr/jit/regset.cpp b/src/coreclr/jit/regset.cpp index 9d8aad3ef88cd..58439020fd693 100644 --- a/src/coreclr/jit/regset.cpp +++ b/src/coreclr/jit/regset.cpp @@ -920,7 +920,7 @@ bool RegSet::tmpAllFree() const return false; } - for (unsigned i = 0; i < _countof(tmpUsed); i++) + for (unsigned i = 0; i < ArrLen(tmpUsed); i++) { if (tmpUsed[i] != nullptr) { diff --git a/src/coreclr/jit/simd.cpp b/src/coreclr/jit/simd.cpp index 1d2344e41dc62..cfcc8f0285624 100644 --- a/src/coreclr/jit/simd.cpp +++ b/src/coreclr/jit/simd.cpp @@ -298,7 +298,7 @@ CorInfoType Compiler::getBaseJitTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeH // TODO-Throughput: implement product shipping solution to query base type. WCHAR className[256] = {0}; WCHAR* pbuf = &className[0]; - int len = _countof(className); + int len = ArrLen(className); info.compCompHnd->appendClassName((char16_t**)&pbuf, &len, typeHnd, true, false, false); noway_assert(pbuf < &className[256]); JITDUMP("SIMD Candidate Type %S\n", className); diff --git a/src/coreclr/jit/smdata.cpp b/src/coreclr/jit/smdata.cpp index 30b0a7b81d7be..0d6ec896552bb 100644 --- a/src/coreclr/jit/smdata.cpp +++ b/src/coreclr/jit/smdata.cpp @@ -269,7 +269,7 @@ const SMState g_SMStates[] = }; // clang-format on -static_assert_no_msg(NUM_SM_STATES == _countof(g_SMStates)); +static_assert_no_msg(NUM_SM_STATES == ArrLen(g_SMStates)); const SMState* gp_SMStates = g_SMStates; diff --git a/src/coreclr/jit/smweights.cpp b/src/coreclr/jit/smweights.cpp index ec55072436eb2..02aa5d647f7db 100644 --- a/src/coreclr/jit/smweights.cpp +++ b/src/coreclr/jit/smweights.cpp @@ -268,6 +268,6 @@ const short g_StateWeights[] = { DEFAULT_WEIGHT_VALUE, // state 249 [ldarga.s -> ldfld -> ldarga.s -> ldfld -> sub] }; -static_assert_no_msg(NUM_SM_STATES == _countof(g_StateWeights)); +static_assert_no_msg(NUM_SM_STATES == ArrLen(g_StateWeights)); const short* gp_StateWeights = g_StateWeights; diff --git a/src/coreclr/jit/unwindarm.cpp b/src/coreclr/jit/unwindarm.cpp index 2b25ed82942cc..54c6a011cb0a7 100644 --- a/src/coreclr/jit/unwindarm.cpp +++ b/src/coreclr/jit/unwindarm.cpp @@ -2270,7 +2270,7 @@ void DumpUnwindInfo(Compiler* comp, else { printf(" --- One epilog, unwind codes at %u\n", epilogCount); - assert(epilogCount < _countof(epilogStartAt)); + assert(epilogCount < ArrLen(epilogStartAt)); epilogStartAt[epilogCount] = true; // the one and only epilog starts its unwind codes at this offset } diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index e454eb338682b..f1e311a9a602c 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -110,7 +110,7 @@ const char* varTypeName(var_types vt) #undef DEF_TP }; - assert((unsigned)vt < _countof(varTypeNames)); + assert((unsigned)vt < ArrLen(varTypeNames)); return varTypeNames[vt]; } @@ -601,7 +601,7 @@ void dumpILRange(const BYTE* const codeAddr, unsigned codeSize) // in bytes for (IL_OFFSET offs = 0; offs < codeSize;) { char prefix[100]; - sprintf_s(prefix, _countof(prefix), "IL_%04x ", offs); + sprintf_s(prefix, ArrLen(prefix), "IL_%04x ", offs); unsigned codeBytesDumped = dumpSingleInstr(codeAddr, offs, prefix); offs += codeBytesDumped; } diff --git a/src/coreclr/jit/utils.h b/src/coreclr/jit/utils.h index 4452101028842..4e98bc5369df7 100644 --- a/src/coreclr/jit/utils.h +++ b/src/coreclr/jit/utils.h @@ -32,7 +32,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #endif template -unsigned ArrLen(T (&)[size]) +inline constexpr unsigned ArrLen(T (&)[size]) { return size; } diff --git a/src/coreclr/jit/valuenum.cpp b/src/coreclr/jit/valuenum.cpp index a21c02191e5a9..51927d5256c8e 100644 --- a/src/coreclr/jit/valuenum.cpp +++ b/src/coreclr/jit/valuenum.cpp @@ -6276,7 +6276,7 @@ void ValueNumStore::InitValueNumStoreStatics() #undef ValueNumFuncSetArity - for (unsigned i = 0; i < _countof(genTreeOpsIllegalAsVNFunc); i++) + for (unsigned i = 0; i < ArrLen(genTreeOpsIllegalAsVNFunc); i++) { vnfOpAttribs[genTreeOpsIllegalAsVNFunc[i]] |= VNFOA_IllegalGenTreeOp; } diff --git a/src/coreclr/md/compiler/custattr_emit.cpp b/src/coreclr/md/compiler/custattr_emit.cpp index 47589f93a2420..02d3f8e9e3a4a 100644 --- a/src/coreclr/md/compiler/custattr_emit.cpp +++ b/src/coreclr/md/compiler/custattr_emit.cpp @@ -198,8 +198,8 @@ DEFINE_CA_NAMED_ARGS(DllImportAttribute) DEFINE_CA_NAMED_ARGS_END() const KnownCaProp DllImportAttributeProps = {"System.Runtime.InteropServices", "DllImportAttribute", DllImportTargets, bDONTKEEPCA, - rDllImportAttributeArgs, lengthof(rDllImportAttributeArgs), - rDllImportAttributeNamedArgs, lengthof(rDllImportAttributeNamedArgs)}; + rDllImportAttributeArgs, ARRAY_SIZE(rDllImportAttributeArgs), + rDllImportAttributeNamedArgs, ARRAY_SIZE(rDllImportAttributeNamedArgs)}; //----------------------------------------------------------------------------- // GUID args, named args (none), and known attribute properties. @@ -208,7 +208,7 @@ DEFINE_CA_CTOR_ARGS(GuidAttribute) DEFINE_CA_CTOR_ARGS_END() const KnownCaProp GuidAttributeProps = {"System.Runtime.InteropServices", "GuidAttribute", GuidTargets, bKEEPCA, - rGuidAttributeArgs, lengthof(rGuidAttributeArgs)}; + rGuidAttributeArgs, ARRAY_SIZE(rGuidAttributeArgs)}; //----------------------------------------------------------------------------- // ComImport args (none), named args (none), and known attribute properties. @@ -221,7 +221,7 @@ DEFINE_CA_CTOR_ARGS(InterfaceTypeAttribute) DEFINE_CA_CTOR_ARGS_END() const KnownCaProp InterfaceTypeAttributeProps = {"System.Runtime.InteropServices", "InterfaceTypeAttribute", InterfaceTypeTargets, bKEEPCA, - rInterfaceTypeAttributeArgs, lengthof(rInterfaceTypeAttributeArgs)}; + rInterfaceTypeAttributeArgs, ARRAY_SIZE(rInterfaceTypeAttributeArgs)}; //----------------------------------------------------------------------------- // Class interface type args, named args (none), and known attribute properties. @@ -230,7 +230,7 @@ DEFINE_CA_CTOR_ARGS(ClassInterfaceAttribute) DEFINE_CA_CTOR_ARGS_END() const KnownCaProp ClassInterfaceAttributeProps = {"System.Runtime.InteropServices", "ClassInterfaceAttribute", ClassInterfaceTargets, bKEEPCA, - rClassInterfaceAttributeArgs, lengthof(rClassInterfaceAttributeArgs)}; + rClassInterfaceAttributeArgs, ARRAY_SIZE(rClassInterfaceAttributeArgs)}; //----------------------------------------------------------------------------- // Serializable args (none), named args (none), and known attribute properties. @@ -275,15 +275,15 @@ DEFINE_CA_NAMED_ARGS_END() const KnownCaProp MethodImplAttribute1Props = {"System.Runtime.CompilerServices", "MethodImplAttribute", MethodImplTargets, bDONTKEEPCA, 0, 0, - rMethodImplAttributeNamedArgs, lengthof(rMethodImplAttributeNamedArgs), + rMethodImplAttributeNamedArgs, ARRAY_SIZE(rMethodImplAttributeNamedArgs), bMATCHBYSIG}; const KnownCaProp MethodImplAttribute2Props = {"System.Runtime.CompilerServices", "MethodImplAttribute", MethodImplTargets, bDONTKEEPCA, - rMethodImplAttribute2Args, lengthof(rMethodImplAttribute2Args), - rMethodImplAttributeNamedArgs, lengthof(rMethodImplAttributeNamedArgs), + rMethodImplAttribute2Args, ARRAY_SIZE(rMethodImplAttribute2Args), + rMethodImplAttributeNamedArgs, ARRAY_SIZE(rMethodImplAttributeNamedArgs), bMATCHBYSIG}; const KnownCaProp MethodImplAttribute3Props = {"System.Runtime.CompilerServices", "MethodImplAttribute", MethodImplTargets, bDONTKEEPCA, - rMethodImplAttribute3Args, lengthof(rMethodImplAttribute3Args), - rMethodImplAttributeNamedArgs, lengthof(rMethodImplAttributeNamedArgs), + rMethodImplAttribute3Args, ARRAY_SIZE(rMethodImplAttribute3Args), + rMethodImplAttributeNamedArgs, ARRAY_SIZE(rMethodImplAttributeNamedArgs), bMATCHBYNAME}; //----------------------------------------------------------------------------- @@ -324,13 +324,13 @@ DEFINE_CA_NAMED_ARGS(MarshalAsAttribute) DEFINE_CA_NAMED_ARGS_END() const KnownCaProp MarshalAsAttribute1Props = {"System.Runtime.InteropServices", "MarshalAsAttribute", MarshalTargets, bDONTKEEPCA, - rMarshalAsAttribute1Args, lengthof(rMarshalAsAttribute1Args), - rMarshalAsAttributeNamedArgs, lengthof(rMarshalAsAttributeNamedArgs), + rMarshalAsAttribute1Args, ARRAY_SIZE(rMarshalAsAttribute1Args), + rMarshalAsAttributeNamedArgs, ARRAY_SIZE(rMarshalAsAttributeNamedArgs), bMATCHBYSIG}; const KnownCaProp MarshalAsAttribute2Props = {"System.Runtime.InteropServices", "MarshalAsAttribute", MarshalTargets, bDONTKEEPCA, - rMarshalAsAttribute2Args, lengthof(rMarshalAsAttribute2Args), - rMarshalAsAttributeNamedArgs, lengthof(rMarshalAsAttributeNamedArgs), + rMarshalAsAttribute2Args, ARRAY_SIZE(rMarshalAsAttribute2Args), + rMarshalAsAttributeNamedArgs, ARRAY_SIZE(rMarshalAsAttributeNamedArgs), bMATCHBYNAME}; //----------------------------------------------------------------------------- @@ -375,12 +375,12 @@ DEFINE_CA_NAMED_ARGS(StructLayoutAttribute) DEFINE_CA_NAMED_ARGS_END() const KnownCaProp StructLayoutAttribute1Props = {"System.Runtime.InteropServices", "StructLayoutAttribute", StructLayoutTargets, bDONTKEEPCA, - rStructLayoutAttribute1Args, lengthof(rStructLayoutAttribute1Args), - rStructLayoutAttributeNamedArgs, lengthof(rStructLayoutAttributeNamedArgs), + rStructLayoutAttribute1Args, ARRAY_SIZE(rStructLayoutAttribute1Args), + rStructLayoutAttributeNamedArgs, ARRAY_SIZE(rStructLayoutAttributeNamedArgs), bMATCHBYSIG}; const KnownCaProp StructLayoutAttribute2Props = {"System.Runtime.InteropServices", "StructLayoutAttribute", StructLayoutTargets, bDONTKEEPCA, - rStructLayoutAttribute2Args, lengthof(rStructLayoutAttribute2Args), - rStructLayoutAttributeNamedArgs, lengthof(rStructLayoutAttributeNamedArgs), + rStructLayoutAttribute2Args, ARRAY_SIZE(rStructLayoutAttribute2Args), + rStructLayoutAttributeNamedArgs, ARRAY_SIZE(rStructLayoutAttributeNamedArgs), bMATCHBYNAME}; //----------------------------------------------------------------------------- @@ -390,7 +390,7 @@ DEFINE_CA_CTOR_ARGS(FieldOffsetAttribute) DEFINE_CA_CTOR_ARGS_END() const KnownCaProp FieldOffsetAttributeProps = {"System.Runtime.InteropServices", "FieldOffsetAttribute", FieldOffsetTargets, bDONTKEEPCA, - rFieldOffsetAttributeArgs, lengthof(rFieldOffsetAttributeArgs)}; + rFieldOffsetAttributeArgs, ARRAY_SIZE(rFieldOffsetAttributeArgs)}; DEFINE_CA_CTOR_ARGS(TypeLibVersionAttribute) DEFINE_CA_CTOR_ARG(SERIALIZATION_TYPE_I4) @@ -398,7 +398,7 @@ DEFINE_CA_CTOR_ARGS(TypeLibVersionAttribute) DEFINE_CA_CTOR_ARGS_END() const KnownCaProp TypeLibVersionAttributeProps = {"System.Runtime.InteropServices", "TypeLibVersionAttribute", TypeLibVersionTargets, bKEEPCA, - rTypeLibVersionAttributeArgs, lengthof(rTypeLibVersionAttributeArgs)}; + rTypeLibVersionAttributeArgs, ARRAY_SIZE(rTypeLibVersionAttributeArgs)}; DEFINE_CA_CTOR_ARGS(ComCompatibleVersionAttribute) @@ -409,7 +409,7 @@ DEFINE_CA_CTOR_ARGS(ComCompatibleVersionAttribute) DEFINE_CA_CTOR_ARGS_END() const KnownCaProp ComCompatibleVersionAttributeProps = {"System.Runtime.InteropServices", "ComCompatibleVersionAttribute", ComCompatibleVersionTargets, bKEEPCA, - rComCompatibleVersionAttributeArgs, lengthof(rComCompatibleVersionAttributeArgs)}; + rComCompatibleVersionAttributeArgs, ARRAY_SIZE(rComCompatibleVersionAttributeArgs)}; //----------------------------------------------------------------------------- diff --git a/src/coreclr/md/compiler/regmeta.cpp b/src/coreclr/md/compiler/regmeta.cpp index ffe2877433469..44acdf6f41057 100644 --- a/src/coreclr/md/compiler/regmeta.cpp +++ b/src/coreclr/md/compiler/regmeta.cpp @@ -910,7 +910,7 @@ const char *DumpMD_DumpRawNameOfType(RegMeta *pMD, ULONG iType) } // default: static char buf[30]; - sprintf_s(buf, NumItems(buf), "unknown type 0x%02x", iType); + sprintf_s(buf, ARRAY_SIZE(buf), "unknown type 0x%02x", iType); return buf; } // const char *DumpMD_DumpRawNameOfType() @@ -1127,7 +1127,7 @@ void DumpMD_DisplayUserStrings( bool bUnprint = false; // Is an unprintable character found? HRESULT hr; // A result. while (SUCCEEDED(hr = pMD->EnumUserStrings( &stringEnum, - Strings, NumItems(Strings), &count)) && + Strings, ARRAY_SIZE(Strings), &count)) && count > 0) { if (totalCount == 1) @@ -1225,7 +1225,7 @@ void DumpMD_DumpRawHeaps( do { pMD->GetBlob(oData, &cbData, (const void**)&pData); - sprintf_s(rcPrefix, NumItems(rcPrefix), "%5x,%-2x", oData, cbData); + sprintf_s(rcPrefix, ARRAY_SIZE(rcPrefix), "%5x,%-2x", oData, cbData); DumpMD_DumpHex(rcPrefix, pData, cbData); hr = pMD->GetNextBlob(oData, &oData); } @@ -1239,7 +1239,7 @@ void DumpMD_DumpRawHeaps( do { pMD->GetString(oData, &pString); - sprintf_s(rcPrefix, NumItems(rcPrefix), "%08x", oData); + sprintf_s(rcPrefix, ARRAY_SIZE(rcPrefix), "%08x", oData); DumpMD_DumpHex(rcPrefix, pString, (ULONG)strlen(pString)+1); if (*pString != 0) DumpMD_VWrite("%08x: %s\n", oData, pString); diff --git a/src/coreclr/md/compiler/regmeta_vm.cpp b/src/coreclr/md/compiler/regmeta_vm.cpp index 04b69c7d5cc3a..80746137bfbaf 100644 --- a/src/coreclr/md/compiler/regmeta_vm.cpp +++ b/src/coreclr/md/compiler/regmeta_vm.cpp @@ -27,9 +27,6 @@ #include - - - #define DEFINE_CUSTOM_NODUPCHECK 1 #define DEFINE_CUSTOM_DUPCHECK 2 #define SET_CUSTOM 3 @@ -210,12 +207,12 @@ RegMeta::ResolveTypeRef( _ASSERTE(TypeFromToken(tr) == mdtTypeRef); IfFailGo(pMiniMd->GetTypeRefRecord(RidFromToken(tr), &pTypeRefRec)); - IfFailGo(pMiniMd->getNamespaceOfTypeRef(pTypeRefRec, wzNameSpace, lengthof(wzNameSpace), NULL)); + IfFailGo(pMiniMd->getNamespaceOfTypeRef(pTypeRefRec, wzNameSpace, ARRAY_SIZE(wzNameSpace), NULL)); if (hr != NOERROR) { _ASSERTE(hr == CLDB_S_TRUNCATION); // Truncate the namespace string - wzNameSpace[lengthof(wzNameSpace) - 1] = 0; + wzNameSpace[STRING_LENGTH(wzNameSpace)] = 0; } //*********************** diff --git a/src/coreclr/md/enc/metamodelrw.cpp b/src/coreclr/md/enc/metamodelrw.cpp index bc15f4f6ffcb1..82142503783b1 100644 --- a/src/coreclr/md/enc/metamodelrw.cpp +++ b/src/coreclr/md/enc/metamodelrw.cpp @@ -5219,7 +5219,7 @@ CMiniMdRW::FindGenericParamHelper( if (IsSorted(TBL_GenericParam)) { mdToken tk; - tk = encodeToken(RidFromToken(tkOwner), TypeFromToken(tkOwner), mdtTypeOrMethodDef, lengthof(mdtTypeOrMethodDef)); + tk = encodeToken(RidFromToken(tkOwner), TypeFromToken(tkOwner), mdtTypeOrMethodDef, ARRAY_SIZE(mdtTypeOrMethodDef)); IfFailGo(SearchTableForMultipleRows(TBL_GenericParam, _COLDEF(GenericParam,Owner), tk, diff --git a/src/coreclr/md/inc/metamodel.h b/src/coreclr/md/inc/metamodel.h index cc36814680766..56845d20ff6ce 100644 --- a/src/coreclr/md/inc/metamodel.h +++ b/src/coreclr/md/inc/metamodel.h @@ -21,6 +21,8 @@ #include "../datablob.h" #include "../debug_metadata.h" +#include + #ifdef FEATURE_METADATA_EMIT_PORTABLE_PDB #include "portablepdbmdds.h" #include "portablepdbmdi.h" @@ -1622,12 +1624,12 @@ template class CMiniMdTemplate : public CMiniMdBase // Return RID to Constant table. __checkReturn HRESULT FindConstantFor(RID rid, mdToken typ, RID *pFoundRid) - { return doSearchTable(TBL_Constant, _COLPAIR(Constant,Parent), encodeToken(rid,typ,mdtHasConstant,lengthof(mdtHasConstant)), pFoundRid); } + { return doSearchTable(TBL_Constant, _COLPAIR(Constant,Parent), encodeToken(rid,typ,mdtHasConstant, ARRAY_SIZE(mdtHasConstant)), pFoundRid); } // Return RID to FieldMarshal table. __checkReturn HRESULT FindFieldMarshalFor(RID rid, mdToken typ, RID *pFoundRid) - { return doSearchTable(TBL_FieldMarshal, _COLPAIR(FieldMarshal,Parent), encodeToken(rid,typ,mdtHasFieldMarshal,lengthof(mdtHasFieldMarshal)), pFoundRid); } + { return doSearchTable(TBL_FieldMarshal, _COLPAIR(FieldMarshal,Parent), encodeToken(rid,typ,mdtHasFieldMarshal, ARRAY_SIZE(mdtHasFieldMarshal)), pFoundRid); } // Return RID to ClassLayout table, given the rid to a TypeDef. __checkReturn @@ -1695,7 +1697,7 @@ template class CMiniMdTemplate : public CMiniMdBase // Return RID to Constant table. __checkReturn HRESULT FindImplMapFor(RID rid, mdToken typ, RID *pFoundRid) - { return doSearchTable(TBL_ImplMap, _COLPAIR(ImplMap,MemberForwarded), encodeToken(rid,typ,mdtMemberForwarded,lengthof(mdtMemberForwarded)), pFoundRid); } + { return doSearchTable(TBL_ImplMap, _COLPAIR(ImplMap,MemberForwarded), encodeToken(rid,typ,mdtMemberForwarded, ARRAY_SIZE(mdtMemberForwarded)), pFoundRid); } // Return RID to FieldRVA table. __checkReturn @@ -1735,7 +1737,7 @@ template class CMiniMdTemplate : public CMiniMdBase { return SearchTableForMultipleRows(TBL_GenericParam, _COLDEF(GenericParam,Owner), - encodeToken(rid, mdtTypeDef, mdtTypeOrMethodDef, lengthof(mdtTypeOrMethodDef)), + encodeToken(rid, mdtTypeDef, mdtTypeOrMethodDef, ARRAY_SIZE(mdtTypeOrMethodDef)), pEnd, pFoundRid); } @@ -1744,7 +1746,7 @@ template class CMiniMdTemplate : public CMiniMdBase { return SearchTableForMultipleRows(TBL_GenericParam, _COLDEF(GenericParam,Owner), - encodeToken(rid, mdtMethodDef, mdtTypeOrMethodDef, lengthof(mdtTypeOrMethodDef)), + encodeToken(rid, mdtMethodDef, mdtTypeOrMethodDef, ARRAY_SIZE(mdtTypeOrMethodDef)), pEnd, pFoundRid); } @@ -1753,7 +1755,7 @@ template class CMiniMdTemplate : public CMiniMdBase { return SearchTableForMultipleRows(TBL_MethodSpec, _COLDEF(MethodSpec,Method), - encodeToken(rid, mdtMethodDef, mdtMethodDefOrRef, lengthof(mdtMethodDefOrRef)), + encodeToken(rid, mdtMethodDef, mdtMethodDefOrRef, ARRAY_SIZE(mdtMethodDefOrRef)), pEnd, pFoundRid); } @@ -1762,7 +1764,7 @@ template class CMiniMdTemplate : public CMiniMdBase { return SearchTableForMultipleRows(TBL_MethodSpec, _COLDEF(MethodSpec,Method), - encodeToken(rid, mdtMemberRef, mdtMethodDefOrRef, lengthof(mdtMethodDefOrRef)), + encodeToken(rid, mdtMemberRef, mdtMethodDefOrRef, ARRAY_SIZE(mdtMethodDefOrRef)), pEnd, pFoundRid); } @@ -1823,7 +1825,7 @@ template class CMiniMdTemplate : public CMiniMdBase { return SearchTableForMultipleRows(TBL_CustomAttribute, _COLDEF(CustomAttribute,Parent), - encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasCustomAttribute, lengthof(mdtHasCustomAttribute)), + encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasCustomAttribute, ARRAY_SIZE(mdtHasCustomAttribute)), pEnd, pFoundRid); } @@ -1842,7 +1844,7 @@ template class CMiniMdTemplate : public CMiniMdBase { return SearchTableForMultipleRows(TBL_DeclSecurity, _COLDEF(DeclSecurity,Parent), - encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasDeclSecurity, lengthof(mdtHasDeclSecurity)), + encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasDeclSecurity, ARRAY_SIZE(mdtHasDeclSecurity)), pEnd, pFoundRid); } @@ -1893,7 +1895,7 @@ template class CMiniMdTemplate : public CMiniMdBase { return SearchTableForMultipleRows(TBL_MethodSemantics, _COLDEF(MethodSemantics,Association), - encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasSemantic, lengthof(mdtHasSemantic)), + encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasSemantic, ARRAY_SIZE(mdtHasSemantic)), pEnd, pFoundRid); } diff --git a/src/coreclr/md/inc/metamodelrw.h b/src/coreclr/md/inc/metamodelrw.h index 90ac20948269e..a8ccf8ae2effb 100644 --- a/src/coreclr/md/inc/metamodelrw.h +++ b/src/coreclr/md/inc/metamodelrw.h @@ -24,6 +24,8 @@ #include "../heaps/export.h" #include "../tables/export.h" +#include + struct HENUMInternal; #ifdef FEATURE_METADATA_CUSTOM_DATA_SOURCE struct IMDCustomDataSource; @@ -950,7 +952,7 @@ class CMiniMdRW : public CMiniMdTemplate HRESULT GetGenericParamsForToken(mdToken tk, RID *pRidStart, RID *pRidEnd = 0) { return LookUpTableByCol( - encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtTypeOrMethodDef, lengthof(mdtTypeOrMethodDef)), + encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtTypeOrMethodDef, ARRAY_SIZE(mdtTypeOrMethodDef)), m_pVS[TBL_GenericParam], pRidStart, pRidEnd); } @@ -965,7 +967,7 @@ class CMiniMdRW : public CMiniMdTemplate HRESULT GetMethodSpecsForToken(mdToken tk, RID *pRidStart, RID *pRidEnd = 0) { return LookUpTableByCol( - encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtMethodDefOrRef, lengthof(mdtMethodDefOrRef)), + encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtMethodDefOrRef, ARRAY_SIZE(mdtMethodDefOrRef)), m_pVS[TBL_MethodSpec], pRidStart, pRidEnd); } @@ -973,7 +975,7 @@ class CMiniMdRW : public CMiniMdTemplate HRESULT GetDeclSecurityForToken(mdToken tk, RID *pRidStart, RID *pRidEnd = 0) { return LookUpTableByCol( - encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasDeclSecurity, lengthof(mdtHasDeclSecurity)), + encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasDeclSecurity, ARRAY_SIZE(mdtHasDeclSecurity)), m_pVS[TBL_DeclSecurity], pRidStart, pRidEnd); @@ -983,7 +985,7 @@ class CMiniMdRW : public CMiniMdTemplate HRESULT GetCustomAttributeForToken(mdToken tk, RID *pRidStart, RID *pRidEnd = 0) { return LookUpTableByCol( - encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasCustomAttribute, lengthof(mdtHasCustomAttribute)), + encodeToken(RidFromToken(tk), TypeFromToken(tk), mdtHasCustomAttribute, ARRAY_SIZE(mdtHasCustomAttribute)), m_pVS[TBL_CustomAttribute], pRidStart, pRidEnd); diff --git a/src/coreclr/md/runtime/metamodel.cpp b/src/coreclr/md/runtime/metamodel.cpp index cd1ccde9cc36a..b13ee6a736aaf 100644 --- a/src/coreclr/md/runtime/metamodel.cpp +++ b/src/coreclr/md/runtime/metamodel.cpp @@ -90,7 +90,7 @@ static const char* rDummy3ColNames[] = { "" }; //----------------------------------------------------------------------------- // Define the array of Coded Token Definitions. -#define MiniMdCodedToken(x) {lengthof(CMiniMdBase::mdt##x), CMiniMdBase::mdt##x, #x}, +#define MiniMdCodedToken(x) {ARRAY_SIZE(CMiniMdBase::mdt##x), CMiniMdBase::mdt##x, #x}, const CCodedTokenDef g_CodedTokens [] = { MiniMdCodedTokens() }; @@ -98,7 +98,7 @@ const CCodedTokenDef g_CodedTokens [] = { // Define the array of Table Definitions. #undef MiniMdTable -#define MiniMdTable(x) { { r##x##Cols, lengthof(r##x##Cols), x##Rec::COL_KEY, 0 }, r##x##ColNames, #x}, +#define MiniMdTable(x) { { r##x##Cols, ARRAY_SIZE(r##x##Cols), x##Rec::COL_KEY, 0 }, r##x##ColNames, #x}, const CMiniTableDefEx g_Tables[TBL_COUNT] = { MiniMdTables() #ifdef FEATURE_METADATA_EMIT_PORTABLE_PDB @@ -107,7 +107,7 @@ const CMiniTableDefEx g_Tables[TBL_COUNT] = { }; // Define a table descriptor for the obsolete v1.0 GenericParam table definition. -const CMiniTableDefEx g_Table_GenericParamV1_1 = { { rGenericParamV1_1Cols, lengthof(rGenericParamV1_1Cols), GenericParamV1_1Rec::COL_KEY, 0 }, rGenericParamV1_1ColNames, "GenericParamV1_"}; +const CMiniTableDefEx g_Table_GenericParamV1_1 = { { rGenericParamV1_1Cols, ARRAY_SIZE(rGenericParamV1_1Cols), GenericParamV1_1Rec::COL_KEY, 0 }, rGenericParamV1_1ColNames, "GenericParamV1_"}; @@ -444,7 +444,7 @@ CMiniMdBase::encodeToken( //***************************************************************************** inline BYTE cbRID(ULONG ixMax) { return ixMax > USHRT_MAX ? (BYTE) sizeof(ULONG) : (BYTE) sizeof(USHORT); } -#define _CBTKN(cRecs,tkns) cbRID((cRecs) << m_cb[lengthof(tkns)]) +#define _CBTKN(cRecs,tkns) cbRID((cRecs) << m_cb[ARRAY_SIZE(tkns)]) //***************************************************************************** // Constructor. @@ -723,7 +723,7 @@ CMiniMdBase::InitColsForTable( HRESULT hr = S_OK; _ASSERTE((bExtra == 0) || (bExtra == 1)); - _ASSERTE(NumItems(pCols) >= pTable->m_cCols); + _ASSERTE(ARRAY_SIZE(pCols) >= pTable->m_cCols); bExtra = 0;//@FUTURE: save in schema header. until then use 0. @@ -751,7 +751,7 @@ CMiniMdBase::InitColsForTable( ULONG iCdTkn = pCols[ixCol].m_Type - iCodedToken; ULONG cRecs = 0; - _ASSERTE(iCdTkn < lengthof(g_CodedTokens)); + _ASSERTE(iCdTkn < ARRAY_SIZE(g_CodedTokens)); CCodedTokenDef const *pCTD = &g_CodedTokens[iCdTkn]; // Iterate the token list of this coded token. @@ -1084,7 +1084,7 @@ CMiniMdBase::FindCustomAttributeFor( { HRESULT hr; int ixFound; // index of some custom value row. - ULONG ulTarget = encodeToken(rid,tkObj,mdtHasCustomAttribute,lengthof(mdtHasCustomAttribute)); // encoded token representing target. + ULONG ulTarget = encodeToken(rid,tkObj,mdtHasCustomAttribute, ARRAY_SIZE(mdtHasCustomAttribute)); // encoded token representing target. ULONG ixCur; // Current row being examined. mdToken tkFound; // Type of some custom value row. void *pCur; // A custom value entry. @@ -1107,7 +1107,7 @@ CMiniMdBase::FindCustomAttributeFor( { // Test the type of the current row. tkFound = getIX(pCur, _COLDEF(CustomAttribute,Type)); - tkFound = decodeToken(tkFound, mdtCustomAttributeType, lengthof(mdtCustomAttributeType)); + tkFound = decodeToken(tkFound, mdtCustomAttributeType, ARRAY_SIZE(mdtCustomAttributeType)); if (tkFound == tkType) { *pFoundRid = ixCur; @@ -1137,7 +1137,7 @@ CMiniMdBase::FindCustomAttributeFor( break; // Test the type of the current row. tkFound = getIX(pCur, _COLDEF(CustomAttribute,Type)); - tkFound = decodeToken(tkFound, mdtCustomAttributeType, lengthof(mdtCustomAttributeType)); + tkFound = decodeToken(tkFound, mdtCustomAttributeType, ARRAY_SIZE(mdtCustomAttributeType)); if (tkFound == tkType) { *pFoundRid = ixCur; diff --git a/src/coreclr/pal/src/exception/machmessage.h b/src/coreclr/pal/src/exception/machmessage.h index c24a979f52089..01e2bb691d2a4 100644 --- a/src/coreclr/pal/src/exception/machmessage.h +++ b/src/coreclr/pal/src/exception/machmessage.h @@ -35,7 +35,7 @@ using namespace CorUnix; if (machret != KERN_SUCCESS) \ { \ char _szError[1024]; \ - snprintf(_szError, _countof(_szError), "%s: %u: %s", __FUNCTION__, __LINE__, _msg); \ + snprintf(_szError, ARRAY_SIZE(_szError), "%s: %u: %s", __FUNCTION__, __LINE__, _msg); \ mach_error(_szError, machret); \ abort(); \ } \ diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h index b0abe2aa9be0a..3a12d78910364 100644 --- a/src/coreclr/pal/src/include/pal/palinternal.h +++ b/src/coreclr/pal/src/include/pal/palinternal.h @@ -617,8 +617,6 @@ function_name() to call the system's implementation #undef assert #define assert (Use__ASSERTE_instead_of_assert) assert -#define string_countof(a) (sizeof(a) / sizeof(a[0]) - 1) - #ifndef __ANDROID__ #define TEMP_DIRECTORY_PATH "/tmp/" #else diff --git a/src/coreclr/pal/src/include/pal/sharedmemory.h b/src/coreclr/pal/src/include/pal/sharedmemory.h index 1ded94e12fcc5..c9cecc750859c 100644 --- a/src/coreclr/pal/src/include/pal/sharedmemory.h +++ b/src/coreclr/pal/src/include/pal/sharedmemory.h @@ -5,15 +5,12 @@ #define _PAL_SHARED_MEMORY_H_ #include "corunix.hpp" +#include #ifndef static_assert_no_msg #define static_assert_no_msg( cond ) static_assert( cond, #cond ) #endif // !static_assert_no_msg -#ifndef _countof -#define _countof(a) (sizeof(a) / sizeof(a[0])) -#endif // !_countof - // The folder used for storing shared memory files and their lock files is defined in // the gSharedFilesPath global variable. The value of the variable depends on which // OS is being used, and if the application is running in a sandbox in Mac. @@ -28,16 +25,16 @@ // {gSharedFilesPath}/.dotnet/lockfiles/session/ #define SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT (_MAX_FNAME - 1) -#define SHARED_MEMORY_MAX_NAME_CHAR_COUNT (string_countof("Global\\") + SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT) +#define SHARED_MEMORY_MAX_NAME_CHAR_COUNT (STRING_LENGTH("Global\\") + SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT) #define SHARED_MEMORY_RUNTIME_TEMP_DIRECTORY_NAME ".dotnet" #define SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_NAME ".dotnet/shm" #define SHARED_MEMORY_LOCK_FILES_DIRECTORY_NAME ".dotnet/lockfiles" -static_assert_no_msg(_countof(SHARED_MEMORY_LOCK_FILES_DIRECTORY_NAME) >= _countof(SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_NAME)); +static_assert_no_msg(ARRAY_SIZE(SHARED_MEMORY_LOCK_FILES_DIRECTORY_NAME) >= ARRAY_SIZE(SHARED_MEMORY_SHARED_MEMORY_DIRECTORY_NAME)); #define SHARED_MEMORY_GLOBAL_DIRECTORY_NAME "global" #define SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX "session" -static_assert_no_msg(_countof(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) >= _countof(SHARED_MEMORY_GLOBAL_DIRECTORY_NAME)); +static_assert_no_msg(ARRAY_SIZE(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) >= ARRAY_SIZE(SHARED_MEMORY_GLOBAL_DIRECTORY_NAME)); #define SHARED_MEMORY_UNIQUE_TEMP_NAME_TEMPLATE ".coreclr.XXXXXX" @@ -46,9 +43,9 @@ static_assert_no_msg(_countof(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) >= _c // Note that this Max size does not include the prefix folder path size which is unknown (in the case of sandbox) until runtime #define SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT \ ( \ - string_countof(SHARED_MEMORY_LOCK_FILES_DIRECTORY_NAME) + \ + STRING_LENGTH(SHARED_MEMORY_LOCK_FILES_DIRECTORY_NAME) + \ 1 /* path separator */ + \ - string_countof(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) + \ + STRING_LENGTH(SHARED_MEMORY_SESSION_DIRECTORY_NAME_PREFIX) + \ SHARED_MEMORY_MAX_SESSION_ID_CHAR_COUNT + \ 1 /* path separator */ + \ SHARED_MEMORY_MAX_FILE_NAME_CHAR_COUNT \ diff --git a/src/coreclr/pal/src/init/pal.cpp b/src/coreclr/pal/src/init/pal.cpp index e9dffec3dbb2a..5469b4bebd483 100644 --- a/src/coreclr/pal/src/init/pal.cpp +++ b/src/coreclr/pal/src/init/pal.cpp @@ -39,7 +39,7 @@ SET_DEFAULT_DEBUG_CHANNEL(PAL); // some headers have code with asserts, so do th #include "pal/numa.h" #include "pal/stackstring.hpp" #include "pal/cgroup.h" -#include +#include #if HAVE_MACH_EXCEPTIONS #include "../exception/machexception.h" @@ -1371,5 +1371,5 @@ static BOOL INIT_SharedFilesPath(void) return gSharedFilesPath->Set(TEMP_DIRECTORY_PATH); // We can verify statically the non sandboxed case, since the size is known during compile time - static_assert_no_msg(string_countof(TEMP_DIRECTORY_PATH) + SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1 /* null terminator */ <= MAX_LONGPATH); + static_assert_no_msg(STRING_LENGTH(TEMP_DIRECTORY_PATH) + SHARED_MEMORY_MAX_FILE_PATH_CHAR_COUNT + 1 /* null terminator */ <= MAX_LONGPATH); } diff --git a/src/coreclr/pal/src/locale/utf8.cpp b/src/coreclr/pal/src/locale/utf8.cpp index 96a633b165d9a..8ff3229fcbaba 100644 --- a/src/coreclr/pal/src/locale/utf8.cpp +++ b/src/coreclr/pal/src/locale/utf8.cpp @@ -3,8 +3,6 @@ /*++ - - Module Name: unicode/utf8.c @@ -14,8 +12,6 @@ Module Name: Revision History: - - --*/ #include "pal/utf8.h" @@ -25,10 +21,6 @@ using namespace CorUnix; #define FASTLOOP -#ifndef COUNTOF -#define COUNTOF(x) (sizeof(x) / sizeof((x)[0])) -#endif - struct CharUnicodeInfo { static const WCHAR HIGH_SURROGATE_START = 0xd800; @@ -232,7 +224,7 @@ class DecoderReplacementFallback : public DecoderFallback if (bFoundHigh) throw ArgumentException("String 'replacement' contains invalid Unicode code points.", "replacement"); - wcscpy_s(strDefault, COUNTOF(strDefault), replacement); + wcscpy_s(strDefault, ARRAY_SIZE(strDefault), replacement); strDefaultLength = replacementLength; } @@ -429,7 +421,7 @@ class DecoderReplacementFallbackBuffer : public DecoderFallbackBuffer // Construction DecoderReplacementFallbackBuffer(DecoderReplacementFallback* fallback) { - wcscpy_s(strDefault, COUNTOF(strDefault), fallback->GetDefaultString()); + wcscpy_s(strDefault, ARRAY_SIZE(strDefault), fallback->GetDefaultString()); strDefaultLength = PAL_wcslen((const WCHAR *)fallback->GetDefaultString()); } @@ -709,7 +701,7 @@ class EncoderReplacementFallback : public EncoderFallback if (bFoundHigh) throw ArgumentException("String 'replacement' contains invalid Unicode code points.", "replacement"); - wcscpy_s(strDefault, COUNTOF(strDefault), replacement); + wcscpy_s(strDefault, ARRAY_SIZE(strDefault), replacement); strDefaultLength = replacementLength; } @@ -881,8 +873,8 @@ class EncoderReplacementFallbackBuffer : public EncoderFallbackBuffer EncoderReplacementFallbackBuffer(EncoderReplacementFallback* fallback) { // 2X in case we're a surrogate pair - wcscpy_s(strDefault, COUNTOF(strDefault), fallback->GetDefaultString()); - wcscat_s(strDefault, COUNTOF(strDefault), fallback->GetDefaultString()); + wcscpy_s(strDefault, ARRAY_SIZE(strDefault), fallback->GetDefaultString()); + wcscat_s(strDefault, ARRAY_SIZE(strDefault), fallback->GetDefaultString()); strDefaultLength = 2 * PAL_wcslen((const WCHAR *)fallback->GetDefaultString()); } diff --git a/src/coreclr/pal/src/misc/dbgmsg.cpp b/src/coreclr/pal/src/misc/dbgmsg.cpp index a41d2d1036b47..a5f98a0b0d323 100644 --- a/src/coreclr/pal/src/misc/dbgmsg.cpp +++ b/src/coreclr/pal/src/misc/dbgmsg.cpp @@ -3,8 +3,6 @@ /*++ - - Module Name: misc/dbgmsg.cpp @@ -13,8 +11,6 @@ Module Name: Implementation of Debug Message utilies. Relay channel information, output functions, etc. - - --*/ /* PAL headers */ @@ -102,7 +98,7 @@ static const char *dbg_channel_names[]= }; // Verify the number of elements in dbg_channel_names -static_assert_no_msg(_countof(dbg_channel_names) == DCI_LAST); +static_assert_no_msg(ARRAY_SIZE(dbg_channel_names) == DCI_LAST); static const char *dbg_level_names[]= { diff --git a/src/coreclr/pal/src/misc/jitsupport.cpp b/src/coreclr/pal/src/misc/jitsupport.cpp index 973de4033e3d4..2addd1526e64c 100644 --- a/src/coreclr/pal/src/misc/jitsupport.cpp +++ b/src/coreclr/pal/src/misc/jitsupport.cpp @@ -82,7 +82,7 @@ static const CpuCapability CpuCapabilities[] = { // If the capability name is not recognized or unused at present, zero is returned. static unsigned long LookupCpuCapabilityFlag(const char* start, size_t length) { - for (size_t i = 0; i < _countof(CpuCapabilities); i++) + for (size_t i = 0; i < ARRAY_SIZE(CpuCapabilities); i++) { const char* capabilityName = CpuCapabilities[i].name; if ((length == strlen(capabilityName)) && (memcmp(start, capabilityName, length) == 0)) diff --git a/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp b/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp index 4c946cc5257b7..f82b4c01a47a9 100644 --- a/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp +++ b/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp @@ -444,13 +444,13 @@ SharedMemoryId::SharedMemoryId(LPCSTR name) if (strncmp(name, "Global\\", 7) == 0) { m_isSessionScope = false; - name += _countof("Global\\") - 1; + name += STRING_LENGTH("Global\\"); } else { if (strncmp(name, "Local\\", 6) == 0) { - name += _countof("Local\\") - 1; + name += STRING_LENGTH("Local\\"); } m_isSessionScope = true; } diff --git a/src/coreclr/pal/src/synchmgr/wait.cpp b/src/coreclr/pal/src/synchmgr/wait.cpp index 273b9617a9fb2..bce09fe91c795 100644 --- a/src/coreclr/pal/src/synchmgr/wait.cpp +++ b/src/coreclr/pal/src/synchmgr/wait.cpp @@ -56,7 +56,7 @@ static PalObjectTypeId sg_rgSignalableObjectIds[] = otiNamedMutex, otiSemaphore }; -static CAllowedObjectTypes sg_aotSignalableObject(sg_rgSignalableObjectIds, _countof(sg_rgSignalableObjectIds)); +static CAllowedObjectTypes sg_aotSignalableObject(sg_rgSignalableObjectIds, ARRAY_SIZE(sg_rgSignalableObjectIds)); /*++ Function: diff --git a/src/coreclr/pal/src/synchobj/mutex.cpp b/src/coreclr/pal/src/synchobj/mutex.cpp index 85bf3da1e79a6..267176b15118a 100644 --- a/src/coreclr/pal/src/synchobj/mutex.cpp +++ b/src/coreclr/pal/src/synchobj/mutex.cpp @@ -3,8 +3,6 @@ /*++ - - Module Name: mutex.ccpp @@ -16,8 +14,6 @@ Module Name: Revision History: - - --*/ #include "pal/dbgmsg.h" @@ -90,7 +86,7 @@ CObjectType CorUnix::otNamedMutex( static CAllowedObjectTypes aotNamedMutex(otiNamedMutex); static PalObjectTypeId anyMutexTypeIds[] = {otiMutex, otiNamedMutex}; -static CAllowedObjectTypes aotAnyMutex(anyMutexTypeIds, _countof(anyMutexTypeIds)); +static CAllowedObjectTypes aotAnyMutex(anyMutexTypeIds, ARRAY_SIZE(anyMutexTypeIds)); /*++ Function: @@ -125,7 +121,7 @@ CreateMutexW( if (lpName != nullptr) { - int bytesWritten = WideCharToMultiByte(CP_ACP, 0, lpName, -1, utf8Name, _countof(utf8Name), nullptr, nullptr); + int bytesWritten = WideCharToMultiByte(CP_ACP, 0, lpName, -1, utf8Name, ARRAY_SIZE(utf8Name), nullptr, nullptr); if (bytesWritten == 0) { DWORD errorCode = GetLastError(); @@ -569,7 +565,7 @@ OpenMutexW( } { - int bytesWritten = WideCharToMultiByte(CP_ACP, 0, lpName, -1, utf8Name, _countof(utf8Name), nullptr, nullptr); + int bytesWritten = WideCharToMultiByte(CP_ACP, 0, lpName, -1, utf8Name, ARRAY_SIZE(utf8Name), nullptr, nullptr); if (bytesWritten == 0) { DWORD errorCode = GetLastError(); diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 7fe41410386dd..f9d591bb84947 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -3,8 +3,6 @@ /*++ - - Module Name: process.cpp @@ -13,8 +11,6 @@ Module Name: Implementation of process object and functions related to processes. - - --*/ #include "pal/dbgmsg.h" @@ -99,7 +95,7 @@ extern "C" if (machret != KERN_SUCCESS) \ { \ char _szError[1024]; \ - snprintf(_szError, _countof(_szError), "%s: %u: %s", __FUNCTION__, __LINE__, _msg); \ + snprintf(_szError, ARRAY_SIZE(_szError), "%s: %u: %s", __FUNCTION__, __LINE__, _msg); \ mach_error(_szError, machret); \ abort(); \ } \ @@ -2993,7 +2989,7 @@ CreateProcessModules( int devHi, devLo, inode; char moduleName[PATH_MAX]; - if (sscanf_s(line, "%p-%p %*[-rwxsp] %p %x:%x %d %s\n", &startAddress, &endAddress, &offset, &devHi, &devLo, &inode, moduleName, _countof(moduleName)) == 7) + if (sscanf_s(line, "%p-%p %*[-rwxsp] %p %x:%x %d %s\n", &startAddress, &endAddress, &offset, &devHi, &devLo, &inode, moduleName, ARRAY_SIZE(moduleName)) == 7) { if (inode != 0) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h index 8cfe4507ac1b8..1feb23ecec935 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h +++ b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/sprintf_s.h @@ -17,13 +17,13 @@ inline void DoStrTest_sprintf_s(const char *formatstr, char* param, const char * { char buf[256] = { 0 }; - sprintf_s(buf, _countof(buf), formatstr, param); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) { Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" "Expected \"%s\" got \"%s\".\n", param, formatstr, checkstr, buf); - } + } } #define DoStrTest DoStrTest_sprintf_s @@ -31,22 +31,22 @@ inline void DoWStrTest_sprintf_s(const char *formatstr, WCHAR* param, const char { char buf[256] = { 0 }; - sprintf_s(buf, _countof(buf), formatstr, param); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) { Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" "Expected \"%s\" got \"%s\".\n", convertC(param), formatstr, checkstr, buf); - } + } } #define DoWStrTest DoWStrTest_sprintf_s -inline void DoPointerTest_sprintf_s(const char *formatstr, void* param, char* paramstr, +inline void DoPointerTest_sprintf_s(const char *formatstr, void* param, char* paramstr, const char *checkstr1) { char buf[256] = { 0 }; - sprintf_s(buf, _countof(buf), formatstr, param); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -60,8 +60,8 @@ inline void DoCountTest_sprintf_s(const char *formatstr, int param, const char * { char buf[512] = { 0 }; int n = -1; - - sprintf_s(buf, _countof(buf), formatstr, &n); + + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, &n); if (n != param) { @@ -80,7 +80,7 @@ inline void DoShortCountTest_sprintf_s(const char *formatstr, int param, const c char buf[256] = { 0 }; short int n = -1; - sprintf_s(buf, _countof(buf), formatstr, &n); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, &n); if (n != param) { @@ -98,7 +98,7 @@ inline void DoCharTest_sprintf_s(const char *formatstr, char param, const char * { char buf[256] = { 0 }; - sprintf_s(buf, _countof(buf), formatstr, param); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -112,7 +112,7 @@ inline void DoWCharTest_sprintf_s(const char *formatstr, WCHAR param, const char { char buf[256] = { 0 }; - sprintf_s(buf, _countof(buf), formatstr, param); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -126,7 +126,7 @@ inline void DoNumTest_sprintf_s(const char *formatstr, int value, const char *ch { char buf[256] = { 0 }; - sprintf_s(buf, _countof(buf), formatstr, value); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr, strlen(checkstr) + 1) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -140,13 +140,13 @@ inline void DoI64Test_sprintf_s(const char *formatstr, INT64 value, char *values { char buf[256] = { 0 }; - sprintf_s(buf, _countof(buf), formatstr, value); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" "Expected \"%s\", got \"%s\".\n", valuestr, formatstr, checkstr1, buf); - } + } } #define DoI64Test DoI64Test_sprintf_s @@ -155,12 +155,12 @@ inline void DoDoubleTest_sprintf_s(const char *formatstr, double value, const ch { char buf[256] = { 0 }; - sprintf_s(buf, _countof(buf), formatstr, value); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { Fail("ERROR: failed to insert %f into \"%s\"\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", + "Expected \"%s\" or \"%s\", got \"%s\".\n", value, formatstr, checkstr1, checkstr2, buf); } } @@ -171,7 +171,7 @@ inline void DoArgumentPrecTest_sprintf_s(const char *formatstr, int precision, v { char buf[256]; - sprintf_s(buf, _countof(buf), formatstr, precision, param); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -188,7 +188,7 @@ inline void DoArgumentPrecDoubleTest_sprintf_s(const char *formatstr, int precis { char buf[256]; - sprintf_s(buf, _countof(buf), formatstr, precision, param); + sprintf_s(buf, ARRAY_SIZE(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp index 12342858aff78..6cc7fe4684600 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/sprintf_s/test1/test1.cpp @@ -16,7 +16,7 @@ #include #include "../sprintf_s.h" -/* +/* * Depends on memcmp and strlen */ @@ -31,7 +31,7 @@ PALTEST(c_runtime_sprintf_s_test1_paltest_sprintf_test1, "c_runtime/sprintf_s/te } - sprintf_s(buf, _countof(buf), "hello world"); + sprintf_s(buf, ARRAY_SIZE(buf), "hello world"); if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h b/src/coreclr/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h index 8c66c98fcb0c6..f4422866781c7 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h +++ b/src/coreclr/pal/tests/palsuite/c_runtime/sscanf_s/sscanf_s.h @@ -43,7 +43,7 @@ inline void DoStrTest_scanf_s(char *inputstr, const char *formatstr, const char char buf[256] = { 0 }; int ret; - ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); + ret = sscanf_s(inputstr, formatstr, buf, ARRAY_SIZE(buf)); if (ret != 1) { Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" @@ -53,7 +53,7 @@ inline void DoStrTest_scanf_s(char *inputstr, const char *formatstr, const char if (memcmp(checkstr, buf, strlen(checkstr) + 1) != 0) { Fail("ERROR: scanned string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", inputstr, formatstr, checkstr, + "Expected \"%s\", got \"%s\".\n", inputstr, formatstr, checkstr, buf); } @@ -65,7 +65,7 @@ inline void DoWStrTest_scanf_s(char *inputstr, const char *formatstr, const WCHA WCHAR buf[256] = { 0 }; int ret; - ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); + ret = sscanf_s(inputstr, formatstr, buf, ARRAY_SIZE(buf)); if (ret != 1) { Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" @@ -75,7 +75,7 @@ inline void DoWStrTest_scanf_s(char *inputstr, const char *formatstr, const WCHA if (memcmp(checkstr, buf, wcslen(checkstr)*2 + 2) != 0) { Fail("ERROR: scanned wide string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", inputstr, formatstr, + "Expected \"%s\", got \"%s\".\n", inputstr, formatstr, convertC(checkstr), convertC(buf)); } @@ -138,8 +138,8 @@ inline void DoI64NumTest_scanf_s(char *inputstr, const char *formatstr, INT64 ch if (checknum != num) { - sprintf_s(buf, _countof(buf), "%I64d", num); - sprintf_s(check, _countof(check), "%I64d", checknum); + sprintf_s(buf, ARRAY_SIZE(buf), "%I64d", num); + sprintf_s(check, ARRAY_SIZE(check), "%I64d", checknum); Fail("ERROR: scanned I64 number incorrectly from \"%s\" using \"%s\".\n" "Expected %s, got %s.\n", inputstr, formatstr, check, buf); } @@ -155,7 +155,7 @@ inline void DoCharTest_scanf_s(char *inputstr, const char *formatstr, char* chec for (i=0; i<256; i++) buf[i] = (char)-1; - ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); + ret = sscanf_s(inputstr, formatstr, buf, ARRAY_SIZE(buf)); if (ret != 1) { Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" @@ -167,14 +167,14 @@ inline void DoCharTest_scanf_s(char *inputstr, const char *formatstr, char* chec buf[numchars] = 0; Fail("ERROR: scanned character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", inputstr, formatstr, checkchars, + "Expected %s, got %s.\n", inputstr, formatstr, checkchars, buf); } if (buf[numchars] != (char)-1) { Fail("ERROR: overflow occurred in scanning character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", inputstr, formatstr, + "using \"%s\".\nExpected %d character(s)\n", inputstr, formatstr, numchars); } } @@ -189,7 +189,7 @@ inline void DoWCharTest_scanf_s(char *inputstr, const char *formatstr, WCHAR* ch for (i=0; i<256; i++) buf[i] = (WCHAR)-1; - ret = sscanf_s(inputstr, formatstr, buf, _countof(buf)); + ret = sscanf_s(inputstr, formatstr, buf, ARRAY_SIZE(buf)); if (ret != 1) { Fail("ERROR: Expected sscanf_s to return 1, got %d.\n" @@ -201,14 +201,14 @@ inline void DoWCharTest_scanf_s(char *inputstr, const char *formatstr, WCHAR* ch buf[numchars] = 0; Fail("ERROR: scanned wide character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", inputstr, formatstr, convertC(checkchars), + "Expected %s, got %s.\n", inputstr, formatstr, convertC(checkchars), convertC(buf)); } if (buf[numchars] != (WCHAR)-1) { Fail("ERROR: overflow occurred in scanning wide character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", inputstr, formatstr, + "using \"%s\".\nExpected %d character(s)\n", inputstr, formatstr, numchars); } } @@ -236,7 +236,7 @@ inline void DoFloatTest_scanf_s(char *inputstr, const char *formatstr, float che if (val != checkval) { Fail("ERROR: scanned float incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%f\", got \"%f\".\n", inputstr, formatstr, checkval, + "Expected \"%f\", got \"%f\".\n", inputstr, formatstr, checkval, val); } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swprintf/swprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/swprintf/swprintf.h index 5ca39606e8b2e..b00ca81d8002c 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swprintf/swprintf.h +++ b/src/coreclr/pal/tests/palsuite/c_runtime/swprintf/swprintf.h @@ -17,13 +17,13 @@ inline void DoWStrTest_swprintf_s(const WCHAR *formatstr, WCHAR *param, const WC { WCHAR buf[256] = { 0 }; - swprintf_s(buf, _countof(buf), formatstr, param); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) { Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - convertC(param), convertC(formatstr), + "Expected \"%s\", got \"%s\".\n", + convertC(param), convertC(formatstr), convertC(checkstr), convertC(buf)); } } @@ -33,13 +33,13 @@ inline void DoStrTest_swprintf_s(const WCHAR *formatstr, char *param, const WCHA { WCHAR buf[256] = { 0 }; - swprintf_s(buf, _countof(buf), formatstr, param); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr) * 2 + 2) != 0) { Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - param, convertC(formatstr), convertC(checkstr), + "Expected \"%s\", got \"%s\".\n", + param, convertC(formatstr), convertC(checkstr), convertC(buf)); } } @@ -49,13 +49,13 @@ inline void DoPointerTest_swprintf_s(const WCHAR *formatstr, void* param, const { WCHAR buf[256] = { 0 }; - swprintf_s(buf, _countof(buf), formatstr, param); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) { Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n" "Expected \"%s\", got \"%s\".\n", param, convertC(formatstr), convertC(checkstr1), convertC(buf)); - } + } } #define DoPointerTest DoPointerTest_swprintf_s @@ -63,7 +63,7 @@ inline void DoCharTest_swprintf_s(const WCHAR *formatstr, char param, const WCHA { WCHAR buf[256] = { 0 }; - swprintf_s(buf, _countof(buf), formatstr, param); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -77,7 +77,7 @@ inline void DoWCharTest_swprintf_s(const WCHAR *formatstr, WCHAR param, const WC { WCHAR buf[256] = { 0 }; - swprintf_s(buf, _countof(buf), formatstr, param); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(checkstr)*2 + 2) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -91,7 +91,7 @@ inline void DoNumTest_swprintf_s(const WCHAR *formatstr, int value, const WCHAR { WCHAR buf[256] = { 0 }; - swprintf_s(buf, _countof(buf), formatstr, value); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(checkstr)* 2 + 2) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -106,7 +106,7 @@ inline void DoI64Test_swprintf_s(const WCHAR *formatstr, INT64 param, char *para { WCHAR buf[256] = { 0 }; - swprintf_s(buf, _countof(buf), formatstr, param); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -121,7 +121,7 @@ inline void DoDoubleTest_swprintf_s(const WCHAR *formatstr, double value, const { WCHAR buf[256] = { 0 }; - swprintf_s(buf, _countof(buf), formatstr, value); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1)*2 + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2)*2 + 2) != 0) { @@ -138,7 +138,7 @@ inline void DoArgumentPrecTest_swprintf_s(const WCHAR *formatstr, int precision, { WCHAR buf[256]; - swprintf_s(buf, _countof(buf), formatstr, precision, param); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { @@ -155,7 +155,7 @@ inline void DoArgumentPrecDoubleTest_swprintf_s(const WCHAR *formatstr, int prec { WCHAR buf[256]; - swprintf_s(buf, _countof(buf), formatstr, precision, param); + swprintf_s(buf, ARRAY_SIZE(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp index 62ec881dfca32..eb1574bbe2e2f 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/swprintf/test1/test1.cpp @@ -30,7 +30,7 @@ PALTEST(c_runtime_swprintf_test1_paltest_swprintf_test1, "c_runtime/swprintf/tes } checkstr = convert("hello world"); - swprintf_s(buf, _countof(buf), convert("hello world")); + swprintf_s(buf, ARRAY_SIZE(buf), convert("hello world")); if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/swscanf.h b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/swscanf.h index a5b0228bc01f3..0950263bfae63 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/swscanf.h +++ b/src/coreclr/pal/tests/palsuite/c_runtime/swscanf/swscanf.h @@ -23,7 +23,7 @@ inline void DoVoidTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr) if (ret != 0) { Fail("ERROR: Expected sscanf to return 0, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), + "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), convertC(formatstr)); } @@ -32,7 +32,7 @@ inline void DoVoidTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr) if (buf[i] != 0) { Fail("ERROR: Parameter unexpectedly modified scanning \"%s\" " - "using \"%s\".\n", convertC(inputstr), + "using \"%s\".\n", convertC(inputstr), convertC(formatstr)); } } @@ -49,15 +49,15 @@ inline void DoStrTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, const cha if (ret != 1) { Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), + "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), convertC(formatstr)); } if (memcmp(checkstr, buf, strlen(checkstr) + 1) != 0) { Fail("ERROR: scanned string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", convertC(inputstr), - convertC(formatstr), checkstr, + "Expected \"%s\", got \"%s\".\n", convertC(inputstr), + convertC(formatstr), checkstr, buf); } @@ -80,8 +80,8 @@ inline void DoWStrTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, const WC if (memcmp(checkstr, buf, wcslen(checkstr)*2 + 2) != 0) { Fail("ERROR: scanned wide string incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", convertC(inputstr), - convertC(formatstr), convertC(checkstr), + "Expected \"%s\", got \"%s\".\n", convertC(inputstr), + convertC(formatstr), convertC(checkstr), convertC(buf)); } @@ -97,14 +97,14 @@ inline void DoNumTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, int check if (ret != 1) { Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), + "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), convertC(formatstr)); } if (checknum != num) { Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" - "Expected %d, got %d.\n", convertC(inputstr), + "Expected %d, got %d.\n", convertC(inputstr), convertC(formatstr), checknum, num); } } @@ -119,14 +119,14 @@ inline void DoShortNumTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, shor if (ret != 1) { Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), + "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), convertC(formatstr)); } if (checknum != num) { Fail("ERROR: scanned number incorrectly from \"%s\" using \"%s\".\n" - "Expected %hd, got %hd.\n", convertC(inputstr), + "Expected %hd, got %hd.\n", convertC(inputstr), convertC(formatstr), checknum, num); } } @@ -143,16 +143,16 @@ inline void DoI64NumTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, INT64 if (ret != 1) { Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), + "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), convertC(formatstr)); } if (checknum != num) { - sprintf_s(buf, _countof(buf), "%I64d", num); - sprintf_s(check, _countof(check), "%I64d", checknum); + sprintf_s(buf, ARRAY_SIZE(buf), "%I64d", num); + sprintf_s(check, ARRAY_SIZE(check), "%I64d", checknum); Fail("ERROR: scanned I64 number incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), + "Expected %s, got %s.\n", convertC(inputstr), convertC(formatstr), check, buf); } } @@ -171,7 +171,7 @@ inline void DoCharTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, char* ch if (ret != 1) { Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), + "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), convertC(formatstr)); } @@ -180,14 +180,14 @@ inline void DoCharTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, char* ch buf[numchars] = 0; Fail("ERROR: scanned character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), + "Expected %s, got %s.\n", convertC(inputstr), convertC(formatstr), checkchars, buf); } if (buf[numchars] != (char)-1) { Fail("ERROR: overflow occurred in scanning character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", + "using \"%s\".\nExpected %d character(s)\n", convertC(inputstr), convertC(formatstr), numchars); } } @@ -206,7 +206,7 @@ inline void DoWCharTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, const W if (ret != 1) { Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), + "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), convertC(formatstr)); } @@ -215,15 +215,15 @@ inline void DoWCharTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, const W buf[numchars] = 0; Fail("ERROR: scanned wide character(s) incorrectly from \"%s\" using \"%s\".\n" - "Expected %s, got %s.\n", convertC(inputstr), - convertC(formatstr), convertC(checkchars), + "Expected %s, got %s.\n", convertC(inputstr), + convertC(formatstr), convertC(checkchars), convertC(buf)); } if (buf[numchars] != (WCHAR)-1) { Fail("ERROR: overflow occurred in scanning wide character(s) from \"%s\" " - "using \"%s\".\nExpected %d character(s)\n", + "using \"%s\".\nExpected %d character(s)\n", convertC(inputstr), convertC(formatstr), numchars); } } @@ -245,14 +245,14 @@ inline void DoFloatTest_swscanf(WCHAR *inputstr, const WCHAR *formatstr, float c if (ret != 1) { Fail("ERROR: Expected swscanf to return 1, got %d.\n" - "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), + "Using \"%s\" in \"%s\".\n", ret, convertC(inputstr), convertC(formatstr)); } if (val != checkval) { Fail("ERROR: scanned float incorrectly from \"%s\" using \"%s\".\n" - "Expected \"%f\", got \"%f\".\n", convertC(inputstr), + "Expected \"%f\", got \"%f\".\n", convertC(inputstr), convertC(formatstr), checkval, val); } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp index 09b0b9f011148..74e4b0c85083d 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/test1/test1.cpp @@ -22,13 +22,13 @@ PALTEST(c_runtime_vsprintf_test1_paltest_vsprintf_test1, "c_runtime/vsprintf/tes char checkstr[] = "hello world"; char buf[256] = { 0 }; int ret; - + if (PAL_Initialize(argc, argv) != 0) { return(FAIL); } - testvsp(buf, _countof(buf), "hello world"); + testvsp(buf, ARRAY_SIZE(buf), "hello world"); if (memcmp(checkstr, buf, strlen(checkstr)+1) != 0) { @@ -36,8 +36,8 @@ PALTEST(c_runtime_vsprintf_test1_paltest_vsprintf_test1, "c_runtime/vsprintf/tes checkstr, 256, buf); } - testvsp(buf, _countof(buf), "xxxxxxxxxxxxxxxxx"); - ret = testvsp(buf, _countof(buf), "hello world"); + testvsp(buf, ARRAY_SIZE(buf), "xxxxxxxxxxxxxxxxx"); + ret = testvsp(buf, ARRAY_SIZE(buf), "hello world"); if (ret != strlen(checkstr)) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h index 00e459b3db0c7..638f90490b70d 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h +++ b/src/coreclr/pal/tests/palsuite/c_runtime/vsprintf/vsprintf.h @@ -29,7 +29,7 @@ inline void DoStrTest_vsprintf(const char *formatstr, char* param, const char *c { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, param); + testvsp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert string \"%s\" into \"%s\"\n" @@ -43,7 +43,7 @@ inline void DoWStrTest_vsprintf(const char *formatstr, WCHAR* param, const char { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, param); + testvsp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert wide string \"%s\" into \"%s\"\n" @@ -57,7 +57,7 @@ inline void DoCharTest_vsprintf(const char *formatstr, char param, const char *c { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, param); + testvsp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" @@ -71,7 +71,7 @@ inline void DoWCharTest_vsprintf(const char *formatstr, WCHAR param, const char { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, param); + testvsp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" @@ -85,7 +85,7 @@ inline void DoNumTest_vsprintf(const char *formatstr, int value, const char *che { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, value); + testvsp(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" @@ -99,7 +99,7 @@ inline void DoI64Test_vsprintf(const char *formatstr, INT64 value, char *valuest { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, value); + testvsp(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr, strlen(buf) + 1) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -114,7 +114,7 @@ inline void DoDoubleTest_vsprintf(const char *formatstr, double value, const cha { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, value); + testvsp(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -131,7 +131,7 @@ inline void DoArgumentPrecTest_vsprintf(const char *formatstr, int precision, vo { char buf[256]; - testvsp(buf, _countof(buf), formatstr, precision, param); + testvsp(buf, ARRAY_SIZE(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -148,7 +148,7 @@ inline void DoArgumentPrecDoubleTest_vsprintf(const char *formatstr, int precisi { char buf[256]; - testvsp(buf, _countof(buf), formatstr, precision, param); + testvsp(buf, ARRAY_SIZE(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0 && memcmp(buf, checkstr2, strlen(checkstr2) + 1) != 0) { @@ -165,7 +165,7 @@ inline void DoPointerTest_vsprintf(const char *formatstr, void* param, char* par { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, param); + testvsp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1)) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -180,7 +180,7 @@ inline void DoI64DoubleTest_vsprintf(const char *formatstr, INT64 value, char *v { char buf[256] = { 0 }; - testvsp(buf, _countof(buf), formatstr, value); + testvsp(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr1, strlen(checkstr1) + 1) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -195,7 +195,7 @@ inline void DoTest_vsprintf(const char *formatstr, int param, const char *checks char buf[256] = { 0 }; int n = -1; - testvsp(buf, _countof(buf), formatstr, &n); + testvsp(buf, ARRAY_SIZE(buf), formatstr, &n); if (n != param) { @@ -214,7 +214,7 @@ inline void DoShortTest_vsprintf(const char *formatstr, int param, const char *c char buf[256] = { 0 }; short int n = -1; - testvsp(buf, _countof(buf), formatstr, &n); + testvsp(buf, ARRAY_SIZE(buf), formatstr, &n); if (n != param) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp index 954f8f99f13e1..41e59d6b3a56a 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp @@ -25,11 +25,11 @@ PALTEST(c_runtime_vswprintf_test1_paltest_vswprintf_test1, "c_runtime/vswprintf/ return(FAIL); checkstr = convert("hello world"); - testvswp(buf, _countof(buf), checkstr); + testvswp(buf, ARRAY_SIZE(buf), checkstr); if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0) { - Fail("ERROR: Expected \"%s\", got \"%s\"\n", + Fail("ERROR: Expected \"%s\", got \"%s\"\n", convertC(checkstr), convertC(buf)); } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp index 482c442f03a2c..eed7f216d255b 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test19/test19.cpp @@ -9,7 +9,7 @@ ** ** **===================================================================*/ - + #include #include "../vswprintf.h" @@ -22,38 +22,38 @@ void DoArgumentPrecTest_vswprintf(WCHAR *formatstr, int precision, void *param, WCHAR *paramstr, WCHAR *checkstr1, WCHAR *checkstr2) { WCHAR buf[256]; - - testvswp(buf, _countof(buf), formatstr, precision, param); + + testvswp(buf, ARRAY_SIZE(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", + "Expected \"%s\" or \"%s\", got \"%s\".\n", paramstr, convertC(formatstr), precision, convertC(checkstr1), convertC(checkstr2), convertC(buf)); - } + } } void DoArgumentPrecDoubleTest_vswprintf(WCHAR *formatstr, int precision, double param, WCHAR *checkstr1, WCHAR *checkstr2) { WCHAR buf[256]; - testvswp(buf, _countof(buf), formatstr, precision, param); + testvswp(buf, ARRAY_SIZE(buf), formatstr, precision, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { Fail("ERROR: failed to insert %f into \"%s\" with precision %d\n" - "Expected \"%s\" or \"%s\", got \"%s\".\n", + "Expected \"%s\" or \"%s\", got \"%s\".\n", param, convertC(formatstr), precision, convertC(checkstr1), convertC(checkstr2), convertC(buf)); - } + } } /* @@ -66,15 +66,15 @@ PALTEST(c_runtime_vswprintf_test19_paltest_vswprintf_test19, "c_runtime/vswprint if (PAL_Initialize(argc, argv) != 0) return(FAIL); - DoArgumentPrecTest_vswprintf(convert("%.*s"), 2, (void*)convert("bar"), convert("bar"), + DoArgumentPrecTest_vswprintf(convert("%.*s"), 2, (void*)convert("bar"), convert("bar"), convert("ba"), convert("ba")); - DoArgumentPrecTest_vswprintf(convert("%.*c"), 0, (void*)'a', convert("a"), + DoArgumentPrecTest_vswprintf(convert("%.*c"), 0, (void*)'a', convert("a"), convert("a"), convert("a")); - DoArgumentPrecTest_vswprintf(convert("%.*c"), 4, (void*)'a', convert("a"), + DoArgumentPrecTest_vswprintf(convert("%.*c"), 4, (void*)'a', convert("a"), convert("a"), convert("a")); - DoArgumentPrecTest_vswprintf(convert("%.*C"), 0, (void*)'a', convert("a"), + DoArgumentPrecTest_vswprintf(convert("%.*C"), 0, (void*)'a', convert("a"), convert("a"), convert("a")); - DoArgumentPrecTest_vswprintf(convert("%.*C"), 4, (void*)'a', convert("a"), + DoArgumentPrecTest_vswprintf(convert("%.*C"), 4, (void*)'a', convert("a"), convert("a"), convert("a")); DoArgumentPrecTest_vswprintf(convert("%.*d"), 1, (void*)42, convert("42"), convert("42"), convert("42")); @@ -96,9 +96,9 @@ PALTEST(c_runtime_vswprintf_test19_paltest_vswprintf_test19, "c_runtime/vswprint convert("42"), convert("42")); DoArgumentPrecTest_vswprintf(convert("%.*x"), 3, (void*)0x42, convert("0x42"), convert("042"), convert("042")); - DoArgumentPrecTest_vswprintf(convert("%.*X"), 1, (void*)0x42, convert("0x42"), + DoArgumentPrecTest_vswprintf(convert("%.*X"), 1, (void*)0x42, convert("0x42"), convert("42"), convert("42")); - DoArgumentPrecTest_vswprintf(convert("%.*X"), 3, (void*)0x42, convert("0x42"), + DoArgumentPrecTest_vswprintf(convert("%.*X"), 3, (void*)0x42, convert("0x42"), convert("042"), convert("042")); @@ -118,7 +118,7 @@ PALTEST(c_runtime_vswprintf_test19_paltest_vswprintf_test19, "c_runtime/vswprint convert("3e+02")); DoArgumentPrecDoubleTest_vswprintf(convert("%.*g"), 3, 256.01, convert("256"), convert("256")); - DoArgumentPrecDoubleTest_vswprintf(convert("%.*g"), 4, 256.01, convert("256"), + DoArgumentPrecDoubleTest_vswprintf(convert("%.*g"), 4, 256.01, convert("256"), convert("256")); DoArgumentPrecDoubleTest_vswprintf(convert("%.*g"), 6, 256.01, convert("256.01"), convert("256.01")); @@ -126,7 +126,7 @@ PALTEST(c_runtime_vswprintf_test19_paltest_vswprintf_test19, "c_runtime/vswprint convert("3E+02")); DoArgumentPrecDoubleTest_vswprintf(convert("%.*G"), 3, 256.01, convert("256"), convert("256")); - DoArgumentPrecDoubleTest_vswprintf(convert("%.*G"), 4, 256.01, convert("256"), + DoArgumentPrecDoubleTest_vswprintf(convert("%.*G"), 4, 256.01, convert("256"), convert("256")); DoArgumentPrecDoubleTest_vswprintf(convert("%.*G"), 6, 256.01, convert("256.01"), convert("256.01")); diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp index 8e72f735224a2..4d933e1dcfbb3 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/test4/test4.cpp @@ -20,25 +20,25 @@ static void DoPointerTest(WCHAR *formatstr, void* param, WCHAR* paramstr, { WCHAR buf[256] = { 0 }; - testvswp(buf, _countof(buf), formatstr, param); + testvswp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) { Fail("ERROR: failed to insert pointer to %#p into \"%s\"\n" "Expected \"%s\" got \"%s\".\n", paramstr, - convertC(formatstr), - convertC(checkstr1), + convertC(formatstr), + convertC(checkstr1), convertC(buf)); - } + } } static void DoI64DoubleTest(WCHAR *formatstr, INT64 value, WCHAR *valuestr, WCHAR *checkstr1) { WCHAR buf[256] = { 0 }; - - testvswp(buf, _countof(buf), formatstr, value); + + testvswp(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" @@ -54,63 +54,63 @@ PALTEST(c_runtime_vswprintf_test4_paltest_vswprintf_test4, "c_runtime/vswprintf/ { void *ptr = (void*) 0x123456; INT64 lptr = I64(0x1234567887654321); - + if (PAL_Initialize(argc, argv) != 0) return(FAIL); - + /* ** Run only on 64 bit platforms */ #if defined(HOST_64BIT) Trace("Testing for 64 Bit Platforms \n"); DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("0000000000000000")); - DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"), convert("0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"), convert(" 0000000000123456")); - DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%17p"), ptr, convert("pointer to 0x123456"), convert(" 0000000000123456")); - DoPointerTest(convert("%-17p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%-17p"), ptr, convert("pointer to 0x123456"), convert("0000000000123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"), convert("0000000000123456")); - DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"), convert("0X0000000000123456")); - DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"), convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"), convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"), convert("00123456")); - DoI64DoubleTest(convert("%I64p"), lptr, + DoI64DoubleTest(convert("%I64p"), lptr, convert("pointer to 0x1234567887654321"), convert("1234567887654321")); #else Trace("Testing for Non 64 Bit Platforms \n"); DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000")); - DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"), convert("00123456")); - DoPointerTest(convert("%9p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%9p"), ptr, convert("pointer to 0x123456"), convert(" 00123456")); - DoPointerTest(convert("%09p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%09p"), ptr, convert("pointer to 0x123456"), convert(" 00123456")); - DoPointerTest(convert("%-9p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%-9p"), ptr, convert("pointer to 0x123456"), convert("00123456 ")); - DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%+p"), ptr, convert("pointer to 0x123456"), convert("00123456")); - DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%#p"), ptr, convert("pointer to 0x123456"), convert("0X00123456")); - DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%lp"), ptr, convert("pointer to 0x123456"), convert("00123456")); - DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%hp"), ptr, convert("pointer to 0x123456"), convert("00003456")); - DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"), + DoPointerTest(convert("%Lp"), ptr, convert("pointer to 0x123456"), convert("00123456")); - DoI64DoubleTest(convert("%I64p"), lptr, + DoI64DoubleTest(convert("%I64p"), lptr, convert("pointer to 0x1234567887654321"), convert("1234567887654321")); #endif - + PAL_Terminate(); return PASS; } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h b/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h index c360c00db4e04..70cee85e7f617 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h +++ b/src/coreclr/pal/tests/palsuite/c_runtime/vswprintf/vswprintf.h @@ -30,13 +30,13 @@ inline void DoWStrTest_vswprintf_s(const WCHAR *formatstr, WCHAR *param, const W { WCHAR buf[256] = { 0 }; - testvswp(buf, _countof(buf), formatstr, param); + testvswp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) { Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - convertC(param), convertC(formatstr), + "Expected \"%s\", got \"%s\".\n", + convertC(param), convertC(formatstr), convertC(checkstr), convertC(buf)); } } @@ -46,13 +46,13 @@ inline void DoStrTest_vswprintf_s(const WCHAR *formatstr, char *param, const WCH { WCHAR buf[256] = { 0 }; - testvswp(buf, _countof(buf), formatstr, param); + testvswp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf) * 2 + 2) != 0) { Fail("ERROR: failed to insert wide string \"%s\" into \"%s\".\n" - "Expected \"%s\", got \"%s\".\n", - param, convertC(formatstr), convertC(checkstr), + "Expected \"%s\", got \"%s\".\n", + param, convertC(formatstr), convertC(checkstr), convertC(buf)); } } @@ -62,14 +62,14 @@ inline void DoCharTest_vswprintf_s(const WCHAR *formatstr, char param, const WCH { WCHAR buf[256] = { 0 }; - testvswp(buf, _countof(buf), formatstr, param); + testvswp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) { Fail("ERROR: failed to insert char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - param, param, convertC(formatstr), convertC(checkstr), + "Expected \"%s\" got \"%s\".\n", + param, param, convertC(formatstr), convertC(checkstr), convertC(buf)); - } + } } #define DoCharTest DoCharTest_vswprintf_s @@ -77,14 +77,14 @@ inline void DoWCharTest_vswprintf_s(const WCHAR *formatstr, WCHAR param, const W { WCHAR buf[256] = { 0 }; - testvswp(buf, _countof(buf), formatstr, param); + testvswp(buf, ARRAY_SIZE(buf), formatstr, param); if (memcmp(buf, checkstr, wcslen(buf)*2 + 2) != 0) { Fail("ERROR: failed to insert wide char \'%c\' (%d) into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", - (char) param, param, convertC(formatstr), convertC(checkstr), + "Expected \"%s\" got \"%s\".\n", + (char) param, param, convertC(formatstr), convertC(checkstr), convertC(buf)); - } + } } #define DoWCharTest DoWCharTest_vswprintf_s @@ -92,13 +92,13 @@ inline void DoNumTest_vswprintf_s(const WCHAR *formatstr, int value, const WCHAR { WCHAR buf[256] = { 0 }; - testvswp(buf, _countof(buf), formatstr, value); + testvswp(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) { Fail("ERROR: failed to insert %#x into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", value, convertC(formatstr), + "Expected \"%s\" got \"%s\".\n", value, convertC(formatstr), convertC(checkstr), convertC(buf)); - } + } } #define DoNumTest DoNumTest_vswprintf_s @@ -106,13 +106,13 @@ inline void DoI64NumTest_vswprintf_s(const WCHAR *formatstr, INT64 value, char * { WCHAR buf[256] = { 0 }; - testvswp(buf, _countof(buf), formatstr, value); + testvswp(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr, wcslen(buf)* 2 + 2) != 0) { Fail("ERROR: failed to insert %s into \"%s\"\n" - "Expected \"%s\" got \"%s\".\n", valuestr, convertC(formatstr), + "Expected \"%s\" got \"%s\".\n", valuestr, convertC(formatstr), convertC(checkstr), convertC(buf)); - } + } } #define DoI64NumTest DoI64NumTest_vswprintf_s @@ -121,7 +121,7 @@ inline void DoDoubleTest_vswprintf_s(const WCHAR *formatstr, double value, const { WCHAR buf[256] = { 0 }; - testvswp(buf, _countof(buf), formatstr, value); + testvswp(buf, ARRAY_SIZE(buf), formatstr, value); if (memcmp(buf, checkstr1, wcslen(checkstr1) + 2) != 0 && memcmp(buf, checkstr2, wcslen(checkstr2) + 2) != 0) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/wcscat/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/wcscat/test1/test1.cpp index da8f581554b5d..d60d483ac50b8 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/wcscat/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/wcscat/test1/test1.cpp @@ -5,8 +5,8 @@ ** ** Source: test1.c ** -** Purpose: -** Test to that wcscat correctly concatanates wide strings, including placing +** Purpose: +** Test to that wcscat correctly concatanates wide strings, including placing ** null pointers. ** ** @@ -30,7 +30,7 @@ PALTEST(c_runtime_wcscat_test1_paltest_wcscat_test1, "c_runtime/wcscat/test1/pal WCHAR *ptr; char buffer[256]; - + if (PAL_Initialize(argc, argv)) { return FAIL; @@ -59,8 +59,8 @@ PALTEST(c_runtime_wcscat_test1_paltest_wcscat_test1, "c_runtime/wcscat/test1/pal if (memcmp(dest, test, sizeof(test)) != 0) { - sprintf_s(buffer, _countof(buffer), "%S", dest); - Fail("ERROR: Expected wcscat to give \"%s\", got \"%s\"\n", + sprintf_s(buffer, ARRAY_SIZE(buffer), "%S", dest); + Fail("ERROR: Expected wcscat to give \"%s\", got \"%s\"\n", "foo bar baz", buffer); } diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/wcscpy/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/wcscpy/test1/test1.cpp index 2c0c9afa8749c..ba8336fa42301 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/wcscpy/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/wcscpy/test1/test1.cpp @@ -25,7 +25,7 @@ PALTEST(c_runtime_wcscpy_test1_paltest_wcscpy_test1, "c_runtime/wcscpy/test1/pal WCHAR *ret; char buffer[256]; - + if (PAL_Initialize(argc, argv)) { return FAIL; @@ -33,10 +33,10 @@ PALTEST(c_runtime_wcscpy_test1_paltest_wcscpy_test1, "c_runtime/wcscpy/test1/pal ret = wcscpy(dest, str); - + if (ret != dest || memcmp(dest, result, sizeof(result)) != 0) { - sprintf_s(buffer, _countof(buffer), "%S", dest); + sprintf_s(buffer, ARRAY_SIZE(buffer), "%S", dest); Fail("Expected wcscpy to give \"%s\" with a return value of %p, got \"%s\" " "with a return value of %p.\n", "foo", dest, buffer, ret); } diff --git a/src/coreclr/pal/tests/palsuite/common/palsuite.h b/src/coreclr/pal/tests/palsuite/common/palsuite.h index d5e5a921ef145..57a56772065be 100644 --- a/src/coreclr/pal/tests/palsuite/common/palsuite.h +++ b/src/coreclr/pal/tests/palsuite/common/palsuite.h @@ -23,6 +23,7 @@ typedef unsigned short char16_t; #include #include #include +#include #define PALTEST(testfunc, testname) \ int __cdecl testfunc(int argc, char* argv[]); \ @@ -38,7 +39,7 @@ enum inline void Trace(const char *format, ...) { va_list arglist; - + va_start(arglist, format); vprintf(format, arglist); @@ -49,10 +50,10 @@ inline void Trace(const char *format, ...) inline void Fail(const char *format, ...) { va_list arglist; - + va_start(arglist, format); - vprintf(format, arglist); + vprintf(format, arglist); va_end(arglist); printf("\n"); @@ -102,7 +103,7 @@ int __cdecl main(int argc, char **argv) // time between PAL_Initialize and PAL_Terminate. However, getenv in PAL // can be run only after PAL_Initialize. szPerfLoopEnv = getenv(PALTEST_LOOP_ENV); - if (szPerfLoopEnv != NULL) + if (szPerfLoopEnv != NULL) { loopCount = atoi(szPerfLoopEnv); if (loopCount <= 0) loopCount = 1; @@ -146,9 +147,9 @@ void Bogus_PAL_Terminate() #ifdef BIGENDIAN inline ULONG VAL32(ULONG x) { - return( ((x & 0xFF000000L) >> 24) | - ((x & 0x00FF0000L) >> 8) | - ((x & 0x0000FF00L) << 8) | + return( ((x & 0xFF000000L) >> 24) | + ((x & 0x00FF0000L) >> 8) | + ((x & 0x0000FF00L) << 8) | ((x & 0x000000FFL) << 24) ); } #define th_htons(w) (w) @@ -157,15 +158,12 @@ inline ULONG VAL32(ULONG x) #define th_htons(w) (((w) >> 8) | ((w) << 8)) #endif // BIGENDIAN -#define _countof(_array) (sizeof(_array)/sizeof(_array[0])) - WCHAR* convert(const char * aString); char* convertC(const WCHAR * wString); UINT64 GetHighPrecisionTimeStamp(LARGE_INTEGER performanceFrequency); extern const char* szTextFile; - int mkAbsoluteFilename( LPSTR dirName, DWORD dwDirLength, @@ -177,10 +175,10 @@ BOOL CleanupHelper (HANDLE *hArray, DWORD dwIndex); BOOL Cleanup(HANDLE *hArray, DWORD dwIndex); -/* +/* * Tokens 0 and 1 are events. Token 2 is the thread. */ -#define NUM_TOKENS 3 +#define NUM_TOKENS 3 extern HANDLE hToken[NUM_TOKENS]; extern CRITICAL_SECTION CriticalSection; @@ -194,11 +192,11 @@ extern CRITICAL_SECTION CriticalSection; * Returns: The number of wide characters in the resulting string. * 0 is returned on Error. */ -int -mkAbsoluteFilenameW ( - LPWSTR dirName, - DWORD dwDirLength, - LPCWSTR fileName, +int +mkAbsoluteFilenameW ( + LPWSTR dirName, + DWORD dwDirLength, + LPCWSTR fileName, DWORD dwFileLength, LPWSTR absPathName ); @@ -211,11 +209,11 @@ mkAbsoluteFilenameW ( * Returns: The number of wide characters in the resulting string. * 0 is returned on Error. */ -int -mkAbsoluteFilenameA ( - LPSTR dirName, - DWORD dwDirLength, - LPCSTR fileName, +int +mkAbsoluteFilenameA ( + LPSTR dirName, + DWORD dwDirLength, + LPCSTR fileName, DWORD dwFileLength, LPSTR absPathName ); diff --git a/src/coreclr/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/test1.cpp index 41f4f825ca250..f64291b7ec858 100644 --- a/src/coreclr/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/debug_api/WriteProcessMemory/test1/test1.cpp @@ -5,9 +5,9 @@ ** ** Source: test1.c ** -** Purpose: Create a child process and some events for communications with it. +** Purpose: Create a child process and some events for communications with it. ** When the child gets back to us with a memory location and a length, -** Call WriteProcessMemory on this location and check to see that it +** Call WriteProcessMemory on this location and check to see that it ** writes successfully. ** ** @@ -27,7 +27,7 @@ PALTEST(debug_api_WriteProcessMemory_test1_paltest_writeprocessmemory_test1, "de HANDLE hEvToHelper; HANDLE hEvFromHelper; DWORD dwExitCode; - + DWORD dwRet; char cmdComposeBuf[MAX_PATH]; @@ -40,33 +40,33 @@ PALTEST(debug_api_WriteProcessMemory_test1_paltest_writeprocessmemory_test1, "de /* Create the signals we need for cross process communication */ hEvToHelper = CreateEvent(NULL, TRUE, FALSE, szcToHelperEvName); - if (!hEvToHelper) + if (!hEvToHelper) { Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "GetLastError() returned %d.\n", szcToHelperEvName, + "GetLastError() returned %d.\n", szcToHelperEvName, GetLastError()); } - if (GetLastError() == ERROR_ALREADY_EXISTS) + if (GetLastError() == ERROR_ALREADY_EXISTS) { Fail("WriteProcessMemory: CreateEvent of '%S' failed. " "(already exists!)\n", szcToHelperEvName); } hEvFromHelper = CreateEvent(NULL, TRUE, FALSE, szcFromHelperEvName); - if (!hEvToHelper) + if (!hEvToHelper) { Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "GetLastError() returned %d.\n", szcFromHelperEvName, + "GetLastError() returned %d.\n", szcFromHelperEvName, GetLastError()); } - if (GetLastError() == ERROR_ALREADY_EXISTS) + if (GetLastError() == ERROR_ALREADY_EXISTS) { Fail("WriteProcessMemory: CreateEvent of '%S' failed. " "(already exists!)\n", szcFromHelperEvName); } ResetEvent(hEvFromHelper); ResetEvent(hEvToHelper); - - if (!sprintf_s(cmdComposeBuf, _countof(cmdComposeBuf), "helper %s", commsFileName)) + + if (!sprintf_s(cmdComposeBuf, ARRAY_SIZE(cmdComposeBuf), "helper %s", commsFileName)) { Fail("Could not convert command line\n"); } @@ -75,11 +75,11 @@ PALTEST(debug_api_WriteProcessMemory_test1_paltest_writeprocessmemory_test1, "de ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); - + /* Create a new process. This is the process that will ask for * memory munging */ - if(!CreateProcess( NULL, uniString, NULL, NULL, - FALSE, 0, NULL, NULL, &si, &pi)) + if(!CreateProcess( NULL, uniString, NULL, NULL, + FALSE, 0, NULL, NULL, &si, &pi)) { Trace("ERROR: CreateProcess failed to load executable '%S'. " "GetLastError() returned %u.\n", @@ -89,7 +89,7 @@ PALTEST(debug_api_WriteProcessMemory_test1_paltest_writeprocessmemory_test1, "de } free(uniString); - while(1) + while(1) { FILE *commsFile; char* pSrcMemory; @@ -122,9 +122,9 @@ PALTEST(debug_api_WriteProcessMemory_test1_paltest_writeprocessmemory_test1, "de } PEDANTIC1(fclose,(commsFile)); sscanf(incomingCMDBuffer, "%u %u", &pDestMemory, &Count); - if (argc > 1) + if (argc > 1) { - Trace("Preparing to write to %u bytes @ %u ('%s')\n", + Trace("Preparing to write to %u bytes @ %u ('%s')\n", Count, pDestMemory, incomingCMDBuffer); } @@ -139,32 +139,32 @@ PALTEST(debug_api_WriteProcessMemory_test1_paltest_writeprocessmemory_test1, "de memset(pSrcMemory, nextValue, Count); /* do the work */ - dwRet = WriteProcessMemory(pi.hProcess, + dwRet = WriteProcessMemory(pi.hProcess, pDestMemory, pSrcMemory, Count, &wpmCount); if (!dwRet) { - Trace("%s: Problem: on a write to %u bytes @ %u ('%s')\n", + Trace("%s: Problem: on a write to %u bytes @ %u ('%s')\n", argv[0], Count, pDestMemory, incomingCMDBuffer); - Trace("test1 WriteProcessMemory returned a%u(!=0) (GLE=%u)\n", + Trace("test1 WriteProcessMemory returned a%u(!=0) (GLE=%u)\n", GetLastError()); } if(Count != wpmCount) { - Trace("%s: Problem: on a write to %u bytes @ %u ('%s')\n", + Trace("%s: Problem: on a write to %u bytes @ %u ('%s')\n", argv[0], Count, pDestMemory, incomingCMDBuffer); Trace("The number of bytes written should have been " "%u, but was reported as %u.\n", Count, wpmCount); } free(pSrcMemory); - doneIteration: + doneIteration: PEDANTIC(ResetEvent, (hEvFromHelper)); PEDANTIC(SetEvent, (hEvToHelper)); } - + /* wait for the child process to complete */ WaitForSingleObject ( pi.hProcess, TIMEOUT ); /* this may return a failure code on a success path */ @@ -172,8 +172,8 @@ PALTEST(debug_api_WriteProcessMemory_test1_paltest_writeprocessmemory_test1, "de /* check the exit code from the process */ if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) ) { - Trace( "GetExitCodeProcess call failed with error code %u\n", - GetLastError() ); + Trace( "GetExitCodeProcess call failed with error code %u\n", + GetLastError() ); dwExitCode = FAIL; } diff --git a/src/coreclr/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/test3.cpp index 196efb1b2abfe..1d6cb240dfda9 100644 --- a/src/coreclr/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/test3.cpp +++ b/src/coreclr/pal/tests/palsuite/debug_api/WriteProcessMemory/test3/test3.cpp @@ -7,8 +7,8 @@ ** ** Purpose: Create a child process and debug it. When the child ** raises an exception, it sends back a memory location. Call -** WriteProcessMemory on the memory location, but attempt to write -** more than the memory allows. This should cause an error and the +** WriteProcessMemory on the memory location, but attempt to write +** more than the memory allows. This should cause an error and the ** data should be unchanged. ** ** @@ -28,7 +28,7 @@ PALTEST(debug_api_WriteProcessMemory_test3_paltest_writeprocessmemory_test3, "de HANDLE hEvToHelper; HANDLE hEvFromHelper; DWORD dwExitCode; - + DWORD dwRet; BOOL success = TRUE; /* assume success */ @@ -42,31 +42,31 @@ PALTEST(debug_api_WriteProcessMemory_test3_paltest_writeprocessmemory_test3, "de /* Create the signals we need for cross process communication */ hEvToHelper = CreateEvent(NULL, TRUE, FALSE, szcToHelperEvName); - if (!hEvToHelper) + if (!hEvToHelper) { Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "GetLastError() returned %u.\n", szcToHelperEvName, + "GetLastError() returned %u.\n", szcToHelperEvName, GetLastError()); } - if (GetLastError() == ERROR_ALREADY_EXISTS) + if (GetLastError() == ERROR_ALREADY_EXISTS) { Fail("WriteProcessMemory: CreateEvent of '%S' failed. " "(already exists!)\n", szcToHelperEvName); } hEvFromHelper = CreateEvent(NULL, TRUE, FALSE, szcFromHelperEvName); - if (!hEvToHelper) + if (!hEvToHelper) { Fail("WriteProcessMemory: CreateEvent of '%S' failed. " - "GetLastError() returned %u.\n", szcFromHelperEvName, + "GetLastError() returned %u.\n", szcFromHelperEvName, GetLastError()); } - if (GetLastError() == ERROR_ALREADY_EXISTS) + if (GetLastError() == ERROR_ALREADY_EXISTS) { Fail("WriteProcessMemory: CreateEvent of '%S' failed. " "(already exists!)\n", szcFromHelperEvName); } - - if (!sprintf_s(cmdComposeBuf, _countof(cmdComposeBuf), "helper %s", commsFileName)) + + if (!sprintf_s(cmdComposeBuf, ARRAY_SIZE(cmdComposeBuf), "helper %s", commsFileName)) { Fail("Could not convert command line\n"); } @@ -75,11 +75,11 @@ PALTEST(debug_api_WriteProcessMemory_test3_paltest_writeprocessmemory_test3, "de ZeroMemory( &si, sizeof(si) ); si.cb = sizeof(si); ZeroMemory( &pi, sizeof(pi) ); - + /* Create a new process. This is the process that will ask for * memory munging */ - if(!CreateProcess( NULL, uniString, NULL, NULL, - FALSE, 0, NULL, NULL, &si, &pi)) + if(!CreateProcess( NULL, uniString, NULL, NULL, + FALSE, 0, NULL, NULL, &si, &pi)) { Trace("ERROR: CreateProcess failed to load executable '%S'. " "GetLastError() returned %u.\n", @@ -127,11 +127,11 @@ PALTEST(debug_api_WriteProcessMemory_test3_paltest_writeprocessmemory_test3, "de goto doneIteration; } PEDANTIC1(fclose,(commsFile)); - sscanf(incomingCMDBuffer, "%u %u %u", + sscanf(incomingCMDBuffer, "%u %u %u", &pDestMemory, &Count, &dwExpectedErrorCode); - if (argc > 1) + if (argc > 1) { - Trace("Preparing to write to %u bytes @ %u ('%s')\n", + Trace("Preparing to write to %u bytes @ %u ('%s')\n", Count, pDestMemory, incomingCMDBuffer); } @@ -147,12 +147,12 @@ PALTEST(debug_api_WriteProcessMemory_test3_paltest_writeprocessmemory_test3, "de memset(pSrcMemory, nextValue, Count); /* do the work */ - dwRet = WriteProcessMemory(pi.hProcess, + dwRet = WriteProcessMemory(pi.hProcess, pDestMemory, pSrcMemory, Count, &wpmCount); - + if(dwRet != 0) { Trace("ERROR: Situation: '%s', return code: %u, bytes 'written': %u\n", @@ -162,7 +162,7 @@ PALTEST(debug_api_WriteProcessMemory_test3_paltest_writeprocessmemory_test3, "de "not completely accessible.\n"); success = FALSE; } - + if(GetLastError() != dwExpectedErrorCode) { Trace("ERROR: GetLastError() should have returned " @@ -172,12 +172,12 @@ PALTEST(debug_api_WriteProcessMemory_test3_paltest_writeprocessmemory_test3, "de } free(pSrcMemory); - doneIteration: + doneIteration: PEDANTIC(ResetEvent, (hEvFromHelper)); PEDANTIC(SetEvent, (hEvToHelper)); } - + /* wait for the child process to complete */ WaitForSingleObject ( pi.hProcess, TIMEOUT ); /* this may return a failure code on a success path */ @@ -185,8 +185,8 @@ PALTEST(debug_api_WriteProcessMemory_test3_paltest_writeprocessmemory_test3, "de /* check the exit code from the process */ if( ! GetExitCodeProcess( pi.hProcess, &dwExitCode ) ) { - Trace( "GetExitCodeProcess call failed with error code %u\n", - GetLastError() ); + Trace( "GetExitCodeProcess call failed with error code %u\n", + GetLastError() ); dwExitCode = FAIL; } if(!success) diff --git a/src/coreclr/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.cpp b/src/coreclr/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.cpp index 06af62f9f3a29..6723f19db3162 100644 --- a/src/coreclr/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.cpp +++ b/src/coreclr/pal/tests/palsuite/file_io/CreateFileA/test1/CreateFileA.cpp @@ -20,7 +20,7 @@ BOOL Cleanup_CreateFileA_test1(void) // loop through all accesses, modes, dispositions and flags for (i=0; i<4*8*4*5; ++i) { - sprintf_s(FileName, _countof(FileName), "test%03d.txt", i); + sprintf_s(FileName, ARRAY_SIZE(FileName), "test%03d.txt", i); if (DeleteFileA(FileName) == FALSE) { if (GetLastError() != ERROR_FILE_NOT_FOUND) { bRet = FALSE; @@ -97,7 +97,7 @@ PALTEST(file_io_CreateFileA_test1_paltest_createfilea_test1, "file_io/CreateFile // creation disp loop for (l = 0; l < 5; l++) { - sprintf_s(lpFileName, _countof(lpFileName), "test%03d.txt", nCounter); + sprintf_s(lpFileName, ARRAY_SIZE(lpFileName), "test%03d.txt", nCounter); hFile = CreateFile(lpFileName, dwDesiredAccess[i], dwShareMode[j], diff --git a/src/coreclr/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.cpp b/src/coreclr/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.cpp index 38d7f5fc9c566..f256a84c56c8a 100644 --- a/src/coreclr/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.cpp +++ b/src/coreclr/pal/tests/palsuite/file_io/CreateFileW/test1/CreateFileW.cpp @@ -20,7 +20,7 @@ BOOL Cleanup_CreateFileW_test1(void) // loop through all accesses, modes, dispositions and flags for (i=0; i<4*8*4*5; ++i) { - sprintf_s(FileName, _countof(FileName), "test%03d.txt", i); + sprintf_s(FileName, ARRAY_SIZE(FileName), "test%03d.txt", i); if (DeleteFileA(FileName) == FALSE) { if (GetLastError() != ERROR_FILE_NOT_FOUND) { bRet = FALSE; @@ -98,7 +98,7 @@ PALTEST(file_io_CreateFileW_test1_paltest_createfilew_test1, "file_io/CreateFile // creation disp loop for (l = 0; l < 5; l++) { - sprintf_s(string, _countof(string), "test%03d.txt", nCounter); + sprintf_s(string, ARRAY_SIZE(string), "test%03d.txt", nCounter); lpFileName = convert(string); hFile = CreateFileW(lpFileName, dwDesiredAccess[i], diff --git a/src/coreclr/pal/tests/palsuite/file_io/GetTempFileNameA/test1/GetTempFileNameA.cpp b/src/coreclr/pal/tests/palsuite/file_io/GetTempFileNameA/test1/GetTempFileNameA.cpp index e93d2d9840cbd..96d45cd90ccfa 100644 --- a/src/coreclr/pal/tests/palsuite/file_io/GetTempFileNameA/test1/GetTempFileNameA.cpp +++ b/src/coreclr/pal/tests/palsuite/file_io/GetTempFileNameA/test1/GetTempFileNameA.cpp @@ -46,7 +46,7 @@ PALTEST(file_io_GetTempFileNameA_test1_paltest_gettempfilenamea_test1, "file_io/ if (GetFileAttributesA(szReturnedName) == -1) { Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed on the " - "returned temp file \"%s\" with error code: %ld.\n", + "returned temp file \"%s\" with error code: %ld.\n", szReturnedName, GetLastError()); } @@ -71,14 +71,14 @@ PALTEST(file_io_GetTempFileNameA_test1_paltest_gettempfilenamea_test1, "file_io/ if (GetFileAttributesA(szReturnedName) == -1) { Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed on the " - "returned temp file \"%s\" with error code: %ld.\n", + "returned temp file \"%s\" with error code: %ld.\n", szReturnedName, GetLastError()); } if (DeleteFileA(szReturnedName) != TRUE) { Fail("GetTempFileNameA: ERROR -> DeleteFileW failed to delete" - "the created temp \"%s\" file with error code: %ld.\n", + "the created temp \"%s\" file with error code: %ld.\n", szReturnedName, GetLastError()); } @@ -97,13 +97,13 @@ PALTEST(file_io_GetTempFileNameA_test1_paltest_gettempfilenamea_test1, "file_io/ if (GetFileAttributesA(szReturnedName) == -1) { Fail("GetTempFileNameA: ERROR -> GetFileAttributes failed on the " - "returned temp file \"%s\" with error code: %ld.\n", + "returned temp file \"%s\" with error code: %ld.\n", szReturnedName, GetLastError()); } /* now verify that it only used the first 3 characters of the prefix */ - sprintf_s(szTempString, _countof(szTempString), "%s\\%s", szDot, szLongValidPrefix); + sprintf_s(szTempString, ARRAY_SIZE(szTempString), "%s\\%s", szDot, szLongValidPrefix); if (strncmp(szTempString, szReturnedName, 6) == 0) { Fail("GetTempFileNameA: ERROR -> It appears that an improper prefix " @@ -113,7 +113,7 @@ PALTEST(file_io_GetTempFileNameA_test1_paltest_gettempfilenamea_test1, "file_io/ if (DeleteFileA(szReturnedName) != TRUE) { Fail("GetTempFileNameA: ERROR -> DeleteFileW failed to delete" - "the created temp file \"%s\" with error code: %ld.\n", + "the created temp file \"%s\" with error code: %ld.\n", szReturnedName, GetLastError()); } diff --git a/src/coreclr/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp b/src/coreclr/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp index 0d6371cd85974..5653609154ecc 100644 --- a/src/coreclr/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp +++ b/src/coreclr/pal/tests/palsuite/file_io/GetTempFileNameW/test1/GetTempFileNameW.cpp @@ -103,7 +103,7 @@ PALTEST(file_io_GetTempFileNameW_test1_paltest_gettempfilenamew_test1, "file_io/ } // now verify that it only used the first 3 characters of the prefix - swprintf_s(wTempString, _countof(wTempString), convert("%s\\%s"), wPath, wPrefix); + swprintf_s(wTempString, ARRAY_SIZE(wTempString), convert("%s\\%s"), wPath, wPrefix); if (memcmp(wTempString, wReturnedName, wcslen(wTempString)*sizeof(WCHAR)) == 0) { free (wPath); diff --git a/src/coreclr/pal/tests/palsuite/file_io/SearchPathW/test1/SearchPathW.cpp b/src/coreclr/pal/tests/palsuite/file_io/SearchPathW/test1/SearchPathW.cpp index aa9e3bee6baa9..a14cd04115f97 100644 --- a/src/coreclr/pal/tests/palsuite/file_io/SearchPathW/test1/SearchPathW.cpp +++ b/src/coreclr/pal/tests/palsuite/file_io/SearchPathW/test1/SearchPathW.cpp @@ -133,7 +133,7 @@ PALTEST(file_io_SearchPathW_test1_paltest_searchpathw_test1, "file_io/SearchPath } memset(fileloc_SearchPathW_test1, 0, _MAX_PATH); - sprintf_s(fileloc_SearchPathW_test1, _countof(fileloc_SearchPathW_test1), "%s%s", fullPath, szFileNameExistsWithExt); + sprintf_s(fileloc_SearchPathW_test1, ARRAY_SIZE(fileloc_SearchPathW_test1), "%s%s", fullPath, szFileNameExistsWithExt); RemoveAll_SearchPathW_test1(); diff --git a/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp b/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp index bacdc92365cdd..ff18c512c4b92 100644 --- a/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp +++ b/src/coreclr/pal/tests/palsuite/filemapping_memmgt/CreateFileMappingW/test2/CreateFileMappingW.cpp @@ -33,9 +33,9 @@ PALTEST(filemapping_memmgt_CreateFileMappingW_test2_paltest_createfilemappingw_t } #if WIN32 - sprintf_s(executableFileName, _countof(executableFileName),"%s","executable.exe"); + sprintf_s(executableFileName, ARRAY_SIZE(executableFileName),"%s","executable.exe"); #else - sprintf_s(executableFileName, _countof(executableFileName),"%s","executable"); + sprintf_s(executableFileName, ARRAY_SIZE(executableFileName),"%s","executable"); #endif //conver string to a unicode one @@ -53,7 +53,7 @@ PALTEST(filemapping_memmgt_CreateFileMappingW_test2_paltest_createfilemappingw_t //free this memory free(wpFileName); - + if(INVALID_HANDLE_VALUE == FileHandle) { Fail("Failed to call CreateFile to create a file\n"); @@ -70,7 +70,7 @@ PALTEST(filemapping_memmgt_CreateFileMappingW_test2_paltest_createfilemappingw_t NULL); //unnamed object - if(NULL == FileMappingHandle) + if(NULL == FileMappingHandle) { Trace("\nFailed to call CreateFileMapping to create a mapping object!\n"); err = CloseHandle(FileHandle); diff --git a/src/coreclr/pal/tests/palsuite/loader/LoadLibraryA/test5/loadlibrarya.cpp b/src/coreclr/pal/tests/palsuite/loader/LoadLibraryA/test5/loadlibrarya.cpp index 690f1ba071c9a..beceabf82fdb6 100644 --- a/src/coreclr/pal/tests/palsuite/loader/LoadLibraryA/test5/loadlibrarya.cpp +++ b/src/coreclr/pal/tests/palsuite/loader/LoadLibraryA/test5/loadlibrarya.cpp @@ -6,7 +6,7 @@ ** Source: loadlibrarya.c ** ** Purpose: Negative test the LoadLibraryA API. -** Call LoadLibraryA by passing a module name +** Call LoadLibraryA by passing a module name ** without extension but with a trailing dot. ** ** @@ -30,13 +30,13 @@ PALTEST(loader_LoadLibraryA_test5_paltest_loadlibrarya_test5, "loader/LoadLibrar /*Module name without extension but with a trailing dot*/ #if WIN32 - sprintf_s(ModuleName, _countof(ModuleName), "%s", "rotor_pal."); + sprintf_s(ModuleName, ARRAY_SIZE(ModuleName), "%s", "rotor_pal."); #else /* Under FreeBSD */ - sprintf_s(ModuleName, _countof(ModuleName), "%s", "librotor_pal."); + sprintf_s(ModuleName, ARRAY_SIZE(ModuleName), "%s", "librotor_pal."); #endif - /* load a module which does not have the file extension, + /* load a module which does not have the file extension, * but has a trailing dot */ ModuleHandle = LoadLibraryA(ModuleName); diff --git a/src/coreclr/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.cpp b/src/coreclr/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.cpp index 33b46fb0a4064..e6c97ad555df7 100644 --- a/src/coreclr/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.cpp +++ b/src/coreclr/pal/tests/palsuite/loader/LoadLibraryW/test5/loadlibraryw.cpp @@ -6,7 +6,7 @@ ** Source: loadlibraryw.c ** ** Purpose: Negative test the LoadLibraryW API. -** Call LoadLibraryW by passing a module name +** Call LoadLibraryW by passing a module name ** without extension but with a trailing dot. ** ** @@ -32,9 +32,9 @@ PALTEST(loader_LoadLibraryW_test5_paltest_loadlibraryw_test5, "loader/LoadLibrar /*Module name without extension but with a trailing dot*/ #if WIN32 - sprintf_s(ModuleName, _countof(ModuleName),"%s","rotor_pal."); + sprintf_s(ModuleName, ARRAY_SIZE(ModuleName),"%s","rotor_pal."); #else - sprintf_s(ModuleName, _countof(ModuleName),"%s","librotor_pal."); + sprintf_s(ModuleName, ARRAY_SIZE(ModuleName),"%s","librotor_pal."); #endif /* convert a normal string to a wide one */ @@ -52,7 +52,7 @@ PALTEST(loader_LoadLibraryW_test5_paltest_loadlibraryw_test5, "loader/LoadLibrar "call LoadLibraryW with module name which does not have " "extension except a trailing dot, a NULL module handle is" "expected, but no NULL module handle is returned, " - "error code = %u\n", GetLastError()); + "error code = %u\n", GetLastError()); /* decrement the reference count of the loaded dll */ err = FreeLibrary(ModuleHandle); diff --git a/src/coreclr/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.cpp index 13f8176f3e646..ea9cbb331c101 100644 --- a/src/coreclr/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/locale_info/GetLocaleInfoW/test1/test1.cpp @@ -5,7 +5,7 @@ ** ** Source: test1.c ** -** Purpose: Tests that GetLocaleInfoW gives the correction information for +** Purpose: Tests that GetLocaleInfoW gives the correction information for ** LOCALE_NEUTRAL. ** ** @@ -14,15 +14,13 @@ #include -int Types[] = { LOCALE_SDECIMAL, LOCALE_STHOUSAND, LOCALE_ILZERO, +int Types[] = { LOCALE_SDECIMAL, LOCALE_STHOUSAND, LOCALE_ILZERO, LOCALE_SCURRENCY, LOCALE_SMONDECIMALSEP, LOCALE_SMONTHOUSANDSEP }; char *TypeStrings[] = { "LOCALE_SDECIMAL", "LOCALE_STHOUSAND", "LOCALE_ILZERO", "LOCALE_SCURRENCY", "LOCALE_SMONDECIMALSEP", "LOCALE_SMONTHOUSANDSEP" }; -#define NUM_TYPES (sizeof(Types) / sizeof(Types[0])) - -typedef WCHAR InfoStrings[NUM_TYPES][4]; +typedef WCHAR InfoStrings[ARRAY_SIZE(Types)][4]; typedef struct { @@ -32,7 +30,7 @@ typedef struct LocalInfoType Locales[] = { - {LOCALE_NEUTRAL, + {LOCALE_NEUTRAL, {{'.',0}, {',',0}, {'1',0}, {'$',0}, {'.',0}, {',',0}}}, }; @@ -40,7 +38,7 @@ int NumLocales = sizeof(Locales) / sizeof(Locales[0]); PALTEST(locale_info_GetLocaleInfoW_test1_paltest_getlocaleinfow_test1, "locale_info/GetLocaleInfoW/test1/paltest_getlocaleinfow_test1") -{ +{ WCHAR buffer[256] = { 0 }; int ret; int i,j; @@ -52,10 +50,10 @@ PALTEST(locale_info_GetLocaleInfoW_test1_paltest_getlocaleinfow_test1, "locale_i for (i=0; i -#ifndef _countof -#define _countof(a) (sizeof(a) / sizeof(a[0])) -#endif // !_countof - const char *const SessionPrefix = "Local\\"; const char *const GlobalPrefix = "Global\\"; @@ -207,7 +203,7 @@ bool StartProcess(const char *funcName) if (g_isStress) { test_strcpy(&g_processCommandLinePath[processCommandLinePathLength], " stress"); - processCommandLinePathLength += _countof("stress") - 1; + processCommandLinePathLength += STRING_LENGTH("stress"); } STARTUPINFO si; @@ -416,8 +412,8 @@ bool NameTests() // Name too long. The maximum allowed length depends on the file system, so we're not checking for that. { char name[257]; - memset(name, 'a', _countof(name) - 1); - name[_countof(name) - 1] = '\0'; + memset(name, 'a', STRING_LENGTH(name)); + name[STRING_LENGTH(name)] = '\0'; TestCreateMutex(m, name); TestAssert(m == nullptr); TestAssert(GetLastError() == ERROR_FILENAME_EXCED_RANGE); @@ -579,7 +575,7 @@ bool MutualExclusionTests() HANDLE waitHandles[] = {m2.GetHandle(), m.GetHandle()}; TestAssert( WaitForMultipleObjects( - _countof(waitHandles), + ARRAY_SIZE(waitHandles), waitHandles, false /* waitAll */, FailTimeoutMilliseconds) == @@ -587,7 +583,7 @@ bool MutualExclusionTests() TestAssert(GetLastError() == ERROR_NOT_SUPPORTED); TestAssert( WaitForMultipleObjects( - _countof(waitHandles), + ARRAY_SIZE(waitHandles), waitHandles, true /* waitAll */, FailTimeoutMilliseconds) == @@ -1114,7 +1110,7 @@ bool (*const TestList[])() = bool RunTests() { bool allPassed = true; - for (SIZE_T i = 0; i < _countof(TestList); ++i) + for (SIZE_T i = 0; i < ARRAY_SIZE(TestList); ++i) { if (!TestList[i]()) { @@ -1125,7 +1121,7 @@ bool RunTests() } DWORD g_stressDurationMilliseconds = 0; -LONG g_stressTestCounts[_countof(TestList)] = {0}; +LONG g_stressTestCounts[ARRAY_SIZE(TestList)] = {0}; LONG g_stressResult = true; DWORD PALAPI StressTest(void *arg) @@ -1154,8 +1150,8 @@ bool StressTests(DWORD durationMinutes) g_stressDurationMilliseconds = durationMinutes * (60 * 1000); // Start a thread for each test - HANDLE threadHandles[_countof(TestList)]; - for (SIZE_T i = 0; i < _countof(threadHandles); ++i) + HANDLE threadHandles[ARRAY_SIZE(TestList)]; + for (SIZE_T i = 0; i < ARRAY_SIZE(threadHandles); ++i) { TestAssert(StartThread(StressTest, reinterpret_cast(i), &threadHandles[i])); } @@ -1163,7 +1159,7 @@ bool StressTests(DWORD durationMinutes) while (true) { DWORD waitResult = - WaitForMultipleObjects(_countof(threadHandles), threadHandles, true /* bWaitAll */, 10 * 1000 /* dwMilliseconds */); + WaitForMultipleObjects(ARRAY_SIZE(threadHandles), threadHandles, true /* bWaitAll */, 10 * 1000 /* dwMilliseconds */); TestAssert(waitResult == WAIT_OBJECT_0 || waitResult == WAIT_TIMEOUT); if (waitResult == WAIT_OBJECT_0) { @@ -1171,7 +1167,7 @@ bool StressTests(DWORD durationMinutes) } Trace("'paltest_namedmutex_test1' stress test counts: "); - for (SIZE_T i = 0; i < _countof(g_stressTestCounts); ++i) + for (SIZE_T i = 0; i < ARRAY_SIZE(g_stressTestCounts); ++i) { if (i != 0) { @@ -1183,7 +1179,7 @@ bool StressTests(DWORD durationMinutes) fflush(stdout); } - for (SIZE_T i = 0; i < _countof(threadHandles); ++i) + for (SIZE_T i = 0; i < ARRAY_SIZE(threadHandles); ++i) { CloseHandle(threadHandles[i]); } diff --git a/src/coreclr/pal/tests/palsuite/threading/NamedMutex/test1/nopal.cpp b/src/coreclr/pal/tests/palsuite/threading/NamedMutex/test1/nopal.cpp index 3c18e67d021c8..d226ff5cf8d82 100644 --- a/src/coreclr/pal/tests/palsuite/threading/NamedMutex/test1/nopal.cpp +++ b/src/coreclr/pal/tests/palsuite/threading/NamedMutex/test1/nopal.cpp @@ -12,8 +12,7 @@ #include #include #include - -#define _countof(a) (sizeof(a) / sizeof(a[0])) +#include #undef PAGE_SIZE #define PAGE_SIZE (4096) @@ -58,7 +57,7 @@ bool WriteHeaderInfo(const char *path, char sharedMemoryType, char version, int // See SharedMemorySharedDataHeader for format char buffer[] = {sharedMemoryType, version}; - if (write(fd, buffer, _countof(buffer)) != _countof(buffer)) + if (write(fd, buffer, ARRAY_SIZE(buffer)) != ARRAY_SIZE(buffer)) return false; return flock(fd, LOCK_SH | LOCK_NB) == 0; diff --git a/src/coreclr/palrt/common.h b/src/coreclr/palrt/common.h index 684c134abede9..9946ed67e8d96 100644 --- a/src/coreclr/palrt/common.h +++ b/src/coreclr/palrt/common.h @@ -14,4 +14,5 @@ #include #include #include "shlwapip.h" +#include #endif // _COMMON_H_ diff --git a/src/coreclr/palrt/path.cpp b/src/coreclr/palrt/path.cpp index 7e0d2279f4a9f..51eb1514769e7 100644 --- a/src/coreclr/palrt/path.cpp +++ b/src/coreclr/palrt/path.cpp @@ -430,15 +430,15 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile) if (!lpszFile || *lpszFile==W('\0')) { // lpszFile is empty - StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszDir, ARRAYSIZE(szTemp)); + StringCchCopyNW(szTemp, ARRAY_SIZE(szTemp), lpszDir, ARRAY_SIZE(szTemp)); } else if (PathIsRelativeW(lpszFile)) { - StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszDir, ARRAYSIZE(szTemp)); + StringCchCopyNW(szTemp, ARRAY_SIZE(szTemp), lpszDir, ARRAY_SIZE(szTemp)); pszT = PathAddBackslashW(szTemp); if (pszT) { - size_t iRemaining = ARRAYSIZE(szTemp) - (pszT - szTemp); + size_t iRemaining = ARRAY_SIZE(szTemp) - (pszT - szTemp); if (wcslen(lpszFile) < iRemaining) { @@ -456,7 +456,7 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile) } else if (IsPathSeparator(*lpszFile) && !PathIsUNCW(lpszFile)) { - StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszDir, ARRAYSIZE(szTemp)); + StringCchCopyNW(szTemp, ARRAY_SIZE(szTemp), lpszDir, ARRAY_SIZE(szTemp)); // FEATURE: Note that we do not check that an actual root is returned; // it is assumed that we are given valid parameters PathStripToRootW(szTemp); @@ -467,7 +467,7 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile) // Skip the backslash when copying // Note: We don't support strings longer than 4GB, but that's // okay because we already fail at MAX_PATH - int iRemaining = (int)(ARRAYSIZE(szTemp) - (pszT - szTemp)); + int iRemaining = (int)(ARRAY_SIZE(szTemp) - (pszT - szTemp)); StringCchCopyNW(pszT, iRemaining, lpszFile+1, iRemaining); } else @@ -478,13 +478,13 @@ STDAPI_(LPWSTR) PathCombineW(LPWSTR lpszDest, LPCWSTR lpszDir, LPCWSTR lpszFile) else { // already fully qualified file part - StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszFile, ARRAYSIZE(szTemp)); + StringCchCopyNW(szTemp, ARRAY_SIZE(szTemp), lpszFile, ARRAY_SIZE(szTemp)); } } else if (lpszFile && *lpszFile) { // no dir just use file. - StringCchCopyNW(szTemp, ARRAYSIZE(szTemp), lpszFile, ARRAYSIZE(szTemp)); + StringCchCopyNW(szTemp, ARRAY_SIZE(szTemp), lpszFile, ARRAY_SIZE(szTemp)); } // diff --git a/src/coreclr/palrt/shlwapip.h b/src/coreclr/palrt/shlwapip.h index a34c923c346b5..490d73f36a9d9 100644 --- a/src/coreclr/palrt/shlwapip.h +++ b/src/coreclr/palrt/shlwapip.h @@ -12,9 +12,6 @@ #ifndef SHLWAPIP_H_INCLUDED #define SHLWAPIP_H_INCLUDED -#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0])) -#define SIZECHARS(sz) (sizeof(sz)/sizeof(sz[0])) - #define SIZEOF(x) sizeof(x) #define PRIVATE #define PUBLIC diff --git a/src/coreclr/tools/StressLogAnalyzer/StressLogAnalyzer.cpp b/src/coreclr/tools/StressLogAnalyzer/StressLogAnalyzer.cpp index 466a536fb1752..42ee883921ed3 100644 --- a/src/coreclr/tools/StressLogAnalyzer/StressLogAnalyzer.cpp +++ b/src/coreclr/tools/StressLogAnalyzer/StressLogAnalyzer.cpp @@ -172,7 +172,7 @@ int wmain(int argc, wchar_t *argv[]) } if (runAgain) { - int largc = ParseCommandLine(&s[1], largv, _countof(largv)); + int largc = ParseCommandLine(&s[1], largv, ARRAY_SIZE(largv)); if (largc > 0) { argc = largc; diff --git a/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin/stressLogDump.cpp b/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin/stressLogDump.cpp index 6d903e622ff0d..2b3c1f884a3a2 100644 --- a/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin/stressLogDump.cpp +++ b/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin/stressLogDump.cpp @@ -2,15 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // ==++== -// - -// +// + +// // ==--== #include "pch.h" #include "strike.h" #include "util.h" -#include +#include #include #ifndef STRESS_LOG @@ -25,11 +25,11 @@ void GcHistAddLog(LPCSTR msg, StressMsg* stressMsg); /*********************************************************************************/ -static const WCHAR* getTime(const FILETIME* time, __out_ecount (buffLen) WCHAR* buff, int buffLen) +static const WCHAR* getTime(const FILETIME* time, __out_ecount (buffLen) WCHAR* buff, int buffLen) { SYSTEMTIME systemTime; static const WCHAR badTime[] = W("BAD TIME"); - + if (!FileTimeToSystemTime(time, &systemTime)) return badTime; @@ -48,21 +48,21 @@ static const WCHAR* getTime(const FILETIME* time, __out_ecount (buffLen) WCHAR* if (ret == 0) return badTime; #endif // FEATURE_PAL else - + return buff; } /*********************************************************************************/ -static inline __int64& toInt64(FILETIME& t) +static inline __int64& toInt64(FILETIME& t) { return *((__int64 *) &t); } /*********************************************************************************/ -ThreadStressLog* ThreadStressLog::FindLatestThreadLog() const +ThreadStressLog* ThreadStressLog::FindLatestThreadLog() const { const ThreadStressLog* latestLog = 0; - for (const ThreadStressLog* ptr = this; ptr != NULL; ptr = ptr->next) + for (const ThreadStressLog* ptr = this; ptr != NULL; ptr = ptr->next) { if (ptr->readPtr != NULL) if (latestLog == 0 || ptr->readPtr->timeStamp > latestLog->readPtr->timeStamp) @@ -87,18 +87,18 @@ const char *getFacilityName(DWORD_PTR lf) } else if ((((DWORD)lf) & (LF_ALWAYS | 0xfffe | LF_GC)) == (LF_ALWAYS | LF_GC)) { - sprintf_s<_countof(buff)>(buff, "`GC l=%d`", (lf >> 16) & 0x7fff); + sprintf_s(buff, "`GC l=%d`", (lf >> 16) & 0x7fff); return buff; } - else + else { buff[1] = '\0'; for ( int i = 0; i < 32; ++i ) { if ( lf & 0x1 ) { - strcat_s ( buff, _countof(buff), &(facilities[i].lfName[3]) ); - strcat_s ( buff, _countof(buff), "`" ); + strcat_s ( buff, ARRAY_SIZE(buff), &(facilities[i].lfName[3]) ); + strcat_s ( buff, ARRAY_SIZE(buff), "`" ); } lf >>= 1; } @@ -131,10 +131,10 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou const SIZE_T capacity_buff = 2048; LPWSTR buff = (LPWSTR)alloca(capacity_buff * sizeof(WCHAR)); static char formatCopy[256]; - + int iArgCount = 0; - - strcpy_s(formatCopy, _countof(formatCopy), format); + + strcpy_s(formatCopy, ARRAY_SIZE(formatCopy), format); char* ptr = formatCopy; format = formatCopy; for(;;) @@ -146,24 +146,24 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou ptr[-1] = '}'; else if (c == '}') ptr[-1] = '{'; - else if (c == '%') + else if (c == '%') { argsPtr++; // This format will consume one of the args - if (*ptr == '%') + if (*ptr == '%') { ptr++; // skip the whole %% - --argsPtr; // except for a %% + --argsPtr; // except for a %% } - else if (*ptr == 'p') + else if (*ptr == 'p') { // It is a %p ptr++; - if (isalpha(*ptr)) + if (isalpha(*ptr)) { // It is a special %p formatter // Print the string up to that point c = *ptr; *ptr = 0; // Terminate the string temporarily vfprintf(file, format, (va_list)args); - *ptr = c; // Put it back + *ptr = c; // Put it back // move the argument pointers past the part the was printed format = ptr + 1; @@ -171,7 +171,7 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou iArgCount = -1; DWORD_PTR arg = DWORD_PTR(argsPtr[-1]); - switch (c) + switch (c) { case 'M': // format as a method Desc if (g_bDacBroken) @@ -180,12 +180,12 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou } else { - if (!IsMethodDesc(arg)) + if (!IsMethodDesc(arg)) { - if (arg != 0) + if (arg != 0) fprintf(file, " (BAD Method)"); } - else + else { DacpMethodDescData MethodDescData; MethodDescData.Request(g_sos,(CLRDATA_ADDRESS)arg); @@ -193,7 +193,7 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou static WCHAR wszNameBuffer[1024]; // should be large enough if (g_sos->GetMethodDescName(arg, 1024, wszNameBuffer, NULL) != S_OK) { - wcscpy_s(wszNameBuffer, _countof(wszNameBuffer), W("UNKNOWN METHODDESC")); + wcscpy_s(wszNameBuffer, ARRAY_SIZE(wszNameBuffer), W("UNKNOWN METHODDESC")); } wcscpy_s(buff, capacity_buff, wszNameBuffer); @@ -210,16 +210,16 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou } else { - if (arg & 3) + if (arg & 3) { - arg &= ~3; // GC steals the lower bits for its own use during GC. + arg &= ~3; // GC steals the lower bits for its own use during GC. fprintf(file, " Low Bit(s) Set"); } if (!IsMethodTable(arg)) { fprintf(file, " (BAD MethodTable)"); } - else + else { NameForMT_s (arg, g_mdName, mdNameLen); fprintf(file, " (%S)", g_mdName); @@ -227,14 +227,14 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou } break; - case 'V': - { // format as a C vtable pointer + case 'V': + { // format as a C vtable pointer char Symbol[1024]; ULONG64 Displacement; HRESULT hr = g_ExtSymbols->GetNameByOffset(TO_CDADDR(arg), Symbol, 1024, NULL, &Displacement); - if (SUCCEEDED(hr) && Symbol[0] != '\0' && Displacement == 0) + if (SUCCEEDED(hr) && Symbol[0] != '\0' && Displacement == 0) fprintf(file, " (%s)", Symbol); - else + else fprintf(file, " (Unknown VTable)"); } break; @@ -243,7 +243,7 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou char Symbol[1024]; ULONG64 Displacement; HRESULT hr = g_ExtSymbols->GetNameByOffset (TO_CDADDR(arg), Symbol, 1024, NULL, &Displacement); - if (SUCCEEDED (hr) && Symbol[0] != '\0') + if (SUCCEEDED (hr) && Symbol[0] != '\0') { fprintf (file, " (%s", Symbol); if (Displacement) @@ -252,16 +252,16 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou } fprintf (file, ")"); } - else - fprintf (file, " (Unknown function)"); + else + fprintf (file, " (Unknown function)"); } break; default: - format = ptr; // Just print the character. + format = ptr; // Just print the character. } } } - else if (*ptr == 's' || (*ptr == 'h' && *(ptr+1) == 's' && ++ptr)) + else if (*ptr == 's' || (*ptr == 'h' && *(ptr+1) == 's' && ++ptr)) { HRESULT hr; @@ -269,16 +269,16 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou // since we may have more than one %s in the format ULONG cbStrBuf = 256; char* strBuf = (char *)_alloca(cbStrBuf); - + hr = memCallBack->ReadVirtual(TO_CDADDR((char* )args[iArgCount]), strBuf, cbStrBuf, 0); - if (hr != S_OK) + if (hr != S_OK) { - strcpy_s(strBuf, cbStrBuf, "(#Could not read address of string#)"); + strcpy_s(strBuf, cbStrBuf, "(#Could not read address of string#)"); } - args[iArgCount] = strBuf; + args[iArgCount] = strBuf; } - else if (*ptr == 'S' || (*ptr == 'l' && *(ptr+1) == 's' && ++ptr)) + else if (*ptr == 'S' || (*ptr == 'l' && *(ptr+1) == 's' && ++ptr)) { HRESULT hr; @@ -286,7 +286,7 @@ void formatOutput(struct IDebugDataSpaces* memCallBack, ___in FILE* file, __inou // since we may have more than one %s in the format ULONG cbWstrBuf = 256 * sizeof(WCHAR); WCHAR* wstrBuf = (WCHAR *)_alloca(cbWstrBuf); - + hr = memCallBack->ReadVirtual(TO_CDADDR((char* )args[iArgCount]), wstrBuf, cbWstrBuf, 0); if (hr != S_OK) { @@ -307,7 +307,7 @@ void __cdecl vDoOut(BOOL bToConsole, FILE* file, PCSTR Format, ...) { va_list Args; - + va_start(Args, Format); if (bToConsole) @@ -324,20 +324,20 @@ vDoOut(BOOL bToConsole, FILE* file, PCSTR Format, ...) /*********************************************************************************/ -HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugDataSpaces* memCallBack) +HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugDataSpaces* memCallBack) { ULONG64 g_hThisInst; BOOL bDoGcHist = (fileName == NULL); FILE* file = NULL; - // Fetch the circular buffer bookkeeping data + // Fetch the circular buffer bookkeeping data StressLog inProcLog; HRESULT hr = memCallBack->ReadVirtual(UL64_TO_CDA(outProcLog), &inProcLog, sizeof(StressLog), 0); - if (hr != S_OK) + if (hr != S_OK) { return hr; } - if (inProcLog.logs.Load() == NULL || inProcLog.moduleOffset == 0) + if (inProcLog.logs.Load() == NULL || inProcLog.moduleOffset == 0) { ExtOut ( "----- No thread logs in the image: The stress log was probably not initialized correctly. -----\n"); return S_FALSE; @@ -394,7 +394,7 @@ HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugD // if this is the first time through, inProcPtr->chunkListHead may still contain // the out-of-process value for the chunk pointer. NULL it to avoid AVs if (TO_CDADDR(inProcPtr->chunkListHead) == outProcListHead) - inProcPtr->chunkListHead = NULL; + inProcPtr->chunkListHead = NULL; delete inProcPtr; goto FREE_MEM; } @@ -405,7 +405,7 @@ HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugD inProcPtr->curWriteChunk = inProcChunkPtr; curPtrInitialized = TRUE; } - + outProcChunkPtr = TO_CDADDR(inProcChunkPtr->next); *chunksPtr = inProcChunkPtr; chunksPtr = &inProcChunkPtr->next; @@ -417,9 +417,9 @@ HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugD inProcChunkPtr->next = inProcPtr->chunkListHead; inProcPtr->chunkListHead->prev = inProcChunkPtr; inProcPtr->chunkListTail = inProcChunkPtr; - } + } } while (outProcChunkPtr != outProcListHead); - + if (!curPtrInitialized) { delete inProcPtr; @@ -478,28 +478,28 @@ HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugD void** args; unsigned msgCtr; msgCtr = 0; - for (;;) + for (;;) { ThreadStressLog* latestLog = logs->FindLatestThreadLog(); - if (IsInterrupt()) + if (IsInterrupt()) { vDoOut(bDoGcHist, file, "----- Interrupted by user -----\n"); break; } - if (latestLog == 0) + if (latestLog == 0) { break; } StressMsg* latestMsg = latestLog->readPtr; - if (latestMsg->formatOffset != 0 && !latestLog->CompletedDump()) + if (latestMsg->formatOffset != 0 && !latestLog->CompletedDump()) { TADDR taFmt = (latestMsg->formatOffset) + TO_TADDR(g_hThisInst); hr = memCallBack->ReadVirtual(TO_CDADDR(taFmt), format, 256, 0); - if (hr != S_OK) - strcpy_s(format, _countof(format), "Could not read address of format string"); + if (hr != S_OK) + strcpy_s(format, ARRAY_SIZE(format), "Could not read address of format string"); double deltaTime = ((double) (latestMsg->timeStamp - inProcLog.startTimeStamp)) / inProcLog.tickFrequency; if (bDoGcHist) @@ -508,7 +508,7 @@ HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugD { latestLog->threadId = (unsigned)(size_t)latestMsg->args[0]; } - GcHistAddLog(format, latestMsg); + GcHistAddLog(format, latestMsg); } else { @@ -517,7 +517,7 @@ HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugD fprintf (file, "Task was switched from %x\n", (unsigned)(size_t)latestMsg->args[0]); latestLog->threadId = (unsigned)(size_t)latestMsg->args[0]; } - else + else { args = latestMsg->args; formatOutput(memCallBack, file, format, (unsigned)latestLog->threadId, deltaTime, latestMsg->facility, args); @@ -536,11 +536,11 @@ HRESULT StressLog::Dump(ULONG64 outProcLog, const char* fileName, struct IDebugD } } - if (msgCtr % 64 == 0) + if (msgCtr % 64 == 0) { ExtOut("."); // to indicate progress - if (msgCtr % (64*64) == 0) - ExtOut("\n"); + if (msgCtr % (64*64) == 0) + ExtOut("\n"); } } ExtOut("\n"); diff --git a/src/coreclr/tools/metainfo/mdinfo.cpp b/src/coreclr/tools/metainfo/mdinfo.cpp index 6ddf1ea96be33..24c782b4076d9 100644 --- a/src/coreclr/tools/metainfo/mdinfo.cpp +++ b/src/coreclr/tools/metainfo/mdinfo.cpp @@ -22,8 +22,6 @@ #define ENUM_BUFFER_SIZE 10 #define TAB_SIZE 8 -#define NumItems(s) (sizeof(s) / sizeof(s[0])) - #define ISFLAG(p,x) if (Is##p##x(flags)) strcat_s(sFlags,STRING_BUFFER_LEN, "["#x "] "); extern HRESULT _FillVariant( @@ -219,8 +217,8 @@ MDInfo::MDInfo(IMetaDataImport2 *pImport, IMetaDataAssemblyImport *pAssemblyImpo { // This constructor is specific to ILDASM/MetaInfo integration _ASSERTE(pImport != NULL); - _ASSERTE(NumItems(g_szMapElementType) == NumItems(g_szMapUndecorateType)); - _ASSERTE(NumItems(g_szMapElementType) == ELEMENT_TYPE_MAX); + _ASSERTE(ARRAY_SIZE(g_szMapElementType) == ARRAY_SIZE(g_szMapUndecorateType)); + _ASSERTE(ARRAY_SIZE(g_szMapElementType) == ELEMENT_TYPE_MAX); Init(inPBFn, (DUMP_FILTER)DumpFilter); @@ -243,8 +241,8 @@ MDInfo::MDInfo(IMetaDataDispenserEx *pDispenser, LPCWSTR szScope, strPassBackFn VARIANT value; _ASSERTE(pDispenser != NULL && inPBFn != NULL); - _ASSERTE(NumItems(g_szMapElementType) == NumItems(g_szMapUndecorateType)); - _ASSERTE(NumItems(g_szMapElementType) == ELEMENT_TYPE_MAX); + _ASSERTE(ARRAY_SIZE(g_szMapElementType) == ARRAY_SIZE(g_szMapUndecorateType)); + _ASSERTE(ARRAY_SIZE(g_szMapElementType) == ELEMENT_TYPE_MAX); Init(inPBFn, (DUMP_FILTER)DumpFilter); @@ -277,8 +275,8 @@ MDInfo::MDInfo(IMetaDataDispenserEx *pDispenser, LPCWSTR szScope, strPassBackFn MDInfo::MDInfo(IMetaDataDispenserEx *pDispenser, PBYTE pbMetaData, DWORD dwSize, strPassBackFn inPBFn, ULONG DumpFilter) { _ASSERTE(pDispenser != NULL && inPBFn != NULL); - _ASSERTE(NumItems(g_szMapElementType) == NumItems(g_szMapUndecorateType)); - _ASSERTE(NumItems(g_szMapElementType) == ELEMENT_TYPE_MAX); + _ASSERTE(ARRAY_SIZE(g_szMapElementType) == ARRAY_SIZE(g_szMapUndecorateType)); + _ASSERTE(ARRAY_SIZE(g_szMapElementType) == ELEMENT_TYPE_MAX); Init(inPBFn, (DUMP_FILTER)DumpFilter); @@ -617,7 +615,7 @@ void MDInfo::DisplayMemberRefs(mdToken tkParent, const char *preFix) while (SUCCEEDED(hr = m_pImport->EnumMemberRefs( &memRefEnum, tkParent, - memRefs, NumItems(memRefs), &count)) && + memRefs, ARRAY_SIZE(memRefs), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -644,7 +642,7 @@ void MDInfo::DisplayTypeRefs() HRESULT hr; while (SUCCEEDED(hr = m_pImport->EnumTypeRefs( &typeRefEnum, - typeRefs, NumItems(typeRefs), &count)) && + typeRefs, ARRAY_SIZE(typeRefs), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -667,7 +665,7 @@ void MDInfo::DisplayTypeSpecs() HRESULT hr; while (SUCCEEDED(hr = m_pImport->EnumTypeSpecs( &typespecEnum, - typespecs, NumItems(typespecs), &count)) && + typespecs, ARRAY_SIZE(typespecs), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -692,7 +690,7 @@ void MDInfo::DisplayMethodSpecs() ///// HACK until I implement EnumMethodSpecs! ///// while (SUCCEEDED(hr = m_pImport->EnumMethodSpecs( &MethodSpecEnum, -///// MethodSpecs, NumItems(MethodSpecs), &count)) && +///// MethodSpecs, ARRAY_SIZE(MethodSpecs), &count)) && ///// count > 0) for (ULONG rid=1; m_pImport->IsValidToken(TokenFromRid(rid, mdtMethodSpec)); ++rid) { @@ -723,7 +721,7 @@ void MDInfo::DisplayTypeDefs() HRESULT hr; while (SUCCEEDED(hr = m_pImport->EnumTypeDefs( &typeDefEnum, - typeDefs, NumItems(typeDefs), &count)) && + typeDefs, ARRAY_SIZE(typeDefs), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -748,7 +746,7 @@ void MDInfo::DisplayModuleRefs() HRESULT hr; while (SUCCEEDED(hr = m_pImport->EnumModuleRefs( &moduleRefEnum, - moduleRefs, NumItems(moduleRefs), &count)) && + moduleRefs, ARRAY_SIZE(moduleRefs), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -793,7 +791,7 @@ void MDInfo::DisplaySignatures() HRESULT hr; while (SUCCEEDED(hr = m_pImport->EnumSignatures( &signatureEnum, - signatures, NumItems(signatures), &count)) && + signatures, ARRAY_SIZE(signatures), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -1051,7 +1049,7 @@ void MDInfo::DisplayMethods(mdTypeDef inTypeDef) while (SUCCEEDED(hr = m_pImport->EnumMethods( &methodEnum, inTypeDef, - methods, NumItems(methods), &count)) && + methods, ARRAY_SIZE(methods), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -1088,7 +1086,7 @@ void MDInfo::DisplayFields(mdTypeDef inTypeDef, COR_FIELD_OFFSET *rFieldOffset, while (SUCCEEDED(hr = m_pImport->EnumFields( &fieldEnum, inTypeDef, - fields, NumItems(fields), &count)) && + fields, ARRAY_SIZE(fields), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -1144,7 +1142,7 @@ void MDInfo::DisplayMethodImpls(mdTypeDef inTypeDef) while (SUCCEEDED(hr = m_pImport->EnumMethodImpls( &methodImplEnum, inTypeDef, - rtkMethodBody, rtkMethodDecl, NumItems(rtkMethodBody), &count)) && + rtkMethodBody, rtkMethodDecl, ARRAY_SIZE(rtkMethodBody), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -1177,7 +1175,7 @@ void MDInfo::DisplayParamInfo(mdParamDef inParamDef) #ifdef FEATURE_COMINTEROP ::VariantInit(&defValue); #endif - HRESULT hr = m_pImport->GetParamProps( inParamDef, &md, &num, paramName, NumItems(paramName), + HRESULT hr = m_pImport->GetParamProps( inParamDef, &md, &num, paramName, ARRAY_SIZE(paramName), &nameLen, &flags, &dwCPlusFlags, &pValue, &cbValue); if (FAILED(hr)) Error("GetParamProps failed.", hr); @@ -1222,7 +1220,7 @@ void MDInfo::DisplayParams(mdMethodDef inMethodDef) while (SUCCEEDED(hr = m_pImport->EnumParams( ¶mEnum, inMethodDef, - params, NumItems(params), &count)) && + params, ARRAY_SIZE(params), &count)) && count > 0) { if (first) @@ -1250,7 +1248,7 @@ void MDInfo::DisplayGenericParams(mdToken tk, const char *prefix) while (SUCCEEDED(hr = m_pImport->EnumGenericParams( ¶mEnum, tk, - params, NumItems(params), &count)) && + params, ARRAY_SIZE(params), &count)) && count > 0) { if (first) @@ -1282,14 +1280,14 @@ void MDInfo::DisplayGenericParamInfo(mdGenericParam tkParam, const char *prefix) mdToken owner; bool first = true; - HRESULT hr = m_pImport->GetGenericParamProps(tkParam, &ulSeq, &flags, &tkOwner, NULL, paramName, NumItems(paramName), &nameLen); + HRESULT hr = m_pImport->GetGenericParamProps(tkParam, &ulSeq, &flags, &tkOwner, NULL, paramName, ARRAY_SIZE(paramName), &nameLen); if (FAILED(hr)) Error("GetGenericParamProps failed.", hr); VWriteLine("%s\t(%ld) GenericParamToken : (%08x) Name : %ls flags: %08x Owner: %08x", prefix, ulSeq, tkParam, paramName, flags, tkOwner); // Any constraints for the GenericParam while (SUCCEEDED(hr = m_pImport->EnumGenericParamConstraints(&constraintEnum, tkParam, - constraints, NumItems(constraints), &count)) && + constraints, ARRAY_SIZE(constraints), &count)) && count > 0) { if (first) @@ -1415,7 +1413,7 @@ void MDInfo::DisplayTypeDefProps(mdTypeDef inTypeDef) VWriteLine("\tTypDefName: %ls (%8.8X)",typeDefName,inTypeDef); VWriteLine("\tFlags : %s (%08x)",ClassFlags(flags, sFlags), flags); VWriteLine("\tExtends : %8.8X [%s] %ls",extends,TokenTypeName(extends), - TypeDeforRefName(extends, szTempBuf, NumItems(szTempBuf))); + TypeDeforRefName(extends, szTempBuf, ARRAY_SIZE(szTempBuf))); hr = m_pImport->GetClassLayout(inTypeDef, &dwPacking, 0,0,0, &dwSize); if (hr == S_OK) @@ -1429,7 +1427,7 @@ void MDInfo::DisplayTypeDefProps(mdTypeDef inTypeDef) if (hr == S_OK) { VWriteLine("\tEnclosingClass : %ls (%8.8X)", TypeDeforRefName(tkEnclosingClass, - szTempBuf, NumItems(szTempBuf)), tkEnclosingClass); + szTempBuf, ARRAY_SIZE(szTempBuf)), tkEnclosingClass); } else if (hr == CLDB_E_RECORD_NOTFOUND) WriteLine("ERROR: EnclosingClass not found for NestedClass"); @@ -1628,7 +1626,7 @@ void MDInfo::DisplayInterfaceImpls(mdTypeDef inTypeDef) HRESULT hr; while(SUCCEEDED(hr = m_pImport->EnumInterfaceImpls( &interfaceImplEnum, - inTypeDef,interfaceImpls,NumItems(interfaceImpls), &count)) && + inTypeDef,interfaceImpls,ARRAY_SIZE(interfaceImpls), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -1657,8 +1655,8 @@ void MDInfo::DisplayInterfaceImplInfo(mdInterfaceImpl inImpl) hr = m_pImport->GetInterfaceImplProps( inImpl, &typeDef, &token); if (FAILED(hr)) Error("GetInterfaceImplProps failed.", hr); - VWriteLine("\t\tClass : %ls",TypeDeforRefName(typeDef, szTempBuf, NumItems(szTempBuf))); - VWriteLine("\t\tToken : %8.8X [%s] %ls",token,TokenTypeName(token), TypeDeforRefName(token, szTempBuf, NumItems(szTempBuf))); + VWriteLine("\t\tClass : %ls",TypeDeforRefName(typeDef, szTempBuf, ARRAY_SIZE(szTempBuf))); + VWriteLine("\t\tToken : %8.8X [%s] %ls",token,TokenTypeName(token), TypeDeforRefName(token, szTempBuf, ARRAY_SIZE(szTempBuf))); DisplayCustomAttributes(inImpl, "\t\t"); } // void MDInfo::DisplayInterfaceImplInfo() @@ -1738,8 +1736,8 @@ void MDInfo::DisplayPropertyInfo(mdProperty inProp) VWriteLine("\t\tDefltValue: %ls",VariantAsString(&defaultValue)); #endif - VWriteLine("\t\tSetter : (%08x) %ls",setter,MemberDeforRefName(setter, szTempBuf, NumItems(szTempBuf))); - VWriteLine("\t\tGetter : (%08x) %ls",getter,MemberDeforRefName(getter, szTempBuf, NumItems(szTempBuf))); + VWriteLine("\t\tSetter : (%08x) %ls",setter,MemberDeforRefName(setter, szTempBuf, ARRAY_SIZE(szTempBuf))); + VWriteLine("\t\tGetter : (%08x) %ls",getter,MemberDeforRefName(getter, szTempBuf, ARRAY_SIZE(szTempBuf))); // do something with others? VWriteLine("\t\t%ld Others",others); @@ -1762,7 +1760,7 @@ void MDInfo::DisplayProperties(mdTypeDef inTypeDef) while(SUCCEEDED(hr = m_pImport->EnumProperties( &propEnum, - inTypeDef,props,NumItems(props), &count)) && + inTypeDef,props,ARRAY_SIZE(props), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -1808,7 +1806,7 @@ void MDInfo::DisplayEventInfo(mdEvent inEvent) &fire, // [OUT] Fire method of the event otherMethod, // [OUT] other method of the event - NumItems(otherMethod), // [IN] size of rmdOtherMethod + ARRAY_SIZE(otherMethod), // [IN] size of rmdOtherMethod &totalOther); // [OUT] total number of other method of this event if (FAILED(hr)) Error("GetEventProps failed.", hr); @@ -1827,9 +1825,9 @@ void MDInfo::DisplayEventInfo(mdEvent inEvent) WCHAR szTempBuf[STRING_BUFFER_LEN]; VWriteLine("\t\tEventType : %8.8X [%s]",eventType,TokenTypeName(eventType)); - VWriteLine("\t\tAddOnMethd: (%08x) %ls",addOn,MemberDeforRefName(addOn, szTempBuf, NumItems(szTempBuf))); - VWriteLine("\t\tRmvOnMethd: (%08x) %ls",removeOn,MemberDeforRefName(removeOn, szTempBuf, NumItems(szTempBuf))); - VWriteLine("\t\tFireMethod: (%08x) %ls",fire,MemberDeforRefName(fire, szTempBuf, NumItems(szTempBuf))); + VWriteLine("\t\tAddOnMethd: (%08x) %ls",addOn,MemberDeforRefName(addOn, szTempBuf, ARRAY_SIZE(szTempBuf))); + VWriteLine("\t\tRmvOnMethd: (%08x) %ls",removeOn,MemberDeforRefName(removeOn, szTempBuf, ARRAY_SIZE(szTempBuf))); + VWriteLine("\t\tFireMethod: (%08x) %ls",fire,MemberDeforRefName(fire, szTempBuf, ARRAY_SIZE(szTempBuf))); VWriteLine("\t\t%ld OtherMethods",totalOther); @@ -1847,7 +1845,7 @@ void MDInfo::DisplayEvents(mdTypeDef inTypeDef) while(SUCCEEDED(hr = m_pImport->EnumEvents( &eventEnum, - inTypeDef,events,NumItems(events), &count)) && + inTypeDef,events,ARRAY_SIZE(events), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -2078,7 +2076,7 @@ void MDInfo::DisplayCustomAttributes(mdToken inToken, const char *preFix) HRESULT hr; while(SUCCEEDED(hr = m_pImport->EnumCustomAttributes( &customAttributeEnum, inToken, 0, - customAttributes, NumItems(customAttributes), &count)) && + customAttributes, ARRAY_SIZE(customAttributes), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -2104,7 +2102,7 @@ void MDInfo::DisplayPermissions(mdToken tk, const char *preFix) while (SUCCEEDED(hr = m_pImport->EnumPermissionSets( &permissionEnum, - tk, 0, permissions, NumItems(permissions), &count)) && + tk, 0, permissions, ARRAY_SIZE(permissions), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -2482,7 +2480,7 @@ void MDInfo::DisplayPinvokeInfo(mdToken inToken) char sFlags[STRING_BUFFER_LEN]; hr = m_pImport->GetPinvokeMap(inToken, &flags, rcImport, - NumItems(rcImport), 0, &tkModuleRef); + ARRAY_SIZE(rcImport), 0, &tkModuleRef); if (FAILED(hr)) { if (hr != CLDB_E_RECORD_NOTFOUND) @@ -2742,7 +2740,7 @@ HRESULT MDInfo::GetOneElementType(PCCOR_SIGNATURE pbSigBlob, ULONG ulSigBlob, UL // get the name of type ref. Don't care if truncated if (TypeFromToken(tk) == mdtTypeDef || TypeFromToken(tk) == mdtTypeRef) { - sprintf_s(m_tempFormatBuffer, STRING_BUFFER_LEN, " %ls",TypeDeforRefName(tk, m_szTempBuf, NumItems(m_szTempBuf))); + sprintf_s(m_tempFormatBuffer, STRING_BUFFER_LEN, " %ls",TypeDeforRefName(tk, m_szTempBuf, ARRAY_SIZE(m_szTempBuf))); IfFailGo(AddToSigBuffer(m_tempFormatBuffer)); } else @@ -3136,7 +3134,7 @@ void MDInfo::DisplayAssemblyRefs() HRESULT hr; while (SUCCEEDED(hr = m_pAssemblyImport->EnumAssemblyRefs( &assemblyRefEnum, - AssemblyRefs, NumItems(AssemblyRefs), &count)) && + AssemblyRefs, ARRAY_SIZE(AssemblyRefs), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -3227,7 +3225,7 @@ void MDInfo::DisplayFiles() HRESULT hr; while (SUCCEEDED(hr = m_pAssemblyImport->EnumFiles( &fileEnum, - Files, NumItems(Files), &count)) && + Files, ARRAY_SIZE(Files), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -3283,7 +3281,7 @@ void MDInfo::DisplayExportedTypes() HRESULT hr; while (SUCCEEDED(hr = m_pAssemblyImport->EnumExportedTypes( &comTypeEnum, - ExportedTypes, NumItems(ExportedTypes), &count)) && + ExportedTypes, ARRAY_SIZE(ExportedTypes), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -3331,7 +3329,7 @@ void MDInfo::DisplayManifestResources() HRESULT hr; while (SUCCEEDED(hr = m_pAssemblyImport->EnumManifestResources( &manifestResourceEnum, - ManifestResources, NumItems(ManifestResources), &count)) && + ManifestResources, ARRAY_SIZE(ManifestResources), &count)) && count > 0) { for (ULONG i = 0; i < count; i++, totalCount++) @@ -3415,7 +3413,7 @@ void MDInfo::DisplayUserStrings() bool bUnprint = false; // Is an unprintable character found? HRESULT hr; // A result. while (SUCCEEDED(hr = m_pImport->EnumUserStrings( &stringEnum, - Strings, NumItems(Strings), &count)) && + Strings, ARRAY_SIZE(Strings), &count)) && count > 0) { if (totalCount == 1) diff --git a/src/coreclr/utilcode/clrconfig.cpp b/src/coreclr/utilcode/clrconfig.cpp index c40ab7825b699..d4f6ec2adabaf 100644 --- a/src/coreclr/utilcode/clrconfig.cpp +++ b/src/coreclr/utilcode/clrconfig.cpp @@ -148,7 +148,7 @@ namespace bool noPrefix = CheckLookupOption(options, LookupOptions::DontPrependPrefix); if (noPrefix) { - if (namelen >= _countof(buff)) + if (namelen >= ARRAY_SIZE(buff)) { _ASSERTE(!"Environment variable name too long."); return NULL; @@ -158,8 +158,8 @@ namespace } else { - bool dotnetValid = namelen < (size_t)(_countof(buff) - 1 - LEN_OF_DOTNET_PREFIX); - bool complusValid = namelen < (size_t)(_countof(buff) - 1 - LEN_OF_COMPLUS_PREFIX); + bool dotnetValid = namelen < (size_t)(STRING_LENGTH(buff) - LEN_OF_DOTNET_PREFIX); + bool complusValid = namelen < (size_t)(STRING_LENGTH(buff) - LEN_OF_COMPLUS_PREFIX); if(!dotnetValid || !complusValid) { _ASSERTE(!"Environment variable name too long."); @@ -171,11 +171,11 @@ namespace return NULL; // Priority order is DOTNET_ and then COMPlus_. - wcscpy_s(buff, _countof(buff), DOTNET_PREFIX); + wcscpy_s(buff, ARRAY_SIZE(buff), DOTNET_PREFIX); fallbackPrefix = COMPLUS_PREFIX; } - wcscat_s(buff, _countof(buff), name); + wcscat_s(buff, ARRAY_SIZE(buff), name); FAULT_NOT_FATAL(); // We don't report OOM errors here, we return a default value. @@ -188,8 +188,8 @@ namespace DWORD len = WszGetEnvironmentVariable(buff, temp); if (len == 0 && fallbackPrefix != NULL) { - wcscpy_s(buff, _countof(buff), fallbackPrefix); - wcscat_s(buff, _countof(buff), name); + wcscpy_s(buff, ARRAY_SIZE(buff), fallbackPrefix); + wcscat_s(buff, ARRAY_SIZE(buff), name); len = WszGetEnvironmentVariable(buff, temp); } diff --git a/src/coreclr/utilcode/debug.cpp b/src/coreclr/utilcode/debug.cpp index b4f44dc989d6f..2c330a78510b6 100644 --- a/src/coreclr/utilcode/debug.cpp +++ b/src/coreclr/utilcode/debug.cpp @@ -681,7 +681,7 @@ VOID DbgAssertDialog(const char *szFile, int iLine, const char *szExpr) FAULT_NOT_FATAL(); szExprToDisplay = &g_szExprWithStack2[0]; strcpy(szExprToDisplay, szExpr); - strcat_s(szExprToDisplay, _countof(g_szExprWithStack2), "\n\n"); + strcat_s(szExprToDisplay, ARRAY_SIZE(g_szExprWithStack2), "\n\n"); GetStringFromStackLevels(1, 10, szExprToDisplay + strlen(szExprToDisplay)); fGotStackTrace = TRUE; } diff --git a/src/coreclr/utilcode/posterror.cpp b/src/coreclr/utilcode/posterror.cpp index c71d1b82e6c56..13cc996099033 100644 --- a/src/coreclr/utilcode/posterror.cpp +++ b/src/coreclr/utilcode/posterror.cpp @@ -20,10 +20,6 @@ #include -#if !defined(lengthof) -#define lengthof(x) (sizeof(x)/sizeof(x[0])) -#endif - // Local prototypes. HRESULT FillErrorInfo(LPCWSTR szMsg, DWORD dwHelpContext); @@ -123,7 +119,7 @@ HRESULT __cdecl FormatRuntimeErrorVa( // If this is one of our errors or if it is simply a resource ID, then grab the error from the rc file. if ((HRESULT_FACILITY(hrRpt) == FACILITY_URT) || (HIWORD(hrRpt) == 0)) { - hr = UtilLoadStringRC(LOWORD(hrRpt), rcBuf, NumItems(rcBuf), true); + hr = UtilLoadStringRC(LOWORD(hrRpt), rcBuf, ARRAY_SIZE(rcBuf), true); if (hr == S_OK) { _vsnwprintf_s(rcMsg, cchMsg, _TRUNCATE, rcBuf, marker); diff --git a/src/coreclr/utilcode/prettyprintsig.cpp b/src/coreclr/utilcode/prettyprintsig.cpp index e902a5fc0015f..f3ee09dd169ff 100644 --- a/src/coreclr/utilcode/prettyprintsig.cpp +++ b/src/coreclr/utilcode/prettyprintsig.cpp @@ -280,11 +280,11 @@ static PCCOR_SIGNATURE PrettyPrintType( if (TypeFromToken(tk) == mdtTypeRef) { - hr = pIMDI->GetTypeRefProps(tk, 0, rcname, NumItems(rcname), 0); + hr = pIMDI->GetTypeRefProps(tk, 0, rcname, ARRAY_SIZE(rcname), 0); } else if (TypeFromToken(tk) == mdtTypeDef) { - hr = pIMDI->GetTypeDefProps(tk, rcname, NumItems(rcname), 0, 0, 0); + hr = pIMDI->GetTypeDefProps(tk, rcname, ARRAY_SIZE(rcname), 0, 0, 0); } else { diff --git a/src/coreclr/utilcode/stacktrace.cpp b/src/coreclr/utilcode/stacktrace.cpp index 9cab6ee2d1f08..dfa07a6d36b47 100644 --- a/src/coreclr/utilcode/stacktrace.cpp +++ b/src/coreclr/utilcode/stacktrace.cpp @@ -11,6 +11,7 @@ #include "corhlpr.h" #include "utilcode.h" #include "pedecoder.h" // for IMAGE_FILE_MACHINE_NATIVE +#include //This is a workaround. We need to work with the debugger team to figure //out how the module handle of the CLR can be found in a SxS safe way. @@ -103,8 +104,6 @@ PVOID UserContext //--- Macros ------------------------------------------------------------------ // -#define COUNT_OF(x) (sizeof(x) / sizeof(x[0])) - // // Types and Constants -------------------------------------------------------- // @@ -295,9 +294,9 @@ LPSTR FillSymbolSearchPathThrows(CQuickBytes &qb) rcBuff.Append(W(';')); // Copy the defacto NT symbol path as well. - size_t sympathLength = chTotal + NumItems(DEFAULT_SYM_PATH) + 1; + size_t sympathLength = chTotal + ARRAY_SIZE(DEFAULT_SYM_PATH) + 1; // integer overflow occurred - if (sympathLength < (size_t)chTotal || sympathLength < NumItems(DEFAULT_SYM_PATH)) + if (sympathLength < (size_t)chTotal || sympathLength < ARRAY_SIZE(DEFAULT_SYM_PATH)) { return NULL; } @@ -342,7 +341,7 @@ LPSTR FillSymbolSearchPathThrows(CQuickBytes &qb) if (ch != 0 && (pathLocationLength < MAX_SYM_PATH)) { - chTotal = chTotal + ch - NumItems(STR_ENGINE_NAME); + chTotal = chTotal + ch - ARRAY_SIZE(STR_ENGINE_NAME); rcBuff.Append(W(';')); } #endif @@ -432,7 +431,7 @@ void MagicInit() // // Try to get the API entrypoints in imagehlp.dll // - for (int i = 0; i < COUNT_OF(ailFuncList); i++) + for (int i = 0; i < ARRAY_SIZE(ailFuncList); i++) { *(ailFuncList[i].ppvfn) = GetProcAddress( g_hinstImageHlp, @@ -509,12 +508,12 @@ DWORD_PTR dwAddr if (!_SymGetModuleInfo(g_hProcess, dwAddr, &mi)) { - strcpy_s(psi->achModule, _countof(psi->achModule), ""); + strcpy_s(psi->achModule, ARRAY_SIZE(psi->achModule), ""); } else { - strcpy_s(psi->achModule, _countof(psi->achModule), mi.ModuleName); - _strupr_s(psi->achModule, _countof(psi->achModule)); + strcpy_s(psi->achModule, ARRAY_SIZE(psi->achModule), mi.ModuleName); + _strupr_s(psi->achModule, ARRAY_SIZE(psi->achModule)); } CHAR rgchUndec[256]; @@ -538,7 +537,7 @@ DWORD_PTR dwAddr { pszSymbol = sym.Name; - if (_SymUnDName(&sym, rgchUndec, COUNT_OF(rgchUndec)-1)) + if (_SymUnDName(&sym, rgchUndec, STRING_LENGTH(rgchUndec))) { pszSymbol = rgchUndec; } @@ -554,7 +553,7 @@ DWORD_PTR dwAddr psi->dwOffset = dwAddr - mi.BaseOfImage; } - strcpy_s(psi->achSymbol, _countof(psi->achSymbol), pszSymbol); + strcpy_s(psi->achSymbol, ARRAY_SIZE(psi->achSymbol), pszSymbol); } /**************************************************************************** diff --git a/src/coreclr/utilcode/util.cpp b/src/coreclr/utilcode/util.cpp index e7b1755b2b1c4..5d1cdbca61fca 100644 --- a/src/coreclr/utilcode/util.cpp +++ b/src/coreclr/utilcode/util.cpp @@ -48,10 +48,10 @@ void InitWinRTStatus() WinRTStatusEnum winRTStatus = WINRT_STATUS_UNSUPPORTED; const WCHAR wszComBaseDll[] = W("\\combase.dll"); - const SIZE_T cchComBaseDll = _countof(wszComBaseDll); + const SIZE_T cchComBaseDll = ARRAY_SIZE(wszComBaseDll); WCHAR wszComBasePath[MAX_LONGPATH + 1]; - const SIZE_T cchComBasePath = _countof(wszComBasePath); + const SIZE_T cchComBasePath = ARRAY_SIZE(wszComBasePath); ZeroMemory(wszComBasePath, cchComBasePath * sizeof(wszComBasePath[0])); @@ -3116,7 +3116,7 @@ namespace Com STANDARD_VM_CONTRACT; WCHAR wszClsid[39]; - if (GuidToLPWSTR(rclsid, wszClsid, NumItems(wszClsid)) == 0) + if (GuidToLPWSTR(rclsid, wszClsid, ARRAY_SIZE(wszClsid)) == 0) return E_UNEXPECTED; StackSString ssKeyName; diff --git a/src/coreclr/utilcode/util_nodependencies.cpp b/src/coreclr/utilcode/util_nodependencies.cpp index fb812b21ba6ea..9dae13a57d311 100644 --- a/src/coreclr/utilcode/util_nodependencies.cpp +++ b/src/coreclr/utilcode/util_nodependencies.cpp @@ -437,7 +437,7 @@ HRESULT GetDebuggerSettingInfoWorker(__out_ecount_part_opt(*pcchDebuggerString, if ((ret == ERROR_SUCCESS) && (valueType == REG_SZ) && (valueSize / sizeof(WCHAR) < MAX_LONGPATH)) { WCHAR wzAutoKey[MAX_LONGPATH]; - valueSize = NumItems(wzAutoKey) * sizeof(WCHAR); + valueSize = ARRAY_SIZE(wzAutoKey) * sizeof(WCHAR); WszRegQueryValueEx(hKeyHolder, kUnmanagedDebuggerAutoValue, NULL, NULL, reinterpret_cast< LPBYTE >(wzAutoKey), &valueSize); // The OS's behavior is to consider Auto to be FALSE unless the first character is set @@ -708,7 +708,7 @@ void _cdecl DbgWriteEx(LPCTSTR szFmt, ...) va_list marker; va_start(marker, szFmt); - _vsnwprintf_s(rcBuff, _countof(rcBuff), _TRUNCATE, szFmt, marker); + _vsnwprintf_s(rcBuff, ARRAY_SIZE(rcBuff), _TRUNCATE, szFmt, marker); va_end(marker); WszOutputDebugString(rcBuff); } diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index 7439fd6c35078..0194f960809d9 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. - #include "common.h" #include "appdomain.hpp" @@ -1567,7 +1566,7 @@ bool SystemDomain::IsReflectionInvocationMethod(MethodDesc* pMeth) if (!VolatileLoad(&fInited)) { // Make sure all types are loaded so that we can use faster GetExistingClass() - for (unsigned i = 0; i < NumItems(reflectionInvocationTypes); i++) + for (unsigned i = 0; i < ARRAY_SIZE(reflectionInvocationTypes); i++) { CoreLibBinder::GetClass(reflectionInvocationTypes[i]); } @@ -1577,7 +1576,7 @@ bool SystemDomain::IsReflectionInvocationMethod(MethodDesc* pMeth) if (!pCaller->HasInstantiation()) { - for (unsigned i = 0; i < NumItems(reflectionInvocationTypes); i++) + for (unsigned i = 0; i < ARRAY_SIZE(reflectionInvocationTypes); i++) { if (CoreLibBinder::GetExistingClass(reflectionInvocationTypes[i]) == pCaller) return true; diff --git a/src/coreclr/vm/arm/stubs.cpp b/src/coreclr/vm/arm/stubs.cpp index 844ba0856065b..57e478633668f 100644 --- a/src/coreclr/vm/arm/stubs.cpp +++ b/src/coreclr/vm/arm/stubs.cpp @@ -755,7 +755,7 @@ void StubPrecode::Init(StubPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator m_rgCode[n++] = 0xf8df; // ldr pc, [pc, #0] m_rgCode[n++] = 0xf000; - _ASSERTE(n == _countof(m_rgCode)); + _ASSERTE(n == ARRAY_SIZE(m_rgCode)); m_pTarget = GetPreStubEntryPoint(); m_pMethodDesc = (TADDR)pMD; @@ -772,7 +772,7 @@ void NDirectImportPrecode::Init(NDirectImportPrecode* pPrecodeRX, MethodDesc* pM m_rgCode[n++] = 0xf8df; // ldr pc, [pc, #4] m_rgCode[n++] = 0xf004; - _ASSERTE(n == _countof(m_rgCode)); + _ASSERTE(n == ARRAY_SIZE(m_rgCode)); m_pMethodDesc = (TADDR)pMD; m_pTarget = GetEEFuncEntryPoint(NDirectImportThunk); @@ -826,7 +826,7 @@ void ThisPtrRetBufPrecode::Init(MethodDesc* pMD, LoaderAllocator *pLoaderAllocat m_rgCode[n++] = 0xf8df; // ldr pc, [pc, #0] m_rgCode[n++] = 0xf000; - _ASSERTE(n == _countof(m_rgCode)); + _ASSERTE(n == ARRAY_SIZE(m_rgCode)); m_pTarget = GetPreStubEntryPoint(); m_pMethodDesc = (TADDR)pMD; diff --git a/src/coreclr/vm/arm64/cgencpu.h b/src/coreclr/vm/arm64/cgencpu.h index f0111372b785e..100f2454b949e 100644 --- a/src/coreclr/vm/arm64/cgencpu.h +++ b/src/coreclr/vm/arm64/cgencpu.h @@ -598,7 +598,7 @@ struct StubPrecode { } CONTRACTL_END; - ExecutableWriterHolder precodeWriterHolder(this, sizeof(StubPrecode)); + ExecutableWriterHolder precodeWriterHolder(this, sizeof(StubPrecode)); InterlockedExchange64((LONGLONG*)&precodeWriterHolder.GetRW()->m_pTarget, (TADDR)GetPreStubEntryPoint()); } @@ -611,7 +611,7 @@ struct StubPrecode { } CONTRACTL_END; - ExecutableWriterHolder precodeWriterHolder(this, sizeof(StubPrecode)); + ExecutableWriterHolder precodeWriterHolder(this, sizeof(StubPrecode)); return (TADDR)InterlockedCompareExchange64( (LONGLONG*)&precodeWriterHolder.GetRW()->m_pTarget, (TADDR)target, (TADDR)expected) == expected; } @@ -691,7 +691,7 @@ struct FixupPrecode { m_rgCode[n++] = 0xD61F0160; // br x11 - _ASSERTE(n == _countof(m_rgCode)); + _ASSERTE(n == ARRAY_SIZE(m_rgCode)); } TADDR GetBase() @@ -796,7 +796,7 @@ struct ThisPtrRetBufPrecode { } CONTRACTL_END; - ExecutableWriterHolder precodeWriterHolder(this, sizeof(ThisPtrRetBufPrecode)); + ExecutableWriterHolder precodeWriterHolder(this, sizeof(ThisPtrRetBufPrecode)); return (TADDR)InterlockedCompareExchange64( (LONGLONG*)&precodeWriterHolder.GetRW()->m_pTarget, (TADDR)target, (TADDR)expected) == expected; } diff --git a/src/coreclr/vm/arm64/stubs.cpp b/src/coreclr/vm/arm64/stubs.cpp index 44b42cd930210..fbd222a9b2aba 100644 --- a/src/coreclr/vm/arm64/stubs.cpp +++ b/src/coreclr/vm/arm64/stubs.cpp @@ -575,7 +575,7 @@ void StubPrecode::Init(StubPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator m_rgCode[n++] = 0xA940312A; // ldp x10,x12,[x9] m_rgCode[n++] = 0xD61F0140; // br x10 - _ASSERTE(n+1 == _countof(m_rgCode)); + _ASSERTE(n+1 == ARRAY_SIZE(m_rgCode)); m_pTarget = GetPreStubEntryPoint(); m_pMethodDesc = (TADDR)pMD; @@ -591,7 +591,7 @@ void NDirectImportPrecode::Init(NDirectImportPrecode* pPrecodeRX, MethodDesc* pM m_rgCode[n++] = 0xA940316A; // ldp x10,x12,[x11] m_rgCode[n++] = 0xD61F0140; // br x10 - _ASSERTE(n+1 == _countof(m_rgCode)); + _ASSERTE(n+1 == ARRAY_SIZE(m_rgCode)); m_pTarget = GetEEFuncEntryPoint(NDirectImportThunk); m_pMethodDesc = (TADDR)pMD; @@ -645,7 +645,7 @@ void ThisPtrRetBufPrecode::Init(MethodDesc* pMD, LoaderAllocator *pLoaderAllocat _ASSERTE((UINT32*)&m_pTarget == &m_rgCode[n + 2]); m_rgCode[n++] = 0xd61f0200; // br x16 n++; // empty 4 bytes for data alignment below - _ASSERTE(n == _countof(m_rgCode)); + _ASSERTE(n == ARRAY_SIZE(m_rgCode)); m_pTarget = GetPreStubEntryPoint(); diff --git a/src/coreclr/vm/array.cpp b/src/coreclr/vm/array.cpp index bbe35286a5b3a..a83c577b72c86 100644 --- a/src/coreclr/vm/array.cpp +++ b/src/coreclr/vm/array.cpp @@ -1297,7 +1297,7 @@ MethodDesc* GetActualImplementationForArrayGenericIListOrIReadOnlyListMethod(Met // Subtract one for the non-generic IEnumerable that the generic enumerable inherits from unsigned int inheritanceDepth = pItfcMeth->GetMethodTable()->GetNumInterfaces() - 1; - PREFIX_ASSUME(0 <= inheritanceDepth && inheritanceDepth < NumItems(startingMethod)); + PREFIX_ASSUME(0 <= inheritanceDepth && inheritanceDepth < ARRAY_SIZE(startingMethod)); MethodDesc *pGenericImplementor = CoreLibBinder::GetMethod((BinderMethodID)(startingMethod[inheritanceDepth] + slot)); diff --git a/src/coreclr/vm/binder.cpp b/src/coreclr/vm/binder.cpp index 4d0ab1c2678fa..d9cfb45acda1a 100644 --- a/src/coreclr/vm/binder.cpp +++ b/src/coreclr/vm/binder.cpp @@ -533,7 +533,7 @@ void CoreLibBinder::Check() MethodTable * pMT = NULL; - for (unsigned i = 0; i < NumItems(OffsetsAndSizes); i++) + for (unsigned i = 0; i < ARRAY_SIZE(OffsetsAndSizes); i++) { const OffsetAndSizeCheck * p = OffsetsAndSizes + i; @@ -822,11 +822,11 @@ static void FCallCheckSignature(MethodDesc* pMD, PCODE pImpl) } else if (argType == ELEMENT_TYPE_I4) { - bSigError = !IsStrInArray(pUnmanagedArg, len, aInt32Type, NumItems(aInt32Type)); + bSigError = !IsStrInArray(pUnmanagedArg, len, aInt32Type, ARRAY_SIZE(aInt32Type)); } else if (argType == ELEMENT_TYPE_U4) { - bSigError = !IsStrInArray(pUnmanagedArg, len, aUInt32Type, NumItems(aUInt32Type)); + bSigError = !IsStrInArray(pUnmanagedArg, len, aUInt32Type, ARRAY_SIZE(aUInt32Type)); } else if (argType == ELEMENT_TYPE_VALUETYPE) { @@ -835,7 +835,7 @@ static void FCallCheckSignature(MethodDesc* pMD, PCODE pImpl) } else { - bSigError = IsStrInArray(pUnmanagedArg, len, aType, NumItems(aType)); + bSigError = IsStrInArray(pUnmanagedArg, len, aType, ARRAY_SIZE(aType)); } if (bSigError) { diff --git a/src/coreclr/vm/callconvbuilder.cpp b/src/coreclr/vm/callconvbuilder.cpp index 8216f06feff37..b47a696f59b83 100644 --- a/src/coreclr/vm/callconvbuilder.cpp +++ b/src/coreclr/vm/callconvbuilder.cpp @@ -60,7 +60,7 @@ namespace { #define BASE_CALL_CONV(name, flag) { \ MAKE_FULLY_QUALIFIED_CALLCONV_TYPE_NAME_PREFIX(name), \ - lengthof(MAKE_FULLY_QUALIFIED_CALLCONV_TYPE_NAME_PREFIX(name)) - 1, \ + STRING_LENGTH(MAKE_FULLY_QUALIFIED_CALLCONV_TYPE_NAME_PREFIX(name)), \ CorInfoCallConvExtension::flag, \ BeginsWith }, @@ -73,7 +73,7 @@ namespace { #define BASE_CALL_CONV(name, flag) { \ name, \ - lengthof(name) - 1, \ + STRING_LENGTH(name), \ CorInfoCallConvExtension::flag, \ Equals }, @@ -86,7 +86,7 @@ namespace { #define CALL_CONV_MODIFIER(name, flag) { \ MAKE_FULLY_QUALIFIED_CALLCONV_TYPE_NAME_PREFIX(name), \ - lengthof(MAKE_FULLY_QUALIFIED_CALLCONV_TYPE_NAME_PREFIX(name)) - 1, \ + STRING_LENGTH(MAKE_FULLY_QUALIFIED_CALLCONV_TYPE_NAME_PREFIX(name)), \ CallConvBuilder::flag, \ BeginsWith }, @@ -99,7 +99,7 @@ namespace { #define CALL_CONV_MODIFIER(name, flag) { \ name, \ - lengthof(name) - 1, \ + STRING_LENGTH(name), \ CallConvBuilder::flag, \ Equals }, @@ -523,7 +523,7 @@ bool CallConv::TryGetCallingConventionFromUnmanagedCallersOnly(_In_ MethodDesc* NULL, 0, namedArgs, - lengthof(namedArgs), + ARRAY_SIZE(namedArgs), domainAssembly)); // If the value isn't defined, then return without setting anything. diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 02374e18df61c..b8d69bc36669f 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -1762,7 +1762,7 @@ BOOL Module::IsRuntimeWrapExceptions() // Then, find the named argument namedArgs[0].InitBoolField("WrapNonExceptionThrows"); - IfFailGo(ParseKnownCaNamedArgs(ca, namedArgs, lengthof(namedArgs))); + IfFailGo(ParseKnownCaNamedArgs(ca, namedArgs, ARRAY_SIZE(namedArgs))); if (namedArgs[0].val.boolean) fRuntimeWrapExceptions = TRUE; diff --git a/src/coreclr/vm/class.cpp b/src/coreclr/vm/class.cpp index d0d9f2b4dd921..3add832d29a72 100644 --- a/src/coreclr/vm/class.cpp +++ b/src/coreclr/vm/class.cpp @@ -1877,7 +1877,7 @@ TypeHandle MethodTable::GetDefItfForComClassItf() if (it.Next()) { // Can use GetInterfaceApprox, as there are no generic default interfaces - return TypeHandle(it.GetInterfaceApprox()); + return TypeHandle(it.GetInterfaceApprox()); } else { @@ -2877,7 +2877,7 @@ DeepFieldDescIterator::Init(MethodTable* pMT, int iteratorType, while (pMT) { - if (m_numClasses < (int)NumItems(m_classes)) + if (m_numClasses < (int)ARRAY_SIZE(m_classes)) { m_classes[m_numClasses++] = pMT; } diff --git a/src/coreclr/vm/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index b9660ba76036a..a7f91f7e13d39 100644 --- a/src/coreclr/vm/clrtocomcall.cpp +++ b/src/coreclr/vm/clrtocomcall.cpp @@ -616,7 +616,7 @@ UINT32 CLRToCOMLateBoundWorker( hr = pItfMD->GetMDImport()->GetDispIdOfMemberDef(tkMember, (ULONG*)&dispId); if (hr == S_OK) { - WCHAR strTmp[ARRAYSIZE(DISPID_NAME_FORMAT_STRING W("4294967295"))]; + WCHAR strTmp[ARRAY_SIZE(DISPID_NAME_FORMAT_STRING W("4294967295"))]; _snwprintf_s(strTmp, COUNTOF(strTmp), _TRUNCATE, DISPID_NAME_FORMAT_STRING, dispId); gc.MemberName = StringObject::NewString(strTmp); } diff --git a/src/coreclr/vm/comcallablewrapper.cpp b/src/coreclr/vm/comcallablewrapper.cpp index a940abf72adaf..d9fc2fe0ac4d5 100644 --- a/src/coreclr/vm/comcallablewrapper.cpp +++ b/src/coreclr/vm/comcallablewrapper.cpp @@ -3715,7 +3715,7 @@ BOOL ComMethodTable::LayOutInterfaceMethodTable(MethodTable* pClsMT) BEGIN_PROFILER_CALLBACK(CORProfilerTrackCCW()); #if defined(_DEBUG) WCHAR rIID[40]; // {00000000-0000-0000-0000-000000000000} - GuidToLPWSTR(m_IID, rIID, lengthof(rIID)); + GuidToLPWSTR(m_IID, rIID, ARRAY_SIZE(rIID)); LOG((LF_CORPROF, LL_INFO100, "COMClassicVTableCreated Class:%hs, IID:%ls, vTbl:%#08x\n", pItfClass->GetDebugClassName(), rIID, pUnkVtable)); #else @@ -4771,7 +4771,7 @@ ComCallWrapperTemplate* ComCallWrapperTemplate::CreateTemplate(TypeHandle thClas #if defined(_DEBUG) WCHAR rIID[40]; // {00000000-0000-0000-0000-000000000000} - GuidToLPWSTR(IClassXIID, rIID, lengthof(rIID)); + GuidToLPWSTR(IClassXIID, rIID, ARRAY_SIZE(rIID)); SString ssName; thClass.GetName(ssName); LOG((LF_CORPROF, LL_INFO100, "COMClassicVTableCreated Class:%ls, IID:%ls, vTbl:%#08x\n", diff --git a/src/coreclr/vm/corelib.cpp b/src/coreclr/vm/corelib.cpp index f3f00bce3f992..4189a6371b25c 100644 --- a/src/coreclr/vm/corelib.cpp +++ b/src/coreclr/vm/corelib.cpp @@ -246,7 +246,7 @@ const CoreLibClassDescription c_rgCoreLibClassDescriptions[] = #define DEFINE_EXCEPTION(ns, reKind, bHRformessage, ...) { ns , # reKind }, #include "rexcep.h" }; -const USHORT c_nCoreLibClassDescriptions = NumItems(c_rgCoreLibClassDescriptions); +const USHORT c_nCoreLibClassDescriptions = ARRAY_SIZE(c_rgCoreLibClassDescriptions); #define gsig_NoSig (*(HardCodedMetaSig *)NULL) @@ -255,14 +255,14 @@ const CoreLibMethodDescription c_rgCoreLibMethodDescriptions[] = #define DEFINE_METHOD(c,i,s,g) { CLASS__ ## c , # s, & gsig_ ## g }, #include "corelib.h" }; -const USHORT c_nCoreLibMethodDescriptions = NumItems(c_rgCoreLibMethodDescriptions) + 1; +const USHORT c_nCoreLibMethodDescriptions = ARRAY_SIZE(c_rgCoreLibMethodDescriptions) + 1; const CoreLibFieldDescription c_rgCoreLibFieldDescriptions[] = { #define DEFINE_FIELD(c,i,s) { CLASS__ ## c , # s }, #include "corelib.h" }; -const USHORT c_nCoreLibFieldDescriptions = NumItems(c_rgCoreLibFieldDescriptions) + 1; +const USHORT c_nCoreLibFieldDescriptions = ARRAY_SIZE(c_rgCoreLibFieldDescriptions) + 1; /////////////////////////////////////////////////////////////////////////////// // @@ -311,4 +311,4 @@ const ECClass c_rgECClasses[] = #include "ecalllist.h" }; // c_rgECClasses[] -const int c_nECClasses = NumItems(c_rgECClasses); +const int c_nECClasses = ARRAY_SIZE(c_rgECClasses); diff --git a/src/coreclr/vm/customattribute.cpp b/src/coreclr/vm/customattribute.cpp index e0fd928721192..da728dfe827bd 100644 --- a/src/coreclr/vm/customattribute.cpp +++ b/src/coreclr/vm/customattribute.cpp @@ -808,7 +808,7 @@ FCIMPL5(VOID, COMCustomAttribute::ParseAttributeUsageAttribute, PVOID pData, ULO CaArg args[1]; args[0].InitEnum(SERIALIZATION_TYPE_I4, 0); - if (FAILED(::ParseKnownCaArgs(ca, args, lengthof(args)))) + if (FAILED(::ParseKnownCaArgs(ca, args, ARRAY_SIZE(args)))) { HELPER_METHOD_FRAME_BEGIN_0(); COMPlusThrow(kCustomAttributeFormatException); @@ -823,7 +823,7 @@ FCIMPL5(VOID, COMCustomAttribute::ParseAttributeUsageAttribute, PVOID pData, ULO namedArgTypes[allowMultiple].Init(SERIALIZATION_TYPE_BOOLEAN); namedArgs[inherited].Init("Inherited", SERIALIZATION_TYPE_PROPERTY, namedArgTypes[inherited], TRUE); namedArgs[allowMultiple].Init("AllowMultiple", SERIALIZATION_TYPE_PROPERTY, namedArgTypes[allowMultiple], FALSE); - if (FAILED(::ParseKnownCaNamedArgs(ca, namedArgs, lengthof(namedArgs)))) + if (FAILED(::ParseKnownCaNamedArgs(ca, namedArgs, ARRAY_SIZE(namedArgs)))) { HELPER_METHOD_FRAME_BEGIN_0(); COMPlusThrow(kCustomAttributeFormatException); diff --git a/src/coreclr/vm/dispatchinfo.cpp b/src/coreclr/vm/dispatchinfo.cpp index e3c88987614c6..3b231c3882baa 100644 --- a/src/coreclr/vm/dispatchinfo.cpp +++ b/src/coreclr/vm/dispatchinfo.cpp @@ -1756,7 +1756,7 @@ void DispatchInfo::InvokeMemberWorker(DispatchMemberInfo* pDispMemberInfo, if (!pDispMemberInfo) { WCHAR strTmp[64]; - _snwprintf_s(strTmp, NumItems(strTmp), _TRUNCATE, DISPID_NAME_FORMAT_STRING, id); + _snwprintf_s(strTmp, ARRAY_SIZE(strTmp), _TRUNCATE, DISPID_NAME_FORMAT_STRING, id); pObjs->MemberName = (OBJECTREF)StringObject::NewString(strTmp); } else @@ -2489,7 +2489,7 @@ void DispatchInfo::SetUpNamedParamArray(DispatchMemberInfo *pMemberInfo, DISPID { WCHAR wszTmp[64]; - _snwprintf_s(wszTmp, NumItems(wszTmp), _TRUNCATE, DISPID_NAME_FORMAT_STRING, pSrcArgNames[iSrcArg]); + _snwprintf_s(wszTmp, ARRAY_SIZE(wszTmp), _TRUNCATE, DISPID_NAME_FORMAT_STRING, pSrcArgNames[iSrcArg]); STRINGREF strTmp = StringObject::NewString(wszTmp); (*pNamedParamArray)->SetAt(iDestArg, (OBJECTREF)strTmp); } diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 675b1d289d8ae..7888c8e377f4b 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -2686,7 +2686,7 @@ PInvokeStaticSigInfo::PInvokeStaticSigInfo(_In_ MethodDesc* pMD) namedArgs[MDA_ThrowOnUnmappableChar].InitBoolField("ThrowOnUnmappableChar", (ULONG)GetThrowOnUnmappableChar()); namedArgs[MDA_SetLastError].InitBoolField("SetLastError", 0); - IfFailGo(ParseKnownCaNamedArgs(ca, namedArgs, lengthof(namedArgs))); + IfFailGo(ParseKnownCaNamedArgs(ca, namedArgs, ARRAY_SIZE(namedArgs))); CorNativeLinkType nlt; IfFailGo(RemapLinkType((CorNativeLinkType)namedArgs[MDA_CharSet].val.u4, &nlt)); diff --git a/src/coreclr/vm/dwbucketmanager.hpp b/src/coreclr/vm/dwbucketmanager.hpp index 21267b8f36070..9731b2081c92d 100644 --- a/src/coreclr/vm/dwbucketmanager.hpp +++ b/src/coreclr/vm/dwbucketmanager.hpp @@ -195,11 +195,11 @@ WCHAR BytesToBase32::GetNextChar() unsigned int result = 0; _ASSERTE(pData <= pEnd); - _ASSERTE(nWhich >= 0 && nWhich < lengthof(decoder)); + _ASSERTE(nWhich >= 0 && nWhich < ARRAY_SIZE(decoder)); // If out of data, return signal value, > any valid char. if (pData == pEnd) - return base32[lengthof(base32)-1]; + return base32[STRING_LENGTH(base32)]; #if defined(_DEBUG) if (decoder[nWhich].l1) @@ -243,11 +243,11 @@ WCHAR BytesToBase32::GetNextChar() } // Advance the 'state machine' -- which 5-bits from an 8-byte block. - if (++nWhich == lengthof(decoder)) + if (++nWhich == ARRAY_SIZE(decoder)) nWhich = 0; // Sanity check on value. - _ASSERTE(result < lengthof(base32)); + _ASSERTE(result < ARRAY_SIZE(base32)); return base32[result]; } // WCHAR BytesToBase32::GetNextChar() @@ -490,7 +490,7 @@ void BaseBucketParamsManager::GetAppVersion(__out_ecount(maxLength) WCHAR* targe W("%d.%d.%d.%d"), major, minor, build, revision); } - else if (DwGetAssemblyVersion(appPath, verBuf, NumItems(verBuf)) != 0) + else if (DwGetAssemblyVersion(appPath, verBuf, ARRAY_SIZE(verBuf)) != 0) { wcscpy_s(targetParam, maxLength, verBuf); } diff --git a/src/coreclr/vm/dwreport.cpp b/src/coreclr/vm/dwreport.cpp index e42fbf752d6cf..228e1d029cd5e 100644 --- a/src/coreclr/vm/dwreport.cpp +++ b/src/coreclr/vm/dwreport.cpp @@ -297,7 +297,7 @@ int DwGetAppDescription( // Number of characters written. // Build the query key for the language-specific file description resource. WCHAR buf[64]; //----+----1----+----2----+----3----+----4----+ - _snwprintf_s(buf, NumItems(buf), _TRUNCATE, W("\\StringFileInfo\\%04x%04x\\FileDescription"), + _snwprintf_s(buf, ARRAY_SIZE(buf), _TRUNCATE, W("\\StringFileInfo\\%04x%04x\\FileDescription"), translation->language, translation->codePage); // Get the file description. @@ -429,7 +429,7 @@ int DwGetAssemblyVersion( // Number of characters written. // Build the query key for the language-specific assembly version resource. WCHAR buf[64]; //----+----1----+----2----+----3----+----4----+ - _snwprintf_s(buf, NumItems(buf), _TRUNCATE, W("\\StringFileInfo\\%04x%04x\\Assembly Version"), + _snwprintf_s(buf, ARRAY_SIZE(buf), _TRUNCATE, W("\\StringFileInfo\\%04x%04x\\Assembly Version"), translation->language, translation->codePage); // Get the assembly version. diff --git a/src/coreclr/vm/eetwain.cpp b/src/coreclr/vm/eetwain.cpp index 228596e26662b..c2fef85d92b55 100644 --- a/src/coreclr/vm/eetwain.cpp +++ b/src/coreclr/vm/eetwain.cpp @@ -3501,7 +3501,7 @@ void UnwindEspFrameEpilog( /* Increment "offset" in steps to see which callee-saved registers have already been popped */ - for (unsigned i = NumItems(CALLEE_SAVED_REGISTERS_MASK); i > 0; i--) + for (unsigned i = ARRAY_SIZE(CALLEE_SAVED_REGISTERS_MASK); i > 0; i--) { RegMask regMask = CALLEE_SAVED_REGISTERS_MASK[i - 1]; @@ -3625,7 +3625,7 @@ void UnwindEbpDoubleAlignFrameEpilog( } } - for (unsigned i = NumItems(CALLEE_SAVED_REGISTERS_MASK) - 1; i > 0; i--) + for (unsigned i = STRING_LENGTH(CALLEE_SAVED_REGISTERS_MASK); i > 0; i--) { RegMask regMask = CALLEE_SAVED_REGISTERS_MASK[i - 1]; _ASSERTE(regMask != RM_EBP); @@ -3750,7 +3750,7 @@ void UnwindEspFrameProlog( unsigned regsMask = RM_NONE; PTR_DWORD savedRegPtr = PTR_DWORD((TADDR)ESP); - for (unsigned i = 0; i < NumItems(CALLEE_SAVED_REGISTERS_MASK); i++) + for (unsigned i = 0; i < ARRAY_SIZE(CALLEE_SAVED_REGISTERS_MASK); i++) { RegMask regMask = CALLEE_SAVED_REGISTERS_MASK[i]; @@ -3857,7 +3857,7 @@ void UnwindEspFrame( const RegMask regsMask = info->savedRegMask; - for (unsigned i = NumItems(CALLEE_SAVED_REGISTERS_MASK); i > 0; i--) + for (unsigned i = ARRAY_SIZE(CALLEE_SAVED_REGISTERS_MASK); i > 0; i--) { RegMask regMask = CALLEE_SAVED_REGISTERS_MASK[i - 1]; @@ -3965,7 +3965,7 @@ void UnwindEbpDoubleAlignFrameProlog( /* Increment "offset" in steps to see which callee-saved registers have been pushed already */ - for (unsigned i = 0; i < NumItems(CALLEE_SAVED_REGISTERS_MASK) - 1; i++) + for (unsigned i = 0; i < STRING_LENGTH(CALLEE_SAVED_REGISTERS_MASK); i++) { RegMask regMask = CALLEE_SAVED_REGISTERS_MASK[i]; _ASSERTE(regMask != RM_EBP); @@ -4133,7 +4133,7 @@ bool UnwindEbpDoubleAlignFrame( if (info->doubleAlign && (curEBP & 0x04)) pSavedRegs--; - for (unsigned i = 0; i < NumItems(CALLEE_SAVED_REGISTERS_MASK) - 1; i++) + for (unsigned i = 0; i < STRING_LENGTH(CALLEE_SAVED_REGISTERS_MASK); i++) { RegMask regMask = CALLEE_SAVED_REGISTERS_MASK[i]; if ((info->savedRegMask & regMask) == 0) diff --git a/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h b/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h index 0544f3ce9ccb0..9744e84a89b69 100644 --- a/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h +++ b/src/coreclr/vm/eventing/eventpipe/ep-rt-coreclr.h @@ -14,9 +14,6 @@ #include "win32threadpool.h" #include "clrversion.h" -#undef EP_ARRAY_SIZE -#define EP_ARRAY_SIZE(expr) (sizeof(expr) / sizeof ((expr) [0])) - #undef EP_INFINITE_WAIT #define EP_INFINITE_WAIT INFINITE @@ -2670,7 +2667,7 @@ ep_rt_diagnostics_command_line_get (void) // The host initalizes the runtime in two phases, init and exec assembly. On non-Windows platforms the commandline returned by the runtime // is different during each phase. We suspend during init where the runtime has populated the commandline with a // mock value (the full path of the executing assembly) and the actual value isn't populated till the exec assembly phase. - // On Windows this does not apply as the value is retrieved directly from the OS any time it is requested. + // On Windows this does not apply as the value is retrieved directly from the OS any time it is requested. // As a result, we cannot actually cache this value. We need to return the _current_ value. // This function needs to handle freeing the string in order to make it consistent with Mono's version. // To that end, we'll "cache" it here so we free the previous string when we get it again. diff --git a/src/coreclr/vm/eventtrace.cpp b/src/coreclr/vm/eventtrace.cpp index c549018584d70..a9a33e50efc14 100644 --- a/src/coreclr/vm/eventtrace.cpp +++ b/src/coreclr/vm/eventtrace.cpp @@ -706,7 +706,7 @@ void ETW::GCLog::MovedReference( { // Moved references - _ASSERTE(pContext->cBulkMovedObjectRanges < _countof(pContext->rgGCBulkMovedObjectRanges)); + _ASSERTE(pContext->cBulkMovedObjectRanges < ARRAY_SIZE(pContext->rgGCBulkMovedObjectRanges)); EventStructGCBulkMovedObjectRangesValue * pValue = &pContext->rgGCBulkMovedObjectRanges[pContext->cBulkMovedObjectRanges]; pValue->OldRangeBase = pbMemBlockStart; @@ -715,7 +715,7 @@ void ETW::GCLog::MovedReference( pContext->cBulkMovedObjectRanges++; // If buffer is now full, empty it into ETW - if (pContext->cBulkMovedObjectRanges == _countof(pContext->rgGCBulkMovedObjectRanges)) + if (pContext->cBulkMovedObjectRanges == ARRAY_SIZE(pContext->rgGCBulkMovedObjectRanges)) { FireEtwGCBulkMovedObjectRanges( pContext->iCurBulkMovedObjectRanges, @@ -732,7 +732,7 @@ void ETW::GCLog::MovedReference( { // Surviving references - _ASSERTE(pContext->cBulkSurvivingObjectRanges < _countof(pContext->rgGCBulkSurvivingObjectRanges)); + _ASSERTE(pContext->cBulkSurvivingObjectRanges < ARRAY_SIZE(pContext->rgGCBulkSurvivingObjectRanges)); EventStructGCBulkSurvivingObjectRangesValue * pValue = &pContext->rgGCBulkSurvivingObjectRanges[pContext->cBulkSurvivingObjectRanges]; pValue->RangeBase = pbMemBlockStart; @@ -740,7 +740,7 @@ void ETW::GCLog::MovedReference( pContext->cBulkSurvivingObjectRanges++; // If buffer is now full, empty it into ETW - if (pContext->cBulkSurvivingObjectRanges == _countof(pContext->rgGCBulkSurvivingObjectRanges)) + if (pContext->cBulkSurvivingObjectRanges == ARRAY_SIZE(pContext->rgGCBulkSurvivingObjectRanges)) { FireEtwGCBulkSurvivingObjectRanges( pContext->iCurBulkSurvivingObjectRanges, @@ -1142,7 +1142,7 @@ void BulkComLogger::FlushRcw() EventDataDescCreate(&eventData[1], &instance, sizeof(const unsigned short)); EventDataDescCreate(&eventData[2], m_etwRcwData, sizeof(EventRCWEntry) * m_currRcw); - ULONG result = EventWrite(Microsoft_Windows_DotNETRuntimeHandle, &GCBulkRCW, _countof(eventData), eventData); + ULONG result = EventWrite(Microsoft_Windows_DotNETRuntimeHandle, &GCBulkRCW, ARRAY_SIZE(eventData), eventData); #else ULONG result = FireEtXplatGCBulkRCW(m_currRcw, instance, sizeof(EventRCWEntry) * m_currRcw, m_etwRcwData); #endif // !defined(HOST_UNIX) @@ -1233,7 +1233,7 @@ void BulkComLogger::FlushCcw() EventDataDescCreate(&eventData[1], &instance, sizeof(const unsigned short)); EventDataDescCreate(&eventData[2], m_etwCcwData, sizeof(EventCCWEntry) * m_currCcw); - ULONG result = EventWrite(Microsoft_Windows_DotNETRuntimeHandle, &GCBulkRootCCW, _countof(eventData), eventData); + ULONG result = EventWrite(Microsoft_Windows_DotNETRuntimeHandle, &GCBulkRootCCW, ARRAY_SIZE(eventData), eventData); #else ULONG result = FireEtXplatGCBulkRootCCW(m_currCcw, instance, sizeof(EventCCWEntry) * m_currCcw, m_etwCcwData); #endif //!defined(HOST_UNIX) @@ -1362,7 +1362,7 @@ void BulkComLogger::AddCcwHandle(Object **handle) while (curr->Next) curr = curr->Next; - if (curr->Count == _countof(curr->Handles)) + if (curr->Count == ARRAY_SIZE(curr->Handles)) { curr->Next = new CCWEnumerationEntry; curr = curr->Next; @@ -1438,7 +1438,7 @@ void BulkStaticsLogger::FireBulkStaticsEvent() EventDataDescCreate(&eventData[2], &instance, sizeof(const unsigned short) ); EventDataDescCreate(&eventData[3], m_buffer, m_used); - ULONG result = EventWrite(Microsoft_Windows_DotNETRuntimeHandle, &GCBulkRootStaticVar, _countof(eventData), eventData); + ULONG result = EventWrite(Microsoft_Windows_DotNETRuntimeHandle, &GCBulkRootStaticVar, ARRAY_SIZE(eventData), eventData); #else ULONG result = FireEtXplatGCBulkRootStaticVar(m_count, appDomain, instance, m_used, m_buffer); #endif //!defined(HOST_UNIX) @@ -1741,12 +1741,12 @@ int BulkTypeEventLogger::LogSingleType(TypeHandle th) CONTRACTL_END; // If there's no room for another type, flush what we've got - if (m_nBulkTypeValueCount == _countof(m_rgBulkTypeValues)) + if (m_nBulkTypeValueCount == ARRAY_SIZE(m_rgBulkTypeValues)) { FireBulkTypeEvent(); } - _ASSERTE(m_nBulkTypeValueCount < (int)_countof(m_rgBulkTypeValues)); + _ASSERTE(m_nBulkTypeValueCount < (int)ARRAY_SIZE(m_rgBulkTypeValues)); BulkTypeValue * pVal = &m_rgBulkTypeValues[m_nBulkTypeValueCount]; @@ -2259,7 +2259,7 @@ VOID ETW::GCLog::RootReference( if (fDependentHandle) { _ASSERTE(pContext->cGCBulkRootConditionalWeakTableElementEdges < - _countof(pContext->rgGCBulkRootConditionalWeakTableElementEdges)); + ARRAY_SIZE(pContext->rgGCBulkRootConditionalWeakTableElementEdges)); EventStructGCBulkRootConditionalWeakTableElementEdgeValue * pRCWTEEdgeValue = &pContext->rgGCBulkRootConditionalWeakTableElementEdges[pContext->cGCBulkRootConditionalWeakTableElementEdges]; pRCWTEEdgeValue->GCKeyNodeID = pRootedNode; @@ -2269,7 +2269,7 @@ VOID ETW::GCLog::RootReference( // If RCWTE edge buffer is now full, empty it into ETW if (pContext->cGCBulkRootConditionalWeakTableElementEdges == - _countof(pContext->rgGCBulkRootConditionalWeakTableElementEdges)) + ARRAY_SIZE(pContext->rgGCBulkRootConditionalWeakTableElementEdges)) { FireEtwGCBulkRootConditionalWeakTableElementEdge( pContext->iCurBulkRootConditionalWeakTableElementEdge, @@ -2284,7 +2284,7 @@ VOID ETW::GCLog::RootReference( } else { - _ASSERTE(pContext->cGcBulkRootEdges < _countof(pContext->rgGcBulkRootEdges)); + _ASSERTE(pContext->cGcBulkRootEdges < ARRAY_SIZE(pContext->rgGcBulkRootEdges)); EventStructGCBulkRootEdgeValue * pBulkRootEdgeValue = &pContext->rgGcBulkRootEdges[pContext->cGcBulkRootEdges]; pBulkRootEdgeValue->RootedNodeAddress = pRootedNode; pBulkRootEdgeValue->GCRootKind = nRootKind; @@ -2293,7 +2293,7 @@ VOID ETW::GCLog::RootReference( pContext->cGcBulkRootEdges++; // If root edge buffer is now full, empty it into ETW - if (pContext->cGcBulkRootEdges == _countof(pContext->rgGcBulkRootEdges)) + if (pContext->cGcBulkRootEdges == ARRAY_SIZE(pContext->rgGcBulkRootEdges)) { FireEtwGCBulkRootEdge( pContext->iCurBulkRootEdge, @@ -2351,7 +2351,7 @@ VOID ETW::GCLog::ObjectReference( //--------------------------------------------------------------------------------------- // Add Node (pObjReferenceSource) to buffer - _ASSERTE(pContext->cGcBulkNodeValues < _countof(pContext->rgGcBulkNodeValues)); + _ASSERTE(pContext->cGcBulkNodeValues < ARRAY_SIZE(pContext->rgGcBulkNodeValues)); EventStructGCBulkNodeValue * pBulkNodeValue = &pContext->rgGcBulkNodeValues[pContext->cGcBulkNodeValues]; pBulkNodeValue->Address = pObjReferenceSource; pBulkNodeValue->Size = pObjReferenceSource->GetSize(); @@ -2360,7 +2360,7 @@ VOID ETW::GCLog::ObjectReference( pContext->cGcBulkNodeValues++; // If Node buffer is now full, empty it into ETW - if (pContext->cGcBulkNodeValues == _countof(pContext->rgGcBulkNodeValues)) + if (pContext->cGcBulkNodeValues == ARRAY_SIZE(pContext->rgGcBulkNodeValues)) { FireEtwGCBulkNode( pContext->iCurBulkNodeEvent, @@ -2402,7 +2402,7 @@ VOID ETW::GCLog::ObjectReference( for (ULONGLONG i=0; i < cRefs; i++) { - _ASSERTE(pContext->cGcBulkEdgeValues < _countof(pContext->rgGcBulkEdgeValues)); + _ASSERTE(pContext->cGcBulkEdgeValues < ARRAY_SIZE(pContext->rgGcBulkEdgeValues)); EventStructGCBulkEdgeValue * pBulkEdgeValue = &pContext->rgGcBulkEdgeValues[pContext->cGcBulkEdgeValues]; pBulkEdgeValue->Value = rgObjReferenceTargets[i]; // FUTURE: ReferencingFieldID @@ -2410,7 +2410,7 @@ VOID ETW::GCLog::ObjectReference( pContext->cGcBulkEdgeValues++; // If Edge buffer is now full, empty it into ETW - if (pContext->cGcBulkEdgeValues == _countof(pContext->rgGcBulkEdgeValues)) + if (pContext->cGcBulkEdgeValues == ARRAY_SIZE(pContext->rgGcBulkEdgeValues)) { FireEtwGCBulkEdge( pContext->iCurBulkEdgeEvent, diff --git a/src/coreclr/vm/eventtracepriv.h b/src/coreclr/vm/eventtracepriv.h index 2d3f09580f580..54fdd43a176c3 100644 --- a/src/coreclr/vm/eventtracepriv.h +++ b/src/coreclr/vm/eventtracepriv.h @@ -18,10 +18,6 @@ #ifndef __EVENTTRACEPRIV_H__ #define __EVENTTRACEPRIV_H__ -#ifndef _countof -#define _countof(_array) (sizeof(_array)/sizeof(_array[0])) -#endif - // ETW has a limitation of 64K for TOTAL event Size, however there is overhead associated with // the event headers. It is unclear exactly how much that is, but 1K should be sufficiently // far away to avoid problems without sacrificing the perf of bulk processing. diff --git a/src/coreclr/vm/gdbjit.cpp b/src/coreclr/vm/gdbjit.cpp index 1f358eb2d68b4..3f20e5c49a9b0 100644 --- a/src/coreclr/vm/gdbjit.cpp +++ b/src/coreclr/vm/gdbjit.cpp @@ -1245,7 +1245,7 @@ void FunctionMember::MangleName(char *buf, int &buf_offset, const char *name) int name_length = strlen(name); char tmp[20]; - int tmp_len = sprintf_s(tmp, _countof(tmp), "%i", name_length); + int tmp_len = sprintf_s(tmp, ARRAY_SIZE(tmp), "%i", name_length); if (tmp_len <= 0) return; @@ -2901,7 +2901,7 @@ bool NotifyGdb::EmitDebugInfo(Elf_Builder &elfBuilder, MethodDesc* methodDescPtr { char name[256]; - sprintf_s(name, _countof(name), ".thunk_%i", i); + sprintf_s(name, ARRAY_SIZE(name), ".thunk_%i", i); Elf_SectionTracker *thunk = elfBuilder.OpenSection(name, SHT_PROGBITS, SHF_ALLOC | SHF_EXECINSTR); thunk->DisableHeaderUpdate(); diff --git a/src/coreclr/vm/hosting.cpp b/src/coreclr/vm/hosting.cpp index 66896fe79268a..3379d2385bea0 100644 --- a/src/coreclr/vm/hosting.cpp +++ b/src/coreclr/vm/hosting.cpp @@ -2,17 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // - #include "common.h" #include "mscoree.h" #include "corhost.h" #include "threads.h" - -#define countof(x) (sizeof(x) / sizeof(x[0])) - - #undef VirtualAlloc LPVOID ClrVirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect) { CONTRACTL diff --git a/src/coreclr/vm/i386/stublinkerx86.cpp b/src/coreclr/vm/i386/stublinkerx86.cpp index 8c8695b024544..685883dd1ae80 100644 --- a/src/coreclr/vm/i386/stublinkerx86.cpp +++ b/src/coreclr/vm/i386/stublinkerx86.cpp @@ -1765,7 +1765,7 @@ VOID StubLinkerCPU::X64EmitMovqWorker(BYTE opcode, X86Reg Xmmreg, X86Reg reg) BYTE modrm = static_cast((Xmmreg << 3) | reg); codeBuffer[nBytes++] = 0xC0|modrm; - _ASSERTE(nBytes <= _countof(codeBuffer)); + _ASSERTE(nBytes <= ARRAY_SIZE(codeBuffer)); // Lastly, emit the encoded bytes EmitBytes(codeBuffer, nBytes); @@ -1836,7 +1836,7 @@ VOID StubLinkerCPU::X64EmitMovXmmWorker(BYTE prefix, BYTE opcode, X86Reg Xmmreg, nBytes += 4; } - _ASSERTE(nBytes <= _countof(codeBuffer)); + _ASSERTE(nBytes <= ARRAY_SIZE(codeBuffer)); // Lastly, emit the encoded bytes EmitBytes(codeBuffer, nBytes); diff --git a/src/coreclr/vm/interoplibinterface_objc.cpp b/src/coreclr/vm/interoplibinterface_objc.cpp index 115d8ac66fb2f..1a28c1689d9c0 100644 --- a/src/coreclr/vm/interoplibinterface_objc.cpp +++ b/src/coreclr/vm/interoplibinterface_objc.cpp @@ -131,7 +131,7 @@ namespace { // Is the function in libobjc and named appropriately. return ((strcmp(libraryName, ObjectiveCLibrary) == 0) - && (strncmp(entrypointName, OBJC_MSGSEND, _countof(OBJC_MSGSEND) -1) == 0)); + && (strncmp(entrypointName, OBJC_MSGSEND, STRING_LENGTH(OBJC_MSGSEND)) == 0)); } const void* STDMETHODCALLTYPE MessageSendPInvokeOverride(_In_z_ const char* libraryName, _In_z_ const char* entrypointName) @@ -139,7 +139,7 @@ namespace if (!IsObjectiveCMessageSendFunction(libraryName, entrypointName)) return nullptr; - for (int i = 0; i < _countof(MsgSendEntryPoints); ++i) + for (int i = 0; i < ARRAY_SIZE(MsgSendEntryPoints); ++i) { void* funcMaybe = s_msgSendOverrides[i]; if (funcMaybe != nullptr @@ -163,7 +163,7 @@ extern "C" BOOL QCALLTYPE ObjCMarshal_TrySetGlobalMessageSendCallback( BEGIN_QCALL; - _ASSERTE(msgSendFunction >= 0 && msgSendFunction < _countof(s_msgSendOverrides)); + _ASSERTE(msgSendFunction >= 0 && msgSendFunction < ARRAY_SIZE(s_msgSendOverrides)); success = FastInterlockCompareExchangePointer(&s_msgSendOverrides[msgSendFunction], fptr, NULL) == NULL; // Set P/Invoke override callback if we haven't already diff --git a/src/coreclr/vm/interoputil.cpp b/src/coreclr/vm/interoputil.cpp index f42d1627de86c..610c3418ae530 100644 --- a/src/coreclr/vm/interoputil.cpp +++ b/src/coreclr/vm/interoputil.cpp @@ -256,7 +256,7 @@ BOOL GetDefaultDllImportSearchPathsAttributeValue(Module *pModule, mdToken token CaArg args[1]; args[0].InitEnum(SERIALIZATION_TYPE_U4, (ULONG)0); - ParseKnownCaArgs(ca, args, lengthof(args)); + ParseKnownCaArgs(ca, args, ARRAY_SIZE(args)); *pDllImportSearchPathFlags = args[0].val.u4; return TRUE; } @@ -287,7 +287,7 @@ int GetLCIDParameterIndex(MethodDesc *pMD) CustomAttributeParser caLCID(pVal, cbVal); CaArg args[1]; args[0].Init(SERIALIZATION_TYPE_I4, 0); - IfFailGo(ParseKnownCaArgs(caLCID, args, lengthof(args))); + IfFailGo(ParseKnownCaArgs(caLCID, args, ARRAY_SIZE(args))); iLCIDParam = args[0].val.i4; } @@ -1711,7 +1711,7 @@ void SafeReleaseStream(IStream *pStream) #ifdef _DEBUG WCHAR logStr[200]; - swprintf_s(logStr, NumItems(logStr), W("Object gone: CoReleaseMarshalData returned %x, file %S, line %d\n"), hr, __FILE__, __LINE__); + swprintf_s(logStr, ARRAY_SIZE(logStr), W("Object gone: CoReleaseMarshalData returned %x, file %S, line %d\n"), hr, __FILE__, __LINE__); LogInterop(logStr); if (hr != S_OK) { @@ -1721,7 +1721,7 @@ void SafeReleaseStream(IStream *pStream) ULARGE_INTEGER li2; pStream->Seek(li, STREAM_SEEK_SET, &li2); hr = CoReleaseMarshalData(pStream); - swprintf_s(logStr, NumItems(logStr), W("Object gone: CoReleaseMarshalData returned %x, file %S, line %d\n"), hr, __FILE__, __LINE__); + swprintf_s(logStr, ARRAY_SIZE(logStr), W("Object gone: CoReleaseMarshalData returned %x, file %S, line %d\n"), hr, __FILE__, __LINE__); LogInterop(logStr); } #endif diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 1ab45790b833e..e5646fc9ab196 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -6966,7 +6966,7 @@ bool getILIntrinsicImplementationForVolatile(MethodDesc * ftn, }; mdMethodDef md = ftn->GetMemberDef(); - for (unsigned i = 0; i < NumItems(volatileImpls); i++) + for (unsigned i = 0; i < ARRAY_SIZE(volatileImpls); i++) { if (md == CoreLibBinder::GetMethod(volatileImpls[i].methodId)->GetMemberDef()) { @@ -7215,7 +7215,7 @@ bool getILIntrinsicImplementationForRuntimeHelpers(MethodDesc * ftn, int tokCompareTo = pCompareToMD->GetMemberDef(); unsigned int index = (et - ELEMENT_TYPE_I1); - _ASSERTE(index < _countof(ilcode)); + _ASSERTE(index < ARRAY_SIZE(ilcode)); ilcode[index][0] = CEE_LDARGA_S; ilcode[index][1] = 0; @@ -8082,7 +8082,7 @@ void CEEInfo::reportTailCallDecision (CORINFO_METHOD_HANDLE callerHnd, static const char * const tailCallType[] = { "optimized tail call", "recursive loop", "helper assisted tailcall" }; - _ASSERTE(tailCallResult >= 0 && (size_t)tailCallResult < _countof(tailCallType)); + _ASSERTE(tailCallResult >= 0 && (size_t)tailCallResult < ARRAY_SIZE(tailCallType)); LOG((LF_JIT, LL_INFO100000, "While compiling '%S', %Splicit tail call from '%S' to '%S' generated as a %s.\n", currentMethodName.GetUnicode(), fIsTailPrefix ? W("ex") : W("im"), @@ -11415,18 +11415,18 @@ void CEEJitInfo::recordRelocation(void * location, // where the jitted code will end up at. Instead we try to keep executable code // and static fields in a preferred memory region and base the decision on this // region. -// +// // If we guess wrong we will recover in recordRelocation if we notice that we // cannot actually use the kind of reloc: in that case we will rejit the // function and turn off the use of those relocs in the future. This scheme // works based on two assumptions: -// +// // 1) The JIT will ask about relocs only for memory that was allocated by the -// loader heap in the preferred region. +// loader heap in the preferred region. // 2) The loader heap allocates memory in the preferred region in a circular fashion; // the region itself might be larger than 2 GB, but the current compilation should // only be hitting the preferred region within 2 GB. -// +// // Under these assumptions we should only hit the "recovery" case once the // preferred range is actually full. WORD CEEJitInfo::getRelocTypeHint(void * target) diff --git a/src/coreclr/vm/managedmdimport.cpp b/src/coreclr/vm/managedmdimport.cpp index ec2aef0cc0398..622e74edb994d 100644 --- a/src/coreclr/vm/managedmdimport.cpp +++ b/src/coreclr/vm/managedmdimport.cpp @@ -155,7 +155,7 @@ static int * EnsureResultSize(MetadataEnumResult * pResult, ULONG length) int * p; - if (length >= NumItems(pResult->smallResult) || DbgRandomOnExe(.01)) + if (length >= ARRAY_SIZE(pResult->smallResult) || DbgRandomOnExe(.01)) { pResult->largeResult = (I4Array *)OBJECTREFToObject(AllocatePrimitiveArray(ELEMENT_TYPE_I4, length)); p = pResult->largeResult->GetDirectPointerToNonObjectElements(); diff --git a/src/coreclr/vm/mlinfo.cpp b/src/coreclr/vm/mlinfo.cpp index bb3aaf700eae4..69cba82dcf6f4 100644 --- a/src/coreclr/vm/mlinfo.cpp +++ b/src/coreclr/vm/mlinfo.cpp @@ -6,7 +6,6 @@ // - #include "common.h" #include "mlinfo.h" #include "dllimport.h" @@ -26,18 +25,12 @@ #include "dispparammarshaler.h" #endif // FEATURE_COMINTEROP - -#ifndef lengthof - #define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) -#endif - - #ifdef FEATURE_COMINTEROP DEFINE_ASM_QUAL_TYPE_NAME(ENUMERATOR_TO_ENUM_VARIANT_CM_NAME, g_EnumeratorToEnumClassName, g_CorelibAsmName); - static const int ENUMERATOR_TO_ENUM_VARIANT_CM_NAME_LEN = lengthof(ENUMERATOR_TO_ENUM_VARIANT_CM_NAME); + static const int ENUMERATOR_TO_ENUM_VARIANT_CM_NAME_LEN = ARRAY_SIZE(ENUMERATOR_TO_ENUM_VARIANT_CM_NAME); static const char ENUMERATOR_TO_ENUM_VARIANT_CM_COOKIE[] = {""}; - static const int ENUMERATOR_TO_ENUM_VARIANT_CM_COOKIE_LEN = lengthof(ENUMERATOR_TO_ENUM_VARIANT_CM_COOKIE); + static const int ENUMERATOR_TO_ENUM_VARIANT_CM_COOKIE_LEN = ARRAY_SIZE(ENUMERATOR_TO_ENUM_VARIANT_CM_COOKIE); DEFINE_ASM_QUAL_TYPE_NAME(COLOR_TRANSLATOR_ASM_QUAL_TYPE_NAME, g_ColorTranslatorClassName, g_DrawingAsmName); DEFINE_ASM_QUAL_TYPE_NAME(COLOR_ASM_QUAL_TYPE_NAME, g_ColorClassName, g_DrawingAsmName); diff --git a/src/coreclr/vm/multicorejit.cpp b/src/coreclr/vm/multicorejit.cpp index 656c7744066b0..2ad518bf9f736 100644 --- a/src/coreclr/vm/multicorejit.cpp +++ b/src/coreclr/vm/multicorejit.cpp @@ -117,9 +117,9 @@ void _MulticoreJitTrace(const char * format, ...) int len; - len = sprintf_s(buffer, _countof(buffer), "Mcj TID %04x: ", GetCurrentThreadId()); - len += _vsnprintf_s(buffer + len, _countof(buffer) - len, format, args); - len += sprintf_s(buffer + len, _countof(buffer) - len, ", (time=%d ms)\r\n", GetTickCount() - s_startTick); + len = sprintf_s(buffer, ARRAY_SIZE(buffer), "Mcj TID %04x: ", GetCurrentThreadId()); + len += _vsnprintf_s(buffer + len, ARRAY_SIZE(buffer) - len, format, args); + len += sprintf_s(buffer + len, ARRAY_SIZE(buffer) - len, ", (time=%d ms)\r\n", GetTickCount() - s_startTick); OutputDebugStringA(buffer); #endif diff --git a/src/coreclr/vm/perfmap.cpp b/src/coreclr/vm/perfmap.cpp index 48f178aeb67c3..30708584c3f72 100644 --- a/src/coreclr/vm/perfmap.cpp +++ b/src/coreclr/vm/perfmap.cpp @@ -247,7 +247,7 @@ void PerfMap::LogImage(PEAssembly * pPEAssembly) EX_TRY { WCHAR wszSignature[39]; - GetNativeImageSignature(pPEAssembly, wszSignature, lengthof(wszSignature)); + GetNativeImageSignature(pPEAssembly, wszSignature, ARRAY_SIZE(wszSignature)); m_PerfInfo->LogImage(pPEAssembly, wszSignature); } @@ -393,7 +393,7 @@ NativeImagePerfMap::NativeImagePerfMap(Assembly * pAssembly, BSTR pDestPath) // Get the native image signature (GUID). // Used to ensure that we match symbols to the correct NGEN image. WCHAR wszSignature[39]; - GetNativeImageSignature(pAssembly->GetManifestFile(), wszSignature, lengthof(wszSignature)); + GetNativeImageSignature(pAssembly->GetManifestFile(), wszSignature, ARRAY_SIZE(wszSignature)); // Build the path to the perfmap file, which consists of .ni..map. // Example: /tmp/System.Private.CoreLib.ni.{GUID}.map diff --git a/src/coreclr/vm/pinvokeoverride.cpp b/src/coreclr/vm/pinvokeoverride.cpp index a2f32310fb48d..b24ad53842b86 100644 --- a/src/coreclr/vm/pinvokeoverride.cpp +++ b/src/coreclr/vm/pinvokeoverride.cpp @@ -46,7 +46,7 @@ const void* PInvokeOverride::GetMethodImpl(const char* libraryName, const char* { if (s_hasOverrides) { - for (size_t i = 0; i < _countof(s_overrideImpls); ++i) + for (size_t i = 0; i < ARRAY_SIZE(s_overrideImpls); ++i) { PInvokeOverrideFn* overrideImpl = s_overrideImpls[i]; if (overrideImpl == nullptr) diff --git a/src/coreclr/vm/profilinghelper.inl b/src/coreclr/vm/profilinghelper.inl index f642630760098..57544c493f7fa 100644 --- a/src/coreclr/vm/profilinghelper.inl +++ b/src/coreclr/vm/profilinghelper.inl @@ -111,7 +111,7 @@ inline void ProfilingAPIUtility::LogNoInterfaceError(REFIID iidRequested, LPCWST CONTRACTL_END; WCHAR wszIidRequested[39]; - if (StringFromGUID2(iidRequested, wszIidRequested, lengthof(wszIidRequested)) == 0) + if (StringFromGUID2(iidRequested, wszIidRequested, ARRAY_SIZE(wszIidRequested)) == 0) { // This is a little super-paranoid; but just use an empty string if GUIDs // get bigger than we expect. @@ -183,7 +183,7 @@ inline HRESULT ProfilingAPIUtility::LoadProfilerForAttach( // Need string version of CLSID for event log messages WCHAR wszClsid[40]; - if (StringFromGUID2(*pClsid, wszClsid, _countof(wszClsid)) == 0) + if (StringFromGUID2(*pClsid, wszClsid, ARRAY_SIZE(wszClsid)) == 0) { _ASSERTE(!"StringFromGUID2 failed!"); return E_UNEXPECTED; diff --git a/src/coreclr/vm/proftoeeinterfaceimpl.cpp b/src/coreclr/vm/proftoeeinterfaceimpl.cpp index 5c47a34f70487..2f742d05638a5 100644 --- a/src/coreclr/vm/proftoeeinterfaceimpl.cpp +++ b/src/coreclr/vm/proftoeeinterfaceimpl.cpp @@ -763,7 +763,7 @@ void GenerationTable::AddRecord(int generation, BYTE* rangeStart, BYTE* rangeEnd // Because the segment/region are added to the heap before they are reported to the profiler, // it is possible that the region is added to the heap, a racing GenerationTable refresh happened, - // that refresh would contain the new region, and then it get reported again here. + // that refresh would contain the new region, and then it get reported again here. // This check will make sure we never add duplicated record to the table. for (ULONG i = 0; i < count; i++) { @@ -889,14 +889,14 @@ void GenerationTable::Refresh() { // fill in the values by calling back into the gc, which will report // the ranges by calling GenWalkFunc for each one - CrstHolder holder(&mutex); + CrstHolder holder(&mutex); IGCHeap *hp = GCHeapUtilities::GetGCHeap(); this->count = 0; hp->DiagDescrGenerations(GenWalkFunc, this); } // This is the table of generation bounds updated by the gc -// and read by the profiler. +// and read by the profiler. static GenerationTable *s_currentGenerationTable; // This is just so we can assert there's a single writer @@ -944,7 +944,7 @@ void __stdcall UpdateGenerationBounds() { RETURN; } - s_currentGenerationTable->Refresh(); + s_currentGenerationTable->Refresh(); } #endif // PROFILING_SUPPORTED RETURN; @@ -2420,7 +2420,7 @@ HRESULT ProfToEEInterfaceImpl::GetCodeInfo(FunctionID functionId, LPCBYTE * pSta HRESULT hr = GetCodeInfoFromCodeStart( pMethodDesc->GetNativeCode(), - _countof(codeInfos), + ARRAY_SIZE(codeInfos), &cCodeInfos, codeInfos); diff --git a/src/coreclr/vm/qcallentrypoints.cpp b/src/coreclr/vm/qcallentrypoints.cpp index 472a2c1a962c6..96971b8180195 100644 --- a/src/coreclr/vm/qcallentrypoints.cpp +++ b/src/coreclr/vm/qcallentrypoints.cpp @@ -74,7 +74,7 @@ #include "tailcallhelp.h" -#include +#include static const Entry s_QCall[] = { @@ -321,5 +321,5 @@ static const Entry s_QCall[] = const void* QCallResolveDllImport(const char* name) { - return minipal_resolve_dllimport(s_QCall, lengthof(s_QCall), name); + return minipal_resolve_dllimport(s_QCall, ARRAY_SIZE(s_QCall), name); } diff --git a/src/coreclr/vm/siginfo.cpp b/src/coreclr/vm/siginfo.cpp index 4c438360513cb..f10acff25522e 100644 --- a/src/coreclr/vm/siginfo.cpp +++ b/src/coreclr/vm/siginfo.cpp @@ -43,7 +43,7 @@ CorTypeInfo::FindPrimitiveType(LPCUTF8 name) _ASSERTE(name != NULL); - for (unsigned int i = 1; i < _countof(CorTypeInfo::info); i++) + for (unsigned int i = 1; i < ARRAY_SIZE(CorTypeInfo::info); i++) { // can skip ELEMENT_TYPE_END (index 0) if ((info[i].className != NULL) && (strcmp(name, info[i].className) == 0)) return (CorElementType)i; @@ -2728,7 +2728,7 @@ HRESULT TypeIdentifierData::Init(Module *pModule, mdToken tk) args[0].Init(SERIALIZATION_TYPE_STRING, 0); args[1].Init(SERIALIZATION_TYPE_STRING, 0); - IfFailRet(ParseKnownCaArgs(caType, args, lengthof(args))); + IfFailRet(ParseKnownCaArgs(caType, args, ARRAY_SIZE(args))); m_cbScope = args[0].val.str.cbStr; m_pchScope = args[0].val.str.pStr; diff --git a/src/coreclr/vm/syncblk.h b/src/coreclr/vm/syncblk.h index 3b79753069976..ff674963b6db2 100644 --- a/src/coreclr/vm/syncblk.h +++ b/src/coreclr/vm/syncblk.h @@ -920,7 +920,7 @@ class InteropSyncBlockInfo size_t GetTaggedMemorySizeInBytes() { LIMITED_METHOD_CONTRACT; - return _countof(m_taggedAlloc); + return ARRAY_SIZE(m_taggedAlloc); } private: diff --git a/src/coreclr/vm/threads.cpp b/src/coreclr/vm/threads.cpp index be14a7a8b883e..200d36586ef52 100644 --- a/src/coreclr/vm/threads.cpp +++ b/src/coreclr/vm/threads.cpp @@ -1927,7 +1927,7 @@ BOOL Thread::HasStarted() { BEGIN_PROFILER_CALLBACK(CORProfilerTrackThreads()); BOOL gcOnTransition = GC_ON_TRANSITIONS(FALSE); // disable GCStress 2 to avoid the profiler receiving a RuntimeThreadSuspended notification even before the ThreadCreated notification - + { GCX_PREEMP(); (&g_profControlBlock)->ThreadCreated((ThreadID) this); @@ -8278,7 +8278,7 @@ void dbgOnly_IdentifySpecialEEThread() LONG ourCount = FastInterlockIncrement(&cnt_SpecialEEThreads); - _ASSERTE(ourCount < (LONG) NumItems(SpecialEEThreads)); + _ASSERTE(ourCount < (LONG) ARRAY_SIZE(SpecialEEThreads)); SpecialEEThreads[ourCount-1] = ::GetCurrentThreadId(); } diff --git a/src/coreclr/vm/typehandle.cpp b/src/coreclr/vm/typehandle.cpp index 48d1c589b44cc..13e59e5ffeb6f 100644 --- a/src/coreclr/vm/typehandle.cpp +++ b/src/coreclr/vm/typehandle.cpp @@ -1590,7 +1590,7 @@ CHECK TypeHandle::CheckLoadLevel(ClassLoadLevel requiredLevel) { CHECK(!IsNull()); // CHECK_MSGF(!IsNull(), ("Type is null, required load level is %s", classLoadLevelName[requiredLevel])); - static_assert_no_msg(NumItems(classLoadLevelName) == (1 + CLASS_LOAD_LEVEL_FINAL)); + static_assert_no_msg(ARRAY_SIZE(classLoadLevelName) == (1 + CLASS_LOAD_LEVEL_FINAL)); // Quick check to avoid creating debug string ClassLoadLevel actualLevel = GetLoadLevel(); diff --git a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c index c9cd85ca43782..31581fbe0c520 100644 --- a/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c +++ b/src/libraries/Native/AnyOS/System.IO.Compression.Native/entrypoints.c @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include +#include // Include System.IO.Compression.Native headers #include "../zlib/pal_zlib.h" @@ -38,5 +38,5 @@ EXTERN_C const void* CompressionResolveDllImport(const char* name); EXTERN_C const void* CompressionResolveDllImport(const char* name) { - return minipal_resolve_dllimport(s_compressionNative, lengthof(s_compressionNative), name); + return minipal_resolve_dllimport(s_compressionNative, ARRAY_SIZE(s_compressionNative), name); } diff --git a/src/libraries/Native/Unix/Common/pal_io_common.h b/src/libraries/Native/Unix/Common/pal_io_common.h index 0cd640cca9d47..82a8289744473 100644 --- a/src/libraries/Native/Unix/Common/pal_io_common.h +++ b/src/libraries/Native/Unix/Common/pal_io_common.h @@ -8,6 +8,7 @@ #include #include #include +#include /** * Our intermediate pollfd struct to normalize the data types diff --git a/src/libraries/Native/Unix/Common/pal_utilities.h b/src/libraries/Native/Unix/Common/pal_utilities.h index 55d35030ce24d..4e582ed6cd002 100644 --- a/src/libraries/Native/Unix/Common/pal_utilities.h +++ b/src/libraries/Native/Unix/Common/pal_utilities.h @@ -43,8 +43,6 @@ #define CONST_CAST2(TOTYPE, FROMTYPE, X) ((union { FROMTYPE _q; TOTYPE _nq; }){ ._q = (X) }._nq) #define CONST_CAST(TYPE, X) CONST_CAST2(TYPE, const TYPE, (X)) -#define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0])) - #if __has_attribute(fallthrough) #define FALLTHROUGH __attribute__((fallthrough)) #else diff --git a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c index 70db3145cd48b..8d4901f62dcf6 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/entrypoints.c @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include +#include typedef uint16_t UChar; @@ -64,5 +64,5 @@ EXTERN_C const void* GlobalizationResolveDllImport(const char* name); EXTERN_C const void* GlobalizationResolveDllImport(const char* name) { - return minipal_resolve_dllimport(s_globalizationNative, lengthof(s_globalizationNative), name); + return minipal_resolve_dllimport(s_globalizationNative, ARRAY_SIZE(s_globalizationNative), name); } diff --git a/src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.c b/src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.c index 686fbf5631fd9..9c82586c68775 100644 --- a/src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.c +++ b/src/libraries/Native/Unix/System.Globalization.Native/pal_localeNumberData.c @@ -7,6 +7,8 @@ #include #include +#include + #include "pal_locale_internal.h" #include "pal_localeNumberData.h" @@ -21,8 +23,6 @@ #define UCHAR_CLOSEPAREN ((UChar)0x0029) // ')' #define UCHAR_ZERO ((UChar)0x0030) // '0' -#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0])) - /* Function: NormalizeNumericPattern @@ -239,7 +239,7 @@ static int GetCurrencyNegativePattern(const char* locale) if (U_SUCCESS(status)) { - int value = GetNumericPattern(pFormat, Patterns, ARRAY_LENGTH(Patterns), true); + int value = GetNumericPattern(pFormat, Patterns, ARRAY_SIZE(Patterns), true); if (value >= 0) { unum_close(pFormat); @@ -270,7 +270,7 @@ static int GetCurrencyPositivePattern(const char* locale) if (U_SUCCESS(status)) { - int value = GetNumericPattern(pFormat, Patterns, ARRAY_LENGTH(Patterns), false); + int value = GetNumericPattern(pFormat, Patterns, ARRAY_SIZE(Patterns), false); if (value >= 0) { unum_close(pFormat); @@ -301,7 +301,7 @@ static int GetNumberNegativePattern(const char* locale) if (U_SUCCESS(status)) { - int value = GetNumericPattern(pFormat, Patterns, ARRAY_LENGTH(Patterns), true); + int value = GetNumericPattern(pFormat, Patterns, ARRAY_SIZE(Patterns), true); if (value >= 0) { unum_close(pFormat); @@ -333,7 +333,7 @@ static int GetPercentNegativePattern(const char* locale) if (U_SUCCESS(status)) { - int value = GetNumericPattern(pFormat, Patterns, ARRAY_LENGTH(Patterns), true); + int value = GetNumericPattern(pFormat, Patterns, ARRAY_SIZE(Patterns), true); if (value >= 0) { unum_close(pFormat); @@ -364,7 +364,7 @@ static int GetPercentPositivePattern(const char* locale) if (U_SUCCESS(status)) { - int value = GetNumericPattern(pFormat, Patterns, ARRAY_LENGTH(Patterns), false); + int value = GetNumericPattern(pFormat, Patterns, ARRAY_SIZE(Patterns), false); if (value >= 0) { unum_close(pFormat); diff --git a/src/libraries/Native/Unix/System.Native/entrypoints.c b/src/libraries/Native/Unix/System.Native/entrypoints.c index 6175dec7fbad0..ab227685b5a89 100644 --- a/src/libraries/Native/Unix/System.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Native/entrypoints.c @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include +#include // Include System.Native headers #include "pal_autoreleasepool.h" @@ -268,5 +268,5 @@ EXTERN_C const void* SystemResolveDllImport(const char* name); EXTERN_C const void* SystemResolveDllImport(const char* name) { - return minipal_resolve_dllimport(s_sysNative, lengthof(s_sysNative), name); + return minipal_resolve_dllimport(s_sysNative, ARRAY_SIZE(s_sysNative), name); } diff --git a/src/libraries/Native/Unix/System.Native/pal_process.c b/src/libraries/Native/Unix/System.Native/pal_process.c index cb8bdf319eb10..01a9db0bb6f6e 100644 --- a/src/libraries/Native/Unix/System.Native/pal_process.c +++ b/src/libraries/Native/Unix/System.Native/pal_process.c @@ -39,7 +39,7 @@ #include #endif -#include +#include // Validate that our SysLogPriority values are correct for the platform c_static_assert(PAL_LOG_EMERG == LOG_EMERG); diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c b/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c index 6c442722734e5..cdcc012b18afa 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Net.Security.Native/entrypoints.c @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include +#include // Include System.Net.Security.Native headers #include "pal_gssapi.h" @@ -33,5 +33,5 @@ EXTERN_C const void* SecurityResolveDllImport(const char* name); EXTERN_C const void* SecurityResolveDllImport(const char* name) { - return minipal_resolve_dllimport(s_securityNative, lengthof(s_securityNative), name); + return minipal_resolve_dllimport(s_securityNative, ARRAY_SIZE(s_securityNative), name); } diff --git a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.c b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.c index ef84a024777d3..7ccc59631b95c 100644 --- a/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.c +++ b/src/libraries/Native/Unix/System.Net.Security.Native/pal_gssapi.c @@ -5,6 +5,8 @@ #include "pal_utilities.h" #include "pal_gssapi.h" +#include + #if HAVE_GSSFW_HEADERS #include #else @@ -45,12 +47,12 @@ c_static_assert(PAL_GSS_CONTINUE_NEEDED == GSS_S_CONTINUE_NEEDED); #if !HAVE_GSS_SPNEGO_MECHANISM static char gss_spnego_oid_value[] = "\x2b\x06\x01\x05\x05\x02"; // Binary representation of SPNEGO Oid (RFC 4178) -static gss_OID_desc gss_mech_spnego_OID_desc = {.length = ARRAY_SIZE(gss_spnego_oid_value) - 1, +static gss_OID_desc gss_mech_spnego_OID_desc = {.length = STRING_LENGTH(gss_spnego_oid_value), .elements = gss_spnego_oid_value}; static char gss_ntlm_oid_value[] = "\x2b\x06\x01\x04\x01\x82\x37\x02\x02\x0a"; // Binary representation of NTLM OID // (https://msdn.microsoft.com/en-us/library/cc236636.aspx) -static gss_OID_desc gss_mech_ntlm_OID_desc = {.length = ARRAY_SIZE(gss_ntlm_oid_value) - 1, +static gss_OID_desc gss_mech_ntlm_OID_desc = {.length = STRING_LENGTH(gss_ntlm_oid_value), .elements = gss_ntlm_oid_value}; #endif diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/entrypoints.c b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/entrypoints.c index c6df8a210029b..78b451a781f53 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/entrypoints.c +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native.Apple/entrypoints.c @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include +#include // Include System.Security.Cryptography.Native.Apple headers #include "pal_digest.h" @@ -131,5 +131,5 @@ EXTERN_C const void* CryptoAppleResolveDllImport(const char* name); EXTERN_C const void* CryptoAppleResolveDllImport(const char* name) { - return minipal_resolve_dllimport(s_cryptoAppleNative, lengthof(s_cryptoAppleNative), name); + return minipal_resolve_dllimport(s_cryptoAppleNative, ARRAY_SIZE(s_cryptoAppleNative), name); } diff --git a/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c b/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c index 2a00d55085459..4a95b97756a32 100644 --- a/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c +++ b/src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#include +#include // Include System.Security.Cryptography.Native headers #include "openssl.h" @@ -29,7 +29,6 @@ #include "pal_x509_name.h" #include "pal_x509_root.h" - static const Entry s_cryptoNative[] = { DllImportEntry(CryptoNative_Asn1BitStringFree) @@ -336,5 +335,5 @@ EXTERN_C const void* CryptoResolveDllImport(const char* name); EXTERN_C const void* CryptoResolveDllImport(const char* name) { - return minipal_resolve_dllimport(s_cryptoNative, lengthof(s_cryptoNative), name); + return minipal_resolve_dllimport(s_cryptoNative, ARRAY_SIZE(s_cryptoNative), name); } diff --git a/src/mono/mono/component/debugger-agent.c b/src/mono/mono/component/debugger-agent.c index 792563b796579..2cfd24d64ebc3 100644 --- a/src/mono/mono/component/debugger-agent.c +++ b/src/mono/mono/component/debugger-agent.c @@ -197,12 +197,12 @@ struct _DebuggerTlsData { /* It is freed up when the thread is resumed */ int frame_count; StackFrame **frames; - /* + /* * Whenever the frame info is up-to-date. If not, compute_frame_info () will need to * re-compute it. */ gboolean frames_up_to_date; - /* + /* * Points to data about a pending invoke which needs to be executed after the thread * resumes. */ @@ -338,7 +338,7 @@ static DebuggerTlsData debugger_wasm_thread; #endif static AgentConfig agent_config; -/* +/* * Whenever the agent is fully initialized. * When using the onuncaught or onthrow options, only some parts of the agent are * initialized on startup, and the full initialization which includes connection @@ -431,7 +431,7 @@ MonoDefaults *mdbg_mono_defaults; mono_loader_unlock(); #define GET_DEBUGGER_TLS() \ DebuggerTlsData *tls; \ - tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); + tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); #else #define GET_TLS_DATA_FROM_THREAD(thread) \ DebuggerTlsData *tls; \ @@ -750,7 +750,7 @@ debugger_agent_init (MonoDefaults *mono_defaults) return; mdbg_mono_defaults = mono_defaults; - + DebuggerEngineCallbacks cbs; memset (&cbs, 0, sizeof (cbs)); cbs.tls_get_restore_state = tls_get_restore_state; @@ -823,7 +823,7 @@ debugger_agent_init (MonoDefaults *mono_defaults) suspend_init (); mini_get_debug_options ()->gen_sdb_seq_points = TRUE; - /* + /* * This is needed because currently we don't handle liveness info. */ mini_get_debug_options ()->mdb_optimizations = TRUE; @@ -971,7 +971,7 @@ socket_transport_recv (void *buf, int len) return total; } - + static void set_keepalive (void) { @@ -999,7 +999,7 @@ socket_transport_accept (int socket_fd) } else { PRINT_DEBUG_MSG (1, "Accepted connection from client, connection fd=%d.\n", conn_fd); } - + return conn_fd; } @@ -1050,7 +1050,7 @@ socket_transport_connect (const char *address) conn_fd = -1; listen_fd = -1; - + MONO_ENTER_GC_UNSAFE; mono_networking_init(); MONO_EXIT_GC_UNSAFE; @@ -1197,7 +1197,7 @@ socket_transport_connect (const char *address) if (res != -1) break; /* Success */ - + #ifdef HOST_WIN32 closesocket (sfd); #else @@ -1208,7 +1208,7 @@ socket_transport_connect (const char *address) if (rp == 0) sleep (1); } while ((elapsedTime < agent_config.timeout) && (rp == 0)); - + if (rp == 0) { PRINT_ERROR_MSG ("debugger-agent: Unable to connect to %s:%d\n", host, port); @@ -1221,7 +1221,7 @@ socket_transport_connect (const char *address) mono_free_address_info (result); MONO_EXIT_GC_UNSAFE; } - + gboolean handshake_ok; MONO_ENTER_GC_UNSAFE; handshake_ok = transport_handshake (); @@ -1410,11 +1410,11 @@ transport_handshake (void) char handshake_msg [128]; guint8 buf [128]; int res; - + MONO_REQ_GC_UNSAFE_MODE; disconnected = TRUE; - + /* Write handshake message */ sprintf (handshake_msg, "DWP-Handshake"); @@ -1442,7 +1442,7 @@ transport_handshake (void) #ifndef DISABLE_SOCKET_TRANSPORT // FIXME: Move this somewhere else - /* + /* * Set TCP_NODELAY on the socket so the client receives events/command * results immediately. */ @@ -1460,7 +1460,7 @@ transport_handshake (void) set_keepalive (); MONO_EXIT_GC_SAFE; #endif - + disconnected = FALSE; return TRUE; } @@ -1473,7 +1473,7 @@ stop_debugger_thread (void) transport_close1 (); - /* + /* * Wait for the thread to exit. * * If we continue with the shutdown without waiting for it, then the client might @@ -1505,7 +1505,7 @@ start_debugger_thread (MonoError *error) /* Is it possible for the thread to be dead alreay ? */ debugger_thread_handle = mono_threads_open_thread_handle (thread->handle); g_assert (debugger_thread_handle); - + } static gboolean @@ -1612,7 +1612,7 @@ static GHashTable *obj_to_objref; static MonoGHashTable *suspended_objs; #ifdef TARGET_WASM -void +void mono_init_debugger_agent_for_wasm (int log_level_parm, MonoProfilerHandle *prof) { if (mono_atomic_cas_i32 (&agent_inited, 1, 0) == 1) @@ -1676,7 +1676,7 @@ get_objref (MonoObject *obj) } mono_loader_lock (); - + /* FIXME: The tables can grow indefinitely */ if (mono_gc_is_moving ()) { @@ -2223,14 +2223,14 @@ save_thread_context (MonoContext *ctx) #ifdef TARGET_WASM void -mono_wasm_save_thread_context (void) +mono_wasm_save_thread_context (void) { debugger_wasm_thread.really_suspended = TRUE; mono_thread_state_init_from_current (&debugger_wasm_thread.context); } DebuggerTlsData* -mono_wasm_get_tls (void) +mono_wasm_get_tls (void) { return &debugger_wasm_thread; } @@ -2248,7 +2248,7 @@ static void suspend_init (void) { mono_coop_mutex_init (&suspend_mutex); - mono_coop_cond_init (&suspend_cond); + mono_coop_cond_init (&suspend_cond); mono_coop_sem_init (&suspend_sem, 0); } @@ -2319,8 +2319,8 @@ thread_interrupt (DebuggerTlsData *tls, MonoThreadInfo *info, MonoJitInfo *ji) /* Running managed code, will be suspended by the single step code */ PRINT_DEBUG_MSG (1, "[%p] Received interrupt while at %s(%p), continuing.\n", (gpointer)(gsize)tid, jinfo_get_method (ji)->name, ip); } else { - /* - * Running native code, will be suspended when it returns to/enters + /* + * Running native code, will be suspended when it returns to/enters * managed code. Treat it as already suspended. * This might interrupt the code in mono_de_process_single_step (), we use the * tls->suspending flag to avoid races when that happens. @@ -2344,7 +2344,7 @@ thread_interrupt (DebuggerTlsData *tls, MonoThreadInfo *info, MonoJitInfo *ji) * the thread is still running, so it might return to managed code, * making these invalid. * So we start a stack walk and save the first frame, along with the - * parent frame's ctx+lmf. This (hopefully) works because the thread will be + * parent frame's ctx+lmf. This (hopefully) works because the thread will be * suspended when it returns to managed code, so the parent's ctx should * remain valid. */ @@ -2381,7 +2381,7 @@ thread_interrupt (DebuggerTlsData *tls, MonoThreadInfo *info, MonoJitInfo *ji) /* * reset_native_thread_suspend_state: - * + * * Reset the suspended flag and state on native threads */ static void @@ -2452,7 +2452,7 @@ notify_thread (gpointer key, gpointer value, gpointer user_data) mono_thread_info_safe_suspend_and_run ((MonoNativeThreadId)(gsize)thread->tid, FALSE, debugger_interrupt_critical, &interrupt_data); if (!interrupt_data.valid_info) { PRINT_DEBUG_MSG (1, "[%p] mono_thread_info_suspend_sync () failed for %p...\n", (gpointer) (gsize) mono_native_thread_id_get (), (gpointer)tid); - /* + /* * Attached thread which died without detaching. */ tls->terminated = TRUE; @@ -2485,8 +2485,8 @@ process_suspend (DebuggerTlsData *tls, MonoContext *ctx) PRINT_DEBUG_MSG (1, "[%p] Received single step event for suspending.\n", (gpointer) (gsize) mono_native_thread_id_get ()); if (suspend_count - tls->resume_count == 0) { - /* - * We are executing a single threaded invoke but the single step for + /* + * We are executing a single threaded invoke but the single step for * suspending is still active. * FIXME: This slows down single threaded invokes. */ @@ -2512,16 +2512,16 @@ static gboolean try_process_suspend (void *the_tls, MonoContext *ctx, gboolean from_breakpoint) { MONO_REQ_GC_UNSAFE_MODE; - + DebuggerTlsData *tls = (DebuggerTlsData*)the_tls; /* if there is a suspend pending that is not executed yes */ - if (suspend_count > 0) { + if (suspend_count > 0) { /* Fastpath during invokes, see in process_suspend () */ /* if there is a suspend pending but this thread is already resumed, we shouldn't suspend it again and the breakpoint/ss can run */ - if (suspend_count - tls->resume_count == 0) + if (suspend_count - tls->resume_count == 0) return FALSE; /* if there is in a invoke the breakpoint/step should be executed even with the suspend pending */ - if (tls->invoke) + if (tls->invoke) return FALSE; /* with the multithreaded single step check if there is a suspend_count pending in the current thread and not in the vm */ if (from_breakpoint && tls->suspend_count <= tls->resume_count_internal) @@ -2535,7 +2535,7 @@ try_process_suspend (void *the_tls, MonoContext *ctx, gboolean from_breakpoint) /* * suspend_vm: * - * Increase the suspend count of the VM. While the suspend count is greater + * Increase the suspend count of the VM. While the suspend count is greater * than 0, runtime threads are suspended at certain points during execution. */ static void @@ -2621,7 +2621,7 @@ resume_thread (MonoInternalThread *thread) tls->resume_count_internal += tls->suspend_count; tls->suspend_count = 0; - /* + /* * Signal suspend_count without decreasing suspend_count, the threads will wake up * but only the one whose resume_count field is > 0 will be resumed. */ @@ -2669,8 +2669,8 @@ invalidate_frames (DebuggerTlsData *tls) /* * suspend_current: * - * Suspend the current thread until the runtime is resumed. If the thread has a - * pending invoke, then the invoke is executed before this function returns. + * Suspend the current thread until the runtime is resumed. If the thread has a + * pending invoke, then the invoke is executed before this function returns. */ static void suspend_current (void) @@ -2757,7 +2757,7 @@ count_threads_to_wait_for (void) mono_loader_unlock (); return count; -} +} /* * wait_for_suspend: @@ -3078,7 +3078,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f #ifndef TARGET_WASM int i; - /* + /* * Reuse the id for already existing stack frames, so invokes don't invalidate * the still valid stack frames. */ @@ -3091,7 +3091,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f if (i >= tls->frame_count) f->id = mono_atomic_inc_i32 (&frame_id); -#else //keep the same behavior that we have for wasm before start using debugger-agent +#else //keep the same behavior that we have for wasm before start using debugger-agent f->id = findex+1; #endif new_frames [findex ++] = f; @@ -3119,7 +3119,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f } } } -#endif +#endif } /* @@ -3298,7 +3298,7 @@ init_jit_info_dbg_attrs (MonoJitInfo *ji) * Return a list of event request ids matching EVENT, starting from REQS, which * can be NULL to include all event requests. Set SUSPEND_POLICY to the suspend * policy. - * We return request ids, instead of requests, to simplify threading, since + * We return request ids, instead of requests, to simplify threading, since * requests could be deleted anytime when the loader lock is not held. * LOCKING: Assumes the loader lock is held. */ @@ -3359,7 +3359,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo (mod->data.exc_class && !mod->subclasses && mod->data.exc_class != ei->exc->vtable->klass)) { is_already_filtered = TRUE; if ((ei->caught && mod->caught) || (!ei->caught && mod->uncaught)) { - filteredException = FALSE; + filteredException = FALSE; filtered_suspend_policy = req->suspend_policy; filtered_req_id = req->id; } @@ -3373,7 +3373,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo } if (!mod->data.exc_class && !mod->everything_else) { if ((ei->caught && mod->caught) || (!ei->caught && mod->uncaught)) { - filteredException = FALSE; + filteredException = FALSE; filtered_suspend_policy = req->suspend_policy; filtered_req_id = req->id; } @@ -3468,7 +3468,7 @@ create_event_list (EventKind event, GPtrArray *reqs, MonoJitInfo *ji, EventInfo } if (has_everything_else && !is_already_filtered) { - filteredException = FALSE; + filteredException = FALSE; filtered_suspend_policy = everything_else_suspend_policy; filtered_req_id = everything_else_req_id; } @@ -3551,9 +3551,9 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx } } - if (event == EVENT_KIND_VM_START) - suspend_policy = agent_config.suspend ? SUSPEND_POLICY_ALL : SUSPEND_POLICY_NONE; - + if (event == EVENT_KIND_VM_START) + suspend_policy = agent_config.suspend ? SUSPEND_POLICY_ALL : SUSPEND_POLICY_NONE; + nevents = g_slist_length (events); buffer_init (&buf, 128); buffer_add_byte (&buf, suspend_policy); @@ -3635,7 +3635,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx buffer_add_objid (&buf, ei->exc); #ifdef TARGET_WASM buffer_add_byte (&buf, ei->caught); -#endif +#endif /* * We are not yet suspending, so get_objref () will not keep this object alive. So we need to do it * later after the suspension. (#12494). @@ -3662,7 +3662,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx case EVENT_KIND_KEEPALIVE: suspend_policy = SUSPEND_POLICY_NONE; break; - + case MDBGPROT_EVENT_KIND_ENC_UPDATE: { EnCInfo *ei = (EnCInfo *)arg; buffer_add_moduleid (&buf, mono_domain_get (), ei->image); @@ -3683,7 +3683,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx mono_error_assert_ok (error); } } - + if (event == EVENT_KIND_VM_DEATH) { vm_death_event_sent = TRUE; suspend_policy = SUSPEND_POLICY_NONE; @@ -3693,7 +3693,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx suspend_policy = SUSPEND_POLICY_NONE; if (suspend_policy != SUSPEND_POLICY_NONE) { - /* + /* * Save the thread context and start suspending before sending the packet, * since we could be receiving the resume request before send_packet () * returns. @@ -3724,7 +3724,7 @@ process_event (EventKind event, gpointer arg, gint32 il_offset, MonoContext *ctx PRINT_DEBUG_MSG (2, "Sending command %s failed.\n", event_to_string (event)); return; } - + if (event == EVENT_KIND_VM_START) { vm_start_event_sent = TRUE; } @@ -3802,7 +3802,7 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) mono_loader_unlock (); if (old_thread) { if (thread == old_thread) { - /* + /* * For some reason, thread_startup () might be called for the same thread * multiple times (attach ?). */ @@ -3842,10 +3842,10 @@ thread_startup (MonoProfiler *prof, uintptr_t tid) process_profiler_event (EVENT_KIND_THREAD_START, thread); - /* + /* * suspend_vm () could have missed this thread, so wait for a resume. */ - + suspend_current (); } @@ -3930,12 +3930,12 @@ appdomain_unload (MonoProfiler *prof, MonoDomain *domain) tls->domain_unloading = NULL; mono_de_clear_breakpoints_for_domain (domain); - + mono_loader_lock (); /* Invalidate each thread's frame stack */ mono_g_hash_table_foreach (thread_to_tls, invalidate_each_thread, NULL); mono_loader_unlock (); - + process_profiler_event (EVENT_KIND_APPDOMAIN_UNLOAD, domain); } @@ -4010,7 +4010,7 @@ send_types_for_domain (MonoDomain *domain, void *user_data) old_domain = mono_domain_get (); mono_domain_set_fast (domain); - + mono_loader_lock (); g_hash_table_foreach (info->loaded_classes, emit_type_load, NULL); mono_loader_unlock (); @@ -4074,7 +4074,7 @@ jit_end (MonoProfiler *prof, MonoMethod *method, MonoJitInfo *jinfo) } } - // only send typeload from AOTed classes if has .cctor when .cctor emits jit_end + // only send typeload from AOTed classes if has .cctor when .cctor emits jit_end // to avoid deadlock while trying to set a breakpoint in a class that was not fully initialized if (jinfo->from_aot && m_class_has_cctor(method->klass) && (!(method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) || strcmp (method->name, ".cctor"))) { @@ -4122,7 +4122,7 @@ void mono_ss_calculate_framecount (void *the_tls, MonoContext *ctx, gboolean force_use_ctx, DbgEngineStackFrame ***frames, int *nframes) { DebuggerTlsData *tls = (DebuggerTlsData*)the_tls; -#ifndef TARGET_WASM +#ifndef TARGET_WASM if (force_use_ctx || !tls->context.valid) mono_thread_state_init_from_monoctx (&tls->context, ctx); compute_frame_info (tls->thread, tls, FALSE); @@ -4333,7 +4333,7 @@ resume_from_signal_handler (void *sigctx, void *func) PRINT_ERROR_MSG ("Thread %p is not attached to the JIT.\n", (gpointer) (gsize) mono_native_thread_id_get ()); g_assert (tls); - // FIXME: MonoContext usually doesn't include the fp registers, so these are + // FIXME: MonoContext usually doesn't include the fp registers, so these are // clobbered by a single step/breakpoint event. If this turns out to be a problem, // clob:c could be added to op_seq_point. @@ -4443,8 +4443,8 @@ debugger_agent_single_step_event (void *sigctx) // here if (is_debugger_thread ()) { - /* - * This could happen despite our best effors when the runtime calls + /* + * This could happen despite our best effors when the runtime calls * assembly/type resolve hooks. * FIXME: Breakpoints too. */ @@ -4513,8 +4513,8 @@ debugger_agent_breakpoint_from_context (MonoContext *ctx) tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id); g_assert (tls); - - //if a thread was suspended and doesn't have any managed stack, it was considered as terminated, + + //if a thread was suspended and doesn't have any managed stack, it was considered as terminated, //but it wasn't really terminated because it can execute managed code again, and stop in a breakpoint so here we set terminated as FALSE tls->terminated = FALSE; @@ -4572,9 +4572,9 @@ mono_ss_create_init_args (SingleStepReq *ss_req, SingleStepArgs *args) gboolean set_ip = FALSE; StackFrame **frames = NULL; int nframes = 0; - + GET_TLS_DATA_FROM_THREAD (ss_req->thread); - + g_assert (tls); if (!tls->context.valid) { PRINT_DEBUG_MSG (1, "Received a single step request on a thread with no managed frames.\n"); @@ -4937,7 +4937,7 @@ debugger_agent_end_exception_filter (MonoException *exc, MonoContext *ctx, MonoC tls->filter_state.valid = FALSE; } -static void +static void buffer_add_fixed_array (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, gboolean as_vtype, GHashTable *parent_vtypes, gint32 len_fixed_array) { @@ -4968,7 +4968,7 @@ buffer_add_fixed_array (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain break; case MONO_TYPE_PTR: { gssize val = *(gssize*)addr; - + buffer_add_byte (buf, t->type); buffer_add_long (buf, val); if (CHECK_PROTOCOL_VERSION(2, 46)) @@ -4993,7 +4993,7 @@ buffer_add_info_for_null_value (Buffer* buf, MonoType* t, MonoDomain* domain) buffer_add_int (buf, m_class_get_rank (mono_class_from_mono_type_internal (t))); if (m_class_get_byval_arg (m_class_get_element_class (mono_class_from_mono_type_internal (t)))->type == MONO_TYPE_CLASS) buffer_add_typeid (buf, domain, m_class_get_element_class (mono_class_from_mono_type_internal (t))); - buffer_add_typeid (buf, domain, mono_class_from_mono_type_internal (t)); + buffer_add_typeid (buf, domain, mono_class_from_mono_type_internal (t)); break; default: buffer_add_typeid (buf, domain, mono_class_from_mono_type_internal (t)); @@ -5047,7 +5047,7 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, break; } } - + if (len_fixed_array > 1 && t->type != MONO_TYPE_VALUETYPE && CHECK_PROTOCOL_VERSION (2, 53)) { buffer_add_fixed_array(buf, t, addr, domain, as_vtype, parent_vtypes, len_fixed_array); @@ -5110,7 +5110,7 @@ buffer_add_value_full (Buffer *buf, MonoType *t, void *addr, MonoDomain *domain, case MONO_TYPE_PTR: case MONO_TYPE_FNPTR: { gssize val = *(gssize*)addr; - + buffer_add_byte (buf, t->type); buffer_add_long (buf, val); if (CHECK_PROTOCOL_VERSION(2, 46)) @@ -5514,7 +5514,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, g_free (name); return ERR_INVALID_ARGUMENT; } - } else if ((t->type == MONO_TYPE_GENERICINST) && + } else if ((t->type == MONO_TYPE_GENERICINST) && mono_metadata_generic_class_is_valuetype (t->data.generic_class) && m_class_is_enumtype (t->data.generic_class->container_class)){ err = decode_vtype (t, domain, addr, buf, &buf, limit, check_field_datatype); @@ -5727,7 +5727,7 @@ set_var (MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domai /* Not saved yet */ PRINT_DEBUG_MSG (1, "[dbg] Setting context location for reg %x to %p.\n", reg, (gpointer)v); mono_arch_context_set_int_reg (restore_ctx, reg, v); - } + } // FIXME: Move these to mono-context.h/c. mono_arch_context_set_int_reg (ctx, reg, v); @@ -5749,7 +5749,7 @@ set_var (MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domai if (!addr) break; } - + // FIXME: Write barriers mono_gc_memmove_atomic (addr, val, size); break; @@ -5969,7 +5969,7 @@ mono_do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, gu MonoStopwatch watch; if (invoke->method) { - /* + /* * Invoke this method directly, currently only Environment.Exit () is supported. */ this_arg = NULL; @@ -6120,7 +6120,7 @@ mono_do_invoke_method (DebuggerTlsData *tls, Buffer *buf, InvokeData *invoke, gu else tls->disable_breakpoints = FALSE; - /* + /* * Add an LMF frame to link the stack frames on the invoke method with our caller. */ #ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED @@ -6289,7 +6289,7 @@ invoke_method (void) } send_reply_packet (id, err, &buf); - + buffer_free (&buf); } @@ -6488,9 +6488,9 @@ get_types_for_source_file (gpointer key, gpointer value, gpointer user_data) } } -static void +static void send_enc_delta (MonoImage *image, gconstpointer dmeta_bytes, int32_t dmeta_len, gconstpointer dpdb_bytes, int32_t dpdb_len) -{ +{ //TODO: if it came from debugger we don't need to pass the parameters back, they are already on debugger client side. if (agent_config.enabled) { int suspend_policy; @@ -6507,7 +6507,7 @@ send_enc_delta (MonoImage *image, gconstpointer dmeta_bytes, int32_t dmeta_len, info.pdb_len = dpdb_len; process_event (MDBGPROT_EVENT_KIND_ENC_UPDATE, &info, 0, NULL, events, suspend_policy); - } + } } static gboolean @@ -6523,7 +6523,7 @@ module_apply_changes (MonoImage *image, MonoArray *dmeta, MonoArray *dil, MonoAr mono_image_load_enc_delta (MONO_ENC_DELTA_DBG, image, dmeta_bytes, dmeta_len, dil_bytes, dil_len, dpdb_bytes, dpdb_len, error); return is_ok (error); } - + static void buffer_add_cattr_arg (Buffer *buf, MonoType *t, MonoDomain *domain, MonoObject *val) @@ -6632,9 +6632,9 @@ buffer_add_cattrs (Buffer *buf, MonoDomain *domain, MonoImage *image, MonoClass return ERR_NONE; } -static void add_error_string (Buffer *buf, const char *str) +static void add_error_string (Buffer *buf, const char *str) { - if (CHECK_PROTOCOL_VERSION (2, 56)) + if (CHECK_PROTOCOL_VERSION (2, 56)) buffer_add_string (buf, str); } @@ -6674,7 +6674,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) count--; buffer_add_int (buf, count); mono_g_hash_table_foreach (tid_to_thread_obj, add_thread, buf); - + mono_loader_unlock (); break; } @@ -6762,7 +6762,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) while (suspend_count > 0) resume_vm (); } else { - /* + /* * No thread found, do it ourselves. * FIXME: This can race with normal shutdown etc. */ @@ -6782,7 +6782,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) exit (exit_code); } break; - } + } case CMD_VM_INVOKE_METHOD: case CMD_VM_INVOKE_METHODS: { int objid = decode_objid (p, &p, end); @@ -6817,7 +6817,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) /* The thread is still running native code, can't do invokes */ return ERR_NOT_SUSPENDED; - /* + /* * Store the invoke data into tls, the thread will execute it after it is * resumed. */ @@ -7024,7 +7024,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf) if (!assembly) { PRINT_DEBUG_MSG (1, "Could not resolve assembly %s\n", assembly_name); buffer_add_int(buf, -1); - mono_assembly_name_free_internal (aname); + mono_assembly_name_free_internal (aname); break; } } @@ -7128,7 +7128,7 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) req->modifiers [i].everything_else = FALSE; PRINT_DEBUG_MSG (1, "[dbg] \tEXCEPTION_ONLY filter (%s%s%s%s).\n", exc_class ? m_class_get_name (exc_class) : "all", req->modifiers [i].caught ? ", caught" : "", req->modifiers [i].uncaught ? ", uncaught" : "", req->modifiers [i].subclasses ? ", include-subclasses" : ""); } - + } else if (mod == MOD_KIND_ASSEMBLY_ONLY) { int n = decode_int (p, &p, end); int j; @@ -7196,10 +7196,10 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } GET_TLS_DATA_FROM_THREAD (THREAD_TO_INTERNAL(step_thread)); - + g_assert (tls); - - if (tls->terminated) { + + if (tls->terminated) { /* if the thread is already terminated ignore the single step */ buffer_add_int (buf, req->id); return ERR_NONE; @@ -7210,7 +7210,7 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) g_free (req); return err; } -#ifdef TARGET_WASM +#ifdef TARGET_WASM int isBPOnManagedCode = 0; SingleStepReq *ss_req = req->info; if (ss_req && ss_req->bps) { @@ -7242,7 +7242,7 @@ event_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mono_loader_lock (); g_ptr_array_add (event_requests, req); - + if (agent_config.defer) { /* Transmit cached data to the client on receipt of the event request */ switch (req->event_kind) { @@ -7372,7 +7372,7 @@ domain_commands (int command, guint8 *p, guint8 *end, Buffer *buf) mono_error_cleanup (error); return ERR_INVALID_OBJECT; } - + if (CHECK_PROTOCOL_VERSION(3, 0)) { buffer_add_byte(buf, 1); buffer_add_byte(buf, MONO_TYPE_STRING); @@ -7460,7 +7460,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) switch (command) { case CMD_ASSEMBLY_GET_LOCATION: { buffer_add_string (buf, mono_image_get_filename (ass->image)); - break; + break; } case CMD_ASSEMBLY_GET_ENTRY_POINT: { guint32 token; @@ -7480,7 +7480,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) buffer_add_methodid (buf, domain, m); } } - break; + break; } case CMD_ASSEMBLY_GET_MANIFEST_MODULE: { buffer_add_moduleid (buf, domain, ass->image); @@ -7576,7 +7576,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) } case CMD_ASSEMBLY_GET_PDB_BLOB: { MonoImage* image = ass->image; - MonoDebugHandle* handle = mono_debug_get_handle (image); + MonoDebugHandle* handle = mono_debug_get_handle (image); if (!handle) { return ERR_INVALID_ARGUMENT; } @@ -7654,7 +7654,7 @@ assembly_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return ERR_NOT_IMPLEMENTED; } - // Mdbg uses arithmetics with this pointer and RVA to get information using readmemory, + // Mdbg uses arithmetics with this pointer and RVA to get information using readmemory, // but it doesn't work on mono, it should call mono_cli_rva_image_map to get the right offset and don't use pure RVA. // To run the tests I changed mdbg but maybe in future we may need to find another solution // PRINT_DEBUG_MSG(1, "MDBGPROT_CMD_ASSEMBLY_GET_PEIMAGE_ADDRESS - [%p] - %d\n", module_handle, image->raw_data_len); @@ -7693,7 +7693,7 @@ module_commands (int command, guint8 *p, guint8 *end, Buffer *buf) buffer_add_string (buf, sourcelink); g_free (basename); g_free (sourcelink); - break; + break; } case MDBGPROT_CMD_MODULE_APPLY_CHANGES: { MonoImage *image = decode_moduleid (p, &p, end, &domain, &err); @@ -7857,7 +7857,7 @@ type_commands_internal (int command, MonoClass *klass, MonoDomain *domain, guint buffer_add_string (buf, m_class_get_name_space (klass)); buffer_add_string (buf, m_class_get_name (klass)); // FIXME: byref - + MonoTypeNameFormat format = MONO_TYPE_NAME_FORMAT_FULL_NAME; if (CHECK_PROTOCOL_VERSION(2, 61)) format = (MonoTypeNameFormat) decode_int (p, &p, end); @@ -8594,7 +8594,7 @@ method_commands_internal (int command, MonoMethod *method, MonoDomain *domain, g result = method; } else { MonoMethodInflated *imethod = (MonoMethodInflated *)method; - + result = imethod->declaring; if (imethod->context.class_inst) { MonoClass *klass = ((MonoMethod *) imethod)->klass; @@ -8883,7 +8883,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return err; thread = THREAD_TO_INTERNAL (thread_obj); - + switch (command) { case CMD_THREAD_GET_NAME: { char *s = mono_thread_get_name_utf8 (thread_obj); @@ -8979,7 +8979,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf) /* * Instead of passing the frame type directly to the client, we associate * it with the previous frame using a set of flags. This avoids lots of - * conditional code in the client, since a frame whose type isn't + * conditional code in the client, since a frame whose type isn't * FRAME_TYPE_MANAGED has no method, location, etc. */ buffer_add_byte (buf, tls->frames [i]->flags); @@ -9111,7 +9111,7 @@ cmd_stack_frame_get_this (StackFrame *frame, MonoMethodSignature *sig, Buffer *b } return ERR_NONE; } -static void +static void cmd_stack_frame_get_parameter (StackFrame *frame, MonoMethodSignature *sig, int pos, Buffer *buf, MonoDebugMethodJitInfo *jit) { PRINT_DEBUG_MSG (4, "[dbg] send arg %d.\n", pos); @@ -9143,7 +9143,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) gssize id; MonoMethodHeader *header; ERROR_DECL (error); - + objid = decode_objid (p, &p, end); err = get_object (objid, (MonoObject**)&thread_obj); if (err != ERR_NONE) @@ -9211,7 +9211,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) else pos--; } - len = 1; + len = 1; cmd_stack_frame_get_parameter (frame, sig, pos, buf, jit); break; } @@ -9347,7 +9347,7 @@ frame_commands (int command, guint8 *p, guint8 *end, Buffer *buf) addr = (guint8*)mini_get_interp_callbacks_api ()->frame_get_this (frame->interp_frame); err = mono_de_set_interp_var (m_class_get_this_arg (frame->actual_method->klass), addr, val_buf); if (err != ERR_NONE) - return err; + return err; } else { var = jit->this_var; if (!var) { @@ -9498,8 +9498,8 @@ string_commands (int command, guint8 *p, guint8 *end, Buffer *buf) return ERR_NONE; } -static void -create_file_to_check_memory_address (void) +static void +create_file_to_check_memory_address (void) { if (file_check_valid_memory != -1) return; @@ -9509,7 +9509,7 @@ create_file_to_check_memory_address (void) g_free (file_name); } -static gboolean +static gboolean valid_memory_address (gpointer addr, gint size) { #ifndef _MSC_VER @@ -9532,7 +9532,7 @@ valid_memory_address (gpointer addr, gint size) } __except(1) { return ret; } -#endif +#endif return ret; } @@ -9559,7 +9559,7 @@ pointer_commands (int command, guint8 *p, guint8 *end, Buffer *buf) type = m_class_get_byval_arg (m_class_get_element_class (klass)); size = mono_type_size (type, &align); - + if (!valid_memory_address((gpointer)addr, size)) return ERR_INVALID_ARGUMENT; @@ -9857,7 +9857,7 @@ static const char* assembly_cmds_str[] = { "GET_METADATA_BLOB", "GET_IS_DYNAMIC", "GET_PDB_BLOB", - "GET_TYPE_FROM_TOKEN", + "GET_TYPE_FROM_TOKEN", "GET_METHOD_FROM_TOKEN", "HAS_DEBUG_INFO", "GET_CUSTOM_ATTRIBUTES", @@ -10051,7 +10051,7 @@ wait_for_attach (void) PRINT_DEBUG_MSG (1, "Transport handshake failed!\n"); return FALSE; } - + return TRUE; } @@ -10153,7 +10153,7 @@ debugger_thread (void *arg) } else { mono_set_is_debugger_attached (TRUE); } - + #ifndef HOST_WASM if (!attach_failed) { if (mono_metadata_has_updates_api ()) { @@ -10218,7 +10218,7 @@ debugger_thread (void *arg) err = ERR_NONE; no_reply = FALSE; - err = mono_process_dbg_packet (id, command_set, command, &no_reply, p, end, &buf); + err = mono_process_dbg_packet (id, command_set, command, &no_reply, p, end, &buf); if (command_set == CMD_SET_VM && command == CMD_VM_START_BUFFERING) { buffer_replies = TRUE; @@ -10263,7 +10263,7 @@ debugger_thread (void *arg) mono_coop_mutex_unlock (&debugger_thread_exited_mutex); PRINT_DEBUG_MSG (1, "[dbg] Debugger thread exited.\n"); - + if (!attach_failed && command_set == CMD_SET_VM && command == CMD_VM_DISPOSE && !(vm_death_event_sent || mono_runtime_is_shutting_down ())) { PRINT_DEBUG_MSG (2, "[dbg] Detached - restarting clean debugger thread.\n"); ERROR_DECL (error); diff --git a/src/mono/mono/eglib/ghashtable.c b/src/mono/mono/eglib/ghashtable.c index 5329fab0cabc5..8b5c29a1a9044 100644 --- a/src/mono/mono/eglib/ghashtable.c +++ b/src/mono/mono/eglib/ghashtable.c @@ -86,7 +86,7 @@ static int calc_prime (int x) { int i; - + for (i = (x & (~1))-1; i< G_MAXINT32; i += 2) { if (test_prime (i)) return i; @@ -98,7 +98,7 @@ guint g_spaced_primes_closest (guint x) { int i; - + for (i = 0; i < G_N_ELEMENTS (prime_tbl); i++) { if (x <= prime_tbl [i]) return prime_tbl [i]; @@ -123,7 +123,7 @@ g_hash_table_new (GHashFunc hash_func, GEqualFunc key_equal_func) hash->table_size = g_spaced_primes_closest (1); hash->table = g_new0 (Slot *, hash->table_size); hash->last_rehash = hash->table_size; - + return hash; } @@ -134,10 +134,10 @@ g_hash_table_new_full (GHashFunc hash_func, GEqualFunc key_equal_func, GHashTable *hash = g_hash_table_new (hash_func, key_equal_func); if (hash == NULL) return NULL; - + hash->key_destroy_func = key_destroy_func; hash->value_destroy_func = value_destroy_func; - + return hash; } @@ -199,7 +199,7 @@ do_rehash (GHashTable *hash) /* printf ("New size: %d\n", hash->table_size); */ table = hash->table; hash->table = g_new0 (Slot *, hash->table_size); - + for (i = 0; i < current_size; i++){ Slot *s, *next; @@ -234,7 +234,7 @@ g_hash_table_insert_replace (GHashTable *hash, gpointer key, gpointer value, gbo guint hashcode; Slot *s; GEqualFunc equal; - + g_return_if_fail (hash != NULL); sanity_check (hash); @@ -301,7 +301,7 @@ guint g_hash_table_size (GHashTable *hash) { g_return_val_if_fail (hash != NULL, 0); - + return hash->in_use; } @@ -317,7 +317,7 @@ gpointer g_hash_table_lookup (GHashTable *hash, gconstpointer key) { gpointer orig_key, value; - + if (g_hash_table_lookup_extended (hash, key, &orig_key, &value)) return value; else @@ -330,13 +330,13 @@ g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *ori GEqualFunc equal; Slot *s; guint hashcode; - + g_return_val_if_fail (hash != NULL, FALSE); sanity_check (hash); equal = hash->key_equal_func; hashcode = ((*hash->hash_func) (key)) % hash->table_size; - + for (s = hash->table [hashcode]; s != NULL; s = s->next){ if ((*equal)(s->key, key)){ if (orig_key) @@ -353,7 +353,7 @@ void g_hash_table_foreach (GHashTable *hash, GHFunc func, gpointer user_data) { int i; - + g_return_if_fail (hash != NULL); g_return_if_fail (func != NULL); @@ -369,7 +369,7 @@ gpointer g_hash_table_find (GHashTable *hash, GHRFunc predicate, gpointer user_data) { int i; - + g_return_val_if_fail (hash != NULL, NULL); g_return_val_if_fail (predicate != NULL, NULL); @@ -387,7 +387,7 @@ void g_hash_table_remove_all (GHashTable *hash) { int i; - + g_return_if_fail (hash != NULL); for (i = 0; i < hash->table_size; i++){ @@ -406,7 +406,7 @@ g_hash_table_remove (GHashTable *hash, gconstpointer key) GEqualFunc equal; Slot *s, *last; guint hashcode; - + g_return_val_if_fail (hash != NULL, FALSE); sanity_check (hash); equal = hash->key_equal_func; @@ -439,7 +439,7 @@ g_hash_table_foreach_remove (GHashTable *hash, GHRFunc func, gpointer user_data) { int i; int count = 0; - + g_return_val_if_fail (hash != NULL, 0); g_return_val_if_fail (func != NULL, 0); @@ -485,11 +485,11 @@ g_hash_table_steal (GHashTable *hash, gconstpointer key) GEqualFunc equal; Slot *s, *last; guint hashcode; - + g_return_val_if_fail (hash != NULL, FALSE); sanity_check (hash); equal = hash->key_equal_func; - + hashcode = ((*hash->hash_func)(key)) % hash->table_size; last = NULL; for (s = hash->table [hashcode]; s != NULL; s = s->next){ @@ -507,7 +507,7 @@ g_hash_table_steal (GHashTable *hash, gconstpointer key) } sanity_check (hash); return FALSE; - + } guint @@ -515,7 +515,7 @@ g_hash_table_foreach_steal (GHashTable *hash, GHRFunc func, gpointer user_data) { int i; int count = 0; - + g_return_val_if_fail (hash != NULL, 0); g_return_val_if_fail (func != NULL, 0); @@ -564,7 +564,7 @@ g_hash_table_destroy (GHashTable *hash) for (s = hash->table [i]; s != NULL; s = next){ next = s->next; - + if (hash->key_destroy_func != NULL) (*hash->key_destroy_func)(s->key); if (hash->value_destroy_func != NULL) @@ -573,7 +573,7 @@ g_hash_table_destroy (GHashTable *hash) } } g_free (hash->table); - + g_free (hash); } diff --git a/src/mono/mono/eglib/giconv.c b/src/mono/mono/eglib/giconv.c index 378b7ef069384..6ab22e11933b4 100644 --- a/src/mono/mono/eglib/giconv.c +++ b/src/mono/mono/eglib/giconv.c @@ -116,41 +116,41 @@ g_iconv_open (const char *to_charset, const char *from_charset) Encoder encoder = NULL; GIConv cd; guint i; - + if (!to_charset || !from_charset || !to_charset[0] || !from_charset[0]) { mono_set_errno (EINVAL); - + return (GIConv) -1; } - + for (i = 0; i < G_N_ELEMENTS (charsets); i++) { if (!g_ascii_strcasecmp (charsets[i].name, from_charset)) decoder = charsets[i].decoder; - + if (!g_ascii_strcasecmp (charsets[i].name, to_charset)) encoder = charsets[i].encoder; } - + if (!encoder || !decoder) { #ifdef HAVE_LIBICONV if ((icd = iconv_open (to_charset, from_charset)) == (iconv_t) -1) return (GIConv) -1; #else mono_set_errno (EINVAL); - + return (GIConv) -1; #endif } - + cd = (GIConv) g_malloc (sizeof (struct _GIConv)); cd->decode = decoder; cd->encode = encoder; cd->c = -1; - + #ifdef HAVE_LIBICONV cd->cd = icd; #endif - + return cd; } @@ -161,9 +161,9 @@ g_iconv_close (GIConv cd) if (cd->cd != (iconv_t) -1) iconv_close (cd->cd); #endif - + g_free (cd); - + return 0; } @@ -175,21 +175,21 @@ g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft, char *inptr, *outptr; gunichar c; int rc = 0; - + #ifdef HAVE_LIBICONV if (cd->cd != (iconv_t) -1) { /* Note: gsize may have a different size than size_t, so we need to remap inbytesleft and outbytesleft to size_t's. */ size_t *outleftptr, *inleftptr; size_t n_outleft, n_inleft; - + if (inbytesleft) { n_inleft = *inbytesleft; inleftptr = &n_inleft; } else { inleftptr = NULL; } - + if (outbytesleft) { n_outleft = *outbytesleft; outleftptr = &n_outleft; @@ -204,47 +204,47 @@ g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft, #endif } #endif - + if (outbytes == NULL || outbytesleft == NULL) { /* reset converter */ cd->c = -1; return 0; } - + inleft = inbytesleft ? *inbytesleft : 0; inptr = inbytes ? *inbytes : NULL; outleft = *outbytesleft; outptr = *outbytes; - + if ((c = cd->c) != (gunichar) -1) goto encode; - + while (inleft > 0) { if ((rc = cd->decode (inptr, inleft, &c)) < 0) break; - + inleft -= rc; inptr += rc; - + encode: if ((rc = cd->encode (c, outptr, outleft)) < 0) break; - + c = (gunichar) -1; outleft -= rc; outptr += rc; } - + if (inbytesleft) *inbytesleft = inleft; - + if (inbytes) *inbytes = inptr; - + *outbytesleft = outleft; *outbytes = outptr; cd->c = c; - + return rc < 0 ? -1 : 0; } @@ -265,14 +265,14 @@ decode_utf32_endian (char *inbuf, size_t inleft, gunichar *outchar, unsigned end { unsigned char *inptr = (unsigned char *) inbuf; gunichar c; - + if (inleft < 4) { mono_set_errno (EINVAL); return -1; } - + c = read_uint32_endian (inptr, endian); - + if (c >= 0xd800 && c < 0xe000) { mono_set_errno (EILSEQ); return -1; @@ -280,9 +280,9 @@ decode_utf32_endian (char *inbuf, size_t inleft, gunichar *outchar, unsigned end mono_set_errno (EILSEQ); return -1; } - + *outchar = c; - + return 4; } @@ -302,17 +302,17 @@ static int encode_utf32be (gunichar c, char *outbuf, size_t outleft) { unsigned char *outptr = (unsigned char *) outbuf; - + if (outleft < 4) { mono_set_errno (E2BIG); return -1; } - + outptr[0] = (c >> 24) & 0xff; outptr[1] = (c >> 16) & 0xff; outptr[2] = (c >> 8) & 0xff; outptr[3] = c & 0xff; - + return 4; } @@ -320,17 +320,17 @@ static int encode_utf32le (gunichar c, char *outbuf, size_t outleft) { unsigned char *outptr = (unsigned char *) outbuf; - + if (outleft < 4) { mono_set_errno (E2BIG); return -1; } - + outptr[0] = c & 0xff; outptr[1] = (c >> 8) & 0xff; outptr[2] = (c >> 16) & 0xff; outptr[3] = (c >> 24) & 0xff; - + return 4; } @@ -348,14 +348,14 @@ decode_utf16_endian (char *inbuf, size_t inleft, gunichar *outchar, unsigned end unsigned char *inptr = (unsigned char *) inbuf; gunichar2 c; gunichar u; - + if (inleft < 2) { mono_set_errno (E2BIG); return -1; } - + u = read_uint16_endian (inptr, endian); - + if (u < 0xd800) { /* 0x0000 -> 0xd7ff */ *outchar = u; @@ -366,17 +366,17 @@ decode_utf16_endian (char *inbuf, size_t inleft, gunichar *outchar, unsigned end mono_set_errno (EINVAL); return -2; } - + c = read_uint16_endian (inptr + 2, endian); - + if (c < 0xdc00 || c > 0xdfff) { mono_set_errno (EILSEQ); return -2; } - + u = ((u - 0xd800) << 10) + (c - 0xdc00) + 0x0010000UL; *outchar = u; - + return 4; } else if (u < 0xe000) { /* 0xdc00 -> 0xdfff */ @@ -419,13 +419,13 @@ encode_utf16_endian (gunichar c, char *outbuf, size_t outleft, unsigned endian) unsigned char *outptr = (unsigned char *) outbuf; gunichar2 ch; gunichar c2; - + if (c < 0x10000) { if (outleft < 2) { mono_set_errno (E2BIG); return -1; } - + write_uint16_endian (outptr, c, endian); return 2; } else { @@ -433,14 +433,14 @@ encode_utf16_endian (gunichar c, char *outbuf, size_t outleft, unsigned endian) mono_set_errno (E2BIG); return -1; } - + c2 = c - 0x10000; - + ch = (gunichar2) ((c2 >> 10) + 0xd800); write_uint16_endian (outptr, ch, endian); ch = (gunichar2) ((c2 & 0x3ff) + 0xdc00); - write_uint16_endian (outptr + 2, ch, endian); + write_uint16_endian (outptr + 2, ch, endian); return 4; } } @@ -463,9 +463,9 @@ decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar) unsigned char *inptr = (unsigned char *) inbuf; gunichar u; int n, i; - + u = *inptr; - + if (u < 0x80) { /* simple ascii case */ *outchar = u; @@ -492,12 +492,12 @@ decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar) mono_set_errno (EILSEQ); return -1; } - + if (n > inleft) { mono_set_errno (EINVAL); return -1; } - + #if UNROLL_DECODE_UTF8 switch (n) { case 6: u = (u << 6) | (*++inptr ^ 0x80); @@ -510,9 +510,9 @@ decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar) for (i = 1; i < n; i++) u = (u << 6) | (*++inptr ^ 0x80); #endif - + *outchar = u; - + return n; } @@ -521,7 +521,7 @@ encode_utf8 (gunichar c, char *outbuf, size_t outleft) { unsigned char *outptr = (unsigned char *) outbuf; int base, n, i; - + if (c < 0x80) { outptr[0] = c; return 1; @@ -541,12 +541,12 @@ encode_utf8 (gunichar c, char *outbuf, size_t outleft) base = 252; n = 6; } - + if (outleft < n) { mono_set_errno (E2BIG); return -1; } - + #if UNROLL_ENCODE_UTF8 switch (n) { case 6: outptr[5] = (c & 0x3f) | 0x80; c >>= 6; @@ -561,10 +561,10 @@ encode_utf8 (gunichar c, char *outbuf, size_t outleft) outptr[i] = (c & 0x3f) | 0x80; c >>= 6; } - + outptr[0] = c | base; #endif - + return n; } @@ -582,14 +582,14 @@ encode_latin1 (gunichar c, char *outbuf, size_t outleft) mono_set_errno (E2BIG); return -1; } - + if (c > 0xff) { mono_set_errno (EILSEQ); return -1; } - + *outbuf = (char) c; - + return 1; } @@ -615,37 +615,37 @@ g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *f gboolean flush = FALSE; gboolean done = FALSE; GIConv cd; - + g_return_val_if_fail (str != NULL, NULL); g_return_val_if_fail (to_charset != NULL, NULL); g_return_val_if_fail (from_charset != NULL, NULL); - + if ((cd = g_iconv_open (to_charset, from_charset)) == (GIConv) -1) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_CONVERSION, "Conversion from %s to %s not supported.", from_charset, to_charset); - + if (bytes_written) *bytes_written = 0; - + if (bytes_read) *bytes_read = 0; - + return NULL; } - + inleft = len < 0 ? strlen (str) : len; inbuf = (char *) str; - + outleft = outsize = MAX (inleft, 8); outbuf = result = g_malloc (outsize + 4); - + do { if (!flush) rc = g_iconv (cd, &inbuf, &inleft, &outbuf, &outleft); else rc = g_iconv (cd, NULL, NULL, &outbuf, &outleft); - + if (rc == (gsize) -1) { switch (errno) { case E2BIG: @@ -667,28 +667,28 @@ g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *f case EILSEQ: /* illegal sequence in the input */ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "%s", g_strerror (errno)); - + if (bytes_read) { /* save offset of the illegal input sequence */ *bytes_read = (inbuf - str); } - + if (bytes_written) *bytes_written = 0; - + g_iconv_close (cd); g_free (result); return NULL; default: /* unknown errno */ g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, "%s", g_strerror (errno)); - + if (bytes_written) *bytes_written = 0; - + if (bytes_read) *bytes_read = 0; - + g_iconv_close (cd); g_free (result); return NULL; @@ -701,23 +701,23 @@ g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *f flush = TRUE; } } while (!done); - + g_iconv_close (cd); - + /* Note: not all charsets can be null-terminated with a single null byte. UCS2, for example, needs 2 null bytes and UCS4 needs 4. I hope that 4 null bytes is enough to terminate all multibyte charsets? */ - + /* null-terminate the result */ memset (outbuf, 0, 4); - + if (bytes_written) *bytes_written = outbuf - result; - + if (bytes_read) *bytes_read = inbuf - str; - + return result; } @@ -735,7 +735,7 @@ gint g_unichar_to_utf8 (gunichar c, gchar *outbuf) { int base, n, i; - + if (c < 0x80) { base = 0; n = 1; @@ -757,18 +757,18 @@ g_unichar_to_utf8 (gunichar c, gchar *outbuf) } else { return -1; } - + if (outbuf != NULL) { for (i = n - 1; i > 0; i--) { /* mask off 6 bits worth and add 128 */ outbuf[i] = (c & 0x3f) | 0x80; c >>= 6; } - + /* first character has a different base */ outbuf[0] = c | base; } - + return n; } @@ -776,27 +776,27 @@ static FORCE_INLINE (int) g_unichar_to_utf16 (gunichar c, gunichar2 *outbuf) { gunichar c2; - + if (c < 0xd800) { if (outbuf) *outbuf = (gunichar2) c; - + return 1; } else if (c < 0xe000) { return -1; } else if (c < 0x10000) { if (outbuf) *outbuf = (gunichar2) c; - + return 1; } else if (c < 0x110000) { if (outbuf) { c2 = c - 0x10000; - + outbuf[0] = (gunichar2) ((c2 >> 10) + 0xd800); outbuf[1] = (gunichar2) ((c2 & 0x3ff) + 0xdc00); } - + return 2; } else { return -1; @@ -809,29 +809,29 @@ g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written) gunichar *outbuf, *outptr; char *inptr; glong n, i; - + g_return_val_if_fail (str != NULL, NULL); - + n = g_utf8_strlen (str, len); - + if (items_written) *items_written = n; - + outptr = outbuf = g_malloc ((n + 1) * sizeof (gunichar)); inptr = (char *) str; - + for (i = 0; i < n; i++) { *outptr++ = g_utf8_get_char (inptr); inptr = g_utf8_next_char (inptr); } - + *outptr = 0; - + return outbuf; } static gunichar2 * -eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong *items_written, gboolean include_nuls, gboolean replace_invalid_codepoints, GCustomAllocator custom_alloc_func, gpointer custom_alloc_data, GError **err) +eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong *items_written, gboolean include_nuls, gboolean replace_invalid_codepoints, GCustomAllocator custom_alloc_func, gpointer custom_alloc_data, GError **err) { gunichar2 *outbuf, *outptr; size_t outlen = 0; @@ -839,28 +839,28 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong char *inptr; gunichar c; int u, n; - + g_return_val_if_fail (str != NULL, NULL); - + if (len < 0) { if (include_nuls) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_FAILED, "Conversions with embedded nulls must pass the string length"); return NULL; } - + len = strlen (str); } - + inptr = (char *) str; inleft = len; - + while (inleft > 0) { if ((n = decode_utf8 (inptr, inleft, &c)) < 0) goto error; - + if (c == 0 && !include_nuls) break; - + if ((u = g_unichar_to_utf16 (c, NULL)) < 0) { if (replace_invalid_codepoints) { u = 2; @@ -869,18 +869,18 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong goto error; } } - + outlen += u; inleft -= n; inptr += n; } - + if (items_read) *items_read = inptr - str; - + if (items_written) *items_written = outlen; - + if (G_LIKELY (!custom_alloc_func)) outptr = outbuf = g_malloc ((outlen + 1) * sizeof (gunichar2)); else @@ -893,14 +893,14 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong inptr = (char *) str; inleft = len; - + while (inleft > 0) { if ((n = decode_utf8 (inptr, inleft, &c)) < 0) break; - + if (c == 0 && !include_nuls) break; - + u = g_unichar_to_utf16 (c, outptr); if ((u < 0) && replace_invalid_codepoints) { outptr[0] = 0xFFFD; @@ -912,11 +912,11 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong inleft -= n; inptr += n; } - + *outptr = '\0'; - + return outbuf; - + error: if (errno == ENOMEM) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_NO_MEMORY, @@ -930,13 +930,13 @@ eg_utf8_to_utf16_general (const gchar *str, glong len, glong *items_read, glong g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT, "Partial byte sequence encountered in the input."); } - + if (items_read) *items_read = inptr - str; - + if (items_written) *items_written = 0; - + return NULL; } @@ -973,15 +973,15 @@ g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_wri char *inptr; gunichar c; int n; - + g_return_val_if_fail (str != NULL, NULL); - + if (len < 0) len = strlen (str); - + inptr = (char *) str; inleft = len; - + while (inleft > 0) { if ((n = decode_utf8 (inptr, inleft, &c)) < 0) { if (errno == EILSEQ) { @@ -994,45 +994,45 @@ g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_wri g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT, "Partial byte sequence encountered in the input."); } - + if (items_read) *items_read = inptr - str; - + if (items_written) *items_written = 0; - + return NULL; } else if (c == 0) break; - + outlen += 4; inleft -= n; inptr += n; } - + if (items_written) *items_written = outlen / 4; - + if (items_read) *items_read = inptr - str; - + outptr = outbuf = g_malloc (outlen + 4); inptr = (char *) str; inleft = len; - + while (inleft > 0) { if ((n = decode_utf8 (inptr, inleft, &c)) < 0) break; else if (c == 0) break; - + *outptr++ = c; inleft -= n; inptr += n; } - + *outptr = 0; - + return outbuf; } @@ -1045,18 +1045,18 @@ eg_utf16_to_utf8_general (const gunichar2 *str, glong len, glong *items_read, gl size_t inleft; gunichar c; int n; - + g_return_val_if_fail (str != NULL, NULL); - + if (len < 0) { len = 0; while (str[len]) len++; } - + inptr = (char *) str; inleft = len * 2; - + while (inleft > 0) { if ((n = decode_utf16 (inptr, inleft, &c)) < 0) { if (n == -2 && inleft > 2) { @@ -1064,7 +1064,7 @@ eg_utf16_to_utf8_general (const gunichar2 *str, glong len, glong *items_read, gl inleft -= 2; inptr += 2; } - + if (errno == EILSEQ) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "Illegal byte sequence encounted in the input."); @@ -1075,25 +1075,25 @@ eg_utf16_to_utf8_general (const gunichar2 *str, glong len, glong *items_read, gl g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT, "Partial byte sequence encountered in the input."); } - + if (items_read) *items_read = (inptr - (char *) str) / 2; - + if (items_written) *items_written = 0; - + return NULL; } else if (c == 0) break; - + outlen += g_unichar_to_utf8 (c, NULL); inleft -= n; inptr += n; } - + if (items_read) *items_read = (inptr - (char *) str) / 2; - + if (items_written) *items_written = outlen; @@ -1108,23 +1108,23 @@ eg_utf16_to_utf8_general (const gunichar2 *str, glong len, glong *items_read, gl *items_written = 0; return NULL; } - + inptr = (char *) str; inleft = len * 2; - + while (inleft > 0) { if ((n = decode_utf16 (inptr, inleft, &c)) < 0) break; else if (c == 0) break; - + outptr += g_unichar_to_utf8 (c, outptr); inleft -= n; inptr += n; } - + *outptr = '\0'; - + return outbuf; } @@ -1149,18 +1149,18 @@ g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *item char *inptr; gunichar c; int n; - + g_return_val_if_fail (str != NULL, NULL); - + if (len < 0) { len = 0; while (str[len]) len++; } - + inptr = (char *) str; inleft = len * 2; - + while (inleft > 0) { if ((n = decode_utf16 (inptr, inleft, &c)) < 0) { if (n == -2 && inleft > 2) { @@ -1168,7 +1168,7 @@ g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *item inleft -= 2; inptr += 2; } - + if (errno == EILSEQ) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "Illegal byte sequence encounted in the input."); @@ -1179,45 +1179,45 @@ g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *item g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT, "Partial byte sequence encountered in the input."); } - + if (items_read) *items_read = (inptr - (char *) str) / 2; - + if (items_written) *items_written = 0; - + return NULL; } else if (c == 0) break; - + outlen += 4; inleft -= n; inptr += n; } - + if (items_read) *items_read = (inptr - (char *) str) / 2; - + if (items_written) *items_written = outlen / 4; - + outptr = outbuf = g_malloc (outlen + 4); inptr = (char *) str; inleft = len * 2; - + while (inleft > 0) { if ((n = decode_utf16 (inptr, inleft, &c)) < 0) break; else if (c == 0) break; - + *outptr++ = c; inleft -= n; inptr += n; } - + *outptr = 0; - + return outbuf; } @@ -1228,24 +1228,24 @@ g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_ size_t outlen = 0; glong i; int n; - + g_return_val_if_fail (str != NULL, NULL); - + if (len < 0) { for (i = 0; str[i] != 0; i++) { if ((n = g_unichar_to_utf8 (str[i], NULL)) < 0) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "Illegal byte sequence encounted in the input."); - + if (items_written) *items_written = 0; - + if (items_read) *items_read = i; - + return NULL; } - + outlen += n; } } else { @@ -1253,33 +1253,33 @@ g_ucs4_to_utf8 (const gunichar *str, glong len, glong *items_read, glong *items_ if ((n = g_unichar_to_utf8 (str[i], NULL)) < 0) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "Illegal byte sequence encounted in the input."); - + if (items_written) *items_written = 0; - + if (items_read) *items_read = i; - + return NULL; } - + outlen += n; } } - + len = i; - + outptr = outbuf = g_malloc (outlen + 1); for (i = 0; i < len; i++) outptr += g_unichar_to_utf8 (str[i], outptr); *outptr = 0; - + if (items_written) *items_written = outlen; - + if (items_read) *items_read = i; - + return outbuf; } @@ -1290,24 +1290,24 @@ g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items size_t outlen = 0; glong i; int n; - + g_return_val_if_fail (str != NULL, NULL); - + if (len < 0) { for (i = 0; str[i] != 0; i++) { if ((n = g_unichar_to_utf16 (str[i], NULL)) < 0) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "Illegal byte sequence encounted in the input."); - + if (items_written) *items_written = 0; - + if (items_read) *items_read = i; - + return NULL; } - + outlen += n; } } else { @@ -1315,33 +1315,33 @@ g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items if ((n = g_unichar_to_utf16 (str[i], NULL)) < 0) { g_set_error (err, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE, "Illegal byte sequence encounted in the input."); - + if (items_written) *items_written = 0; - + if (items_read) *items_read = i; - + return NULL; } - + outlen += n; } } - + len = i; - + outptr = outbuf = g_malloc ((outlen + 1) * sizeof (gunichar2)); for (i = 0; i < len; i++) outptr += g_unichar_to_utf16 (str[i], outptr); *outptr = 0; - + if (items_written) *items_written = outlen; - + if (items_read) *items_read = i; - + return outbuf; } diff --git a/src/mono/mono/eglib/glib.h b/src/mono/mono/eglib/glib.h index 5a454a037202f..14872b9814f48 100644 --- a/src/mono/mono/eglib/glib.h +++ b/src/mono/mono/eglib/glib.h @@ -27,6 +27,7 @@ #include #include #include +#include // - Pointers should only be converted to or from pointer-sized integers. // - Any size integer can be converted to any other size integer. @@ -206,10 +207,7 @@ typedef guint32 gunichar; /* * Macros */ -#define G_N_ELEMENTS(s) (sizeof(s) / sizeof ((s) [0])) - -// e.g. strncmp (foo, G_STRING_CONSTANT_AND_LENGTH ("version")) -#define G_STRING_CONSTANT_AND_LENGTH(x) (x), G_N_ELEMENTS (x) - 1 +#define G_N_ELEMENTS(s) ARRAY_SIZE(s) #define FALSE 0 #define TRUE 1 @@ -234,7 +232,7 @@ typedef guint32 gunichar; #define G_LITTLE_ENDIAN 1234 #define G_BIG_ENDIAN 4321 -#define G_STMT_START do +#define G_STMT_START do #define G_STMT_END while (0) #define G_USEC_PER_SEC 1000000 @@ -755,14 +753,14 @@ void g_queue_foreach (GQueue *queue, GFunc func, gpointer user_data); typedef enum { G_LOG_FLAG_RECURSION = 1 << 0, G_LOG_FLAG_FATAL = 1 << 1, - + G_LOG_LEVEL_ERROR = 1 << 2, G_LOG_LEVEL_CRITICAL = 1 << 3, G_LOG_LEVEL_WARNING = 1 << 4, G_LOG_LEVEL_MESSAGE = 1 << 5, G_LOG_LEVEL_INFO = 1 << 6, G_LOG_LEVEL_DEBUG = 1 << 7, - + G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL) } GLogLevelFlags; @@ -951,16 +949,16 @@ GUnicodeBreakType g_unichar_break_type (gunichar c); * Where you might have said: * if (!(expr)) * g_error("%s invalid bar:%d", __func__, bar) - * + * * You can say: * g_assertf(expr, "bar:%d", bar); - * + * * The usual assertion text of file/line/expr/newline are builtin, and __func__. - * + * * g_assertf is a boolean expression -- the precise value is not preserved, just true or false. - * + * * Other than expr, the parameters are not evaluated unless expr is false. - * + * * format must be a string literal, in order to be concatenated. * If this is too restrictive, g_error remains. */ @@ -1222,7 +1220,7 @@ g_async_safe_fgets (char *str, int num, int handle, gboolean *newline) str [i] = '\0'; *newline = TRUE; } - + if (!isprint (str [i])) str [i] = '\0'; @@ -1317,16 +1315,16 @@ typedef struct { const gchar *element_name, gpointer user_data, GError **gerror); - + void (*text) (GMarkupParseContext *context, const gchar *text, - gsize text_len, + gsize text_len, gpointer user_data, GError **gerror); - + void (*passthrough) (GMarkupParseContext *context, const gchar *passthrough_text, - gsize text_len, + gsize text_len, gpointer user_data, GError **gerror); void (*error) (GMarkupParseContext *context, @@ -1393,12 +1391,12 @@ glong g_utf8_pointer_to_offset (const gchar *str, const gchar *pos); ((((guint32) (x)) & 0xff0000) >> 8) | \ ((((guint32) (x)) & 0xff00) << 8) | \ (((guint32) (x)) >> 24)) ) - + #define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \ GUINT32_SWAP_LE_BE(((guint64)x) >> 32)) - - + + #if G_BYTE_ORDER == G_LITTLE_ENDIAN # define GUINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x) # define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x) @@ -1445,7 +1443,7 @@ glong g_utf8_pointer_to_offset (const gchar *str, const gchar *pos); #define _EGLIB_MAJOR 2 #define _EGLIB_MIDDLE 4 #define _EGLIB_MINOR 0 - + #define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR)))) #define G_HAVE_API_SUPPORT(x) (x) diff --git a/src/mono/mono/eglib/gmodule-win32.c b/src/mono/mono/eglib/gmodule-win32.c index b4521c61cd20f..18084b24577a6 100644 --- a/src/mono/mono/eglib/gmodule-win32.c +++ b/src/mono/mono/eglib/gmodule-win32.c @@ -56,7 +56,7 @@ g_module_open (const gchar *file, GModuleFlags flags) if (file != NULL) { gunichar2 *file16; - file16 = u8to16(file); + file16 = u8to16(file); module->main_module = FALSE; module->handle = LoadLibraryW (file16); g_free(file16); @@ -64,7 +64,7 @@ g_module_open (const gchar *file, GModuleFlags flags) g_free (module); return NULL; } - + } else { module->main_module = TRUE; module->handle = GetModuleHandle (NULL); @@ -221,7 +221,7 @@ g_module_error (void) #else WCHAR local_buf [1024]; if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, - code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, G_N_ELEMENTS (local_buf) - 1, NULL) ) + code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, STRING_LENGTH (local_buf), NULL) ) local_buf [0] = TEXT('\0'); ret = u16to8 (local_buf); @@ -256,18 +256,18 @@ gchar * g_module_build_path (const gchar *directory, const gchar *module_name) { const char *lib_prefix = ""; - + if (module_name == NULL) return NULL; if (strncmp (module_name, "lib", 3) != 0) lib_prefix = LIBPREFIX; - - if (directory && *directory){ - + + if (directory && *directory){ + return g_strdup_printf ("%s/%s%s" LIBSUFFIX, directory, lib_prefix, module_name); } - return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name); + return g_strdup_printf ("%s%s" LIBSUFFIX, lib_prefix, module_name); } // This is not about GModule but is still a close fit. diff --git a/src/mono/mono/eglib/test/utf8.c b/src/mono/mono/eglib/test/utf8.c index cc298b0d2cece..4f0766ce2ec3d 100644 --- a/src/mono/mono/eglib/test/utf8.c +++ b/src/mono/mono/eglib/test/utf8.c @@ -115,7 +115,7 @@ test_utf16_to_utf8 (void) } /* - * g_utf8_to_utf16 + * g_utf8_to_utf16 */ static glong @@ -312,94 +312,94 @@ test_convert (void) gboolean loaded; guint i, j, k; char c; - + if (!(srcdir = getenv ("srcdir")) && !(srcdir = getenv ("PWD"))) return FAILED ("srcdir not defined!"); - + expected = g_malloc (sizeof (convert_result_t *) * G_N_ELEMENTS (charsets)); - + /* first load all our test samples... */ for (i = 0; i < G_N_ELEMENTS (charsets); i++) { path = g_strdup_printf ("%s%c%s.txt", srcdir, G_DIR_SEPARATOR, charsets[i]); loaded = g_file_get_contents (path, &content, &length, &err); g_free (path); - + if (!loaded) { for (j = 0; j < i; j++) { g_free (expected[j]->content); g_free (expected[j]); } - + g_free (expected); - + return FAILED ("Failed to load content for %s: %s", charsets[i], err->message); } - + expected[i] = g_malloc (sizeof (convert_result_t)); expected[i]->content = content; expected[i]->length = length; } - + /* test conversion from every charset to every other charset */ for (i = 0; i < G_N_ELEMENTS (charsets); i++) { for (j = 0; j < G_N_ELEMENTS (charsets); j++) { converted = g_convert (expected[i]->content, expected[i]->length, charsets[j], charsets[i], NULL, &converted_length, NULL); - + if (converted == NULL) { for (k = 0; k < G_N_ELEMENTS (charsets); k++) { g_free (expected[k]->content); g_free (expected[k]); } - + g_free (expected); - + return FAILED ("Failed to convert from %s to %s: NULL", charsets[i], charsets[j]); } - + if (converted_length != expected[j]->length) { length = expected[j]->length; - + for (k = 0; k < G_N_ELEMENTS (charsets); k++) { g_free (expected[k]->content); g_free (expected[k]); } - + g_free (converted); g_free (expected); - + return FAILED ("Failed to convert from %s to %s: expected %u bytes, got %u", charsets[i], charsets[j], length, converted_length); } - + for (n = 0; n < converted_length; n++) { if (converted[n] != expected[j]->content[n]) { c = expected[j]->content[n]; - + for (k = 0; k < G_N_ELEMENTS (charsets); k++) { g_free (expected[k]->content); g_free (expected[k]); } - + g_free (converted); g_free (expected); - + return FAILED ("Failed to convert from %s to %s: expected 0x%x at offset %u, got 0x%x", charsets[i], charsets[j], c, n, converted[n]); } } - + g_free (converted); } } - + for (k = 0; k < G_N_ELEMENTS (charsets); k++) { g_free (expected[k]->content); g_free (expected[k]); } - + g_free (expected); - + return OK; } @@ -407,13 +407,13 @@ static RESULT test_xdigit (void) { static char test_chars[] = { - '0', '1', '2', '3', '4', - '5', '6', '7', '8', '9', + '0', '1', '2', '3', '4', + '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'A', 'B', 'C', 'D', 'E', 'F', 'G'}; static gint32 test_values[] = { - 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, + 0, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, 10, 11, 12, 13, 14, 15, -1}; @@ -449,9 +449,9 @@ ucs4_to_utf16_check_result (const gunichar2 *result_str, const gunichar2 *expect if (result_str [i] != expected_str [i]) return FAILED("Incorrect value %d at index %d", result_str [i], i); } - if (result_str && result_str[expected_items_written] != '\0') + if (result_str && result_str[expected_items_written] != '\0') return FAILED("Null termination not found at the end of the string."); - + return OK; } @@ -475,7 +475,7 @@ test_ucs4_to_utf16 (void) GError* err=0; RESULT check_result; glong i; - + res = g_ucs4_to_utf16 (str1, 12, &items_read, &items_written, &err); check_result = ucs4_to_utf16_check_result (res, exp1, items_read, 11, items_written, 11, err, FALSE); if (check_result) return check_result; @@ -519,7 +519,7 @@ test_ucs4_to_utf16 (void) items_read = items_written = 0; err = 0; res = g_ucs4_to_utf16 (&str5[i], 1, &items_read, &items_written, &err); - check_result = ucs4_to_utf16_check_result (res, &exp5[current_write_index], + check_result = ucs4_to_utf16_check_result (res, &exp5[current_write_index], items_read, read_write[i*2], items_written, read_write[(i*2)+1], err, !read_write[(i*2)+1]); if (check_result) return check_result; g_free (res); @@ -559,9 +559,9 @@ utf16_to_ucs4_check_result (const gunichar *result_str, const gunichar *expected if (result_str [i] != expected_str [i]) return FAILED("Incorrect value %d at index %d", result_str [i], i); } - if (result_str && result_str[expected_items_written] != '\0') + if (result_str && result_str[expected_items_written] != '\0') return FAILED("Null termination not found at the end of the string."); - + return OK; } @@ -585,63 +585,63 @@ test_utf16_to_ucs4 (void) GError* err=0; RESULT check_result; glong i; - + res = g_utf16_to_ucs4 (str1, 12, &items_read, &items_written, &err); check_result = utf16_to_ucs4_check_result (res, exp1, items_read, 11, items_written, 11, err, FALSE); if (check_result) return check_result; g_free (res); - + items_read = items_written = 0; res = g_utf16_to_ucs4 (str2, 0, &items_read, &items_written, &err); check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 0, items_written, 0, err, FALSE); if (check_result) return check_result; g_free (res); - + items_read = items_written = 0; res = g_utf16_to_ucs4 (str2, 1, &items_read, &items_written, &err); check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 1, items_written, 1, err, FALSE); if (check_result) return check_result; g_free (res); - + items_read = items_written = 0; res = g_utf16_to_ucs4 (str2, 2, &items_read, &items_written, &err); check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 1, items_written, 1, err, FALSE); if (check_result) return check_result; g_free (res); - + items_read = items_written = 0; res = g_utf16_to_ucs4 (str2, 3, &items_read, &items_written, &err); check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 3, items_written, 2, err, FALSE); if (check_result) return check_result; g_free (res); - + items_read = items_written = 0; res = g_utf16_to_ucs4 (str2, 4, &items_read, &items_written, &err); check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 3, items_written, 2, err, FALSE); if (check_result) return check_result; g_free (res); - + items_read = items_written = 0; res = g_utf16_to_ucs4 (str2, 5, &items_read, &items_written, &err); check_result = utf16_to_ucs4_check_result (res, exp2, items_read, 4, items_written, 0, err, TRUE); if (check_result) return check_result; g_free (res); - + items_read = items_written = 0; err = 0; res = g_utf16_to_ucs4 (str3, 5, &items_read, &items_written, &err); check_result = utf16_to_ucs4_check_result (res, exp3, items_read, 1, items_written, 0, err, TRUE); if (check_result) return check_result; g_free (res); - + // This loop tests the bounds of the conversion algorithm current_read_index = current_write_index = 0; for (i=0;i<11;i++) { items_read = items_written = 0; err = 0; res = g_utf16_to_ucs4 (&str4[current_read_index], read_write[i*3], &items_read, &items_written, &err); - check_result = utf16_to_ucs4_check_result (res, &exp4[current_write_index], items_read, - read_write[(i*3)+1], items_written, read_write[(i*3)+2], err, + check_result = utf16_to_ucs4_check_result (res, &exp4[current_write_index], items_read, + read_write[(i*3)+1], items_written, read_write[(i*3)+2], err, !read_write[(i*3)+2]); if (check_result) return check_result; g_free (res); @@ -666,9 +666,9 @@ test_utf8_strlen (void) gchar word2 [] = {0xF1, 0x82, 0x82, 0x82,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'};//Valid, len = 5 gchar word3 [] = {'h','e',0xC2, 0x82,0x45,'\0'}; //Valid, len = 4 gchar word4 [] = {0x62,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Valid, len = 5 - + glong len = 0; - + //Test word1 len = g_utf8_strlen (word1,-1); if (len != 5) @@ -683,22 +683,22 @@ test_utf8_strlen (void) len = g_utf8_strlen (word1,3); if (len != 2) return FAILED ("Word1, max = 2, expected length of 2, but was %i", len); - + //Test word2 len = g_utf8_strlen (word2,-1); if (len != 5) return FAILED ("Word2 expected length of 5, but was %i", len); - + //Test word3 len = g_utf8_strlen (word3,-1); if (len != 4) return FAILED ("Word3 expected length of 4, but was %i", len); - + //Test word4 len = g_utf8_strlen (word4,-1); if (len != 5) return FAILED ("Word4 expected length of 5, but was %i", len); - + //Test null case len = g_utf8_strlen(NULL,0); if (len != 0) @@ -737,7 +737,7 @@ test_utf8_next_char (void) gchar word2 [] = {0xF1, 0x82, 0x82, 0x82,0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,'\0'}; //Valid, len = 5 gchar word1ExpectedValues [] = {0xC2, 0x45,0xE1, 0x58, 0xF1}; gchar word2ExpectedValues [] = {0xF1, 0xC2, 0x45, 0xE1, 0x58}; - + gchar* ptr = word1; gint count = 0; //Test word1 @@ -749,7 +749,7 @@ test_utf8_next_char (void) ptr = g_utf8_next_char (ptr); count++; } - + //Test word2 count = 0; ptr = word2; @@ -761,7 +761,7 @@ test_utf8_next_char (void) ptr = g_utf8_next_char (ptr); count++; } - + return OK; } @@ -774,7 +774,7 @@ test_utf8_validate (void) gchar validWord1 [] = {0xC2, 0x82, 0xC3,0xA0,'\0'}; //Valid gchar validWord2 [] = {0xC2, 0x82,0x45,0xE1, 0x81, 0x83,0x58,0xF1, 0x82, 0x82, 0x82,'\0'}; //Valid - + const gchar* end; gboolean retVal = g_utf8_validate (invalidWord1, -1, &end); if (retVal != FALSE) diff --git a/src/mono/mono/eventpipe/ep-rt-mono.h b/src/mono/mono/eventpipe/ep-rt-mono.h index 02ba8024a7fc7..6829e696f41d8 100644 --- a/src/mono/mono/eventpipe/ep-rt-mono.h +++ b/src/mono/mono/eventpipe/ep-rt-mono.h @@ -28,9 +28,6 @@ #include #include -#undef EP_ARRAY_SIZE -#define EP_ARRAY_SIZE(expr) G_N_ELEMENTS(expr) - #undef EP_INFINITE_WAIT #define EP_INFINITE_WAIT MONO_INFINITE_WAIT @@ -1756,7 +1753,7 @@ ep_rt_utf8_string_replace ( if (strFound != NULL) { size_t strSearchLen = strlen(strSearch); - size_t newStrSize = strlen(*str) + strlen(strReplacement) - strSearchLen + 1; + size_t newStrSize = strlen(*str) + strlen(strReplacement) - strSearchLen + 1; ep_char8_t *newStr = g_new(ep_char8_t, newStrSize); if (newStr == NULL) { diff --git a/src/mono/mono/eventpipe/test/ep-buffer-manager-tests.c b/src/mono/mono/eventpipe/test/ep-buffer-manager-tests.c index 642b58e52975c..126b04740c0b2 100644 --- a/src/mono/mono/eventpipe/test/ep-buffer-manager-tests.c +++ b/src/mono/mono/eventpipe/test/ep-buffer-manager-tests.c @@ -162,7 +162,7 @@ write_events ( uint32_t i = 0; for (; i < event_count; ++i) { EventPipeEventPayload payload; - ep_event_payload_init (&payload, (uint8_t *)TEST_EVENT_DATA, EP_ARRAY_SIZE (TEST_EVENT_DATA)); + ep_event_payload_init (&payload, (uint8_t *)TEST_EVENT_DATA, ARRAY_SIZE (TEST_EVENT_DATA)); result = ep_buffer_manager_write_event (buffer_manager, thread, session, ep_event, &payload, NULL, NULL, thread, NULL); ep_event_payload_fini (&payload); diff --git a/src/mono/mono/eventpipe/test/ep-buffer-tests.c b/src/mono/mono/eventpipe/test/ep-buffer-tests.c index 4ff600864c4ad..add8bfe358b6e 100644 --- a/src/mono/mono/eventpipe/test/ep-buffer-tests.c +++ b/src/mono/mono/eventpipe/test/ep-buffer-tests.c @@ -141,7 +141,7 @@ load_buffer ( event_data_len = strlen (event_data) + 1; }else { event_data = (gchar *)TEST_EVENT_DATA; - event_data_len = EP_ARRAY_SIZE (TEST_EVENT_DATA); + event_data_len = ARRAY_SIZE (TEST_EVENT_DATA); } if (event_data) { ep_event_payload_init (&payload, (uint8_t *)event_data, event_data_len); diff --git a/src/mono/mono/eventpipe/test/ep-tests.c b/src/mono/mono/eventpipe/test/ep-tests.c index e9e30c3983321..f7eab1c96b963 100644 --- a/src/mono/mono/eventpipe/test/ep-tests.c +++ b/src/mono/mono/eventpipe/test/ep-tests.c @@ -1107,7 +1107,7 @@ test_write_event (void) EventData data[1]; ep_event_data_init (&data[0], 0, 0, 0); - ep_write_event_2 (ep_event, data, EP_ARRAY_SIZE (data), NULL, NULL); + ep_write_event_2 (ep_event, data, ARRAY_SIZE (data), NULL, NULL); ep_event_data_fini (data); ep_on_exit: @@ -1158,7 +1158,7 @@ test_write_get_next_event (void) EventData data[1]; ep_event_data_init (&data[0], 0, 0, 0); - ep_write_event_2 (ep_event, data, EP_ARRAY_SIZE (data), NULL, NULL); + ep_write_event_2 (ep_event, data, ARRAY_SIZE (data), NULL, NULL); ep_event_data_fini (data); event_instance = ep_get_next_event (session_id); @@ -1234,7 +1234,7 @@ test_write_wait_get_next_event (void) EventData data[1]; ep_event_data_init (&data[0], 0, 0, 0); for (int i = 0; i < 100; i++) - ep_write_event_2 (ep_event, data, EP_ARRAY_SIZE (data), NULL, NULL); + ep_write_event_2 (ep_event, data, ARRAY_SIZE (data), NULL, NULL); ep_event_data_fini (data); //Should be signaled, since we should have buffers put in readonly by now. @@ -1303,7 +1303,7 @@ test_write_event_perf (void) for (events_written = 0; events_written < 10 * 1000 * 1000; events_written += 1000) { int64_t start = ep_perf_timestamp_get (); for (uint32_t i = 0; i < 1000; i++) - ep_write_event_2 (ep_event, data, EP_ARRAY_SIZE (data), NULL, NULL); + ep_write_event_2 (ep_event, data, ARRAY_SIZE (data), NULL, NULL); int64_t stop = ep_perf_timestamp_get (); accumulted_write_time_ticks += stop - start; diff --git a/src/mono/mono/metadata/assembly.c b/src/mono/mono/metadata/assembly.c index 1014840fc3f54..e8c4bbee3c0a4 100644 --- a/src/mono/mono/metadata/assembly.c +++ b/src/mono/mono/metadata/assembly.c @@ -46,7 +46,7 @@ #include #include #include -#include +#include #ifndef HOST_WIN32 #include diff --git a/src/mono/mono/metadata/components.c b/src/mono/mono/metadata/components.c index 1794d1e6fc51c..3750bbf33b323 100644 --- a/src/mono/mono/metadata/components.c +++ b/src/mono/mono/metadata/components.c @@ -75,7 +75,7 @@ mono_components_init (void) { #ifdef STATIC_COMPONENTS /* directly call each components init function */ - /* TODO: support disabled components. + /* TODO: support disabled components. * * The issue here is that we need to do static linking, so if we don't * directly reference mono_component__init anywhere (ie @@ -94,7 +94,7 @@ mono_components_init (void) /* call get_component for each component and init it or its stubs and add it to loaded_components */ MonoComponentLibrary *component_lib = NULL; - + for (int i = 0; i < G_N_ELEMENTS (components); ++i) { *components [i].component = get_component (&components [i], &component_lib); components [i].lib = component_lib; diff --git a/src/mono/mono/metadata/domain.c b/src/mono/mono/metadata/domain.c index 869e7f00d0ec4..ec0e8c71e728a 100644 --- a/src/mono/mono/metadata/domain.c +++ b/src/mono/mono/metadata/domain.c @@ -72,7 +72,7 @@ static MonoDomain *mono_root_domain; gboolean mono_dont_free_domains; -/* AppConfigInfo: Information about runtime versions supported by an +/* AppConfigInfo: Information about runtime versions supported by an * aplication. */ typedef struct { @@ -134,13 +134,13 @@ create_root_domain (void) #endif MONO_PROFILER_RAISE (domain_loaded, (domain)); - + return domain; } /** * mono_init_internal: - * + * * Creates the initial application domain and initializes the mono_defaults * structure. * This function is guaranteed to not run any IL code. @@ -236,7 +236,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * g_print ("WARNING: The requested runtime version \"%s\" is unavailable.\n", runtime_version); else g_print ("WARNING: The runtime version supported by this application is unavailable.\n"); - g_print ("Using default runtime: %s\n", default_runtime->runtime_version); + g_print ("Using default runtime: %s\n", default_runtime->runtime_version); } /* The selected runtime will be the first one for which there is a mscrolib.dll */ @@ -251,7 +251,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * } g_slist_free (runtimes); - + if ((status != MONO_IMAGE_OK) || (ass == NULL)) { switch (status){ case MONO_IMAGE_ERROR_ERRNO: { @@ -273,7 +273,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * /* to suppress compiler warning */ break; } - + exit (1); } mono_defaults.corlib = mono_assembly_get_image_internal (ass); @@ -425,7 +425,7 @@ mono_init_internal (const char *filename, const char *exe_filename, const char * /** * mono_init: - * + * * Creates the initial application domain and initializes the mono_defaults * structure. * @@ -451,7 +451,7 @@ mono_init (const char *domain_name) * structure. * This function is guaranteed to not run any IL code. * The runtime is initialized using the runtime version required by the - * provided executable. The version is determined by looking at the exe + * provided executable. The version is determined by looking at the exe * configuration file and the version PE field) * * \returns the initial domain. @@ -464,9 +464,9 @@ mono_init_from_assembly (const char *domain_name, const char *filename) /** * mono_init_version: - * + * * Used by the runtime, users should use \c mono_jit_init instead. - * + * * Creates the initial application domain and initializes the \c mono_defaults * structure. * @@ -833,7 +833,7 @@ get_runtime_by_version (const char *version) if (strcmp (version, supported_runtimes[n].runtime_version) == 0) return &supported_runtimes[n]; } - + vlen = strlen (version); if (vlen >= 4 && version [1] - '0' >= 4) { for (n=0; n MONO_TYPE_R8 || src_type > MONO_TYPE_R8) { @@ -289,7 +289,7 @@ get_normalized_integral_array_element_type (MonoTypeEnum elementType) return elementType; } -MonoBoolean +MonoBoolean ves_icall_System_Array_CanChangePrimitive (MonoReflectionType *volatile* ref_src_type_handle, MonoReflectionType *volatile* ref_dst_type_handle, MonoBoolean reliable) { MonoReflectionType* const ref_src_type = *ref_src_type_handle; @@ -838,7 +838,7 @@ ves_icall_System_Array_FastCopy (MonoArrayHandle source, int source_idx, MonoArr * Handle common cases. */ - /* Case1: object[] -> valuetype[] (ArrayList::ToArray) + /* Case1: object[] -> valuetype[] (ArrayList::ToArray) We fallback to managed here since we need to typecheck each boxed valuetype before storing them in the dest array. */ if (src_class == mono_defaults.object_class && m_class_is_valuetype (dest_class)) @@ -1249,8 +1249,8 @@ ves_icall_System_ValueType_Equals (MonoObjectHandle this_obj, MonoObjectHandle t /* * Do the comparison for fields of primitive type and return a result if - * possible. Otherwise, return the remaining fields in an array to the - * managed side. This way, we can avoid costly reflection operations in + * possible. Otherwise, return the remaining fields in an array to the + * managed side. This way, we can avoid costly reflection operations in * managed code. */ iter = NULL; @@ -1582,7 +1582,7 @@ type_from_parsed_name (MonoTypeNameParse *info, MonoStackCrawlMark *stack_mark, goto_if_nok (error, fail); } - if (!type) + if (!type) goto fail; return mono_type_get_object_handle (type, error); @@ -1632,7 +1632,7 @@ ves_icall_System_RuntimeTypeHandle_internal_from_name (MonoStringHandle name, } goto leave; } - + leave: if (free_info) mono_reflection_free_type_info (&info); @@ -1707,7 +1707,7 @@ guint32 ves_icall_RuntimeTypeHandle_type_is_assignable_from (MonoReflectionTypeHandle ref_type, MonoReflectionTypeHandle ref_c, MonoError *error) { g_assert (!MONO_HANDLE_IS_NULL (ref_type)); - + MonoType *type = MONO_HANDLE_GETVAL (ref_type, type); MonoClass *klass = mono_class_from_mono_type_internal (type); MonoType *ctype = MONO_HANDLE_GETVAL (ref_c, type); @@ -1968,7 +1968,7 @@ ves_icall_System_MonoMethodInfo_get_retval_marshal (MonoMethod *method, MonoErro MONO_HANDLE_ASSIGN (res, mono_reflection_marshal_as_attribute_from_marshal_spec (method->klass, mspecs [0], error)); goto_if_nok (error, leave); } - + leave: for (int i = mono_method_signature_internal (method)->param_count; i >= 0; i--) if (mspecs [i]) @@ -2004,7 +2004,7 @@ ves_icall_RuntimeFieldInfo_GetParentType (MonoReflectionFieldHandle field, MonoB MonoObjectHandle ves_icall_RuntimeFieldInfo_GetValueInternal (MonoReflectionFieldHandle field_handle, MonoObjectHandle obj_handle, MonoError *error) -{ +{ MonoReflectionField * const field = MONO_HANDLE_RAW (field_handle); MonoClassField *cf = field->field; @@ -2063,7 +2063,7 @@ ves_icall_RuntimeFieldInfo_SetValueInternal (MonoReflectionFieldHandle field, Mo if (mono_class_is_nullable (mono_class_from_mono_type_internal (type))) { MonoClass *nklass = mono_class_from_mono_type_internal (type); - /* + /* * Convert the boxed vtype into a Nullable structure. * This is complicated by the fact that Nullables have * a variable structure. @@ -2338,9 +2338,9 @@ ves_icall_RuntimePropertyInfo_get_property_info (MonoReflectionPropertyHandle pr MONO_STRUCT_SETREF_INTERNAL (info, set, MONO_HANDLE_RAW (rm)); } - /* - * There may be other methods defined for properties, though, it seems they are not exposed - * in the reflection API + /* + * There may be other methods defined for properties, though, it seems they are not exposed + * in the reflection API */ } @@ -2417,7 +2417,7 @@ ves_icall_RuntimeEventInfo_get_event_info (MonoReflectionMonoEventHandle ref_eve for (i = 0; i < n; i++) if (!add_event_other_methods_to_array (event->other [i], info_arr, i, error)) return; - } + } #endif } @@ -2611,7 +2611,7 @@ set_interface_map_data_method_object (MonoMethod *method, MonoClass *iclass, int goto_if_nok (error, leave); MONO_HANDLE_ARRAY_SETREF (targets, i, member); } - + leave: HANDLE_FUNCTION_RETURN_VAL (is_ok (error)); } @@ -2644,7 +2644,7 @@ ves_icall_RuntimeType_GetInterfaceMapData (MonoReflectionTypeHandle ref_type, Mo if (method->flags & METHOD_ATTRIBUTE_VIRTUAL) i++; } - + MonoArrayHandle targets_arr = mono_array_new_handle (mono_defaults.method_info_class, i, error); return_if_nok (error); MONO_HANDLE_ASSIGN (targets, targets_arr); @@ -2816,7 +2816,7 @@ ves_icall_RuntimeType_get_DeclaringType (MonoReflectionTypeHandle ref_type, Mono MonoStringHandle ves_icall_RuntimeType_get_Name (MonoReflectionTypeHandle reftype, MonoError *error) { - MonoType *type = MONO_HANDLE_RAW(reftype)->type; + MonoType *type = MONO_HANDLE_RAW(reftype)->type; MonoClass *klass = mono_class_from_mono_type_internal (type); // FIXME: this should be escaped in some scenarios with mono_identifier_escape_type_name_chars // Determining exactly when to do so is fairly difficult, so for now we don't bother to avoid regressions @@ -2907,7 +2907,7 @@ ves_icall_RuntimeType_GetGenericArguments (MonoReflectionTypeHandle ref_type, Mo if (!set_type_object_in_array (m_class_get_byval_arg (pklass), res, i, error)) goto leave; } - + } else if (mono_class_is_ginst (klass)) { MonoGenericInst *inst = mono_class_get_generic_class (klass)->context.class_inst; MONO_HANDLE_ASSIGN (res, create_type_array (runtimeTypeArray, inst->type_argc, error)); @@ -2961,7 +2961,7 @@ ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl (MonoReflectionTypeHan MonoClass *generic_class = mono_class_get_generic_class (klass)->container_class; MonoGCHandle ref_info_handle = mono_class_get_ref_info_handle (generic_class); - + if (m_class_was_typebuilder (generic_class) && ref_info_handle) { MonoObjectHandle tb = mono_gchandle_get_target_handle (ref_info_handle); g_assert (!MONO_HANDLE_IS_NULL (tb)); @@ -3056,19 +3056,19 @@ ves_icall_RuntimeTypeHandle_IsGenericVariable (MonoReflectionTypeHandle ref_type } MonoReflectionMethodHandle -ves_icall_RuntimeType_GetCorrespondingInflatedMethod (MonoReflectionTypeHandle ref_type, +ves_icall_RuntimeType_GetCorrespondingInflatedMethod (MonoReflectionTypeHandle ref_type, MonoReflectionMethodHandle generic, MonoError *error) { error_init (error); MonoType *type = MONO_HANDLE_GETVAL (ref_type, type); MonoClass *klass = mono_class_from_mono_type_internal (type); - + mono_class_init_checked (klass, error); return_val_if_nok (error, MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE)); MonoMethod *generic_method = MONO_HANDLE_GETVAL (generic, method); - + MonoReflectionMethodHandle ret = MONO_HANDLE_CAST (MonoReflectionMethod, NULL_HANDLE); MonoMethod *method; gpointer iter = NULL; @@ -3122,7 +3122,7 @@ ves_icall_RuntimeMethodInfo_GetPInvoke (MonoReflectionMethodHandle ref_method, i error_init (error); if (image_is_dynamic (image)) { - MonoReflectionMethodAux *method_aux = + MonoReflectionMethodAux *method_aux = (MonoReflectionMethodAux *)g_hash_table_lookup (((MonoDynamicImage*)image)->method_aux_hash, method); if (method_aux) { import = method_aux->dllentry; @@ -3137,14 +3137,14 @@ ves_icall_RuntimeMethodInfo_GetPInvoke (MonoReflectionMethodHandle ref_method, i else { if (piinfo->implmap_idx) { mono_metadata_decode_row (im, piinfo->implmap_idx - 1, im_cols, MONO_IMPLMAP_SIZE); - + piinfo->piflags = im_cols [MONO_IMPLMAP_FLAGS]; import = mono_metadata_string_heap (image, im_cols [MONO_IMPLMAP_NAME]); scope_token = mono_metadata_decode_row_col (mr, im_cols [MONO_IMPLMAP_SCOPE] - 1, MONO_MODULEREF_NAME); scope = mono_metadata_string_heap (image, scope_token); } } - + *flags = piinfo->piflags; MONO_HANDLE_ASSIGN (entry_point, mono_string_new_handle (import, error)); return_if_nok (error); @@ -3364,7 +3364,7 @@ ves_icall_InternalInvoke (MonoReflectionMethodHandle method_handle, MonoObjectHa MonoObject* const this_arg = MONO_HANDLE_RAW (this_arg_handle); g_assert (params_span != NULL); - /* + /* * Invoke from reflection is supposed to always be a virtual call (the API * is stupid), mono_runtime_invoke_*() calls the provided method, allowing * greater flexibility. @@ -3434,12 +3434,12 @@ ves_icall_InternalInvoke (MonoReflectionMethodHandle method_handle, MonoObjectHa g_assert (pcount == (m_class_get_rank (m->klass) * 2)); /* The arguments are lower-bound-length pairs */ intptr_t * const lower_bounds = (intptr_t *)g_alloca (sizeof (intptr_t) * pcount); - + for (i = 0; i < pcount / 2; ++i) { lower_bounds [i] = *(int32_t*) ((char*)mono_span_get (params_span, MonoObject*, (i * 2)) + sizeof (MonoObject)); lengths [i] = *(int32_t*) ((char*)mono_span_get (params_span, MonoObject*, (i * 2) + 1) + sizeof (MonoObject)); } - + arr = mono_array_new_full_checked (m->klass, lengths, lower_bounds, error); goto_if_nok (error, return_null); goto exit; @@ -3710,15 +3710,15 @@ ves_icall_RuntimeType_GetFields_native (MonoReflectionTypeHandle ref_type, char return g_ptr_array_new (); } - int (*compare_func) (const char *s1, const char *s2) = NULL; + int (*compare_func) (const char *s1, const char *s2) = NULL; compare_func = ((bflags & BFLAGS_IgnoreCase) || (mlisttype == MLISTTYPE_CaseInsensitive)) ? mono_utf8_strcasecmp : strcmp; MonoClass *startklass, *klass; klass = startklass = mono_class_from_mono_type_internal (type); GPtrArray *ptr_array = g_ptr_array_sized_new (16); - -handle_parent: + +handle_parent: if (mono_class_has_failure (klass)) { mono_error_set_for_class_failure (error, klass); goto fail; @@ -3801,7 +3801,7 @@ mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bfla array = g_ptr_array_new (); startklass = klass; error_init (error); - + compare_func = ((bflags & BFLAGS_IgnoreCase) || (mlisttype == MLISTTYPE_CaseInsensitive)) ? mono_utf8_strcasecmp : strcmp; /* An optimization for calls made from Delegate:CreateDelegate () */ @@ -3832,7 +3832,7 @@ mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bfla mono_class_setup_methods (klass); mono_class_setup_vtable (klass); if (mono_class_has_failure (klass)) - goto loader_error; + goto loader_error; iter = NULL; while ((method = mono_class_get_methods (klass, &iter))) { @@ -3872,7 +3872,7 @@ mono_class_get_methods_by_name (MonoClass *klass, const char *name, guint32 bfla if (compare_func (name, method->name)) continue; } - + match = 0; g_ptr_array_add (array, method); } @@ -3922,7 +3922,7 @@ ves_icall_RuntimeType_GetConstructors_native (MonoReflectionTypeHandle ref_type, mono_error_set_for_class_failure (error, klass); return NULL; } - + GPtrArray *res_array = g_ptr_array_sized_new (4); /* FIXME, guestimating */ @@ -4033,7 +4033,7 @@ ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionTypeHandle ref_t return g_ptr_array_new (); } - + MonoClass *startklass, *klass; klass = startklass = mono_class_from_mono_type_internal (type); @@ -4092,12 +4092,12 @@ ves_icall_RuntimeType_GetPropertiesByName_native (MonoReflectionTypeHandle ref_t if ((mlisttype != MLISTTYPE_All) && (propname != NULL) && compare_func (propname, prop->name)) continue; - + if (g_hash_table_lookup (properties, prop)) continue; g_ptr_array_add (res_array, prop); - + g_hash_table_insert (properties, prop, prop); } if (!(bflags & BFLAGS_DeclaredOnly) && (klass = m_class_get_parent (klass))) { @@ -4185,7 +4185,7 @@ ves_icall_RuntimeType_GetEvents_native (MonoReflectionTypeHandle ref_type, char if (g_hash_table_lookup (events, event)) continue; - g_ptr_array_add (res_array, event); + g_ptr_array_add (res_array, event); g_hash_table_insert (events, event, event); } @@ -4231,7 +4231,7 @@ ves_icall_RuntimeType_GetNestedTypes_native (MonoReflectionTypeHandle ref_type, klass = mono_class_get_generic_class (klass)->container_class; GPtrArray *res_array = g_ptr_array_new (); - + MonoClass *nested; gpointer iter = NULL; while ((nested = mono_class_get_nested_types (klass, &iter))) { @@ -4418,7 +4418,7 @@ MonoStringHandle ves_icall_System_Reflection_RuntimeAssembly_get_code_base (MonoReflectionAssemblyHandle assembly, MonoError *error) { MonoAssembly *mass = MONO_HANDLE_GETVAL (assembly, assembly); - + /* return NULL for bundled assemblies in single-file scenarios */ const char* filename = m_image_get_filename (mass->image); @@ -4466,7 +4466,7 @@ ves_icall_System_Reflection_RuntimeAssembly_InternalImageRuntimeVersion (MonoRef } MonoReflectionMethodHandle -ves_icall_System_Reflection_RuntimeAssembly_get_EntryPoint (MonoReflectionAssemblyHandle assembly_h, MonoError *error) +ves_icall_System_Reflection_RuntimeAssembly_get_EntryPoint (MonoReflectionAssemblyHandle assembly_h, MonoError *error) { MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly); MonoMethod *method; @@ -4485,7 +4485,7 @@ ves_icall_System_Reflection_RuntimeAssembly_get_EntryPoint (MonoReflectionAssemb } MonoReflectionModuleHandle -ves_icall_System_Reflection_Assembly_GetManifestModuleInternal (MonoReflectionAssemblyHandle assembly, MonoError *error) +ves_icall_System_Reflection_Assembly_GetManifestModuleInternal (MonoReflectionAssemblyHandle assembly, MonoError *error) { MonoAssembly *a = MONO_HANDLE_GETVAL (assembly, assembly); return mono_module_get_object_handle (a->image, error); @@ -4504,7 +4504,7 @@ add_manifest_resource_name_to_array (MonoImage *image, MonoTableInfo *table, int } MonoArrayHandle -ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceNames (MonoReflectionAssemblyHandle assembly_h, MonoError *error) +ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceNames (MonoReflectionAssemblyHandle assembly_h, MonoError *error) { MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly); MonoTableInfo *table = &assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE]; @@ -4540,14 +4540,14 @@ create_referenced_assembly_name (MonoImage *image, int i, MonoError *error) aname->hash_value = NULL; aname->hash_len = 0; g_assert (aname->public_key == NULL); - + /* note: this function doesn't return the codebase on purpose (i.e. it can be used under partial trust as path information isn't present). */ return aname; } GPtrArray* -ves_icall_System_Reflection_Assembly_InternalGetReferencedAssemblies (MonoReflectionAssemblyHandle assembly, MonoError *error) +ves_icall_System_Reflection_Assembly_InternalGetReferencedAssemblies (MonoReflectionAssemblyHandle assembly, MonoError *error) { error_init (error); MonoAssembly *ass = MONO_HANDLE_GETVAL(assembly, assembly); @@ -4666,7 +4666,7 @@ get_manifest_resource_internal (MonoReflectionAssemblyHandle assembly_h, MonoStr impl = cols [MONO_MANIFEST_IMPLEMENTATION]; if (impl) { /* - * this code should only be called after obtaining the + * this code should only be called after obtaining the * ResourceInfo and handling the other cases. */ g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_FILE); @@ -4679,7 +4679,7 @@ get_manifest_resource_internal (MonoReflectionAssemblyHandle assembly_h, MonoStr else module = assembly->image; - + MonoReflectionModuleHandle rm = mono_module_get_object_handle (module, error); return_val_if_nok (error, NULL); MONO_HANDLE_ASSIGN (ref_module, rm); @@ -4688,7 +4688,7 @@ get_manifest_resource_internal (MonoReflectionAssemblyHandle assembly_h, MonoStr } void * -ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, gint32 *size, MonoReflectionModuleHandleOut ref_module, MonoError *error) +ves_icall_System_Reflection_RuntimeAssembly_GetManifestResourceInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, gint32 *size, MonoReflectionModuleHandleOut ref_module, MonoError *error) { gpointer ret = get_manifest_resource_internal (assembly_h, name, size, ref_module, error); @@ -4714,7 +4714,7 @@ get_manifest_resource_info_internal (MonoReflectionAssemblyHandle assembly_h, Mo char *n; gboolean result = FALSE; - + n = mono_string_handle_to_utf8 (name, error); goto_if_nok (error, leave); @@ -4799,7 +4799,7 @@ add_filename_to_files_array (MonoAssembly * assembly, MonoTableInfo *table, int } MonoObjectHandle -ves_icall_System_Reflection_RuntimeAssembly_GetFilesInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, MonoBoolean resource_modules, MonoError *error) +ves_icall_System_Reflection_RuntimeAssembly_GetFilesInternal (MonoReflectionAssemblyHandle assembly_h, MonoStringHandle name, MonoBoolean resource_modules, MonoError *error) { MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_h, assembly); MonoTableInfo *table = &assembly->image->tables [MONO_TABLE_FILE]; @@ -4857,7 +4857,7 @@ add_module_to_modules_array (MonoArrayHandle dest, int *dest_idx, MonoImage* mod if (module) { MonoReflectionModuleHandle rm = mono_module_get_object_handle (module, error); goto_if_nok (error, leave); - + MONO_HANDLE_ARRAY_SETREF (dest, *dest_idx, rm); ++(*dest_idx); } @@ -4946,7 +4946,7 @@ ves_icall_System_Reflection_RuntimeAssembly_GetModulesInternal (MonoReflectionAs } MonoReflectionMethodHandle -ves_icall_GetCurrentMethod (MonoError *error) +ves_icall_GetCurrentMethod (MonoError *error) { MonoMethod *m = mono_method_get_last_managed (); @@ -4991,7 +4991,7 @@ mono_method_get_equivalent_method (MonoMethod *method, MonoClass *klass) if (method_klass_methods [i] == method) { offset = i; break; - } + } } mono_class_setup_methods (klass); if (mono_class_has_failure (klass)) @@ -5082,7 +5082,7 @@ ves_icall_System_RuntimeType_getFullName (MonoReflectionTypeHandle object, MonoB MONO_TYPE_NAME_FORMAT_FULL_NAME; else format = MONO_TYPE_NAME_FORMAT_REFLECTION; - + name = mono_type_get_name_full (type, format); if (!name) return NULL_HANDLE_STRING; @@ -5239,7 +5239,7 @@ mono_module_get_types (MonoImage *image, MonoArrayHandleOut exceptions, MonoBool count++; } } - + return res; } @@ -5317,7 +5317,7 @@ assembly_get_types (MonoReflectionAssemblyHandle assembly_handle, MonoBoolean ex } } - /* the ReflectionTypeLoadException must have all the types (Types property), + /* the ReflectionTypeLoadException must have all the types (Types property), * NULL replacing types which throws an exception. The LoaderException must * contain all exceptions for NULL items. */ @@ -5374,7 +5374,7 @@ assembly_get_types (MonoReflectionAssemblyHandle assembly_handle, MonoBoolean ex mono_error_set_exception_handle (error, exc); return NULL_HANDLE_ARRAY; } - + return res; } @@ -5391,7 +5391,7 @@ get_top_level_forwarded_type (MonoImage *image, MonoTableInfo *table, int i, Mon guint32 cols [MONO_EXP_TYPE_SIZE]; MonoClass *klass; MonoReflectionTypeHandle rt; - + mono_metadata_decode_row (table, i, cols, MONO_EXP_TYPE_SIZE); if (!(cols [MONO_EXP_TYPE_FLAGS] & TYPE_ATTRIBUTE_FORWARDER)) return; @@ -5454,7 +5454,7 @@ ves_icall_System_Reflection_RuntimeAssembly_GetTopLevelForwardedTypes (MonoRefle if (mono_metadata_decode_row_col (table, i, MONO_EXP_TYPE_FLAGS) & TYPE_ATTRIBUTE_FORWARDER) count ++; } - + MonoArrayHandle types = mono_array_new_handle (mono_defaults.runtimetype_class, count, error); return_val_if_nok (error, NULL_HANDLE_ARRAY); MonoArrayHandle exceptions = mono_array_new_handle (mono_defaults.exception_class, count, error); @@ -5506,7 +5506,7 @@ ves_icall_AssemblyExtensions_ApplyUpdate (MonoAssembly *assm, #endif mono_image_load_enc_delta (MONO_ENC_DELTA_API, image_base, dmeta_bytes, dmeta_len, dil_bytes, dil_len, dpdb_bytes, dpdb_len, error); - + mono_error_set_pending_exception (error); } @@ -5699,7 +5699,7 @@ module_resolve_type_token (MonoImage *image, guint32 token, MonoArrayHandle type *resolve_error = ResolveTokenError_Other; /* Validate token */ - if ((table != MONO_TABLE_TYPEDEF) && (table != MONO_TABLE_TYPEREF) && + if ((table != MONO_TABLE_TYPEDEF) && (table != MONO_TABLE_TYPEREF) && (table != MONO_TABLE_TYPESPEC)) { *resolve_error = ResolveTokenError_BadTable; goto leave; @@ -5758,7 +5758,7 @@ module_resolve_method_token (MonoImage *image, guint32 token, MonoArrayHandle ty *resolve_error = ResolveTokenError_Other; /* Validate token */ - if ((table != MONO_TABLE_METHOD) && (table != MONO_TABLE_METHODSPEC) && + if ((table != MONO_TABLE_METHOD) && (table != MONO_TABLE_METHODSPEC) && (table != MONO_TABLE_MEMBERREF)) { *resolve_error = ResolveTokenError_BadTable; goto leave; @@ -5887,7 +5887,7 @@ module_resolve_field_token (MonoImage *image, guint32 token, MonoArrayHandle typ init_generic_context_from_args_handles (&context, type_args, method_args); field = mono_field_from_token_checked (image, token, &klass, &context, error); - + leave: HANDLE_FUNCTION_RETURN_VAL (field); } @@ -5923,7 +5923,7 @@ ves_icall_System_Reflection_RuntimeModule_ResolveMemberToken (MonoImage *image, return MONO_HANDLE_CAST (MonoObject, mono_method_get_object_handle (m, m->klass, merror)); } else return NULL_HANDLE; - } + } case MONO_TABLE_FIELD: { MonoClassField *f = module_resolve_field_token (image, token, type_args, method_args, error, merror); if (f) { @@ -6334,7 +6334,7 @@ void ves_icall_System_ArgIterator_Setup (MonoArgIterator *iter, char* argsp, char* start) { iter->sig = *(MonoMethodSignature**)argsp; - + g_assert (iter->sig->sentinelpos <= iter->sig->param_count); g_assert (iter->sig->call_convention == MONO_CALL_VARARG); @@ -6415,7 +6415,7 @@ MonoType* ves_icall_System_ArgIterator_IntGetNextArgType (MonoArgIterator *iter) { gint i; - + i = iter->sig->sentinelpos + iter->next_arg; g_assert (i < iter->sig->param_count); @@ -6571,7 +6571,7 @@ ves_icall_RuntimeParameterInfo_GetTypeModifiers (MonoReflectionTypeHandle rt, Mo MonoProperty *prop = MONO_HANDLE_GETVAL (MONO_HANDLE_CAST (MonoReflectionProperty, member), property); if (!(method = prop->get)) method = prop->set; - g_assert (method); + g_assert (method); } else if (strcmp (m_class_get_name (member_class), "DynamicMethod") == 0 && strcmp (m_class_get_name_space (member_class), "System.Reflection.Emit") == 0) { MonoArrayHandle params = MONO_HANDLE_NEW_GET (MonoArray, MONO_HANDLE_CAST (MonoReflectionDynamicMethod, member), parameters); MonoReflectionTypeHandle t = MONO_HANDLE_NEW (MonoReflectionType, NULL); @@ -6964,7 +6964,7 @@ mono_add_internal_call_internal (const char *name, gconstpointer method) add_internal_call_with_flags (name, method, MONO_ICALL_FLAGS_COOPERATIVE); } -/* +/* * we should probably export this as an helper (handle nested types). * Returns the number of chars written in buf. */ diff --git a/src/mono/mono/metadata/metadata.c b/src/mono/mono/metadata/metadata.c index 698a9a20fa191..580a0988650e3 100644 --- a/src/mono/mono/metadata/metadata.c +++ b/src/mono/mono/metadata/metadata.c @@ -91,7 +91,7 @@ enum { /* HasCustomAttribute index. Indexes any table except CustomAttribute */ MONO_MT_HASCAT_IDX, - + /* CustomAttributeType encoded index */ MONO_MT_CAT_IDX, @@ -541,7 +541,7 @@ static gboolean check_assembly_names_strictly = FALSE; * * Returns the name of the given ECMA metadata logical format table * as described in ECMA 335, Partition II, Section 22. - * + * * \returns the name for the \p table index */ const char * @@ -555,11 +555,11 @@ mono_meta_table_name (int table) /* The guy who wrote the spec for this should not be allowed near a * computer again. - -If e is a coded token(see clause 23.1.7) that points into table ti out of n possible tables t0, .. tn-1, -then it is stored as e << (log n) & tag{ t0, .. tn-1}[ ti] using 2 bytes if the maximum number of -rows of tables t0, ..tn-1, is less than 2^16 - (log n), and using 4 bytes otherwise. The family of -finite maps tag{ t0, ..tn-1} is defined below. Note that to decode a physical row, you need the + +If e is a coded token(see clause 23.1.7) that points into table ti out of n possible tables t0, .. tn-1, +then it is stored as e << (log n) & tag{ t0, .. tn-1}[ ti] using 2 bytes if the maximum number of +rows of tables t0, ..tn-1, is less than 2^16 - (log n), and using 4 bytes otherwise. The family of +finite maps tag{ t0, ..tn-1} is defined below. Note that to decode a physical row, you need the inverse of this mapping. */ @@ -600,7 +600,7 @@ get_nrows (MonoImage *meta, int idx) * \param meta metadata context * \param tableindex metadata table number * \param result_bitfield pointer to \c guint32 where to store additional info - * + * * \c mono_metadata_compute_size computes the length in bytes of a single * row in a metadata table. The size of each column is encoded in the * \p result_bitfield return value along with the number of columns in the table. @@ -621,26 +621,26 @@ mono_metadata_compute_size (MonoImage *meta, int tableindex, guint32 *result_bit switch (code){ case MONO_MT_UINT32: field_size = 4; break; - + case MONO_MT_UINT16: field_size = 2; break; - + case MONO_MT_UINT8: field_size = 1; break; - + case MONO_MT_BLOB_IDX: field_size = meta->idx_blob_wide ? 4 : 2; break; - + case MONO_MT_STRING_IDX: field_size = meta->idx_string_wide ? 4 : 2; break; - + case MONO_MT_GUID_IDX: field_size = meta->idx_guid_wide ? 4 : 2; break; case MONO_MT_TABLE_IDX: /* Uhm, a table index can point to other tables besides the current one * so, it's not correct to use the rowcount of the current table to - * get the size for this column - lupus + * get the size for this column - lupus */ switch (tableindex) { case MONO_TABLE_ASSEMBLYREFOS: @@ -781,7 +781,7 @@ mono_metadata_compute_size (MonoImage *meta, int tableindex, guint32 *result_bit field_size = 4; break; }*/ - + n = MAX (get_nrows (meta, MONO_TABLE_METHOD), get_nrows (meta, MONO_TABLE_FIELD)); n = MAX (n, get_nrows (meta, MONO_TABLE_TYPEREF)); @@ -931,7 +931,7 @@ mono_metadata_compute_size (MonoImage *meta, int tableindex, guint32 *result_bit /* 3 bits to encode */ field_size = rtsize (meta, n, 16 - 3); break; - + /* * MethodDefOrRef: MethodDef, MemberRef */ @@ -942,7 +942,7 @@ mono_metadata_compute_size (MonoImage *meta, int tableindex, guint32 *result_bit /* 1 bit used to encode tag */ field_size = rtsize (meta, n, 16-1); break; - + /* * HasSemantics: Property, Event */ @@ -1011,7 +1011,7 @@ mono_metadata_compute_table_bases (MonoImage *meta) { int i; const char *base = meta->tables_base; - + for (i = 0; i < MONO_TABLE_NUM; i++) { MonoTableInfo *table = &meta->tables [i]; if (table_info_get_rows (table) == 0) @@ -1038,7 +1038,7 @@ mono_metadata_locate (MonoImage *meta, int table, int idx) /* FIXME: metadata-update */ /* idx == 0 refers always to NULL */ g_return_val_if_fail (idx > 0 && idx <= table_info_get_rows (&meta->tables [table]), ""); /*FIXME shouldn't we return NULL here?*/ - + return meta->tables [table].base + (meta->tables [table].row_size * (idx - 1)); } @@ -1132,7 +1132,7 @@ mono_metadata_string_heap_checked (MonoImage *meta, guint32 index, MonoError *er if (G_UNLIKELY (!ok)) { const char *image_name = meta && meta->name ? meta->name : "unknown image"; mono_error_set_bad_image_by_name (error, image_name, "string heap index %ud out bounds %u: %s, also checked delta images", index, meta->heap_strings.size, image_name); - + return NULL; } meta = dmeta; @@ -1320,7 +1320,7 @@ mono_metadata_decode_row_raw (const MonoTableInfo *t, int idx, guint32 *res, int g_assert (idx < table_info_get_rows (t)); g_assert (idx >= 0); data = t->base + idx * t->row_size; - + g_assert (res_size == count); for (i = 0; i < count; i++) { @@ -1466,7 +1466,7 @@ mono_metadata_decode_row_col_raw (const MonoTableInfo *t, int idx, guint col) int n; guint32 bitfield = t->size_bitfield; - + g_assert (idx < table_info_get_rows (t)); g_assert (col < mono_metadata_table_count (bitfield)); data = t->base + idx * t->row_size; @@ -1503,7 +1503,7 @@ mono_metadata_decode_blob_size (const char *xptr, const char **rptr) { const unsigned char *ptr = (const unsigned char *)xptr; guint32 size; - + if ((*ptr & 0x80) == 0){ size = ptr [0] & 0x7f; ptr++; @@ -1538,7 +1538,7 @@ mono_metadata_decode_value (const char *_ptr, const char **rptr) const unsigned char *ptr = (const unsigned char *) _ptr; unsigned char b = *ptr; guint32 len; - + if ((b & 0x80) == 0){ len = b; ++ptr; @@ -1554,7 +1554,7 @@ mono_metadata_decode_value (const char *_ptr, const char **rptr) } if (rptr) *rptr = (char*)ptr; - + return len; } @@ -1595,7 +1595,7 @@ mono_metadata_decode_signed_value (const char *ptr, const char **rptr) * Translates the given 1-based index into the \c Method, \c Field, \c Event, or \c Param tables * using the \c *Ptr tables in uncompressed metadata, if they are available. * - * FIXME: The caller is not forced to call this function, which is error-prone, since + * FIXME: The caller is not forced to call this function, which is error-prone, since * forgetting to call it would only show up as a bug on uncompressed metadata. */ guint32 @@ -1732,7 +1732,7 @@ mono_metadata_parse_array_internal (MonoImage *m, MonoGenericContainer *containe int i; MonoArrayType *array; MonoType *etype; - + etype = mono_metadata_parse_type_checked (m, container, 0, FALSE, ptr, &ptr, error); //FIXME this doesn't respect @transient if (!etype) return NULL; @@ -1833,8 +1833,6 @@ builtin_types[] = { {{NULL}, 0, MONO_TYPE_U, 0, 1, 0}, }; -#define NBUILTIN_TYPES() (sizeof (builtin_types) / sizeof (builtin_types [0])) - static GHashTable *type_cache = NULL; static gint32 next_generic_inst_id = 0; @@ -1858,7 +1856,7 @@ mono_type_equal (gconstpointer ka, gconstpointer kb) { const MonoType *a = (const MonoType *) ka; const MonoType *b = (const MonoType *) kb; - + if (a->type != b->type || m_type_is_byref (a) != m_type_is_byref (b) || a->attrs != b->attrs || a->pinned != b->pinned) return 0; /* need other checks */ @@ -1873,7 +1871,7 @@ mono_metadata_generic_inst_hash (gconstpointer data) int i; g_assert (ginst); g_assert (ginst->type_argv); - + for (i = 0; i < ginst->type_argc; ++i) { hash *= 13; g_assert (ginst->type_argv [i]); @@ -1964,14 +1962,14 @@ mono_metadata_init (void) type_cache = g_hash_table_new (mono_type_hash, mono_type_equal); - for (i = 0; i < NBUILTIN_TYPES (); ++i) + for (i = 0; i < G_N_ELEMENTS (builtin_types); ++i) g_hash_table_insert (type_cache, (gpointer) &builtin_types [i], (gpointer) &builtin_types [i]); mono_metadata_update_init (); } /* - * Make a pass over the metadata signature blob starting at \p tmp_ptr and count the custom modifiers. + * Make a pass over the metadata signature blob starting at \p tmp_ptr and count the custom modifiers. */ static int count_custom_modifiers (MonoImage *m, const char *tmp_ptr) @@ -2160,7 +2158,7 @@ do_mono_metadata_parse_type_with_cmods (MonoType *type, int cmod_count, MonoImag * \param ptr pointer to the type representation * \param rptr pointer updated to match the end of the decoded stream * \param transient whenever to allocate the result from the heap or from a mempool - * + * * Decode a compressed type description found at \p ptr in \p m . * \p mode can be one of \c MONO_PARSE_MOD_TYPE, \c MONO_PARSE_PARAM, \c MONO_PARSE_RET, * \c MONO_PARSE_FIELD, \c MONO_PARSE_LOCAL, \c MONO_PARSE_TYPE. @@ -2229,7 +2227,7 @@ mono_metadata_parse_type_internal (MonoImage *m, MonoGenericContainer *container free_parsed_type (type, transient); return NULL; } - + // Possibly we can return an already-allocated type instead of the one we decoded if (!allocated && !transient) { @@ -2238,7 +2236,7 @@ mono_metadata_parse_type_internal (MonoImage *m, MonoGenericContainer *container if (try_get_canonical_type (type, &ret_type)) return ret_type; } - + /* printf ("%x %x %c %s\n", type->attrs, type->num_mods, type->pinned ? 'p' : ' ', mono_type_full_name (type)); */ // Otherwise return the type we decoded @@ -2300,7 +2298,7 @@ mono_metadata_method_has_param_attrs (MonoImage *m, int def) * @def method def token (one based) * @param_count number of params to decode including the return value * - * Return the parameter attributes for the method whose MethodDef index is DEF. The + * Return the parameter attributes for the method whose MethodDef index is DEF. The * returned memory needs to be freed by the caller. If all the param attributes are * 0, then NULL is returned. */ @@ -2383,7 +2381,7 @@ mono_metadata_parse_signature_checked (MonoImage *image, guint32 token, MonoErro } g_assert (mono_metadata_token_table(token) == MONO_TABLE_STANDALONESIG); - + sig = mono_metadata_decode_row_col (&tables [MONO_TABLE_STANDALONESIG], idx - 1, 0); ptr = mono_metadata_blob_heap (image, sig); @@ -2963,7 +2961,7 @@ aggregate_modifiers_in_image (MonoAggregateModContainer *amods, MonoImage *image return FALSE; } -/* +/* * Structure used by the collect_..._images functions to store the image list. */ typedef struct { @@ -3083,7 +3081,7 @@ collect_aggregate_modifiers_images (MonoAggregateModContainer *amods, CollectDat for (int i = 0; i < amods->count; ++i) collect_type_images (amods->modifiers [i].type, data); } - + static void collect_type_images (MonoType *type, CollectData *data) { @@ -3255,7 +3253,7 @@ free_aggregate_modifiers (MonoAggregateModContainer *amods) /* * mono_metadata_get_inflated_signature: * - * Given an inflated signature and a generic context, return a canonical copy of the + * Given an inflated signature and a generic context, return a canonical copy of the * signature. The returned signature might be equal to SIG or it might be a cached copy. */ MonoMethodSignature * @@ -3445,7 +3443,7 @@ mono_metadata_get_canonical_aggregate_modifiers (MonoAggregateModContainer *cand { g_assert (candidate->count > 0); MonoMemoryManager *mm = mono_metadata_get_mem_manager_for_aggregate_modifiers (candidate); - + mono_mem_manager_lock (mm); if (!mm->aggregate_modifiers_cache) @@ -3470,7 +3468,7 @@ mono_metadata_get_canonical_aggregate_modifiers (MonoAggregateModContainer *cand static gboolean mono_metadata_is_type_builder_generic_type_definition (MonoClass *container_class, MonoGenericInst *inst, gboolean is_dynamic) { - MonoGenericContainer *container = mono_class_get_generic_container (container_class); + MonoGenericContainer *container = mono_class_get_generic_container (container_class); if (!is_dynamic || m_class_was_typebuilder (container_class) || container->type_argc != inst->type_argc) return FALSE; @@ -3957,7 +3955,7 @@ verify_var_type_and_container (MonoImage *image, int var_type, MonoGenericContai return TRUE; } -/* +/* * do_mono_metadata_parse_type: * @type: MonoType to be filled in with the return value * @m: image context @@ -3965,8 +3963,8 @@ verify_var_type_and_container (MonoImage *image, int var_type, MonoGenericContai * @transient: whenever to allocate data from the heap * @ptr: pointer to the encoded type * @rptr: pointer where the end of the encoded type is saved - * - * Internal routine used to "fill" the contents of @type from an + * + * Internal routine used to "fill" the contents of @type from an * allocated pointer. This is done this way to avoid doing too * many mini-allocations (particularly for the MonoFieldType which * most of the time is just a MonoType, but sometimes might be augmented). @@ -3974,7 +3972,7 @@ verify_var_type_and_container (MonoImage *image, int var_type, MonoGenericContai * This routine is used by mono_metadata_parse_type and * mono_metadata_parse_field_type * - * This extracts a Type as specified in Partition II (22.2.12) + * This extracts a Type as specified in Partition II (22.2.12) * * Returns: FALSE if the type could not be loaded */ @@ -3985,7 +3983,7 @@ do_mono_metadata_parse_type (MonoType *type, MonoImage *m, MonoGenericContainer error_init (error); type->type = (MonoTypeEnum)mono_metadata_decode_value (ptr, &ptr); - + switch (type->type){ case MONO_TYPE_VOID: case MONO_TYPE_BOOLEAN: @@ -4072,7 +4070,7 @@ do_mono_metadata_parse_type (MonoType *type, MonoImage *m, MonoGenericContainer mono_error_set_bad_image (error, m, "type 0x%02x not handled in do_mono_metadata_parse_type on image %s", type->type, m->name); return FALSE; } - + if (rptr) *rptr = ptr; return TRUE; @@ -4089,9 +4087,9 @@ mono_metadata_free_type (MonoType *type) { /* Note: keep in sync with do_mono_metadata_parse_type and try_get_canonical_type which * allocate memory or try to avoid allocating memory. */ - if (type >= builtin_types && type < builtin_types + NBUILTIN_TYPES ()) + if (type >= builtin_types && type < builtin_types + G_N_ELEMENTS (builtin_types)) return; - + switch (type->type){ case MONO_TYPE_OBJECT: case MONO_TYPE_STRING: @@ -4130,7 +4128,7 @@ hex_dump (const char *buffer, int base, int count) count = -count; show_header = 0; } - + for (i = 0; i < count; i++){ if (show_header) if ((i % 16) == 0) @@ -4142,7 +4140,7 @@ hex_dump (const char *buffer, int base, int count) } #endif -/** +/** * @ptr: Points to the beginning of the Section Data (25.3) */ static MonoExceptionClause* @@ -4154,13 +4152,13 @@ parse_section_data (MonoImage *m, int *num_clauses, const unsigned char *ptr, Mo MonoExceptionClause* clauses = NULL; error_init (error); - + while (1) { /* align on 32-bit boundary */ - ptr = dword_align (ptr); + ptr = dword_align (ptr); sect_data_flags = *ptr; ptr++; - + is_fat = sect_data_flags & METHOD_HEADER_SECTION_FAT_FORMAT; if (is_fat) { sect_data_len = (ptr [2] << 16) | (ptr [1] << 8) | ptr [0]; @@ -4574,7 +4572,7 @@ mono_method_header_get_clauses (MonoMethodHeader *header, MonoMethod *method, gp * \param ptr pointer to the field signature * \param rptr pointer updated to match the end of the decoded stream * - * Parses the field signature, and returns the type information for it. + * Parses the field signature, and returns the type information for it. * * \returns The \c MonoType that was extracted from \p ptr . */ @@ -4593,7 +4591,7 @@ mono_metadata_parse_field_type (MonoImage *m, short field_flags, const char *ptr * \param ptr pointer to the param signature * \param rptr pointer updated to match the end of the decoded stream * - * Parses the param signature, and returns the type information for it. + * Parses the param signature, and returns the type information for it. * * \returns The \c MonoType that was extracted from \p ptr . */ @@ -4656,10 +4654,10 @@ typedef struct { * ___|___ Table B * ___|___------> _______ * ___|___ _______ - * + * * A column in the rows of table A references an index in table B. * For example A may be the TYPEDEF table and B the METHODDEF table. - * + * * Given an index in table B we want to get the row in table A * where the column n references our index in B. * @@ -4702,11 +4700,11 @@ typedef_locator (const void *a, const void *b) return 1; if (col == col_next) - return 1; + return 1; } loc->result = typedef_index; - + return 0; } @@ -4717,7 +4715,7 @@ table_locator (const void *a, const void *b) const char *bb = (const char *) b; guint32 table_index = (bb - loc->t->base) / loc->t->row_size; guint32 col; - + col = mono_metadata_decode_row_col (loc->t, table_index, loc->col_idx); if (loc->idx == col) { @@ -4726,7 +4724,7 @@ table_locator (const void *a, const void *b) } if (loc->idx < col) return -1; - else + else return 1; } @@ -4753,7 +4751,7 @@ declsec_locator (const void *a, const void *b) /** * search_ptr_table: * - * Return the 1-based row index in TABLE, which must be one of the *Ptr tables, + * Return the 1-based row index in TABLE, which must be one of the *Ptr tables, * which contains IDX. */ static guint32 @@ -4820,7 +4818,7 @@ mono_metadata_typedef_from_method (MonoImage *meta, guint32 index) { MonoTableInfo *tdef = &meta->tables [MONO_TABLE_TYPEDEF]; locator_t loc; - + if (!tdef->base) return 0; @@ -4849,7 +4847,7 @@ mono_metadata_typedef_from_method (MonoImage *meta, guint32 index) * \param heap_alloc_result if TRUE the result array will be \c g_malloc'd * \param context The generic context * \param error set on error - * + * * The array of interfaces that the \p index typedef token implements is returned in * \p interfaces. The number of elements in the array is returned in \p count. * @@ -4883,7 +4881,7 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono start = loc.result; /* - * We may end up in the middle of the rows... + * We may end up in the middle of the rows... */ while (start > 0) { if (loc.idx == mono_metadata_decode_row_col (tdef, start - 1, MONO_INTERFACEIMPL_CLASS)) @@ -4908,7 +4906,7 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono pos = start; while (pos < rows) { MonoClass *iface; - + mono_metadata_decode_row (tdef, pos, cols, MONO_INTERFACEIMPL_SIZE); if (cols [MONO_INTERFACEIMPL_CLASS] != loc.idx) break; @@ -4929,7 +4927,7 @@ mono_metadata_interfaces_from_typedef_full (MonoImage *meta, guint32 index, Mono * \param meta metadata context * \param index typedef token * \param count Out parameter used to store the number of interfaces - * + * * The array of interfaces that the \p index typedef token implements is returned in * \p interfaces. The number of elements in the array is returned in \p count. The returned * array is allocated with \c g_malloc and the caller must free it. @@ -4966,7 +4964,7 @@ mono_metadata_nested_in_typedef (MonoImage *meta, guint32 index) { MonoTableInfo *tdef = &meta->tables [MONO_TABLE_NESTEDCLASS]; locator_t loc; - + if (!tdef->base) return 0; @@ -4997,7 +4995,7 @@ mono_metadata_nesting_typedef (MonoImage *meta, guint32 index, guint32 start_ind MonoTableInfo *tdef = &meta->tables [MONO_TABLE_NESTEDCLASS]; guint32 start; guint32 class_index = mono_metadata_token_index (index); - + if (!tdef->base) return 0; @@ -5033,7 +5031,7 @@ mono_metadata_packing_from_typedef (MonoImage *meta, guint32 index, guint32 *pac MonoTableInfo *tdef = &meta->tables [MONO_TABLE_CLASSLAYOUT]; locator_t loc; guint32 cols [MONO_CLASS_LAYOUT_SIZE]; - + if (!tdef->base) return 0; @@ -5042,7 +5040,7 @@ mono_metadata_packing_from_typedef (MonoImage *meta, guint32 index, guint32 *pac loc.t = tdef; /* FIXME: metadata-update */ - + if (!mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator)) return 0; @@ -5060,7 +5058,7 @@ mono_metadata_packing_from_typedef (MonoImage *meta, guint32 index, guint32 *pac * mono_metadata_custom_attrs_from_index: * \param meta metadata context * \param index token representing the parent - * \returns: the 1-based index into the \c CustomAttribute table of the first + * \returns: the 1-based index into the \c CustomAttribute table of the first * attribute which belongs to the metadata object described by \p index. * Returns 0 if no such attribute is found. */ @@ -5069,7 +5067,7 @@ mono_metadata_custom_attrs_from_index (MonoImage *meta, guint32 index) { MonoTableInfo *tdef = &meta->tables [MONO_TABLE_CUSTOMATTRIBUTE]; locator_t loc; - + if (!tdef->base) return 0; @@ -5095,7 +5093,7 @@ mono_metadata_custom_attrs_from_index (MonoImage *meta, guint32 index) * mono_metadata_declsec_from_index: * \param meta metadata context * \param index token representing the parent - * \returns the 0-based index into the \c DeclarativeSecurity table of the first + * \returns the 0-based index into the \c DeclarativeSecurity table of the first * attribute which belongs to the metadata object described by \p index. * Returns \c -1 if no such attribute is found. */ @@ -5113,7 +5111,7 @@ mono_metadata_declsec_from_index (MonoImage *meta, guint32 index) loc.t = tdef; /* FIXME: metadata-update */ - + if (!mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, declsec_locator)) return -1; @@ -5128,7 +5126,7 @@ mono_metadata_declsec_from_index (MonoImage *meta, guint32 index) * mono_metadata_localscope_from_methoddef: * @meta: metadata context * @index: methoddef index - * + * * Returns: the 1-based index into the LocalScope table of the first * scope which belongs to the method described by @index. * Returns 0 if no such row is found. @@ -5147,7 +5145,7 @@ mono_metadata_localscope_from_methoddef (MonoImage *meta, guint32 index) loc.t = tdef; /* FIXME: metadata-update */ - + if (!mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator)) return 0; @@ -5234,7 +5232,7 @@ mono_type_size (MonoType *t, int *align) case MONO_TYPE_I2: case MONO_TYPE_U2: *align = MONO_ABI_ALIGNOF (gint16); - return 2; + return 2; case MONO_TYPE_I4: case MONO_TYPE_U4: *align = MONO_ABI_ALIGNOF (gint32); @@ -5245,10 +5243,10 @@ mono_type_size (MonoType *t, int *align) case MONO_TYPE_I8: case MONO_TYPE_U8: *align = MONO_ABI_ALIGNOF (gint64); - return 8; + return 8; case MONO_TYPE_R8: *align = MONO_ABI_ALIGNOF (double); - return 8; + return 8; case MONO_TYPE_I: case MONO_TYPE_U: *align = MONO_ABI_ALIGNOF (gpointer); @@ -5368,11 +5366,11 @@ mono_type_stack_size_internal (MonoType *t, int *align, gboolean allow_open) return stack_slot_size * 3; case MONO_TYPE_R4: *align = MONO_ABI_ALIGNOF (float); - return sizeof (float); + return sizeof (float); case MONO_TYPE_I8: case MONO_TYPE_U8: *align = MONO_ABI_ALIGNOF (gint64); - return sizeof (gint64); + return sizeof (gint64); case MONO_TYPE_R8: *align = MONO_ABI_ALIGNOF (double); return sizeof (double); @@ -5507,7 +5505,7 @@ mono_metadata_str_hash (gconstpointer v1) } return hash; -} +} /** * mono_metadata_type_hash: @@ -5857,10 +5855,10 @@ signature_equiv (MonoMethodSignature *sig1, MonoMethodSignature *sig2, int equiv * That's what the `signature_only' argument of do_mono_metadata_type_equal() is for. */ - for (i = 0; i < sig1->param_count; i++) { + for (i = 0; i < sig1->param_count; i++) { MonoType *p1 = sig1->params[i]; MonoType *p2 = sig2->params[i]; - + /* if (p1->attrs != p2->attrs) return FALSE; */ @@ -5987,7 +5985,7 @@ do_metadata_type_dup_append_cmods (MonoImage *image, const MonoType *o, const Mo uint8_t total_cmods = 0; total_cmods += mono_type_custom_modifier_count (o); total_cmods += mono_type_custom_modifier_count (cmods_source); - + gboolean aggregate = TRUE; size_t sizeof_dup = mono_sizeof_type_with_mods (total_cmods, aggregate); @@ -6103,7 +6101,7 @@ void mono_metadata_encode_value (guint32 value, char *buf, char **endbuf) { char *p = buf; - + if (value < 0x80) *p++ = value; else if (value < 0x4000) { @@ -6129,27 +6127,27 @@ mono_metadata_encode_value (guint32 value, char *buf, char **endbuf) * \param rva a pointer to the RVA of the field data in the image that may have been defined in a \c FieldRVA table * \param marshal_spec a pointer to the marshal spec that may have been defined for the field in a \c FieldMarshal table. * - * Gather info for field \p index that may have been defined in the \c FieldLayout, + * Gather info for field \p index that may have been defined in the \c FieldLayout, * \c FieldRVA and \c FieldMarshal tables. - * Either of \p offset, \p rva and \p marshal_spec can be NULL if you're not interested + * Either of \p offset, \p rva and \p marshal_spec can be NULL if you're not interested * in the data. */ void -mono_metadata_field_info (MonoImage *meta, guint32 index, guint32 *offset, guint32 *rva, +mono_metadata_field_info (MonoImage *meta, guint32 index, guint32 *offset, guint32 *rva, MonoMarshalSpec **marshal_spec) { mono_metadata_field_info_full (meta, index, offset, rva, marshal_spec, FALSE); } void -mono_metadata_field_info_with_mempool (MonoImage *meta, guint32 index, guint32 *offset, guint32 *rva, +mono_metadata_field_info_with_mempool (MonoImage *meta, guint32 index, guint32 *offset, guint32 *rva, MonoMarshalSpec **marshal_spec) { mono_metadata_field_info_full (meta, index, offset, rva, marshal_spec, TRUE); } static void -mono_metadata_field_info_full (MonoImage *meta, guint32 index, guint32 *offset, guint32 *rva, +mono_metadata_field_info_full (MonoImage *meta, guint32 index, guint32 *offset, guint32 *rva, MonoMarshalSpec **marshal_spec, gboolean alloc_from_image) { MonoTableInfo *tdef; @@ -6178,7 +6176,7 @@ mono_metadata_field_info_full (MonoImage *meta, guint32 index, guint32 *offset, loc.col_idx = MONO_FIELD_RVA_FIELD; loc.t = tdef; - + if (tdef->base && mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator)) { /* * LAMESPEC: There is no signature, no nothing, just the raw data. @@ -6190,7 +6188,7 @@ mono_metadata_field_info_full (MonoImage *meta, guint32 index, guint32 *offset, } if (marshal_spec) { const char *p; - + if ((p = mono_metadata_get_marshal_info (meta, index, TRUE))) { *marshal_spec = mono_metadata_parse_marshal_spec_full (alloc_from_image ? meta : NULL, meta, p); } @@ -6264,7 +6262,7 @@ mono_metadata_events_from_typedef (MonoImage *meta, guint32 index, guint *end_id MonoTableInfo *tdef = &meta->tables [MONO_TABLE_EVENTMAP]; *end_idx = 0; - + if (!tdef->base) return 0; @@ -6276,7 +6274,7 @@ mono_metadata_events_from_typedef (MonoImage *meta, guint32 index, guint *end_id if (!mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator)) return 0; - + start = mono_metadata_decode_row_col (tdef, loc.result, MONO_EVENT_MAP_EVENTLIST); if (loc.result + 1 < table_info_get_rows (tdef)) { end = mono_metadata_decode_row_col (tdef, loc.result + 1, MONO_EVENT_MAP_EVENTLIST) - 1; @@ -6322,7 +6320,7 @@ mono_metadata_methods_from_event (MonoImage *meta, guint32 index, guint *end_i start = loc.result; /* - * We may end up in the middle of the rows... + * We may end up in the middle of the rows... */ while (start > 0) { if (loc.idx == mono_metadata_decode_row_col (msemt, start - 1, MONO_METHOD_SEMA_ASSOCIATION)) @@ -6358,7 +6356,7 @@ mono_metadata_properties_from_typedef (MonoImage *meta, guint32 index, guint *en MonoTableInfo *tdef = &meta->tables [MONO_TABLE_PROPERTYMAP]; *end_idx = 0; - + if (!tdef->base) return 0; @@ -6370,7 +6368,7 @@ mono_metadata_properties_from_typedef (MonoImage *meta, guint32 index, guint *en if (!mono_binary_search (&loc, tdef->base, table_info_get_rows (tdef), tdef->row_size, table_locator)) return 0; - + start = mono_metadata_decode_row_col (tdef, loc.result, MONO_PROPERTY_MAP_PROPERTY_LIST); if (loc.result + 1 < table_info_get_rows (tdef)) { end = mono_metadata_decode_row_col (tdef, loc.result + 1, MONO_PROPERTY_MAP_PROPERTY_LIST) - 1; @@ -6410,13 +6408,13 @@ mono_metadata_methods_from_property (MonoImage *meta, guint32 index, guint *en loc.idx = ((index + 1) << MONO_HAS_SEMANTICS_BITS) | MONO_HAS_SEMANTICS_PROPERTY; /* Method association coded index */ /* FIXME: metadata-update */ - + if (!mono_binary_search (&loc, msemt->base, table_info_get_rows (msemt), msemt->row_size, table_locator)) return 0; start = loc.result; /* - * We may end up in the middle of the rows... + * We may end up in the middle of the rows... */ while (start > 0) { if (loc.idx == mono_metadata_decode_row_col (msemt, start - 1, MONO_METHOD_SEMA_ASSOCIATION)) @@ -6562,7 +6560,7 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image res = (MonoMarshalSpec *)mono_image_alloc0 (image, sizeof (MonoMarshalSpec)); else res = g_new0 (MonoMarshalSpec, 1); - + len = mono_metadata_decode_value (ptr, &ptr); res->native = (MonoMarshalNative)*ptr++; @@ -6579,7 +6577,7 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image res->data.array_data.num_elem = mono_metadata_decode_value (ptr, &ptr); if (ptr - start <= len) { /* - * LAMESPEC: Older spec versions say this parameter comes before + * LAMESPEC: Older spec versions say this parameter comes before * num_elem. Never spec versions don't talk about elem_mult at * all, but csc still emits it, and it is used to distinguish * between param_num being 0, and param_num being omitted. @@ -6589,7 +6587,7 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image */ res->data.array_data.elem_mult = mono_metadata_decode_value (ptr, &ptr); } - } + } if (res->native == MONO_NATIVE_BYVALTSTR) { if (ptr - start <= len) @@ -6600,7 +6598,7 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image if (ptr - start <= len) res->data.array_data.num_elem = mono_metadata_decode_value (ptr, &ptr); } - + if (res->native == MONO_NATIVE_CUSTOM) { /* skip unused type guid */ len = mono_metadata_decode_value (ptr, &ptr); @@ -6610,7 +6608,7 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image ptr += len; /* read custom marshaler type name */ len = mono_metadata_decode_value (ptr, &ptr); - res->data.custom_data.custom_name = mono_image_strndup (image, ptr, len); + res->data.custom_data.custom_name = mono_image_strndup (image, ptr, len); ptr += len; /* read cookie string */ len = mono_metadata_decode_value (ptr, &ptr); @@ -6632,7 +6630,7 @@ mono_metadata_parse_marshal_spec_full (MonoImage *image, MonoImage *parent_image /** * mono_metadata_free_marshal_spec: */ -void +void mono_metadata_free_marshal_spec (MonoMarshalSpec *spec) { if (!spec) @@ -6654,7 +6652,7 @@ mono_metadata_free_marshal_spec (MonoMarshalSpec *spec) */ guint32 // FIXMEcxx MonoMarshalNative mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_field, - gboolean unicode, MonoMarshalConv *conv) + gboolean unicode, MonoMarshalConv *conv) { MonoMarshalConv dummy_conv; int t = type->type; @@ -6669,7 +6667,7 @@ mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_fiel handle_enum: switch (t) { - case MONO_TYPE_BOOLEAN: + case MONO_TYPE_BOOLEAN: if (mspec) { switch (mspec->native) { case MONO_NATIVE_VARIANTBOOL: @@ -6741,14 +6739,14 @@ mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_fiel default: g_error ("Can not marshal string to native type '%02x': Invalid managed/unmanaged type combination (String fields must be paired with LPStr, LPWStr, BStr or ByValTStr).", mspec->native); } - } + } if (unicode) { *conv = MONO_MARSHAL_CONV_STR_LPWSTR; - return MONO_NATIVE_LPWSTR; + return MONO_NATIVE_LPWSTR; } else { *conv = MONO_MARSHAL_CONV_STR_LPSTR; - return MONO_NATIVE_LPSTR; + return MONO_NATIVE_LPSTR; } case MONO_TYPE_PTR: return MONO_NATIVE_UINT; case MONO_TYPE_VALUETYPE: /*FIXME*/ @@ -6761,8 +6759,8 @@ mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_fiel return MONO_NATIVE_INT; } return MONO_NATIVE_STRUCT; - case MONO_TYPE_SZARRAY: - case MONO_TYPE_ARRAY: + case MONO_TYPE_SZARRAY: + case MONO_TYPE_ARRAY: if (mspec) { switch (mspec->native) { case MONO_NATIVE_BYVALARRAY: @@ -6774,19 +6772,19 @@ mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_fiel case MONO_NATIVE_SAFEARRAY: *conv = MONO_MARSHAL_CONV_ARRAY_SAVEARRAY; return MONO_NATIVE_SAFEARRAY; - case MONO_NATIVE_LPARRAY: + case MONO_NATIVE_LPARRAY: *conv = MONO_MARSHAL_CONV_ARRAY_LPARRAY; return MONO_NATIVE_LPARRAY; default: g_error ("cant marshal array as native type %02x", mspec->native); } - } + } *conv = MONO_MARSHAL_CONV_ARRAY_LPARRAY; return MONO_NATIVE_LPARRAY; case MONO_TYPE_I: return MONO_NATIVE_INT; case MONO_TYPE_U: return MONO_NATIVE_UINT; - case MONO_TYPE_CLASS: + case MONO_TYPE_CLASS: case MONO_TYPE_OBJECT: { /* FIXME : we need to handle ArrayList and StringBuilder here, probably */ if (mspec) { @@ -6817,7 +6815,7 @@ mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_fiel return MONO_NATIVE_IUNKNOWN; case MONO_NATIVE_FUNC: if (t == MONO_TYPE_CLASS && (type->data.klass == mono_defaults.multicastdelegate_class || - type->data.klass == mono_defaults.delegate_class || + type->data.klass == mono_defaults.delegate_class || m_class_get_parent (type->data.klass) == mono_defaults.multicastdelegate_class)) { *conv = MONO_MARSHAL_CONV_DEL_FTN; return MONO_NATIVE_FUNC; @@ -6828,7 +6826,7 @@ mono_type_to_unmanaged (MonoType *type, MonoMarshalSpec *mspec, gboolean as_fiel } } if (t == MONO_TYPE_CLASS && (type->data.klass == mono_defaults.multicastdelegate_class || - type->data.klass == mono_defaults.delegate_class || + type->data.klass == mono_defaults.delegate_class || m_class_get_parent (type->data.klass) == mono_defaults.multicastdelegate_class)) { *conv = MONO_MARSHAL_CONV_DEL_FTN; return MONO_NATIVE_FUNC; @@ -6921,7 +6919,7 @@ mono_class_get_overrides_full (MonoImage *image, guint32 type_token, MonoMethod gint32 i, num; guint32 cols [MONO_METHODIMPL_SIZE]; MonoMethod **result; - + error_init (error); *overrides = NULL; @@ -6943,7 +6941,7 @@ mono_class_get_overrides_full (MonoImage *image, guint32 type_token, MonoMethod start = loc.result; end = start + 1; /* - * We may end up in the middle of the rows... + * We may end up in the middle of the rows... */ while (start > 0) { if (loc.idx == mono_metadata_decode_row_col (tdef, start - 1, MONO_METHODIMPL_CLASS)) @@ -6996,7 +6994,7 @@ mono_class_get_overrides_full (MonoImage *image, guint32 type_token, MonoMethod char * mono_guid_to_string (const guint8 *guid) { - return g_strdup_printf ("%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", + return g_strdup_printf ("%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid[3], guid[2], guid[1], guid[0], guid[5], guid[4], guid[7], guid[6], @@ -7069,7 +7067,7 @@ get_constraints (MonoImage *image, int owner, MonoClass ***constraints, MonoGene * @image: * @token: TypeOrMethodDef token, owner for GenericParam * @owner: coded token, set on return - * + * * Returns: 1-based row-id in the GenericParam table whose * owner is @token. 0 if not found. */ @@ -7353,7 +7351,7 @@ mono_type_is_struct (MonoType *type) { return (!m_type_is_byref (type) && ((type->type == MONO_TYPE_VALUETYPE && !m_class_is_enumtype (type->data.klass)) || (type->type == MONO_TYPE_TYPEDBYREF) || - ((type->type == MONO_TYPE_GENERICINST) && + ((type->type == MONO_TYPE_GENERICINST) && mono_metadata_generic_class_is_valuetype (type->data.generic_class) && !m_class_is_enumtype (type->data.generic_class->container_class)))); } @@ -7675,7 +7673,7 @@ mono_sizeof_aggregate_modifiers (uint8_t num_mods) return accum; } -size_t +size_t mono_sizeof_type_with_mods (uint8_t num_mods, gboolean is_aggregate) { if (num_mods == 0) @@ -7693,7 +7691,7 @@ mono_sizeof_type_with_mods (uint8_t num_mods, gboolean is_aggregate) return accum; } -size_t +size_t mono_sizeof_type (const MonoType *ty) { if (ty->has_cmods) { diff --git a/src/mono/mono/metadata/mono-perfcounters.c b/src/mono/mono/metadata/mono-perfcounters.c index 316e1b340473b..d38f69a9da930 100644 --- a/src/mono/mono/metadata/mono-perfcounters.c +++ b/src/mono/mono/metadata/mono-perfcounters.c @@ -406,7 +406,7 @@ predef_cleanup (ImplVtable *vtable) { PredefVtable *vt = (PredefVtable*)vtable; /* ExternalSArea *data; */ - + perfctr_lock (); if (!pid_to_shared_area) { perfctr_unlock (); diff --git a/src/mono/mono/metadata/native-library-qcall.c b/src/mono/mono/metadata/native-library-qcall.c index 519d37daecf94..5b17173c66612 100644 --- a/src/mono/mono/metadata/native-library-qcall.c +++ b/src/mono/mono/metadata/native-library-qcall.c @@ -1,7 +1,7 @@ -#include +#include #include "mono/metadata/native-library.h" -static Entry mono_qcalls[] = +static Entry mono_qcalls[] = { DllImportEntry(NULL) // This NULL entry can be removed when a QCall is added to Mono (and added to this array) }; @@ -9,5 +9,5 @@ static Entry mono_qcalls[] = gpointer mono_lookup_pinvoke_qcall_internal (const char *name) { - return (gpointer)minipal_resolve_dllimport(mono_qcalls, lengthof(mono_qcalls), name); + return (gpointer)minipal_resolve_dllimport(mono_qcalls, G_N_ELEMENTS(mono_qcalls), name); } diff --git a/src/mono/mono/metadata/threads-types.h b/src/mono/mono/metadata/threads-types.h index 0e38b09429c6f..fe57d74a02e39 100644 --- a/src/mono/mono/metadata/threads-types.h +++ b/src/mono/mono/metadata/threads-types.h @@ -261,7 +261,7 @@ mono_thread_set_name (MonoInternalThread *thread, MonoSetThreadNameFlags flags, MonoError *error); #define mono_thread_set_name_constant_ignore_error(thread, name, flags) \ - mono_thread_set_name ((thread), name, G_N_ELEMENTS (name) - 1, \ + mono_thread_set_name ((thread), name, STRING_LENGTH (name), \ MONO_THREAD_NAME_WINDOWS_CONSTANT (name), \ (flags) | MonoSetThreadNameFlag_Constant, NULL) @@ -379,11 +379,11 @@ mono_threads_exiting (void); /* Spin lock for unaligned InterlockedXXX 64 bit functions on 32bit platforms. */ extern mono_mutex_t mono_interlocked_mutex; static inline void -mono_interlocked_lock(void) { +mono_interlocked_lock(void) { mono_os_mutex_lock (&mono_interlocked_mutex); } static inline void -mono_interlocked_unlock(void) { +mono_interlocked_unlock(void) { mono_os_mutex_unlock (&mono_interlocked_mutex); } #endif diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index ed2398c215989..a8c1188832cef 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -8,7 +8,7 @@ * Johan Lorensson (lateralusx.github@gmail.com) * * (C) 2002 Ximian, Inc. - * Copyright 2003-2011 Novell, Inc + * Copyright 2003-2011 Novell, Inc * Copyright 2011 Xamarin Inc (http://www.xamarin.com) * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ @@ -210,10 +210,10 @@ typedef struct MonoAotOptions { gboolean use_trampolines_page; gboolean no_instances; // We are collecting inflated methods and emitting non-inflated - gboolean dedup; - // The name of the assembly for which the AOT module is going to have all deduped methods moved to. + gboolean dedup; + // The name of the assembly for which the AOT module is going to have all deduped methods moved to. // When set, we are emitting inflated methods only - char *dedup_include; + char *dedup_include; gboolean gnu_asm; gboolean try_llvm; gboolean llvm; @@ -450,10 +450,10 @@ get_patch_name (int info) static int emit_aot_image (MonoAotCompile *acfg); -static void +static void mono_flush_method_cache (MonoAotCompile *acfg); -static void +static void mono_read_method_cache (MonoAotCompile *acfg); static guint32 @@ -604,40 +604,40 @@ emit_local_symbol (MonoAotCompile *acfg, const char *name, const char *end_label #else static void -emit_local_symbol (MonoAotCompile *acfg, const char *name, const char *end_label, gboolean func) -{ +emit_local_symbol (MonoAotCompile *acfg, const char *name, const char *end_label, gboolean func) +{ mono_img_writer_emit_local_symbol (acfg->w, name, end_label, func); } #endif static void -emit_label (MonoAotCompile *acfg, const char *name) -{ - mono_img_writer_emit_label (acfg->w, name); +emit_label (MonoAotCompile *acfg, const char *name) +{ + mono_img_writer_emit_label (acfg->w, name); } static void -emit_bytes (MonoAotCompile *acfg, const guint8* buf, int size) -{ - mono_img_writer_emit_bytes (acfg->w, buf, size); +emit_bytes (MonoAotCompile *acfg, const guint8* buf, int size) +{ + mono_img_writer_emit_bytes (acfg->w, buf, size); } static void -emit_string (MonoAotCompile *acfg, const char *value) -{ - mono_img_writer_emit_string (acfg->w, value); +emit_string (MonoAotCompile *acfg, const char *value) +{ + mono_img_writer_emit_string (acfg->w, value); } static void -emit_line (MonoAotCompile *acfg) -{ - mono_img_writer_emit_line (acfg->w); +emit_line (MonoAotCompile *acfg) +{ + mono_img_writer_emit_line (acfg->w); } static void emit_alignment (MonoAotCompile *acfg, int size) -{ +{ mono_img_writer_emit_alignment (acfg->w, size); } @@ -672,14 +672,14 @@ emit_padding (MonoAotCompile *acfg, int size) } static void -emit_pointer (MonoAotCompile *acfg, const char *target) -{ - mono_img_writer_emit_pointer (acfg->w, target); +emit_pointer (MonoAotCompile *acfg, const char *target) +{ + mono_img_writer_emit_pointer (acfg->w, target); } static void -emit_pointer_2 (MonoAotCompile *acfg, const char *prefix, const char *target) -{ +emit_pointer_2 (MonoAotCompile *acfg, const char *prefix, const char *target) +{ if (prefix [0] != '\0') { char *s = g_strdup_printf ("%s%s", prefix, target); mono_img_writer_emit_pointer (acfg->w, s); @@ -690,33 +690,33 @@ emit_pointer_2 (MonoAotCompile *acfg, const char *prefix, const char *target) } static void -emit_int16 (MonoAotCompile *acfg, int value) -{ - mono_img_writer_emit_int16 (acfg->w, value); +emit_int16 (MonoAotCompile *acfg, int value) +{ + mono_img_writer_emit_int16 (acfg->w, value); } static void -emit_int32 (MonoAotCompile *acfg, int value) -{ - mono_img_writer_emit_int32 (acfg->w, value); +emit_int32 (MonoAotCompile *acfg, int value) +{ + mono_img_writer_emit_int32 (acfg->w, value); } static void -emit_symbol_diff (MonoAotCompile *acfg, const char *end, const char* start, int offset) -{ - mono_img_writer_emit_symbol_diff (acfg->w, end, start, offset); +emit_symbol_diff (MonoAotCompile *acfg, const char *end, const char* start, int offset) +{ + mono_img_writer_emit_symbol_diff (acfg->w, end, start, offset); } static void -emit_zero_bytes (MonoAotCompile *acfg, int num) -{ - mono_img_writer_emit_zero_bytes (acfg->w, num); +emit_zero_bytes (MonoAotCompile *acfg, int num) +{ + mono_img_writer_emit_zero_bytes (acfg->w, num); } static void -emit_byte (MonoAotCompile *acfg, guint8 val) -{ - mono_img_writer_emit_byte (acfg->w, val); +emit_byte (MonoAotCompile *acfg, guint8 val) +{ + mono_img_writer_emit_byte (acfg->w, val); } #if defined(TARGET_WIN32) && defined(TARGET_X86) @@ -729,7 +729,7 @@ emit_global_inner (MonoAotCompile *acfg, const char *name, gboolean func) mangled_symbol_name_alloc = mangle_symbol_alloc (name); mangled_symbol_name = mangled_symbol_name_alloc; - + if (0 != g_strcasecmp (name, mangled_symbol_name)) { mono_img_writer_emit_label (acfg->w, mangled_symbol_name); } @@ -1035,7 +1035,7 @@ arch_emit_unwind_info_sections (MonoAotCompile *acfg, const char *function_start #else #define AOT_FUNC_ALIGNMENT 16 #endif - + #if defined(TARGET_POWERPC64) && !defined(MONO_ARCH_ILP32) #define PPC_LD_OP "ld" #define PPC_LDX_OP "ldx" @@ -1666,7 +1666,7 @@ arch_emit_label_address (MonoAotCompile *acfg, const char *target, gboolean exte /* * PPC32 design: - * - we use an approach similar to the x86 abi: reserve a register (r30) to hold + * - we use an approach similar to the x86 abi: reserve a register (r30) to hold * the GOT pointer. * - The full-aot trampolines need access to the GOT of mscorlib, so we store * in in the 2. slot of every GOT, and require every method to place the GOT @@ -1677,13 +1677,13 @@ arch_emit_label_address (MonoAotCompile *acfg, const char *target, gboolean exte /* * PPC64 design: * PPC64 uses function descriptors which greatly complicate all code, since - * these are used very inconsistently in the runtime. Some functions like + * these are used very inconsistently in the runtime. Some functions like * mono_compile_method () return ftn descriptors, while others like the * trampoline creation functions do not. - * We assume that all GOT slots contain function descriptors, and create + * We assume that all GOT slots contain function descriptors, and create * descriptors in aot-runtime.c when needed. * The ppc64 abi uses r2 to hold the address of the TOC/GOT, which is loaded - * from function descriptors, we could do the same, but it would require + * from function descriptors, we could do the same, but it would require * rewriting all the ppc/aot code to handle function descriptors properly. * So instead, we use the same approach as on PPC32. * This is a horrible mess, but fixing it would probably lead to an even bigger @@ -1708,7 +1708,7 @@ arch_emit_got_offset (MonoAotCompile *acfg, guint8 *code, int *code_size) { #if defined(TARGET_POWERPC64) emit_unset_mode (acfg); - /* + /* * The ppc32 code doesn't seem to work on ppc64, the assembler complains about * unsupported relocations. So we store the got address into the .Lgot_addr * symbol which is in the text segment, compute its address, and load it. @@ -2253,8 +2253,8 @@ static void arch_emit_specific_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size) { /* - * The trampolines created here are variations of the specific - * trampolines created in mono_arch_create_specific_trampoline (). The + * The trampolines created here are variations of the specific + * trampolines created in mono_arch_create_specific_trampoline (). The * differences are: * - the generic trampoline address is taken from a got slot. * - the offset of the got slot where the trampoline argument is stored @@ -2298,7 +2298,7 @@ arch_emit_specific_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size /* Emit it */ emit_bytes (acfg, buf, code - buf); - /* + /* * Only one offset is needed, since the second one would be equal to the * first one. */ @@ -2563,7 +2563,7 @@ arch_emit_static_rgctx_trampoline (MonoAotCompile *acfg, int offset, int *tramp_ #else g_assert_not_reached (); #endif -} +} /* * arch_emit_imt_trampoline: @@ -2571,8 +2571,8 @@ arch_emit_static_rgctx_trampoline (MonoAotCompile *acfg, int offset, int *tramp_ * Emit an IMT trampoline usable in full-aot mode. The trampoline uses 1 got slot which * points to an array of pointer pairs. The pairs of the form [key, ptr], where * key is the IMT key, and ptr holds the address of a memory location holding - * the address to branch to if the IMT arg matches the key. The array is - * terminated by a pair whose key is NULL, and whose ptr is the address of the + * the address to branch to if the IMT arg matches the key. The array is + * terminated by a pair whose key is NULL, and whose ptr is the address of the * fail_tramp. * TRAMP_SIZE is set to the size of the emitted trampoline. */ @@ -2705,7 +2705,7 @@ arch_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size) x86_breakpoint (code); emit_bytes (acfg, buf, code - buf); - + *tramp_size = code - buf; g_free (buf); @@ -2903,7 +2903,7 @@ arch_emit_gsharedvt_arg_trampoline (MonoAotCompile *acfg, int offset, int *tramp #else g_assert_not_reached (); #endif -} +} static void arch_emit_ftnptr_arg_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size) @@ -2987,7 +2987,7 @@ arch_emit_unbox_arbitrary_trampoline (MonoAotCompile *acfg, int offset, int *tra /* END OF ARCH SPECIFIC CODE */ static guint32 -mono_get_field_token (MonoClassField *field) +mono_get_field_token (MonoClassField *field) { MonoClass *klass = field->parent; int i; @@ -3010,7 +3010,7 @@ encode_value (gint32 value, guint8 *buf, guint8 **endbuf) //printf ("ENCODE: %d 0x%x.\n", value, value); - /* + /* * Same encoding as the one used in the metadata, extended to handle values * greater than 0x1fffffff. */ @@ -3056,14 +3056,14 @@ make_room_in_stream (MonoDynamicStream *stream, int size) { if (size <= stream->alloc_size) return; - + while (stream->alloc_size <= size) { if (stream->alloc_size < 4096) stream->alloc_size = 4096; else stream->alloc_size *= 2; } - + stream->data = (char *)g_realloc (stream->data, stream->alloc_size); } @@ -3071,7 +3071,7 @@ static guint32 add_stream_data (MonoDynamicStream *stream, const char *data, guint32 len) { guint32 idx; - + make_room_in_stream (stream, stream->index + len); memcpy (stream->data + stream->index, data, len); idx = stream->index; @@ -3449,7 +3449,7 @@ encode_klass_ref (MonoAotCompile *acfg, MonoClass *klass, guint8 *buf, guint8 ** { gboolean shared = FALSE; - /* + /* * The encoding of generic instances is large so emit them only once. */ if (mono_class_is_ginst (klass)) { @@ -3709,7 +3709,7 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8 * types of method encodings. */ - /* Mark methods which can't use aot trampolines because they need the further + /* Mark methods which can't use aot trampolines because they need the further * processing in mono_magic_trampoline () which requires a MonoMethod*. */ if ((method->is_generic && (method->flags & METHOD_ATTRIBUTE_VIRTUAL)) || @@ -3855,7 +3855,7 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8 g_assert_not_reached (); } } else if (mono_method_signature_internal (method)->is_inflated) { - /* + /* * This is a generic method, find the original token which referenced it and * encode that. * Obtain the token from information recorded by the JIT. @@ -3884,8 +3884,8 @@ encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8 declaring = ((MonoMethodInflated*)method)->declaring; /* - * This might be a non-generic method of a generic instance, which - * doesn't have a token since the reference is generated by the JIT + * This might be a non-generic method of a generic instance, which + * doesn't have a token since the reference is generated by the JIT * like Nullable:Box/Unbox, or by generic sharing. */ encode_value ((MONO_AOT_METHODREF_GINST << 24), p, &p); @@ -4043,7 +4043,7 @@ static char* get_plt_symbol (MonoAotCompile *acfg, int plt_offset, MonoJumpInfo *patch_info) { #ifdef TARGET_MACH - /* + /* * The Apple linker reorganizes object files, so it doesn't like branches to local * labels, since those have no relocations. */ @@ -4073,7 +4073,7 @@ get_plt_entry (MonoAotCompile *acfg, MonoJumpInfo *patch_info) res = (MonoPltEntry *)g_hash_table_lookup (acfg->patch_to_plt_entry [patch_info->type], patch_info); if (!acfg->llvm && patch_info->type == MONO_PATCH_INFO_METHOD && (patch_info->data.method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)) { - /* + /* * Allocate a separate PLT slot for each such patch, since some plt * entries will refer to the method itself, and some will refer to the * wrapper. @@ -4217,7 +4217,7 @@ static guint32 get_method_index (MonoAotCompile *acfg, MonoMethod *method) { int index = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_indexes, method)); - + g_assert (index); return index - 1; @@ -4623,7 +4623,7 @@ add_wrappers (MonoAotCompile *acfg) MonoMethodSignature *sig, *csig; guint32 token; - /* + /* * FIXME: Instead of AOTing all the wrappers, it might be better to redesign them * so there is only one wrapper of a given type, or inlining their contents into their * callers. @@ -4813,7 +4813,7 @@ add_wrappers (MonoAotCompile *acfg) } } - /* + /* * remoting-invoke-with-check wrappers are very frequent, so avoid emitting them, * we use the original method instead at runtime. * Since full-aot doesn't support remoting, this is not a problem. @@ -4824,7 +4824,7 @@ add_wrappers (MonoAotCompile *acfg) for (i = 0; i < rows; ++i) { ERROR_DECL (error); MonoMethodSignature *sig; - + token = MONO_TOKEN_METHOD_DEF | (i + 1); method = mono_get_method_checked (acfg->image, token, NULL, NULL, error); g_assert (is_ok (error)); /* FIXME don't swallow the error */ @@ -4844,7 +4844,7 @@ add_wrappers (MonoAotCompile *acfg) for (i = 0; i < rows; ++i) { ERROR_DECL (error); MonoClass *klass; - + token = MONO_TOKEN_TYPE_DEF | (i + 1); klass = mono_class_get_checked (acfg->image, token, error); @@ -4963,7 +4963,7 @@ add_wrappers (MonoAotCompile *acfg) for (i = 0; i < rows; ++i) { ERROR_DECL (error); MonoClass *klass; - + token = MONO_TOKEN_TYPE_SPEC | (i + 1); klass = mono_class_get_checked (acfg->image, token, error); @@ -5049,7 +5049,7 @@ add_wrappers (MonoAotCompile *acfg) } } } - + /* native-to-managed wrappers */ rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]); for (i = 0; i < rows; ++i) { @@ -5062,7 +5062,7 @@ add_wrappers (MonoAotCompile *acfg) method = mono_get_method_checked (acfg->image, token, NULL, NULL, error); report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error)); - /* + /* * Only generate native-to-managed wrappers for methods which have an * attribute named MonoPInvokeCallbackAttribute. We search for the attribute by * name to avoid defining a new assembly to contain it. @@ -5100,11 +5100,11 @@ add_wrappers (MonoAotCompile *acfg) g_assert (sig->param_count == 1); g_assert (sig->params [0]->type == MONO_TYPE_CLASS && !strcmp (m_class_get_name (mono_class_from_mono_type_internal (sig->params [0])), "Type")); - /* + /* * Decode the cattr manually since we can't create objects * during aot compilation. */ - + /* Skip prolog */ p += 2; @@ -5221,7 +5221,7 @@ MONO_RESTORE_WARNING for (i = 0; i < rows; ++i) { ERROR_DECL (error); MonoClass *klass; - + token = MONO_TOKEN_TYPE_DEF | (i + 1); klass = mono_class_get_checked (acfg->image, token, error); @@ -5495,7 +5495,7 @@ add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, const char *klass_name = m_class_get_name (klass); const char *klass_name_space = m_class_get_name_space (klass); const gboolean in_corlib = m_class_get_image (klass) == mono_defaults.corlib; - /* + /* * For ICollection, add instances of the helper methods * in Array, since a T[] could be cast to ICollection. */ @@ -5759,7 +5759,7 @@ add_generic_instances (MonoAotCompile *acfg) else type_argv [i] = inst->type_argv [i]; } - + shared_context.class_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv); g_free (type_argv); } @@ -5787,7 +5787,7 @@ add_generic_instances (MonoAotCompile *acfg) g_assert (is_ok (error)); /* FIXME don't swallow the error */ } - /* + /* * If the method is fully sharable, it was already added in place of its * generic definition. */ @@ -5896,7 +5896,7 @@ add_generic_instances (MonoAotCompile *acfg) if (klass) add_instances_of (acfg, klass, insts, ninsts, TRUE); - /* + /* * Add a managed-to-native wrapper of Array.GetGenericValue_icall, which is * used for all instances of GetGenericValue_icall by the AOT runtime. */ @@ -6077,7 +6077,7 @@ method_is_externally_callable (MonoAotCompile *acfg, MonoMethod *method) /* * is_direct_callable: * - * Return whenever the method identified by JI is directly callable without + * Return whenever the method identified by JI is directly callable without * going through the PLT. */ static gboolean @@ -6168,7 +6168,7 @@ get_pinvoke_import (MonoAotCompile *acfg, MonoMethod *method) import = g_strdup_printf ("%s", mono_metadata_string_heap (image, im_cols [MONO_IMPLMAP_NAME])); g_hash_table_insert (acfg->method_to_pinvoke_import, method, import); - + return import; } #else @@ -6383,7 +6383,7 @@ emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, gui break; case MONO_PATCH_INFO_GOT_OFFSET: { int code_size; - + arch_emit_got_offset (acfg, code + i, &code_size); i += code_size - INST_LEN; skip = TRUE; @@ -6498,7 +6498,7 @@ emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, gui /* This patch has a PLT entry, so we must emit a call to the PLT entry */ direct_call = TRUE; direct_call_target = plt_entry->symbol; - + /* Nullify the patch */ patch_info->type = MONO_PATCH_INFO_NONE; plt_entry->jit_used = TRUE; @@ -6683,14 +6683,14 @@ emit_method_code (MonoAotCompile *acfg, MonoCompile *cfg) /* Make the labels local */ emit_section_change (acfg, ".text", 0); emit_alignment_code (acfg, func_alignment); - + if (acfg->global_symbols && acfg->need_no_dead_strip) fprintf (acfg->fp, " .no_dead_strip %s\n", cfg->asm_symbol); - + emit_label (acfg, cfg->asm_symbol); if (acfg->aot_opts.write_symbols && !acfg->global_symbols && !acfg->llvm) { - /* + /* * Write a C style symbol for every method, this has two uses: * - it works on platforms where the dwarf debugging info is not * yet supported. @@ -6880,7 +6880,7 @@ encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint MonoJumpInfoRgctxEntry *entry = patch_info->data.rgctx_entry; guint32 offset; - /* + /* * entry->d.klass/method has a lenghtly encoding and multiple rgctx_fetch entries * reference the same klass/method, so encode it only once. * For patches which refer to got entries, this sharing is done by get_got_offset, but @@ -7006,7 +7006,7 @@ emit_method_info (MonoAotCompile *acfg, MonoCompile *cfg) n_patches = 0; for (pindex = 0; pindex < patches->len; ++pindex) { patch_info = (MonoJumpInfo *)g_ptr_array_index (patches, pindex); - + if ((patch_info->type == MONO_PATCH_INFO_GOT_OFFSET) || (patch_info->type == MONO_PATCH_INFO_NONE)) { patch_info->type = MONO_PATCH_INFO_NONE; @@ -7114,7 +7114,7 @@ get_unwind_info_offset (MonoAotCompile *acfg, guint8 *encoded, guint32 encoded_l guint8 buf [16]; guint8 *p; - /* + /* * It would be easier to use assembler symbols, but the caller needs an * offset now. */ @@ -7344,7 +7344,7 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg, gboolean stor } } - /* + /* * Need to encode jinfo->method too, since it is not equal to 'method' * when using generic sharing. */ @@ -7422,7 +7422,7 @@ emit_klass_info (MonoAotCompile *acfg, guint32 token) return res; } - + buf_size = 10240 + (m_class_get_vtable_size (klass) * 16); p = buf = (guint8 *)g_malloc (buf_size); @@ -7435,7 +7435,7 @@ emit_klass_info (MonoAotCompile *acfg, guint32 token) mono_class_setup_vtable (klass); - /* + /* * Emit all the information which is required for creating vtables so * the runtime does not need to create the MonoMethod structures which * take up a lot of space. @@ -7467,7 +7467,7 @@ emit_klass_info (MonoAotCompile *acfg, guint32 token) encode_method_ref (acfg, mono_class_get_cctor (klass), p, &p); if (m_class_has_finalize (klass)) encode_method_ref (acfg, mono_class_get_finalizer (klass), p, &p); - + encode_value (m_class_get_instance_size (klass), p, &p); encode_value (mono_class_data_size (klass), p, &p); encode_value (m_class_get_packing_size (klass), p, &p); @@ -7522,7 +7522,7 @@ get_plt_entry_debug_sym (MonoAotCompile *acfg, MonoJumpInfo *ji, GHashTable *cac case MONO_PATCH_INFO_ICALL_ADDR: case MONO_PATCH_INFO_ICALL_ADDR_CALL: { char *s = get_debug_sym (ji->data.method, "", cache); - + debug_sym = g_strdup_printf ("%s_icall_native_%s", prefix, s); g_free (s); break; @@ -7569,7 +7569,7 @@ emit_plt (MonoAotCompile *acfg) MonoPltEntry *plt_entry = NULL; if (i == 0) - /* + /* * The first plt entry is unused. */ continue; @@ -7617,7 +7617,7 @@ emit_plt (MonoAotCompile *acfg) /* Make sure the ARM symbols don't alias the thumb ones */ emit_zero_bytes (acfg, 16); - /* + /* * Emit a separate set of PLT entries using thumb2 which is called by LLVM generated * code. */ @@ -7712,7 +7712,7 @@ emit_trampoline_full (MonoAotCompile *acfg, MonoTrampInfo *info, gboolean emit_t sprintf (symbol, "%snamed_%s", acfg->temp_prefix, name); emit_label (acfg, symbol); - /* + /* * The code should access everything through the GOT, so we pass * TRUE here. */ @@ -7805,7 +7805,7 @@ emit_trampolines (MonoAotCompile *acfg) return; if (acfg->aot_opts.llvm_only) return; - + g_assert (acfg->image->assembly); /* Currently, we emit most trampolines into the mscorlib AOT image. */ @@ -7939,21 +7939,21 @@ emit_trampolines (MonoAotCompile *acfg) * - specific trampolines * - static rgctx invoke trampolines * - imt trampolines - * These trampolines have the same code, they are parameterized by GOT - * slots. + * These trampolines have the same code, they are parameterized by GOT + * slots. * They are defined in this file, in the arch_... routines instead of * in tramp-.c, since it is easier to do it this way. */ /* - * When running in aot-only mode, we can't create specific trampolines at - * runtime, so we create a few, and save them in the AOT file. - * Normal trampolines embed their argument as a literal inside the + * When running in aot-only mode, we can't create specific trampolines at + * runtime, so we create a few, and save them in the AOT file. + * Normal trampolines embed their argument as a literal inside the * trampoline code, we can't do that here, so instead we embed an offset * which needs to be added to the trampoline address to get the address of * the GOT slot which contains the argument value. * The generated trampolines jump to the generic trampolines using another - * GOT slot, which will be setup by the AOT loader to point to the + * GOT slot, which will be setup by the AOT loader to point to the * generic trampoline code of the given type. */ @@ -8009,7 +8009,7 @@ emit_trampolines (MonoAotCompile *acfg) tramp_got_offset += 2; break; case MONO_AOT_TRAMP_STATIC_RGCTX: - arch_emit_static_rgctx_trampoline (acfg, tramp_got_offset, &tramp_size); + arch_emit_static_rgctx_trampoline (acfg, tramp_got_offset, &tramp_size); tramp_got_offset += 2; break; case MONO_AOT_TRAMP_IMT: @@ -8017,7 +8017,7 @@ emit_trampolines (MonoAotCompile *acfg) tramp_got_offset += 1; break; case MONO_AOT_TRAMP_GSHAREDVT_ARG: - arch_emit_gsharedvt_arg_trampoline (acfg, tramp_got_offset, &tramp_size); + arch_emit_gsharedvt_arg_trampoline (acfg, tramp_got_offset, &tramp_size); tramp_got_offset += 2; break; case MONO_AOT_TRAMP_FTNPTR_ARG: @@ -8206,7 +8206,7 @@ mono_aot_split_options (const char *aot_options) // If we find a quote, then if we're in the default case then // it means we've found the start of a string, if not then it // means we've found the end of the string and should switch - // back to the default case. + // back to the default case. switch (state) { case MONO_AOT_OPTION_STATE_DEFAULT: state = MONO_AOT_OPTION_STATE_STRING; @@ -8221,8 +8221,8 @@ mono_aot_split_options (const char *aot_options) break; case '\\': // If we've found an escaping operator, then this means we - // should not process the next character if inside a string. - if (state == MONO_AOT_OPTION_STATE_STRING) + // should not process the next character if inside a string. + if (state == MONO_AOT_OPTION_STATE_STRING) state = MONO_AOT_OPTION_STATE_ESCAPE; break; case ',': @@ -8334,7 +8334,7 @@ parse_cpu_features (const gchar *attr) if (enabled) mono_cpu_features_enabled = (MonoCPUFeatures) (mono_cpu_features_enabled | feature); - else + else mono_cpu_features_disabled = (MonoCPUFeatures) (mono_cpu_features_disabled | feature); return TRUE; @@ -8371,7 +8371,7 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts) } else if (str_begins_with (arg, "full")) { opts->mode = MONO_AOT_MODE_FULL; } else if (str_begins_with (arg, "hybrid")) { - opts->mode = MONO_AOT_MODE_HYBRID; + opts->mode = MONO_AOT_MODE_HYBRID; } else if (str_begins_with (arg, "interp")) { opts->interp = TRUE; } else if (str_begins_with (arg, "threads=")) { @@ -8997,7 +8997,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method) switch (patch_info->type) { case MONO_PATCH_INFO_ABS: /* unable to handle this */ - skip = TRUE; + skip = TRUE; break; default: break; @@ -9051,8 +9051,8 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method) } /* Adds generic instances referenced by this method */ - /* - * The depth is used to avoid infinite loops when generic virtual recursion is + /* + * The depth is used to avoid infinite loops when generic virtual recursion is * encountered. */ depth = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_depth, method)); @@ -9195,7 +9195,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method) g_hash_table_insert (acfg->export_names, cfg->method, export_name); } - /* + /* * FIXME: Instead of this mess, allocate the patches from the aot mempool. */ /* Make a copy of the patch info which is in the mempool */ @@ -9233,7 +9233,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method) MonoMethodSignature *sig; MonoMethodHeader *header; int i; - + sig = mono_method_signature_internal (method); args = (MonoInst **)mono_mempool_alloc (acfg->mempool, sizeof (MonoInst*) * (sig->param_count + sig->hasthis)); for (i = 0; i < sig->param_count + sig->hasthis; ++i) { @@ -9274,7 +9274,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method) mono_atomic_inc_i32 (&acfg->stats.ccount); } - + static mono_thread_start_return_t WINAPI compile_thread_main (gpointer user_data) { @@ -9289,7 +9289,7 @@ compile_thread_main (gpointer user_data) return 0; } - + /* Used by the LLVM backend */ guint32 mono_aot_get_got_offset (MonoJumpInfo *ji) @@ -9521,11 +9521,11 @@ append_mangled_wrapper_type (GString *s, guint32 wrapper_type) } static void -append_mangled_wrapper_subtype (GString *s, WrapperSubtype subtype) +append_mangled_wrapper_subtype (GString *s, WrapperSubtype subtype) { const char *label; - switch (subtype) + switch (subtype) { case WRAPPER_SUBTYPE_NONE: return; @@ -9710,7 +9710,7 @@ static gboolean append_mangled_method (GString *s, MonoMethod *method); static gboolean -append_mangled_wrapper (GString *s, MonoMethod *method) +append_mangled_wrapper (GString *s, MonoMethod *method) { gboolean success = TRUE; gboolean append_sig = TRUE; @@ -10073,7 +10073,7 @@ execute_system (const char * command) int status = 0; #if defined (HOST_WIN32) - // We need an extra set of quotes around the whole command to properly handle commands + // We need an extra set of quotes around the whole command to properly handle commands // with spaces since internally the command is called through "cmd /c. char * quoted_command = g_strdup_printf ("\"%s\"", command); @@ -10293,7 +10293,7 @@ dedup_skip_methods (MonoAotCompile *acfg) // // In second phase, we emit methods that // are dedupable. We also emit later methods - // which are referenced by them and added later. + // which are referenced by them and added later. // For this reason, when in the dedup_include mode, // we never set skip. if (acfg->aot_opts.dedup) @@ -10339,7 +10339,7 @@ emit_code (MonoAotCompile *acfg) emit_pointer (acfg, acfg->got_symbol); #endif - /* + /* * This global symbol is used to compute the address of each method using the * code_offsets array. It is also used to compute the memory ranges occupied by * AOT code, so it must be equal to the address of the first emitted method. @@ -10348,7 +10348,7 @@ emit_code (MonoAotCompile *acfg) emit_alignment_code (acfg, 8); emit_info_symbol (acfg, "jit_code_start", TRUE); - /* + /* * Emit some padding so the local symbol for the first method doesn't have the * same address as 'methods'. */ @@ -10427,7 +10427,7 @@ emit_code (MonoAotCompile *acfg) /* To distinguish it from the next symbol */ emit_padding (acfg, 4); - /* + /* * Add .no_dead_strip directives for all LLVM methods to prevent the OSX linker * from optimizing them away, since it doesn't see that code_offsets references them. * JITted methods don't need this since they are referenced using assembler local @@ -10704,7 +10704,7 @@ mono_aot_method_hash (MonoMethod *method) if (ginst) { for (i = 0; i < ginst->type_argc; ++i) hashes [hindex ++] = mono_aot_type_hash (ginst->type_argv [i]); - } + } g_assert (hindex == hashes_count); /* Setup internal state */ @@ -10721,7 +10721,7 @@ mono_aot_method_hash (MonoMethod *method) } /* Handle the last 3 hashes (all the case statements fall through) */ - switch (hashes_count) { + switch (hashes_count) { case 3 : c += hashes [2]; case 2 : b += hashes [1]; case 1 : a += hashes [0]; @@ -10729,9 +10729,9 @@ mono_aot_method_hash (MonoMethod *method) case 0: /* nothing left to add */ break; } - + g_free (hashes_start); - + return c; } #undef rot @@ -10870,7 +10870,7 @@ emit_extra_methods (MonoAotCompile *acfg) } else { while (entry->next) entry = entry->next; - + entry->next = new_entry; new_entry->index = table->len; g_ptr_array_add (table, new_entry); @@ -10908,7 +10908,7 @@ emit_extra_methods (MonoAotCompile *acfg) g_free (buf); - /* + /* * Emit a table reverse mapping method indexes to their index in extra_method_info. * This is used by mono_aot_find_jit_info (). */ @@ -10926,7 +10926,7 @@ emit_extra_methods (MonoAotCompile *acfg) g_free (buf); g_free (info_offsets); g_ptr_array_free (table, TRUE); -} +} static void generate_aotid (guint8* aotid) @@ -10961,7 +10961,7 @@ emit_exception_info (MonoAotCompile *acfg) gboolean method_seq_points_to_file = acfg->aot_opts.gen_msym_dir && cfg->gen_seq_points && !cfg->gen_sdb_seq_points; gboolean method_seq_points_to_binary = cfg->gen_seq_points && !method_seq_points_to_file; - + emit_exception_debug_info (acfg, cfg, method_seq_points_to_binary); offsets [i] = cfg->ex_info_offset; @@ -11014,7 +11014,7 @@ emit_unwind_info (MonoAotCompile *acfg) return; } - /* + /* * The unwind info contains a lot of duplicates so we emit each unique * entry once, and only store the offset from the start of the table in the * exception info. @@ -11105,7 +11105,7 @@ emit_class_name_table (MonoAotCompile *acfg) } else { while (entry->next) entry = entry->next; - + entry->next = new_entry; new_entry->index = table->len; g_ptr_array_add (table, new_entry); @@ -11246,11 +11246,11 @@ emit_got_info (MonoAotCompile *acfg, gboolean llvm) } /** - * FIXME: + * FIXME: * - optimize offsets table. * - reduce number of exported symbols. * - emit info for a klass only once. - * - determine when a method uses a GOT slot which is guaranteed to be already + * - determine when a method uses a GOT slot which is guaranteed to be already * initialized. * - clean up and document the code. * - use String.Empty in class libs. @@ -11397,7 +11397,7 @@ emit_globals (MonoAotCompile *acfg) return; } - /* + /* * When static linking, we emit a table containing our globals. */ @@ -11425,7 +11425,7 @@ emit_globals (MonoAotCompile *acfg) } else { while (entry->next) entry = entry->next; - + entry->next = new_entry; new_entry->index = table->len; g_ptr_array_add (table, new_entry); @@ -11665,7 +11665,7 @@ emit_aot_file_info (MonoAotCompile *acfg, MonoAotFileInfo *info) emit_int32 (acfg, info->version); emit_int32 (acfg, info->dummy); - /* + /* * We emit pointers to our data structures instead of emitting global symbols which * point to them, to reduce the number of globals, and because using globals leads to * various problems (i.e. arm/thumb). @@ -12284,7 +12284,7 @@ collect_methods (MonoAotCompile *acfg) mono_error_cleanup (error); return FALSE; } - + /* Load all methods eagerly to skip the slower lazy loading code */ mono_class_setup_methods (method->klass); @@ -12374,7 +12374,7 @@ compile_methods (MonoAotCompile *acfg) len = acfg->methods->len / acfg->aot_opts.nthreads; g_assert (len > 0); - /* + /* * Partition the list of methods into fragments, and hand it to threads to * process. */ @@ -12400,7 +12400,7 @@ compile_methods (MonoAotCompile *acfg) user_data = g_new0 (gpointer, 3); user_data [0] = acfg; user_data [1] = frag; - + thread = mono_thread_create_internal ((MonoThreadStart)compile_thread_main, user_data, MONO_THREAD_CREATE_FLAGS_NONE, error); mono_error_assert_ok (error); @@ -12531,7 +12531,7 @@ compile_asm (MonoAotCompile *acfg) #endif command = g_strdup_printf ("\"%s%s\" %s %s -o %s %s", tool_prefix, AS_NAME, AS_OPTIONS, - acfg->as_args ? acfg->as_args->str : "", + acfg->as_args ? acfg->as_args->str : "", wrap_path (objfile), wrap_path (acfg->tmpfname)); aot_printf (acfg, "Executing the native assembler: %s\n", command); if (execute_system (command) != 0) { @@ -12638,8 +12638,8 @@ compile_asm (MonoAotCompile *acfg) g_free (com);*/ #if defined(TARGET_ARM) && !defined(TARGET_MACH) - /* - * gas generates 'mapping symbols' each time code and data is mixed, which + /* + * gas generates 'mapping symbols' each time code and data is mixed, which * happens a lot in emit_and_reloc_code (), so we need to get rid of them. */ command = g_strdup_printf ("\"%sstrip\" --strip-symbol=\\$a --strip-symbol=\\$d %s", tool_prefix, wrap_path(tmp_outfile_name)); @@ -13378,7 +13378,7 @@ static void aot_dump (MonoAotCompile *acfg) MonoJumpInfo *ji; if (i == 0) - /* + /* * The first plt entry is unused. */ continue; @@ -13606,7 +13606,7 @@ mono_flush_method_cache (MonoAotCompile *acfg) if (!cache) g_error ("Could not create cache at %s because of error: %s\n", filename, strerror (errno)); - + GHashTableIter iter; gchar *name = NULL; g_hash_table_iter_init (&iter, method_cache); @@ -13638,7 +13638,7 @@ mono_read_method_cache (MonoAotCompile *acfg) if (acfg->aot_opts.dedup_include || acfg->aot_opts.dedup) g_assert (acfg->dedup_stats); - + // only in skip mode if (!acfg->aot_opts.dedup) goto early_exit; @@ -13704,7 +13704,7 @@ typedef struct { } MonoAotState; static MonoAotState * -alloc_aot_state (void) +alloc_aot_state (void) { MonoAotState *state = g_malloc (sizeof (MonoAotState)); // FIXME: Should this own the memory? @@ -13717,7 +13717,7 @@ alloc_aot_state (void) } static void -free_aot_state (MonoAotState *astate) +free_aot_state (MonoAotState *astate) { g_hash_table_destroy (astate->cache); g_free (astate); @@ -13740,7 +13740,7 @@ mono_add_deferred_extra_methods (MonoAotCompile *acfg, MonoAotState *astate) } static void -mono_setup_dedup_state (MonoAotCompile *acfg, MonoAotState **global_aot_state, MonoAssembly *ass, MonoAotState **astate, gboolean *is_dedup_dummy) +mono_setup_dedup_state (MonoAotCompile *acfg, MonoAotState **global_aot_state, MonoAssembly *ass, MonoAotState **astate, gboolean *is_dedup_dummy) { if (!acfg->aot_opts.dedup_include && !acfg->aot_opts.dedup) return; @@ -13781,7 +13781,7 @@ mono_setup_dedup_state (MonoAotCompile *acfg, MonoAotState **global_aot_state, M } } -int +int mono_compile_deferred_assemblies (guint32 opts, const char *aot_options, gpointer **aot_state) { // create assembly, loop and add extra_methods @@ -13796,7 +13796,7 @@ mono_compile_deferred_assemblies (guint32 opts, const char *aot_options, gpointe const char* inflate = strstr (aot_options, "dedup-inflate"); if (!inflate) return 0; - else + else g_error ("Error: mono was not given an assembly with the provided inflate name\n"); } @@ -13920,7 +13920,7 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options, // Process later if (is_dedup_dummy && astate && !astate->emit_inflated_methods) - return 0; + return 0; if (acfg->aot_opts.dedup_include && !is_dedup_dummy) acfg->dedup_collect_only = TRUE; @@ -14350,7 +14350,7 @@ emit_aot_image (MonoAotCompile *acfg) g_assertf (temp_path, "mkdtemp failed, error = (%d) %s", errno, g_strerror (errno)); acfg->temp_dir_to_delete = g_strdup (temp_path); } - + acfg->tmpbasename = g_build_filename (temp_path, "temp", (const char*)NULL); acfg->tmpfname = g_strdup_printf ("%s.s", acfg->tmpbasename); acfg->llvm_sfile = g_strdup_printf ("%s-llvm.s", acfg->tmpbasename); @@ -14551,7 +14551,7 @@ emit_aot_image (MonoAotCompile *acfg) } acfg_free (acfg); - + return 0; } diff --git a/src/mono/mono/mini/driver.c b/src/mono/mono/mini/driver.c index 9ad3f21a12d87..a249b3d6d3678 100644 --- a/src/mono/mono/mini/driver.c +++ b/src/mono/mono/mini/driver.c @@ -240,7 +240,7 @@ typedef struct { MonoGraphOptions value; } GraphName; -static const GraphName +static const GraphName graph_names [] = { {"cfg", "Control Flow", MONO_GRAPH_CFG}, {"dtree", "Dominator Tree", MONO_GRAPH_DTREE}, @@ -324,7 +324,7 @@ opt_sets [] = { MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS | MONO_OPT_EXCEPTION | MONO_OPT_ABCREM, MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_LINEARS | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS | MONO_OPT_ABCREM, MONO_OPT_BRANCH | MONO_OPT_PEEPHOLE | MONO_OPT_COPYPROP | MONO_OPT_CONSPROP | MONO_OPT_DEADCE | MONO_OPT_LOOP | MONO_OPT_INLINE | MONO_OPT_INTRINS | MONO_OPT_EXCEPTION | MONO_OPT_CMOV, - DEFAULT_OPTIMIZATIONS, + DEFAULT_OPTIMIZATIONS, }; static const guint32 @@ -621,7 +621,7 @@ mini_regression (MonoImage *image, int verbose, int *total_run) if (opt) fprintf (mini_stats_fd, " "); fprintf (mini_stats_fd, "%s", n); - + } fprintf (mini_stats_fd, "));\n"); @@ -704,7 +704,7 @@ mini_regression_list (int verbose, int count, char *images []) { int i, total, total_run, run; MonoAssembly *ass; - + total_run = total = 0; for (i = 0; i < count; ++i) { MonoAssemblyOpenRequest req; @@ -718,13 +718,13 @@ mini_regression_list (int verbose, int count, char *images []) total_run += run; } if (total > 0){ - g_print ("Overall results: tests: %d, failed: %d, opt combinations: %d (pass: %.2f%%)\n", + g_print ("Overall results: tests: %d, failed: %d, opt combinations: %d (pass: %.2f%%)\n", total_run, total, (int)G_N_ELEMENTS (opt_sets), 100.0*(total_run-total)/total_run); } else { - g_print ("Overall results: tests: %d, 100%% pass, opt combinations: %d\n", + g_print ("Overall results: tests: %d, 100%% pass, opt combinations: %d\n", total_run, (int)G_N_ELEMENTS (opt_sets)); } - + return total; } @@ -1299,7 +1299,7 @@ compile_all_methods (MonoAssembly *ass, int verbose, guint32 opts, guint32 recom args.opts = opts; args.recompilation_times = recompilation_times; - /* + /* * Need to create a mono thread since compilation might trigger * running of managed code. */ @@ -1316,7 +1316,7 @@ compile_all_methods (MonoAssembly *ass, int verbose, guint32 opts, guint32 recom * \param argv argument vector * Start execution of a program. */ -int +int mono_jit_exec (MonoDomain *domain, MonoAssembly *assembly, int argc, char *argv[]) { int rv; @@ -1363,7 +1363,7 @@ mono_jit_exec_internal (MonoDomain *domain, MonoAssembly *assembly, int argc, ch mono_environment_exitcode_set (1); return 1; } - + if (mono_llvm_only) { MonoObject *exc = NULL; int res; @@ -1389,7 +1389,7 @@ mono_jit_exec_internal (MonoDomain *domain, MonoAssembly *assembly, int argc, ch } } -typedef struct +typedef struct { MonoDomain *domain; const char *file; @@ -1446,7 +1446,7 @@ static void main_thread_handler (gpointer user_data) exit (1); } - /* + /* * This must be done in a thread managed by mono since it can invoke * managed code. */ @@ -1461,7 +1461,7 @@ static int load_agent (MonoDomain *domain, char *desc) { ERROR_DECL (error); - char* col = strchr (desc, ':'); + char* col = strchr (desc, ':'); char *agent, *args; MonoAssembly *agent_assembly; MonoImage *image; @@ -1489,7 +1489,7 @@ load_agent (MonoDomain *domain, char *desc) return 2; } - /* + /* * Can't use mono_jit_exec (), as it sets things which might confuse the * real Main method. */ @@ -1508,7 +1508,7 @@ load_agent (MonoDomain *domain, char *desc) g_free (agent); return 1; } - + mono_thread_set_main (mono_thread_current ()); if (args) { @@ -1527,7 +1527,7 @@ load_agent (MonoDomain *domain, char *desc) g_free (agent); return 1; } - + pa [0] = main_args; /* Pass NULL as 'exc' so unhandled exceptions abort the runtime */ @@ -1547,7 +1547,7 @@ static void mini_usage_jitdeveloper (void) { int i; - + fprintf (stdout, "Runtime and JIT debugging options:\n" " --apply-bindings=FILE Apply assembly bindings from FILE (only for AOT)\n" @@ -1571,9 +1571,9 @@ mini_usage_jitdeveloper (void) "\n" "The options supported by MONO_DEBUG can also be passed on the command line.\n" "\n" - "Other options:\n" + "Other options:\n" " --graph[=TYPE] METHOD Draws a graph of the specified method:\n"); - + for (i = 0; i < G_N_ELEMENTS (graph_names); ++i) { fprintf (stdout, " %-10s %s\n", graph_names [i].name, graph_names [i].desc); } @@ -1583,7 +1583,7 @@ static void mini_usage_list_opt (void) { int i; - + for (i = 0; i < G_N_ELEMENTS (opt_names); ++i) fprintf (stdout, " %-10s %s\n", optflag_get_name (i), optflag_get_desc (i)); } @@ -1601,7 +1601,7 @@ mini_usage (void) " --debugger-agent=options Enable the debugger agent\n" " --profile[=profiler] Runs in profiling mode with the specified profiler module\n" " --trace[=EXPR] Enable tracing, use --help-trace for details\n" -#ifdef __linux__ +#ifdef __linux__ " --jitmap Output a jit method map to /tmp/perf-PID.map\n" #endif #ifdef ENABLE_JIT_DUMP @@ -1683,7 +1683,7 @@ mini_debug_usage (void) #endif static char * -mono_get_version_info (void) +mono_get_version_info (void) { GString *output; output = g_string_new (""); @@ -1790,8 +1790,8 @@ mono_jit_parse_options (int argc, char * argv[]) int mini_verbose_level = 0; guint32 opt; - /* - * Some options have no effect here, since they influence the behavior of + /* + * Some options have no effect here, since they influence the behavior of * mono_main (). */ @@ -1840,7 +1840,7 @@ mono_jit_parse_options (int argc, char * argv[]) fprintf (stderr, "Missing method name in --break command line option\n"); exit (1); } - + if (!mono_debugger_insert_breakpoint (argv [++i], FALSE)) fprintf (stderr, "Error: invalid method name '%s'\n", argv [i]); } else if (strncmp (argv[i], "--gc-params=", 12) == 0) { @@ -1867,8 +1867,8 @@ mono_jit_parse_options (int argc, char * argv[]) } if (trace_options != NULL) { - /* - * Need to call this before mini_init () so we can trace methods + /* + * Need to call this before mini_init () so we can trace methods * compiled there too. */ mono_jit_trace_calls = mono_trace_set_options (trace_options); @@ -1932,7 +1932,7 @@ static void darwin_change_default_file_handles () { struct rlimit limit; - + if (getrlimit (RLIMIT_NOFILE, &limit) == 0){ if (limit.rlim_cur < 1024){ limit.rlim_cur = MAX(1024,limit.rlim_cur); @@ -1971,7 +1971,7 @@ switch_arch (char* argv[], const char* target_arch) #endif #define MONO_HANDLERS_ARGUMENT "--handlers=" -#define MONO_HANDLERS_ARGUMENT_LEN G_N_ELEMENTS(MONO_HANDLERS_ARGUMENT)-1 +#define MONO_HANDLERS_ARGUMENT_LEN STRING_LENGTH(MONO_HANDLERS_ARGUMENT) static void apply_root_domain_configuration_file_bindings (MonoDomain *domain, char *root_domain_configuration_file) @@ -2115,7 +2115,7 @@ mono_main (int argc, char* argv[]) mono_init_jemalloc (); #endif - + g_log_set_always_fatal (G_LOG_LEVEL_ERROR); g_log_set_fatal_mask (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR); @@ -2242,7 +2242,7 @@ mono_main (int argc, char* argv[]) fprintf (stderr, "Missing method name in --break command line option\n"); return 1; } - + if (!mono_debugger_insert_breakpoint (argv [++i], FALSE)) fprintf (stderr, "Error: invalid method name '%s'\n", argv [i]); } else if (strcmp (argv [i], "--break-at-bb") == 0) { @@ -2343,7 +2343,7 @@ mono_main (int argc, char* argv[]) fprintf (stderr, "error: --compile option requires a method name argument\n"); return 1; } - + mname = argv [++i]; action = DO_BENCH; } else if (strncmp (argv [i], "--graph=", 8) == 0) { @@ -2351,7 +2351,7 @@ mono_main (int argc, char* argv[]) fprintf (stderr, "error: --graph option requires a method name argument\n"); return 1; } - + mono_graph_options = mono_parse_graph_options (argv [i] + 8); mname = argv [++i]; action = DO_DRAW; @@ -2360,7 +2360,7 @@ mono_main (int argc, char* argv[]) fprintf (stderr, "error: --graph option requires a method name argument\n"); return 1; } - + mname = argv [++i]; mono_graph_options = MONO_GRAPH_CFG; action = DO_DRAW; @@ -2538,8 +2538,8 @@ mono_main (int argc, char* argv[]) mono_set_rootdir (); if (trace_options != NULL){ - /* - * Need to call this before mini_init () so we can trace methods + /* + * Need to call this before mini_init () so we can trace methods * compiled there too. */ mono_jit_trace_calls = mono_trace_set_options (trace_options); @@ -2587,7 +2587,7 @@ mono_main (int argc, char* argv[]) g_ptr_array_free (agents, TRUE); } - + switch (action) { case DO_SINGLE_METHOD_REGRESSION: case DO_REGRESSION: @@ -2668,7 +2668,7 @@ mono_main (int argc, char* argv[]) #endif main_args.domain = domain; - main_args.file = aname; + main_args.file = aname; main_args.argc = argc - i; main_args.argv = argv + i; main_args.opts = opt; @@ -2744,7 +2744,7 @@ mono_main (int argc, char* argv[]) const char *n; double no_opt_time = 0.0; GTimer *timer = g_timer_new (); - fprintf (mini_stats_fd, "$stattitle = \'Compilations times for %s\';\n", + fprintf (mini_stats_fd, "$stattitle = \'Compilations times for %s\';\n", mono_method_full_name (method, TRUE)); fprintf (mini_stats_fd, "@data = (\n"); fprintf (mini_stats_fd, "["); @@ -2775,7 +2775,7 @@ mono_main (int argc, char* argv[]) fprintf (mini_stats_fd, "]"); if (no_opt_time > 0.0) { fprintf (mini_stats_fd, ", \n["); - for (i = 0; i < G_N_ELEMENTS (opt_sets); i++) + for (i = 0; i < G_N_ELEMENTS (opt_sets); i++) fprintf (mini_stats_fd, "%f,", no_opt_time); fprintf (mini_stats_fd, "]"); } @@ -2803,7 +2803,7 @@ mono_main (int argc, char* argv[]) /** * mono_jit_init: */ -MonoDomain * +MonoDomain * mono_jit_init (const char *file) { MonoDomain *ret = mini_init (file, NULL); @@ -2831,7 +2831,7 @@ mono_jit_init (const char *file) * \returns the \c MonoDomain representing the domain where the assembly * was loaded. */ -MonoDomain * +MonoDomain * mono_jit_init_version (const char *domain_name, const char *runtime_version) { MonoDomain *ret = mini_init (domain_name, runtime_version); @@ -2839,7 +2839,7 @@ mono_jit_init_version (const char *domain_name, const char *runtime_version) return ret; } -MonoDomain * +MonoDomain * mono_jit_init_version_for_test_only (const char *domain_name, const char *runtime_version) { MonoDomain *ret = mini_init (domain_name, runtime_version); @@ -2849,7 +2849,7 @@ mono_jit_init_version_for_test_only (const char *domain_name, const char *runtim /** * mono_jit_cleanup: */ -void +void mono_jit_cleanup (MonoDomain *domain) { MONO_STACKDATA (dummy); @@ -2956,7 +2956,7 @@ mono_jit_set_aot_mode (MonoAotMode mode) g_assert (!inited); mono_aot_mode = mode; inited = TRUE; - + mono_runtime_set_execution_mode (mode); } @@ -3018,8 +3018,8 @@ mono_set_crash_chaining (gboolean chain_crashes) /** * mono_parse_options_from: - * \param options string containing strings - * \param ref_argc pointer to the \c argc variable that might be updated + * \param options string containing strings + * \param ref_argc pointer to the \c argc variable that might be updated * \param ref_argv pointer to the \c argv string vector variable that might be updated * * This function parses the contents of the \c MONO_ENV_OPTIONS @@ -3031,7 +3031,7 @@ mono_set_crash_chaining (gboolean chain_crashes) * * The \ character can be used to escape the next character which will * be added to the current element verbatim. Typically this is used - * inside quotes. If the quotes are not balanced, this method + * inside quotes. If the quotes are not balanced, this method * * If the environment variable is empty, no changes are made * to the values pointed by \p ref_argc and \p ref_argv. @@ -3131,7 +3131,7 @@ mono_parse_options (const char *options, int *ref_argc, char **ref_argv [], gboo break; } } - if (in_quotes) + if (in_quotes) return g_strdup_printf ("Unmatched quotes in value: [%s]\n", options); if (buffer->len != 0) @@ -3214,7 +3214,7 @@ mono_parse_response_options (const char *options, int *ref_argc, char **ref_argv /** * mono_parse_env_options: - * \param ref_argc pointer to the \c argc variable that might be updated + * \param ref_argc pointer to the \c argc variable that might be updated * \param ref_argv pointer to the \c argv string vector variable that might be updated * * This function parses the contents of the \c MONO_ENV_OPTIONS @@ -3226,7 +3226,7 @@ mono_parse_response_options (const char *options, int *ref_argc, char **ref_argv * * The \ character can be used to escape the next character which will * be added to the current element verbatim. Typically this is used - * inside quotes. If the quotes are not balanced, this method + * inside quotes. If the quotes are not balanced, this method * * If the environment variable is empty, no changes are made * to the values pointed by \p ref_argc and \p ref_argv. @@ -3245,7 +3245,7 @@ void mono_parse_env_options (int *ref_argc, char **ref_argv []) { char *ret; - + char *env_options = g_getenv ("MONO_ENV_OPTIONS"); if (env_options == NULL) return; diff --git a/src/mono/mono/mini/dwarfwriter.c b/src/mono/mono/mini/dwarfwriter.c index febfef0fc416c..e18f86e7dc78c 100644 --- a/src/mono/mono/mini/dwarfwriter.c +++ b/src/mono/mono/mini/dwarfwriter.c @@ -60,7 +60,7 @@ struct _MonoDwarfWriter }; static void -emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, +emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, char *start_symbol, char *end_symbol, guint8 *code, guint32 code_size, MonoDebugMethodJitInfo *debug_info); @@ -68,7 +68,7 @@ emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, /* * mono_dwarf_writer_create: * - * Create a DWARF writer object. WRITER is the underlying image writer this + * Create a DWARF writer object. WRITER is the underlying image writer this * writer will emit to. IL_FILE is the file where IL code will be dumped to for * methods which have no line number info. It can be NULL. */ @@ -128,57 +128,57 @@ emit_pop_section (MonoDwarfWriter *w) } static void -emit_label (MonoDwarfWriter *w, const char *name) -{ - mono_img_writer_emit_label (w->w, name); +emit_label (MonoDwarfWriter *w, const char *name) +{ + mono_img_writer_emit_label (w->w, name); } static void -emit_bytes (MonoDwarfWriter *w, const guint8* buf, int size) -{ - mono_img_writer_emit_bytes (w->w, buf, size); +emit_bytes (MonoDwarfWriter *w, const guint8* buf, int size) +{ + mono_img_writer_emit_bytes (w->w, buf, size); } static void -emit_string (MonoDwarfWriter *w, const char *value) -{ - mono_img_writer_emit_string (w->w, value); +emit_string (MonoDwarfWriter *w, const char *value) +{ + mono_img_writer_emit_string (w->w, value); } static void -emit_line (MonoDwarfWriter *w) -{ - mono_img_writer_emit_line (w->w); +emit_line (MonoDwarfWriter *w) +{ + mono_img_writer_emit_line (w->w); } static void -emit_alignment (MonoDwarfWriter *w, int size) -{ - mono_img_writer_emit_alignment (w->w, size); +emit_alignment (MonoDwarfWriter *w, int size) +{ + mono_img_writer_emit_alignment (w->w, size); } static void -emit_pointer_unaligned (MonoDwarfWriter *w, const char *target) -{ - mono_img_writer_emit_pointer_unaligned (w->w, target); +emit_pointer_unaligned (MonoDwarfWriter *w, const char *target) +{ + mono_img_writer_emit_pointer_unaligned (w->w, target); } static void -emit_pointer (MonoDwarfWriter *w, const char *target) -{ - mono_img_writer_emit_pointer (w->w, target); +emit_pointer (MonoDwarfWriter *w, const char *target) +{ + mono_img_writer_emit_pointer (w->w, target); } static void -emit_int16 (MonoDwarfWriter *w, int value) -{ - mono_img_writer_emit_int16 (w->w, value); +emit_int16 (MonoDwarfWriter *w, int value) +{ + mono_img_writer_emit_int16 (w->w, value); } static void -emit_int32 (MonoDwarfWriter *w, int value) -{ - mono_img_writer_emit_int32 (w->w, value); +emit_int32 (MonoDwarfWriter *w, int value) +{ + mono_img_writer_emit_int32 (w->w, value); } static void @@ -188,15 +188,15 @@ emit_symbol (MonoDwarfWriter *w, const char *symbol) } static void -emit_symbol_diff (MonoDwarfWriter *w, const char *end, const char* start, int offset) -{ - mono_img_writer_emit_symbol_diff (w->w, end, start, offset); +emit_symbol_diff (MonoDwarfWriter *w, const char *end, const char* start, int offset) +{ + mono_img_writer_emit_symbol_diff (w->w, end, start, offset); } static void -emit_byte (MonoDwarfWriter *w, guint8 val) -{ - mono_img_writer_emit_byte (w->w, val); +emit_byte (MonoDwarfWriter *w, guint8 val) +{ + mono_img_writer_emit_byte (w->w, val); } static void @@ -415,7 +415,7 @@ emit_fde (MonoDwarfWriter *w, int fde_index, char *start_symbol, char *end_symbo l = l->next; } - /* Convert the list of MonoUnwindOps to the format used by DWARF */ + /* Convert the list of MonoUnwindOps to the format used by DWARF */ uw_info = mono_unwind_ops_encode_full (l, &uw_info_len, FALSE); emit_bytes (w, uw_info, uw_info_len); g_free (uw_info); @@ -541,7 +541,7 @@ static int variable_loclist_attr [] = { DW_AT_type, DW_FORM_ref4, DW_AT_location, DW_FORM_data4 }; - + static int inheritance_attr [] = { DW_AT_type, DW_FORM_ref4, DW_AT_data_member_location, DW_FORM_block1 @@ -664,7 +664,7 @@ emit_all_line_number_info (MonoDwarfWriter *w) MonoDebugSourceInfo *sinfo = (MonoDebugSourceInfo *)g_ptr_array_index (source_file_list, i); add_line_number_file_name (w, sinfo->source_file, 0, 0); } - } + } /* Preprocess files */ dir_to_index = g_hash_table_new (g_str_hash, g_str_equal); @@ -739,7 +739,7 @@ emit_all_line_number_info (MonoDwarfWriter *w) dir_index = GPOINTER_TO_UINT (g_hash_table_lookup (dir_to_index, dir)); basename = g_path_get_basename (name); } - + if (basename) emit_string (w, basename); else @@ -776,7 +776,7 @@ emit_all_line_number_info (MonoDwarfWriter *w) /* * Some assemblers like apple's do not support subsections, so we can't place - * .Ldebug_info_end at the end of the section using subsections. Instead, we + * .Ldebug_info_end at the end of the section using subsections. Instead, we * define it every time something gets added to the .debug_info section. * The apple assember seems to use the last definition. */ @@ -806,23 +806,23 @@ mono_dwarf_writer_emit_base_info (MonoDwarfWriter *w, const char *cu_name, GSLis emit_section_change (w, ".debug_abbrev", 0); emit_label (w, ".Ldebug_abbrev_start"); - emit_dwarf_abbrev (w, ABBREV_COMPILE_UNIT, DW_TAG_compile_unit, TRUE, + emit_dwarf_abbrev (w, ABBREV_COMPILE_UNIT, DW_TAG_compile_unit, TRUE, compile_unit_attr, G_N_ELEMENTS (compile_unit_attr)); - emit_dwarf_abbrev (w, ABBREV_SUBPROGRAM, DW_TAG_subprogram, TRUE, + emit_dwarf_abbrev (w, ABBREV_SUBPROGRAM, DW_TAG_subprogram, TRUE, subprogram_attr, G_N_ELEMENTS (subprogram_attr)); - emit_dwarf_abbrev (w, ABBREV_PARAM, DW_TAG_formal_parameter, FALSE, + emit_dwarf_abbrev (w, ABBREV_PARAM, DW_TAG_formal_parameter, FALSE, param_attr, G_N_ELEMENTS (param_attr)); - emit_dwarf_abbrev (w, ABBREV_PARAM_LOCLIST, DW_TAG_formal_parameter, FALSE, + emit_dwarf_abbrev (w, ABBREV_PARAM_LOCLIST, DW_TAG_formal_parameter, FALSE, param_loclist_attr, G_N_ELEMENTS (param_loclist_attr)); - emit_dwarf_abbrev (w, ABBREV_BASE_TYPE, DW_TAG_base_type, FALSE, + emit_dwarf_abbrev (w, ABBREV_BASE_TYPE, DW_TAG_base_type, FALSE, base_type_attr, G_N_ELEMENTS (base_type_attr)); - emit_dwarf_abbrev (w, ABBREV_STRUCT_TYPE, DW_TAG_class_type, TRUE, + emit_dwarf_abbrev (w, ABBREV_STRUCT_TYPE, DW_TAG_class_type, TRUE, struct_type_attr, G_N_ELEMENTS (struct_type_attr)); - emit_dwarf_abbrev (w, ABBREV_STRUCT_TYPE_NOCHILDREN, DW_TAG_class_type, FALSE, + emit_dwarf_abbrev (w, ABBREV_STRUCT_TYPE_NOCHILDREN, DW_TAG_class_type, FALSE, struct_type_attr, G_N_ELEMENTS (struct_type_attr)); - emit_dwarf_abbrev (w, ABBREV_DATA_MEMBER, DW_TAG_member, FALSE, + emit_dwarf_abbrev (w, ABBREV_DATA_MEMBER, DW_TAG_member, FALSE, data_member_attr, G_N_ELEMENTS (data_member_attr)); - emit_dwarf_abbrev (w, ABBREV_TYPEDEF, DW_TAG_typedef, FALSE, + emit_dwarf_abbrev (w, ABBREV_TYPEDEF, DW_TAG_typedef, FALSE, typedef_attr, G_N_ELEMENTS (typedef_attr)); emit_dwarf_abbrev (w, ABBREV_ENUM_TYPE, DW_TAG_enumeration_type, TRUE, enum_type_attr, G_N_ELEMENTS (enum_type_attr)); @@ -960,7 +960,7 @@ emit_class_dwarf_info (MonoDwarfWriter *w, MonoClass *klass, gboolean vtype) } full_name = g_strdup_printf ("%s%s%s", m_class_get_name_space (klass), m_class_get_name_space (klass) ? "." : "", m_class_get_name (klass)); - /* + /* * gdb doesn't support namespaces for non-C++ dwarf objects, so use _ * to separate components. */ @@ -1302,8 +1302,8 @@ emit_loclist (MonoDwarfWriter *w, MonoInst *ins, emit_symbol_diff (w, label, ".Ldebug_loc_start", 0); } -/* - * MonoDisHelper->tokener doesn't take an IP argument, and we can't add one since +/* + * MonoDisHelper->tokener doesn't take an IP argument, and we can't add one since * it is a public header. */ static const guint8 *token_handler_ip; @@ -1435,7 +1435,7 @@ disasm_ins (MonoMethod *method, const guchar *ip, const guint8 **endip) } static gint32 -il_offset_from_address (MonoMethod *method, MonoDebugMethodJitInfo *jit, +il_offset_from_address (MonoMethod *method, MonoDebugMethodJitInfo *jit, guint32 native_offset) { int i; @@ -1497,7 +1497,7 @@ compare_lne (MonoDebugLineNumberEntry *a, MonoDebugLineNumberEntry *b) } static void -emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, +emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, char *start_symbol, char *end_symbol, guint8 *code, guint32 code_size, MonoDebugMethodJitInfo *debug_info) @@ -1513,7 +1513,7 @@ emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, MonoDebugMethodInfo *minfo; MonoDebugLineNumberEntry *ln_array; int *native_to_il_offset = NULL; - + mono_error_assert_ok (error); /* FIXME don't swallow the error */ if (!w->emit_line) { @@ -1598,7 +1598,7 @@ emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, line_diff = (gint32)loc->row - (gint32)prev_line; addr_diff = i - prev_native_offset; - if (first) { + if (first) { emit_section_change (w, ".debug_line", 0); emit_byte (w, 0); @@ -1624,7 +1624,7 @@ emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, emit_uleb128 (w, file_index); emit_byte (w, DW_LNS_copy); w->cur_file_index = file_index; - } + } } } @@ -1704,7 +1704,7 @@ emit_line_number_info (MonoDwarfWriter *w, MonoMethod *method, continue; line = il_to_line [lne->il_offset]; if (!line) { - /* + /* * This seems to happen randomly, it looks like il_offset points * into the middle of an instruction. */ @@ -1895,7 +1895,7 @@ mono_dwarf_writer_emit_method (MonoDwarfWriter *w, MonoCompile *cfg, MonoMethod emit_byte (w, p - buf); emit_bytes (w, buf, p - buf); } - } + } g_free (names); /* Locals */ diff --git a/src/mono/mono/mini/exceptions-amd64.c b/src/mono/mono/mini/exceptions-amd64.c index 20eb44c8fbdb2..fd118ad499760 100644 --- a/src/mono/mono/mini/exceptions-amd64.c +++ b/src/mono/mono/mini/exceptions-amd64.c @@ -289,7 +289,7 @@ mono_arch_get_restore_context (MonoTrampInfo **info, gboolean aot) * mono_arch_get_call_filter: * * Returns a pointer to a method which calls an exception filter. We - * also use this function to call finally handlers (we pass NULL as + * also use this function to call finally handlers (we pass NULL as * @exc object in this case). */ gpointer @@ -374,7 +374,7 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot) } #endif /* !DISABLE_JIT */ -/* +/* * The first few arguments are dummy, to force the other arguments to be passed on * the stack, this avoids overwriting the argument registers in the throw trampoline. */ @@ -564,9 +564,9 @@ get_throw_trampoline (MonoTrampInfo **info, gboolean rethrow, gboolean corlib, g /** * mono_arch_get_throw_exception: - * \returns a function pointer which can be used to raise - * exceptions. The returned function has the following - * signature: void (*func) (MonoException *exc); + * \returns a function pointer which can be used to raise + * exceptions. The returned function has the following + * signature: void (*func) (MonoException *exc); */ gpointer mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot) @@ -574,13 +574,13 @@ mono_arch_get_throw_exception (MonoTrampInfo **info, gboolean aot) return get_throw_trampoline (info, FALSE, FALSE, FALSE, FALSE, "throw_exception", aot, FALSE); } -gpointer +gpointer mono_arch_get_rethrow_exception (MonoTrampInfo **info, gboolean aot) { return get_throw_trampoline (info, TRUE, FALSE, FALSE, FALSE, "rethrow_exception", aot, FALSE); } -gpointer +gpointer mono_arch_get_rethrow_preserve_exception (MonoTrampInfo **info, gboolean aot) { return get_throw_trampoline (info, TRUE, FALSE, FALSE, FALSE, "rethrow_preserve_exception", aot, TRUE); @@ -589,14 +589,14 @@ mono_arch_get_rethrow_preserve_exception (MonoTrampInfo **info, gboolean aot) /** * mono_arch_get_throw_corlib_exception: * - * Returns a function pointer which can be used to raise - * corlib exceptions. The returned function has the following - * signature: void (*func) (guint32 ex_token, guint32 offset); - * Here, offset is the offset which needs to be substracted from the caller IP - * to get the IP of the throw. Passing the offset has the advantage that it + * Returns a function pointer which can be used to raise + * corlib exceptions. The returned function has the following + * signature: void (*func) (guint32 ex_token, guint32 offset); + * Here, offset is the offset which needs to be substracted from the caller IP + * to get the IP of the throw. Passing the offset has the advantage that it * needs no relocations in the caller. */ -gpointer +gpointer mono_arch_get_throw_corlib_exception (MonoTrampInfo **info, gboolean aot) { return get_throw_trampoline (info, FALSE, TRUE, FALSE, FALSE, "throw_corlib_exception", aot, FALSE); @@ -650,7 +650,7 @@ mono_arch_unwind_frame (MonoJitTlsData *jit_tls, /* LLVM compiled code doesn't have this info */ if (ji->has_arch_eh_info) epilog = (guint8*)ji->code_start + ji->code_size - mono_jinfo_get_epilog_size (ji); - + for (i = 0; i < AMD64_NREG; ++i) regs [i] = new_ctx->gregs [i]; @@ -664,7 +664,7 @@ mono_arch_unwind_frame (MonoJitTlsData *jit_tls, for (i = 0; i < AMD64_NREG; ++i) new_ctx->gregs [i] = regs [i]; - + /* The CFA becomes the new SP value */ new_ctx->gregs [AMD64_RSP] = (host_mgreg_t)(gsize)cfa; @@ -685,8 +685,8 @@ mono_arch_unwind_frame (MonoJitTlsData *jit_tls, /* Top LMF entry */ return FALSE; } else { - /* - * The rsp field is set just before the call which transitioned to native + /* + * The rsp field is set just before the call which transitioned to native * code. Obtain the rip from the stack. */ rip = *(guint64*)((*lmf)->rsp - sizeof(host_mgreg_t)); @@ -826,7 +826,7 @@ mono_arch_ip_from_context (void *sigctx) #else MonoContext *ctx = (MonoContext*)sigctx; return (gpointer)ctx->gregs [AMD64_RIP]; -#endif +#endif } static MonoObject* @@ -844,7 +844,7 @@ restore_soft_guard_pages (void) return NULL; } -/* +/* * this function modifies mctx so that when it is restored, it * won't execcute starting at mctx.eip, but in a function that * will restore the protection on the soft-guard pages and return back to @@ -1908,7 +1908,7 @@ void mono_arch_code_chunk_destroy (void *chunk) void mono_arch_setup_resume_sighandler_ctx (MonoContext *ctx, gpointer func) { - /* + /* * When resuming from a signal handler, the stack should be misaligned, just like right after * a call. */ diff --git a/src/mono/mono/mini/image-writer.c b/src/mono/mono/mini/image-writer.c index cc81ac7b070dc..436d2b316635f 100644 --- a/src/mono/mono/mini/image-writer.c +++ b/src/mono/mono/mini/image-writer.c @@ -29,7 +29,7 @@ #include "mini.h" -/* +/* * The used assembler dialect * TARGET_ASM_APPLE == apple assembler on OSX * TARGET_ASM_GAS == GNU assembler @@ -318,7 +318,7 @@ asm_writer_emit_line (MonoImageWriter *acfg) fprintf (acfg->fp, "\n"); } -static void +static void asm_writer_emit_alignment (MonoImageWriter *acfg, int size) { asm_writer_emit_unset_mode (acfg); @@ -336,7 +336,7 @@ asm_writer_emit_alignment (MonoImageWriter *acfg, int size) #endif } -static void +static void asm_writer_emit_alignment_fill (MonoImageWriter *acfg, int size, int fill) { asm_writer_emit_unset_mode (acfg); @@ -646,7 +646,7 @@ mono_img_writer_emit_byte (MonoImageWriter *acfg, guint8 val) mono_img_writer_emit_bytes (acfg, &val, 1); } -/* +/* * Emit a relocation entry of type RELOC_TYPE against symbol SYMBOL at the current PC. * Do not advance PC. */ diff --git a/src/mono/mono/mini/jit-icalls.c b/src/mono/mono/mini/jit-icalls.c index 98290fde4e160..a0078c4565698 100644 --- a/src/mono/mono/mini/jit-icalls.c +++ b/src/mono/mono/mini/jit-icalls.c @@ -125,13 +125,13 @@ ldvirtfn_internal (MonoObject *obj, MonoMethod *method, gboolean gshared) } void* -mono_ldvirtfn (MonoObject *obj, MonoMethod *method) +mono_ldvirtfn (MonoObject *obj, MonoMethod *method) { return ldvirtfn_internal (obj, method, FALSE); } void* -mono_ldvirtfn_gshared (MonoObject *obj, MonoMethod *method) +mono_ldvirtfn_gshared (MonoObject *obj, MonoMethod *method) { return ldvirtfn_internal (obj, method, TRUE); } @@ -155,19 +155,19 @@ mono_helper_stelem_ref_check (MonoArray *array, MonoObject *val) #if !defined(MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS) || defined(MONO_ARCH_EMULATE_LONG_MUL_OVF_OPTS) -gint64 +gint64 mono_llmult (gint64 a, gint64 b) { return a * b; } -guint64 +guint64 mono_llmult_ovf_un (guint64 a, guint64 b) { guint32 al = a; guint32 ah = a >> 32; guint32 bl = b; - guint32 bh = b >> 32; + guint32 bh = b >> 32; guint64 res, t1; // fixme: this is incredible slow @@ -182,7 +182,7 @@ mono_llmult_ovf_un (guint64 a, guint64 b) if (t1 > 0xffffffff) goto raise_exception; - res += ((guint64)t1) << 32; + res += ((guint64)t1) << 32; return res; @@ -195,13 +195,13 @@ mono_llmult_ovf_un (guint64 a, guint64 b) return 0; } -guint64 -mono_llmult_ovf (gint64 a, gint64 b) +guint64 +mono_llmult_ovf (gint64 a, gint64 b) { guint32 al = a; gint32 ah = a >> 32; guint32 bl = b; - gint32 bh = b >> 32; + gint32 bh = b >> 32; /* Use Karatsuba algorithm where: a*b is: AhBh(R^2+R)+(Ah-Al)(Bl-Bh)R+AlBl(R+1) @@ -214,7 +214,7 @@ mono_llmult_ovf (gint64 a, gint64 b) result, ah and/or bh must be 0. This will save us from doing the AhBh term at all. - Also note that we refactor so that we don't overflow 64 bits with + Also note that we refactor so that we don't overflow 64 bits with intermediate results. So we use [(Ah-Al)(Bl-Bh)+AlBl]R+AlBl */ @@ -267,9 +267,9 @@ mono_llmult_ovf (gint64 a, gint64 b) bl +=1; } } - - /* we overflow for sure if both upper halves are greater - than zero because we would need to shift their + + /* we overflow for sure if both upper halves are greater + than zero because we would need to shift their product 64 bits to the left and that will not fit in a 64 bit result */ if (ah && bh) @@ -308,7 +308,7 @@ mono_llmult_ovf (gint64 a, gint64 b) return 0; } -gint64 +gint64 mono_lldiv (gint64 a, gint64 b) { #ifdef MONO_ARCH_NEED_DIV_CHECK @@ -328,7 +328,7 @@ mono_lldiv (gint64 a, gint64 b) return a / b; } -gint64 +gint64 mono_llrem (gint64 a, gint64 b) { #ifdef MONO_ARCH_NEED_DIV_CHECK @@ -348,7 +348,7 @@ mono_llrem (gint64 a, gint64 b) return a % b; } -guint64 +guint64 mono_lldiv_un (guint64 a, guint64 b) { #ifdef MONO_ARCH_NEED_DIV_CHECK @@ -362,7 +362,7 @@ mono_lldiv_un (guint64 a, guint64 b) return a / b; } -guint64 +guint64 mono_llrem_un (guint64 a, guint64 b) { #ifdef MONO_ARCH_NEED_DIV_CHECK @@ -380,7 +380,7 @@ mono_llrem_un (guint64 a, guint64 b) #ifndef MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS -guint64 +guint64 mono_lshl (guint64 a, gint32 shamt) { const guint64 res = a << (shamt & 0x7f); @@ -390,7 +390,7 @@ mono_lshl (guint64 a, gint32 shamt) return res; } -guint64 +guint64 mono_lshr_un (guint64 a, gint32 shamt) { const guint64 res = a >> (shamt & 0x7f); @@ -400,7 +400,7 @@ mono_lshr_un (guint64 a, gint32 shamt) return res; } -gint64 +gint64 mono_lshr (gint64 a, gint32 shamt) { const gint64 res = a >> (shamt & 0x7f); @@ -977,10 +977,10 @@ mono_fconv_ovf_u8 (double v) * The soft-float implementation of some ARM devices have a buggy guin64 to double * conversion that it looses precision even when the integer if fully representable * as a double. - * + * * This was found with 4294967295ull, converting to double and back looses one bit of precision. - * - * To work around this issue we test for value boundaries instead. + * + * To work around this issue we test for value boundaries instead. */ #if defined(__arm__) && defined(MONO_ARCH_SOFT_FLOAT_FALLBACK) if (mono_isnan (v) || !(v >= -0.5 && v <= ULLONG_MAX+0.5)) { diff --git a/src/mono/mono/mini/linear-scan.c b/src/mono/mono/mini/linear-scan.c index 15ec1680582fa..f3679d3b1de7c 100644 --- a/src/mono/mono/mini/linear-scan.c +++ b/src/mono/mono/mini/linear-scan.c @@ -26,12 +26,12 @@ mono_varlist_insert_sorted (MonoCompile *cfg, GList *list, MonoMethodVar *mv, in for (l = list; l; l = l->next) { MonoMethodVar *v1 = (MonoMethodVar *)l->data; - + if (sort_type == 2) { if (mv->spill_costs >= v1->spill_costs) { list = g_list_insert_before (list, l, mv); break; - } + } } else if (sort_type == 1) { if (mv->range.last_use.abs_pos <= v1->range.last_use.abs_pos) { list = g_list_insert_before (list, l, mv); @@ -50,7 +50,7 @@ mono_varlist_insert_sorted (MonoCompile *cfg, GList *list, MonoMethodVar *mv, in return list; } -static gint +static gint compare_by_first_use_func (gconstpointer a, gconstpointer b) { MonoMethodVar *v1 = (MonoMethodVar*)a; @@ -98,7 +98,7 @@ mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_ma #ifdef DEBUG_LSCAN for (l = vars; l; l = l->next) { vmv = l->data; - printf ("VAR %d %08x %08x C%d\n", vmv->idx, vmv->range.first_use.abs_pos, + printf ("VAR %d %08x %08x C%d\n", vmv->idx, vmv->range.first_use.abs_pos, vmv->range.last_use.abs_pos, vmv->spill_costs); } #endif @@ -115,7 +115,7 @@ mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_ma vmv = (MonoMethodVar *)l->data; #ifdef DEBUG_LSCAN - printf ("START %2d %08x %08x\n", vmv->idx, vmv->range.first_use.abs_pos, + printf ("START %2d %08x %08x\n", vmv->idx, vmv->range.first_use.abs_pos, vmv->range.last_use.abs_pos); #endif /* expire old intervals in active */ @@ -127,7 +127,7 @@ mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_ma break; #ifdef DEBUG_LSCAN - printf ("EXPIR %2d %08x %08x C%d R%d\n", amv->idx, amv->range.first_use.abs_pos, + printf ("EXPIR %2d %08x %08x C%d R%d\n", amv->idx, amv->range.first_use.abs_pos, amv->range.last_use.abs_pos, amv->spill_costs, amv->reg); #endif active = g_list_delete_link (active, active); @@ -142,25 +142,25 @@ mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_ma a = g_list_nth (active, max_regs - 1); amv = (MonoMethodVar *)a->data; - if ((cost_driven && amv->spill_costs < vmv->spill_costs) || + if ((cost_driven && amv->spill_costs < vmv->spill_costs) || (!cost_driven && amv->range.last_use.abs_pos > vmv->range.last_use.abs_pos)) { vmv->reg = amv->reg; amv->reg = -1; active = g_list_delete_link (active, a); if (cost_driven) - active = mono_varlist_insert_sorted (cfg, active, vmv, 2); + active = mono_varlist_insert_sorted (cfg, active, vmv, 2); else - active = mono_varlist_insert_sorted (cfg, active, vmv, 1); + active = mono_varlist_insert_sorted (cfg, active, vmv, 1); #ifdef DEBUG_LSCAN - printf ("SPILL0 %2d %08x %08x C%d\n", amv->idx, + printf ("SPILL0 %2d %08x %08x C%d\n", amv->idx, amv->range.first_use.abs_pos, amv->range.last_use.abs_pos, amv->spill_costs); #endif } else { #ifdef DEBUG_LSCAN - printf ("SPILL1 %2d %08x %08x C%d\n", vmv->idx, + printf ("SPILL1 %2d %08x %08x C%d\n", vmv->idx, vmv->range.first_use.abs_pos, vmv->range.last_use.abs_pos, vmv->spill_costs); #endif @@ -178,33 +178,33 @@ mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_ma regs = g_list_delete_link (regs, regs); #ifdef DEBUG_LSCAN - printf ("ADD %2d %08x %08x C%d R%d\n", vmv->idx, - vmv->range.first_use.abs_pos, vmv->range.last_use.abs_pos, + printf ("ADD %2d %08x %08x C%d R%d\n", vmv->idx, + vmv->range.first_use.abs_pos, vmv->range.last_use.abs_pos, vmv->spill_costs, vmv->reg); #endif - active = mono_varlist_insert_sorted (cfg, active, vmv, TRUE); + active = mono_varlist_insert_sorted (cfg, active, vmv, TRUE); } #ifdef DEBUG_LSCAN for (a = active; a; a = a->next) { - amv = (MonoMethodVar *)a->data; - printf ("ACT %2d %08x %08x C%d R%d\n", amv->idx, amv->range.first_use.abs_pos, + amv = (MonoMethodVar *)a->data; + printf ("ACT %2d %08x %08x C%d R%d\n", amv->idx, amv->range.first_use.abs_pos, amv->range.last_use.abs_pos, amv->spill_costs, amv->reg); } printf ("NEXT\n"); #endif - } + } for (a = active; a; a = a->next) { - amv = (MonoMethodVar *)a->data; + amv = (MonoMethodVar *)a->data; gains [amv->reg] += amv->spill_costs; } n_regvars = 0; for (l = vars; l; l = l->next) { vmv = (MonoMethodVar *)l->data; - + if (vmv->reg >= 0) { if ((gains [vmv->reg] > mono_arch_regalloc_cost (cfg, vmv)) && (cfg->varinfo [vmv->idx]->opcode != OP_REGVAR)) { if (cfg->verbose_level > 2) { @@ -232,7 +232,7 @@ mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_ma used_regs = 0; for (l = vars; l; l = l->next) { vmv = (MonoMethodVar *)l->data; - + if (vmv->reg >= 0) used_regs |= 1LL << vmv->reg; } @@ -293,7 +293,7 @@ mono_linear_scan2 (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_m for (l = vars; l; l = l->next) { vmv = (MonoMethodVar *)l->data; - LSCAN_DEBUG (printf ("VAR R%d %08x %08x C%d\n", cfg->varinfo [vmv->idx]->dreg, vmv->range.first_use.abs_pos, + LSCAN_DEBUG (printf ("VAR R%d %08x %08x C%d\n", cfg->varinfo [vmv->idx]->dreg, vmv->range.first_use.abs_pos, vmv->range.last_use.abs_pos, vmv->spill_costs)); } @@ -318,7 +318,7 @@ mono_linear_scan2 (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_m if (!current->interval->range) continue; - + pos = current->interval->range->from; /* Check for intervals in active which expired or inactive */ @@ -414,7 +414,7 @@ mono_linear_scan2 (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_m gains [current->reg] += current->spill_costs; } else { - /* + /* * free_pos [reg] > 0 means there is a register available for parts * of the interval, so splitting it is possible. This is not yet * supported, so we spill in this case too. @@ -427,7 +427,7 @@ mono_linear_scan2 (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_m if (active) { GList *min_spill_pos; #if 0 - /* + /* * This favors registers with big spill costs, thus larger liveness ranges, * thus actually leading to worse code size. */ @@ -503,7 +503,7 @@ mono_linear_scan2 (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_m used_regs = 0; for (l = vars; l; l = l->next) { vmv = (MonoMethodVar *)l->data; - + if (vmv->reg >= 0) used_regs |= 1LL << vmv->reg; } diff --git a/src/mono/mono/mini/mini-amd64.h b/src/mono/mono/mini/mini-amd64.h index 2c3e8a009beac..5528a7b03039f 100644 --- a/src/mono/mono/mini/mini-amd64.h +++ b/src/mono/mono/mini/mini-amd64.h @@ -176,12 +176,12 @@ struct sigcontext { #define MONO_ARCH_FRAME_ALIGNMENT 16 -/* fixme: align to 16byte instead of 32byte (we align to 32byte to get +/* fixme: align to 16byte instead of 32byte (we align to 32byte to get * reproduceable results for benchmarks */ #define MONO_ARCH_CODE_ALIGNMENT 32 struct MonoLMF { - /* + /* * The rsp field points to the stack location where the caller ip is saved. * If the second lowest bit is set, then this is a MonoLMFExt structure, and * the other fields are not valid. @@ -364,7 +364,7 @@ typedef struct { #else -/* +/* * __builtin_frame_address () is broken on some older gcc versions in the presence of * frame pointer elimination, see bug #82095. */ @@ -500,7 +500,7 @@ typedef struct { // can pass context to generics or interfaces? #define MONO_ARCH_HAVE_VOLATILE_NON_PARAM_REGISTER 1 -void +void mono_amd64_patch (unsigned char* code, gpointer target); void @@ -644,5 +644,5 @@ mono_arch_unwindinfo_validate_size (GSList *unwind_ops, guint max_size) CallInfo* mono_arch_get_call_info (MonoMemPool *mp, MonoMethodSignature *sig); -#endif /* __MONO_MINI_AMD64_H__ */ +#endif /* __MONO_MINI_AMD64_H__ */ diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 2b8e07dfb3745..84573c71d9c30 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -125,7 +125,7 @@ typedef struct { LLVMBasicBlockRef bblock, end_bblock; LLVMValueRef finally_ind; gboolean added, invoke_target; - /* + /* * If this bblock is the start of a finally clause, this is a list of bblocks it * needs to branch to in ENDFINALLY. */ @@ -780,7 +780,7 @@ type_to_llvm_type (EmitContext *ctx, MonoType *t) case MONO_TYPE_U4: return LLVMPointerType (type_to_llvm_type (ctx, ptr_type), 0); } - + return ObjRefType (); } case MONO_TYPE_VAR: @@ -869,7 +869,7 @@ type_to_llvm_arg_type (EmitContext *ctx, MonoType *t) */ #ifndef TARGET_ARM64 if (ptype == LLVMInt8Type () || ptype == LLVMInt16Type ()) { - /* + /* * LLVM generates code which only sets the lower bits, while JITted * code expects all the bits to be set. */ @@ -904,7 +904,7 @@ llvm_type_to_stack_type (MonoCompile *cfg, LLVMTypeRef type) /* * regtype_to_llvm_type: * - * Return the LLVM type corresponding to the regtype C used in instruction + * Return the LLVM type corresponding to the regtype C used in instruction * descriptions. */ static LLVMTypeRef @@ -999,7 +999,7 @@ op_to_llvm_type (int opcode) g_assert_not_reached (); return NULL; } -} +} #define CLAUSE_START(clause) ((clause)->try_offset) #define CLAUSE_END(clause) (((clause))->try_offset + ((clause))->try_len) @@ -1267,7 +1267,7 @@ get_bb (EmitContext *ctx, MonoBasicBlock *bb) return ctx->bblocks [bb->block_num].bblock; } -/* +/* * get_end_bb: * * Return the last LLVM bblock corresponding to BB. @@ -1415,8 +1415,8 @@ emit_volatile_load (EmitContext *ctx, int vreg) v = mono_llvm_build_load (ctx->builder, ctx->addresses [vreg], "", TRUE); t = ctx->vreg_cli_types [vreg]; if (t && !m_type_is_byref (t)) { - /* - * Might have to zero extend since llvm doesn't have + /* + * Might have to zero extend since llvm doesn't have * unsigned types. */ if (t->type == MONO_TYPE_U1 || t->type == MONO_TYPE_U2 || t->type == MONO_TYPE_CHAR || t->type == MONO_TYPE_BOOLEAN) @@ -1618,7 +1618,7 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo * } cinfo->vret_arg_pindex = vret_arg_pindex; - } + } if (vretaddr && vret_arg_pindex == pindex) param_types [pindex ++] = IntPtrType (); @@ -1744,7 +1744,7 @@ LLVMFunctionType0 (LLVMTypeRef ReturnType, * * Create an LLVM function type from the arguments. */ -static G_GNUC_UNUSED LLVMTypeRef +static G_GNUC_UNUSED LLVMTypeRef LLVMFunctionType1 (LLVMTypeRef ReturnType, LLVMTypeRef ParamType1, int IsVarArg) @@ -2001,7 +2001,7 @@ get_aotconst (EmitContext *ctx, MonoJumpInfoType type, gconstpointer data, LLVMT ji->next = cfg->patch_info; cfg->patch_info = ji; - /* + /* * If the got slot is shared, it means its initialized when the aot image is loaded, so we don't need to * explicitly initialize it. */ @@ -2267,7 +2267,7 @@ get_handler_clause (MonoCompile *cfg, MonoBasicBlock *bb) /* Indirectly */ for (i = 0; i < header->num_clauses; ++i) { clause = &header->clauses [i]; - + if (MONO_OFFSET_IN_CLAUSE (clause, bb->real_offset) && clause->flags == MONO_EXCEPTION_CLAUSE_NONE) return i; } @@ -2291,7 +2291,7 @@ get_most_deep_clause (MonoCompile *cfg, EmitContext *ctx, MonoBasicBlock *bb) return NULL; } - + static void set_metadata_flag (LLVMValueRef v, const char *flag_name) { @@ -2421,7 +2421,7 @@ emit_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, LL ctx->bblocks [bb->block_num].end_bblock = noex_bb; } } - + if (!lcall) { lcall = LLVMBuildCall (builder, callee, args, pindex, ""); ctx->builder = builder; @@ -2438,7 +2438,7 @@ emit_load (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, in { LLVMValueRef res; - /* + /* * We emit volatile loads for loads which can fault, because otherwise * LLVM will generate invalid code when encountering a load from a * NULL address. @@ -2491,7 +2491,7 @@ emit_cond_system_exception (EmitContext *ctx, MonoBasicBlock *bb, const char *ex if (!exc_classes [exc_id]) exc_classes [exc_id] = mono_class_load_from_name (mono_get_corlib (), "System", exc_type); exc_class = exc_classes [exc_id]; - + ex_bb = gen_bb (ctx, "EX_BB"); if (ctx->llvm_only) ex2_bb = gen_bb (ctx, "EX2_BB"); @@ -2563,7 +2563,7 @@ emit_cond_system_exception (EmitContext *ctx, MonoBasicBlock *bb, const char *ex callee = get_jit_callee (ctx, "llvm_throw_corlib_exception_trampoline", sig, MONO_PATCH_INFO_JIT_ICALL_ID, GUINT_TO_POINTER (icall_id)); /* - * Make sure that ex_bb starts with the invoke, so the block address points to it, and not to the load + * Make sure that ex_bb starts with the invoke, so the block address points to it, and not to the load * added by get_jit_callee (). */ ex2_bb = gen_bb (ctx, "EX2_BB"); @@ -2827,7 +2827,7 @@ emit_llvm_used (MonoLLVMModule *module) LLVMTypeRef used_type; LLVMValueRef used, *used_elem; int i; - + if (!module->used) return; @@ -4291,7 +4291,7 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref, } } - /* + /* * Collect and convert arguments */ nargs = (sig->param_count * 16) + sig->hasthis + vretaddr + call->rgctx_reg + call->imt_arg_reg + call->cinfo->dummy_arg + 1; @@ -4622,7 +4622,7 @@ emit_throw (EmitContext *ctx, MonoBasicBlock *bb, gboolean rethrow, LLVMValueRef callee = get_callee (ctx, sig_to_llvm_sig (ctx, throw_sig), MONO_PATCH_INFO_JIT_ICALL_ID, GUINT_TO_POINTER (icall_id)); } else { #ifdef TARGET_X86 - /* + /* * LLVM doesn't push the exception argument, so we need a different * trampoline. */ @@ -5678,7 +5678,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) has_terminator = TRUE; g_assert (!ins->next); - + break; } @@ -5976,12 +5976,12 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_FMOVE: case OP_RMOVE: { MonoInst *var = get_vreg_to_inst (cfg, ins->dreg); - + g_assert (lhs); values [ins->dreg] = lhs; if (var && m_class_get_byval_arg (var->klass)->type == MONO_TYPE_R4) { - /* + /* * This is added by the spilling pass in case of the JIT, * but we have to do it ourselves. */ @@ -6452,7 +6452,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) } case OP_LOCALLOC: { LLVMValueRef v, size; - + size = LLVMBuildAnd (builder, LLVMBuildAdd (builder, convert (ctx, lhs, LLVMInt32Type ()), LLVMConstInt (LLVMInt32Type (), MONO_ARCH_FRAME_ALIGNMENT - 1, FALSE), ""), LLVMConstInt (LLVMInt32Type (), ~ (MONO_ARCH_FRAME_ALIGNMENT - 1), FALSE), ""); v = mono_llvm_build_alloca (builder, LLVMInt8Type (), size, MONO_ARCH_FRAME_ALIGNMENT, ""); @@ -6688,7 +6688,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) /* Might have instructions after this */ while (ins->next) { MonoInst *next = ins->next; - /* + /* * FIXME: If later code uses the regs defined by these instructions, * compilation will fail. */ @@ -6696,7 +6696,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) if (spec [MONO_INST_DEST] == 'i' && !MONO_IS_STORE_MEMBASE (next)) ctx->values [next->dreg] = LLVMConstNull (LLVMInt32Type ()); MONO_DELETE_INS (bb, next); - } + } break; case OP_LDADDR: { MonoInst *var = ins->inst_i0; @@ -6851,7 +6851,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) args [0] = convert (ctx, values [ins->sreg1], LLVMDoubleType ()); args [1] = convert (ctx, values [ins->sreg2], LLVMDoubleType ()); args [2] = convert (ctx, values [ins->sreg3], LLVMDoubleType ()); - + values [ins->dreg] = call_intrins (ctx, INTRINS_FMA, args, dname); break; } @@ -6861,7 +6861,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) args [0] = convert (ctx, values [ins->sreg1], LLVMFloatType ()); args [1] = convert (ctx, values [ins->sreg2], LLVMFloatType ()); args [2] = convert (ctx, values [ins->sreg3], LLVMFloatType ()); - + values [ins->dreg] = call_intrins (ctx, INTRINS_FMAF, args, dname); break; } @@ -6983,7 +6983,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_ATOMIC_EXCHANGE_I8: { LLVMValueRef args [2]; LLVMTypeRef t; - + if (ins->opcode == OP_ATOMIC_EXCHANGE_I4) t = LLVMInt32Type (); else @@ -7035,7 +7035,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_ATOMIC_CAS_I8: { LLVMValueRef args [3], val; LLVMTypeRef t; - + if (ins->opcode == OP_ATOMIC_CAS_I4) t = LLVMInt32Type (); else @@ -7254,10 +7254,10 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) break; } - /* + /* * Valuetypes. - * We currently model them using arrays. Promotion to local vregs is - * disabled for them in mono_handle_global_vregs () in the LLVM case, + * We currently model them using arrays. Promotion to local vregs is + * disabled for them in mono_handle_global_vregs () in the LLVM case, * so we always have an entry in cfg->varinfo for them. * FIXME: Is this needed ? */ @@ -8007,7 +8007,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) LLVMValueRef v1 = NULL, v2 = NULL, mask_values [16]; int i, mask_size = 0; int imask = ins->inst_c0; - + /* Convert the x86 shuffle mask to LLVM's */ switch (ins->opcode) { case OP_SHUFPS: @@ -8141,7 +8141,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) for (i = 0; i < mask_size; ++i) mask_values [i] = LLVMConstInt (LLVMInt32Type (), mask [i], FALSE); - + values [ins->dreg] = LLVMBuildShuffleVector (builder, values [ins->sreg1], values [ins->sreg2], LLVMConstVector (mask_values, mask_size), dname); @@ -8164,7 +8164,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_DUPPS_HIGH: { LLVMTypeRef t = simd_op_to_llvm_type (ins->opcode); LLVMValueRef v1, v2, val; - + if (ins->opcode == OP_DUPPS_LOW) { v1 = LLVMBuildExtractElement (builder, lhs, LLVMConstInt (LLVMInt32Type (), 0, FALSE), ""); @@ -8178,7 +8178,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) val = LLVMBuildInsertElement (builder, val, v1, LLVMConstInt (LLVMInt32Type (), 1, FALSE), ""); val = LLVMBuildInsertElement (builder, val, v2, LLVMConstInt (LLVMInt32Type (), 2, FALSE), ""); val = LLVMBuildInsertElement (builder, val, v2, LLVMConstInt (LLVMInt32Type (), 3, FALSE), ""); - + values [ins->dreg] = val; break; } @@ -8216,8 +8216,8 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) else if (ins->inst_c1 == MONO_TYPE_R8) values [ins->dreg] = LLVMBuildShuffleVector (builder, rhs, lhs, create_const_vector_2_i32 (0, 3), ""); else if (ins->inst_c1 == MONO_TYPE_I8 || ins->inst_c1 == MONO_TYPE_U8) - values [ins->dreg] = LLVMBuildInsertElement (builder, lhs, - LLVMConstInt (LLVMInt64Type (), 0, FALSE), + values [ins->dreg] = LLVMBuildInsertElement (builder, lhs, + LLVMConstInt (LLVMInt64Type (), 0, FALSE), LLVMConstInt (LLVMInt32Type (), 1, FALSE), ""); else g_assert_not_reached (); // will be needed for other types later @@ -8247,14 +8247,14 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) values [ins->dreg] = LLVMBuildShuffleVector (builder, lhs, rhs, create_const_vector_4_i32 (0, 4, 1, 5), ""); } else if (ins->inst_c1 == MONO_TYPE_I2 || ins->inst_c1 == MONO_TYPE_U2) { const int mask_values [] = { 0, 8, 1, 9, 2, 10, 3, 11 }; - LLVMValueRef shuffled = LLVMBuildShuffleVector (builder, + LLVMValueRef shuffled = LLVMBuildShuffleVector (builder, convert (ctx, lhs, sse_i2_t), convert (ctx, rhs, sse_i2_t), create_const_vector_i32 (mask_values, 8), ""); values [ins->dreg] = convert (ctx, shuffled, type_to_sse_type (ins->inst_c1)); } else if (ins->inst_c1 == MONO_TYPE_I1 || ins->inst_c1 == MONO_TYPE_U1) { const int mask_values [] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; - LLVMValueRef shuffled = LLVMBuildShuffleVector (builder, + LLVMValueRef shuffled = LLVMBuildShuffleVector (builder, convert (ctx, lhs, sse_i1_t), convert (ctx, rhs, sse_i1_t), create_const_vector_i32 (mask_values, 16), ""); @@ -8272,14 +8272,14 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) values [ins->dreg] = LLVMBuildShuffleVector (builder, lhs, rhs, create_const_vector_4_i32 (2, 6, 3, 7), ""); } else if (ins->inst_c1 == MONO_TYPE_I2 || ins->inst_c1 == MONO_TYPE_U2) { const int mask_values [] = { 4, 12, 5, 13, 6, 14, 7, 15 }; - LLVMValueRef shuffled = LLVMBuildShuffleVector (builder, + LLVMValueRef shuffled = LLVMBuildShuffleVector (builder, convert (ctx, lhs, sse_i2_t), convert (ctx, rhs, sse_i2_t), create_const_vector_i32 (mask_values, 8), ""); values [ins->dreg] = convert (ctx, shuffled, type_to_sse_type (ins->inst_c1)); } else if (ins->inst_c1 == MONO_TYPE_I1 || ins->inst_c1 == MONO_TYPE_U1) { const int mask_values [] = { 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31 }; - LLVMValueRef shuffled = LLVMBuildShuffleVector (builder, + LLVMValueRef shuffled = LLVMBuildShuffleVector (builder, convert (ctx, lhs, sse_i1_t), convert (ctx, rhs, sse_i1_t), create_const_vector_i32 (mask_values, 16), ""); @@ -8675,7 +8675,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) args [0] = convert (ctx, args [0], sse_i8_t); args [1] = convert (ctx, args [1], sse_i8_t); } - + LLVMValueRef call = call_intrins (ctx, id, args, ""); if (ret_bool) { // if return type is bool (it's still i32) we need to normalize it to 1/0 @@ -8751,7 +8751,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) LLVMValueRef args [2]; args [0] = convert (ctx, lhs, sse_i2_t); args [1] = convert (ctx, rhs, sse_i2_t); - values [ins->dreg] = convert (ctx, + values [ins->dreg] = convert (ctx, call_intrins (ctx, INTRINS_SSE_PACKUSWB, args, dname), type_to_sse_type (ins->inst_c1)); break; @@ -8759,7 +8759,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) case OP_SSE2_SRLI: { LLVMValueRef args [] = { lhs, rhs }; - values [ins->dreg] = convert (ctx, + values [ins->dreg] = convert (ctx, call_intrins (ctx, INTRINS_SSE_PSRLI_W, args, dname), type_to_sse_type (ins->inst_c1)); break; @@ -9161,7 +9161,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) } case OP_SSE_CVTII: { - gboolean is_signed = (ins->inst_c1 == MONO_TYPE_I1) || + gboolean is_signed = (ins->inst_c1 == MONO_TYPE_I1) || (ins->inst_c1 == MONO_TYPE_I2) || (ins->inst_c1 == MONO_TYPE_I4); LLVMTypeRef vec_type; @@ -9226,12 +9226,12 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) mul_args[i] = mono_llvm_build_exact_ashr (builder, padded, shift_vec); } values [ins->dreg] = LLVMBuildNSWMul (builder, mul_args [0], mul_args [1], dname); - break; + break; } case OP_SSE41_MULLO: { values [ins->dreg] = LLVMBuildMul (ctx->builder, lhs, rhs, ""); - break; + break; } case OP_SSE42_CRC32: @@ -9747,11 +9747,11 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) // %mul = shl i32 %xor, 1 // %add = or i32 %mul, 1 // %0 = tail call i32 @llvm.ctlz.i32(i32 %add, i1 false) - LLVMValueRef shr = LLVMBuildAShr (builder, lhs, ins->opcode == OP_LSCNT32 ? - LLVMConstInt (LLVMInt32Type (), 31, FALSE) : + LLVMValueRef shr = LLVMBuildAShr (builder, lhs, ins->opcode == OP_LSCNT32 ? + LLVMConstInt (LLVMInt32Type (), 31, FALSE) : LLVMConstInt (LLVMInt64Type (), 63, FALSE), ""); - LLVMValueRef one = ins->opcode == OP_LSCNT32 ? - LLVMConstInt (LLVMInt32Type (), 1, FALSE) : + LLVMValueRef one = ins->opcode == OP_LSCNT32 ? + LLVMConstInt (LLVMInt32Type (), 1, FALSE) : LLVMConstInt (LLVMInt64Type (), 1, FALSE); LLVMValueRef xor = LLVMBuildXor (builder, shr, lhs, ""); LLVMValueRef mul = LLVMBuildShl (builder, xor, one, ""); @@ -10892,7 +10892,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) break; } case OP_CALL_HANDLER: { - /* + /* * We don't 'call' handlers, but instead simply branch to them. * The code generated by ENDFINALLY will branch back to us. */ @@ -10902,13 +10902,13 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb) bb_list = info->call_handler_return_bbs; - /* + /* * Set the indicator variable for the finally clause. */ lhs = info->finally_ind; g_assert (lhs); LLVMBuildStore (builder, LLVMConstInt (LLVMInt32Type (), g_slist_length (bb_list) + 1, FALSE), lhs); - + /* Branch to the finally clause */ LLVMBuildBr (builder, info->call_handler_target_bb); @@ -11241,7 +11241,7 @@ mono_llvm_emit_method (MonoCompile *cfg) ctx->is_vphi = g_new0 (gboolean, cfg->next_vreg); ctx->vreg_cli_types = g_new0 (MonoType*, cfg->next_vreg); ctx->phi_values = g_ptr_array_sized_new (256); - /* + /* * This signals whenever the vreg was defined by a phi node with no input vars * (i.e. all its input bblocks end with NOT_REACHABLE). */ @@ -11652,7 +11652,7 @@ emit_method_inner (EmitContext *ctx) for (bb = cfg->bb_entry; bb; bb = bb->next_bb) { if (bb->last_ins && MONO_IS_COND_BRANCH_OP (bb->last_ins) && bb->next_bb != bb->last_ins->inst_false_bb) { - + MonoInst *inst = (MonoInst*)mono_mempool_alloc0 (cfg->mempool, sizeof (MonoInst)); inst->opcode = OP_BR; inst->inst_target_bb = bb->last_ins->inst_false_bb; @@ -11691,7 +11691,7 @@ emit_method_inner (EmitContext *ctx) phi_type = LLVMPointerType (type_to_llvm_type (ctx, m_class_get_byval_arg (ins->klass)), 0); } - /* + /* * Have to precreate these, as they can be referenced by * earlier instructions. */ @@ -11704,13 +11704,13 @@ emit_method_inner (EmitContext *ctx) g_ptr_array_add (ctx->phi_values, values [ins->dreg]); - /* + /* * Set the expected type of the incoming arguments since these have * to have the same type. */ for (i = 0; i < ins->inst_phi_args [0]; i++) { int sreg1 = ins->inst_phi_args [i + 1]; - + if (sreg1 != -1) { if (ins->opcode == OP_VPHI) ctx->is_vphi [sreg1] = TRUE; @@ -11728,7 +11728,7 @@ emit_method_inner (EmitContext *ctx) } } - /* + /* * Create an ordering for bblocks, use the depth first order first, then * put the exception handling bblocks last. */ @@ -12124,7 +12124,7 @@ mono_llvm_emit_call (MonoCompile *cfg, MonoCallInst *call) ainfo = call->cinfo->args + i; in = call->args [i]; - + /* Simply remember the arguments */ switch (ainfo->storage) { case LLVMArgNormal: { @@ -13007,7 +13007,7 @@ mono_llvm_propagate_nonnull_final (GHashTable *all_specializable, MonoLLVMModule { // When we first traverse the mini IL, we mark the things that are // nonnull (the roots). Then, for all of the methods that can be specialized, we - // see if their call sites have nonnull attributes. + // see if their call sites have nonnull attributes. // If so, we mark the function's param. This param has uses to propagate // the attribute to. This propagation can trigger a need to mark more attributes @@ -13049,7 +13049,7 @@ mono_llvm_propagate_nonnull_final (GHashTable *all_specializable, MonoLLVMModule while (queue) { // Update the queue state. - // Our only other per-iteration responsibility is now to free current + // Our only other per-iteration responsibility is now to free current NonnullPropWorkItem *current = (NonnullPropWorkItem *) queue->data; queue = queue->next; g_assert (current->argument < LLVMCountParams (current->lmethod)); @@ -13072,8 +13072,8 @@ mono_llvm_propagate_nonnull_final (GHashTable *all_specializable, MonoLLVMModule LLVMValueRef lcall = (LLVMValueRef) cursor->data; LLVMValueRef callee_lmethod = LLVMGetCalledValue (lcall); - // If this wasn't a direct call for which mono_aot_can_specialize is true, - // this lookup won't find a MonoMethod. + // If this wasn't a direct call for which mono_aot_can_specialize is true, + // this lookup won't find a MonoMethod. MonoMethod *callee_method = (MonoMethod *) g_hash_table_lookup (all_specializable, callee_lmethod); if (!callee_method) continue; @@ -13135,7 +13135,7 @@ mono_llvm_emit_aot_module (const char *filename, const char *cu_name) emit_llvm_code_end (module); - /* + /* * Create the real init_var and replace all uses of the dummy variable with * the real one. */ @@ -13318,7 +13318,7 @@ emit_default_dbg_loc (EmitContext *ctx, LLVMBuilderRef builder) into something we can't handle. */ -/* +/* A partial list of issues: - Handling of opcodes which can throw exceptions. @@ -13336,7 +13336,7 @@ emit_default_dbg_loc (EmitContext *ctx, LLVMBuilderRef builder) in the LLVM IR, since it does not support label values. -> this can be implemented in AOT mode using inline asm + labels, but cannot be implemented in JIT mode ? - -> a possible but slower implementation would use the normal exception + -> a possible but slower implementation would use the normal exception throwing code but it would need to control the placement of the throw code (it needs to be exactly after the compare+branch). -> perhaps add a PC offset intrinsics ? @@ -13350,7 +13350,7 @@ emit_default_dbg_loc (EmitContext *ctx, LLVMBuilderRef builder) Some overflow opcodes are now supported by LLVM SVN. - exception handling, unwinding. - - SSA is disabled for methods with exception handlers + - SSA is disabled for methods with exception handlers - How to obtain unwind info for LLVM compiled methods ? -> this is now solved by converting the unwind info generated by LLVM into our format. @@ -13360,21 +13360,21 @@ emit_default_dbg_loc (EmitContext *ctx, LLVMBuilderRef builder) - it might be impossible to support filter clauses with it. - trampolines. - + The trampolines need a predictable call sequence, since they need to disasm the calling code to obtain register numbers / offsets. LLVM currently generates this code in non-JIT mode: mov -0x98(%rax),%eax callq *%rax - Here, the vtable pointer is lost. + Here, the vtable pointer is lost. -> solution: use one vtable trampoline per class. - passing/receiving the IMT pointer/RGCTX. -> solution: pass them as normal arguments ? - argument passing. - + LLVM does not allow the specification of argument registers etc. This means that all calls are made according to the platform ABI. @@ -13395,7 +13395,7 @@ emit_default_dbg_loc (EmitContext *ctx, LLVMBuilderRef builder) The mono JIT uses pointer sized iregs/double fregs, while LLVM uses precisely typed registers, so we have to keep track of the precise LLVM type of each vreg. This is made easier because the IR is already in SSA form. - An additional problem is that our IR is not consistent with types, i.e. i32/i64 + An additional problem is that our IR is not consistent with types, i.e. i32/i64 types are frequently used incorrectly. */ @@ -13571,7 +13571,7 @@ llvm_jit_finalize_method (EmitContext *ctx) { MonoCompile *cfg = ctx->cfg; int nvars = g_hash_table_size (ctx->jit_callees); - LLVMValueRef *callee_vars = g_new0 (LLVMValueRef, nvars); + LLVMValueRef *callee_vars = g_new0 (LLVMValueRef, nvars); gpointer *callee_addrs = g_new0 (gpointer, nvars); GHashTableIter iter; LLVMValueRef var; diff --git a/src/mono/mono/mini/mini-windows.c b/src/mono/mono/mini/mini-windows.c index 87de60ea9b568..c678f4c4594c4 100644 --- a/src/mono/mono/mini/mini-windows.c +++ b/src/mono/mono/mini/mini-windows.c @@ -55,10 +55,9 @@ #include "jit-icalls.h" #define MONO_HANDLER_DELIMITER ',' -#define MONO_HANDLER_DELIMITER_LEN G_N_ELEMENTS(MONO_HANDLER_DELIMITER)-1 #define MONO_HANDLER_ATEXIT_WAIT_KEYPRESS "atexit-waitkeypress" -#define MONO_HANDLER_ATEXIT_WAIT_KEYPRESS_LEN G_N_ELEMENTS(MONO_HANDLER_ATEXIT_WAIT_KEYPRESS)-1 +#define MONO_HANDLER_ATEXIT_WAIT_KEYPRESS_LEN STRING_LENGTH(MONO_HANDLER_ATEXIT_WAIT_KEYPRESS) // Typedefs used to setup handler table. typedef void (*handler)(void); diff --git a/src/mono/mono/profiler/log-args.c b/src/mono/mono/profiler/log-args.c index baa444c319cce..c8609177d18b0 100644 --- a/src/mono/mono/profiler/log-args.c +++ b/src/mono/mono/profiler/log-args.c @@ -232,7 +232,7 @@ proflog_parse_args (ProfilerConfig *config, const char *desc) break; } } - + if (buffer_pos != 0) { buffer [buffer_pos] = 0; parse_arg (buffer, config); diff --git a/src/mono/mono/profiler/log.c b/src/mono/mono/profiler/log.c index efe7bbfb56d1f..bbdf3ee44a840 100644 --- a/src/mono/mono/profiler/log.c +++ b/src/mono/mono/profiler/log.c @@ -3201,7 +3201,7 @@ profiler_thread_begin_function (const char *name8, const gunichar2* name16, size } #define profiler_thread_begin(name, send) \ - profiler_thread_begin_function (name, MONO_THREAD_NAME_WINDOWS_CONSTANT (name), G_N_ELEMENTS (name) - 1, (send)) + profiler_thread_begin_function (name, MONO_THREAD_NAME_WINDOWS_CONSTANT (name), STRING_LENGTH (name), (send)) static void profiler_thread_end (MonoProfilerThread *thread, MonoOSEvent *event, gboolean send) diff --git a/src/mono/mono/tests/libtest.c b/src/mono/mono/tests/libtest.c index 053d8678e30e0..ce0dd55cf732a 100644 --- a/src/mono/mono/tests/libtest.c +++ b/src/mono/mono/tests/libtest.c @@ -139,7 +139,7 @@ test_lpwstr_marshal (unsigned short* chars, int length) res = (unsigned short *)marshal_alloc (2 * (length + 1)); // printf("test_lpwstr_marshal()\n"); - + while ( i < length ) { // printf("X|%u|\n", chars[i]); res [i] = chars[i]; @@ -160,7 +160,7 @@ test_lpwstr_marshal_out (unsigned short** chars) glong len = strlen(abc); *chars = (unsigned short *)marshal_alloc (2 * (len + 1)); - + while ( i < len ) { (*chars) [i] = abc[i]; i++; @@ -175,19 +175,19 @@ typedef struct { int c; } union_test_1_type; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_union_test_1 (union_test_1_type u1) { // printf ("Got values %d %d %d\n", u1.b, u1.a, u1.c); return u1.a + u1.b + u1.c; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_return_int (int a) { // printf ("Got value %d\n", a); return a; } -LIBTEST_API float STDCALL +LIBTEST_API float STDCALL mono_test_marshal_pass_return_float (float f) { return f + 1.0; } @@ -197,7 +197,7 @@ struct ss int i; }; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_return_int_ss (struct ss a) { // printf ("Got value %d\n", a.i); return a.i; @@ -228,7 +228,7 @@ struct sc3 char c[3]; }; -LIBTEST_API struct sc3 STDCALL +LIBTEST_API struct sc3 STDCALL mono_return_sc3 (struct sc3 a) { // printf ("Got values %d %d %d\n", a.c[0], a.c[1], a.c[2]); a.c[0]++; @@ -242,7 +242,7 @@ struct sc5 char c[5]; }; -LIBTEST_API struct sc5 STDCALL +LIBTEST_API struct sc5 STDCALL mono_return_sc5 (struct sc5 a) { // printf ("Got values %d %d %d %d %d\n", a.c[0], a.c[1], a.c[2], a.c[3], a.c[4]); a.c[0]++; @@ -259,7 +259,7 @@ union su int i2; }; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_return_int_su (union su a) { // printf ("Got value %d\n", a.i1); return a.i1; @@ -306,53 +306,53 @@ mono_return_struct_4_double (void *ptr, struct Rect rect, struct Scalar4 sc4, in return buffer; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_many_int_arguments (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j); -LIBTEST_API short STDCALL +LIBTEST_API short STDCALL mono_test_many_short_arguments (short a, short b, short c, short d, short e, short f, short g, short h, short i, short j); -LIBTEST_API char STDCALL +LIBTEST_API char STDCALL mono_test_many_char_arguments (char a, char b, char c, char d, char e, char f, char g, char h, char i, char j); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_many_int_arguments (int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { return a + b + c + d + e + f + g + h + i + j; } -LIBTEST_API short STDCALL +LIBTEST_API short STDCALL mono_test_many_short_arguments (short a, short b, short c, short d, short e, short f, short g, short h, short i, short j) { return a + b + c + d + e + f + g + h + i + j; } -LIBTEST_API char STDCALL +LIBTEST_API char STDCALL mono_test_many_byte_arguments (char a, char b, char c, char d, char e, char f, char g, char h, char i, char j) { return a + b + c + d + e + f + g + h + i + j; } -LIBTEST_API float STDCALL +LIBTEST_API float STDCALL mono_test_many_float_arguments (float a, float b, float c, float d, float e, float f, float g, float h, float i, float j) { return a + b + c + d + e + f + g + h + i + j; } -LIBTEST_API double STDCALL +LIBTEST_API double STDCALL mono_test_many_double_arguments (double a, double b, double c, double d, double e, double f, double g, double h, double i, double j) { return a + b + c + d + e + f + g + h + i + j; } -LIBTEST_API double STDCALL +LIBTEST_API double STDCALL mono_test_split_double_arguments (double a, double b, float c, double d, double e) { return a + b + c + d + e; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_puts_static (char *s) { // printf ("TEST %s\n", s); @@ -361,7 +361,7 @@ mono_test_puts_static (char *s) typedef int (STDCALL *SimpleDelegate3) (int a, int b); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_invoke_delegate (SimpleDelegate3 delegate) { int res; @@ -381,12 +381,12 @@ mono_invoke_simple_delegate (SimpleDelegate d) return d (4); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_char (short a1) { if (a1 == 'a') return 0; - + return 1; } @@ -398,7 +398,7 @@ mono_test_marshal_char_array (gunichar2 *s) glong len; s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL); - + len = (len * 2) + 2; memcpy (s, s2, len); @@ -437,13 +437,13 @@ mono_test_marshal_unicode_char_array (gunichar2 *s) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_empty_pinvoke (int i) { return i; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bool_byref (int a, int *b, int c) { int res = *b; @@ -453,7 +453,7 @@ mono_test_marshal_bool_byref (int a, int *b, int c) return res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bool_in_as_I1_U1 (char bTrue, char bFalse) { if (!bTrue) @@ -463,7 +463,7 @@ mono_test_marshal_bool_in_as_I1_U1 (char bTrue, char bFalse) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bool_out_as_I1_U1 (char* bTrue, char* bFalse) { if (!bTrue || !bFalse) @@ -475,7 +475,7 @@ mono_test_marshal_bool_out_as_I1_U1 (char* bTrue, char* bFalse) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue, char* bFalse) { if (!bTrue || !bFalse) @@ -492,18 +492,18 @@ mono_test_marshal_bool_ref_as_I1_U1 (char* bTrue, char* bFalse) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_array (int *a1) { int i, sum = 0; for (i = 0; i < 50; i++) sum += a1 [i]; - + return sum; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_inout_array (int *a1) { int i, sum = 0; @@ -512,7 +512,7 @@ mono_test_marshal_inout_array (int *a1) sum += a1 [i]; a1 [i] = 50 - a1 [i]; } - + return sum; } @@ -522,7 +522,7 @@ mono_test_marshal_inout_array_cdecl (int *a1) return mono_test_marshal_inout_array (a1); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_out_array (int *a1) { int i; @@ -530,7 +530,7 @@ mono_test_marshal_out_array (int *a1) for (i = 0; i < 50; i++) { a1 [i] = i; } - + return 0; } @@ -563,7 +563,7 @@ mono_test_marshal_out_lparray_out_size_param (int *arr, int *out_len) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_inout_nonblittable_array (gunichar2 *a1) { int i, sum = 0; @@ -571,7 +571,7 @@ mono_test_marshal_inout_nonblittable_array (gunichar2 *a1) for (i = 0; i < 10; i++) { a1 [i] = 'F'; } - + return sum; } @@ -588,7 +588,7 @@ typedef struct { double y; } point; -LIBTEST_API simplestruct STDCALL +LIBTEST_API simplestruct STDCALL mono_test_return_vtype (int i) { simplestruct res; @@ -611,7 +611,7 @@ mono_test_delegate_struct (void) typedef char* (STDCALL *ReturnStringDelegate) (const char *s); -LIBTEST_API char * STDCALL +LIBTEST_API char * STDCALL mono_test_return_string (ReturnStringDelegate func) { char *res; @@ -627,7 +627,7 @@ mono_test_return_string (ReturnStringDelegate func) typedef int (STDCALL *RefVTypeDelegate) (int a, simplestruct *ss, int b); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func) { if (a == 1 && b == 2 && ss->a == 0 && ss->b == 1 && ss->c == 0 && @@ -645,7 +645,7 @@ mono_test_ref_vtype (int a, simplestruct *ss, int b, RefVTypeDelegate func) typedef int (STDCALL *OutVTypeDelegate) (int a, simplestruct *ss, int b); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate func) { /* Check that the input pointer is ignored */ @@ -661,7 +661,7 @@ mono_test_marshal_out_struct (int a, simplestruct *ss, int b, OutVTypeDelegate f typedef int (STDCALL *InVTypeDelegate) (int a, simplestruct *ss, int b); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_in_struct (int a, simplestruct *ss, int b, InVTypeDelegate func) { simplestruct ss2; @@ -687,7 +687,7 @@ typedef struct { SimpleDelegate func, func2, func3; } DelegateStruct; -LIBTEST_API DelegateStruct STDCALL +LIBTEST_API DelegateStruct STDCALL mono_test_marshal_delegate_struct (DelegateStruct ds) { DelegateStruct res; @@ -700,7 +700,7 @@ mono_test_marshal_delegate_struct (DelegateStruct ds) return res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_byref_struct (simplestruct *ss, int a, int b, int c, char *d) { gboolean res = (ss->a == a && ss->b == b && ss->c == c && strcmp (ss->d, d) == 0); @@ -726,11 +726,11 @@ typedef struct { guint64 h; } simplestruct2; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_struct2 (simplestruct2 ss) { if (ss.a == 0 && ss.b == 1 && ss.c == 0 && - !strcmp (ss.d, "TEST") && + !strcmp (ss.d, "TEST") && ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123) return 0; @@ -738,20 +738,20 @@ mono_test_marshal_struct2 (simplestruct2 ss) } /* on HP some of the struct should be on the stack and not in registers */ -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_struct2_2 (int i, int j, int k, simplestruct2 ss) { if (i != 10 || j != 11 || k != 12) return 1; if (ss.a == 0 && ss.b == 1 && ss.c == 0 && - !strcmp (ss.d, "TEST") && + !strcmp (ss.d, "TEST") && ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123) return 0; return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_lpstruct (simplestruct *ss) { if (ss->a == 0 && ss->b == 1 && ss->c == 0 && @@ -761,7 +761,7 @@ mono_test_marshal_lpstruct (simplestruct *ss) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_lpstruct_blittable (point *p) { if (p->x == 1.0 && p->y == 2.0) @@ -770,16 +770,16 @@ mono_test_marshal_lpstruct_blittable (point *p) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_struct_array (simplestruct2 *ss) { if (! (ss[0].a == 0 && ss[0].b == 1 && ss[0].c == 0 && - !strcmp (ss[0].d, "TEST") && + !strcmp (ss[0].d, "TEST") && ss[0].e == 99 && ss[0].f == 1.5 && ss[0].g == 42 && ss[0].h == (guint64)123)) return 1; if (! (ss[1].a == 0 && ss[1].b == 0 && ss[1].c == 0 && - !strcmp (ss[1].d, "TEST2") && + !strcmp (ss[1].d, "TEST2") && ss[1].e == 100 && ss[1].f == 2.5 && ss[1].g == 43 && ss[1].h == (guint64)124)) return 1; @@ -792,13 +792,13 @@ typedef struct long_align_struct { gint64 c; } long_align_struct; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_long_align_struct_array (long_align_struct *ss) { return ss[0].a + ss[0].b + ss[0].c + ss[1].a + ss[1].b + ss[1].c; } -LIBTEST_API simplestruct2 * STDCALL +LIBTEST_API simplestruct2 * STDCALL mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l) { simplestruct2 *res; @@ -809,7 +809,7 @@ mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l) if (i != 10 || j != 11 || k != 12 || l != 14) return NULL; if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 && - !strcmp (ss->d, "TEST") && + !strcmp (ss->d, "TEST") && ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123)) return NULL; @@ -819,14 +819,14 @@ mono_test_marshal_class (int i, int j, int k, simplestruct2 *ss, int l) return res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_byref_class (simplestruct2 **ssp) { simplestruct2 *ss = *ssp; simplestruct2 *res; - + if (! (ss->a == 0 && ss->b == 1 && ss->c == 0 && - !strcmp (ss->d, "TEST") && + !strcmp (ss->d, "TEST") && ss->e == 99 && ss->f == 1.5 && ss->g == 42 && ss->h == (guint64)123)) return 1; @@ -853,7 +853,7 @@ get_sp (void) MONO_RESTORE_WARNING -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL reliable_delegate (int a) { return a; @@ -872,9 +872,9 @@ is_get_sp_reliable (void) reliable_delegate(1); sp2 = get_sp(); return sp1 == sp2; -} +} -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate (SimpleDelegate delegate) { void *sp1, *sp2; @@ -895,7 +895,7 @@ static int STDCALL inc_cb (int i) return i + 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_out_delegate (SimpleDelegate *delegate) { *delegate = inc_cb; @@ -903,7 +903,7 @@ mono_test_marshal_out_delegate (SimpleDelegate *delegate) return 0; } -LIBTEST_API SimpleDelegate STDCALL +LIBTEST_API SimpleDelegate STDCALL mono_test_marshal_return_delegate (SimpleDelegate delegate) { return delegate; @@ -927,7 +927,7 @@ return_plus_one (int i) return i + 1; } -LIBTEST_API SimpleDelegate STDCALL +LIBTEST_API SimpleDelegate STDCALL mono_test_marshal_return_delegate_2 (void) { return return_plus_one; @@ -958,7 +958,7 @@ mono_test_marshal_struct (simplestruct ss) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate2 (SimpleDelegate2 delegate) { simplestruct ss, res; @@ -967,7 +967,7 @@ mono_test_marshal_delegate2 (SimpleDelegate2 delegate) ss.b = 1; ss.c = 0; ss.d = "TEST"; - ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL); + ss.d2 = g_utf8_to_utf16 ("TEST2", -1, NULL, NULL, NULL); res = delegate (ss); if (! (res.a && !res.b && res.c && !strcmp (res.d, "TEST-RES") && is_utf16_equals (res.d2, "TEST2-RES"))) @@ -978,7 +978,7 @@ mono_test_marshal_delegate2 (SimpleDelegate2 delegate) typedef simplestruct* (STDCALL *SimpleDelegate4) (simplestruct *ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate4 (SimpleDelegate4 delegate) { simplestruct ss; @@ -1008,7 +1008,7 @@ mono_test_marshal_delegate4 (SimpleDelegate4 delegate) typedef int (STDCALL *SimpleDelegate5) (simplestruct **ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate5 (SimpleDelegate5 delegate) { simplestruct ss; @@ -1032,7 +1032,7 @@ mono_test_marshal_delegate5 (SimpleDelegate5 delegate) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate6 (SimpleDelegate5 delegate) { delegate (NULL); @@ -1041,7 +1041,7 @@ mono_test_marshal_delegate6 (SimpleDelegate5 delegate) typedef int (STDCALL *SimpleDelegate7) (simplestruct **ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate7 (SimpleDelegate7 delegate) { int res; @@ -1062,7 +1062,7 @@ mono_test_marshal_delegate7 (SimpleDelegate7 delegate) typedef int (STDCALL *InOutByvalClassDelegate) (simplestruct *ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate) { int res; @@ -1085,7 +1085,7 @@ mono_test_marshal_inout_byval_class_delegate (InOutByvalClassDelegate delegate) typedef int (STDCALL *SimpleDelegate8) (gunichar2 *s); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s) { return delegate (s); @@ -1094,19 +1094,19 @@ mono_test_marshal_delegate8 (SimpleDelegate8 delegate, gunichar2 *s) typedef int (STDCALL *return_int_fnt) (int i); typedef int (STDCALL *SimpleDelegate9) (return_int_fnt d); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate9 (SimpleDelegate9 delegate, gpointer ftn) { return delegate ((return_int_fnt)ftn); } -static int STDCALL +static int STDCALL return_self (int i) { return i; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_delegate10 (SimpleDelegate9 delegate) { return delegate (return_self); @@ -1114,7 +1114,7 @@ mono_test_marshal_delegate10 (SimpleDelegate9 delegate) typedef int (STDCALL *PrimitiveByrefDelegate) (int *i); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_primitive_byref_delegate (PrimitiveByrefDelegate delegate) { int i = 1; @@ -1133,7 +1133,7 @@ typedef int (STDCALL *return_int_delegate) (int i); typedef return_int_delegate (STDCALL *ReturnDelegateDelegate) (void); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_return_delegate_delegate (ReturnDelegateDelegate d) { return (d ()) (55); @@ -1155,7 +1155,7 @@ mono_test_marshal_icall_delegate (IcallDelegate del) return strcmp (res, "ABC") == 0 ? 0 : 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_stringbuilder (char *s, int n) { const char m[] = "This is my message. Isn't it nice?"; @@ -1167,7 +1167,7 @@ mono_test_marshal_stringbuilder (char *s, int n) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_stringbuilder_append (char *s, int length) { const char out_sentinel[] = "CSHARP_"; @@ -1183,7 +1183,7 @@ mono_test_marshal_stringbuilder_append (char *s, int length) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_stringbuilder_default (char *s, int n) { const char m[] = "This is my message. Isn't it nice?"; @@ -1193,7 +1193,7 @@ mono_test_marshal_stringbuilder_default (char *s, int n) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n) { const char m[] = "This is my message. Isn't it nice?"; @@ -1201,7 +1201,7 @@ mono_test_marshal_stringbuilder_unicode (gunichar2 *s, int n) glong len; s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL); - + len = (len * 2) + 2; if (len > (n * 2)) len = n * 2; @@ -1220,11 +1220,11 @@ mono_test_marshal_stringbuilder_out (char **s) str = (char *)marshal_alloc (strlen (m) + 1); memcpy (str, m, strlen (m) + 1); - + *s = str; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_stringbuilder_out_unicode (gunichar2 **s) { const char m[] = "This is my message. Isn't it nice?"; @@ -1232,7 +1232,7 @@ mono_test_marshal_stringbuilder_out_unicode (gunichar2 **s) glong len; s2 = g_utf8_to_utf16 (m, -1, NULL, &len, NULL); - + len = (len * 2) + 2; *s = (gunichar2 *)marshal_alloc (len); memcpy (*s, s2, len); @@ -1253,12 +1253,12 @@ mono_test_marshal_stringbuilder_ref (char **s) str = (char *)marshal_alloc (strlen (m) + 1); memcpy (str, m, strlen (m) + 1); - + *s = str; return 0; } -LIBTEST_API void STDCALL +LIBTEST_API void STDCALL mono_test_marshal_stringbuilder_utf16_tolower (short *s, int n) { for (int i = 0; i < n; i++) @@ -1290,13 +1290,13 @@ typedef struct { #pragma GCC diagnostic pop #endif -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_empty_string_array (char **array) { return (array == NULL) ? 0 : 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_string_array (char **array) { if (strcmp (array [0], "ABC")) @@ -1310,7 +1310,7 @@ mono_test_marshal_string_array (char **array) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_byref_string_array (char ***array) { if (*array == NULL) @@ -1326,7 +1326,7 @@ mono_test_marshal_byref_string_array (char ***array) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_stringbuilder_array (char **array) { if (strcmp (array [0], "ABC")) @@ -1340,12 +1340,12 @@ mono_test_marshal_stringbuilder_array (char **array) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2) { GError *gerror = NULL; char *s; - + s = g_utf16_to_utf8 (array [0], -1, NULL, NULL, &gerror); if (strcmp (s, "ABC")) { g_free (s); @@ -1365,14 +1365,14 @@ mono_test_marshal_unicode_string_array (gunichar2 **array, char **array2) if (strcmp (array2 [0], "ABC")) return 3; - if (strcmp (array2 [1], "DEF")) + if (strcmp (array2 [1], "DEF")) return 4; return 0; } /* this does not work on Redhat gcc 2.96 */ -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_empty_struct (int a, EmptyStruct es, int b) { // printf ("mono_test_empty_struct %d %d\n", a, b); @@ -1406,11 +1406,11 @@ typedef struct { char a[100]; } ByValStrStruct; -LIBTEST_API ByValStrStruct * STDCALL +LIBTEST_API ByValStrStruct * STDCALL mono_test_byvalstr_gen (void) { ByValStrStruct *ret; - + ret = (ByValStrStruct *)malloc (sizeof (ByValStrStruct)); memset(ret, 'a', sizeof(ByValStrStruct)-1); ret->a[sizeof(ByValStrStruct)-1] = 0; @@ -1418,7 +1418,7 @@ mono_test_byvalstr_gen (void) return ret; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_byvalstr_check (ByValStrStruct* data, char* correctString) { int ret; @@ -1437,14 +1437,14 @@ typedef struct { int flag; } ByValStrStruct_Unicode; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test) { if (ref->flag != 0x1234abcd){ printf ("overwritten data"); return 1; } - + if (test == 1 || test == 3){ if (ref->a [0] != '1' || ref->a [1] != '2' || @@ -1461,55 +1461,55 @@ mono_test_byvalstr_check_unicode (ByValStrStruct_Unicode *ref, int test) return 10; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingAnsi (char *data) { return data [0] + data [1] + data [2]; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingAnsiA (char *data) { g_assert_not_reached (); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingAnsiW (char *data) { g_assert_not_reached (); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingAnsi2A (char *data) { return data [0] + data [1] + data [2]; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingAnsi2W (char *data) { g_assert_not_reached (); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingUnicode (char *data) { g_assert_not_reached (); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingUnicodeW (gunichar2 *data) { return data [0] + data [1] + data [2]; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingUnicode2 (gunichar2 *data) { return data [0] + data [1] + data [2]; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingAutoW (char *data) { #ifdef WIN32 @@ -1519,7 +1519,7 @@ NameManglingAutoW (char *data) #endif } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL NameManglingAuto (char *data) { #ifndef WIN32 @@ -1531,7 +1531,7 @@ NameManglingAuto (char *data) typedef int (STDCALL *intcharFunc)(const char*); -LIBTEST_API void STDCALL +LIBTEST_API void STDCALL callFunction (intcharFunc f) { f ("ABC"); @@ -1542,7 +1542,7 @@ typedef struct { int i; } SimpleObj; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL class_marshal_test0 (SimpleObj *obj1) { // printf ("class_marshal_test0 %s %d\n", obj1->str, obj1->i); @@ -1555,7 +1555,7 @@ class_marshal_test0 (SimpleObj *obj1) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL class_marshal_test4 (SimpleObj *obj1) { if (obj1) @@ -1575,7 +1575,7 @@ class_marshal_test1 (SimpleObj **obj1) *obj1 = res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL class_marshal_test2 (SimpleObj **obj1) { // printf ("class_marshal_test2 %s %d\n", (*obj1)->str, (*obj1)->i); @@ -1588,7 +1588,7 @@ class_marshal_test2 (SimpleObj **obj1) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL string_marshal_test0 (char *str) { if (strcmp (str, "TEST0")) @@ -1603,7 +1603,7 @@ string_marshal_test1 (const char **str) *str = marshal_strdup ("TEST1"); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL string_marshal_test2 (char **str) { // printf ("string_marshal_test2 %s\n", *str); @@ -1616,7 +1616,7 @@ string_marshal_test2 (char **str) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL string_marshal_test3 (char *str) { if (str) @@ -1630,7 +1630,7 @@ typedef struct { int b; } BlittableClass; -LIBTEST_API BlittableClass* STDCALL +LIBTEST_API BlittableClass* STDCALL TestBlittableClass (BlittableClass *vl) { BlittableClass *res; @@ -1653,12 +1653,12 @@ TestBlittableClass (BlittableClass *vl) } typedef struct OSVERSIONINFO_STRUCT -{ - int a; - int b; +{ + int a; + int b; } OSVERSIONINFO_STRUCT; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi) { @@ -1670,7 +1670,7 @@ MyGetVersionEx (OSVERSIONINFO_STRUCT *osvi) return osvi->a + osvi->b; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSIONINFO_STRUCT *osvi) { @@ -1682,7 +1682,7 @@ BugGetVersionEx (int a, int b, int c, int d, int e, int f, int g, int h, OSVERSI return osvi->a + osvi->b; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_point (point pt) { // printf("point %g %g\n", pt.x, pt.y); @@ -1697,7 +1697,7 @@ typedef struct { double y; } mixed_point; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_mixed_point (mixed_point pt) { // printf("mixed point %d %g\n", pt.x, pt.y); @@ -1707,7 +1707,7 @@ mono_test_marshal_mixed_point (mixed_point pt) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_mixed_point_2 (mixed_point *pt) { if (pt->x != 5 || pt->y != 6.75) @@ -1719,7 +1719,7 @@ mono_test_marshal_mixed_point_2 (mixed_point *pt) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL marshal_test_ref_bool(int i, char *b1, short *b2, int *b3) { int res = 1; @@ -1745,7 +1745,7 @@ struct BoolStruct int b3; }; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL marshal_test_bool_struct(struct BoolStruct *s) { int res = 1; @@ -1797,13 +1797,13 @@ mono_test_last_error (int err) */ char buffer[256] = { 0 }; char value[] = "Dummy"; - strncpy (buffer, value, G_N_ELEMENTS (value) - 1); + strncpy (buffer, value, STRING_LENGTH (value)); #else mono_set_errno (err); #endif } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_asany (void *ptr, int what) { switch (what) { @@ -1815,7 +1815,7 @@ mono_test_asany (void *ptr, int what) simplestruct2 ss = *(simplestruct2*)ptr; if (ss.a == 0 && ss.b == 1 && ss.c == 0 && - !strcmp (ss.d, "TEST") && + !strcmp (ss.d, "TEST") && ss.e == 99 && ss.f == 1.5 && ss.g == 42 && ss.h == (guint64)123) return 0; else @@ -1857,7 +1857,7 @@ typedef struct char *s; } AsAnyStruct; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_asany_in (void* ptr) { AsAnyStruct *asAny = (AsAnyStruct *)ptr; @@ -1866,7 +1866,7 @@ mono_test_marshal_asany_in (void* ptr) return res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_asany_inout (void* ptr) { AsAnyStruct *asAny = (AsAnyStruct *)ptr; @@ -1882,7 +1882,7 @@ mono_test_marshal_asany_inout (void* ptr) return res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_asany_out (void* ptr) { AsAnyStruct *asAny = (AsAnyStruct *)ptr; @@ -1907,7 +1907,7 @@ typedef struct amd64_struct1 { int l; } amd64_struct1; -LIBTEST_API amd64_struct1 STDCALL +LIBTEST_API amd64_struct1 STDCALL mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s) { s.i ++; @@ -1918,7 +1918,7 @@ mono_test_marshal_amd64_pass_return_struct1 (amd64_struct1 s) return s; } -LIBTEST_API amd64_struct1 STDCALL +LIBTEST_API amd64_struct1 STDCALL mono_test_marshal_amd64_pass_return_struct1_many_args (amd64_struct1 s, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8) { s.i ++; @@ -1934,7 +1934,7 @@ typedef struct amd64_struct2 { int j; } amd64_struct2; -LIBTEST_API amd64_struct2 STDCALL +LIBTEST_API amd64_struct2 STDCALL mono_test_marshal_amd64_pass_return_struct2 (amd64_struct2 s) { s.i ++; @@ -1947,7 +1947,7 @@ typedef struct amd64_struct3 { int i; } amd64_struct3; -LIBTEST_API amd64_struct3 STDCALL +LIBTEST_API amd64_struct3 STDCALL mono_test_marshal_amd64_pass_return_struct3 (amd64_struct3 s) { s.i ++; @@ -1959,7 +1959,7 @@ typedef struct amd64_struct4 { double d1, d2; } amd64_struct4; -LIBTEST_API amd64_struct4 STDCALL +LIBTEST_API amd64_struct4 STDCALL mono_test_marshal_amd64_pass_return_struct4 (amd64_struct4 s) { s.d1 ++; @@ -1975,7 +1975,7 @@ typedef struct test_struct5 { float d1, d2; } test_struct5; -LIBTEST_API test_struct5 STDCALL +LIBTEST_API test_struct5 STDCALL mono_test_marshal_ia64_pass_return_struct5 (double d1, double d2, test_struct5 s, int i, double d3, double d4) { s.d1 += d1 + d2 + i; @@ -1988,7 +1988,7 @@ typedef struct test_struct6 { double d1, d2; } test_struct6; -LIBTEST_API test_struct6 STDCALL +LIBTEST_API test_struct6 STDCALL mono_test_marshal_ia64_pass_return_struct6 (double d1, double d2, test_struct6 s, int i, double d3, double d4) { s.d1 += d1 + d2 + i; @@ -2009,7 +2009,7 @@ mono_test_marshal_pass_return_custom (int i, guint32 *ptr, int j) return &custom_res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j) { custom_res [0] = 0; @@ -2020,7 +2020,7 @@ mono_test_marshal_pass_out_custom (int i, guint32 **ptr, int j) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j) { ptr [0] = 0; @@ -2029,13 +2029,13 @@ mono_test_marshal_pass_inout_custom (int i, guint32 *ptr, int j) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_pass_out_byval_custom (int i, guint32 *ptr, int j) { return ptr == NULL ? 0 : 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_pass_byref_custom (int i, guint32 **ptr, int j) { (*ptr)[1] += i + j; @@ -2061,7 +2061,7 @@ mono_test_marshal_pass_return_custom_null (int i, guint32 *ptr, int j) typedef void *(STDCALL *PassReturnPtrDelegate) (void *ptr); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del) { guint32 buf [2]; @@ -2084,7 +2084,7 @@ mono_test_marshal_pass_return_custom_in_delegate (PassReturnPtrDelegate del) return res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del) { void *ptr = del (NULL); @@ -2094,7 +2094,7 @@ mono_test_marshal_pass_return_custom_null_in_delegate (PassReturnPtrDelegate del typedef void (STDCALL *CustomOutParamDelegate) (void **pptr); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del) { void* pptr = (void*)del; @@ -2109,7 +2109,7 @@ mono_test_marshal_custom_out_param_delegate (CustomOutParamDelegate del) typedef int (STDCALL *ReturnEnumDelegate) (int e); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_return_enum_delegate (ReturnEnumDelegate func) { return func (1); @@ -2119,10 +2119,10 @@ typedef struct { int a, b, c; gint64 d; } BlittableStruct; - + typedef BlittableStruct (STDCALL *SimpleDelegate10) (BlittableStruct ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate) { BlittableStruct ss, res; @@ -2139,7 +2139,7 @@ mono_test_marshal_blittable_struct_delegate (SimpleDelegate10 delegate) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_stdcall_name_mangling (int a, int b, int c) { return a + b + c; @@ -2164,10 +2164,10 @@ mono_test_stdcall_mismatch_2 (int a, int b, int c) typedef struct { int i; } SmallStruct1; - + typedef SmallStruct1 (STDCALL *SmallStructDelegate1) (SmallStruct1 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate) { SmallStruct1 ss, res; @@ -2184,10 +2184,10 @@ mono_test_marshal_small_struct_delegate1 (SmallStructDelegate1 delegate) typedef struct { gint16 i, j; } SmallStruct2; - + typedef SmallStruct2 (STDCALL *SmallStructDelegate2) (SmallStruct2 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate2 (SmallStructDelegate2 delegate) { SmallStruct2 ss, res; @@ -2206,10 +2206,10 @@ typedef struct { gint16 i; gint8 j; } SmallStruct3; - + typedef SmallStruct3 (STDCALL *SmallStructDelegate3) (SmallStruct3 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate) { SmallStruct3 ss, res; @@ -2227,10 +2227,10 @@ mono_test_marshal_small_struct_delegate3 (SmallStructDelegate3 delegate) typedef struct { gint16 i; } SmallStruct4; - + typedef SmallStruct4 (STDCALL *SmallStructDelegate4) (SmallStruct4 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate) { SmallStruct4 ss, res; @@ -2247,10 +2247,10 @@ mono_test_marshal_small_struct_delegate4 (SmallStructDelegate4 delegate) typedef struct { gint64 i; } SmallStruct5; - + typedef SmallStruct5 (STDCALL *SmallStructDelegate5) (SmallStruct5 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate) { SmallStruct5 ss, res; @@ -2267,10 +2267,10 @@ mono_test_marshal_small_struct_delegate5 (SmallStructDelegate5 delegate) typedef struct { int i, j; } SmallStruct6; - + typedef SmallStruct6 (STDCALL *SmallStructDelegate6) (SmallStruct6 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate6 (SmallStructDelegate6 delegate) { SmallStruct6 ss, res; @@ -2289,10 +2289,10 @@ typedef struct { int i; gint16 j; } SmallStruct7; - + typedef SmallStruct7 (STDCALL *SmallStructDelegate7) (SmallStruct7 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate) { SmallStruct7 ss, res; @@ -2310,10 +2310,10 @@ mono_test_marshal_small_struct_delegate7 (SmallStructDelegate7 delegate) typedef struct { float i; } SmallStruct8; - + typedef SmallStruct8 (STDCALL *SmallStructDelegate8) (SmallStruct8 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate) { SmallStruct8 ss, res; @@ -2330,10 +2330,10 @@ mono_test_marshal_small_struct_delegate8 (SmallStructDelegate8 delegate) typedef struct { double i; } SmallStruct9; - + typedef SmallStruct9 (STDCALL *SmallStructDelegate9) (SmallStruct9 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate) { SmallStruct9 ss, res; @@ -2350,10 +2350,10 @@ mono_test_marshal_small_struct_delegate9 (SmallStructDelegate9 delegate) typedef struct { float i, j; } SmallStruct10; - + typedef SmallStruct10 (STDCALL *SmallStructDelegate10) (SmallStruct10 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate10 (SmallStructDelegate10 delegate) { SmallStruct10 ss, res; @@ -2372,10 +2372,10 @@ typedef struct { float i; int j; } SmallStruct11; - + typedef SmallStruct11 (STDCALL *SmallStructDelegate11) (SmallStruct11 ss); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate) { SmallStruct11 ss, res; @@ -2392,7 +2392,7 @@ mono_test_marshal_small_struct_delegate11 (SmallStructDelegate11 delegate) typedef int (STDCALL *ArrayDelegate) (int i, char *j, void *arr); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del) { return del (len, NULL, arr); @@ -2400,13 +2400,13 @@ mono_test_marshal_array_delegate (void *arr, int len, ArrayDelegate del) typedef int (STDCALL *ArrayDelegateLong) (gint64 i, char *j, void *arr); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_array_delegate_long (void *arr, gint64 len, ArrayDelegateLong del) { return del (len, NULL, arr); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del) { del (len, NULL, arr); @@ -2419,7 +2419,7 @@ mono_test_marshal_out_array_delegate (int *arr, int len, ArrayDelegate del) typedef gunichar2* (STDCALL *UnicodeStringDelegate) (gunichar2 *message); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del) { const char m[] = "abcdef"; @@ -2435,7 +2435,7 @@ mono_test_marshal_return_unicode_string_delegate (UnicodeStringDelegate del) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate del) { del (len, NULL, arr); @@ -2448,7 +2448,7 @@ mono_test_marshal_out_string_array_delegate (char **arr, int len, ArrayDelegate typedef int (*CdeclDelegate) (int i, int j); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_cdecl_delegate (CdeclDelegate del) { int i; @@ -2461,7 +2461,7 @@ mono_test_marshal_cdecl_delegate (CdeclDelegate del) typedef char** (STDCALL *ReturnStringArrayDelegate) (int i); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d) { char **arr = d (2); @@ -2482,7 +2482,7 @@ mono_test_marshal_return_string_array_delegate (ReturnStringArrayDelegate d) typedef int (STDCALL *ByrefStringDelegate) (char **s); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_byref_string_delegate (ByrefStringDelegate d) { char *s = (char*)"ABC"; @@ -2502,19 +2502,19 @@ mono_test_marshal_byref_string_delegate (ByrefStringDelegate d) return res; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL add_delegate (int i, int j) { return i + j; } -LIBTEST_API gpointer STDCALL +LIBTEST_API gpointer STDCALL mono_test_marshal_return_fnptr (void) { return (gpointer)&add_delegate; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_xr (int code) { printf ("codigo %x\n", code); @@ -2525,7 +2525,7 @@ typedef struct { int handle; } HandleRef; -LIBTEST_API HandleRef STDCALL +LIBTEST_API HandleRef STDCALL mono_xr_as_handle (int code) { HandleRef ref; @@ -2534,7 +2534,7 @@ mono_xr_as_handle (int code) return ref; } - + typedef struct { int a; void *handle1; @@ -2542,7 +2542,7 @@ typedef struct { int b; } HandleStructs; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_safe_handle_struct_ref (HandleStructs *x) { printf ("Dingus Ref! \n"); @@ -2561,7 +2561,7 @@ mono_safe_handle_struct_ref (HandleStructs *x) return 0xf00d; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_safe_handle_struct (HandleStructs x) { printf ("Dingus Standard! \n"); @@ -2576,7 +2576,7 @@ mono_safe_handle_struct (HandleStructs x) if (x.handle2 != (void*) 0x1234abcd) return 4; - + return 0xf00f; } @@ -2584,14 +2584,14 @@ typedef struct { void *a; } TrivialHandle; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_safe_handle_struct_simple (TrivialHandle x) { printf ("The value is %p\n", x.a); return ((int)(gsize)x.a) * 2; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_safe_handle_return (void) { return 0x1000f00d; @@ -2742,7 +2742,7 @@ void VariantInit(VARIANT* vt) #endif -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bstr_in(gunichar2* bstr) { gint32 result = 0; @@ -2754,14 +2754,14 @@ mono_test_marshal_bstr_in(gunichar2* bstr) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bstr_out(gunichar2** bstr) { *bstr = marshal_bstr_alloc ("mono_test_marshal_bstr_out"); return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bstr_in_null(gunichar2* bstr) { if (!bstr) @@ -2769,14 +2769,14 @@ mono_test_marshal_bstr_in_null(gunichar2* bstr) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bstr_out_null(gunichar2** bstr) { *bstr = NULL; return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_sbyte(VARIANT variant) { if (variant.vt == VT_I1 && variant.cVal == 100) @@ -2784,7 +2784,7 @@ mono_test_marshal_variant_in_sbyte(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_byte(VARIANT variant) { if (variant.vt == VT_UI1 && variant.bVal == 100) @@ -2792,7 +2792,7 @@ mono_test_marshal_variant_in_byte(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_short(VARIANT variant) { if (variant.vt == VT_I2 && variant.iVal == 314) @@ -2800,7 +2800,7 @@ mono_test_marshal_variant_in_short(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_ushort(VARIANT variant) { if (variant.vt == VT_UI2 && variant.uiVal == 314) @@ -2808,7 +2808,7 @@ mono_test_marshal_variant_in_ushort(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_int(VARIANT variant) { if (variant.vt == VT_I4 && variant.lVal == 314) @@ -2816,7 +2816,7 @@ mono_test_marshal_variant_in_int(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_uint(VARIANT variant) { if (variant.vt == VT_UI4 && variant.ulVal == 314) @@ -2824,7 +2824,7 @@ mono_test_marshal_variant_in_uint(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_long(VARIANT variant) { if (variant.vt == VT_I8 && variant.llVal == 314) @@ -2832,7 +2832,7 @@ mono_test_marshal_variant_in_long(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_ulong(VARIANT variant) { if (variant.vt == VT_UI8 && variant.ullVal == 314) @@ -2840,7 +2840,7 @@ mono_test_marshal_variant_in_ulong(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_float(VARIANT variant) { if (variant.vt == VT_R4 && (variant.fltVal - 3.14)/3.14 < .001) @@ -2848,7 +2848,7 @@ mono_test_marshal_variant_in_float(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_double(VARIANT variant) { if (variant.vt == VT_R8 && (variant.dblVal - 3.14)/3.14 < .001) @@ -2856,7 +2856,7 @@ mono_test_marshal_variant_in_double(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_bstr(VARIANT variant) { gint32 result = 0; @@ -2869,7 +2869,7 @@ mono_test_marshal_variant_in_bstr(VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_bool_true (VARIANT variant) { if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_TRUE) @@ -2877,7 +2877,7 @@ mono_test_marshal_variant_in_bool_true (VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_bool_false (VARIANT variant) { if (variant.vt == VT_BOOL && variant.boolVal == VARIANT_FALSE) @@ -2885,7 +2885,7 @@ mono_test_marshal_variant_in_bool_false (VARIANT variant) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_sbyte(VARIANT* variant) { variant->vt = VT_I1; @@ -2894,7 +2894,7 @@ mono_test_marshal_variant_out_sbyte(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_sbyte_byref(VARIANT* variant) { variant->vt = VT_I1|VT_BYREF; @@ -2904,18 +2904,18 @@ mono_test_marshal_variant_out_sbyte_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_byte(VARIANT* variant) -{ +{ variant->vt = VT_UI1; variant->bVal = 100; return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_byte_byref(VARIANT* variant) -{ +{ variant->vt = VT_UI1|VT_BYREF; variant->byref = marshal_alloc(1); *((gint8*)variant->byref) = 100; @@ -2923,7 +2923,7 @@ mono_test_marshal_variant_out_byte_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_short(VARIANT* variant) { variant->vt = VT_I2; @@ -2932,7 +2932,7 @@ mono_test_marshal_variant_out_short(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_short_byref(VARIANT* variant) { variant->vt = VT_I2|VT_BYREF; @@ -2942,7 +2942,7 @@ mono_test_marshal_variant_out_short_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_ushort(VARIANT* variant) { variant->vt = VT_UI2; @@ -2951,7 +2951,7 @@ mono_test_marshal_variant_out_ushort(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_ushort_byref(VARIANT* variant) { variant->vt = VT_UI2|VT_BYREF; @@ -2961,7 +2961,7 @@ mono_test_marshal_variant_out_ushort_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_int(VARIANT* variant) { variant->vt = VT_I4; @@ -2970,7 +2970,7 @@ mono_test_marshal_variant_out_int(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_int_byref(VARIANT* variant) { variant->vt = VT_I4|VT_BYREF; @@ -2980,7 +2980,7 @@ mono_test_marshal_variant_out_int_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_uint(VARIANT* variant) { variant->vt = VT_UI4; @@ -2989,7 +2989,7 @@ mono_test_marshal_variant_out_uint(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_uint_byref(VARIANT* variant) { variant->vt = VT_UI4|VT_BYREF; @@ -2999,7 +2999,7 @@ mono_test_marshal_variant_out_uint_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_long(VARIANT* variant) { variant->vt = VT_I8; @@ -3008,7 +3008,7 @@ mono_test_marshal_variant_out_long(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_long_byref(VARIANT* variant) { variant->vt = VT_I8|VT_BYREF; @@ -3018,7 +3018,7 @@ mono_test_marshal_variant_out_long_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_ulong(VARIANT* variant) { variant->vt = VT_UI8; @@ -3027,7 +3027,7 @@ mono_test_marshal_variant_out_ulong(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_ulong_byref(VARIANT* variant) { variant->vt = VT_UI8|VT_BYREF; @@ -3037,7 +3037,7 @@ mono_test_marshal_variant_out_ulong_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_float(VARIANT* variant) { variant->vt = VT_R4; @@ -3046,7 +3046,7 @@ mono_test_marshal_variant_out_float(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_float_byref(VARIANT* variant) { variant->vt = VT_R4|VT_BYREF; @@ -3056,7 +3056,7 @@ mono_test_marshal_variant_out_float_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_double(VARIANT* variant) { variant->vt = VT_R8; @@ -3065,7 +3065,7 @@ mono_test_marshal_variant_out_double(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_double_byref(VARIANT* variant) { variant->vt = VT_R8|VT_BYREF; @@ -3075,7 +3075,7 @@ mono_test_marshal_variant_out_double_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bstr(VARIANT* variant) { variant->vt = VT_BSTR; @@ -3084,7 +3084,7 @@ mono_test_marshal_variant_out_bstr(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bstr_byref(VARIANT* variant) { variant->vt = VT_BSTR|VT_BYREF; @@ -3094,7 +3094,7 @@ mono_test_marshal_variant_out_bstr_byref(VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bool_true (VARIANT* variant) { variant->vt = VT_BOOL; @@ -3103,7 +3103,7 @@ mono_test_marshal_variant_out_bool_true (VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bool_true_byref (VARIANT* variant) { variant->vt = VT_BOOL|VT_BYREF; @@ -3113,7 +3113,7 @@ mono_test_marshal_variant_out_bool_true_byref (VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bool_false (VARIANT* variant) { variant->vt = VT_BOOL; @@ -3122,7 +3122,7 @@ mono_test_marshal_variant_out_bool_false (VARIANT* variant) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bool_false_byref (VARIANT* variant) { variant->vt = VT_BOOL|VT_BYREF; @@ -3135,7 +3135,7 @@ mono_test_marshal_variant_out_bool_false_byref (VARIANT* variant) typedef int (STDCALL *VarFunc) (int vt, VARIANT variant); typedef int (STDCALL *VarRefFunc) (int vt, VARIANT* variant); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func) { VARIANT vt; @@ -3144,7 +3144,7 @@ mono_test_marshal_variant_in_sbyte_unmanaged(VarFunc func) return func (VT_I1, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_byte_unmanaged(VarFunc func) { VARIANT vt; @@ -3153,7 +3153,7 @@ mono_test_marshal_variant_in_byte_unmanaged(VarFunc func) return func (VT_UI1, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_short_unmanaged(VarFunc func) { VARIANT vt; @@ -3162,7 +3162,7 @@ mono_test_marshal_variant_in_short_unmanaged(VarFunc func) return func (VT_I2, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func) { VARIANT vt; @@ -3171,7 +3171,7 @@ mono_test_marshal_variant_in_ushort_unmanaged(VarFunc func) return func (VT_UI2, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_int_unmanaged(VarFunc func) { VARIANT vt; @@ -3180,7 +3180,7 @@ mono_test_marshal_variant_in_int_unmanaged(VarFunc func) return func (VT_I4, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_uint_unmanaged(VarFunc func) { VARIANT vt; @@ -3189,7 +3189,7 @@ mono_test_marshal_variant_in_uint_unmanaged(VarFunc func) return func (VT_UI4, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_long_unmanaged(VarFunc func) { VARIANT vt; @@ -3198,7 +3198,7 @@ mono_test_marshal_variant_in_long_unmanaged(VarFunc func) return func (VT_I8, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func) { VARIANT vt; @@ -3207,7 +3207,7 @@ mono_test_marshal_variant_in_ulong_unmanaged(VarFunc func) return func (VT_UI8, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_float_unmanaged(VarFunc func) { VARIANT vt; @@ -3216,7 +3216,7 @@ mono_test_marshal_variant_in_float_unmanaged(VarFunc func) return func (VT_R4, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_double_unmanaged(VarFunc func) { VARIANT vt; @@ -3225,7 +3225,7 @@ mono_test_marshal_variant_in_double_unmanaged(VarFunc func) return func (VT_R8, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func) { VARIANT vt; @@ -3234,7 +3234,7 @@ mono_test_marshal_variant_in_bstr_unmanaged(VarFunc func) return func (VT_BSTR, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func) { VARIANT vt; @@ -3243,7 +3243,7 @@ mono_test_marshal_variant_in_bool_true_unmanaged(VarFunc func) return func (VT_BOOL, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func) { VARIANT vt; @@ -3252,7 +3252,7 @@ mono_test_marshal_variant_in_bool_false_unmanaged(VarFunc func) return func (VT_BOOL, vt); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3263,7 +3263,7 @@ mono_test_marshal_variant_out_sbyte_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3274,7 +3274,7 @@ mono_test_marshal_variant_out_byte_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3285,7 +3285,7 @@ mono_test_marshal_variant_out_short_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3296,7 +3296,7 @@ mono_test_marshal_variant_out_ushort_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3307,7 +3307,7 @@ mono_test_marshal_variant_out_int_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3318,7 +3318,7 @@ mono_test_marshal_variant_out_uint_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3329,7 +3329,7 @@ mono_test_marshal_variant_out_long_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3340,7 +3340,7 @@ mono_test_marshal_variant_out_ulong_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3351,7 +3351,7 @@ mono_test_marshal_variant_out_float_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3362,7 +3362,7 @@ mono_test_marshal_variant_out_double_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3380,7 +3380,7 @@ mono_test_marshal_variant_out_bstr_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3391,7 +3391,7 @@ mono_test_marshal_variant_out_bool_true_unmanaged(VarRefFunc func) return 1; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_variant_out_bool_false_unmanaged(VarRefFunc func) { VARIANT vt; @@ -3407,7 +3407,7 @@ typedef struct _StructWithVariant { } StructWithVariant; typedef int (STDCALL *CheckStructWithVariantFunc) (StructWithVariant sv); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_struct_with_variant_in_unmanaged(CheckStructWithVariantFunc func) { StructWithVariant sv; @@ -3431,7 +3431,7 @@ typedef struct _StructWithBstr { } StructWithBstr; typedef int (STDCALL *CheckStructWithBstrFunc) (StructWithBstr sb); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_struct_with_bstr_in_unmanaged(CheckStructWithBstrFunc func) { StructWithBstr sb; @@ -3525,85 +3525,85 @@ MonoQueryInterface(MonoComObject* pUnk, gpointer riid, gpointer* ppv) return 0x80004002; //E_NOINTERFACE; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL MonoAddRef(MonoComObject* pUnk) { return ++(pUnk->m_ref); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL MonoRelease(MonoComObject* pUnk) { return --(pUnk->m_ref); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL SByteIn(MonoComObject* pUnk, char a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL ByteIn(MonoComObject* pUnk, unsigned char a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL ShortIn(MonoComObject* pUnk, short a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL UShortIn(MonoComObject* pUnk, unsigned short a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL IntIn(MonoComObject* pUnk, int a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL UIntIn(MonoComObject* pUnk, unsigned int a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL LongIn(MonoComObject* pUnk, gint64 a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL ULongIn(MonoComObject* pUnk, guint64 a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL FloatIn(MonoComObject* pUnk, float a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL DoubleIn(MonoComObject* pUnk, double a) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL ITestIn(MonoComObject* pUnk, MonoComObject *pUnk2) { return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL ITestOut(MonoComObject* pUnk, MonoComObject* *ppUnk) { return S_OK; @@ -3659,7 +3659,7 @@ GetDefInterface2(MonoComObject* pUnk, MonoDefItfObject **obj) static void create_com_object (MonoComObject** pOut); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL get_ITest(MonoComObject* pUnk, MonoComObject* *ppUnk) { create_com_object (ppUnk); @@ -3700,7 +3700,7 @@ static void create_com_object (MonoComObject** pOut) static MonoComObject* same_object = NULL; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_com_object_create(MonoComObject* *pUnk) { create_com_object (pUnk); @@ -3711,7 +3711,7 @@ mono_test_marshal_com_object_create(MonoComObject* *pUnk) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_com_object_same(MonoComObject* *pUnk) { *pUnk = same_object; @@ -3719,7 +3719,7 @@ mono_test_marshal_com_object_same(MonoComObject* *pUnk) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_com_object_destroy(MonoComObject *pUnk) { int ref = --(pUnk->m_ref); @@ -3729,13 +3729,13 @@ mono_test_marshal_com_object_destroy(MonoComObject *pUnk) return ref; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_com_object_ref_count(MonoComObject *pUnk) { return pUnk->m_ref; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_ccw_itest (MonoComObject *pUnk) { int hr = 0; @@ -3912,7 +3912,7 @@ mono_test_marshal_lookup_symbol (const char *symbol_name) * @test_method_handle: MonoMethod* of the C# test method * @create_object_method_handle: MonoMethod* of thunks.cs:Test.CreateObject */ -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_object_method_handle) { int ret = 0; @@ -3941,7 +3941,7 @@ test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_obj void (*mono_threads_exit_gc_unsafe_region) (gpointer, gpointer) = (void (*)(gpointer, gpointer))lookup_mono_symbol ("mono_threads_exit_gc_unsafe_region"); - + gpointer test_method, ex = NULL; gpointer (STDCALL *CreateObject)(gpointer*); @@ -3964,7 +3964,7 @@ test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_obj ret = 3; goto done; } - + switch (test_id) { @@ -4321,7 +4321,7 @@ test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_obj ret = 5; goto done; } - + a1 = (TestStruct *)mono_object_unbox (obj); if (!a1) { @@ -4363,12 +4363,12 @@ test_method_thunk (int test_id, gpointer test_method_handle, gpointer create_obj return ret; } -typedef struct +typedef struct { char a; } winx64_struct1; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_struct1_in (winx64_struct1 var) { if (var.a != 123) @@ -4382,7 +4382,7 @@ typedef struct char b; } winx64_struct2; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_struct2_in (winx64_struct2 var) { if (var.a != 4) @@ -4400,7 +4400,7 @@ typedef struct short c; } winx64_struct3; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_struct3_in (winx64_struct3 var) { if (var.a != 4) @@ -4420,7 +4420,7 @@ typedef struct unsigned int d; } winx64_struct4; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_struct4_in (winx64_struct4 var) { if (var.a != 4) @@ -4441,7 +4441,7 @@ typedef struct char c; } winx64_struct5; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_struct5_in (winx64_struct5 var) { if (var.a != 4) @@ -4460,7 +4460,7 @@ typedef struct char c; } winx64_struct6; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_struct6_in (winx64_struct6 var) { if (var.a.a != 4) @@ -4472,7 +4472,7 @@ mono_test_Winx64_struct6_in (winx64_struct6 var) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_structs_in1 (winx64_struct1 var1, winx64_struct2 var2, winx64_struct3 var3, @@ -4480,19 +4480,19 @@ mono_test_Winx64_structs_in1 (winx64_struct1 var1, { if (var1.a != 123) return 1; - + if (var2.a != 4) return 2; if (var2.b != 5) return 3; - + if (var3.a != 4) return 4; if (var3.b != 5) return 2; if (var3.c != 0x1234) return 5; - + if (var4.a != 4) return 6; if (var4.b != 5) @@ -4504,7 +4504,7 @@ mono_test_Winx64_structs_in1 (winx64_struct1 var1, return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_structs_in2 (winx64_struct1 var1, winx64_struct1 var2, winx64_struct1 var3, @@ -4521,11 +4521,11 @@ mono_test_Winx64_structs_in2 (winx64_struct1 var1, return 4; if (var5.a != 5) return 5; - + return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_structs_in3 (winx64_struct1 var1, winx64_struct5 var2, winx64_struct1 var3, @@ -4535,24 +4535,24 @@ mono_test_Winx64_structs_in3 (winx64_struct1 var1, { if (var1.a != 1) return 1; - + if (var2.a != 2) return 2; if (var2.b != 3) return 2; if (var2.c != 4) return 4; - + if (var3.a != 5) return 5; - + if (var4.a != 6) return 6; if (var4.b != 7) return 7; if (var4.c != 8) return 8; - + if (var5.a != 9) return 9; @@ -4562,11 +4562,11 @@ mono_test_Winx64_structs_in3 (winx64_struct1 var1, return 11; if (var6.c != 12) return 12; - + return 0; } -LIBTEST_API winx64_struct1 STDCALL +LIBTEST_API winx64_struct1 STDCALL mono_test_Winx64_struct1_ret (void) { winx64_struct1 ret; @@ -4574,7 +4574,7 @@ mono_test_Winx64_struct1_ret (void) return ret; } -LIBTEST_API winx64_struct2 STDCALL +LIBTEST_API winx64_struct2 STDCALL mono_test_Winx64_struct2_ret (void) { winx64_struct2 ret; @@ -4583,7 +4583,7 @@ mono_test_Winx64_struct2_ret (void) return ret; } -LIBTEST_API winx64_struct3 STDCALL +LIBTEST_API winx64_struct3 STDCALL mono_test_Winx64_struct3_ret (void) { winx64_struct3 ret; @@ -4593,7 +4593,7 @@ mono_test_Winx64_struct3_ret (void) return ret; } -LIBTEST_API winx64_struct4 STDCALL +LIBTEST_API winx64_struct4 STDCALL mono_test_Winx64_struct4_ret (void) { winx64_struct4 ret; @@ -4604,7 +4604,7 @@ mono_test_Winx64_struct4_ret (void) return ret; } -LIBTEST_API winx64_struct5 STDCALL +LIBTEST_API winx64_struct5 STDCALL mono_test_Winx64_struct5_ret (void) { winx64_struct5 ret; @@ -4614,7 +4614,7 @@ mono_test_Winx64_struct5_ret (void) return ret; } -LIBTEST_API winx64_struct1 STDCALL +LIBTEST_API winx64_struct1 STDCALL mono_test_Winx64_struct1_ret_5_args (char a, char b, char c, char d, char e) { winx64_struct1 ret; @@ -4638,7 +4638,7 @@ typedef struct float b; } winx64_floatStruct; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_floatStruct (winx64_floatStruct a) { if (a.a > 5.6 || a.a < 5.4) @@ -4646,7 +4646,7 @@ mono_test_Winx64_floatStruct (winx64_floatStruct a) if (a.b > 9.6 || a.b < 9.4) return 2; - + return 0; } @@ -4655,18 +4655,18 @@ typedef struct double a; } winx64_doubleStruct; -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_doubleStruct (winx64_doubleStruct a) { if (a.a > 5.6 || a.a < 5.4) return 1; - + return 0; } typedef int (STDCALL *managed_struct1_delegate) (winx64_struct1 a); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func) { winx64_struct1 val; @@ -4676,7 +4676,7 @@ mono_test_managed_Winx64_struct1_in(managed_struct1_delegate func) typedef int (STDCALL *managed_struct5_delegate) (winx64_struct5 a); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_managed_Winx64_struct5_in(managed_struct5_delegate func) { winx64_struct5 val; @@ -4690,7 +4690,7 @@ typedef int (STDCALL *managed_struct1_struct5_delegate) (winx64_struct1 a, winx6 winx64_struct1 c, winx64_struct5 d, winx64_struct1 e, winx64_struct5 f); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate func) { winx64_struct1 a, c, e; @@ -4707,7 +4707,7 @@ mono_test_managed_Winx64_struct1_struct5_in(managed_struct1_struct5_delegate fun typedef winx64_struct1 (STDCALL *managed_struct1_ret_delegate) (void); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func) { winx64_struct1 ret; @@ -4716,13 +4716,13 @@ mono_test_Winx64_struct1_ret_managed (managed_struct1_ret_delegate func) if (ret.a != 0x45) return 1; - + return 0; } typedef winx64_struct5 (STDCALL *managed_struct5_ret_delegate) (void); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func) { winx64_struct5 ret; @@ -4735,112 +4735,112 @@ mono_test_Winx64_struct5_ret_managed (managed_struct5_ret_delegate func) return 2; if (ret.c != 0x56) return 3; - + return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bool_in (int arg, unsigned int expected, unsigned int bDefaultMarsh, unsigned int bBoolCustMarsh, char bI1CustMarsh, unsigned char bU1CustMarsh, short bVBCustMarsh) { switch (arg) { - case 1: + case 1: if (bDefaultMarsh != expected) return 1; break; - case 2: + case 2: if (bBoolCustMarsh != expected) return 2; break; - case 3: + case 3: if (bI1CustMarsh != expected) return 3; break; - case 4: + case 4: if (bU1CustMarsh != expected) return 4; break; - case 5: + case 5: if (bVBCustMarsh != expected) return 5; break; default: - return 999; + return 999; } return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bool_out (int arg, unsigned int testVal, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh) { switch (arg) { - case 1: + case 1: if (!bDefaultMarsh) return 1; *bDefaultMarsh = testVal; - break; - case 2: + break; + case 2: if (!bBoolCustMarsh) return 2; *bBoolCustMarsh = testVal; - break; - case 3: + break; + case 3: if (!bI1CustMarsh) return 3; *bI1CustMarsh = (char)testVal; - break; - case 4: + break; + case 4: if (!bU1CustMarsh) return 4; *bU1CustMarsh = (unsigned char)testVal; - break; - case 5: + break; + case 5: if (!bVBCustMarsh) return 5; *bVBCustMarsh = (unsigned short)testVal; - break; + break; default: return 999; } return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh, - unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, + unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh) { switch (arg) { - case 1: + case 1: if (!bDefaultMarsh) return 1; if (*bDefaultMarsh != expected) return 2; *bDefaultMarsh = testVal; break; - case 2: + case 2: if (!bBoolCustMarsh) return 3; if (*bBoolCustMarsh != expected) return 4; *bBoolCustMarsh = testVal; break; - case 3: + case 3: if (!bI1CustMarsh) return 5; if (*bI1CustMarsh != expected) return 6; *bI1CustMarsh = (char)testVal; break; - case 4: + case 4: if (!bU1CustMarsh) return 7; if (*bU1CustMarsh != expected) return 8; *bU1CustMarsh = (unsigned char)testVal; break; - case 5: + case 5: if (!bVBCustMarsh) return 9; if (*bVBCustMarsh != expected) @@ -4848,7 +4848,7 @@ mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal *bVBCustMarsh = (unsigned short)testVal; break; default: - return 999; + return 999; } return 0; } @@ -4857,7 +4857,7 @@ mono_test_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal typedef int (STDCALL *MarshalBoolInDelegate) (int arg, unsigned int expected, unsigned int bDefaultMarsh, unsigned int bBoolCustMarsh, char bI1CustMarsh, unsigned char bU1CustMarsh, unsigned short bVBCustMarsh); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_managed_marshal_bool_in (int arg, unsigned int expected, unsigned int testVal, MarshalBoolInDelegate pfcn) { if (!pfcn) @@ -4884,7 +4884,7 @@ mono_test_managed_marshal_bool_in (int arg, unsigned int expected, unsigned int typedef int (STDCALL *MarshalBoolOutDelegate) (int arg, unsigned int expected, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_managed_marshal_bool_out (int arg, unsigned int expected, unsigned int testVal, MarshalBoolOutDelegate pfcn) { int ret; @@ -4953,7 +4953,7 @@ mono_test_managed_marshal_bool_out (int arg, unsigned int expected, unsigned int typedef int (STDCALL *MarshalBoolRefDelegate) (int arg, unsigned int expected, unsigned int testVal, unsigned int* bDefaultMarsh, unsigned int* bBoolCustMarsh, char* bI1CustMarsh, unsigned char* bU1CustMarsh, unsigned short* bVBCustMarsh); -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_managed_marshal_bool_ref (int arg, unsigned int expected, unsigned int testVal, unsigned int outExpected, unsigned int outTestVal, MarshalBoolRefDelegate pfcn) { @@ -5027,7 +5027,7 @@ mono_test_managed_marshal_bool_ref (int arg, unsigned int expected, unsigned int #ifdef WIN32 -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY** safearray) { /* Create an empty one-dimensional array of variants */ @@ -5042,7 +5042,7 @@ mono_test_marshal_safearray_out_1dim_vt_bstr_empty (SAFEARRAY** safearray) return S_OK; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY** safearray) { /* Create a one-dimensional array of 10 variants filled with "0" to "9" */ @@ -5075,7 +5075,7 @@ mono_test_marshal_safearray_out_1dim_vt_bstr (SAFEARRAY** safearray) return hr; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY** safearray) { /* Create a two-dimensional array of 4x3 variants filled with 11, 12, 13, etc. */ @@ -5104,14 +5104,14 @@ mono_test_marshal_safearray_out_2dim_vt_i4 (SAFEARRAY** safearray) SafeArrayDestroy (pSA); return hr; } - VariantClear (&vOut); // does a deep destroy of source VARIANT + VariantClear (&vOut); // does a deep destroy of source VARIANT } } *safearray = pSA; return hr; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY** safearray) { /* Create a four-dimensional array of 10x3x6x7 variants filled with their indices */ @@ -5145,14 +5145,14 @@ mono_test_marshal_safearray_out_4dim_vt_i4 (SAFEARRAY** safearray) return hr; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY* safearray) { /* Check that array is one dimensional and empty */ UINT dim; long lbound, ubound; - + dim = SafeArrayGetDim (safearray); if (dim != 1) return 1; @@ -5166,14 +5166,14 @@ mono_test_marshal_safearray_in_byval_1dim_empty (SAFEARRAY* safearray) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY* safearray) { /* Check that array is one dimensional containing integers from 1 to 10 */ UINT dim; long lbound, ubound; - VARIANT *pData; + VARIANT *pData; long i; int result=0; @@ -5197,14 +5197,14 @@ mono_test_marshal_safearray_in_byval_1dim_vt_i4 (SAFEARRAY* safearray) return result; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY* safearray) { /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */ UINT dim; long lbound, ubound; - VARIANT *pData; + VARIANT *pData; long i; long indices [1]; VARIANT element; @@ -5218,7 +5218,7 @@ mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY* safearray) SafeArrayGetLBound (safearray, 1, &lbound); SafeArrayGetUBound (safearray, 1, &ubound); - + if ((lbound != 0) || (ubound != 12)) return 1; @@ -5244,7 +5244,7 @@ mono_test_marshal_safearray_in_byval_1dim_vt_mixed (SAFEARRAY* safearray) return result; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY* safearray) { /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */ @@ -5299,7 +5299,7 @@ mono_test_marshal_safearray_in_byval_2dim_vt_i4 (SAFEARRAY* safearray) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY* safearray) { /* Check that array is one dimensional containing integers mixed with strings from 0 to 12 */ @@ -5342,8 +5342,8 @@ mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY* safearray) indices [2] = k; if (SafeArrayGetElement (safearray, indices, &element) != S_OK) return 1; - failed = ((element.vt != VT_BSTR) - || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) + failed = ((element.vt != VT_BSTR) + || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (element.lVal != 100*(i+1)+10*(j+1)+(k+1))); VariantClear (&element); if (failed) @@ -5365,13 +5365,13 @@ mono_test_marshal_safearray_in_byval_3dim_vt_bstr (SAFEARRAY* safearray) return 0; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_byref_3dim_vt_bstr (SAFEARRAY** safearray) { return mono_test_marshal_safearray_in_byval_3dim_vt_bstr (*safearray); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY** safearray) { /* Check that the input array is what is expected and change it so the caller can check */ @@ -5394,7 +5394,7 @@ mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY** safearray) SafeArrayGetLBound (*safearray, 1, &lbound); SafeArrayGetUBound (*safearray, 1, &ubound); - + if ((lbound > 0) || (ubound > 0)) { return 1; } @@ -5425,7 +5425,7 @@ mono_test_marshal_safearray_in_out_byref_1dim_empty (SAFEARRAY** safearray) return hr; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY** safearray) { /* Check that the input array is what is expected and change it so the caller can check */ @@ -5474,8 +5474,8 @@ mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY** safearray) indices [2] = k; if (SafeArrayGetElement (*safearray, indices, &element) != S_OK) return 1; - failed = ((element.vt != VT_BSTR) - || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) + failed = ((element.vt != VT_BSTR) + || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (element.lVal != 100*(i+1)+10*(j+1)+(k+1))); VariantClear (&element); if (failed) @@ -5512,7 +5512,7 @@ mono_test_marshal_safearray_in_out_byref_3dim_vt_bstr (SAFEARRAY** safearray) return hr; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY** safearray) { /* Check that the input array is what is expected and change it so the caller can check */ @@ -5524,7 +5524,7 @@ mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY** safearray) HRESULT hr = S_OK; long indices [1]; VARIANT element; - + VariantInit (&element); /* Check that in array is one dimensional and contains the expected value */ @@ -5562,7 +5562,7 @@ mono_test_marshal_safearray_in_out_byref_1dim_vt_i4 (SAFEARRAY** safearray) return hr; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY* safearray) { /* Check that the input array is what is expected and change it so the caller can check */ @@ -5586,7 +5586,7 @@ mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY* safearray) SafeArrayGetLBound (safearray, 1, &lbound1); SafeArrayGetUBound (safearray, 1, &ubound1); - + if ((lbound1 != 0) || (ubound1 != 0)) return 1; @@ -5622,7 +5622,7 @@ mono_test_marshal_safearray_in_out_byval_1dim_vt_i4 (SAFEARRAY* safearray) return hr; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY* safearray) { /* Check that the input array is what is expected and change it so the caller can check */ @@ -5669,8 +5669,8 @@ mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY* safearray) indices [2] = k; if (SafeArrayGetElement (safearray, indices, &element) != S_OK) return 1; - failed = ((element.vt != VT_BSTR) - || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) + failed = ((element.vt != VT_BSTR) + || (VariantChangeType (&element, &element, VARIANT_NOUSEROVERRIDE, VT_I4) != S_OK) || (element.lVal != 100*(i+1)+10*(j+1)+(k+1))); VariantClear (&element); if (failed) @@ -5708,7 +5708,7 @@ mono_test_marshal_safearray_in_out_byval_3dim_vt_bstr (SAFEARRAY* safearray) return hr; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_safearray_mixed( SAFEARRAY *safearray1, SAFEARRAY **safearray2, @@ -5805,7 +5805,7 @@ call_managed (gpointer arg) call_managed_res = del (42); } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_thread_attach (SimpleDelegate del) { #ifdef WIN32 @@ -5858,13 +5858,13 @@ typedef int (STDCALL *Callback) (void); static Callback callback; -LIBTEST_API void STDCALL +LIBTEST_API void STDCALL mono_test_marshal_set_callback (Callback cb) { callback = cb; } -LIBTEST_API int STDCALL +LIBTEST_API int STDCALL mono_test_marshal_call_callback (void) { return callback (); @@ -6016,7 +6016,7 @@ mono_return_sbyte1 (sbyte1 s1, int addend) { if (s1.f1 != 1) { fprintf(stderr, "mono_return_sbyte1 s1.f1: got %d but expected %d\n", s1.f1, 1); } - s1.f1+=addend; + s1.f1+=addend; return s1; } @@ -6032,7 +6032,7 @@ mono_return_sbyte2 (sbyte2 s2, int addend) { if (s2.f2 != 2) { fprintf(stderr, "mono_return_sbyte2 s2.f2: got %d but expected %d\n", s2.f2, 2); } - s2.f1+=addend; s2.f2+=addend; + s2.f1+=addend; s2.f2+=addend; return s2; } @@ -6051,7 +6051,7 @@ mono_return_sbyte3 (sbyte3 s3, int addend) { if (s3.f3 != 3) { fprintf(stderr, "mono_return_sbyte3 s3.f3: got %d but expected %d\n", s3.f3, 3); } - s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; + s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; return s3; } @@ -6073,7 +6073,7 @@ mono_return_sbyte4 (sbyte4 s4, int addend) { if (s4.f4 != 4) { fprintf(stderr, "mono_return_sbyte4 s4.f4: got %d but expected %d\n", s4.f4, 4); } - s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; + s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; return s4; } @@ -6098,7 +6098,7 @@ mono_return_sbyte5 (sbyte5 s5, int addend) { if (s5.f5 != 5) { fprintf(stderr, "mono_return_sbyte5 s5.f5: got %d but expected %d\n", s5.f5, 5); } - s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; + s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; return s5; } @@ -6126,7 +6126,7 @@ mono_return_sbyte6 (sbyte6 s6, int addend) { if (s6.f6 != 6) { fprintf(stderr, "mono_return_sbyte6 s6.f6: got %d but expected %d\n", s6.f6, 6); } - s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend; + s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend; return s6; } @@ -6157,7 +6157,7 @@ mono_return_sbyte7 (sbyte7 s7, int addend) { if (s7.f7 != 7) { fprintf(stderr, "mono_return_sbyte7 s7.f7: got %d but expected %d\n", s7.f7, 7); } - s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend; + s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend; return s7; } @@ -6191,7 +6191,7 @@ mono_return_sbyte8 (sbyte8 s8, int addend) { if (s8.f8 != 8) { fprintf(stderr, "mono_return_sbyte8 s8.f8: got %d but expected %d\n", s8.f8, 8); } - s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend; + s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend; return s8; } @@ -6228,7 +6228,7 @@ mono_return_sbyte9 (sbyte9 s9, int addend) { if (s9.f9 != 9) { fprintf(stderr, "mono_return_sbyte9 s9.f9: got %d but expected %d\n", s9.f9, 9); } - s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend; + s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend; return s9; } @@ -6268,7 +6268,7 @@ mono_return_sbyte10 (sbyte10 s10, int addend) { if (s10.f10 != 10) { fprintf(stderr, "mono_return_sbyte10 s10.f10: got %d but expected %d\n", s10.f10, 10); } - s10.f1+=addend; s10.f2+=addend; s10.f3+=addend; s10.f4+=addend; s10.f5+=addend; s10.f6+=addend; s10.f7+=addend; s10.f8+=addend; s10.f9+=addend; s10.f10+=addend; + s10.f1+=addend; s10.f2+=addend; s10.f3+=addend; s10.f4+=addend; s10.f5+=addend; s10.f6+=addend; s10.f7+=addend; s10.f8+=addend; s10.f9+=addend; s10.f10+=addend; return s10; } @@ -6311,7 +6311,7 @@ mono_return_sbyte11 (sbyte11 s11, int addend) { if (s11.f11 != 11) { fprintf(stderr, "mono_return_sbyte11 s11.f11: got %d but expected %d\n", s11.f11, 11); } - s11.f1+=addend; s11.f2+=addend; s11.f3+=addend; s11.f4+=addend; s11.f5+=addend; s11.f6+=addend; s11.f7+=addend; s11.f8+=addend; s11.f9+=addend; s11.f10+=addend; s11.f11+=addend; + s11.f1+=addend; s11.f2+=addend; s11.f3+=addend; s11.f4+=addend; s11.f5+=addend; s11.f6+=addend; s11.f7+=addend; s11.f8+=addend; s11.f9+=addend; s11.f10+=addend; s11.f11+=addend; return s11; } @@ -6357,7 +6357,7 @@ mono_return_sbyte12 (sbyte12 s12, int addend) { if (s12.f12 != 12) { fprintf(stderr, "mono_return_sbyte12 s12.f12: got %d but expected %d\n", s12.f12, 12); } - s12.f1+=addend; s12.f2+=addend; s12.f3+=addend; s12.f4+=addend; s12.f5+=addend; s12.f6+=addend; s12.f7+=addend; s12.f8+=addend; s12.f9+=addend; s12.f10+=addend; s12.f11+=addend; s12.f12+=addend; + s12.f1+=addend; s12.f2+=addend; s12.f3+=addend; s12.f4+=addend; s12.f5+=addend; s12.f6+=addend; s12.f7+=addend; s12.f8+=addend; s12.f9+=addend; s12.f10+=addend; s12.f11+=addend; s12.f12+=addend; return s12; } @@ -6406,7 +6406,7 @@ mono_return_sbyte13 (sbyte13 s13, int addend) { if (s13.f13 != 13) { fprintf(stderr, "mono_return_sbyte13 s13.f13: got %d but expected %d\n", s13.f13, 13); } - s13.f1+=addend; s13.f2+=addend; s13.f3+=addend; s13.f4+=addend; s13.f5+=addend; s13.f6+=addend; s13.f7+=addend; s13.f8+=addend; s13.f9+=addend; s13.f10+=addend; s13.f11+=addend; s13.f12+=addend; s13.f13+=addend; + s13.f1+=addend; s13.f2+=addend; s13.f3+=addend; s13.f4+=addend; s13.f5+=addend; s13.f6+=addend; s13.f7+=addend; s13.f8+=addend; s13.f9+=addend; s13.f10+=addend; s13.f11+=addend; s13.f12+=addend; s13.f13+=addend; return s13; } @@ -6458,7 +6458,7 @@ mono_return_sbyte14 (sbyte14 s14, int addend) { if (s14.f14 != 14) { fprintf(stderr, "mono_return_sbyte14 s14.f14: got %d but expected %d\n", s14.f14, 14); } - s14.f1+=addend; s14.f2+=addend; s14.f3+=addend; s14.f4+=addend; s14.f5+=addend; s14.f6+=addend; s14.f7+=addend; s14.f8+=addend; s14.f9+=addend; s14.f10+=addend; s14.f11+=addend; s14.f12+=addend; s14.f13+=addend; s14.f14+=addend; + s14.f1+=addend; s14.f2+=addend; s14.f3+=addend; s14.f4+=addend; s14.f5+=addend; s14.f6+=addend; s14.f7+=addend; s14.f8+=addend; s14.f9+=addend; s14.f10+=addend; s14.f11+=addend; s14.f12+=addend; s14.f13+=addend; s14.f14+=addend; return s14; } @@ -6513,7 +6513,7 @@ mono_return_sbyte15 (sbyte15 s15, int addend) { if (s15.f15 != 15) { fprintf(stderr, "mono_return_sbyte15 s15.f15: got %d but expected %d\n", s15.f15, 15); } - s15.f1+=addend; s15.f2+=addend; s15.f3+=addend; s15.f4+=addend; s15.f5+=addend; s15.f6+=addend; s15.f7+=addend; s15.f8+=addend; s15.f9+=addend; s15.f10+=addend; s15.f11+=addend; s15.f12+=addend; s15.f13+=addend; s15.f14+=addend; s15.f15+=addend; + s15.f1+=addend; s15.f2+=addend; s15.f3+=addend; s15.f4+=addend; s15.f5+=addend; s15.f6+=addend; s15.f7+=addend; s15.f8+=addend; s15.f9+=addend; s15.f10+=addend; s15.f11+=addend; s15.f12+=addend; s15.f13+=addend; s15.f14+=addend; s15.f15+=addend; return s15; } @@ -6571,7 +6571,7 @@ mono_return_sbyte16 (sbyte16 s16, int addend) { if (s16.f16 != 16) { fprintf(stderr, "mono_return_sbyte16 s16.f16: got %d but expected %d\n", s16.f16, 16); } - s16.f1+=addend; s16.f2+=addend; s16.f3+=addend; s16.f4+=addend; s16.f5+=addend; s16.f6+=addend; s16.f7+=addend; s16.f8+=addend; s16.f9+=addend; s16.f10+=addend; s16.f11+=addend; s16.f12+=addend; s16.f13+=addend; s16.f14+=addend; s16.f15+=addend; s16.f16+=addend; + s16.f1+=addend; s16.f2+=addend; s16.f3+=addend; s16.f4+=addend; s16.f5+=addend; s16.f6+=addend; s16.f7+=addend; s16.f8+=addend; s16.f9+=addend; s16.f10+=addend; s16.f11+=addend; s16.f12+=addend; s16.f13+=addend; s16.f14+=addend; s16.f15+=addend; s16.f16+=addend; return s16; } @@ -6632,7 +6632,7 @@ mono_return_sbyte17 (sbyte17 s17, int addend) { if (s17.f17 != 17) { fprintf(stderr, "mono_return_sbyte17 s17.f17: got %d but expected %d\n", s17.f17, 17); } - s17.f1+=addend; s17.f2+=addend; s17.f3+=addend; s17.f4+=addend; s17.f5+=addend; s17.f6+=addend; s17.f7+=addend; s17.f8+=addend; s17.f9+=addend; s17.f10+=addend; s17.f11+=addend; s17.f12+=addend; s17.f13+=addend; s17.f14+=addend; s17.f15+=addend; s17.f16+=addend; s17.f17+=addend; + s17.f1+=addend; s17.f2+=addend; s17.f3+=addend; s17.f4+=addend; s17.f5+=addend; s17.f6+=addend; s17.f7+=addend; s17.f8+=addend; s17.f9+=addend; s17.f10+=addend; s17.f11+=addend; s17.f12+=addend; s17.f13+=addend; s17.f14+=addend; s17.f15+=addend; s17.f16+=addend; s17.f17+=addend; return s17; } @@ -6696,7 +6696,7 @@ mono_return_sbyte16_nested (sbyte16_nested sn16, int addend) { if (sn16.nested2.f16 != 16) { fprintf(stderr, "mono_return_sbyte16_nested sn16.nested2.f16: got %d but expected %d\n", sn16.nested2.f16, 16); } - sn16.nested1.f1+=addend; sn16.f2+=addend; sn16.f3+=addend; sn16.f4+=addend; sn16.f5+=addend; sn16.f6+=addend; sn16.f7+=addend; sn16.f8+=addend; sn16.f9+=addend; sn16.f10+=addend; sn16.f11+=addend; sn16.f12+=addend; sn16.f13+=addend; sn16.f14+=addend; sn16.f15+=addend; sn16.nested2.f16+=addend; + sn16.nested1.f1+=addend; sn16.f2+=addend; sn16.f3+=addend; sn16.f4+=addend; sn16.f5+=addend; sn16.f6+=addend; sn16.f7+=addend; sn16.f8+=addend; sn16.f9+=addend; sn16.f10+=addend; sn16.f11+=addend; sn16.f12+=addend; sn16.f13+=addend; sn16.f14+=addend; sn16.f15+=addend; sn16.nested2.f16+=addend; return sn16; } @@ -6710,7 +6710,7 @@ mono_return_short1 (short1 s1, int addend) { if (s1.f1 != 1) { fprintf(stderr, "mono_return_short1 s1.f1: got %d but expected %d\n", s1.f1, 1); } - s1.f1+=addend; + s1.f1+=addend; return s1; } @@ -6726,7 +6726,7 @@ mono_return_short2 (short2 s2, int addend) { if (s2.f2 != 2) { fprintf(stderr, "mono_return_short2 s2.f2: got %d but expected %d\n", s2.f2, 2); } - s2.f1+=addend; s2.f2+=addend; + s2.f1+=addend; s2.f2+=addend; return s2; } @@ -6745,7 +6745,7 @@ mono_return_short3 (short3 s3, int addend) { if (s3.f3 != 3) { fprintf(stderr, "mono_return_short3 s3.f3: got %d but expected %d\n", s3.f3, 3); } - s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; + s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; return s3; } @@ -6767,7 +6767,7 @@ mono_return_short4 (short4 s4, int addend) { if (s4.f4 != 4) { fprintf(stderr, "mono_return_short4 s4.f4: got %d but expected %d\n", s4.f4, 4); } - s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; + s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; return s4; } @@ -6792,7 +6792,7 @@ mono_return_short5 (short5 s5, int addend) { if (s5.f5 != 5) { fprintf(stderr, "mono_return_short5 s5.f5: got %d but expected %d\n", s5.f5, 5); } - s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; + s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; return s5; } @@ -6820,7 +6820,7 @@ mono_return_short6 (short6 s6, int addend) { if (s6.f6 != 6) { fprintf(stderr, "mono_return_short6 s6.f6: got %d but expected %d\n", s6.f6, 6); } - s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend; + s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend; return s6; } @@ -6851,7 +6851,7 @@ mono_return_short7 (short7 s7, int addend) { if (s7.f7 != 7) { fprintf(stderr, "mono_return_short7 s7.f7: got %d but expected %d\n", s7.f7, 7); } - s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend; + s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend; return s7; } @@ -6885,7 +6885,7 @@ mono_return_short8 (short8 s8, int addend) { if (s8.f8 != 8) { fprintf(stderr, "mono_return_short8 s8.f8: got %d but expected %d\n", s8.f8, 8); } - s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend; + s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend; return s8; } @@ -6922,7 +6922,7 @@ mono_return_short9 (short9 s9, int addend) { if (s9.f9 != 9) { fprintf(stderr, "mono_return_short9 s9.f9: got %d but expected %d\n", s9.f9, 9); } - s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend; + s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend; return s9; } @@ -6962,7 +6962,7 @@ mono_return_short8_nested (short8_nested sn8, int addend) { if (sn8.nested2.f8 != 8) { fprintf(stderr, "mono_return_short8_nested sn8.nested2.f8: got %d but expected %d\n", sn8.nested2.f8, 8); } - sn8.nested1.f1+=addend; sn8.f2+=addend; sn8.f3+=addend; sn8.f4+=addend; sn8.f5+=addend; sn8.f6+=addend; sn8.f7+=addend; sn8.nested2.f8+=addend; + sn8.nested1.f1+=addend; sn8.f2+=addend; sn8.f3+=addend; sn8.f4+=addend; sn8.f5+=addend; sn8.f6+=addend; sn8.f7+=addend; sn8.nested2.f8+=addend; return sn8; } @@ -6976,7 +6976,7 @@ mono_return_int1 (int1 s1, int addend) { if (s1.f1 != 1) { fprintf(stderr, "mono_return_int1 s1.f1: got %d but expected %d\n", s1.f1, 1); } - s1.f1+=addend; + s1.f1+=addend; return s1; } @@ -6992,7 +6992,7 @@ mono_return_int2 (int2 s2, int addend) { if (s2.f2 != 2) { fprintf(stderr, "mono_return_int2 s2.f2: got %d but expected %d\n", s2.f2, 2); } - s2.f1+=addend; s2.f2+=addend; + s2.f1+=addend; s2.f2+=addend; return s2; } @@ -7011,7 +7011,7 @@ mono_return_int3 (int3 s3, int addend) { if (s3.f3 != 3) { fprintf(stderr, "mono_return_int3 s3.f3: got %d but expected %d\n", s3.f3, 3); } - s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; + s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; return s3; } @@ -7033,7 +7033,7 @@ mono_return_int4 (int4 s4, int addend) { if (s4.f4 != 4) { fprintf(stderr, "mono_return_int4 s4.f4: got %d but expected %d\n", s4.f4, 4); } - s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; + s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; return s4; } @@ -7058,7 +7058,7 @@ mono_return_int5 (int5 s5, int addend) { if (s5.f5 != 5) { fprintf(stderr, "mono_return_int5 s5.f5: got %d but expected %d\n", s5.f5, 5); } - s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; + s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; return s5; } @@ -7086,7 +7086,7 @@ mono_return_int4_nested (int4_nested sn4, int addend) { if (sn4.nested2.f4 != 4) { fprintf(stderr, "mono_return_int4_nested sn4.nested2.f4: got %d but expected %d\n", sn4.nested2.f4, 4); } - sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend; + sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend; return sn4; } @@ -7099,7 +7099,7 @@ mono_return_float1 (float1 s1, int addend) { if (s1.f1 != 1) { fprintf(stderr, "mono_return_float1 s1.f1: got %f but expected %d\n", s1.f1, 1); } - s1.f1+=addend; + s1.f1+=addend; return s1; } @@ -7115,7 +7115,7 @@ mono_return_float2 (float2 s2, int addend) { if (s2.f2 != 2) { fprintf(stderr, "mono_return_float2 s2.f2: got %f but expected %d\n", s2.f2, 2); } - s2.f1+=addend; s2.f2+=addend; + s2.f1+=addend; s2.f2+=addend; return s2; } @@ -7134,7 +7134,7 @@ mono_return_float3 (float3 s3, int addend) { if (s3.f3 != 3) { fprintf(stderr, "mono_return_float3 s3.f3: got %f but expected %d\n", s3.f3, 3); } - s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; + s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; return s3; } @@ -7156,7 +7156,7 @@ mono_return_float4 (float4 s4, int addend) { if (s4.f4 != 4) { fprintf(stderr, "mono_return_float4 s4.f4: got %f but expected %d\n", s4.f4, 4); } - s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; + s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; return s4; } @@ -7181,7 +7181,7 @@ mono_return_float5 (float5 s5, int addend) { if (s5.f5 != 5) { fprintf(stderr, "mono_return_float5 s5.f5: got %f but expected %d\n", s5.f5, 5); } - s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; + s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; return s5; } @@ -7209,7 +7209,7 @@ mono_return_float6 (float6 s6, int addend) { if (s6.f6 != 6) { fprintf(stderr, "mono_return_float6 s6.f6: got %f but expected %d\n", s6.f6, 6); } - s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend; + s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend; return s6; } @@ -7240,7 +7240,7 @@ mono_return_float7 (float7 s7, int addend) { if (s7.f7 != 7) { fprintf(stderr, "mono_return_float7 s7.f7: got %f but expected %d\n", s7.f7, 7); } - s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend; + s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend; return s7; } @@ -7274,7 +7274,7 @@ mono_return_float8 (float8 s8, int addend) { if (s8.f8 != 8) { fprintf(stderr, "mono_return_float8 s8.f8: got %f but expected %d\n", s8.f8, 8); } - s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend; + s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend; return s8; } @@ -7311,7 +7311,7 @@ mono_return_float9 (float9 s9, int addend) { if (s9.f9 != 9) { fprintf(stderr, "mono_return_float9 s9.f9: got %f but expected %d\n", s9.f9, 9); } - s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend; + s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend; return s9; } @@ -7339,7 +7339,7 @@ mono_return_float4_nested (float4_nested sn4, int addend) { if (sn4.nested2.f4 != 4) { fprintf(stderr, "mono_return_float4_nested sn4.nested2.f4: got %f but expected %d\n", sn4.nested2.f4, 4); } - sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend; + sn4.nested1.f1+=addend; sn4.f2+=addend; sn4.f3+=addend; sn4.nested2.f4+=addend; return sn4; } @@ -7352,7 +7352,7 @@ mono_return_double1 (double1 s1, int addend) { if (s1.f1 != 1) { fprintf(stderr, "mono_return_double1 s1.f1: got %f but expected %d\n", s1.f1, 1); } - s1.f1+=addend; + s1.f1+=addend; return s1; } @@ -7368,7 +7368,7 @@ mono_return_double2 (double2 s2, int addend) { if (s2.f2 != 2) { fprintf(stderr, "mono_return_double2 s2.f2: got %f but expected %d\n", s2.f2, 2); } - s2.f1+=addend; s2.f2+=addend; + s2.f1+=addend; s2.f2+=addend; return s2; } @@ -7387,7 +7387,7 @@ mono_return_double3 (double3 s3, int addend) { if (s3.f3 != 3) { fprintf(stderr, "mono_return_double3 s3.f3: got %f but expected %d\n", s3.f3, 3); } - s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; + s3.f1+=addend; s3.f2+=addend; s3.f3+=addend; return s3; } @@ -7409,7 +7409,7 @@ mono_return_double4 (double4 s4, int addend) { if (s4.f4 != 4) { fprintf(stderr, "mono_return_double4 s4.f4: got %f but expected %d\n", s4.f4, 4); } - s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; + s4.f1+=addend; s4.f2+=addend; s4.f3+=addend; s4.f4+=addend; return s4; } @@ -7434,7 +7434,7 @@ mono_return_double5 (double5 s5, int addend) { if (s5.f5 != 5) { fprintf(stderr, "mono_return_double5 s5.f5: got %f but expected %d\n", s5.f5, 5); } - s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; + s5.f1+=addend; s5.f2+=addend; s5.f3+=addend; s5.f4+=addend; s5.f5+=addend; return s5; } @@ -7462,7 +7462,7 @@ mono_return_double6 (double6 s6, int addend) { if (s6.f6 != 6) { fprintf(stderr, "mono_return_double6 s6.f6: got %f but expected %d\n", s6.f6, 6); } - s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend; + s6.f1+=addend; s6.f2+=addend; s6.f3+=addend; s6.f4+=addend; s6.f5+=addend; s6.f6+=addend; return s6; } @@ -7493,7 +7493,7 @@ mono_return_double7 (double7 s7, int addend) { if (s7.f7 != 7) { fprintf(stderr, "mono_return_double7 s7.f7: got %f but expected %d\n", s7.f7, 7); } - s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend; + s7.f1+=addend; s7.f2+=addend; s7.f3+=addend; s7.f4+=addend; s7.f5+=addend; s7.f6+=addend; s7.f7+=addend; return s7; } @@ -7527,7 +7527,7 @@ mono_return_double8 (double8 s8, int addend) { if (s8.f8 != 8) { fprintf(stderr, "mono_return_double8 s8.f8: got %f but expected %d\n", s8.f8, 8); } - s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend; + s8.f1+=addend; s8.f2+=addend; s8.f3+=addend; s8.f4+=addend; s8.f5+=addend; s8.f6+=addend; s8.f7+=addend; s8.f8+=addend; return s8; } @@ -7564,7 +7564,7 @@ mono_return_double9 (double9 s9, int addend) { if (s9.f9 != 9) { fprintf(stderr, "mono_return_double9 s9.f9: got %f but expected %d\n", s9.f9, 9); } - s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend; + s9.f1+=addend; s9.f2+=addend; s9.f3+=addend; s9.f4+=addend; s9.f5+=addend; s9.f6+=addend; s9.f7+=addend; s9.f8+=addend; s9.f9+=addend; return s9; } @@ -7585,7 +7585,7 @@ mono_return_double2_nested (double2_nested sn2, int addend) { if (sn2.nested2.f2 != 2) { fprintf(stderr, "mono_return_double2_nested sn2.nested2.f2: got %f but expected %d\n", sn2.nested2.f2, 2); } - sn2.nested1.f1+=addend; sn2.nested2.f2+=addend; + sn2.nested1.f1+=addend; sn2.nested2.f2+=addend; return sn2; } @@ -7609,7 +7609,7 @@ mono_return_double_array4 (double_array4 sa4, int addend) { if (sa4.f1[3] != 4) { fprintf(stderr, "mono_return_double_array4 sa4.f1[3]: got %f but expected %d\n", sa4.f1[3], 4); } - sa4.f1[0]+=addend; sa4.f1[1]+=addend; sa4.f1[2]+=addend; sa4.f1[3]+=addend; + sa4.f1[0]+=addend; sa4.f1[1]+=addend; sa4.f1[2]+=addend; sa4.f1[3]+=addend; return sa4; } @@ -7657,7 +7657,7 @@ mono_test_marshal_fixed_buffer_unicode (FixedBufferUnicode *s) const int NSTRINGS = 6; //test strings -const char *utf8Strings[] = { +const char *utf8Strings[] = { "Managed", "Sîne klâwen durh die wolken sint geslagen" , "काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम्", @@ -7718,7 +7718,7 @@ StringParameterRef(/*ref*/ char **s, int index) { marshal_free (*s); } - // overwrite the orginal + // overwrite the orginal *s = (char *)(marshal_alloc (sizeof(char)* (strLength + 1))); memcpy(*s, pszTextutf8, strLength); (*s)[strLength] = '\0'; @@ -7727,7 +7727,7 @@ StringParameterRef(/*ref*/ char **s, int index) LIBTEST_API void StringBuilderParameterInOut(/*[In,Out] StringBuilder*/ char *s, int index) { - // if string.empty + // if string.empty if (s == 0 || *s == 0) return; @@ -7735,16 +7735,16 @@ StringBuilderParameterInOut(/*[In,Out] StringBuilder*/ char *s, int index) // do byte by byte validation of in string size_t szLen = strlen(s); - for (size_t i = 0; i < szLen; i++) + for (size_t i = 0; i < szLen; i++) { if (s[i] != pszTextutf8[i]) { printf("[in] managed string do not match native string\n"); abort (); } - } + } - // modify the string inplace + // modify the string inplace size_t outLen = strlen(pszTextutf8); for (size_t i = 0; i < outLen; i++) { s[i] = pszTextutf8[i]; @@ -7759,7 +7759,7 @@ StringBuilderParameterOut(/*[Out] StringBuilder*/ char *s, int index) char *pszTextutf8 = (char*)utf8Strings[index]; printf ("SBPO: Receiving %s\n", s); - // modify the string inplace + // modify the string inplace size_t outLen = strlen(pszTextutf8); for (size_t i = 0; i < outLen; i++) { s[i] = pszTextutf8[i]; @@ -7797,9 +7797,9 @@ TestStructWithUtf8Field(struct FieldWithUtf8 fieldStruct) outLen = strlen(pszNative); // do byte by byte comparision - for (size_t i = 0; i < outLen; i++) + for (size_t i = 0; i < outLen; i++) { - if (pszNative[i] != pszManagedutf8[i]) + if (pszNative[i] != pszManagedutf8[i]) { printf("Native and managed string do not match.\n"); abort (); @@ -7812,7 +7812,7 @@ typedef void (* Callback2)(char *text, int index); LIBTEST_API void Utf8DelegateAsParameter(Callback2 managedCallback) { - for (int i = 0; i < NSTRINGS; ++i) + for (int i = 0; i < NSTRINGS; ++i) { char *pszNative = 0; pszNative = (char*)utf8Strings[i]; diff --git a/src/mono/mono/tools/offsets-tool/offsets-tool.py b/src/mono/mono/tools/offsets-tool/offsets-tool.py index 0c9dff64d2b79..11de36fda20b1 100644 --- a/src/mono/mono/tools/offsets-tool/offsets-tool.py +++ b/src/mono/mono/tools/offsets-tool/offsets-tool.py @@ -221,10 +221,11 @@ def run_clang(self): args.mono_path, args.mono_path + "/mono", args.mono_path + "/mono/eglib", + args.mono_path + "/../native", args.target_path, args.target_path + "/mono/eglib" ] - + self.basic_types = ["gint8", "gint16", "gint32", "gint64", "float", "double", "gpointer"] self.runtime_type_names = [ "MonoObject", @@ -259,7 +260,7 @@ def run_clang(self): "MonoDelegateTrampInfo", "GSharedVtCallInfo", "SeqPointInfo", - "DynCallArgs", + "DynCallArgs", "MonoLMFTramp", "CallContext", "MonoFtnDesc" @@ -268,7 +269,7 @@ def run_clang(self): self.runtime_types [name] = TypeInfo (name, False) for name in self.jit_type_names: self.runtime_types [name] = TypeInfo (name, True) - + self.basic_type_size = {} self.basic_type_align = {} @@ -285,9 +286,9 @@ def run_clang(self): clang_args.append (include) for define in self.target.get_clang_args (): clang_args.append ("-D" + define) - + clang.cindex.Config.set_library_file (args.libclang) - + for srcfile in srcfiles: src = args.mono_path + "/" + srcfile file_args = clang_args[:] @@ -363,7 +364,7 @@ def gen (self): for field in type.fields: f.write ("DECL_OFFSET2(%s,%s,%s)\n" % (type.name, field.name, field.offset)) f.write ("#endif //disable metadata check\n") - + f.write ("#ifndef DISABLE_JIT_OFFSETS\n") f.write ("#define USED_CROSS_COMPILER_OFFSETS\n") for type_name in self.jit_type_names: @@ -374,7 +375,7 @@ def gen (self): for field in type.fields: f.write ("DECL_OFFSET2(%s,%s,%s)\n" % (type.name, field.name, field.offset)) f.write ("#endif //disable jit check\n") - + f.write ("#endif //cross compiler checks\n") f.write ("#endif //gc check\n") if target.arch_define: diff --git a/src/mono/mono/utils/mono-context.c b/src/mono/mono/utils/mono-context.c index 81de515cafdc4..c77193186e5b9 100644 --- a/src/mono/mono/utils/mono-context.c +++ b/src/mono/mono/utils/mono-context.c @@ -51,7 +51,7 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx) g_assert_not_reached (); #elif defined(MONO_SIGNAL_USE_UCONTEXT_T) ucontext_t *ctx = (ucontext_t*)sigctx; - + mctx->eax = UCONTEXT_REG_EAX (ctx); mctx->ebx = UCONTEXT_REG_EBX (ctx); mctx->ecx = UCONTEXT_REG_ECX (ctx); @@ -85,7 +85,7 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx) mctx->eax = context->Eax; mctx->ebp = context->Ebp; mctx->esp = context->Esp; -#else +#else struct sigcontext *ctx = (struct sigcontext *)sigctx; mctx->eax = ctx->SC_EAX; @@ -468,7 +468,7 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx) mctx->pc = context->Pc; mctx->cpsr = context->Cpsr; memcpy (&mctx->regs, &context->R0, sizeof (DWORD) * 16); - + /* Why are we only copying 16 registers?! There are 32! */ memcpy (&mctx->fregs, &context->D, sizeof (double) * 16); #else @@ -495,7 +495,7 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *ctx) context->Pc = mctx->pc; context->Cpsr = mctx->cpsr; memcpy (&context->R0, &mctx->regs, sizeof (DWORD) * 16); - + /* Why are we only copying 16 registers?! There are 32! */ memcpy (&context->D, &mctx->fregs, sizeof (double) * 16); #else diff --git a/src/mono/mono/utils/mono-dl-windows.c b/src/mono/mono/utils/mono-dl-windows.c index e2c6d2dfc64ca..a7ad6d80c8d96 100644 --- a/src/mono/mono/utils/mono-dl-windows.c +++ b/src/mono/mono/utils/mono-dl-windows.c @@ -205,7 +205,7 @@ mono_dl_current_error_string (void) #else WCHAR local_buf [1024]; if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, - code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, G_N_ELEMENTS (local_buf) - 1, NULL) ) + code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, STRING_LENGTH (local_buf), NULL) ) local_buf [0] = TEXT('\0'); ret = u16to8 (local_buf) diff --git a/src/mono/mono/utils/mono-dl.c b/src/mono/mono/utils/mono-dl.c index 137999e208346..5583be758e17b 100644 --- a/src/mono/mono/utils/mono-dl.c +++ b/src/mono/mono/utils/mono-dl.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #if defined(TARGET_ANDROID) && !defined(WIN32) #include diff --git a/src/mono/mono/utils/mono-mmap-windows.c b/src/mono/mono/utils/mono-mmap-windows.c index a7612ad75daf6..e6945440363d5 100644 --- a/src/mono/mono/utils/mono-mmap-windows.c +++ b/src/mono/mono/utils/mono-mmap-windows.c @@ -165,7 +165,7 @@ format_win32_error_string (gint32 win32_error) #else WCHAR local_buf [1024]; if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, - win32_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, G_N_ELEMENTS (local_buf) - 1, NULL) ) + win32_error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), local_buf, STRING_LENGTH (local_buf), NULL) ) local_buf [0] = TEXT('\0'); ret = u16to8 (local_buf) diff --git a/src/mono/mono/utils/mono-threads-windows.c b/src/mono/mono/utils/mono-threads-windows.c index bd639adfcd56e..b8279499ddbb5 100644 --- a/src/mono/mono/utils/mono-threads-windows.c +++ b/src/mono/mono/utils/mono-threads-windows.c @@ -408,7 +408,7 @@ mono_thread_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_d *tid = thread_id; if (stack_size) { - // TOOD: Use VirtualQuery to get correct value + // TOOD: Use VirtualQuery to get correct value // http://stackoverflow.com/questions/2480095/thread-stack-size-on-windows-visual-c *stack_size = set_stack_size; } diff --git a/src/native/corehost/comhost/comhost.cpp b/src/native/corehost/comhost/comhost.cpp index 9e7317b15917c..23c673c89736e 100644 --- a/src/native/corehost/comhost/comhost.cpp +++ b/src/native/corehost/comhost/comhost.cpp @@ -10,6 +10,7 @@ #include "error_codes.h" #include "utils.h" #include +#include using comhost::clsid_map_entry; using comhost::clsid_map; @@ -273,7 +274,7 @@ namespace if (res != ERROR_SUCCESS) return __HRESULT_FROM_WIN32(res); - WCHAR regKeyProgIdClsidPath[ARRAYSIZE(regKeyProgIdPath) * 2]; + WCHAR regKeyProgIdClsidPath[ARRAY_SIZE(regKeyProgIdPath) * 2]; ::swprintf_s(regKeyProgIdClsidPath, L"%s\\CLSID", regKeyProgIdPath); HKEY regProgIdClsidRaw; @@ -350,7 +351,7 @@ namespace if (res != ERROR_SUCCESS) return __HRESULT_FROM_WIN32(res); - WCHAR regKeyServerPath[ARRAYSIZE(regKeyClsidPath) * 2]; + WCHAR regKeyServerPath[ARRAY_SIZE(regKeyClsidPath) * 2]; ::swprintf_s(regKeyServerPath, L"%s\\InProcServer32", regKeyClsidPath); HKEY regServerKeyRaw; @@ -411,7 +412,7 @@ namespace if (!entry.progid.empty()) { // Register the ProgID in the CLSID key - WCHAR regKeyProgIdPath[ARRAYSIZE(regKeyClsidPath) * 2]; + WCHAR regKeyProgIdPath[ARRAY_SIZE(regKeyClsidPath) * 2]; ::swprintf_s(regKeyProgIdPath, L"%s\\ProgID", regKeyClsidPath); HKEY regProgIdKeyRaw; diff --git a/src/native/corehost/hostmisc/pal.unix.cpp b/src/native/corehost/hostmisc/pal.unix.cpp index 0657041541af4..8d3fcbb5314d0 100644 --- a/src/native/corehost/hostmisc/pal.unix.cpp +++ b/src/native/corehost/hostmisc/pal.unix.cpp @@ -19,7 +19,7 @@ #include #include #include "config.h" -#include +#include #if defined(TARGET_OSX) #include diff --git a/src/native/eventpipe/ds-ipc.c b/src/native/eventpipe/ds-ipc.c index 063b98b84aef8..b9c00030e69bf 100644 --- a/src/native/eventpipe/ds-ipc.c +++ b/src/native/eventpipe/ds-ipc.c @@ -218,11 +218,11 @@ ipc_log_poll_handles (ds_rt_ipc_poll_handle_array_t *ipc_poll_handles) while (!ds_rt_ipc_poll_handle_array_iterator_end (ipc_poll_handles, &ipc_poll_handles_iterator)) { ipc_poll_handle = ds_rt_ipc_poll_handle_array_iterator_value (&ipc_poll_handles_iterator); if (ipc_poll_handle.ipc) { - if (!(ds_ipc_to_string (ipc_poll_handle.ipc, buffer, (uint32_t)EP_ARRAY_SIZE (buffer)) > 0)) + if (!(ds_ipc_to_string (ipc_poll_handle.ipc, buffer, (uint32_t)ARRAY_SIZE (buffer)) > 0)) buffer [0] = '\0'; DS_LOG_DEBUG_2 ("\tSERVER IpcPollHandle[%d] = %s", connection_id, buffer); } else { - if (!(ds_ipc_stream_to_string (ipc_poll_handle.stream, buffer, (uint32_t)EP_ARRAY_SIZE (buffer)))) + if (!(ds_ipc_stream_to_string (ipc_poll_handle.stream, buffer, (uint32_t)ARRAY_SIZE (buffer)))) buffer [0] = '\0'; DS_LOG_DEBUG_2 ("\tCLIENT IpcPollHandle[%d] = %s", connection_id, buffer); } @@ -703,7 +703,7 @@ connect_port_get_ipc_poll_handle_func ( } ep_char8_t buffer [DS_IPC_MAX_TO_STRING_LEN]; - if (!(ds_ipc_stream_to_string (connection, buffer, (uint32_t)EP_ARRAY_SIZE (buffer)))) + if (!(ds_ipc_stream_to_string (connection, buffer, (uint32_t)ARRAY_SIZE (buffer)))) buffer [0] = '\0'; DS_LOG_DEBUG_1 ("connect_port_get_ipc_poll_handle - returned connection %s", buffer); diff --git a/src/native/eventpipe/ds-profiler-protocol.c b/src/native/eventpipe/ds-profiler-protocol.c index 73999ffe42985..56cc5a559fdc9 100644 --- a/src/native/eventpipe/ds-profiler-protocol.c +++ b/src/native/eventpipe/ds-profiler-protocol.c @@ -67,7 +67,7 @@ attach_profiler_command_try_parse_payload ( instance->incoming_buffer = buffer; if (!ds_ipc_message_try_parse_uint32_t (&buffer_cursor, &buffer_cursor_len, &instance->attach_timeout ) || - !ds_ipc_message_try_parse_value (&buffer_cursor, &buffer_cursor_len, (uint8_t *)&instance->profiler_guid, (uint32_t)EP_ARRAY_SIZE (instance->profiler_guid)) || + !ds_ipc_message_try_parse_value (&buffer_cursor, &buffer_cursor_len, (uint8_t *)&instance->profiler_guid, (uint32_t)ARRAY_SIZE (instance->profiler_guid)) || !ds_ipc_message_try_parse_string_utf16_t (&buffer_cursor, &buffer_cursor_len, &instance->profiler_path) || !ds_ipc_message_try_parse_uint32_t (&buffer_cursor, &buffer_cursor_len, &instance->client_data_len) || !(buffer_cursor_len <= instance->client_data_len)) @@ -193,7 +193,7 @@ startup_profiler_command_try_parse_payload ( instance->incoming_buffer = buffer; - if (!ds_ipc_message_try_parse_value (&buffer_cursor, &buffer_cursor_len, (uint8_t *)&instance->profiler_guid, (uint32_t)EP_ARRAY_SIZE (instance->profiler_guid)) || + if (!ds_ipc_message_try_parse_value (&buffer_cursor, &buffer_cursor_len, (uint8_t *)&instance->profiler_guid, (uint32_t)ARRAY_SIZE (instance->profiler_guid)) || !ds_ipc_message_try_parse_string_utf16_t (&buffer_cursor, &buffer_cursor_len, &instance->profiler_path)) ep_raise_error (); @@ -223,7 +223,7 @@ profiler_protocol_helper_startup_profiler ( if (!ds_server_is_paused_in_startup()) { ds_ipc_message_send_error (stream, DS_IPC_E_INVALIDARG); ep_raise_error (); - } + } payload = (DiagnosticsStartupProfilerCommandPayload *)ds_ipc_message_try_parse_payload (message, startup_profiler_command_try_parse_payload); @@ -294,7 +294,7 @@ ds_profiler_protocol_helper_handle_ipc_message ( return true; } -#endif // PROFILING_SUPPORTED +#endif // PROFILING_SUPPORTED #endif /* !defined(DS_INCLUDE_SOURCE_FILES) || defined(DS_FORCE_INCLUDE_SOURCE_FILES) */ #endif /* ENABLE_PERFTRACING */ diff --git a/src/native/eventpipe/ep-block.c b/src/native/eventpipe/ep-block.c index 267ce30cbbd3c..0bd7d1e941a76 100644 --- a/src/native/eventpipe/ep-block.c +++ b/src/native/eventpipe/ep-block.c @@ -441,7 +441,7 @@ ep_event_block_base_init ( event_block_base->use_header_compression = use_header_compression; - memset (event_block_base->compressed_header, 0, EP_ARRAY_SIZE (event_block_base->compressed_header)); + memset (event_block_base->compressed_header, 0, ARRAY_SIZE (event_block_base->compressed_header)); ep_event_block_base_clear (event_block_base); ep_on_exit: diff --git a/src/native/eventpipe/ep-event-instance.c b/src/native/eventpipe/ep-event-instance.c index b021ca399999a..4266d2bbcf23b 100644 --- a/src/native/eventpipe/ep-event-instance.c +++ b/src/native/eventpipe/ep-event-instance.c @@ -200,13 +200,13 @@ ep_event_instance_serialize_to_json_file ( int32_t characters_written = -1; characters_written = ep_rt_utf8_string_snprintf ( buffer, - EP_ARRAY_SIZE (buffer), + ARRAY_SIZE (buffer), "Provider=%s/EventID=%d/Version=%d", ep_provider_get_provider_name (ep_event_get_provider (ep_event_instance->ep_event)), ep_event_get_event_id (ep_event_instance->ep_event), ep_event_get_event_version (ep_event_instance->ep_event)); - if (characters_written > 0 && characters_written < (int32_t)EP_ARRAY_SIZE (buffer)) + if (characters_written > 0 && characters_written < (int32_t)ARRAY_SIZE (buffer)) ep_json_file_write_event_data (json_file, ep_event_instance->timestamp, ep_rt_uint64_t_to_thread_id_t (ep_event_instance->thread_id), buffer, &ep_event_instance->stack_contents); } #else diff --git a/src/native/eventpipe/ep-event-source.c b/src/native/eventpipe/ep-event-source.c index 237f0346128de..36eac2dcbbfc4 100644 --- a/src/native/eventpipe/ep-event-source.c +++ b/src/native/eventpipe/ep-event-source.c @@ -100,7 +100,7 @@ ep_event_source_init (EventPipeEventSource *event_source) // Generate metadata. EventPipeParameterDesc params [3]; uint32_t params_len; - params_len = (uint32_t)EP_ARRAY_SIZE (params); + params_len = (uint32_t)ARRAY_SIZE (params); command_line_arg_utf16 = ep_rt_utf8_to_utf16_string ("CommandLine", -1); ep_raise_error_if_nok (command_line_arg_utf16 != NULL); @@ -221,7 +221,7 @@ ep_event_source_send_process_info ( if (arch_info_utf16) ep_event_data_init (&data[2], (uint64_t)arch_info_utf16, (uint32_t)((ep_rt_utf16_string_len (arch_info_utf16) + 1) * sizeof (ep_char16_t)), 0); - ep_write_event_2 (event_source->process_info_event, data, (uint32_t)EP_ARRAY_SIZE (data), NULL, NULL); + ep_write_event_2 (event_source->process_info_event, data, (uint32_t)ARRAY_SIZE (data), NULL, NULL); ep_rt_utf16_string_free (arch_info_utf16); ep_rt_utf16_string_free (os_info_utf16); diff --git a/src/native/eventpipe/ep-file.c b/src/native/eventpipe/ep-file.c index 40acec0a8392c..1606d7a9c2fed 100644 --- a/src/native/eventpipe/ep-file.c +++ b/src/native/eventpipe/ep-file.c @@ -398,7 +398,7 @@ ep_file_initialize_file (EventPipeFile *file) bool success = true; if (file->format >= EP_SERIALIZATION_FORMAT_NETTRACE_V4) { const ep_char8_t header[] = "Nettrace"; - const uint32_t bytes_to_write = (uint32_t)(EP_ARRAY_SIZE (header) - 1); + const uint32_t bytes_to_write = (uint32_t)(STRING_LENGTH (header)); uint32_t bytes_written = 0; success = ep_stream_writer_write (file->stream_writer, (const uint8_t *)header, bytes_to_write, &bytes_written) && bytes_written == bytes_to_write; } diff --git a/src/native/eventpipe/ep-json-file.c b/src/native/eventpipe/ep-json-file.c index 35d33b3026d09..5340895424b03 100644 --- a/src/native/eventpipe/ep-json-file.c +++ b/src/native/eventpipe/ep-json-file.c @@ -111,8 +111,8 @@ ep_json_file_write_event_data ( ep_char8_t buffer [MAX_BUFFER_SIZE]; int32_t characters_written = -1; - characters_written = ep_rt_utf8_string_snprintf (buffer, EP_ARRAY_SIZE (buffer), "{\"Time\" : \"%f\", \"Metric\" : \"1\",\n\"Stack\": [\n\"", millis_since_trace_start); - if (characters_written > 0 && characters_written < (int32_t)EP_ARRAY_SIZE (buffer)) + characters_written = ep_rt_utf8_string_snprintf (buffer, ARRAY_SIZE (buffer), "{\"Time\" : \"%f\", \"Metric\" : \"1\",\n\"Stack\": [\n\"", millis_since_trace_start); + if (characters_written > 0 && characters_written < (int32_t)ARRAY_SIZE (buffer)) json_file_write_string (json_file, buffer); if (message) @@ -126,23 +126,23 @@ ep_json_file_write_event_data ( for (uint32_t i = 0; i < ep_stack_contents_get_length (stack_contents); ++i) { ep_rt_method_desc_t *method = ep_stack_contents_get_method (stack_contents, i); - if (!ep_rt_method_get_simple_assembly_name (method, assembly_name, EP_ARRAY_SIZE (assembly_name))) { + if (!ep_rt_method_get_simple_assembly_name (method, assembly_name, ARRAY_SIZE (assembly_name))) { assembly_name [0] = '?'; assembly_name [1] = 0; } - if (!ep_rt_method_get_full_name (method, method_name, EP_ARRAY_SIZE (method_name))) { + if (!ep_rt_method_get_full_name (method, method_name, ARRAY_SIZE (method_name))) { method_name [0] = '?'; method_name [1] = 0; } - characters_written = ep_rt_utf8_string_snprintf (buffer, EP_ARRAY_SIZE (buffer), "\"%s!%s\",\n", assembly_name, method_name); - if (characters_written > 0 && characters_written < (int32_t)EP_ARRAY_SIZE (buffer)) + characters_written = ep_rt_utf8_string_snprintf (buffer, ARRAY_SIZE (buffer), "\"%s!%s\",\n", assembly_name, method_name); + if (characters_written > 0 && characters_written < (int32_t)ARRAY_SIZE (buffer)) json_file_write_string (json_file, buffer); } - characters_written = ep_rt_utf8_string_snprintf (buffer, EP_ARRAY_SIZE (buffer), "\"Thread (%" PRIu64 ")\"]},", ep_rt_thread_id_t_to_uint64_t (thread_id)); - if (characters_written > 0 && characters_written < (int32_t)EP_ARRAY_SIZE (buffer)) + characters_written = ep_rt_utf8_string_snprintf (buffer, ARRAY_SIZE (buffer), "\"Thread (%" PRIu64 ")\"]},", ep_rt_thread_id_t_to_uint64_t (thread_id)); + if (characters_written > 0 && characters_written < (int32_t)ARRAY_SIZE (buffer)) json_file_write_string (json_file, buffer); } diff --git a/src/native/eventpipe/ep-rt.h b/src/native/eventpipe/ep-rt.h index d043710f46c1a..4fc22632c6c17 100644 --- a/src/native/eventpipe/ep-rt.h +++ b/src/native/eventpipe/ep-rt.h @@ -3,10 +3,11 @@ #include "ep-rt-config.h" +#include + #ifdef ENABLE_PERFTRACING #include "ep-types.h" -#define EP_ARRAY_SIZE(expr) ep_rt_redefine #define EP_INFINITE_WAIT ep_rt_redefine #define EP_GCX_PREEMP_ENTER ep_rt_redefine diff --git a/src/native/eventpipe/ep-session.c b/src/native/eventpipe/ep-session.c index dc3a259cae28e..4f572f98b49b4 100644 --- a/src/native/eventpipe/ep-session.c +++ b/src/native/eventpipe/ep-session.c @@ -276,7 +276,7 @@ ep_session_enable_rundown (EventPipeSession *session) const EventPipeEventLevel verbose_logging_level = EP_EVENT_LEVEL_VERBOSE; EventPipeProviderConfiguration rundown_providers [2]; - uint32_t rundown_providers_len = (uint32_t)EP_ARRAY_SIZE (rundown_providers); + uint32_t rundown_providers_len = (uint32_t)ARRAY_SIZE (rundown_providers); ep_provider_config_init (&rundown_providers [0], ep_config_get_public_provider_name_utf8 (), keywords, verbose_logging_level, NULL); // Public provider. ep_provider_config_init (&rundown_providers [1], ep_config_get_rundown_provider_name_utf8 (), keywords, verbose_logging_level, NULL); // Rundown provider. diff --git a/src/native/eventpipe/ep-stream.c b/src/native/eventpipe/ep-stream.c index f650dd6142762..fafe72b06db1d 100644 --- a/src/native/eventpipe/ep-stream.c +++ b/src/native/eventpipe/ep-stream.c @@ -167,7 +167,7 @@ ep_fast_serializer_alloc (StreamWriter *stream_writer) EP_ASSERT (stream_writer != NULL); const ep_char8_t signature[] = "!FastSerialization.1"; // the consumer lib expects exactly the same string, it must not be changed - uint32_t signature_len = (uint32_t)(EP_ARRAY_SIZE (signature) - 1); + uint32_t signature_len = (uint32_t)(STRING_LENGTH (signature)); FastSerializer *instance = ep_rt_object_alloc (FastSerializer); ep_raise_error_if_nok (instance != NULL); diff --git a/src/native/eventpipe/ep.c b/src/native/eventpipe/ep.c index ae8f3ce24f62f..bdac36b3effe4 100644 --- a/src/native/eventpipe/ep.c +++ b/src/native/eventpipe/ep.c @@ -868,7 +868,7 @@ enable_default_session_via_env_variables (void) ep_config_output_path = ep_rt_config_value_get_output_path (); ep_char8_t pidStr[24]; - ep_rt_utf8_string_snprintf(pidStr, EP_ARRAY_SIZE (pidStr), "%u", (unsigned)ep_rt_current_process_get_id()); + ep_rt_utf8_string_snprintf(pidStr, ARRAY_SIZE (pidStr), "%u", (unsigned)ep_rt_current_process_get_id()); while (true) { @@ -1115,7 +1115,7 @@ ep_disable (EventPipeSessionID id) // single threaded. HOWEVER, if the runtime was suspended during startup, // then ep_finish_init might not have executed yet. Disabling a session // needs to either happen before we resume or after initialization. We briefly take the - // lock to check _ep_can_start_threads to check whether we've finished initialization. We + // lock to check _ep_can_start_threads to check whether we've finished initialization. We // also check whether we are still suspended in which case we can safely disable the session // without deferral. EP_LOCK_ENTER (section1) diff --git a/src/native/common/entrypoints.h b/src/native/minipal/entrypoints.h similarity index 83% rename from src/native/common/entrypoints.h rename to src/native/minipal/entrypoints.h index 79cd2b509bf79..d7908764e05e6 100644 --- a/src/native/common/entrypoints.h +++ b/src/native/minipal/entrypoints.h @@ -1,14 +1,12 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#pragma once +#ifndef HAVE_MINIPAL_ENTRYPOINTS_H +#define HAVE_MINIPAL_ENTRYPOINTS_H #include #include - -#ifndef lengthof -#define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) -#endif +#include typedef struct { @@ -32,3 +30,5 @@ static const void* minipal_resolve_dllimport(const Entry* resolutionTable, size_ return NULL; } + +#endif // HAVE_MINIPAL_ENTRYPOINTS_H diff --git a/src/native/common/getexepath.h b/src/native/minipal/getexepath.h similarity index 95% rename from src/native/common/getexepath.h rename to src/native/minipal/getexepath.h index 01c6b01e249a1..ecc6dc8d72771 100644 --- a/src/native/common/getexepath.h +++ b/src/native/minipal/getexepath.h @@ -1,8 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#ifndef GETEXEPATH_H -#define GETEXEPATH_H +#ifndef HAVE_MINIPAL_GETEXEPATH_H +#define HAVE_MINIPAL_GETEXEPATH_H #include #include @@ -95,4 +95,4 @@ static inline char* minipal_getexepath(void) } #endif // extern "C" -#endif // GETEXEPATH_H +#endif // HAVE_MINIPAL_GETEXEPATH_H diff --git a/src/native/minipal/utils.h b/src/native/minipal/utils.h new file mode 100644 index 0000000000000..140ea158fdba1 --- /dev/null +++ b/src/native/minipal/utils.h @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#ifndef HAVE_MINIPAL_UTILS_H +#define HAVE_MINIPAL_UTILS_H + +#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) + +// Number of characters in a string literal. Excludes terminating NULL. +#define STRING_LENGTH(str) (ARRAY_SIZE(str) - 1) + +#endif // HAVE_MINIPAL_UTILS_H diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index fdc509005e437..1d22f41db5ff9 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -9,6 +9,8 @@ project(Tests) include(../../eng/native/configurepaths.cmake) include(${CLR_ENG_NATIVE_DIR}/configurecompiler.cmake) +include_directories("${CLR_SRC_NATIVE_DIR}") + # Add this subdir. We install the headers for the jit. add_subdirectory(../coreclr/pal/prebuilt/inc ../coreclr/pal/prebuilt/inc) diff --git a/src/tests/Common/Platform/platformdefines.h b/src/tests/Common/Platform/platformdefines.h index c5e61c58400c9..c8dd750add300 100644 --- a/src/tests/Common/Platform/platformdefines.h +++ b/src/tests/Common/Platform/platformdefines.h @@ -8,6 +8,7 @@ #include #include #include +#include #ifndef _PLATFORMDEFINES__H #define _PLATFORMDEFINES__H @@ -91,8 +92,6 @@ typedef unsigned int ULONG, *PULONG; #define UInt32x32To64(a, b) ((unsigned __int64)((ULONG)(a)) * (unsigned __int64)((ULONG)(b))) -#define ARRAYSIZE(x) (sizeof(x)/sizeof(*x)) - #ifndef TRUE #define TRUE 1 #endif diff --git a/src/tests/Interop/COM/NativeClients/Events/EventTests.cpp b/src/tests/Interop/COM/NativeClients/Events/EventTests.cpp index 53a05e6bba240..7b5b7db7caa9a 100644 --- a/src/tests/Interop/COM/NativeClients/Events/EventTests.cpp +++ b/src/tests/Interop/COM/NativeClients/Events/EventTests.cpp @@ -33,7 +33,7 @@ namespace public: DispIDToStringMap() : _pairs{} - , _end{ _pairs + ARRAYSIZE(_pairs) } + , _end{ _pairs + ARRAY_SIZE(_pairs) } { for (auto curr = _pairs; curr != _end; ++curr) curr->id = DISPID_UNKNOWN; diff --git a/src/tests/Interop/COM/NativeClients/Primitives/ErrorTests.cpp b/src/tests/Interop/COM/NativeClients/Primitives/ErrorTests.cpp index 2def0ac0b9d48..99639a40e052a 100644 --- a/src/tests/Interop/COM/NativeClients/Primitives/ErrorTests.cpp +++ b/src/tests/Interop/COM/NativeClients/Primitives/ErrorTests.cpp @@ -20,7 +20,7 @@ namespace HRESULT{-1} }; - for (int i = 0; i < ARRAYSIZE(hrs); ++i) + for (int i = 0; i < ARRAY_SIZE(hrs); ++i) { HRESULT hr = hrs[i]; HRESULT hrMaybe = et->Throw_HResult(hr); @@ -44,7 +44,7 @@ namespace HRESULT{2} }; - for (int i = 0; i < ARRAYSIZE(hrs); ++i) + for (int i = 0; i < ARRAY_SIZE(hrs); ++i) { HRESULT hr = hrs[i]; HRESULT hrMaybe = et->Return_As_HResult(hr); @@ -68,7 +68,7 @@ namespace HRESULT{2} }; - for (int i = 0; i < ARRAYSIZE(hrs); ++i) + for (int i = 0; i < ARRAY_SIZE(hrs); ++i) { HRESULT hr = hrs[i]; HRESULT hrMaybe = et->Return_As_HResult_Struct(hr); diff --git a/src/tests/Interop/COM/NativeServer/DispatchTesting.h b/src/tests/Interop/COM/NativeServer/DispatchTesting.h index 26ab5e86ed94b..927439fe03dc4 100644 --- a/src/tests/Interop/COM/NativeServer/DispatchTesting.h +++ b/src/tests/Interop/COM/NativeServer/DispatchTesting.h @@ -25,7 +25,7 @@ class Enumerator : public UnknownImpl, public IEnumVARIANT { } public: // IEnumVARIANT - HRESULT STDMETHODCALLTYPE Next( + HRESULT STDMETHODCALLTYPE Next( ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched) @@ -36,7 +36,7 @@ class Enumerator : public UnknownImpl, public IEnumVARIANT V_VT(&rgVar[*pCeltFetched]) = VT_I4; V_I4(&(rgVar[*pCeltFetched])) = _current; } - + return celt == *pCeltFetched ? S_OK : S_FALSE; } @@ -89,22 +89,22 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting static const int NamesCount; public: // IDispatch - virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount( + virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount( /* [out] */ __RPC__out UINT *pctinfo) { *pctinfo = 0; return S_OK; } - - virtual HRESULT STDMETHODCALLTYPE GetTypeInfo( + + virtual HRESULT STDMETHODCALLTYPE GetTypeInfo( /* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ __RPC__deref_out_opt ITypeInfo **ppTInfo) { return E_NOTIMPL; } - - virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames( + + virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames( /* [in] */ __RPC__in REFIID, /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR *rgszNames, /* [range][in] */ __RPC__in_range(0,16384) UINT cNames, @@ -134,7 +134,7 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting return (containsUnknown) ? DISP_E_UNKNOWNNAME : S_OK; } - virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke( + virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke( /* [annotation][in] */ _In_ DISPID dispIdMember, /* [annotation][in] */ _In_ REFIID riid, /* [annotation][in] */ _In_ LCID lcid, @@ -278,13 +278,13 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting __int64 *l_args[2]; unsigned __int64 *ul_args[2]; size_t expectedArgCount = - ARRAYSIZE(b_args) - + ARRAYSIZE(s_args) - + ARRAYSIZE(us_args) - + ARRAYSIZE(i_args) - + ARRAYSIZE(ui_args) - + ARRAYSIZE(l_args) - + ARRAYSIZE(ul_args); + ARRAY_SIZE(b_args) + + ARRAY_SIZE(s_args) + + ARRAY_SIZE(us_args) + + ARRAY_SIZE(i_args) + + ARRAY_SIZE(ui_args) + + ARRAY_SIZE(l_args) + + ARRAY_SIZE(ul_args); RETURN_IF_FAILED(VerifyValues(UINT(expectedArgCount), pDispParams->cArgs)); VARENUM currType; @@ -371,7 +371,7 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting HRESULT hr; float *args[2]; - size_t expectedArgCount = ARRAYSIZE(args); + size_t expectedArgCount = ARRAY_SIZE(args); RETURN_IF_FAILED(VerifyValues(UINT(expectedArgCount), pDispParams->cArgs)); if (pVarResult == nullptr) @@ -401,7 +401,7 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting HRESULT hr; double *args[2]; - size_t expectedArgCount = ARRAYSIZE(args); + size_t expectedArgCount = ARRAY_SIZE(args); RETURN_IF_FAILED(VerifyValues(UINT(expectedArgCount), pDispParams->cArgs)); if (pVarResult == nullptr) @@ -434,7 +434,7 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting HRESULT hr; int *args[2]; - size_t expectedArgCount = ARRAYSIZE(args); + size_t expectedArgCount = ARRAY_SIZE(args); RETURN_IF_FAILED(VerifyValues(UINT(expectedArgCount), pDispParams->cArgs)); VARENUM currType; @@ -461,8 +461,8 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting *puArgErr = 1; pExcepInfo->scode = HRESULT_FROM_WIN32(*args[1]); - WCHAR buffer[ARRAYSIZE(W("4294967295"))]; - _snwprintf_s(buffer, ARRAYSIZE(buffer), _TRUNCATE, W("%x"), *args[1]); + WCHAR buffer[ARRAY_SIZE(W("4294967295"))]; + _snwprintf_s(buffer, ARRAY_SIZE(buffer), _TRUNCATE, W("%x"), *args[1]); pExcepInfo->bstrDescription = SysAllocString(buffer); } @@ -474,7 +474,7 @@ class DispatchTesting : public UnknownImpl, public IDispatchTesting HRESULT hr; HFA_4 *args[1]; - size_t expectedArgCount = ARRAYSIZE(args); + size_t expectedArgCount = ARRAY_SIZE(args); RETURN_IF_FAILED(VerifyValues(UINT(expectedArgCount), pDispParams->cArgs)); VARENUM currType; @@ -523,4 +523,4 @@ const WCHAR * const DispatchTesting::Names[] = W("ExplicitGetEnumerator") }; -const int DispatchTesting::NamesCount = ARRAYSIZE(DispatchTesting::Names); +const int DispatchTesting::NamesCount = ARRAY_SIZE(DispatchTesting::Names); diff --git a/src/tests/Interop/COM/NativeServer/EventTesting.h b/src/tests/Interop/COM/NativeServer/EventTesting.h index ce5ef5b094ecf..f9ffc32ae19a3 100644 --- a/src/tests/Interop/COM/NativeServer/EventTesting.h +++ b/src/tests/Interop/COM/NativeServer/EventTesting.h @@ -26,22 +26,22 @@ class EventTesting : } public: // IDispatch - virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount( + virtual HRESULT STDMETHODCALLTYPE GetTypeInfoCount( /* [out] */ __RPC__out UINT *pctinfo) { *pctinfo = 0; return S_OK; } - - virtual HRESULT STDMETHODCALLTYPE GetTypeInfo( + + virtual HRESULT STDMETHODCALLTYPE GetTypeInfo( /* [in] */ UINT iTInfo, /* [in] */ LCID lcid, /* [out] */ __RPC__deref_out_opt ITypeInfo **ppTInfo) { return E_NOTIMPL; } - - virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames( + + virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames( /* [in] */ __RPC__in REFIID, /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR *rgszNames, /* [range][in] */ __RPC__in_range(0,16384) UINT cNames, @@ -71,7 +71,7 @@ class EventTesting : return (containsUnknown) ? DISP_E_UNKNOWNNAME : S_OK; } - virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke( + virtual /* [local] */ HRESULT STDMETHODCALLTYPE Invoke( /* [annotation][in] */ _In_ DISPID dispIdMember, /* [annotation][in] */ _In_ REFIID riid, /* [annotation][in] */ _In_ LCID lcid, @@ -103,12 +103,12 @@ class EventTesting : } public: // IConnectionPointContainer - virtual HRESULT STDMETHODCALLTYPE EnumConnectionPoints( + virtual HRESULT STDMETHODCALLTYPE EnumConnectionPoints( /* [out] */ __RPC__deref_out_opt IEnumConnectionPoints **ppEnum) { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE FindConnectionPoint( + virtual HRESULT STDMETHODCALLTYPE FindConnectionPoint( /* [in] */ __RPC__in REFIID riid, /* [out] */ __RPC__deref_out_opt IConnectionPoint **ppCP) { @@ -119,24 +119,24 @@ class EventTesting : } public: // IConnectionPoint - virtual HRESULT STDMETHODCALLTYPE GetConnectionInterface( + virtual HRESULT STDMETHODCALLTYPE GetConnectionInterface( /* [out] */ __RPC__out IID *pIID) { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE GetConnectionPointContainer( + virtual HRESULT STDMETHODCALLTYPE GetConnectionPointContainer( /* [out] */ __RPC__deref_out_opt IConnectionPointContainer **ppCPC) { return E_NOTIMPL; } - virtual HRESULT STDMETHODCALLTYPE Advise( + virtual HRESULT STDMETHODCALLTYPE Advise( /* [in] */ __RPC__in_opt IUnknown *pUnkSink, /* [out] */ __RPC__out DWORD *pdwCookie) { if (pUnkSink == nullptr || pdwCookie == nullptr) return E_POINTER; - for (DWORD i = 0; i < ARRAYSIZE(_eventConnections); ++i) + for (DWORD i = 0; i < ARRAY_SIZE(_eventConnections); ++i) { if (_eventConnections[i] == nullptr) { @@ -153,10 +153,10 @@ class EventTesting : return CONNECT_E_ADVISELIMIT; } - virtual HRESULT STDMETHODCALLTYPE Unadvise( + virtual HRESULT STDMETHODCALLTYPE Unadvise( /* [in] */ DWORD dwCookie) { - if (0 <= dwCookie && dwCookie < ARRAYSIZE(_eventConnections)) + if (0 <= dwCookie && dwCookie < ARRAY_SIZE(_eventConnections)) { IDispatch *handler = _eventConnections[dwCookie]; if (handler != nullptr) @@ -169,7 +169,7 @@ class EventTesting : return E_POINTER; } - virtual HRESULT STDMETHODCALLTYPE EnumConnections( + virtual HRESULT STDMETHODCALLTYPE EnumConnections( /* [out] */ __RPC__deref_out_opt IEnumConnections **ppEnum) { return E_NOTIMPL; @@ -186,7 +186,7 @@ class EventTesting : arg.vt = VT_BSTR; arg.bstrVal = TP_SysAllocString(Names[dispId]); - for (DWORD i = 0; i < ARRAYSIZE(_eventConnections); ++i) + for (DWORD i = 0; i < ARRAY_SIZE(_eventConnections); ++i) { IDispatch *handler = _eventConnections[i]; if (handler != nullptr) @@ -233,4 +233,4 @@ const WCHAR * const EventTesting::Names[] = W("FireEvent"), }; -const int EventTesting::NamesCount = ARRAYSIZE(EventTesting::Names); +const int EventTesting::NamesCount = ARRAY_SIZE(EventTesting::Names); diff --git a/src/tests/Interop/COM/NativeServer/Servers.cpp b/src/tests/Interop/COM/NativeServer/Servers.cpp index 30fcea847aee2..6ed9d11460dee 100644 --- a/src/tests/Interop/COM/NativeServer/Servers.cpp +++ b/src/tests/Interop/COM/NativeServer/Servers.cpp @@ -124,7 +124,7 @@ namespace return HRESULT_FROM_WIN32(::GetLastError()); } - ::GetModuleFileNameW(mod, fullPath, ARRAYSIZE(fullPath)); + ::GetModuleFileNameW(mod, fullPath, ARRAY_SIZE(fullPath)); // The default value for the key is the path to the DLL res = ::RegSetValueExW( diff --git a/src/tests/Interop/PInvoke/Array/MarshalArray.h b/src/tests/Interop/PInvoke/Array/MarshalArray.h index 54c8a4052a12c..c53c2e4bcba36 100644 --- a/src/tests/Interop/PInvoke/Array/MarshalArray.h +++ b/src/tests/Interop/PInvoke/Array/MarshalArray.h @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#pragma once +#pragma once #include #include // required by itoa #include @@ -10,11 +10,10 @@ ////////////////////////////////////////////////////////////////////////////// // Macro definitions ////////////////////////////////////////////////////////////////////////////// -#define ARRAY_SIZE 100 +#define ARRAY_LENGTH 100 #define ROWS 2 #define COLUMNS 3 -#define COUNTOF(__arr) sizeof(__arr) / sizeof(__arr[0]) #define ELEM_PER_ROW_2D(__arr) (&(__arr[1][0]) - &(__arr[0][0])) #define ROWS_2D(__arr) sizeof(__arr) / (ELEM_PER_ROW_2D(__arr) * sizeof(__arr[0][0])) diff --git a/src/tests/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp b/src/tests/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp index 5f9aaf419b318..05a306b26a7e4 100644 --- a/src/tests/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp +++ b/src/tests/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/MarshalArrayByValArrayNative.cpp @@ -34,29 +34,27 @@ macro definition struct definition ----------------------------------------------------------------------------*/ -typedef struct { INT arr[ARRAY_SIZE]; } S_INTArray; -typedef struct { UINT arr[ARRAY_SIZE]; } S_UINTArray; -typedef struct { SHORT arr[ARRAY_SIZE]; } S_SHORTArray; -typedef struct { WORD arr[ARRAY_SIZE]; } S_WORDArray; -typedef struct { LONG64 arr[ARRAY_SIZE]; } S_LONG64Array; - -typedef struct { ULONG64 arr[ARRAY_SIZE]; } S_ULONG64Array; -typedef struct { DOUBLE arr[ARRAY_SIZE]; } S_DOUBLEArray; -typedef struct { FLOAT arr[ARRAY_SIZE]; } S_FLOATArray; -typedef struct { BYTE arr[ARRAY_SIZE]; } S_BYTEArray; -typedef struct { CHAR arr[ARRAY_SIZE]; } S_CHARArray; - -typedef struct { LPSTR arr[ARRAY_SIZE]; } S_LPSTRArray; -typedef struct { LPCSTR arr[ARRAY_SIZE]; } S_LPCSTRArray; +typedef struct { INT arr[ARRAY_LENGTH]; } S_INTArray; +typedef struct { UINT arr[ARRAY_LENGTH]; } S_UINTArray; +typedef struct { SHORT arr[ARRAY_LENGTH]; } S_SHORTArray; +typedef struct { WORD arr[ARRAY_LENGTH]; } S_WORDArray; +typedef struct { LONG64 arr[ARRAY_LENGTH]; } S_LONG64Array; + +typedef struct { ULONG64 arr[ARRAY_LENGTH]; } S_ULONG64Array; +typedef struct { DOUBLE arr[ARRAY_LENGTH]; } S_DOUBLEArray; +typedef struct { FLOAT arr[ARRAY_LENGTH]; } S_FLOATArray; +typedef struct { BYTE arr[ARRAY_LENGTH]; } S_BYTEArray; +typedef struct { CHAR arr[ARRAY_LENGTH]; } S_CHARArray; + +typedef struct { LPSTR arr[ARRAY_LENGTH]; } S_LPSTRArray; +typedef struct { LPCSTR arr[ARRAY_LENGTH]; } S_LPCSTRArray; #ifdef _WIN32 -typedef struct { BSTR arr[ARRAY_SIZE]; } S_BSTRArray; +typedef struct { BSTR arr[ARRAY_LENGTH]; } S_BSTRArray; #endif //struct array in a struct - -typedef struct { TestStruct arr[ARRAY_SIZE]; } S_StructArray; - -typedef struct { BOOL arr[ARRAY_SIZE]; } S_BOOLArray; +typedef struct { TestStruct arr[ARRAY_LENGTH]; } S_StructArray; +typedef struct { BOOL arr[ARRAY_LENGTH]; } S_BOOLArray; enum class TestEnum : int32_t { @@ -66,9 +64,7 @@ enum class TestEnum : int32_t }; typedef struct { TestEnum arr[3]; } EnregisterableNonBlittable; - typedef struct { int32_t i; } SimpleStruct; - typedef struct { SimpleStruct arr[3]; } EnregisterableUserType; /*---------------------------------------------------------------------------- @@ -77,9 +73,9 @@ helper function TestStruct* InitTestStruct() { - TestStruct *expected = (TestStruct *)CoreClrAlloc( sizeof(TestStruct) * ARRAY_SIZE ); + TestStruct *expected = (TestStruct *)CoreClrAlloc( sizeof(TestStruct) * ARRAY_LENGTH ); - for ( int i = 0; i < ARRAY_SIZE; i++) + for ( int i = 0; i < ARRAY_LENGTH; i++) { expected[i].x = i; expected[i].d = i; @@ -124,7 +120,7 @@ bool TestStructEquals(TestStruct Actual[], TestStruct Expected[]) else if ( Actual != NULL && Expected == NULL ) return false; - for ( int i = 0; i < ARRAY_SIZE; ++i ) + for ( int i = 0; i < ARRAY_LENGTH; ++i ) { if ( !(IsObjectEquals(Actual[i].x, Expected[i].x) && IsObjectEquals(Actual[i].d, Expected[i].d) && @@ -151,93 +147,93 @@ marshal sequential strut extern "C" DLL_EXPORT BOOL __cdecl TakeIntArraySeqStructByVal( S_INTArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( INT, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( INT, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeUIntArraySeqStructByVal( S_UINTArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( UINT, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( UINT, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeShortArraySeqStructByVal( S_SHORTArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( SHORT, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( SHORT, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeWordArraySeqStructByVal( S_WORDArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( WORD, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( WORD, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeLong64ArraySeqStructByVal( S_LONG64Array s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( LONG64, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( LONG64, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeULong64ArraySeqStructByVal( S_ULONG64Array s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( ULONG64, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( ULONG64, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeDoubleArraySeqStructByVal( S_DOUBLEArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( DOUBLE, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( DOUBLE, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeFloatArraySeqStructByVal( S_FLOATArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( FLOAT, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( FLOAT, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeByteArraySeqStructByVal( S_BYTEArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( BYTE, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( BYTE, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeCharArraySeqStructByVal( S_CHARArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - INIT_EXPECTED( CHAR, ARRAY_SIZE ); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + INIT_EXPECTED( CHAR, ARRAY_LENGTH ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeLPSTRArraySeqStructByVal( S_LPSTRArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - LPSTR expected[ARRAY_SIZE]; - for ( int i = 0; i < ARRAY_SIZE; ++i ) + LPSTR expected[ARRAY_LENGTH]; + for ( int i = 0; i < ARRAY_LENGTH; ++i ) expected[i] = ToString(i); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } extern "C" DLL_EXPORT BOOL __cdecl TakeLPCSTRArraySeqStructByVal( S_LPCSTRArray s, int size ) { CHECK_PARAM_NOT_EMPTY( s.arr ); - LPSTR expected[ARRAY_SIZE]; - for ( int i = 0; i < ARRAY_SIZE; ++i ) + LPSTR expected[ARRAY_LENGTH]; + for ( int i = 0; i < ARRAY_LENGTH; ++i ) expected[i] = ToString(i); - return Equals( s.arr, size, (LPCSTR *)expected, ARRAY_SIZE ); + return Equals( s.arr, size, (LPCSTR *)expected, ARRAY_LENGTH ); } #ifdef _WIN32 @@ -245,11 +241,11 @@ extern "C" DLL_EXPORT BOOL __cdecl TakeBSTRArraySeqStructByVal( S_BSTRArray s, i { CHECK_PARAM_NOT_EMPTY( s.arr ); - BSTR expected[ARRAY_SIZE]; - for ( int i = 0; i < ARRAY_SIZE; ++i ) + BSTR expected[ARRAY_LENGTH]; + for ( int i = 0; i < ARRAY_LENGTH; ++i ) expected[i] = ToBSTR(i); - return Equals( s.arr, size, expected, ARRAY_SIZE ); + return Equals( s.arr, size, expected, ARRAY_LENGTH ); } #endif @@ -502,77 +498,77 @@ return a struct including a C array ----------------------------------------------------------------------------*/ extern "C" DLL_EXPORT S_INTArray __cdecl S_INTArray_Ret_ByValue() { - INIT_EXPECTED_STRUCT( S_INTArray, ARRAY_SIZE, INT ); + INIT_EXPECTED_STRUCT( S_INTArray, ARRAY_LENGTH, INT ); return *expected; } extern "C" DLL_EXPORT S_INTArray* __cdecl S_INTArray_Ret() { - INIT_EXPECTED_STRUCT( S_INTArray, ARRAY_SIZE, INT ); + INIT_EXPECTED_STRUCT( S_INTArray, ARRAY_LENGTH, INT ); return expected; } extern "C" DLL_EXPORT S_UINTArray* __cdecl S_UINTArray_Ret() { - INIT_EXPECTED_STRUCT( S_UINTArray, ARRAY_SIZE, UINT ); + INIT_EXPECTED_STRUCT( S_UINTArray, ARRAY_LENGTH, UINT ); return expected; } extern "C" DLL_EXPORT S_SHORTArray* __cdecl S_SHORTArray_Ret() { - INIT_EXPECTED_STRUCT( S_SHORTArray, ARRAY_SIZE, SHORT ); + INIT_EXPECTED_STRUCT( S_SHORTArray, ARRAY_LENGTH, SHORT ); return expected; } extern "C" DLL_EXPORT S_WORDArray* __cdecl S_WORDArray_Ret() { - INIT_EXPECTED_STRUCT( S_WORDArray, ARRAY_SIZE, WORD ); + INIT_EXPECTED_STRUCT( S_WORDArray, ARRAY_LENGTH, WORD ); return expected; } extern "C" DLL_EXPORT S_LONG64Array* __cdecl S_LONG64Array_Ret() { - INIT_EXPECTED_STRUCT( S_LONG64Array, ARRAY_SIZE, LONG64 ); + INIT_EXPECTED_STRUCT( S_LONG64Array, ARRAY_LENGTH, LONG64 ); return expected; } extern "C" DLL_EXPORT S_ULONG64Array* __cdecl S_ULONG64Array_Ret() { - INIT_EXPECTED_STRUCT( S_ULONG64Array, ARRAY_SIZE, ULONG64 ); + INIT_EXPECTED_STRUCT( S_ULONG64Array, ARRAY_LENGTH, ULONG64 ); return expected; } extern "C" DLL_EXPORT S_DOUBLEArray* __cdecl S_DOUBLEArray_Ret() { - INIT_EXPECTED_STRUCT( S_DOUBLEArray, ARRAY_SIZE, DOUBLE ); + INIT_EXPECTED_STRUCT( S_DOUBLEArray, ARRAY_LENGTH, DOUBLE ); return expected; } extern "C" DLL_EXPORT S_FLOATArray* __cdecl S_FLOATArray_Ret() { - INIT_EXPECTED_STRUCT( S_FLOATArray, ARRAY_SIZE, FLOAT ); + INIT_EXPECTED_STRUCT( S_FLOATArray, ARRAY_LENGTH, FLOAT ); return expected; } extern "C" DLL_EXPORT S_BYTEArray* __cdecl S_BYTEArray_Ret() { - INIT_EXPECTED_STRUCT( S_BYTEArray, ARRAY_SIZE, BYTE ); + INIT_EXPECTED_STRUCT( S_BYTEArray, ARRAY_LENGTH, BYTE ); return expected; } extern "C" DLL_EXPORT S_CHARArray* __cdecl S_CHARArray_Ret() { - INIT_EXPECTED_STRUCT( S_CHARArray, ARRAY_SIZE, CHAR ); + INIT_EXPECTED_STRUCT( S_CHARArray, ARRAY_LENGTH, CHAR ); return expected; } @@ -580,7 +576,7 @@ extern "C" DLL_EXPORT S_CHARArray* __cdecl S_CHARArray_Ret() extern "C" DLL_EXPORT S_LPSTRArray* __cdecl S_LPSTRArray_Ret() { S_LPSTRArray *expected = (S_LPSTRArray *)CoreClrAlloc( sizeof(S_LPSTRArray) ); - for ( int i = 0; i < ARRAY_SIZE; ++i ) + for ( int i = 0; i < ARRAY_LENGTH; ++i ) expected->arr[i] = ToString(i); return expected; @@ -590,7 +586,7 @@ extern "C" DLL_EXPORT S_LPSTRArray* __cdecl S_LPSTRArray_Ret() extern "C" DLL_EXPORT S_BSTRArray* __cdecl S_BSTRArray_Ret() { S_BSTRArray *expected = (S_BSTRArray *)CoreClrAlloc( sizeof(S_BSTRArray) ); - for ( int i = 0; i < ARRAY_SIZE; ++i ) + for ( int i = 0; i < ARRAY_LENGTH; ++i ) expected->arr[i] = ToBSTR(i); return expected; @@ -600,7 +596,7 @@ extern "C" DLL_EXPORT S_BSTRArray* __cdecl S_BSTRArray_Ret() extern "C" DLL_EXPORT S_StructArray* __cdecl S_StructArray_Ret() { S_StructArray *expected = (S_StructArray *)CoreClrAlloc( sizeof(S_StructArray) ); - for ( int i = 0; i < ARRAY_SIZE; ++i ) + for ( int i = 0; i < ARRAY_LENGTH; ++i ) { expected->arr[i].x = i; expected->arr[i].d = i; diff --git a/src/tests/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp b/src/tests/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp index 3c98214341ab0..4493b5b671f18 100644 --- a/src/tests/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp +++ b/src/tests/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/MarshalArrayLPArrayNative.cpp @@ -45,7 +45,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Int(int *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(int, ARRAY_SIZE); + INIT_EXPECTED(int, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -55,10 +55,10 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Object(VARIANT *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - //VARIANT expected[ARRAY_SIZE]; - size_t nullIdx = ARRAY_SIZE / 2; + //VARIANT expected[ARRAY_LENGTH]; + size_t nullIdx = ARRAY_LENGTH / 2; - for (size_t i = 0; i < ARRAY_SIZE; ++i) + for (size_t i = 0; i < ARRAY_LENGTH; ++i) { //VariantInit(&expected[i]); if (i == nullIdx) @@ -89,7 +89,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Uint(UINT *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(UINT, ARRAY_SIZE); + INIT_EXPECTED(UINT, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -98,7 +98,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Short(SHORT *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(SHORT, ARRAY_SIZE); + INIT_EXPECTED(SHORT, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -107,7 +107,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Word(WORD *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(WORD, ARRAY_SIZE); + INIT_EXPECTED(WORD, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -116,7 +116,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Long64(LONG64 *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(LONG64, ARRAY_SIZE); + INIT_EXPECTED(LONG64, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -125,7 +125,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_ULong64(ULONG64 *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(ULONG64, ARRAY_SIZE); + INIT_EXPECTED(ULONG64, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -134,7 +134,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Double(DOUBLE *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(DOUBLE, ARRAY_SIZE); + INIT_EXPECTED(DOUBLE, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -143,7 +143,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Float(FLOAT *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(FLOAT, ARRAY_SIZE); + INIT_EXPECTED(FLOAT, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -152,7 +152,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Byte(BYTE *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(BYTE, ARRAY_SIZE); + INIT_EXPECTED(BYTE, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -161,7 +161,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Char(CHAR *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - INIT_EXPECTED(CHAR, ARRAY_SIZE); + INIT_EXPECTED(CHAR, ARRAY_LENGTH); return EQUALS(pActual, cActual, expected); } @@ -170,9 +170,9 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_LPCSTR(LPCSTR *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - LPSTR expected[ARRAY_SIZE]; - size_t nullIdx = ARRAY_SIZE / 2; - for (size_t i = 0; i < ARRAY_SIZE; ++i) + LPSTR expected[ARRAY_LENGTH]; + size_t nullIdx = ARRAY_LENGTH / 2; + for (size_t i = 0; i < ARRAY_LENGTH; ++i) { if (i == nullIdx) { @@ -184,7 +184,7 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_LPCSTR(LPCSTR *pActual, int cActual) int retval = EQUALS((LPSTR *)pActual, cActual, expected); - for (size_t i = 0; i < ARRAY_SIZE; ++i) + for (size_t i = 0; i < ARRAY_LENGTH; ++i) { if (i == nullIdx) continue; @@ -206,8 +206,8 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Struct(TestStruct *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - TestStruct expected[ARRAY_SIZE]; - for (size_t i = 0; i < ARRAY_SIZE; ++i) + TestStruct expected[ARRAY_LENGTH]; + for (size_t i = 0; i < ARRAY_LENGTH; ++i) { expected[i].x = (int)i; expected[i].d = (int)i; @@ -222,8 +222,8 @@ extern "C" DLL_EXPORT BOOL CStyle_Array_Bool(BOOL *pActual, int cActual) { CHECK_PARAM_NOT_EMPTY(pActual); - BOOL expected[ARRAY_SIZE]; - for (size_t i = 0; i < ARRAY_SIZE; ++i) + BOOL expected[ARRAY_LENGTH]; + for (size_t i = 0; i < ARRAY_LENGTH; ++i) { if (i % 2 == 0) expected[i] = TRUE; diff --git a/src/tests/Interop/StringMarshalling/AnsiBSTR/AnsiBStrTestNative.cpp b/src/tests/Interop/StringMarshalling/AnsiBSTR/AnsiBStrTestNative.cpp index 85e9173927965..4414cbed14430 100644 --- a/src/tests/Interop/StringMarshalling/AnsiBSTR/AnsiBStrTestNative.cpp +++ b/src/tests/Interop/StringMarshalling/AnsiBSTR/AnsiBStrTestNative.cpp @@ -7,6 +7,6 @@ using StringType = BSTR; using Tests = BStrMarshalingTests; -#define FUNCTION_NAME CoreClrBStrAlloc(__func__, ARRAYSIZE(__func__) - 1) +#define FUNCTION_NAME CoreClrBStrAlloc(__func__, STRING_LENGTH(__func__)) #include "../Native/StringTestEntrypoints.inl" diff --git a/src/tests/JIT/Performance/CodeQuality/Benchstones/MDBenchI/MDGeneralArray/MDGeneralArray.cs b/src/tests/JIT/Performance/CodeQuality/Benchstones/MDBenchI/MDGeneralArray/MDGeneralArray.cs index a89a1f6429412..c26db421224ef 100644 --- a/src/tests/JIT/Performance/CodeQuality/Benchstones/MDBenchI/MDGeneralArray/MDGeneralArray.cs +++ b/src/tests/JIT/Performance/CodeQuality/Benchstones/MDBenchI/MDGeneralArray/MDGeneralArray.cs @@ -1,7 +1,5 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -// using System.Runtime.CompilerServices; @@ -38,7 +36,7 @@ static bool VerifyCopy(int[,,] s, int[,,] d) { return true; } - + [MethodImpl(MethodImplOptions.NoInlining)] static bool Bench(int loop, int[,,] s, int[,,] d) { diff --git a/src/tests/JIT/SIMD/Vector3TestNative.cpp b/src/tests/JIT/SIMD/Vector3TestNative.cpp index bad17072320ba..2a41c39da4e00 100644 --- a/src/tests/JIT/SIMD/Vector3TestNative.cpp +++ b/src/tests/JIT/SIMD/Vector3TestNative.cpp @@ -3,6 +3,7 @@ #include #include +#include #if defined(__GNUC__) #define EXPORT(type) extern "C" __attribute__((visibility("default"))) type @@ -20,30 +21,26 @@ #endif // !__i386__ #endif // !defined(_MSC_VER) -#ifndef _countof -#define _countof(_array) (sizeof(_array)/sizeof(_array[0])) -#endif - #ifdef _MSC_VER #define CALLBACK __stdcall #else // _MSC_VER #define CALLBACK #endif // !_MSC_VER -typedef struct _Vector3 +typedef struct _Vector3 { float x; float y; - float z; + float z; } Vector3; -typedef struct _DT +typedef struct _DT { Vector3 a; Vector3 b; -} DT; +} DT; -typedef struct _ComplexDT +typedef struct _ComplexDT { int iv; DT vecs; @@ -55,7 +52,7 @@ typedef struct _ComplexDT // PInvoke native call for Vector3 size check // -EXPORT(int) __stdcall nativeCall_PInvoke_CheckVector3Size() +EXPORT(int) __stdcall nativeCall_PInvoke_CheckVector3Size() { printf("nativeCall_PInvoke_CheckVector3Size: sizeof(Vector3) == %d\n", (int)sizeof(Vector3)); fflush(stdout); @@ -66,7 +63,7 @@ EXPORT(int) __stdcall nativeCall_PInvoke_CheckVector3Size() // PInvoke native call for Vector3 argument // -EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Arg(int i, Vector3 v1, char* s, Vector3 v2) +EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Arg(int i, Vector3 v1, char* s, Vector3 v2) { float sum0 = v1.x + v1.y + v1.z; float sum1 = v2.x + v2.y + v2.z; @@ -78,7 +75,7 @@ EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Arg(int i, Vector3 v1, char* s fflush(stdout); if ((strncmp(s, "abcdefg", strnlen(s, 32)) != 0) || i != 123) { return 0; - } + } return sum0 + sum1; } @@ -86,7 +83,7 @@ EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Arg(int i, Vector3 v1, char* s // PInvoke native call for Vector3 argument // EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Arg_Unix( - Vector3 v3f32_xmm0, + Vector3 v3f32_xmm0, float f32_xmm2, float f32_xmm3, float f32_xmm4, @@ -105,28 +102,28 @@ EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Arg_Unix( printf(" f32_mem0: %f\n", f32_mem0); printf(" v3f32_mem1: %f %f %f\n", v3f32_mem1.x, v3f32_mem1.y, v3f32_mem1.z); printf(" f32_mem2-3: %f %f\n", f32_mem2, f32_mem3); - + // sum = 1 + 2 + 3 - // + 100 + 101 + 102 + 103 + 104 + 105 + 106 + // + 100 + 101 + 102 + 103 + 104 + 105 + 106 // + 10 + 20 + 30 // + 107 + 108 // = 1002 float sum = v3f32_xmm0.x + v3f32_xmm0.y + v3f32_xmm0.z - + f32_xmm2 + f32_xmm3 + f32_xmm4 + f32_xmm5 + f32_xmm6 + f32_xmm7 + f32_mem0 + + + f32_xmm2 + f32_xmm3 + f32_xmm4 + f32_xmm5 + f32_xmm6 + f32_xmm7 + f32_mem0 + + v3f32_mem1.x + v3f32_mem1.y + v3f32_mem1.z + f32_mem2 + f32_mem3; - + printf(" sum = %f\n", sum); - + return sum; -} +} // // PInvoke native call for Vector3 argument // EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Arg_Unix2( - Vector3 v3f32_xmm0, + Vector3 v3f32_xmm0, float f32_xmm2, float f32_xmm3, float f32_xmm4, @@ -142,39 +139,39 @@ EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Arg_Unix2( { printf("nativeCall_PInvoke_Vector3Arg_Unix2:\n"); printf(" v3f32_xmm0: %f %f %f\n", v3f32_xmm0.x, v3f32_xmm0.y, v3f32_xmm0.z); - printf(" f32_xmm2 - f32_xmm7: %f %f %f %f %f %f\n", + printf(" f32_xmm2 - f32_xmm7: %f %f %f %f %f %f\n", f32_xmm2, f32_xmm3, f32_xmm4, f32_xmm5, f32_xmm6, f32_xmm7); printf(" f32_mem0: %f\n", f32_mem0); printf(" v3f32_mem1: %f %f %f\n", v3f32_mem1.x, v3f32_mem1.y, v3f32_mem1.z); printf(" f32_mem2-3: %f %f\n", f32_mem2, f32_mem3); printf(" v3f32_mem4: %f %f %f\n", v3f32_mem4.x, v3f32_mem4.y, v3f32_mem4.z); printf(" f32_mem5: %f\n", f32_mem5); - - // sum = 1 + 2 + 3 + - // + 100 + 101 + 102 + 103 + 104 + 105 + 106 + + // sum = 1 + 2 + 3 + + // + 100 + 101 + 102 + 103 + 104 + 105 + 106 // + 4 + 5 + 6 // + 107 + 108 // + 7 + 8 + 9 // + 109 // = 6 + 15 + 24 + 1045 = 1090 float sum = v3f32_xmm0.x + v3f32_xmm0.y + v3f32_xmm0.z - + f32_xmm2 + f32_xmm3 + f32_xmm4 + f32_xmm5 + f32_xmm6 + f32_xmm7 + f32_mem0 + + + f32_xmm2 + f32_xmm3 + f32_xmm4 + f32_xmm5 + f32_xmm6 + f32_xmm7 + f32_mem0 + + v3f32_mem1.x + v3f32_mem1.y + v3f32_mem1.z + f32_mem2 + f32_mem3 + v3f32_mem4.x + v3f32_mem4.y + v3f32_mem4.z + f32_mem5; - + printf(" sum = %f\n", sum); - + return sum; -} +} // // PInvoke native call for Vector3 argument // -EXPORT(Vector3) __stdcall nativeCall_PInvoke_Vector3Ret() +EXPORT(Vector3) __stdcall nativeCall_PInvoke_Vector3Ret() { Vector3 ret; ret.x = 1; @@ -192,11 +189,11 @@ EXPORT(Vector3) __stdcall nativeCall_PInvoke_Vector3Ret() // PInvoke native call for Vector3 array // -EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Array(Vector3* arr) +EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Array(Vector3* arr) { float sum = 0.0; printf("nativeCall_PInvoke_Vector3Array\n"); - for (unsigned i = 0; i < 2; ++i) + for (unsigned i = 0; i < 2; ++i) { Vector3* e = &arr[i]; printf(" arrEle[%d]: %f %f %f\n", i, e->x, e->y, e->z); @@ -211,7 +208,7 @@ EXPORT(float) __stdcall nativeCall_PInvoke_Vector3Array(Vector3* arr) // PInvoke native call for Vector3 in struct // -EXPORT(DT) __stdcall nativeCall_PInvoke_Vector3InStruct(DT data) +EXPORT(DT) __stdcall nativeCall_PInvoke_Vector3InStruct(DT data) { printf("nativeCall_PInvoke_Vector3InStruct\n"); DT ret; @@ -221,9 +218,9 @@ EXPORT(DT) __stdcall nativeCall_PInvoke_Vector3InStruct(DT data) ret.b.x = data.b.x + 1; ret.b.y = data.b.y + 1; ret.b.z = data.b.z + 1; - printf(" First struct memeber: (%f %f %f) -> (%f %f %f)\n", + printf(" First struct memeber: (%f %f %f) -> (%f %f %f)\n", data.a.x, data.a.y, data.a.z, ret.a.x, ret.a.y, ret.a.z); - printf(" Second struct member: (%f %f %f) -> (%f %f %f)\n", + printf(" Second struct member: (%f %f %f) -> (%f %f %f)\n", data.b.x, data.b.y, data.b.z, ret.b.x, ret.b.y, ret.b.z); float sum = ret.a.x + ret.a.y + ret.a.z + ret.b.x + ret.b.y + ret.b.z; printf(" Sum of all return scalar values = %f\n", sum); @@ -235,14 +232,14 @@ EXPORT(DT) __stdcall nativeCall_PInvoke_Vector3InStruct(DT data) // PInvoke native call for Vector3 in complex struct // -EXPORT(void) __stdcall nativeCall_PInvoke_Vector3InComplexStruct(ComplexDT* arg) +EXPORT(void) __stdcall nativeCall_PInvoke_Vector3InComplexStruct(ComplexDT* arg) { printf("nativeCall_PInvoke_Vector3InComplexStruct\n"); printf(" Arg ival: %d\n", arg->iv); printf(" Arg Vector3 v1: (%f %f %f)\n", arg->vecs.a.x, arg->vecs.a.y, arg->vecs.a.z); printf(" Arg Vector3 v2: (%f %f %f)\n", arg->vecs.b.x, arg->vecs.b.y, arg->vecs.b.z); printf(" Arg Vector3 v3: (%f %f %f)\n", arg->v3.x, arg->v3.y, arg->v3.z); - printf(" Arg string arg: %s\n", arg->str); + printf(" Arg string arg: %s\n", arg->str); arg->vecs.a.x = arg->vecs.a.x + 1; arg->vecs.a.y = arg->vecs.a.y + 1; @@ -252,22 +249,22 @@ EXPORT(void) __stdcall nativeCall_PInvoke_Vector3InComplexStruct(ComplexDT* arg) arg->vecs.b.z = arg->vecs.b.z + 1; arg->v3.x = arg->v3.x + 1; arg->v3.y = arg->v3.y + 1; - arg->v3.z = arg->v3.z + 1; + arg->v3.z = arg->v3.z + 1; arg->iv = arg->iv + 1; - snprintf(arg->str, _countof(arg->str), "%s", "ret_string"); - + snprintf(arg->str, ARRAY_SIZE(arg->str), "%s", "ret_string"); + printf(" Return ival: %d\n", arg->iv); printf(" Return Vector3 v1: (%f %f %f)\n", arg->vecs.a.x, arg->vecs.a.y, arg->vecs.a.z); printf(" Return Vector3 v2: (%f %f %f)\n", arg->vecs.b.x, arg->vecs.b.y, arg->vecs.b.z); printf(" Return Vector3 v3: (%f %f %f)\n", arg->v3.x, arg->v3.y, arg->v3.z); - printf(" Return string arg: %s\n", arg->str); - float sum = arg->vecs.a.x + arg->vecs.a.y + arg->vecs.a.z + printf(" Return string arg: %s\n", arg->str); + float sum = arg->vecs.a.x + arg->vecs.a.y + arg->vecs.a.z + arg->vecs.b.x + arg->vecs.b.y + arg->vecs.b.z + arg->v3.x + arg->v3.y + arg->v3.z; printf(" Sum of all return float scalar values = %f\n", sum); - fflush(stdout); + fflush(stdout); } - + // // RPInvoke native call for Vector3 argument // @@ -277,13 +274,13 @@ typedef void (CALLBACK *CallBack_RPInvoke_Vector3Arg)(int i, Vector3 v1, char* s EXPORT(void) __stdcall nativeCall_RPInvoke_Vector3Arg( CallBack_RPInvoke_Vector3Arg notify) { - int i = 123; + int i = 123; const static char* str = "abcdefg"; Vector3 v1, v2; v1.x = 1; v1.y = 2; v1.z = 3; v2.x = 10; v2.y = 20; v2.z = 30; notify(i, v1, (char*)str, v2); -} +} @@ -291,7 +288,7 @@ EXPORT(void) __stdcall nativeCall_RPInvoke_Vector3Arg( // RPInvoke native call for Vector3 argument // typedef void (CALLBACK *CallBack_RPInvoke_Vector3Arg_Unix)( - Vector3 v3f32_xmm0, + Vector3 v3f32_xmm0, float f32_xmm2, float f32_xmm3, float f32_xmm4, @@ -312,12 +309,12 @@ EXPORT(void) __stdcall nativeCall_RPInvoke_Vector3Arg_Unix( v2.x = 10; v2.y = 20; v2.z = 30; float f0 = 100, f1 = 101, f2 = 102, f3 = 103, f4 = 104, f5 = 105, f6 = 106, f7 = 107, f8 = 108; notify( - v1, + v1, f0, f1, f2, f3, f4, f5, f6, // mapped onto stack - v2, + v2, f7, f8); -} +} @@ -325,7 +322,7 @@ EXPORT(void) __stdcall nativeCall_RPInvoke_Vector3Arg_Unix( // RPInvoke native call for Vector3 argument // typedef void (CALLBACK *CallBack_RPInvoke_Vector3Arg_Unix2)( - Vector3 v3f32_xmm0, + Vector3 v3f32_xmm0, float f32_xmm2, float f32_xmm3, float f32_xmm4, @@ -349,14 +346,14 @@ EXPORT(void) __stdcall nativeCall_RPInvoke_Vector3Arg_Unix2( v3.x = 7; v3.y = 8; v3.z = 9; float f0 = 100, f1 = 101, f2 = 102, f3 = 103, f4 = 104, f5 = 105, f6 = 106, f7 = 107, f8 = 108, f9 = 109; notify( - v1, + v1, f0, f1, f2, f3, f4, f5, f6, // mapped onto stack - v2, + v2, f7, f8, v3, f9); -} +} // @@ -376,7 +373,7 @@ EXPORT(bool) __stdcall nativeCall_RPInvoke_Vector3Ret( return true; } return false; -} +} // // RPInvoke native call for Vector3 array @@ -387,7 +384,7 @@ typedef void (CALLBACK *CallBack_RPInvoke_Vector3Array)(Vector3* v, int size); static Vector3 arr[2]; EXPORT(void) __stdcall nativeCall_RPInvoke_Vector3Array( - CallBack_RPInvoke_Vector3Array notify, + CallBack_RPInvoke_Vector3Array notify, int a) { arr[0].x = a + 1.0f; @@ -397,7 +394,7 @@ EXPORT(void) __stdcall nativeCall_RPInvoke_Vector3Array( arr[1].y = a + 20.0f; arr[1].z = a + 30.0f; notify(arr, 2); -} +} // // RPInvoke native call for Vector3-in-struct test @@ -408,7 +405,7 @@ typedef void (CALLBACK *CallBack_RPInvoke_Vector3InStruct)(DT v); static DT v; EXPORT(void) __stdcall nativeCall_RPInvoke_Vector3InStruct( - CallBack_RPInvoke_Vector3InStruct notify, + CallBack_RPInvoke_Vector3InStruct notify, int a) { v.a.x = a + 1.0f; @@ -431,28 +428,28 @@ EXPORT(bool) __stdcall nativeCall_RPInvoke_Vector3InComplexStruct( { static ComplexDT cdt; cdt.iv = 99; - snprintf(cdt.str, _countof("arg_string"), "%s", "arg_string"); + snprintf(cdt.str, ARRAY_SIZE("arg_string"), "%s", "arg_string"); cdt.vecs.a.x = 1; cdt.vecs.a.y = 2; cdt.vecs.a.z = 3; cdt.vecs.b.x = 5; cdt.vecs.b.y = 6; cdt.vecs.b.z = 7; - cdt.v3.x = 10; cdt.v3.y = 20; cdt.v3.z = 30; - + cdt.v3.x = 10; cdt.v3.y = 20; cdt.v3.z = 30; + notify(&cdt); - + printf(" Native ival: %d\n", cdt.iv); printf(" Native Vector3 v1: (%f %f %f)\n", cdt.vecs.a.x, cdt.vecs.a.y, cdt.vecs.a.z); printf(" Native Vector3 v2: (%f %f %f)\n", cdt.vecs.b.x, cdt.vecs.b.y, cdt.vecs.b.z); printf(" Native Vector3 v3: (%f %f %f)\n", cdt.v3.x, cdt.v3.y, cdt.v3.z); - printf(" Native string arg: %s\n", cdt.str); + printf(" Native string arg: %s\n", cdt.str); fflush(stdout); - + // Expected return value = 2 + 3 + 4 + 6 + 7 + 8 + 11 + 12 + 13 = 93 float sum = cdt.vecs.a.x + cdt.vecs.a.y + cdt.vecs.a.z - + cdt.vecs.b.x + cdt.vecs.b.y + cdt.vecs.b.z + + cdt.vecs.b.x + cdt.vecs.b.y + cdt.vecs.b.z + cdt.v3.x + cdt.v3.y + cdt.v3.z; - + if ((sum != 93) || (cdt.iv != 100) || (strcmp(cdt.str, "ret_string")!=0) ) { - return false; - } + return false; + } return true; }