#include "processdescriptor.h"
-#ifdef TARGET_UNIX
+#ifdef HOST_UNIX
#define INVALID_PIPE -1
#else
#define INVALID_PIPE INVALID_HANDLE_VALUE
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
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
#define OS_PAGE_SIZE GCToOSInterface::GetPageSize()
+#ifndef DACCESS_COMPILE
__forceinline size_t GCToOSInterface::GetPageSize()
{
return g_pageSizeUnixInl;
}
+#endif // DACCESS_COMPILE
#endif // __GCENV_UNIX_INL__
#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
#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"
typedef Wrapper<RAW_KEYWORD(volatile) LONG*, CounterIncrease, CounterDecrease, (UINT_PTR)0, CompareDefault<RAW_KEYWORD(volatile) LONG*>> CounterHolder;
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
FORCEINLINE void RegKeyRelease(HKEY k) {RegCloseKey(k);};
typedef Wrapper<HKEY,DoNothing,RegKeyRelease> RegKeyHolder;
-#endif // !TARGET_UNIX
+#endif // HOST_WINDOWS
class ErrorModeHolder
{
UINT OldMode() {return m_oldMode;};
};
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
//-----------------------------------------------------------------------------
// HKEYHolder : HKEY holder, Calls RegCloseKey on scope exit.
//
private:
HKEY m_value;
};
-#endif // !TARGET_UNIX
+#endif // HOST_WINDOWS
//----------------------------------------------------------------------------
//
// ===========================================================================
-#if !defined(HOST_UNIX)
+#if defined(HOST_WINDOWS)
#ifndef __PALCLR_H__
#define __PALCLR_H__
// 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 <windef.h>
#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(); \
#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
#include "palclr_win.h"
-#endif // !defined(HOST_UNIX)
+#endif // defined(HOST_WINDOWS)
-#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(); \
#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__
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
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);
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
{
DWORD_PTR GetCurrentProcessCpuMask();
-#endif // !TARGET_UNIX
+#endif // HOST_WINDOWS
//******************************************************************************
// Returns the number of processors that a process has been configured to run on
return PAL_GetStackLimit();
}
-#else // !HOST_UNIX
+#else // HOST_UNIX
// returns pointer that uniquely identifies the fiber
static void* GetFiberPtrId()
{
return (void*) 1;
}
-#endif // !HOST_UNIX
+#endif // HOST_UNIX
};
#if !defined(DACCESS_COMPILE)
* Overloaded operators for the executable heap
* ------------------------------------------------------------------------ */
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
struct CExecutable { int x; };
extern const CExecutable executable;
}
}
-#endif // TARGET_UNIX
+#endif // HOST_WINDOWS
INDEBUG(BOOL DbgIsExecutable(LPVOID lpMem, SIZE_T length);)
#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);
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)
{
return E_OUTOFMEMORY;
}
-#ifdef TARGET_UNIX
+#ifdef HOST_UNIX
if (m_pResourceFile == m_pDefaultResource)
{
_ASSERTE(!"Unsupported resource file");
}
-#endif // TARGET_UNIX
+#endif // HOST_UNIX
if (m_csMap == NULL)
{
}
CONTRACTL_END;
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
HRESULT hr;
HRESOURCEDLL hInst = 0; //instance of cultured resource dll
int length;
*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;
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;
}
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:
static HRESULT NormalizePath(SString& path);
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
static void NormalizeDirectorySeparators(SString& path);
#endif
};
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);
}
}
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
BOOL
CopyFileExWrapper(
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;
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("\\\\.\\");
{
return S_OK;
}
-#endif //TARGET_UNIX
+#endif //HOST_WINDOWS
BOOL LongFile::ContainsDirectorySeparator(SString & path)
{
// 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);
_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();
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
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.
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);
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;
m_enableGCNumaAware = InitNumaNodeInfoAPI();
}
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
//******************************************************************************
// CPUGroupInfo
{
LIMITED_METHOD_CONTRACT;
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
return ::GetSystemTimes(idleTime, kernelTime, userTime);
#else
return FALSE;
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
unsigned int count = 0;
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
DWORD_PTR pmask, smask;
if (!GetProcessAffinityMask(GetCurrentProcess(), &pmask, &smask))
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
}
CONTRACTL_END;
-#ifndef TARGET_UNIX
+#ifdef HOST_WINDOWS
DWORD_PTR pmask, smask;
if (!GetProcessAffinityMask(GetCurrentProcess(), &pmask, &smask))
return 0;
#endif
}
-#endif // !TARGET_UNIX
+#endif // HOST_WINDOWS
uint32_t GetOsPageSizeUncached()
{
uint32_t GetOsPageSize()
{
-#ifdef TARGET_UNIX
+#ifdef HOST_UNIX
size_t result = g_pageSize.LoadWithoutBarrier();
if(!result)
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<PTR_BYTE>(pParam->hModule);
{
}
PAL_ENDTRY
-#endif // !TARGET_UNIX
+#endif // HOST_WINDOWS
return param.fRet;
}
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
return __imp::FindSubKeyDefaultValueForCLSID(rclsid, W("InprocServer32"), ssInprocServer32Name);
}
} // namespace Com
-#endif // TARGET_UNIX
+#endif // HOST_WINDOWS
} // namespace Util
} // namespace Clr
//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.
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);
if (h == NULL)
return;
-#ifdef TARGET_UNIX
+#ifdef HOST_UNIX
PAL_FreeLibraryDirect(h);
#else
FreeLibrary(h);