From 13b3c5bb387852ff005daa653c493ab452f59349 Mon Sep 17 00:00:00 2001 From: Steve MacLean Date: Thu, 6 Feb 2020 16:55:05 -0500 Subject: [PATCH] Configure Host OS APIs based on HOST macros (#31774) * Use gcenv.windows.inl on Windows HOSTS * Make two way pipe implementation depend on host We have no ability to implement a cross OS pipe. Allow the two way pipe implentation depend on the host. * Use empty debug macro implementation on Windows hosts. * Make HMODULE type depend on host compiler * Configure long file path wrappers based on host * Configure memcpy based on host * Configure FreeLibrary based on host * Configure host utility funtion based on host VirtualAlloc, CPU count, NUMA config make most sense as host queries. Configure based on host. * Configure exceptiion holder based on host * Prefer #if HOST_WINDOWS for longfilepathwrappers.cpp * Prefer #if HOST_WINDOWS for src/coreclr/src/inc/holder.h * Do not include GCToOSInterface::GetPageSize() in DAC * Remove JIT64_BUILD * !HOST_UNIX -> HOST_WINDOWS --- src/coreclr/src/debug/inc/twowaypipe.h | 6 +-- src/coreclr/src/gc/env/gcenv.unix.inl | 2 + src/coreclr/src/inc/debugmacros.h | 2 +- src/coreclr/src/inc/ex.h | 6 +-- src/coreclr/src/inc/holder.h | 8 ++-- src/coreclr/src/inc/palclr.h | 12 ++---- src/coreclr/src/inc/palclr_win.h | 8 ++-- src/coreclr/src/inc/utilcode.h | 26 ++++++------ src/coreclr/src/utilcode/ccomprc.cpp | 22 +++++------ src/coreclr/src/utilcode/longfilepathwrappers.cpp | 22 +++++------ src/coreclr/src/utilcode/util.cpp | 48 +++++++++++------------ src/coreclr/src/vm/common.h | 12 +++--- src/coreclr/src/vm/util.hpp | 2 +- 13 files changed, 87 insertions(+), 89 deletions(-) diff --git a/src/coreclr/src/debug/inc/twowaypipe.h b/src/coreclr/src/debug/inc/twowaypipe.h index 18942b4..5a3d78e 100644 --- a/src/coreclr/src/debug/inc/twowaypipe.h +++ b/src/coreclr/src/debug/inc/twowaypipe.h @@ -8,7 +8,7 @@ #include "processdescriptor.h" -#ifdef TARGET_UNIX +#ifdef HOST_UNIX #define INVALID_PIPE -1 #else #define INVALID_PIPE INVALID_HANDLE_VALUE @@ -83,7 +83,7 @@ private: State m_state; -#ifdef TARGET_UNIX +#ifdef HOST_UNIX int m_inboundPipe, m_outboundPipe; // two one sided pipes used for communication char m_inPipeName[MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH]; // filename of the inbound pipe @@ -99,7 +99,7 @@ private: HANDLE CreateOneWayPipe(DWORD id, bool inbound); HANDLE m_inboundPipe, m_outboundPipe; //two one sided pipes used for communication -#endif //TARGET_UNIX +#endif //HOST_UNIX }; #endif //TwoWayPipe_H diff --git a/src/coreclr/src/gc/env/gcenv.unix.inl b/src/coreclr/src/gc/env/gcenv.unix.inl index 42b8a43..cc71651 100644 --- a/src/coreclr/src/gc/env/gcenv.unix.inl +++ b/src/coreclr/src/gc/env/gcenv.unix.inl @@ -11,9 +11,11 @@ extern uint32_t g_pageSizeUnixInl; #define OS_PAGE_SIZE GCToOSInterface::GetPageSize() +#ifndef DACCESS_COMPILE __forceinline size_t GCToOSInterface::GetPageSize() { return g_pageSizeUnixInl; } +#endif // DACCESS_COMPILE #endif // __GCENV_UNIX_INL__ diff --git a/src/coreclr/src/inc/debugmacros.h b/src/coreclr/src/inc/debugmacros.h index 14cba42..4fb4fb8 100644 --- a/src/coreclr/src/inc/debugmacros.h +++ b/src/coreclr/src/inc/debugmacros.h @@ -201,7 +201,7 @@ do { hr = (EXPR); if(hr != ERROR_SUCCESS) { hr = HRESULT_FROM_WIN32(hr); goto LA #define _ASSERT _ASSERTE -#if defined(_DEBUG) && !defined(TARGET_UNIX) +#if defined(_DEBUG) && defined(HOST_WINDOWS) // This function returns the EXE time stamp (effectively a random number) // Under retail it always returns 0. This is meant to be used in the diff --git a/src/coreclr/src/inc/ex.h b/src/coreclr/src/inc/ex.h index 548fa22..4037e51 100644 --- a/src/coreclr/src/inc/ex.h +++ b/src/coreclr/src/inc/ex.h @@ -6,15 +6,15 @@ #if !defined(_EX_H_) #define _EX_H_ -#ifdef TARGET_UNIX +#ifdef HOST_UNIX #define EX_TRY_HOLDER \ HardwareExceptionHolder \ NativeExceptionHolderCatchAll __exceptionHolder; \ __exceptionHolder.Push(); \ -#else // TARGET_UNIX +#else // HOST_UNIX #define EX_TRY_HOLDER -#endif // TARGET_UNIX +#endif // HOST_UNIX #include "sstring.h" #include "crtwrap.h" diff --git a/src/coreclr/src/inc/holder.h b/src/coreclr/src/inc/holder.h index 4ac4182..1d34f2b 100644 --- a/src/coreclr/src/inc/holder.h +++ b/src/coreclr/src/inc/holder.h @@ -1175,10 +1175,10 @@ FORCEINLINE void CounterDecrease(RAW_KEYWORD(volatile) LONG* p) {InterlockedDecr typedef Wrapper> CounterHolder; -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS FORCEINLINE void RegKeyRelease(HKEY k) {RegCloseKey(k);}; typedef Wrapper RegKeyHolder; -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS class ErrorModeHolder { @@ -1189,7 +1189,7 @@ public: UINT OldMode() {return m_oldMode;}; }; -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS //----------------------------------------------------------------------------- // HKEYHolder : HKEY holder, Calls RegCloseKey on scope exit. // @@ -1244,7 +1244,7 @@ public: private: HKEY m_value; }; -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS //---------------------------------------------------------------------------- // diff --git a/src/coreclr/src/inc/palclr.h b/src/coreclr/src/inc/palclr.h index 1fcd951..5978ea1 100644 --- a/src/coreclr/src/inc/palclr.h +++ b/src/coreclr/src/inc/palclr.h @@ -10,7 +10,7 @@ // =========================================================================== -#if !defined(HOST_UNIX) +#if defined(HOST_WINDOWS) #ifndef __PALCLR_H__ #define __PALCLR_H__ @@ -19,11 +19,7 @@ // Unix L"" is UTF32, and on windows it's UTF16. Because of built-in assumptions on the size // of string literals, it's important to match behaviour between Unix and Windows. Unix will be defined // as u"" (char16_t) -#ifdef HOST_UNIX -#define W(str) u##str -#else // HOST_UNIX #define W(str) L##str -#endif // HOST_UNIX #include @@ -515,7 +511,7 @@ #endif -#if defined(_DEBUG_IMPL) && !defined(JIT_BUILD) && !defined(JIT64_BUILD) && !defined(CROSS_COMPILE) && !defined(DISABLE_CONTRACTS) +#if defined(_DEBUG_IMPL) && !defined(JIT_BUILD) && !defined(CROSS_COMPILE) && !defined(DISABLE_CONTRACTS) #define PAL_TRY_HANDLER_DBG_BEGIN \ BOOL ___oldOkayToThrowValue = FALSE; \ ClrDebugState *___pState = ::GetClrDebugState(); \ @@ -560,7 +556,7 @@ #define PAL_TRY_HANDLER_DBG_BEGIN_DLLMAIN(_reason) ANNOTATION_TRY_BEGIN; #define PAL_TRY_HANDLER_DBG_END ANNOTATION_TRY_END; #define PAL_ENDTRY_NAKED_DBG -#endif // defined(ENABLE_CONTRACTS_IMPL) && !defined(JIT64_BUILD) +#endif // defined(ENABLE_CONTRACTS_IMPL) #if !BIGENDIAN @@ -631,4 +627,4 @@ #include "palclr_win.h" -#endif // !defined(HOST_UNIX) +#endif // defined(HOST_WINDOWS) diff --git a/src/coreclr/src/inc/palclr_win.h b/src/coreclr/src/inc/palclr_win.h index 2d88e6f..4db25f6 100644 --- a/src/coreclr/src/inc/palclr_win.h +++ b/src/coreclr/src/inc/palclr_win.h @@ -85,7 +85,7 @@ -#if defined(_DEBUG_IMPL) && !defined(JIT_BUILD) && !defined(JIT64_BUILD) && !defined(HOST_ARM) // @ARMTODO +#if defined(_DEBUG_IMPL) && !defined(JIT_BUILD) && !defined(HOST_ARM) // @ARMTODO #define WIN_PAL_TRY_HANDLER_DBG_BEGIN \ BOOL ___oldOkayToThrowValue = FALSE; \ ClrDebugState *___pState = GetClrDebugState(); \ @@ -133,12 +133,12 @@ #define WIN_PAL_TRY_HANDLER_DBG_BEGIN_DLLMAIN(_reason) ANNOTATION_TRY_BEGIN; #define WIN_PAL_TRY_HANDLER_DBG_END ANNOTATION_TRY_END; #define WIN_PAL_ENDTRY_NAKED_DBG -#endif // defined(ENABLE_CONTRACTS_IMPL) && !defined(JIT64_BUILD) +#endif // defined(ENABLE_CONTRACTS_IMPL) -#if !defined (TARGET_UNIX) +#if defined(HOST_WINDOWS) // Native system libray handle. // In Windows, NATIVE_LIBRARY_HANDLE is the same as HMODULE. typedef HMODULE NATIVE_LIBRARY_HANDLE; -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS #endif // __PALCLR_WIN_H__ diff --git a/src/coreclr/src/inc/utilcode.h b/src/coreclr/src/inc/utilcode.h index 4fb33d1..73971b5 100644 --- a/src/coreclr/src/inc/utilcode.h +++ b/src/coreclr/src/inc/utilcode.h @@ -704,9 +704,9 @@ public: m_nHashSize = 0; m_csMap = NULL; m_pResourceFile = NULL; -#ifdef TARGET_UNIX +#ifdef HOST_UNIX m_pResourceDomain = NULL; -#endif // TARGET_UNIX +#endif // HOST_UNIX }// CCompRC @@ -794,12 +794,12 @@ private: CRITSEC_COOKIE m_csMap; LPCWSTR m_pResourceFile; -#ifdef TARGET_UNIX +#ifdef HOST_UNIX // Resource domain is an ANSI string identifying a native resources file static LPCSTR m_pDefaultResourceDomain; static LPCSTR m_pFallbackResourceDomain; LPCSTR m_pResourceDomain; -#endif // TARGET_UNIX +#endif // HOST_UNIX // Main accessors for hash HRESOURCEDLL LookupNode(LocaleID langId, BOOL &fMissing); @@ -1280,16 +1280,16 @@ public: // functions static LPVOID VirtualAllocExNuma(HANDLE hProc, LPVOID lpAddr, SIZE_T size, DWORD allocType, DWORD prot, DWORD node); -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS static BOOL GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no); static bool GetNumaInfo(PUSHORT total_nodes, DWORD* max_procs_per_node); -#else // !TARGET_UNIX +#else // HOST_WINDOWS static BOOL GetNumaProcessorNodeEx(USHORT proc_no, PUSHORT node_no); -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS #endif }; -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS struct CPU_Group_Info { @@ -1353,7 +1353,7 @@ public: DWORD_PTR GetCurrentProcessCpuMask(); -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS //****************************************************************************** // Returns the number of processors that a process has been configured to run on @@ -4321,7 +4321,7 @@ public: return PAL_GetStackLimit(); } -#else // !HOST_UNIX +#else // HOST_UNIX // returns pointer that uniquely identifies the fiber static void* GetFiberPtrId() @@ -4370,7 +4370,7 @@ public: { return (void*) 1; } -#endif // !HOST_UNIX +#endif // HOST_UNIX }; #if !defined(DACCESS_COMPILE) @@ -4809,7 +4809,7 @@ namespace util * Overloaded operators for the executable heap * ------------------------------------------------------------------------ */ -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS struct CExecutable { int x; }; extern const CExecutable executable; @@ -4833,7 +4833,7 @@ template void DeleteExecutable(T *p) } } -#endif // TARGET_UNIX +#endif // HOST_WINDOWS INDEBUG(BOOL DbgIsExecutable(LPVOID lpMem, SIZE_T length);) diff --git a/src/coreclr/src/utilcode/ccomprc.cpp b/src/coreclr/src/utilcode/ccomprc.cpp index 0fca5cc..1417caf 100644 --- a/src/coreclr/src/utilcode/ccomprc.cpp +++ b/src/coreclr/src/utilcode/ccomprc.cpp @@ -8,7 +8,7 @@ #include "ndpversion.h" #include "../dlls/mscorrc/resource.h" -#ifdef TARGET_UNIX +#ifdef HOST_UNIX #include "resourcestring.h" #define NATIVE_STRING_RESOURCE_NAME mscorrc_debug __attribute__((visibility("default"))) DECLARE_NATIVE_STRING_RESOURCE_TABLE(NATIVE_STRING_RESOURCE_NAME); @@ -115,10 +115,10 @@ HRESULT CCompRC::AddMapNode(LocaleID langId, HRESOURCEDLL hInst, BOOL fMissing) LPCWSTR CCompRC::m_pDefaultResource = W("mscorrc.debug.dll"); LPCWSTR CCompRC::m_pFallbackResource= W("mscorrc.dll"); -#ifdef TARGET_UNIX +#ifdef HOST_UNIX LPCSTR CCompRC::m_pDefaultResourceDomain = "mscorrc.debug"; LPCSTR CCompRC::m_pFallbackResourceDomain = "mscorrc"; -#endif // TARGET_UNIX +#endif // HOST_UNIX HRESULT CCompRC::Init(LPCWSTR pResourceFile, BOOL bUseFallback) { @@ -166,7 +166,7 @@ HRESULT CCompRC::Init(LPCWSTR pResourceFile, BOOL bUseFallback) return E_OUTOFMEMORY; } -#ifdef TARGET_UNIX +#ifdef HOST_UNIX if (m_pResourceFile == m_pDefaultResource) { @@ -181,7 +181,7 @@ HRESULT CCompRC::Init(LPCWSTR pResourceFile, BOOL bUseFallback) _ASSERTE(!"Unsupported resource file"); } -#endif // TARGET_UNIX +#endif // HOST_UNIX if (m_csMap == NULL) { @@ -551,7 +551,7 @@ HRESULT CCompRC::LoadString(ResourceCategory eCategory, LocaleID langId, UINT iR } CONTRACTL_END; -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS HRESULT hr; HRESOURCEDLL hInst = 0; //instance of cultured resource dll int length; @@ -692,17 +692,17 @@ HRESULT CCompRC::LoadString(ResourceCategory eCategory, LocaleID langId, UINT iR *szBuffer = W('\0'); return hr; -#else // !TARGET_UNIX +#else // HOST_WINDOWS return LoadNativeStringResource(NATIVE_STRING_RESOURCE_TABLE(NATIVE_STRING_RESOURCE_NAME), iResourceID, szBuffer, iMax, pcwchUsed); -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS } #ifndef DACCESS_COMPILE HRESULT CCompRC::LoadResourceFile(HRESOURCEDLL * pHInst, LPCWSTR lpFileName) { -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS DWORD dwLoadLibraryFlags; if(m_pResourceFile == m_pDefaultResource) dwLoadLibraryFlags = LOAD_LIBRARY_AS_DATAFILE; @@ -712,9 +712,9 @@ HRESULT CCompRC::LoadResourceFile(HRESOURCEDLL * pHInst, LPCWSTR lpFileName) if ((*pHInst = WszLoadLibraryEx(lpFileName, NULL, dwLoadLibraryFlags)) == NULL) { return HRESULT_FROM_GetLastError(); } -#else // !TARGET_UNIX +#else // HOST_WINDOWS PORTABILITY_ASSERT("UNIXTODO: Implement resource loading - use peimagedecoder?"); -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS return S_OK; } diff --git a/src/coreclr/src/utilcode/longfilepathwrappers.cpp b/src/coreclr/src/utilcode/longfilepathwrappers.cpp index 44c35ad..4a0bf3b 100644 --- a/src/coreclr/src/utilcode/longfilepathwrappers.cpp +++ b/src/coreclr/src/utilcode/longfilepathwrappers.cpp @@ -11,14 +11,14 @@ class LongFile { private: -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS static const WCHAR* ExtendedPrefix; static const WCHAR* DevicePathPrefix; static const WCHAR* UNCPathPrefix; static const WCHAR* UNCExtendedPathPrefix; static const WCHAR VolumeSeparatorChar; #define UNCPATHPREFIX W("\\\\") -#endif //TARGET_UNIX +#endif //HOST_WINDOWS static const WCHAR DirectorySeparatorChar; static const WCHAR AltDirectorySeparatorChar; public: @@ -31,7 +31,7 @@ public: static HRESULT NormalizePath(SString& path); -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS static void NormalizeDirectorySeparators(SString& path); #endif }; @@ -60,11 +60,11 @@ LoadLibraryExWrapper( if (LongFile::IsPathNotFullyQualified(path) || SUCCEEDED(LongFile::NormalizePath(path))) { -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS //Adding the assert to ensure relative paths which are not just filenames are not used for LoadLibrary Calls _ASSERTE(!LongFile::IsPathNotFullyQualified(path) || !LongFile::ContainsDirectorySeparator(path)); LongFile::NormalizeDirectorySeparators(path); -#endif //TARGET_UNIX +#endif //HOST_WINDOWS ret = LoadLibraryExW(path.GetUnicode(), hFile, dwFlags); } @@ -657,7 +657,7 @@ DWORD WINAPI GetEnvironmentVariableWrapper( } -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS BOOL CopyFileExWrapper( @@ -764,10 +764,10 @@ FindFirstFileExWrapper( return ret; } -#endif //!TARGET_UNIX +#endif // HOST_WINDOWS -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS #if ! defined(DACCESS_COMPILE) && !defined(SELF_NO_HOST) extern HINSTANCE g_pMSCorEE; @@ -822,13 +822,13 @@ BOOL PAL_GetPALDirectoryWrapper(SString& pbuffer) return retval; } -#endif // TARGET_UNIX +#endif // HOST_WINDOWS //Implementation of LongFile Helpers const WCHAR LongFile::DirectorySeparatorChar = W('\\'); const WCHAR LongFile::AltDirectorySeparatorChar = W('/'); -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS const WCHAR LongFile::VolumeSeparatorChar = W(':'); const WCHAR* LongFile::ExtendedPrefix = W("\\\\?\\"); const WCHAR* LongFile::DevicePathPrefix = W("\\\\.\\"); @@ -1003,7 +1003,7 @@ HRESULT LongFile::NormalizePath(SString & path) { return S_OK; } -#endif //TARGET_UNIX +#endif //HOST_WINDOWS BOOL LongFile::ContainsDirectorySeparator(SString & path) { diff --git a/src/coreclr/src/utilcode/util.cpp b/src/coreclr/src/utilcode/util.cpp index db7f2be..9ee6444 100644 --- a/src/coreclr/src/utilcode/util.cpp +++ b/src/coreclr/src/utilcode/util.cpp @@ -503,12 +503,12 @@ BYTE * ClrVirtualAllocExecutable(SIZE_T dwSize, // Fall through to #endif // USE_UPPER_ADDRESS -#ifdef TARGET_UNIX +#ifdef HOST_UNIX // Tell PAL to use the executable memory allocator to satisfy this request for virtual memory. // This will allow us to place JIT'ed code close to the coreclr library // and thus improve performance by avoiding jump stubs in managed code. flAllocationType |= MEM_RESERVE_EXECUTABLE; -#endif // TARGET_UNIX +#endif // HOST_UNIX return (BYTE *) ClrVirtualAlloc (NULL, dwSize, flAllocationType, flProtect); @@ -523,13 +523,13 @@ LPVOID ClrVirtualAllocAligned(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocatio _ASSERTE(alignment != 0); _ASSERTE((alignment & (alignment - 1)) == 0); -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS // The VirtualAlloc on Windows ensures 64kB alignment _ASSERTE(alignment <= 0x10000); return ClrVirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); -#else // !TARGET_UNIX +#else // HOST_WINDOWS if(alignment < GetOsPageSize()) alignment = GetOsPageSize(); @@ -538,7 +538,7 @@ LPVOID ClrVirtualAllocAligned(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocatio SIZE_T addr = (SIZE_T)ClrVirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect); return (LPVOID)((addr + (alignment - 1)) & ~(alignment - 1)); -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS } #ifdef _DEBUG @@ -620,13 +620,13 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, return (BYTE*) ClrVirtualAlloc(nullptr, dwSize, flAllocationType, flProtect); } -#ifdef TARGET_UNIX +#ifdef HOST_UNIX pResult = (BYTE *)PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange(pMinAddr, pMaxAddr, dwSize); if (pResult != nullptr) { return pResult; } -#endif // TARGET_UNIX +#endif // HOST_UNIX // We will do one scan from [pMinAddr .. pMaxAddr] // First align the tryAddr up to next 64k base address. @@ -733,7 +733,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, return ::VirtualAllocExNuma(hProc, lpAddr, dwSize, allocType, prot, node); } -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS /*static*/ BOOL NumaNodeInfo::GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no) { return ::GetNumaProcessorNodeEx(proc_no, node_no); @@ -767,12 +767,12 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, return false; } -#else // !TARGET_UNIX +#else // HOST_WINDOWS /*static*/ BOOL NumaNodeInfo::GetNumaProcessorNodeEx(USHORT proc_no, PUSHORT node_no) { return PAL_GetNumaProcessorNode(proc_no, node_no); } -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS #endif /*static*/ BOOL NumaNodeInfo::m_enableGCNumaAware = FALSE; @@ -808,7 +808,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, m_enableGCNumaAware = InitNumaNodeInfoAPI(); } -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS //****************************************************************************** // CPUGroupInfo @@ -840,7 +840,7 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, { LIMITED_METHOD_CONTRACT; -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS return ::GetSystemTimes(idleTime, kernelTime, userTime); #else return FALSE; @@ -1238,7 +1238,7 @@ BOOL CPUGroupInfo::GetCPUGroupRange(WORD group_number, WORD* group_begin, WORD* LIMITED_METHOD_CONTRACT; return m_threadUseAllCpuGroups; } -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS //****************************************************************************** // Returns the number of processors that a process has been configured to run on @@ -1259,7 +1259,7 @@ int GetCurrentProcessCpuCount() unsigned int count = 0; -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS DWORD_PTR pmask, smask; if (!GetProcessAffinityMask(GetCurrentProcess(), &pmask, &smask)) @@ -1287,20 +1287,20 @@ int GetCurrentProcessCpuCount() count = 64; } -#else // !TARGET_UNIX +#else // HOST_WINDOWS count = PAL_GetLogicalCpuCountFromOS(); uint32_t cpuLimit; if (PAL_GetCpuLimit(&cpuLimit) && cpuLimit < count) count = cpuLimit; -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS cCPUs = count; return count; } -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS DWORD_PTR GetCurrentProcessCpuMask() { CONTRACTL @@ -1310,7 +1310,7 @@ DWORD_PTR GetCurrentProcessCpuMask() } CONTRACTL_END; -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS DWORD_PTR pmask, smask; if (!GetProcessAffinityMask(GetCurrentProcess(), &pmask, &smask)) @@ -1322,7 +1322,7 @@ DWORD_PTR GetCurrentProcessCpuMask() return 0; #endif } -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS uint32_t GetOsPageSizeUncached() { @@ -1338,7 +1338,7 @@ namespace uint32_t GetOsPageSize() { -#ifdef TARGET_UNIX +#ifdef HOST_UNIX size_t result = g_pageSize.LoadWithoutBarrier(); if(!result) @@ -2958,7 +2958,7 @@ BOOL IsIPInModule(HMODULE_TGT hModule, PCODE ip) param.fRet = FALSE; // UNIXTODO: implement a proper version for PAL -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS PAL_TRY(Param *, pParam, ¶m) { PTR_BYTE pBase = dac_cast(pParam->hModule); @@ -3027,7 +3027,7 @@ lDone: ; { } PAL_ENDTRY -#endif // !TARGET_UNIX +#endif // HOST_WINDOWS return param.fRet; } @@ -3096,7 +3096,7 @@ namespace Util static BOOL g_fLocalAppDataDirectoryInitted = FALSE; static WCHAR *g_wszLocalAppDataDirectory = NULL; -#ifndef TARGET_UNIX +#ifdef HOST_WINDOWS // Struct used to scope suspension of client impersonation for the current thread. // https://docs.microsoft.com/en-us/windows/desktop/secauthz/client-impersonation class SuspendImpersonation @@ -3337,7 +3337,7 @@ namespace Com return __imp::FindSubKeyDefaultValueForCLSID(rclsid, W("InprocServer32"), ssInprocServer32Name); } } // namespace Com -#endif // TARGET_UNIX +#endif // HOST_WINDOWS } // namespace Util } // namespace Clr diff --git a/src/coreclr/src/vm/common.h b/src/coreclr/src/vm/common.h index cbaa63ba..2f26763 100644 --- a/src/coreclr/src/vm/common.h +++ b/src/coreclr/src/vm/common.h @@ -242,11 +242,11 @@ FORCEINLINE void* memcpyUnsafe(void *dest, const void *src, size_t len) //If memcpy has been defined to PAL_memcpy, we undefine it so that this case //can be covered by the if !defined(memcpy) block below - #ifdef TARGET_UNIX + #ifdef HOST_UNIX #if IS_REDEFINED_IN_PAL(memcpy) #undef memcpy #endif //IS_REDEFINED_IN_PAL - #endif //TARGET_UNIX + #endif //HOST_UNIX // You should be using CopyValueClass if you are doing an memcpy // in the CG heap. @@ -254,11 +254,11 @@ FORCEINLINE void* memcpyUnsafe(void *dest, const void *src, size_t len) FORCEINLINE void* memcpyNoGCRefs(void * dest, const void * src, size_t len) { WRAPPER_NO_CONTRACT; - #ifndef TARGET_UNIX - return memcpy(dest, src, len); - #else //TARGET_UNIX + #ifdef HOST_UNIX return PAL_memcpy(dest, src, len); - #endif //TARGET_UNIX + #else //HOST_UNIX + return memcpy(dest, src, len); + #endif //HOST_UNIX } extern "C" void * __cdecl GCSafeMemCpy(void *, const void *, size_t); diff --git a/src/coreclr/src/vm/util.hpp b/src/coreclr/src/vm/util.hpp index d2b5639..e28ec88 100644 --- a/src/coreclr/src/vm/util.hpp +++ b/src/coreclr/src/vm/util.hpp @@ -655,7 +655,7 @@ FORCEINLINE void VoidFreeNativeLibrary(NATIVE_LIBRARY_HANDLE h) if (h == NULL) return; -#ifdef TARGET_UNIX +#ifdef HOST_UNIX PAL_FreeLibraryDirect(h); #else FreeLibrary(h); -- 2.7.4