mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-11 10:18:21 +09:00
Remove remaining CRT PAL wrappers and enable including standard headers in the CoreCLR build (#98336)
- Remove malloc-family PAL and update callsites that might get passed 0 to bump up to 1. - Move `getenv` usage to use the `PAL` function directly when on non-Windows (to preserve the existing behavior). - Remove other remaining CRT PAL shims - Remove header shims and enable building with the CRT and STL headers across the product, with various build fixes required (mostly around using the standard min/max definitions)
This commit is contained in:
parent
01f039ce1d
commit
5c4e2a301e
240 changed files with 559 additions and 5127 deletions
|
@ -28,7 +28,6 @@ if (CLR_CMAKE_HOST_UNIX)
|
|||
add_compile_options(-Wno-null-conversion)
|
||||
add_compile_options(-glldb)
|
||||
else()
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Werror=conversion-null>)
|
||||
add_compile_options(-g)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -220,6 +220,12 @@ endfunction(convert_to_absolute_path)
|
|||
function(preprocess_file inputFilename outputFilename)
|
||||
get_compile_definitions(PREPROCESS_DEFINITIONS)
|
||||
get_include_directories(PREPROCESS_INCLUDE_DIRECTORIES)
|
||||
get_source_file_property(SOURCE_FILE_DEFINITIONS ${inputFilename} COMPILE_DEFINITIONS)
|
||||
|
||||
foreach(DEFINITION IN LISTS SOURCE_FILE_DEFINITIONS)
|
||||
list(APPEND PREPROCESS_DEFINITIONS -D${DEFINITION})
|
||||
endforeach()
|
||||
|
||||
if (MSVC)
|
||||
add_custom_command(
|
||||
OUTPUT ${outputFilename}
|
||||
|
|
|
@ -202,11 +202,12 @@ if(CLR_CMAKE_HOST_UNIX)
|
|||
add_subdirectory(debug/createdump)
|
||||
endif(CLR_CMAKE_HOST_OSX OR (CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_UNIX_X86 AND NOT CLR_CMAKE_HOST_ANDROID))
|
||||
|
||||
# Include the dummy c++ include files
|
||||
include_directories("pal/inc/rt/cpp")
|
||||
|
||||
# This prevents inclusion of standard C compiler headers
|
||||
add_compile_options(-nostdinc)
|
||||
# The CoreCLR PAL used to redefine NULL, which caused a number of null conversion and arithmetic
|
||||
# warnings and errors to be suppressed.
|
||||
# Suppress these warnings here to avoid breaking the build.
|
||||
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,Clang,AppleClang>:-Wno-null-arithmetic>)
|
||||
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wno-conversion-null>)
|
||||
add_compile_options($<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wno-pointer-arith>)
|
||||
|
||||
set (NATIVE_RESOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nativeresources)
|
||||
include_directories(${NATIVE_RESOURCE_DIR})
|
||||
|
@ -218,7 +219,7 @@ if(CLR_CMAKE_HOST_UNIX)
|
|||
# given Windows .rc file. The target C++ file path is returned in the
|
||||
# variable specified by the TARGET_FILE parameter.
|
||||
function(build_resources SOURCE TARGET_NAME TARGET_FILE)
|
||||
|
||||
set_property(SOURCE ${SOURCE} APPEND PROPERTY COMPILE_DEFINITIONS "RC_INVOKED")
|
||||
set(PREPROCESSED_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.rc.i)
|
||||
|
||||
preprocess_file(${SOURCE} ${PREPROCESSED_SOURCE})
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
//
|
||||
// ============================================================
|
||||
|
||||
#include "common.h"
|
||||
#include "assemblyname.hpp"
|
||||
#include "assemblybindercommon.hpp"
|
||||
|
||||
#include "common.h"
|
||||
#include "utils.hpp"
|
||||
|
||||
#include "textualidentityparser.hpp"
|
||||
|
|
|
@ -53,6 +53,7 @@ if(CLR_CMAKE_HOST_WIN32)
|
|||
add_definitions(-D_WIN32_WINNT=0x0602)
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_compile_definitions(NOMINMAX)
|
||||
endif(CLR_CMAKE_HOST_WIN32)
|
||||
|
||||
if (NOT (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX))
|
||||
|
|
|
@ -56,8 +56,6 @@ else(CLR_CMAKE_HOST_WIN32)
|
|||
endif(CLR_CMAKE_HOST_OSX)
|
||||
endif (CORECLR_SET_RPATH)
|
||||
|
||||
add_definitions(-DPAL_STDCPP_COMPAT)
|
||||
|
||||
# This is so we can include "version.c"
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
|
||||
|
|
|
@ -5793,7 +5793,7 @@ ClrDataAccess::RawGetMethodName(
|
|||
SIZE_T maxPrecodeSize = sizeof(StubPrecode);
|
||||
|
||||
#ifdef HAS_THISPTR_RETBUF_PRECODE
|
||||
maxPrecodeSize = max(maxPrecodeSize, sizeof(ThisPtrRetBufPrecode));
|
||||
maxPrecodeSize = max((size_t)maxPrecodeSize, sizeof(ThisPtrRetBufPrecode));
|
||||
#endif
|
||||
|
||||
for (SIZE_T i = 0; i < maxPrecodeSize / PRECODE_ALIGNMENT; i++)
|
||||
|
|
|
@ -9,8 +9,6 @@ if(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX)
|
|||
include_directories(${CLR_DIR}/inc/llvm)
|
||||
endif(CLR_CMAKE_HOST_WIN32 OR CLR_CMAKE_HOST_OSX)
|
||||
|
||||
add_definitions(-DPAL_STDCPP_COMPAT)
|
||||
|
||||
if(CLR_CMAKE_TARGET_LINUX_MUSL)
|
||||
add_definitions(-DTARGET_LINUX_MUSL)
|
||||
endif(CLR_CMAKE_TARGET_LINUX_MUSL)
|
||||
|
|
|
@ -2,8 +2,6 @@ include_directories(../inc)
|
|||
include_directories(../../pal/inc)
|
||||
include_directories(${EP_GENERATED_HEADER_PATH})
|
||||
|
||||
add_definitions(-DPAL_STDCPP_COMPAT)
|
||||
|
||||
set(SHARED_EVENTPIPE_SOURCE_PATH ${CLR_SRC_NATIVE_DIR}/eventpipe)
|
||||
add_definitions(-DFEATURE_CORECLR)
|
||||
add_definitions(-DFEATURE_PERFTRACING)
|
||||
|
|
|
@ -3975,9 +3975,9 @@ public:
|
|||
|
||||
// CORDB_ADDRESS's are UINT_PTR's (64 bit under HOST_64BIT, 32 bit otherwise)
|
||||
#if defined(TARGET_64BIT)
|
||||
#define MAX_ADDRESS (_UI64_MAX)
|
||||
#define MAX_ADDRESS (UINT64_MAX)
|
||||
#else
|
||||
#define MAX_ADDRESS (_UI32_MAX)
|
||||
#define MAX_ADDRESS (UINT32_MAX)
|
||||
#endif
|
||||
#define MIN_ADDRESS (0x0)
|
||||
CORDB_ADDRESS m_minPatchAddr; //smallest patch in table
|
||||
|
|
|
@ -5122,7 +5122,7 @@ HRESULT CordbValueEnum::Next(ULONG celt, ICorDebugValue *values[], ULONG *pceltF
|
|||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
int iMax = min( m_iMax, m_iCurrent+celt);
|
||||
int iMax = (int)min( (ULONG)m_iMax, m_iCurrent+celt);
|
||||
int i;
|
||||
for (i = m_iCurrent; i< iMax;i++)
|
||||
{
|
||||
|
@ -8186,7 +8186,7 @@ HRESULT CordbJITILFrame::FabricateNativeInfo(DWORD dwIndex,
|
|||
// first argument, but thereafter we have to decrement it
|
||||
// before getting the variable's location from it. So increment
|
||||
// it here to be consistent later.
|
||||
rpCur += max(cbType, cbArchitectureMin);
|
||||
rpCur += max((ULONG)cbType, cbArchitectureMin);
|
||||
#endif
|
||||
|
||||
// Grab the IL code's function's method signature so we can see if it's static.
|
||||
|
@ -8219,7 +8219,7 @@ HRESULT CordbJITILFrame::FabricateNativeInfo(DWORD dwIndex,
|
|||
IfFailThrow(pArgType->GetUnboxedObjectSize(&cbType));
|
||||
|
||||
#if defined(TARGET_X86) // STACK_GROWS_DOWN_ON_ARGS_WALK
|
||||
rpCur -= max(cbType, cbArchitectureMin);
|
||||
rpCur -= max((ULONG)cbType, cbArchitectureMin);
|
||||
m_rgNVI[i].loc.vlFixedVarArg.vlfvOffset =
|
||||
(unsigned)(m_FirstArgAddr - rpCur);
|
||||
|
||||
|
@ -8229,7 +8229,7 @@ HRESULT CordbJITILFrame::FabricateNativeInfo(DWORD dwIndex,
|
|||
#else // STACK_GROWS_UP_ON_ARGS_WALK
|
||||
m_rgNVI[i].loc.vlFixedVarArg.vlfvOffset =
|
||||
(unsigned)(rpCur - m_FirstArgAddr);
|
||||
rpCur += max(cbType, cbArchitectureMin);
|
||||
rpCur += max((ULONG)cbType, cbArchitectureMin);
|
||||
AlignAddressForType(pArgType, rpCur);
|
||||
#endif
|
||||
|
||||
|
@ -10877,7 +10877,7 @@ HRESULT CordbCodeEnum::Next(ULONG celt, ICorDebugCode *values[], ULONG *pceltFet
|
|||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
int iMax = min( m_iMax, m_iCurrent+celt);
|
||||
int iMax = (int)min( (ULONG)m_iMax, m_iCurrent+celt);
|
||||
int i;
|
||||
|
||||
for (i = m_iCurrent; i < iMax; i++)
|
||||
|
|
|
@ -2898,7 +2898,7 @@ HRESULT CordbTypeEnum::Next(ULONG celt, ICorDebugType *values[], ULONG *pceltFet
|
|||
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
int iMax = min( m_iMax, m_iCurrent+celt);
|
||||
int iMax = (int)min( (ULONG)m_iMax, m_iCurrent+celt);
|
||||
int i;
|
||||
|
||||
for (i = m_iCurrent; i < iMax; i++)
|
||||
|
|
|
@ -1408,7 +1408,7 @@ HRESULT ShimProxyCallback::DataBreakpoint(ICorDebugProcess* pProcess, ICorDebugT
|
|||
this->m_pThread.Assign(pThread);
|
||||
|
||||
_ASSERTE(contextSize == sizeof(CONTEXT));
|
||||
this->m_contextSize = min(contextSize, sizeof(CONTEXT));
|
||||
this->m_contextSize = min(contextSize, (ULONG32)sizeof(CONTEXT));
|
||||
memcpy(&(this->m_context), pContext, this->m_contextSize);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <winnt.h>
|
||||
#include <algorithm>
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
#include <dbgtargetcontext.h>
|
||||
|
||||
|
|
|
@ -3029,7 +3029,7 @@ HRESULT Debugger::GetILToNativeMappingIntoArrays(
|
|||
if (pDJI == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
ULONG32 cMap = min(cMapMax, pDJI->GetSequenceMapCount());
|
||||
ULONG32 cMap = min((ULONG32)cMapMax, pDJI->GetSequenceMapCount());
|
||||
DebuggerILToNativeMap * rgMapInt = pDJI->GetSequenceMap();
|
||||
|
||||
NewArrayHolder<UINT> rguiILOffsetTemp = new (nothrow) UINT[cMap];
|
||||
|
|
|
@ -2806,7 +2806,7 @@ void PackArgumentArray(DebuggerEval *pDE,
|
|||
|
||||
#ifdef FEATURE_HFA
|
||||
// The buffer for HFAs has to be always ENREGISTERED_RETURNTYPE_MAXSIZE
|
||||
size = max(size, ENREGISTERED_RETURNTYPE_MAXSIZE);
|
||||
size = max(size, (unsigned)ENREGISTERED_RETURNTYPE_MAXSIZE);
|
||||
#endif
|
||||
|
||||
BYTE * pTemp = new (interopsafe) BYTE[ALIGN_UP(sizeof(ValueClassInfo), 8) + size];
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <stdint.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
|
|
|
@ -768,7 +768,7 @@ public:
|
|||
//
|
||||
// Operators to emulate Pointer semantics.
|
||||
//
|
||||
bool IsNull() { SUPPORTS_DAC; return m_addr == NULL; }
|
||||
bool IsNull() { SUPPORTS_DAC; return m_addr == (TADDR)0; }
|
||||
|
||||
static VMPTR_This NullPtr()
|
||||
{
|
||||
|
|
|
@ -1949,7 +1949,7 @@ void DbgTransportSession::TransportWorker()
|
|||
DWORD cbBytesToRead = sReceiveHeader.TypeSpecificData.MemoryAccess.m_cbLeftSideBuffer;
|
||||
while (cbBytesToRead)
|
||||
{
|
||||
DWORD cbTransfer = min(cbBytesToRead, sizeof(rgDummy));
|
||||
DWORD cbTransfer = min(cbBytesToRead, (DWORD)sizeof(rgDummy));
|
||||
if (!ReceiveBlock(rgDummy, cbTransfer))
|
||||
HANDLE_TRANSIENT_ERROR();
|
||||
cbBytesToRead -= cbTransfer;
|
||||
|
|
|
@ -22,15 +22,10 @@ nativeStringResourceTable_mscorrc
|
|||
; All the # exports are prefixed with DAC_
|
||||
#PAL_CatchHardwareExceptionHolderEnter
|
||||
#PAL_CatchHardwareExceptionHolderExit
|
||||
#PAL_bsearch
|
||||
#PAL_CopyModuleData
|
||||
#PAL_errno
|
||||
#PAL_free
|
||||
#PAL_GetLogicalCpuCountFromOS
|
||||
#PAL_GetTotalCpuCount
|
||||
#PAL_GetUnwindInfoSize
|
||||
#PAL_stdout
|
||||
#PAL_stderr
|
||||
#PAL_GetApplicationGroupId
|
||||
#PAL_GetTransportName
|
||||
#PAL_GetCurrentThread
|
||||
|
@ -47,9 +42,6 @@ nativeStringResourceTable_mscorrc
|
|||
#PAL_ReadProcessMemory
|
||||
#PAL_ProbeMemory
|
||||
#PAL_Random
|
||||
#PAL_malloc
|
||||
#PAL_realloc
|
||||
#PAL_qsort
|
||||
#PAL__wcstoui64
|
||||
#PAL_wcstoul
|
||||
#PAL_wcstod
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <algorithm>
|
||||
|
||||
#define FEATURE_NO_HOST // Do not use host interface
|
||||
#include <utilcode.h>
|
||||
|
@ -21,3 +22,6 @@
|
|||
#include "ceegen.h"
|
||||
#include "ceefilegenwriter.h"
|
||||
#include "ceesectionstring.h"
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
|
3
src/coreclr/gc/env/common.h
vendored
3
src/coreclr/gc/env/common.h
vendored
|
@ -25,6 +25,9 @@
|
|||
#include <math.h>
|
||||
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef TARGET_UNIX
|
||||
#include <pthread.h>
|
||||
|
|
9
src/coreclr/gc/env/gcenv.base.h
vendored
9
src/coreclr/gc/env/gcenv.base.h
vendored
|
@ -100,14 +100,6 @@ inline HRESULT HRESULT_FROM_WIN32(unsigned long x)
|
|||
|
||||
#define ZeroMemory(Destination,Length) memset((Destination),0,(Length))
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#ifndef max
|
||||
#define max(a,b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define C_ASSERT(cond) static_assert( cond, #cond )
|
||||
|
||||
#define UNREFERENCED_PARAMETER(P) (void)(P)
|
||||
|
@ -393,7 +385,6 @@ typedef struct _PROCESSOR_NUMBER {
|
|||
uint8_t Number;
|
||||
uint8_t Reserved;
|
||||
} PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
|
||||
|
||||
#endif // _INC_WINDOWS
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -3113,7 +3113,7 @@ void gc_history_global::print()
|
|||
|
||||
uint32_t limit_time_to_uint32 (uint64_t time)
|
||||
{
|
||||
time = min (time, UINT32_MAX);
|
||||
time = min (time, (uint64_t)UINT32_MAX);
|
||||
return (uint32_t)time;
|
||||
}
|
||||
|
||||
|
@ -6972,7 +6972,7 @@ void gc_heap::gc_thread_function ()
|
|||
|
||||
dynamic_heap_count_data_t::sample& sample = dynamic_heap_count_data.samples[dynamic_heap_count_data.sample_index];
|
||||
wait_time = min (wait_time, (uint32_t)(sample.elapsed_between_gcs / 1000 / 3));
|
||||
wait_time = max (wait_time, 1);
|
||||
wait_time = max (wait_time, 1u);
|
||||
|
||||
dprintf (6666, ("gc#0 thread waiting for %d ms (betwen GCs %I64d)", wait_time, sample.elapsed_between_gcs));
|
||||
}
|
||||
|
@ -7022,7 +7022,7 @@ void gc_heap::gc_thread_function ()
|
|||
}
|
||||
|
||||
// wait till the threads that should have gone idle at least reached the place where they are about to wait on the idle event.
|
||||
if ((gc_heap::dynamic_adaptation_mode == dynamic_adaptation_to_application_sizes) &&
|
||||
if ((gc_heap::dynamic_adaptation_mode == dynamic_adaptation_to_application_sizes) &&
|
||||
(n_heaps != dynamic_heap_count_data.last_n_heaps))
|
||||
{
|
||||
int spin_count = 1024;
|
||||
|
@ -12141,7 +12141,7 @@ void gc_heap::clear_region_demoted (heap_segment* region)
|
|||
|
||||
int gc_heap::get_plan_gen_num (int gen_number)
|
||||
{
|
||||
return ((settings.promotion) ? min ((gen_number + 1), max_generation) : gen_number);
|
||||
return ((settings.promotion) ? min ((gen_number + 1), (int)max_generation) : gen_number);
|
||||
}
|
||||
|
||||
uint8_t* gc_heap::get_uoh_start_object (heap_segment* region, generation* gen)
|
||||
|
@ -12280,7 +12280,7 @@ void gc_heap::init_heap_segment (heap_segment* seg, gc_heap* hp
|
|||
#endif //MULTIPLE_HEAPS
|
||||
|
||||
#ifdef USE_REGIONS
|
||||
int gen_num_for_region = min (gen_num, max_generation);
|
||||
int gen_num_for_region = min (gen_num, (int)max_generation);
|
||||
set_region_gen_num (seg, gen_num_for_region);
|
||||
heap_segment_plan_gen_num (seg) = gen_num_for_region;
|
||||
heap_segment_swept_in_plan (seg) = false;
|
||||
|
@ -13300,7 +13300,7 @@ void gc_heap::distribute_free_regions()
|
|||
const int i = 0;
|
||||
const int n_heaps = 1;
|
||||
#endif //MULTIPLE_HEAPS
|
||||
ptrdiff_t budget_gen = max (hp->estimate_gen_growth (gen), 0);
|
||||
ptrdiff_t budget_gen = max (hp->estimate_gen_growth (gen), (ptrdiff_t)0);
|
||||
int kind = gen >= loh_generation;
|
||||
size_t budget_gen_in_region_units = (budget_gen + (region_size[kind] - 1)) / region_size[kind];
|
||||
dprintf (REGIONS_LOG, ("h%2d gen %d has an estimated growth of %zd bytes (%zd regions)", i, gen, budget_gen, budget_gen_in_region_units));
|
||||
|
@ -13520,7 +13520,7 @@ void gc_heap::distribute_free_regions()
|
|||
if (ephemeral_elapsed >= DECOMMIT_TIME_STEP_MILLISECONDS)
|
||||
{
|
||||
gc_last_ephemeral_decommit_time = dd_time_clock (dd0);
|
||||
size_t decommit_step_milliseconds = min (ephemeral_elapsed, (10*1000));
|
||||
size_t decommit_step_milliseconds = min (ephemeral_elapsed, (size_t)(10*1000));
|
||||
|
||||
decommit_step (decommit_step_milliseconds);
|
||||
}
|
||||
|
@ -13896,7 +13896,7 @@ uint32_t adjust_heaps_hard_limit_worker (uint32_t nhp, size_t limit)
|
|||
size_t aligned_limit = align_on_segment_hard_limit (limit);
|
||||
uint32_t nhp_oh = (uint32_t)(aligned_limit / min_segment_size_hard_limit);
|
||||
nhp = min (nhp_oh, nhp);
|
||||
return (max (nhp, 1));
|
||||
return (max (nhp, 1u));
|
||||
}
|
||||
|
||||
uint32_t gc_heap::adjust_heaps_hard_limit (uint32_t nhp)
|
||||
|
@ -14300,7 +14300,7 @@ gc_heap::init_semi_shared()
|
|||
#endif //!USE_REGIONS
|
||||
|
||||
#ifdef MULTIPLE_HEAPS
|
||||
mark_list_size = min (100*1024, max (8192, soh_segment_size/(2*10*32)));
|
||||
mark_list_size = min ((size_t)100*1024, max ((size_t)8192, soh_segment_size/(2*10*32)));
|
||||
#ifdef DYNAMIC_HEAP_COUNT
|
||||
if (dynamic_adaptation_mode == dynamic_adaptation_to_application_sizes)
|
||||
{
|
||||
|
@ -14322,7 +14322,7 @@ gc_heap::init_semi_shared()
|
|||
}
|
||||
#else //MULTIPLE_HEAPS
|
||||
|
||||
mark_list_size = min(100*1024, max (8192, soh_segment_size/(64*32)));
|
||||
mark_list_size = min((size_t)100*1024, max ((size_t)8192, soh_segment_size/(64*32)));
|
||||
g_mark_list_total_size = mark_list_size;
|
||||
g_mark_list = make_mark_list (mark_list_size);
|
||||
|
||||
|
@ -14444,7 +14444,7 @@ gc_heap::init_semi_shared()
|
|||
if (bgc_tuning::enable_fl_tuning && (current_memory_load < bgc_tuning::memory_load_goal))
|
||||
{
|
||||
uint32_t distance_to_goal = bgc_tuning::memory_load_goal - current_memory_load;
|
||||
bgc_tuning::stepping_interval = max (distance_to_goal / 10, 1);
|
||||
bgc_tuning::stepping_interval = max (distance_to_goal / 10, 1u);
|
||||
bgc_tuning::last_stepping_mem_load = current_memory_load;
|
||||
bgc_tuning::last_stepping_bgc_count = 0;
|
||||
dprintf (BGC_TUNING_LOG, ("current ml: %d, %d to goal, interval: %d",
|
||||
|
@ -21815,13 +21815,13 @@ size_t gc_heap::min_reclaim_fragmentation_threshold (uint32_t num_heaps)
|
|||
dprintf (GTC_LOG, ("min av: %zd, 10%% gen2: %zd, 3%% mem: %zd",
|
||||
min_mem_based_on_available, ten_percent_size, three_percent_mem));
|
||||
#endif //SIMPLE_DPRINTF
|
||||
return (size_t)(min (min_mem_based_on_available, min (ten_percent_size, three_percent_mem)));
|
||||
return (size_t)(min ((uint64_t)min_mem_based_on_available, min ((uint64_t)ten_percent_size, three_percent_mem)));
|
||||
}
|
||||
|
||||
inline
|
||||
uint64_t gc_heap::min_high_fragmentation_threshold(uint64_t available_mem, uint32_t num_heaps)
|
||||
{
|
||||
return min (available_mem, (256*1024*1024)) / num_heaps;
|
||||
return min (available_mem, (uint64_t)(256*1024*1024)) / num_heaps;
|
||||
}
|
||||
|
||||
enum {
|
||||
|
@ -22082,7 +22082,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 smoothing = min((size_t)3, collection_count);
|
||||
|
||||
size_t desired_total = desired_per_heap * n_heaps;
|
||||
size_t new_smoothed_desired_total = desired_total / smoothing + ((smoothed_desired_total[gen] / smoothing) * (smoothing - 1));
|
||||
|
@ -22191,7 +22191,7 @@ void gc_heap::gc1()
|
|||
}
|
||||
|
||||
//adjust the allocation size from the pinned quantities.
|
||||
for (int gen_number = 0; gen_number <= min (max_generation,n+1); gen_number++)
|
||||
for (int gen_number = 0; gen_number <= min ((int)max_generation,n+1); gen_number++)
|
||||
{
|
||||
generation* gn = generation_of (gen_number);
|
||||
if (settings.compaction)
|
||||
|
@ -22371,7 +22371,7 @@ void gc_heap::gc1()
|
|||
if (alloc_contexts_used >= 1)
|
||||
{
|
||||
allocation_quantum = Align (min ((size_t)CLR_SIZE,
|
||||
(size_t)max (1024, get_new_allocation (0) / (2 * alloc_contexts_used))),
|
||||
(size_t)max ((size_t)1024, get_new_allocation (0) / (2 * alloc_contexts_used))),
|
||||
get_alignment_constant(FALSE));
|
||||
dprintf (3, ("New allocation quantum: %zd(0x%zx)", allocation_quantum, allocation_quantum));
|
||||
}
|
||||
|
@ -28594,7 +28594,7 @@ recheck:
|
|||
if (grow_mark_array_p)
|
||||
{
|
||||
// Try to grow the array.
|
||||
size_t new_size = max (MARK_STACK_INITIAL_LENGTH, 2*background_mark_stack_array_length);
|
||||
size_t new_size = max ((size_t)MARK_STACK_INITIAL_LENGTH, 2*background_mark_stack_array_length);
|
||||
|
||||
if ((new_size * sizeof(mark)) > 100*1024)
|
||||
{
|
||||
|
@ -28934,7 +28934,7 @@ recheck:
|
|||
overflow_p = TRUE;
|
||||
// Try to grow the array.
|
||||
size_t new_size =
|
||||
max (MARK_STACK_INITIAL_LENGTH, 2*mark_stack_array_length);
|
||||
max ((size_t)MARK_STACK_INITIAL_LENGTH, 2*mark_stack_array_length);
|
||||
|
||||
if ((new_size * sizeof(mark)) > 100*1024)
|
||||
{
|
||||
|
@ -29237,7 +29237,7 @@ BOOL gc_heap::decide_on_promotion_surv (size_t threshold)
|
|||
{
|
||||
gc_heap* hp = pGenGCHeap;
|
||||
#endif //MULTIPLE_HEAPS
|
||||
dynamic_data* dd = hp->dynamic_data_of (min ((settings.condemned_generation + 1), max_generation));
|
||||
dynamic_data* dd = hp->dynamic_data_of (min ((int)(settings.condemned_generation + 1), (int)max_generation));
|
||||
size_t older_gen_size = dd_current_size (dd) + (dd_desired_allocation (dd) - dd_new_allocation (dd));
|
||||
|
||||
size_t promoted = hp->total_promoted_bytes;
|
||||
|
@ -29313,7 +29313,7 @@ void gc_heap::verify_region_to_generation_map()
|
|||
}
|
||||
size_t region_index_start = get_basic_region_index_for_address (get_region_start (region));
|
||||
size_t region_index_end = get_basic_region_index_for_address (heap_segment_reserved (region));
|
||||
int gen_num = min (gen_number, soh_gen2);
|
||||
int gen_num = min (gen_number, (int)soh_gen2);
|
||||
assert (gen_num == heap_segment_gen_num (region));
|
||||
int plan_gen_num = heap_segment_plan_gen_num (region);
|
||||
bool is_demoted = (region->flags & heap_segment_flags_demoted) != 0;
|
||||
|
@ -32546,7 +32546,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
|
|||
|
||||
if ((condemned_gen_number < max_generation))
|
||||
{
|
||||
older_gen = generation_of (min (max_generation, 1 + condemned_gen_number));
|
||||
older_gen = generation_of (min ((int)max_generation, 1 + condemned_gen_number));
|
||||
generation_allocator (older_gen)->copy_to_alloc_list (r_free_list);
|
||||
|
||||
r_free_list_space = generation_free_list_space (older_gen);
|
||||
|
@ -34117,7 +34117,7 @@ void gc_heap::plan_phase (int condemned_gen_number)
|
|||
{
|
||||
reset_pinned_queue_bos();
|
||||
#ifndef USE_REGIONS
|
||||
unsigned int gen_number = min (max_generation, 1 + condemned_gen_number);
|
||||
unsigned int gen_number = (unsigned int)min ((int)max_generation, 1 + condemned_gen_number);
|
||||
generation* gen = generation_of (gen_number);
|
||||
uint8_t* low = generation_allocation_start (generation_of (gen_number-1));
|
||||
uint8_t* high = heap_segment_allocated (ephemeral_heap_segment);
|
||||
|
@ -42454,8 +42454,8 @@ adjust:
|
|||
#endif // SEG_REUSE_STATS
|
||||
if (free_space_items)
|
||||
{
|
||||
max_free_space_items = min (MAX_NUM_FREE_SPACES, free_space_items * 2);
|
||||
max_free_space_items = max (max_free_space_items, MIN_NUM_FREE_SPACES);
|
||||
max_free_space_items = min ((size_t)MAX_NUM_FREE_SPACES, free_space_items * 2);
|
||||
max_free_space_items = max (max_free_space_items, (size_t)MIN_NUM_FREE_SPACES);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -42686,8 +42686,8 @@ BOOL gc_heap::can_expand_into_p (heap_segment* seg, size_t min_free_size, size_t
|
|||
memcpy (ordered_free_space_indices,
|
||||
saved_ordered_free_space_indices,
|
||||
sizeof(ordered_free_space_indices));
|
||||
max_free_space_items = max (MIN_NUM_FREE_SPACES, free_space_items * 3 / 2);
|
||||
max_free_space_items = min (MAX_NUM_FREE_SPACES, max_free_space_items);
|
||||
max_free_space_items = max ((size_t)MIN_NUM_FREE_SPACES, free_space_items * 3 / 2);
|
||||
max_free_space_items = min ((size_t)MAX_NUM_FREE_SPACES, max_free_space_items);
|
||||
dprintf (SEG_REUSE_LOG_0, ("could fit! %zd free spaces, %zd max", free_space_items, max_free_space_items));
|
||||
}
|
||||
|
||||
|
@ -43371,14 +43371,14 @@ void gc_heap::init_static_data()
|
|||
|
||||
size_t gen0_max_size =
|
||||
#ifdef MULTIPLE_HEAPS
|
||||
max (6*1024*1024, min ( Align(soh_segment_size/2), 200*1024*1024));
|
||||
max ((size_t)6*1024*1024, min ( Align(soh_segment_size/2), (size_t)200*1024*1024));
|
||||
#else //MULTIPLE_HEAPS
|
||||
(
|
||||
#ifdef BACKGROUND_GC
|
||||
gc_can_use_concurrent ?
|
||||
6*1024*1024 :
|
||||
#endif //BACKGROUND_GC
|
||||
max (6*1024*1024, min ( Align(soh_segment_size/2), 200*1024*1024))
|
||||
max ((size_t)6*1024*1024, min ( Align(soh_segment_size/2), (size_t)200*1024*1024))
|
||||
);
|
||||
#endif //MULTIPLE_HEAPS
|
||||
|
||||
|
@ -43408,14 +43408,14 @@ void gc_heap::init_static_data()
|
|||
// TODO: gen0_max_size has a 200mb cap; gen1_max_size should also have a cap.
|
||||
size_t gen1_max_size = (size_t)
|
||||
#ifdef MULTIPLE_HEAPS
|
||||
max (6*1024*1024, Align(soh_segment_size/2));
|
||||
max ((size_t)6*1024*1024, Align(soh_segment_size/2));
|
||||
#else //MULTIPLE_HEAPS
|
||||
(
|
||||
#ifdef BACKGROUND_GC
|
||||
gc_can_use_concurrent ?
|
||||
6*1024*1024 :
|
||||
#endif //BACKGROUND_GC
|
||||
max (6*1024*1024, Align(soh_segment_size/2))
|
||||
max ((size_t)6*1024*1024, Align(soh_segment_size/2))
|
||||
);
|
||||
#endif //MULTIPLE_HEAPS
|
||||
|
||||
|
@ -43562,7 +43562,7 @@ size_t gc_heap::desired_new_allocation (dynamic_data* dd,
|
|||
}
|
||||
else
|
||||
{
|
||||
new_size = (size_t) min (max ( (f * current_size), min_gc_size), max_size);
|
||||
new_size = (size_t) min (max ( (size_t)(f * current_size), min_gc_size), max_size);
|
||||
}
|
||||
|
||||
assert ((new_size >= current_size) || (new_size == max_size));
|
||||
|
@ -43634,7 +43634,7 @@ size_t gc_heap::desired_new_allocation (dynamic_data* dd,
|
|||
size_t survivors = out;
|
||||
cst = float (survivors) / float (dd_begin_data_size (dd));
|
||||
f = surv_to_growth (cst, limit, max_limit);
|
||||
new_allocation = (size_t) min (max ((f * (survivors)), min_gc_size), max_size);
|
||||
new_allocation = (size_t) min (max ((size_t)(f * (survivors)), min_gc_size), max_size);
|
||||
|
||||
new_allocation = linear_allocation_model (allocation_fraction, new_allocation,
|
||||
dd_desired_allocation (dd), time_since_previous_collection_secs);
|
||||
|
@ -43700,9 +43700,9 @@ size_t gc_heap::generation_plan_size (int gen_number)
|
|||
return result;
|
||||
#else //USE_REGIONS
|
||||
if (0 == gen_number)
|
||||
return max((heap_segment_plan_allocated (ephemeral_heap_segment) -
|
||||
return (size_t)max((heap_segment_plan_allocated (ephemeral_heap_segment) -
|
||||
generation_plan_allocation_start (generation_of (gen_number))),
|
||||
(int)Align (min_obj_size));
|
||||
(ptrdiff_t)Align (min_obj_size));
|
||||
else
|
||||
{
|
||||
generation* gen = generation_of (gen_number);
|
||||
|
@ -43751,9 +43751,9 @@ size_t gc_heap::generation_size (int gen_number)
|
|||
return result;
|
||||
#else //USE_REGIONS
|
||||
if (0 == gen_number)
|
||||
return max((heap_segment_allocated (ephemeral_heap_segment) -
|
||||
return (size_t)max((heap_segment_allocated (ephemeral_heap_segment) -
|
||||
generation_allocation_start (generation_of (gen_number))),
|
||||
(int)Align (min_obj_size));
|
||||
(ptrdiff_t)Align (min_obj_size));
|
||||
else
|
||||
{
|
||||
generation* gen = generation_of (gen_number);
|
||||
|
@ -43835,7 +43835,7 @@ size_t gc_heap::trim_youngest_desired (uint32_t memory_load,
|
|||
}
|
||||
else
|
||||
{
|
||||
size_t total_max_allocation = max (mem_one_percent, total_min_allocation);
|
||||
size_t total_max_allocation = max ((size_t)mem_one_percent, total_min_allocation);
|
||||
return min (total_new_allocation, total_max_allocation);
|
||||
}
|
||||
}
|
||||
|
@ -44170,7 +44170,7 @@ void gc_heap::decommit_ephemeral_segment_pages()
|
|||
dynamic_data* dd0 = dynamic_data_of (0);
|
||||
|
||||
ptrdiff_t desired_allocation = dd_new_allocation (dd0) +
|
||||
max (estimate_gen_growth (soh_gen1), 0) +
|
||||
max (estimate_gen_growth (soh_gen1), (ptrdiff_t)0) +
|
||||
loh_size_threshold;
|
||||
|
||||
size_t slack_space =
|
||||
|
@ -44219,7 +44219,7 @@ void gc_heap::decommit_ephemeral_segment_pages()
|
|||
|
||||
// we do a max of DECOMMIT_SIZE_PER_MILLISECOND per millisecond of elapsed time since the last GC
|
||||
// we limit the elapsed time to 10 seconds to avoid spending too much time decommitting
|
||||
ptrdiff_t max_decommit_size = min (ephemeral_elapsed, (10*1000)) * DECOMMIT_SIZE_PER_MILLISECOND;
|
||||
ptrdiff_t max_decommit_size = min (ephemeral_elapsed, (size_t)(10*1000)) * DECOMMIT_SIZE_PER_MILLISECOND;
|
||||
decommit_size = min (decommit_size, max_decommit_size);
|
||||
|
||||
slack_space = heap_segment_committed (ephemeral_heap_segment) - heap_segment_allocated (ephemeral_heap_segment) - decommit_size;
|
||||
|
@ -47199,7 +47199,7 @@ enable_no_gc_region_callback_status gc_heap::enable_no_gc_callback(NoGCRegionCal
|
|||
soh_withheld_budget = soh_withheld_budget / gc_heap::n_heaps;
|
||||
loh_withheld_budget = loh_withheld_budget / gc_heap::n_heaps;
|
||||
#endif
|
||||
soh_withheld_budget = max(soh_withheld_budget, 1);
|
||||
soh_withheld_budget = max(soh_withheld_budget, (size_t)1);
|
||||
soh_withheld_budget = Align(soh_withheld_budget, get_alignment_constant (TRUE));
|
||||
loh_withheld_budget = Align(loh_withheld_budget, get_alignment_constant (FALSE));
|
||||
#ifdef MULTIPLE_HEAPS
|
||||
|
@ -47614,7 +47614,7 @@ void gc_heap::verify_regions (int gen_number, bool can_verify_gen_num, bool can_
|
|||
}
|
||||
if (can_verify_gen_num)
|
||||
{
|
||||
if (heap_segment_gen_num (seg_in_gen) != min (gen_number, max_generation))
|
||||
if (heap_segment_gen_num (seg_in_gen) != min (gen_number, (int)max_generation))
|
||||
{
|
||||
dprintf (REGIONS_LOG, ("h%d gen%d region %p(%p) gen is %d!",
|
||||
heap_number, gen_number, seg_in_gen, heap_segment_mem (seg_in_gen),
|
||||
|
@ -48464,7 +48464,7 @@ HRESULT GCHeap::Initialize()
|
|||
|
||||
nhp = ((nhp_from_config == 0) ? g_num_active_processors : nhp_from_config);
|
||||
|
||||
nhp = min (nhp, MAX_SUPPORTED_CPUS);
|
||||
nhp = min (nhp, (uint32_t)MAX_SUPPORTED_CPUS);
|
||||
|
||||
gc_heap::gc_thread_no_affinitize_p = (gc_heap::heap_hard_limit ?
|
||||
!affinity_config_specified_p : (GCConfig::GetNoAffinitize() != 0));
|
||||
|
@ -48613,7 +48613,7 @@ HRESULT GCHeap::Initialize()
|
|||
/*
|
||||
* Allocation requests less than loh_size_threshold will be allocated on the small object heap.
|
||||
*
|
||||
* An object cannot span more than one region and regions in small object heap are of the same size - gc_region_size.
|
||||
* An object cannot span more than one region and regions in small object heap are of the same size - gc_region_size.
|
||||
* However, the space available for actual allocations is reduced by the following implementation details -
|
||||
*
|
||||
* 1.) heap_segment_mem is set to the new pages + sizeof(aligned_plug_and_gap) in make_heap_segment.
|
||||
|
@ -48629,7 +48629,7 @@ HRESULT GCHeap::Initialize()
|
|||
#ifdef FEATURE_STRUCTALIGN
|
||||
/*
|
||||
* The above assumed FEATURE_STRUCTALIGN is not turned on for platforms where USE_REGIONS is supported, otherwise it is possible
|
||||
* that the allocation size is inflated by ComputeMaxStructAlignPad in GCHeap::Alloc and we have to compute an upper bound of that
|
||||
* that the allocation size is inflated by ComputeMaxStructAlignPad in GCHeap::Alloc and we have to compute an upper bound of that
|
||||
* function.
|
||||
*
|
||||
* Note that ComputeMaxStructAlignPad is defined to be 0 if FEATURE_STRUCTALIGN is turned off.
|
||||
|
@ -48838,7 +48838,7 @@ HRESULT GCHeap::Initialize()
|
|||
gc_heap::dynamic_heap_count_data.inc_recheck_threshold = 5;
|
||||
gc_heap::dynamic_heap_count_data.dec_failure_recheck_threshold = 5;
|
||||
// This should really be set as part of computing static data and should take conserve_mem_setting into consideration.
|
||||
gc_heap::dynamic_heap_count_data.max_gen0_new_allocation = min (dd_max_size (gc_heap::g_heaps[0]->dynamic_data_of (0)), (64 * 1024 * 1024));
|
||||
gc_heap::dynamic_heap_count_data.max_gen0_new_allocation = min (dd_max_size (gc_heap::g_heaps[0]->dynamic_data_of (0)), (size_t)(64 * 1024 * 1024));
|
||||
gc_heap::dynamic_heap_count_data.min_gen0_new_allocation = dd_min_size (gc_heap::g_heaps[0]->dynamic_data_of (0));
|
||||
|
||||
dprintf (6666, ("datas max gen0 budget %Id, min %Id",
|
||||
|
@ -49809,7 +49809,7 @@ GCHeap::GarbageCollect (int generation, bool low_memory_p, int mode)
|
|||
gc_heap* hpt = 0;
|
||||
#endif //MULTIPLE_HEAPS
|
||||
|
||||
generation = (generation < 0) ? max_generation : min (generation, max_generation);
|
||||
generation = (generation < 0) ? max_generation : min (generation, (int)max_generation);
|
||||
dynamic_data* dd = hpt->dynamic_data_of (generation);
|
||||
|
||||
#ifdef BACKGROUND_GC
|
||||
|
@ -49907,7 +49907,7 @@ size_t
|
|||
GCHeap::GarbageCollectTry (int generation, BOOL low_memory_p, int mode)
|
||||
{
|
||||
int gen = (generation < 0) ?
|
||||
max_generation : min (generation, max_generation);
|
||||
max_generation : min (generation, (int)max_generation);
|
||||
|
||||
gc_reason reason = reason_empty;
|
||||
|
||||
|
@ -51262,11 +51262,11 @@ size_t gc_heap::get_gen0_min_size()
|
|||
#ifdef SERVER_GC
|
||||
// performance data seems to indicate halving the size results
|
||||
// in optimal perf. Ask for adjusted gen0 size.
|
||||
gen0size = max(GCToOSInterface::GetCacheSizePerLogicalCpu(FALSE),(256*1024));
|
||||
gen0size = max(GCToOSInterface::GetCacheSizePerLogicalCpu(FALSE), (size_t)(256*1024));
|
||||
|
||||
// if gen0 size is too large given the available memory, reduce it.
|
||||
// Get true cache size, as we don't want to reduce below this.
|
||||
size_t trueSize = max(GCToOSInterface::GetCacheSizePerLogicalCpu(TRUE),(256*1024));
|
||||
size_t trueSize = max(GCToOSInterface::GetCacheSizePerLogicalCpu(TRUE), (size_t)(256*1024));
|
||||
dprintf (1, ("cache: %zd-%zd",
|
||||
GCToOSInterface::GetCacheSizePerLogicalCpu(FALSE),
|
||||
GCToOSInterface::GetCacheSizePerLogicalCpu(TRUE)));
|
||||
|
@ -51274,8 +51274,8 @@ size_t gc_heap::get_gen0_min_size()
|
|||
int n_heaps = gc_heap::n_heaps;
|
||||
#else //SERVER_GC
|
||||
size_t trueSize = GCToOSInterface::GetCacheSizePerLogicalCpu(TRUE);
|
||||
gen0size = max((4*trueSize/5),(256*1024));
|
||||
trueSize = max(trueSize, (256*1024));
|
||||
gen0size = max((4*trueSize/5),(size_t)(256*1024));
|
||||
trueSize = max(trueSize, (size_t)(256*1024));
|
||||
int n_heaps = 1;
|
||||
#endif //SERVER_GC
|
||||
|
||||
|
@ -51283,7 +51283,7 @@ size_t gc_heap::get_gen0_min_size()
|
|||
if (dynamic_adaptation_mode == dynamic_adaptation_to_application_sizes)
|
||||
{
|
||||
// if we are asked to be stingy with memory, limit gen 0 size
|
||||
gen0size = min (gen0size, (4*1024*1024));
|
||||
gen0size = min (gen0size, (size_t)(4*1024*1024));
|
||||
}
|
||||
#endif //DYNAMIC_HEAP_COUNT
|
||||
|
||||
|
@ -51904,7 +51904,7 @@ CFinalize::UpdatePromotedGenerations (int gen, BOOL gen_0_empty_p)
|
|||
// it was promoted or not
|
||||
if (gen_0_empty_p)
|
||||
{
|
||||
for (int i = min (gen+1, max_generation); i > 0; i--)
|
||||
for (int i = min (gen+1, (int)max_generation); i > 0; i--)
|
||||
{
|
||||
m_FillPointers [gen_segment(i)] = m_FillPointers [gen_segment(i-1)];
|
||||
}
|
||||
|
@ -52807,7 +52807,7 @@ bool gc_heap::compute_memory_settings(bool is_initialization, uint32_t& nhp, uin
|
|||
if (is_initialization)
|
||||
#endif //USE_REGIONS
|
||||
{
|
||||
heap_hard_limit = (size_t)max ((20 * 1024 * 1024), physical_mem_for_gc);
|
||||
heap_hard_limit = (size_t)max ((uint64_t)(20 * 1024 * 1024), physical_mem_for_gc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52855,8 +52855,8 @@ bool gc_heap::compute_memory_settings(bool is_initialization, uint32_t& nhp, uin
|
|||
uint32_t highmem_th_from_config = (uint32_t)GCConfig::GetGCHighMemPercent();
|
||||
if (highmem_th_from_config)
|
||||
{
|
||||
high_memory_load_th = min (99, highmem_th_from_config);
|
||||
v_high_memory_load_th = min (99, (highmem_th_from_config + 7));
|
||||
high_memory_load_th = min (99u, highmem_th_from_config);
|
||||
v_high_memory_load_th = min (99u, (highmem_th_from_config + 7));
|
||||
#ifdef FEATURE_EVENT_TRACE
|
||||
high_mem_percent_from_config = highmem_th_from_config;
|
||||
#endif //FEATURE_EVENT_TRACE
|
||||
|
|
|
@ -3345,8 +3345,8 @@ private:
|
|||
size_t new_current_total_committed);
|
||||
|
||||
#ifdef USE_REGIONS
|
||||
PER_HEAP_ISOLATED_METHOD void compute_committed_bytes(size_t& total_committed, size_t& committed_decommit, size_t& committed_free,
|
||||
size_t& committed_bookkeeping, size_t& new_current_total_committed, size_t& new_current_total_committed_bookkeeping,
|
||||
PER_HEAP_ISOLATED_METHOD void compute_committed_bytes(size_t& total_committed, size_t& committed_decommit, size_t& committed_free,
|
||||
size_t& committed_bookkeeping, size_t& new_current_total_committed, size_t& new_current_total_committed_bookkeeping,
|
||||
size_t* new_committed_by_oh);
|
||||
#endif
|
||||
|
||||
|
@ -4226,7 +4226,7 @@ private:
|
|||
|
||||
#ifdef DYNAMIC_HEAP_COUNT
|
||||
// Sample collection -
|
||||
//
|
||||
//
|
||||
// For every GC, we collect the msl wait time + GC pause duration info and use both to calculate the
|
||||
// throughput cost percentage. We will also be using the wait time and the GC pause duration separately
|
||||
// for other purposes in the future.
|
||||
|
@ -6019,3 +6019,6 @@ public:
|
|||
#else
|
||||
#define THIS_ARG
|
||||
#endif // FEATURE_CARD_MARKING_STEALING
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
|
|
@ -53,6 +53,7 @@ if(CLR_CMAKE_TARGET_WIN32)
|
|||
list(APPEND SOURCES
|
||||
../windows/gcenv.windows.cpp)
|
||||
add_definitions(-DUNICODE)
|
||||
add_compile_definitions(NOMINMAX)
|
||||
else()
|
||||
list(APPEND SOURCES
|
||||
../gcenv.unix.cpp)
|
||||
|
|
|
@ -176,7 +176,7 @@ int __cdecl main(int argc, char* argv[])
|
|||
// GC expects the size of ObjHeader (extra void*) to be included in the size.
|
||||
baseSize = baseSize + sizeof(ObjHeader);
|
||||
// Add padding as necessary. GC requires the object size to be at least MIN_OBJECT_SIZE.
|
||||
My_MethodTable.m_MT.m_baseSize = max(baseSize, MIN_OBJECT_SIZE);
|
||||
My_MethodTable.m_MT.m_baseSize = max(baseSize, (uint32_t)MIN_OBJECT_SIZE);
|
||||
|
||||
My_MethodTable.m_MT.m_componentSize = 0; // Array component size
|
||||
My_MethodTable.m_MT.m_flags = MTFlag_ContainsPointers;
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;HOST_X86;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;HOST_X86;NOMINMAX;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>.;..;..\env</AdditionalIncludeDirectories>
|
||||
|
@ -68,7 +68,7 @@
|
|||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;HOST_X86;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;HOST_X86;NOMINMAX;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>.;..;..\env</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
|
@ -109,4 +109,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -45,16 +45,6 @@
|
|||
#define NOINLINE __attribute__((noinline))
|
||||
#endif
|
||||
|
||||
#include <limits>
|
||||
|
||||
#ifndef max
|
||||
template <typename T>
|
||||
T max(T a, T b) {
|
||||
if (a > b)
|
||||
return a;
|
||||
else
|
||||
return b;
|
||||
}
|
||||
#endif
|
||||
|
||||
using std::max;
|
||||
using std::min;
|
||||
#endif // VXSORT_DEFS_H
|
||||
|
|
|
@ -290,8 +290,8 @@ static size_t GetRestrictedPhysicalMemoryLimit()
|
|||
(job_process_memory_limit != (size_t)UINTPTR_MAX) ||
|
||||
(job_workingset_limit != (size_t)UINTPTR_MAX))
|
||||
{
|
||||
job_physical_memory_limit = min (job_memory_limit, job_process_memory_limit);
|
||||
job_physical_memory_limit = min (job_physical_memory_limit, job_workingset_limit);
|
||||
job_physical_memory_limit = std::min (job_memory_limit, job_process_memory_limit);
|
||||
job_physical_memory_limit = std::min (job_physical_memory_limit, job_workingset_limit);
|
||||
|
||||
MEMORYSTATUSEX ms;
|
||||
::GetProcessMemoryLoad(&ms);
|
||||
|
@ -299,7 +299,7 @@ static size_t GetRestrictedPhysicalMemoryLimit()
|
|||
total_physical = ms.ullAvailPhys;
|
||||
|
||||
// A sanity check in case someone set a larger limit than there is actual physical memory.
|
||||
job_physical_memory_limit = (size_t) min (job_physical_memory_limit, ms.ullTotalPhys);
|
||||
job_physical_memory_limit = (size_t) std::min (job_physical_memory_limit, (size_t)ms.ullTotalPhys);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1139,7 +1139,7 @@ bool GCToOSInterface::GetNumaInfo(uint16_t* total_nodes, uint32_t* max_procs_per
|
|||
mask &= mask - 1;
|
||||
}
|
||||
|
||||
currentProcsOnNode = max(currentProcsOnNode, procsOnNode);
|
||||
currentProcsOnNode = std::max(currentProcsOnNode, procsOnNode);
|
||||
}
|
||||
*max_procs_per_node = currentProcsOnNode;
|
||||
*total_nodes = (uint16_t)g_nNodes;
|
||||
|
@ -1163,7 +1163,7 @@ bool GCToOSInterface::GetCPUGroupInfo(uint16_t* total_groups, uint32_t* max_proc
|
|||
DWORD currentProcsInGroup = 0;
|
||||
for (WORD i = 0; i < g_nGroups; i++)
|
||||
{
|
||||
currentProcsInGroup = max(currentProcsInGroup, g_CPUGroupInfoArray[i].nr_active);
|
||||
currentProcsInGroup = std::max(currentProcsInGroup, (DWORD)g_CPUGroupInfoArray[i].nr_active);
|
||||
}
|
||||
*max_procs_per_group = currentProcsInGroup;
|
||||
return true;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#define _CORESHIM_H_
|
||||
|
||||
// Platform
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#include <combaseapi.h>
|
||||
|
||||
|
|
|
@ -1914,7 +1914,7 @@ BYTE* PrettyPrintCABlobValue(PCCOR_SIGNATURE &typePtr,
|
|||
for(n=0; n < numElements; n++)
|
||||
{
|
||||
if(n) appendStr(out," ");
|
||||
_gcvt_s(str,64,*((float*)dataPtr), 8);
|
||||
sprintf_s(str, 64, "%.*g", 8, (double)(*((float*)dataPtr)));
|
||||
float df = (float)atof(str);
|
||||
// Must compare as underlying bytes, not floating point otherwise optimizer will
|
||||
// try to enregister and compare 80-bit precision number with 32-bit precision number!!!!
|
||||
|
@ -1933,7 +1933,7 @@ BYTE* PrettyPrintCABlobValue(PCCOR_SIGNATURE &typePtr,
|
|||
{
|
||||
if(n) appendStr(out," ");
|
||||
char *pch;
|
||||
_gcvt_s(str,64,*((double*)dataPtr), 17);
|
||||
sprintf_s(str, 64, "%.*g", 17, *((double*)dataPtr));
|
||||
double df = strtod(str, &pch);
|
||||
// Must compare as underlying bytes, not floating point otherwise optimizer will
|
||||
// try to enregister and compare 80-bit precision number with 64-bit precision number!!!!
|
||||
|
@ -2605,7 +2605,7 @@ void DumpDefaultValue(mdToken tok, __inout __nullterminated char* szString, void
|
|||
case ELEMENT_TYPE_R4:
|
||||
{
|
||||
char szf[32];
|
||||
_gcvt_s(szf,32,MDDV.m_fltValue, 8);
|
||||
sprintf_s(szf, 32, "%.*g", 8, (double)MDDV.m_fltValue);
|
||||
float df = (float)atof(szf);
|
||||
// Must compare as underlying bytes, not floating point otherwise optimizer will
|
||||
// try to enregister and compare 80-bit precision number with 32-bit precision number!!!!
|
||||
|
@ -2619,7 +2619,7 @@ void DumpDefaultValue(mdToken tok, __inout __nullterminated char* szString, void
|
|||
case ELEMENT_TYPE_R8:
|
||||
{
|
||||
char szf[32], *pch;
|
||||
_gcvt_s(szf,32,MDDV.m_dblValue, 17);
|
||||
sprintf_s(szf, 32, "%.*g", 17, MDDV.m_dblValue);
|
||||
double df = strtod(szf, &pch); //atof(szf);
|
||||
szf[31]=0;
|
||||
// Must compare as underlying bytes, not floating point otherwise optimizer will
|
||||
|
|
|
@ -1573,7 +1573,7 @@ BOOL Disassemble(IMDInternalImport *pImport, BYTE *ILHeader, void *GUICookie, md
|
|||
if(f==0.0)
|
||||
strcpy_s(szf,32,((v>>24)==0)? "0.0" : "-0.0");
|
||||
else
|
||||
_gcvt_s(szf,32,(double)f, 8);
|
||||
sprintf_s(szf, 32, "%.*g", 8, (double)f);
|
||||
float fd = (float)atof(szf);
|
||||
// Must compare as underlying bytes, not floating point otherwise optimizer will
|
||||
// try to enregister and compare 80-bit precision number with 32-bit precision number!!!!
|
||||
|
@ -1612,7 +1612,7 @@ BOOL Disassemble(IMDInternalImport *pImport, BYTE *ILHeader, void *GUICookie, md
|
|||
if(d==0.0)
|
||||
strcpy_s(szf,32,((v>>56)==0)? "0.0" : "-0.0");
|
||||
else
|
||||
_gcvt_s(szf,32,d, 17);
|
||||
sprintf_s(szf, 32, "%.*g", 17, d);
|
||||
double df = strtod(szf, &pch); //atof(szf);
|
||||
// Must compare as underlying bytes, not floating point otherwise optimizer will
|
||||
// try to enregister and compare 80-bit precision number with 64-bit precision number!!!!
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <algorithm>
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
#ifndef Debug_ReportError
|
||||
#define Debug_ReportError(strMessage)
|
||||
|
|
|
@ -23,7 +23,16 @@
|
|||
|
||||
#ifndef AllocaCheck_h
|
||||
#define AllocaCheck_h
|
||||
#include <malloc.h> // for alloca itself
|
||||
|
||||
#if defined(HOST_WINDOWS)
|
||||
#include <malloc.h> // for alloca itself
|
||||
#else
|
||||
#if defined(__has_include)
|
||||
#if __has_include(<alloca.h>)
|
||||
#include <alloca.h>
|
||||
#endif // __has_include(alloca.h)
|
||||
#endif // defined(__has_include)
|
||||
#endif // defined(HOST_WINDOWS)
|
||||
|
||||
#if defined(assert) && !defined(_ASSERTE)
|
||||
#define _ASSERTE assert
|
||||
|
|
|
@ -111,7 +111,7 @@ public: // !!! NOTE: Called from macros only!!!
|
|||
#ifdef _DEBUG
|
||||
, m_condition (NULL)
|
||||
, m_file(NULL)
|
||||
, m_line(NULL)
|
||||
, m_line(0)
|
||||
, m_pCount(NULL)
|
||||
#endif
|
||||
{}
|
||||
|
|
|
@ -1,118 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
//
|
||||
// clr_std/algorithm
|
||||
//
|
||||
// Copy of some key Standard Template Library functionality
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef USE_STL
|
||||
#include <algorithm>
|
||||
#else
|
||||
#ifndef __clr_std_algorithm_h__
|
||||
#define __clr_std_algorithm_h__
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<class iter, class CompareFunc>
|
||||
iter find_if ( iter first, iter last, CompareFunc comp )
|
||||
{
|
||||
for ( ; first!=last ; first++ )
|
||||
if ( comp(*first) )
|
||||
break;
|
||||
return first;
|
||||
}
|
||||
|
||||
template<class iter, class T>
|
||||
iter find(iter first, iter last, const T& val)
|
||||
{
|
||||
for (;first != last; first++)
|
||||
{
|
||||
if (*first == val)
|
||||
break;
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
template <class iter, class comp>
|
||||
iter qsort_partition( iter first, iter last, iter pivot, comp compare )
|
||||
{
|
||||
iter lastMinusOne = last - 1;
|
||||
swap(pivot, lastMinusOne);
|
||||
|
||||
// Pivot is at end
|
||||
pivot = last - 1;
|
||||
|
||||
iter partitionLoc = first;
|
||||
|
||||
for (iter partitionWalk = first; partitionWalk != pivot; ++partitionWalk)
|
||||
{
|
||||
if (compare(*partitionWalk, *pivot))
|
||||
{
|
||||
swap(*partitionWalk, *partitionLoc);
|
||||
partitionLoc++;
|
||||
}
|
||||
}
|
||||
swap(*pivot, *partitionLoc);
|
||||
|
||||
return partitionLoc;
|
||||
}
|
||||
|
||||
template <class iter, class comp>
|
||||
void sort_worker ( iter first, iter last, comp compare )
|
||||
{
|
||||
typename iter::difference_type RangeSize = last - first;
|
||||
|
||||
// When down to a list of size 1, be done
|
||||
if (RangeSize < 2)
|
||||
return;
|
||||
|
||||
// Pick pivot
|
||||
|
||||
// Use simple pick middle algorithm
|
||||
iter pivotLoc = first + (RangeSize / 2);
|
||||
|
||||
// Partition
|
||||
pivotLoc = qsort_partition(first, last, pivotLoc, compare);
|
||||
|
||||
// Sort first array
|
||||
sort_worker(first, pivotLoc, compare);
|
||||
|
||||
// Sort second array
|
||||
sort_worker(pivotLoc + 1, last, compare);
|
||||
}
|
||||
|
||||
template <class iter, class comp>
|
||||
void sort ( iter first, iter last, comp compare )
|
||||
{
|
||||
sort_worker(first, last, compare);
|
||||
if (first != last)
|
||||
{
|
||||
for (iter i = first; i < (last - 1); i++)
|
||||
{
|
||||
// Assert that the sort function works.
|
||||
assert(!compare(*(i+1), *i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class InIter, class OutIter, class Fn1>
|
||||
OutIter transform( InIter first, InIter last, OutIter dest, Fn1 func )
|
||||
{
|
||||
for ( ; first!=last ; ++first, ++dest )
|
||||
*dest = func(*first);
|
||||
return dest;
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif /* __clr_std_algorithm_h__ */
|
||||
|
||||
#endif // !USE_STL
|
||||
|
||||
// Help the VIM editor figure out what kind of file this no-extension file is.
|
||||
// vim: filetype=cpp
|
|
@ -1,425 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
//
|
||||
// clr_std/string
|
||||
//
|
||||
// Copy of some key Standard Template Library functionality
|
||||
//
|
||||
// This was created for use with SuperPMI. It has the minimal functionality needed by SuperPMI. It hasn't
|
||||
// been tested elsewhere.
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef USE_STL
|
||||
#include <string>
|
||||
#else
|
||||
#ifndef __clr_std_string_h__
|
||||
#define __clr_std_string_h__
|
||||
|
||||
#include "clr_std/vector"
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
template<class T>
|
||||
class basic_string
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef typename vector<T>::iterator iterator;
|
||||
typedef typename vector<T>::const_iterator const_iterator;
|
||||
|
||||
basic_string()
|
||||
: m_string(1) // start with a string of length 1 for null terminator
|
||||
{
|
||||
m_string[0] = T();
|
||||
}
|
||||
|
||||
basic_string(const basic_string<T>& _Right)
|
||||
{
|
||||
assign(_Right);
|
||||
}
|
||||
|
||||
// Initialize a string with _Count characters from the string pointed at by _Ptr.
|
||||
// If you want to include the trailing null character, _Count needs to include that.
|
||||
basic_string(const value_type* _Ptr, size_type _Count)
|
||||
: m_string(_Count + 1) // add 1 for a null terminator
|
||||
{
|
||||
copy(_Ptr, _Count);
|
||||
}
|
||||
|
||||
basic_string(const value_type* _Ptr) : basic_string(_Ptr, c_len(_Ptr))
|
||||
{
|
||||
}
|
||||
|
||||
void reserve(size_t newcapacity)
|
||||
{
|
||||
m_string.reserve(newcapacity + 1); // add 1 for the null terminator
|
||||
}
|
||||
|
||||
//
|
||||
// Assignment
|
||||
//
|
||||
|
||||
basic_string<T>& operator=(const basic_string<T>& _Right)
|
||||
{
|
||||
if (this != &_Right)
|
||||
{
|
||||
assign(_Right);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
|
||||
basic_string<T>& assign(const basic_string<T>& _Right)
|
||||
{
|
||||
m_string.resize(_Right.size() + 1); // +1 for null terminator
|
||||
copy(_Right);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
//
|
||||
// Basic data copying
|
||||
//
|
||||
|
||||
void copy(const basic_string<T>& _Right)
|
||||
{
|
||||
assert(size() >= _Right.size());
|
||||
size_type i;
|
||||
for (i = 0; i < _Right.size(); i++)
|
||||
{
|
||||
m_string[i] = _Right.m_string[i];
|
||||
}
|
||||
m_string[i] = T();
|
||||
}
|
||||
|
||||
void copy(const value_type* _Ptr, size_type _Count)
|
||||
{
|
||||
assert(size() >= _Count);
|
||||
size_type i;
|
||||
for (i = 0; i < _Count; i++)
|
||||
{
|
||||
m_string[i] = _Ptr[i];
|
||||
}
|
||||
m_string[i] = T();
|
||||
}
|
||||
|
||||
//
|
||||
// Appending
|
||||
//
|
||||
|
||||
// Append a C-style string to the string.
|
||||
basic_string<T>& operator+=(const value_type* _Ptr)
|
||||
{
|
||||
size_type oldsize = size(); // doesn't include null terminator
|
||||
size_type addsize = c_len(_Ptr); // doesn't include null terminator
|
||||
size_type newsize = oldsize + addsize + 1;
|
||||
m_string.resize(newsize);
|
||||
size_type i;
|
||||
for (i = oldsize; i < newsize - 1; i++)
|
||||
{
|
||||
m_string[i] = *_Ptr++;
|
||||
}
|
||||
m_string[i] = T();
|
||||
return (*this);
|
||||
}
|
||||
|
||||
basic_string<T>& operator+=(const basic_string<T>& _Right)
|
||||
{
|
||||
size_type oldsize = size(); // doesn't include null terminator
|
||||
size_type addsize = _Right.size(); // doesn't include null terminator
|
||||
size_type newsize = oldsize + addsize + 1;
|
||||
m_string.resize(newsize);
|
||||
size_type new_index = oldsize, right_index = 0;
|
||||
while (right_index < addsize)
|
||||
{
|
||||
m_string[new_index] = _Right.m_string[right_index];
|
||||
++new_index;
|
||||
++right_index;
|
||||
}
|
||||
m_string[new_index] = T();
|
||||
return (*this);
|
||||
}
|
||||
|
||||
basic_string<T>& operator+=(value_type _Ch)
|
||||
{
|
||||
size_type oldsize = size(); // doesn't include null terminator
|
||||
m_string[oldsize] = _Ch; // Replace the null terminator with the new symbol.
|
||||
m_string.push_back(T()); // Return the replaced terminator again.
|
||||
return (*this);
|
||||
}
|
||||
|
||||
~basic_string()
|
||||
{
|
||||
// vector destructor does all the work
|
||||
}
|
||||
|
||||
size_t size() const
|
||||
{
|
||||
assert(m_string.size() > 0);
|
||||
return m_string.size() - 1; // Don't report the null terminator.
|
||||
}
|
||||
|
||||
size_t length() const
|
||||
{
|
||||
return size();
|
||||
}
|
||||
|
||||
T& operator[](size_t iIndex)
|
||||
{
|
||||
assert(iIndex < size() + 1); // allow looking at the null terminator
|
||||
return m_string[iIndex];
|
||||
}
|
||||
|
||||
const T* c_str() const
|
||||
{
|
||||
return m_string.data();
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
return m_string.begin();
|
||||
}
|
||||
|
||||
iterator end()
|
||||
{
|
||||
return m_string.end();
|
||||
}
|
||||
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
return m_string.cbegin();
|
||||
}
|
||||
|
||||
const_iterator cend() const
|
||||
{
|
||||
return m_string.cend();
|
||||
}
|
||||
|
||||
basic_string<T> substr(size_type _Off = 0, size_type _Count = npos) const
|
||||
{
|
||||
size_type cursize = size();
|
||||
if (_Off >= cursize)
|
||||
{
|
||||
// result will be empty
|
||||
return basic_string<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((_Count == npos) || // No count specified; take the whole string suffix
|
||||
(_Off + _Count > cursize)) // Count specified is too many characters; just take the whole suffix
|
||||
{
|
||||
_Count = cursize - _Off;
|
||||
}
|
||||
return basic_string<T>(m_string.data() + _Off, _Count);
|
||||
}
|
||||
}
|
||||
|
||||
size_type find_last_of(value_type _Ch) const
|
||||
{
|
||||
for (size_type _Off = size(); _Off != 0; _Off--)
|
||||
{
|
||||
if (m_string[_Off - 1] == _Ch)
|
||||
{
|
||||
return _Off - 1;
|
||||
}
|
||||
}
|
||||
return npos;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
int compare(const basic_string<T>& _Str) const
|
||||
{
|
||||
size_type i;
|
||||
size_type compareSize = size();
|
||||
if (_Str.size() < compareSize)
|
||||
{
|
||||
// This string is longer; compare character-by-character only as many characters as we have.
|
||||
compareSize = _Str.size();
|
||||
}
|
||||
for (i = 0; i < compareSize; i++)
|
||||
{
|
||||
if (m_string[i] != _Str.m_string[i])
|
||||
{
|
||||
if (m_string[i] < _Str.m_string[i])
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All the characters we compared were identical, but one string might be longer than the other.
|
||||
if (size() == _Str.size())
|
||||
{
|
||||
// We compared everything.
|
||||
return 0;
|
||||
}
|
||||
else if (size() < _Str.size())
|
||||
{
|
||||
// _Str has more characters than this.
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// this has more characters than _Str
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static const size_type npos = size_type(-1);
|
||||
|
||||
private:
|
||||
|
||||
// Compute the length in characters of a null-terminated C-style string, not including the trailing null character.
|
||||
// _Ptr must not be nullptr.
|
||||
size_type c_len(const value_type* _Ptr)
|
||||
{
|
||||
size_type count;
|
||||
for (count = 0; *_Ptr != T(); _Ptr++)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
vector<T> m_string; // use a vector<> to represent the string, to avoid reimplementing similar functionality
|
||||
|
||||
}; // class basic_string
|
||||
|
||||
//
|
||||
// String class instantiations
|
||||
//
|
||||
|
||||
typedef basic_string<char> string;
|
||||
|
||||
//
|
||||
// Numeric conversions
|
||||
//
|
||||
|
||||
// convert integer T to string
|
||||
template<class T> inline
|
||||
string _IntToString(const char *_Fmt, T _Val)
|
||||
{
|
||||
const size_t MaxIntBufSize = 21; /* can hold -2^63 and 2^64 - 1, plus NUL */
|
||||
char buf[MaxIntBufSize];
|
||||
int len = sprintf_s(buf, MaxIntBufSize, _Fmt, _Val);
|
||||
return (string(buf, len));
|
||||
}
|
||||
|
||||
inline string to_string(int _Val)
|
||||
{
|
||||
return (_IntToString("%d", _Val));
|
||||
}
|
||||
|
||||
inline string to_string(unsigned int _Val)
|
||||
{
|
||||
return (_IntToString("%u", _Val));
|
||||
}
|
||||
|
||||
inline string to_string(long _Val)
|
||||
{
|
||||
return (_IntToString("%ld", _Val));
|
||||
}
|
||||
|
||||
inline string to_string(unsigned long _Val)
|
||||
{
|
||||
return (_IntToString("%lu", _Val));
|
||||
}
|
||||
|
||||
inline string to_string(long long _Val)
|
||||
{
|
||||
return (_IntToString("%lld", _Val));
|
||||
}
|
||||
|
||||
inline string to_string(unsigned long long _Val)
|
||||
{
|
||||
return (_IntToString("%llu", _Val));
|
||||
}
|
||||
|
||||
//
|
||||
// Comparisons
|
||||
//
|
||||
|
||||
template<class T> inline
|
||||
bool operator==(
|
||||
const basic_string<T>& _Left,
|
||||
const basic_string<T>& _Right)
|
||||
{
|
||||
return (_Left.compare(_Right) == 0);
|
||||
}
|
||||
|
||||
template<class T> inline
|
||||
bool operator!=(
|
||||
const basic_string<T>& _Left,
|
||||
const basic_string<T>& _Right)
|
||||
{
|
||||
return (!(_Left == _Right));
|
||||
}
|
||||
|
||||
template<class T> inline
|
||||
bool operator<(
|
||||
const basic_string<T>& _Left,
|
||||
const basic_string<T>& _Right)
|
||||
{
|
||||
return (_Left.compare(_Right) < 0);
|
||||
}
|
||||
|
||||
template<class T> inline
|
||||
bool operator>(
|
||||
const basic_string<T>& _Left,
|
||||
const basic_string<T>& _Right)
|
||||
{
|
||||
return (_Right < _Left);
|
||||
}
|
||||
|
||||
template<class T> inline
|
||||
bool operator<=(
|
||||
const basic_string<T>& _Left,
|
||||
const basic_string<T>& _Right)
|
||||
{
|
||||
return (!(_Right < _Left));
|
||||
}
|
||||
|
||||
template<class T> inline
|
||||
bool operator>=(
|
||||
const basic_string<T>& _Left,
|
||||
const basic_string<T>& _Right)
|
||||
{
|
||||
return (!(_Left < _Right));
|
||||
}
|
||||
|
||||
//
|
||||
// String concatenation and other string operations
|
||||
//
|
||||
|
||||
template<class T> inline
|
||||
basic_string<T> operator+(
|
||||
const basic_string<T>& _Left,
|
||||
const basic_string<T>& _Right)
|
||||
{
|
||||
basic_string<T> ret;
|
||||
ret.reserve(_Left.size() + _Right.size());
|
||||
ret += _Left;
|
||||
ret += _Right;
|
||||
return ret;
|
||||
}
|
||||
|
||||
}; // namespace std
|
||||
|
||||
#endif /* __clr_std_string_h__ */
|
||||
|
||||
#endif // !USE_STL
|
||||
|
||||
// Help the VIM editor figure out what kind of file this no-extension file is.
|
||||
// vim: filetype=cpp
|
|
@ -1,627 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
//
|
||||
// clr_std/utility
|
||||
//
|
||||
// Copy of some key Standard Template Library functionality.
|
||||
// See http://msdn.microsoft.com/en-us/library/bb982077.aspx for documentation.
|
||||
//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifndef __clr_std_type_traits_h__
|
||||
#define __clr_std_type_traits_h__
|
||||
|
||||
#ifdef USE_STL
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
#else
|
||||
|
||||
namespace std
|
||||
{
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS remove_const
|
||||
template<class _Ty>
|
||||
struct remove_const
|
||||
{ // remove top level const qualifier
|
||||
typedef _Ty type;
|
||||
};
|
||||
|
||||
template<class _Ty>
|
||||
struct remove_const<const _Ty>
|
||||
{ // remove top level const qualifier
|
||||
typedef _Ty type;
|
||||
};
|
||||
|
||||
template<class _Ty>
|
||||
struct remove_const<const _Ty[]>
|
||||
{ // remove top level const qualifier
|
||||
typedef _Ty type[];
|
||||
};
|
||||
|
||||
template<class _Ty, unsigned int _Nx>
|
||||
struct remove_const<const _Ty[_Nx]>
|
||||
{ // remove top level const qualifier
|
||||
typedef _Ty type[_Nx];
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS remove_volatile
|
||||
template<class _Ty>
|
||||
struct remove_volatile
|
||||
{ // remove top level volatile qualifier
|
||||
typedef _Ty type;
|
||||
};
|
||||
|
||||
template<class _Ty>
|
||||
struct remove_volatile<volatile _Ty>
|
||||
{ // remove top level volatile qualifier
|
||||
typedef _Ty type;
|
||||
};
|
||||
|
||||
template<class _Ty>
|
||||
struct remove_volatile<volatile _Ty[]>
|
||||
{ // remove top level volatile qualifier
|
||||
typedef _Ty type[];
|
||||
};
|
||||
|
||||
template<class _Ty, unsigned int _Nx>
|
||||
struct remove_volatile<volatile _Ty[_Nx]>
|
||||
{ // remove top level volatile qualifier
|
||||
typedef _Ty type[_Nx];
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS remove_cv
|
||||
template<class _Ty>
|
||||
struct remove_cv
|
||||
{ // remove top level const and volatile qualifiers
|
||||
typedef typename remove_const<typename remove_volatile<_Ty>::type>::type type;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE remove_reference
|
||||
template<class T>
|
||||
struct remove_reference
|
||||
{ // remove reference
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_reference<T&>
|
||||
{ // remove reference
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_reference<T&&>
|
||||
{ // remove rvalue reference
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE remove_pointer
|
||||
template<class T>
|
||||
struct remove_pointer
|
||||
{ // remove pointer
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
struct remove_pointer<T*>
|
||||
{ // remove pointer
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE FUNCTION identity
|
||||
template<class T>
|
||||
struct identity
|
||||
{ // map T to type unchanged
|
||||
typedef T type;
|
||||
|
||||
inline
|
||||
const T& operator()(const T& left) const
|
||||
{ // apply identity operator to operand
|
||||
return (left);
|
||||
}
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS integral_constant
|
||||
template<class _Ty, _Ty _Val>
|
||||
struct integral_constant
|
||||
{ // convenient template for integral constant types
|
||||
static const _Ty value = _Val;
|
||||
|
||||
typedef _Ty value_type;
|
||||
typedef integral_constant<_Ty, _Val> type;
|
||||
};
|
||||
|
||||
typedef integral_constant<bool, true> true_type;
|
||||
typedef integral_constant<bool, false> false_type;
|
||||
|
||||
// TEMPLATE CLASS _Cat_base
|
||||
template<bool>
|
||||
struct _Cat_base
|
||||
: false_type
|
||||
{ // base class for type predicates
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Cat_base<true>
|
||||
: true_type
|
||||
{ // base class for type predicates
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS enable_if
|
||||
template<bool _Test, class _Type = void>
|
||||
struct enable_if
|
||||
{ // type is undefined for assumed !_Test
|
||||
};
|
||||
|
||||
template<class _Type>
|
||||
struct enable_if<true, _Type>
|
||||
{ // type is _Type for _Test
|
||||
typedef _Type type;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS conditional
|
||||
template<bool _Test, class _Ty1, class _Ty2>
|
||||
struct conditional
|
||||
{ // type is _Ty2 for assumed !_Test
|
||||
typedef _Ty2 type;
|
||||
};
|
||||
|
||||
template<class _Ty1, class _Ty2>
|
||||
struct conditional<true, _Ty1, _Ty2>
|
||||
{ // type is _Ty1 for _Test
|
||||
typedef _Ty1 type;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS make_unsigned
|
||||
template<typename Type1>
|
||||
struct make_unsigned
|
||||
{
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_unsigned<int>
|
||||
{
|
||||
typedef unsigned int type;
|
||||
};
|
||||
|
||||
#ifndef HOST_UNIX
|
||||
|
||||
template<>
|
||||
struct make_unsigned<long>
|
||||
{
|
||||
typedef unsigned long type;
|
||||
};
|
||||
|
||||
#endif // !HOST_UNIX
|
||||
|
||||
template<>
|
||||
struct make_unsigned<__int64>
|
||||
{
|
||||
typedef unsigned __int64 type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_unsigned<size_t>
|
||||
{
|
||||
typedef size_t type;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS make_signed
|
||||
template<typename Type1>
|
||||
struct make_signed
|
||||
{
|
||||
};
|
||||
|
||||
template<>
|
||||
struct make_signed<unsigned int>
|
||||
{
|
||||
typedef signed int type;
|
||||
};
|
||||
|
||||
#ifndef HOST_UNIX
|
||||
|
||||
template<>
|
||||
struct make_signed<unsigned long>
|
||||
{
|
||||
typedef signed long type;
|
||||
};
|
||||
|
||||
#endif // !HOST_UNIX
|
||||
|
||||
template<>
|
||||
struct make_signed<unsigned __int64>
|
||||
{
|
||||
typedef signed __int64 type;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS is_lvalue_reference
|
||||
template<class _Ty>
|
||||
struct is_lvalue_reference
|
||||
: false_type
|
||||
{ // determine whether _Ty is an lvalue reference
|
||||
};
|
||||
|
||||
template<class _Ty>
|
||||
struct is_lvalue_reference<_Ty&>
|
||||
: true_type
|
||||
{ // determine whether _Ty is an lvalue reference
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS is_rvalue_reference
|
||||
template<class _Ty>
|
||||
struct is_rvalue_reference
|
||||
: false_type
|
||||
{ // determine whether _Ty is an rvalue reference
|
||||
};
|
||||
|
||||
template<class _Ty>
|
||||
struct is_rvalue_reference<_Ty&&>
|
||||
: true_type
|
||||
{ // determine whether _Ty is an rvalue reference
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS is_reference
|
||||
template<class _Ty>
|
||||
struct is_reference
|
||||
: conditional<
|
||||
is_lvalue_reference<_Ty>::value || is_rvalue_reference<_Ty>::value,
|
||||
true_type,
|
||||
false_type>::type
|
||||
{ // determine whether _Ty is a reference
|
||||
};
|
||||
|
||||
// TEMPLATE CLASS is_pointer
|
||||
template<class _Ty>
|
||||
struct is_pointer
|
||||
: false_type
|
||||
{ // determine whether _Ty is a pointer
|
||||
};
|
||||
|
||||
template<class _Ty>
|
||||
struct is_pointer<_Ty *>
|
||||
: true_type
|
||||
{ // determine whether _Ty is a pointer
|
||||
};
|
||||
|
||||
// TEMPLATE CLASS _Is_integral
|
||||
template<class _Ty>
|
||||
struct _Is_integral
|
||||
: false_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<bool>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<char>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<unsigned char>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<signed char>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<unsigned short>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<signed short>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<unsigned int>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<signed int>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
// On Unix 'long' is a 64-bit type (same as __int64) and the following two definitions
|
||||
// conflict with _Is_integral<unsigned __int64> and _Is_integral<signed __int64>.
|
||||
#if !defined(HOST_UNIX) || defined(__APPLE__)
|
||||
template<>
|
||||
struct _Is_integral<unsigned long>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<signed long>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
#endif /* !HOST_UNIX || __APPLE__ */
|
||||
|
||||
#if _HAS_CHAR16_T_LANGUAGE_SUPPORT
|
||||
template<>
|
||||
struct _Is_integral<char16_t>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<char32_t>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
#endif /* _HAS_CHAR16_T_LANGUAGE_SUPPORT */
|
||||
|
||||
template<>
|
||||
struct _Is_integral<unsigned __int64>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_integral<signed __int64>
|
||||
: true_type
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
// TEMPLATE CLASS is_integral
|
||||
template<class _Ty>
|
||||
struct is_integral
|
||||
: _Is_integral<typename remove_cv<_Ty>::type>
|
||||
{ // determine whether _Ty is integral
|
||||
};
|
||||
|
||||
// TEMPLATE CLASS _Is_floating_point
|
||||
template<class _Ty>
|
||||
struct _Is_floating_point
|
||||
: false_type
|
||||
{ // determine whether _Ty is floating point
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_floating_point<float>
|
||||
: true_type
|
||||
{ // determine whether _Ty is floating point
|
||||
};
|
||||
|
||||
template<>
|
||||
struct _Is_floating_point<double>
|
||||
: true_type
|
||||
{ // determine whether _Ty is floating point
|
||||
};
|
||||
|
||||
// In PAL, we define long as int and so this becomes int double,
|
||||
// which is a nonsense
|
||||
#ifndef HOST_UNIX
|
||||
template<>
|
||||
struct _Is_floating_point<long double>
|
||||
: true_type
|
||||
{ // determine whether _Ty is floating point
|
||||
};
|
||||
#endif
|
||||
|
||||
// TEMPLATE CLASS is_floating_point
|
||||
template<class _Ty>
|
||||
struct is_floating_point
|
||||
: _Is_floating_point<typename remove_cv<_Ty>::type>
|
||||
{ // determine whether _Ty is floating point
|
||||
};
|
||||
|
||||
// TEMPLATE CLASS is_arithmetic
|
||||
template<class _Ty>
|
||||
struct is_arithmetic
|
||||
: _Cat_base<is_integral<_Ty>::value
|
||||
|| is_floating_point<_Ty>::value>
|
||||
{ // determine whether _Ty is an arithmetic type
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS is_signed
|
||||
template <typename T>
|
||||
struct is_signed : conditional<
|
||||
static_cast<typename remove_const<T>::type>(-1) < 0, true_type, false_type>::type {};
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS is_same
|
||||
template<class T1, class T2>
|
||||
struct is_same : false_type { };
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
template<class T1>
|
||||
struct is_same<T1, T1> : true_type { };
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE CLASS is_base_of
|
||||
#ifdef _MSC_VER
|
||||
|
||||
template <typename TBase, typename TDerived>
|
||||
struct is_base_of :
|
||||
conditional<__is_base_of( TBase, TDerived), true_type, false_type>::type {};
|
||||
|
||||
#else
|
||||
namespace detail
|
||||
{
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Helper types Small and Big - guarantee that sizeof(Small) < sizeof(Big)
|
||||
//
|
||||
|
||||
template <class T, class U>
|
||||
struct conversion_helper
|
||||
{
|
||||
typedef char Small;
|
||||
struct Big { char dummy[2]; };
|
||||
static Big Test(...);
|
||||
static Small Test(U);
|
||||
static T MakeT();
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// class template conversion
|
||||
// Figures out the conversion relationships between two types
|
||||
// Invocations (T and U are types):
|
||||
// a) conversion<T, U>::exists
|
||||
// returns (at compile time) true if there is an implicit conversion from T
|
||||
// to U (example: Derived to Base)
|
||||
// b) conversion<T, U>::exists2Way
|
||||
// returns (at compile time) true if there are both conversions from T
|
||||
// to U and from U to T (example: int to char and back)
|
||||
// c) conversion<T, U>::sameType
|
||||
// returns (at compile time) true if T and U represent the same type
|
||||
//
|
||||
// NOTE: might not work if T and U are in a private inheritance hierarchy.
|
||||
//
|
||||
|
||||
template <class T, class U>
|
||||
struct conversion
|
||||
{
|
||||
typedef detail::conversion_helper<T, U> H;
|
||||
static const bool exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT())));
|
||||
static const bool exists2Way = exists && conversion<U, T>::exists;
|
||||
static const bool sameType = false;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct conversion<T, T>
|
||||
{
|
||||
static const bool exists = true;
|
||||
static const bool exists2Way = true;
|
||||
static const bool sameType = true;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct conversion<void, T>
|
||||
{
|
||||
static const bool exists = false;
|
||||
static const bool exists2Way = false;
|
||||
static const bool sameType = false;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct conversion<T, void>
|
||||
{
|
||||
static const bool exists = false;
|
||||
static const bool exists2Way = false;
|
||||
static const bool sameType = false;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct conversion<void, void>
|
||||
{
|
||||
static const bool exists = true;
|
||||
static const bool exists2Way = true;
|
||||
static const bool sameType = true;
|
||||
};
|
||||
} // detail
|
||||
|
||||
// Note that we need to compare pointer types here, since conversion of types by-value
|
||||
// just tells us whether or not an implicit conversion constructor exists. We handle
|
||||
// type parameters that are already pointers specially; see below.
|
||||
template <typename TBase, typename TDerived>
|
||||
struct is_base_of :
|
||||
conditional<detail::conversion<TDerived *, TBase *>::exists, true_type, false_type>::type {};
|
||||
|
||||
// Specialization to handle type parameters that are already pointers.
|
||||
template <typename TBase, typename TDerived>
|
||||
struct is_base_of<TBase *, TDerived *> :
|
||||
conditional<detail::conversion<TDerived *, TBase *>::exists, true_type, false_type>::type {};
|
||||
|
||||
// Specialization to handle invalid mixing of pointer types.
|
||||
template <typename TBase, typename TDerived>
|
||||
struct is_base_of<TBase *, TDerived> :
|
||||
false_type {};
|
||||
|
||||
// Specialization to handle invalid mixing of pointer types.
|
||||
template <typename TBase, typename TDerived>
|
||||
struct is_base_of<TBase, TDerived *> :
|
||||
false_type {};
|
||||
|
||||
#endif
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename...>
|
||||
using void_t = void;
|
||||
}
|
||||
// Always false dependent-value for static_asserts.
|
||||
template <typename...>
|
||||
struct _Always_false
|
||||
{
|
||||
const bool value = false;
|
||||
};
|
||||
|
||||
template <class _Ty, class = void>
|
||||
struct _Add_reference { // add reference (non-referenceable type)
|
||||
using _Lvalue = _Ty;
|
||||
using _Rvalue = _Ty;
|
||||
};
|
||||
|
||||
template <class _Ty>
|
||||
struct _Add_reference<_Ty, detail::void_t<_Ty&>> { // (referenceable type)
|
||||
using _Lvalue = _Ty&;
|
||||
using _Rvalue = _Ty&&;
|
||||
};
|
||||
|
||||
template <class _Ty>
|
||||
struct add_lvalue_reference {
|
||||
using type = typename _Add_reference<_Ty>::_Lvalue;
|
||||
};
|
||||
|
||||
template <class _Ty>
|
||||
struct add_rvalue_reference {
|
||||
using type = typename _Add_reference<_Ty>::_Rvalue;
|
||||
};
|
||||
|
||||
template<typename _Ty>
|
||||
typename add_rvalue_reference<_Ty>::type declval() noexcept
|
||||
{
|
||||
static_assert(_Always_false<_Ty>::value, "Calling declval is ill-formed, see N4892 [declval]/2.");
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#endif // !USE_STL
|
||||
|
||||
#define REM_CONST(T) typename std::remove_const< T >::type
|
||||
#define REM_CV(T) typename std::remove_cv< T >::type
|
||||
#define REM_REF(T) typename std::remove_reference< T >::type
|
||||
|
||||
#define REF_T(T) REM_REF(T) &
|
||||
#define REF_CT(T) REM_REF(REM_CONST(T)) const &
|
||||
|
||||
#endif // __clr_std_type_traits_h__
|
||||
|
||||
// Help the VIM editor figure out what kind of file this no-extension file is.
|
||||
// vim: filetype=cpp
|
|
@ -1,253 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
//
|
||||
// clr_std/utility
|
||||
//
|
||||
// Copy of some key Standard Template Library functionality
|
||||
// See http://msdn.microsoft.com/en-us/library/bb982077.aspx for documentation.
|
||||
//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef USE_STL
|
||||
#include <utility>
|
||||
#else
|
||||
#ifndef __clr_std_utility_h__
|
||||
#define __clr_std_utility_h__
|
||||
|
||||
#include "clr_std/type_traits"
|
||||
|
||||
namespace std
|
||||
{
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE FUNCTION move
|
||||
template<class T> inline
|
||||
typename remove_reference<T>::type&&
|
||||
move(T&& arg)
|
||||
{ // forward _Arg as movable
|
||||
return ((typename remove_reference<T>::type&&)arg);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE FUNCTION swap (from <algorithm>)
|
||||
template<class T> inline
|
||||
void swap(T& left, T& right)
|
||||
{ // exchange values stored at left and right
|
||||
T tmp = std::move(left);
|
||||
left = std::move(right);
|
||||
right = std::move(tmp);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE FUNCTION forward
|
||||
template<class T> inline
|
||||
T&&
|
||||
forward(typename identity<T>::type& _Arg)
|
||||
{ // forward _Arg, given explicitly specified type parameter
|
||||
return ((T&&)_Arg);
|
||||
}
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// TEMPLATE STRUCT pair
|
||||
template<class _Ty1, class _Ty2>
|
||||
struct pair
|
||||
{ // store a pair of values
|
||||
typedef pair<_Ty1, _Ty2> _Myt;
|
||||
typedef _Ty1 first_type;
|
||||
typedef _Ty2 second_type;
|
||||
|
||||
pair()
|
||||
: first(_Ty1()), second(_Ty2())
|
||||
{ // construct from defaults
|
||||
}
|
||||
|
||||
pair(const _Ty1& _Val1, const _Ty2& _Val2)
|
||||
: first(_Val1.first), second(_Val2.second)
|
||||
{ // construct from specified values
|
||||
}
|
||||
|
||||
template<class _Other1, class _Other2>
|
||||
pair(pair<_Other1, _Other2>& _Right)
|
||||
: first(_Right.first), second(_Right.second)
|
||||
{ // construct from compatible pair
|
||||
}
|
||||
|
||||
template<class _Other1, class _Other2>
|
||||
pair(const pair<_Other1, _Other2>& _Right)
|
||||
: first(_Right.first), second(_Right.second)
|
||||
{ // construct from compatible pair
|
||||
}
|
||||
|
||||
void swap(_Myt& _Right)
|
||||
{ // exchange contents with _Right
|
||||
if (this != &_Right)
|
||||
{ // different, worth swapping
|
||||
swap(this->first, _Right.first);
|
||||
swap(this->second, _Right.second);
|
||||
}
|
||||
}
|
||||
|
||||
_Myt& operator=(const _Myt& _Right)
|
||||
{ // assign from copied pair
|
||||
this->first = _Right.first;
|
||||
this->second = _Right.second;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
typedef typename remove_reference<_Ty1>::type _Ty1x;
|
||||
typedef typename remove_reference<_Ty2>::type _Ty2x;
|
||||
|
||||
pair(_Ty1x&& _Val1, _Ty2x&& _Val2)
|
||||
: first(std::move(_Val1)),
|
||||
second(std::move(_Val2))
|
||||
{ // construct from specified values
|
||||
}
|
||||
|
||||
pair(const _Ty1x& _Val1, _Ty2x&& _Val2)
|
||||
: first(_Val1),
|
||||
second(std::move(_Val2))
|
||||
{ // construct from specified values
|
||||
}
|
||||
|
||||
pair(_Ty1x&& _Val1, const _Ty2x& _Val2)
|
||||
: first(std::move(_Val1)),
|
||||
second(_Val2)
|
||||
{ // construct from specified values
|
||||
}
|
||||
|
||||
template<class _Other1, class _Other2>
|
||||
pair(_Other1&& _Val1, _Other2&& _Val2)
|
||||
: first(std::move(_Val1)),
|
||||
second(std::move(_Val2))
|
||||
{ // construct from moved values
|
||||
}
|
||||
|
||||
template<class _Other1, class _Other2>
|
||||
pair(pair<_Other1, _Other2>&& _Right)
|
||||
: first(std::move(_Right.first)),
|
||||
second(std::move(_Right.second))
|
||||
{ // construct from moved compatible pair
|
||||
}
|
||||
|
||||
pair& operator=(pair<_Ty1, _Ty2>&& _Right)
|
||||
{ // assign from moved pair
|
||||
this->first = std::move(_Right.first);
|
||||
this->second = std::move(_Right.second);
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void swap(_Myt&& _Right)
|
||||
{ // exchange contents with _Right
|
||||
if (this != &_Right)
|
||||
{ // different, worth swapping
|
||||
this->first = std::move(_Right.first);
|
||||
this->second = std::move(_Right.second);
|
||||
}
|
||||
}
|
||||
|
||||
_Ty1 first; // the first stored value
|
||||
_Ty2 second; // the second stored value
|
||||
}; // struct pair
|
||||
|
||||
//-----------------------------------------------------------------------------------------
|
||||
// pair TEMPLATE FUNCTIONS
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
void swap(pair<_Ty1, _Ty2>& _Left, pair<_Ty1, _Ty2>& _Right)
|
||||
{ // swap _Left and _Right pairs
|
||||
_Left.swap(_Right);
|
||||
}
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
void swap(pair<_Ty1, _Ty2>& _Left, pair<_Ty1, _Ty2>&& _Right)
|
||||
{ // swap _Left and _Right pairs
|
||||
typedef pair<_Ty1, _Ty2> _Myt;
|
||||
_Left.swap(std::forward<_Myt>(_Right));
|
||||
}
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
void swap(
|
||||
pair<_Ty1, _Ty2>&& _Left,
|
||||
pair<_Ty1, _Ty2>& _Right)
|
||||
{ // swap _Left and _Right pairs
|
||||
typedef pair<_Ty1, _Ty2> _Myt;
|
||||
_Right.swap(std::forward<_Myt>(_Left));
|
||||
}
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
bool operator==(
|
||||
const pair<_Ty1, _Ty2>& _Left,
|
||||
const pair<_Ty1, _Ty2>& _Right)
|
||||
{ // test for pair equality
|
||||
return (_Left.first == _Right.first && _Left.second == _Right.second);
|
||||
}
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
bool operator!=(
|
||||
const pair<_Ty1, _Ty2>& _Left,
|
||||
const pair<_Ty1, _Ty2>& _Right)
|
||||
{ // test for pair inequality
|
||||
return (!(_Left == _Right));
|
||||
}
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
bool operator<(
|
||||
const pair<_Ty1, _Ty2>& _Left,
|
||||
const pair<_Ty1, _Ty2>& _Right)
|
||||
{ // test if _Left < _Right for pairs
|
||||
return (_Left.first < _Right.first ||
|
||||
(!(_Right.first < _Left.first) && _Left.second < _Right.second));
|
||||
}
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
bool operator>(
|
||||
const pair<_Ty1, _Ty2>& _Left,
|
||||
const pair<_Ty1, _Ty2>& _Right)
|
||||
{ // test if _Left > _Right for pairs
|
||||
return (_Right < _Left);
|
||||
}
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
bool operator<=(
|
||||
const pair<_Ty1, _Ty2>& _Left,
|
||||
const pair<_Ty1, _Ty2>& _Right)
|
||||
{ // test if _Left <= _Right for pairs
|
||||
return (!(_Right < _Left));
|
||||
}
|
||||
|
||||
template<class _Ty1, class _Ty2> inline
|
||||
bool operator>=(
|
||||
const pair<_Ty1, _Ty2>& _Left,
|
||||
const pair<_Ty1, _Ty2>& _Right)
|
||||
{ // test if _Left >= _Right for pairs
|
||||
return (!(_Left < _Right));
|
||||
}
|
||||
|
||||
template<class _InIt> inline
|
||||
_InIt begin(
|
||||
const pair<_InIt, _InIt>& _Pair)
|
||||
{ // return first element of pair
|
||||
return (_Pair.first);
|
||||
}
|
||||
|
||||
template<class _InIt> inline
|
||||
_InIt end(
|
||||
const pair<_InIt, _InIt>& _Pair)
|
||||
{ // return second element of pair
|
||||
return (_Pair.second);
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif /* __clr_std_utility_h__ */
|
||||
|
||||
#endif // !USE_STL
|
||||
|
||||
// Help the VIM editor figure out what kind of file this no-extension file is.
|
||||
// vim: filetype=cpp
|
|
@ -1,462 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
//
|
||||
// clr_std/vector
|
||||
//
|
||||
// Copy of some key Standard Template Library functionality
|
||||
//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#ifdef USE_STL
|
||||
#include <vector>
|
||||
#else
|
||||
#ifndef __clr_std_vector_h__
|
||||
#define __clr_std_vector_h__
|
||||
|
||||
// This is defined in the debugmacrosext.h header, but don't take a dependency on that.
|
||||
#ifndef INDEBUG
|
||||
#ifdef _DEBUG
|
||||
#define INDEBUG(x) x
|
||||
#else
|
||||
#define INDEBUG(x)
|
||||
#endif
|
||||
#endif // !def INDEBUG
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <class T>
|
||||
class vector
|
||||
{
|
||||
public:
|
||||
class const_iterator;
|
||||
|
||||
class iterator
|
||||
{
|
||||
friend class std::vector<T>::const_iterator;
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
|
||||
typedef class vector<T>::iterator _MyIter;
|
||||
|
||||
_MyIter &operator++()
|
||||
{
|
||||
m_ptr++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_MyIter operator++(int)
|
||||
{
|
||||
// post-increment ++
|
||||
_MyIter myiter(m_ptr);
|
||||
m_ptr++;
|
||||
return myiter;
|
||||
}
|
||||
|
||||
_MyIter &operator--()
|
||||
{
|
||||
m_ptr--;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_MyIter operator--(int)
|
||||
{
|
||||
// post-decrement --
|
||||
_MyIter myiter(m_ptr);
|
||||
m_ptr--;
|
||||
return myiter;
|
||||
}
|
||||
|
||||
_MyIter operator- (ptrdiff_t n)
|
||||
{
|
||||
_MyIter myiter(m_ptr);
|
||||
myiter.m_ptr -= n;
|
||||
return myiter;
|
||||
}
|
||||
|
||||
ptrdiff_t operator- (_MyIter right)
|
||||
{
|
||||
_MyIter myiter(m_ptr);
|
||||
return myiter.m_ptr - right.m_ptr;
|
||||
}
|
||||
|
||||
_MyIter operator+ (ptrdiff_t n)
|
||||
{
|
||||
_MyIter myiter(m_ptr);
|
||||
myiter.m_ptr += n;
|
||||
return myiter;
|
||||
}
|
||||
|
||||
T* operator->() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
T & operator*() const
|
||||
{
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
bool operator==(const _MyIter& _Right) const
|
||||
{
|
||||
bool equals = this->m_ptr == _Right.m_ptr;
|
||||
return equals;
|
||||
}
|
||||
|
||||
bool operator!=(const _MyIter& _Right) const
|
||||
{
|
||||
bool equals = this->m_ptr == _Right.m_ptr;
|
||||
return !equals;
|
||||
}
|
||||
|
||||
bool operator<(const _MyIter& _Right) const
|
||||
{
|
||||
return this->m_ptr < _Right.m_ptr;
|
||||
}
|
||||
|
||||
bool operator>(const _MyIter& _Right) const
|
||||
{
|
||||
return this->m_ptr > _Right.m_ptr;
|
||||
}
|
||||
public:
|
||||
explicit iterator(T* ptr)
|
||||
{
|
||||
m_ptr = ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
T* m_ptr;
|
||||
}; // class iterator
|
||||
|
||||
class const_iterator
|
||||
{
|
||||
public:
|
||||
typedef class vector<T>::const_iterator _MyIter;
|
||||
typedef class vector<T>::iterator _MyNonConstIter;
|
||||
|
||||
_MyIter &operator++()
|
||||
{
|
||||
m_ptr++;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_MyIter operator++(int)
|
||||
{
|
||||
// post-increment ++
|
||||
_MyIter myiter(m_ptr);
|
||||
m_ptr++;
|
||||
return myiter;
|
||||
}
|
||||
|
||||
const T* operator->() const
|
||||
{
|
||||
return m_ptr;
|
||||
}
|
||||
|
||||
const T & operator*() const
|
||||
{
|
||||
return *m_ptr;
|
||||
}
|
||||
|
||||
bool operator==(const _MyIter& _Right) const
|
||||
{
|
||||
bool equals = this->m_ptr == _Right.m_ptr;
|
||||
return equals;
|
||||
}
|
||||
|
||||
bool operator!=(const _MyIter& _Right) const
|
||||
{
|
||||
bool equals = this->m_ptr == _Right.m_ptr;
|
||||
return !equals;
|
||||
}
|
||||
|
||||
public:
|
||||
explicit const_iterator(T* ptr)
|
||||
{
|
||||
m_ptr = ptr;
|
||||
}
|
||||
const_iterator(const _MyNonConstIter &nonConstIterator)
|
||||
{
|
||||
m_ptr = nonConstIterator.m_ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
T* m_ptr;
|
||||
}; // class const iterator
|
||||
|
||||
|
||||
public:
|
||||
explicit vector(size_t n = 0)
|
||||
{
|
||||
m_size = 0;
|
||||
m_capacity = 0;
|
||||
m_pelements = NULL;
|
||||
m_isBufferOwner = true;
|
||||
resize(n);
|
||||
}
|
||||
|
||||
~vector()
|
||||
{
|
||||
if (m_isBufferOwner)
|
||||
{
|
||||
erase(m_pelements, 0, m_size);
|
||||
delete [] (BYTE*)m_pelements; // cast to BYTE* as we don't want this delete to invoke T's dtor
|
||||
}
|
||||
else
|
||||
{
|
||||
m_size = 0;
|
||||
m_capacity = 0;
|
||||
}
|
||||
}
|
||||
|
||||
vector(const vector<T>&) = delete;
|
||||
vector<T>& operator=(const vector<T>&) = delete;
|
||||
|
||||
vector(vector<T>&& v) noexcept
|
||||
: m_size(v.m_size)
|
||||
, m_capacity(v.m_capacity)
|
||||
, m_pelements(v.m_pelements)
|
||||
, m_isBufferOwner(v.m_isBufferOwner)
|
||||
{
|
||||
v.m_isBufferOwner = false;
|
||||
}
|
||||
|
||||
vector<T>& operator=(vector<T>&& v) noexcept
|
||||
{
|
||||
if (m_isBufferOwner)
|
||||
{
|
||||
erase(m_pelements, 0, m_size);
|
||||
delete [] (BYTE*)m_pelements;
|
||||
}
|
||||
|
||||
m_size = v.m_size;
|
||||
m_capacity = v.m_capacity;
|
||||
m_pelements = v.m_pelements;
|
||||
m_isBufferOwner = v.m_isBufferOwner;
|
||||
v.m_isBufferOwner = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_t size() const
|
||||
{
|
||||
return m_size;
|
||||
}
|
||||
|
||||
T & operator[](size_t iIndex)
|
||||
{
|
||||
assert(iIndex < m_size);
|
||||
return m_pelements[iIndex];
|
||||
}
|
||||
|
||||
T & operator[](size_t iIndex) const
|
||||
{
|
||||
assert(iIndex < m_size);
|
||||
return m_pelements[iIndex];
|
||||
}
|
||||
|
||||
void resize(size_t newsize)
|
||||
{
|
||||
assert(m_isBufferOwner);
|
||||
size_t oldsize = this->size();
|
||||
resize_noinit(newsize);
|
||||
if (newsize > oldsize)
|
||||
{
|
||||
fill_uninitialized_with_default_value(m_pelements, oldsize, newsize);
|
||||
}
|
||||
}
|
||||
|
||||
void clear()
|
||||
{
|
||||
assert(m_isBufferOwner);
|
||||
resize(0);
|
||||
}
|
||||
|
||||
void resize(size_t newsize, T c)
|
||||
{
|
||||
assert(m_isBufferOwner);
|
||||
size_t oldsize = this->size();
|
||||
resize_noinit(newsize);
|
||||
if (newsize > oldsize)
|
||||
{
|
||||
for (size_t i = oldsize; i < newsize; i++)
|
||||
{
|
||||
m_pelements[i] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wrap(size_t numElements, T* pElements)
|
||||
{
|
||||
m_size = numElements;
|
||||
m_pelements = pElements;
|
||||
m_isBufferOwner = false;
|
||||
}
|
||||
|
||||
void resize_noinit(size_t newsize)
|
||||
{
|
||||
assert(m_isBufferOwner);
|
||||
size_t oldsize = this->size();
|
||||
if (newsize < oldsize)
|
||||
{
|
||||
// Shrink
|
||||
erase(m_pelements, newsize, oldsize);
|
||||
}
|
||||
else if (newsize > oldsize)
|
||||
{
|
||||
// Grow
|
||||
reserve(newsize);
|
||||
}
|
||||
m_size = newsize;
|
||||
}
|
||||
|
||||
void push_back(const T & val)
|
||||
{
|
||||
assert(m_isBufferOwner);
|
||||
if (m_size + 1 < m_size)
|
||||
{
|
||||
assert("push_back: overflow");
|
||||
// @todo: how to throw.
|
||||
}
|
||||
resize(m_size + 1, val);
|
||||
}
|
||||
|
||||
void reserve(size_t newcapacity)
|
||||
{
|
||||
assert(m_isBufferOwner);
|
||||
if (newcapacity > m_capacity)
|
||||
{
|
||||
// To avoid resizing for every element that gets added to a vector, we
|
||||
// allocate at least twice the old capacity, or 16 elements, whichever is greater.
|
||||
newcapacity = max(newcapacity, max(m_capacity * 2, 16));
|
||||
|
||||
size_t bytesNeeded = newcapacity * sizeof(T);
|
||||
if (bytesNeeded / sizeof(T) != newcapacity)
|
||||
{
|
||||
assert("resize: overflow");
|
||||
// @todo: how to throw something here?
|
||||
}
|
||||
|
||||
|
||||
T *pelements = (T*)(new BYTE[bytesNeeded]); // Allocate as BYTE array to avoid automatic construction
|
||||
INDEBUG(memset(pelements, 0xcc, bytesNeeded));
|
||||
for (size_t i = 0; i < m_size; i++)
|
||||
{
|
||||
pelements[i] = m_pelements[i];
|
||||
}
|
||||
|
||||
erase(m_pelements, 0, m_size);
|
||||
delete [] (BYTE*)m_pelements; // cast to BYTE* as we don't want this delete to invoke T's dtor
|
||||
|
||||
m_pelements = pelements;
|
||||
m_capacity = newcapacity;
|
||||
}
|
||||
}
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
return iterator(m_pelements);
|
||||
}
|
||||
|
||||
iterator end()
|
||||
{
|
||||
return iterator(m_pelements + m_size);
|
||||
}
|
||||
|
||||
const_iterator cbegin() const
|
||||
{
|
||||
return const_iterator(m_pelements);
|
||||
}
|
||||
|
||||
const_iterator cend() const
|
||||
{
|
||||
return const_iterator(m_pelements + m_size);
|
||||
}
|
||||
|
||||
iterator erase(iterator position)
|
||||
{
|
||||
assert(m_isBufferOwner);
|
||||
assert((position > begin() || position == begin()) && position < end());
|
||||
ptrdiff_t index = position - begin();
|
||||
erase(m_pelements, index, index + 1);
|
||||
memcpy(&m_pelements[index], &m_pelements[index + 1], sizeof(T) * (m_size - index - 1));
|
||||
--m_size;
|
||||
return iterator(m_pelements + (position - begin()));
|
||||
}
|
||||
|
||||
iterator erase(iterator position, iterator positionEnd)
|
||||
{
|
||||
assert(m_isBufferOwner);
|
||||
assert((position > begin() || position == begin()) && position < end());
|
||||
ptrdiff_t index = position - begin();
|
||||
ptrdiff_t elements = positionEnd - position;
|
||||
erase(m_pelements, index, index + elements);
|
||||
memcpy(&m_pelements[index], &m_pelements[index + elements], sizeof(T) * (m_size - index - elements));
|
||||
m_size -= elements;
|
||||
return iterator(m_pelements + (position - begin()));
|
||||
}
|
||||
|
||||
T* data()
|
||||
{
|
||||
return m_pelements;
|
||||
}
|
||||
|
||||
const T* data() const
|
||||
{
|
||||
return m_pelements;
|
||||
}
|
||||
|
||||
private:
|
||||
// Transition a subset of the array from uninitialized to initialized with default value for T.
|
||||
static void fill_uninitialized_with_default_value(T* pelements, size_t startIdx, size_t endIdx)
|
||||
{
|
||||
assert(startIdx <= endIdx);
|
||||
assert(pelements != NULL || startIdx == endIdx);
|
||||
for (size_t i = startIdx; i < endIdx; i++)
|
||||
{
|
||||
INDEBUG(assert(0xcc == *((BYTE*)&pelements[i])));
|
||||
pelements[i] = T();
|
||||
}
|
||||
}
|
||||
|
||||
// Transition a subset of the array from a valid value of T to uninitialized.
|
||||
static void erase(T* pelements, size_t startIdx, size_t endIdx)
|
||||
{
|
||||
assert(startIdx <= endIdx);
|
||||
assert(pelements != NULL || startIdx == endIdx);
|
||||
for (size_t i = startIdx; i < endIdx; i++)
|
||||
{
|
||||
pelements[i].~T();
|
||||
}
|
||||
|
||||
INDEBUG(memset(&pelements[startIdx], 0xcc, (endIdx - startIdx) * sizeof(T)));
|
||||
}
|
||||
|
||||
private:
|
||||
size_t m_size; //# of elements
|
||||
size_t m_capacity; //# of elements allocated
|
||||
T *m_pelements; //actual array
|
||||
// invariants:
|
||||
// dimensions == m_capacity
|
||||
// elements 0 thru m_size-1 always contain constructed T values.
|
||||
// elements from m_size thru m_capacity - 1 contain memory garbage (0xcc in DEBUG).
|
||||
bool m_isBufferOwner; // indicate if this vector creates its own buffer, or wraps an existing buffer.
|
||||
|
||||
|
||||
|
||||
|
||||
}; // class vector
|
||||
|
||||
}; // namespace std
|
||||
|
||||
#endif /* __clr_std_vector_h__ */
|
||||
|
||||
#endif // !USE_STL
|
||||
|
||||
// Help the VIM editor figure out what kind of file this no-extension file is.
|
||||
// vim: filetype=cpp
|
|
@ -232,7 +232,6 @@
|
|||
|
||||
#include "specstrings.h"
|
||||
#include "clrtypes.h"
|
||||
#include "malloc.h"
|
||||
#include "check.h"
|
||||
#include "debugreturn.h"
|
||||
#include "staticcontract.h"
|
||||
|
|
|
@ -352,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 (ARRAY_SIZE(m_rgTakenLockInfos), cCombinedLocks + cTakes);
|
||||
i < std::min (ARRAY_SIZE(m_rgTakenLockInfos), (size_t)(cCombinedLocks + cTakes));
|
||||
i++)
|
||||
{
|
||||
m_rgTakenLockInfos[i].m_pvLock = pvLock;
|
||||
|
@ -377,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 (ARRAY_SIZE(m_rgTakenLockInfos), cCombinedLocks);
|
||||
i < std::min (ARRAY_SIZE(m_rgTakenLockInfos), (size_t)cCombinedLocks);
|
||||
i++)
|
||||
{
|
||||
if (m_rgTakenLockInfos[i].m_pvLock != pvLock)
|
||||
|
@ -443,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(ARRAY_SIZE(m_pLockData->m_rgTakenLockInfos), m_cLocksEnteringCannotRetakeLock);
|
||||
i < std::min(ARRAY_SIZE(m_pLockData->m_rgTakenLockInfos), (size_t)m_cLocksEnteringCannotRetakeLock);
|
||||
++i)
|
||||
{
|
||||
if (m_pLockData->m_rgTakenLockInfos[i].m_pvLock == pvLock)
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
#define __CrtWrap_h__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <windows.h>
|
||||
#include <objbase.h>
|
||||
#include "debugmacros.h"
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -561,6 +561,10 @@
|
|||
#ifndef NATIVEAOT
|
||||
#include <stdint.h>
|
||||
|
||||
#if !defined(HOST_WINDOWS)
|
||||
#include <pal_mstypes.h>
|
||||
#endif
|
||||
|
||||
#include "switches.h"
|
||||
#include "safemath.h"
|
||||
#include "corerror.h"
|
||||
|
@ -568,12 +572,8 @@
|
|||
// Keep in sync with the definitions in dbgutil.cpp and createdump.h
|
||||
#define DACCESS_TABLE_SYMBOL "g_dacTable"
|
||||
|
||||
#ifdef PAL_STDCPP_COMPAT
|
||||
#include <type_traits>
|
||||
#else
|
||||
#include "clr_std/type_traits"
|
||||
#include "crosscomp.h"
|
||||
#endif
|
||||
|
||||
#include <dn-u16.h>
|
||||
|
||||
|
|
|
@ -467,7 +467,7 @@ struct MSLAYOUT DacpAssemblyData
|
|||
|
||||
HRESULT Request(ISOSDacInterface *sos, CLRDATA_ADDRESS addr)
|
||||
{
|
||||
return Request(sos, addr, NULL);
|
||||
return Request(sos, addr, 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -577,7 +577,7 @@ struct MSLAYOUT DacpMethodDescData
|
|||
{
|
||||
return sos->GetMethodDescData(
|
||||
addr,
|
||||
NULL, // IP address
|
||||
0, // IP address
|
||||
this,
|
||||
0, // cRejitData
|
||||
NULL, // rejitData[]
|
||||
|
|
|
@ -11,13 +11,8 @@
|
|||
#include "volatile.h"
|
||||
#include "palclr.h"
|
||||
|
||||
#ifdef PAL_STDCPP_COMPAT
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#else
|
||||
#include "clr_std/utility"
|
||||
#include "clr_std/type_traits"
|
||||
#endif
|
||||
|
||||
#if defined(FEATURE_COMINTEROP) && !defined(STRIKE)
|
||||
#include <Activation.h>
|
||||
|
|
|
@ -158,7 +158,7 @@ struct LoaderHeapEvent;
|
|||
inline UINT32 GetStubCodePageSize()
|
||||
{
|
||||
#if defined(TARGET_ARM64) && defined(TARGET_UNIX)
|
||||
return max(16*1024, GetOsPageSize());
|
||||
return max(16*1024u, GetOsPageSize());
|
||||
#elif defined(TARGET_ARM)
|
||||
return 4096; // ARM is special as the 32bit instruction set does not easily permit a 16KB offset
|
||||
#else
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
// Forbid the use of srand()/rand(), as these are globally shared facilities and our use of them would
|
||||
// interfere with native user code in the same process. This override is not compatible with stl headers.
|
||||
//
|
||||
#if !defined(DO_NOT_DISABLE_RAND) && !defined(USE_STL)
|
||||
#if !defined(DO_NOT_DISABLE_RAND)
|
||||
|
||||
#ifdef srand
|
||||
#undef srand
|
||||
|
@ -36,7 +36,7 @@
|
|||
#endif
|
||||
#define rand Do_not_use_rand
|
||||
|
||||
#endif //!DO_NOT_DISABLE_RAND && !USE_STL
|
||||
#endif //!DO_NOT_DISABLE_RAND
|
||||
|
||||
|
||||
class CLRRandom
|
||||
|
|
|
@ -31,11 +31,11 @@
|
|||
|
||||
#include "static_assert.h"
|
||||
|
||||
#ifdef PAL_STDCPP_COMPAT
|
||||
#include <type_traits>
|
||||
#else
|
||||
#include "clr_std/type_traits"
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_PAL
|
||||
#include "pal_mstypes.h"
|
||||
#endif // FEATURE_PAL
|
||||
|
||||
//==================================================================
|
||||
// Semantics: if val can be represented as the exact same value
|
||||
|
|
|
@ -10,14 +10,16 @@
|
|||
#ifndef __UtilCode_h__
|
||||
#define __UtilCode_h__
|
||||
|
||||
#include <type_traits>
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "crtwrap.h"
|
||||
#include "winwrap.h"
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <ole2.h>
|
||||
#include <oleauto.h>
|
||||
#include <limits.h>
|
||||
#include "clrtypes.h"
|
||||
#include "safewrap.h"
|
||||
#include "volatile.h"
|
||||
|
@ -29,12 +31,6 @@
|
|||
#include "safemath.h"
|
||||
#include "new.hpp"
|
||||
|
||||
#ifdef PAL_STDCPP_COMPAT
|
||||
#include <type_traits>
|
||||
#else
|
||||
#include "clr_std/type_traits"
|
||||
#endif
|
||||
|
||||
#include "contract.h"
|
||||
|
||||
#include <minipal/utils.h>
|
||||
|
@ -224,7 +220,7 @@ typedef LPSTR LPUTF8;
|
|||
#define MAKE_UTF8PTR_FROMWIDE_NOTHROW(ptrname, widestr) \
|
||||
CQuickBytes __qb##ptrname; \
|
||||
int __l##ptrname = (int)u16_strlen(widestr); \
|
||||
LPUTF8 ptrname = 0; \
|
||||
LPUTF8 ptrname = NULL; \
|
||||
if (__l##ptrname <= MAKE_MAX_LENGTH) { \
|
||||
__l##ptrname = (int)((__l##ptrname + 1) * 2 * sizeof(char)); \
|
||||
ptrname = (LPUTF8) __qb##ptrname.AllocNoThrow(__l##ptrname); \
|
||||
|
@ -240,12 +236,12 @@ typedef LPSTR LPUTF8;
|
|||
if (WszWideCharToMultiByte(CP_UTF8, 0, widestr, -1, ptrname, __lsize##ptrname, NULL, NULL) != 0) { \
|
||||
ptrname[__l##ptrname] = 0; \
|
||||
} else { \
|
||||
ptrname = 0; \
|
||||
ptrname = NULL; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
else { \
|
||||
ptrname = 0; \
|
||||
ptrname = NULL; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
|
@ -255,7 +251,7 @@ typedef LPSTR LPUTF8;
|
|||
#define MAKE_WIDEPTR_FROMUTF8N_NOTHROW(ptrname, utf8str, n8chrs) \
|
||||
CQuickBytes __qb##ptrname; \
|
||||
int __l##ptrname; \
|
||||
LPWSTR ptrname = 0; \
|
||||
LPWSTR ptrname = NULL; \
|
||||
__l##ptrname = WszMultiByteToWideChar(CP_UTF8, 0, utf8str, n8chrs, 0, 0); \
|
||||
if (__l##ptrname <= MAKE_MAX_LENGTH) { \
|
||||
ptrname = (LPWSTR) __qb##ptrname.AllocNoThrow((__l##ptrname+1)*sizeof(WCHAR)); \
|
||||
|
@ -263,7 +259,7 @@ typedef LPSTR LPUTF8;
|
|||
if (WszMultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, utf8str, n8chrs, ptrname, __l##ptrname) != 0) { \
|
||||
ptrname[__l##ptrname] = 0; \
|
||||
} else { \
|
||||
ptrname = 0; \
|
||||
ptrname = NULL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
@ -302,28 +298,6 @@ inline WCHAR* FormatInteger(WCHAR* str, size_t strCount, const char* fmt, I v)
|
|||
return str;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
// Placement new is used to new and object at an exact location. The pointer
|
||||
// is simply returned to the caller without actually using the heap. The
|
||||
// advantage here is that you cause the ctor() code for the object to be run.
|
||||
// This is ideal for heaps of C++ objects that need to get init'd multiple times.
|
||||
// Example:
|
||||
// void *pMem = GetMemFromSomePlace();
|
||||
// Foo *p = new (pMem) Foo;
|
||||
// DoSomething(p);
|
||||
// p->~Foo();
|
||||
//*****************************************************************************
|
||||
#ifndef __PLACEMENT_NEW_INLINE
|
||||
#define __PLACEMENT_NEW_INLINE
|
||||
inline void *__cdecl operator new(size_t, void *_P)
|
||||
{
|
||||
LIMITED_METHOD_DAC_CONTRACT;
|
||||
|
||||
return (_P);
|
||||
}
|
||||
#endif // __PLACEMENT_NEW_INLINE
|
||||
|
||||
|
||||
/********************************************************************************/
|
||||
/* portability helpers */
|
||||
|
||||
|
@ -1920,7 +1894,7 @@ public:
|
|||
~CHashTableAndData()
|
||||
{
|
||||
WRAPPER_NO_CONTRACT;
|
||||
if (m_pcEntries != NULL)
|
||||
if (m_pcEntries != (TADDR)NULL)
|
||||
MemMgr::Free((BYTE*)m_pcEntries, MemMgr::RoundSize(m_iEntries * m_iEntrySize));
|
||||
}
|
||||
|
||||
|
@ -2100,7 +2074,7 @@ int CHashTableAndData<MemMgr>::Grow() // 1 if successful, 0 if not.
|
|||
int iCurSize; // Current size in bytes.
|
||||
int iEntries; // New # of entries.
|
||||
|
||||
_ASSERTE(m_pcEntries != NULL);
|
||||
_ASSERTE(m_pcEntries != (TADDR)NULL);
|
||||
_ASSERTE(m_iFree == UINT32_MAX);
|
||||
|
||||
// Compute the current size and new # of entries.
|
||||
|
@ -3934,37 +3908,6 @@ inline T* InterlockedCompareExchangeT(
|
|||
return InterlockedCompareExchangeT(destination, exchange, static_cast<T*>(comparand));
|
||||
}
|
||||
|
||||
// NULL pointer variants of the above to avoid having to cast NULL
|
||||
// to the appropriate pointer type.
|
||||
template <typename T>
|
||||
inline T* InterlockedExchangeT(
|
||||
T* volatile * target,
|
||||
int value) // When NULL is provided as argument.
|
||||
{
|
||||
//STATIC_ASSERT(value == 0);
|
||||
return InterlockedExchangeT(target, nullptr);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T* InterlockedCompareExchangeT(
|
||||
T* volatile * destination,
|
||||
int exchange, // When NULL is provided as argument.
|
||||
T* comparand)
|
||||
{
|
||||
//STATIC_ASSERT(exchange == 0);
|
||||
return InterlockedCompareExchangeT(destination, nullptr, comparand);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T* InterlockedCompareExchangeT(
|
||||
T* volatile * destination,
|
||||
T* exchange,
|
||||
int comparand) // When NULL is provided as argument.
|
||||
{
|
||||
//STATIC_ASSERT(comparand == 0);
|
||||
return InterlockedCompareExchangeT(destination, exchange, nullptr);
|
||||
}
|
||||
|
||||
#undef InterlockedExchangePointer
|
||||
#define InterlockedExchangePointer Use_InterlockedExchangeT
|
||||
#undef InterlockedCompareExchangePointer
|
||||
|
|
|
@ -156,7 +156,11 @@ void* ArenaAllocator::allocateHostMemory(size_t size, size_t* pActualSize)
|
|||
if (bypassHostAllocator())
|
||||
{
|
||||
*pActualSize = size;
|
||||
void* p = malloc(size);
|
||||
if (size == 0)
|
||||
{
|
||||
size = 1;
|
||||
}
|
||||
void* p = malloc(size);
|
||||
if (p == nullptr)
|
||||
{
|
||||
NOMEM();
|
||||
|
|
|
@ -673,7 +673,7 @@ void Compiler::optAssertionInit(bool isLocalProp)
|
|||
// Local assertion prop keeps mappings from each local var to the assertions about that var.
|
||||
//
|
||||
optAssertionDep =
|
||||
new (this, CMK_AssertionProp) JitExpandArray<ASSERT_TP>(getAllocator(CMK_AssertionProp), max(1, lvaCount));
|
||||
new (this, CMK_AssertionProp) JitExpandArray<ASSERT_TP>(getAllocator(CMK_AssertionProp), max(1u, lvaCount));
|
||||
|
||||
if (optCrossBlockLocalAssertionProp)
|
||||
{
|
||||
|
|
|
@ -432,7 +432,7 @@ void CodeGen::genStackPointerAdjustment(ssize_t spDelta, regNumber tmpReg, bool*
|
|||
{
|
||||
// spDelta is negative in the prolog, positive in the epilog, but we always tell the unwind codes the positive
|
||||
// value.
|
||||
ssize_t spDeltaAbs = abs(spDelta);
|
||||
ssize_t spDeltaAbs = std::abs(spDelta);
|
||||
unsigned unwindSpDelta = (unsigned)spDeltaAbs;
|
||||
assert((ssize_t)unwindSpDelta == spDeltaAbs); // make sure that it fits in a unsigned
|
||||
|
||||
|
|
|
@ -2815,6 +2815,12 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|||
* assigned location, in the function prolog.
|
||||
*/
|
||||
|
||||
// std::max isn't constexpr until C++14 and we're still on C++11
|
||||
constexpr size_t const_max(size_t a, size_t b)
|
||||
{
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
#ifdef _PREFAST_
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 21000) // Suppress PREFast warning about overly large function
|
||||
|
@ -2908,7 +2914,7 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere
|
|||
bool circular; // true if this register participates in a circular dependency loop.
|
||||
bool hfaConflict; // arg is part of an HFA that will end up in the same register
|
||||
// but in a different slot (eg arg in s3 = v3.s[0], needs to end up in v3.s[3])
|
||||
} regArgTab[max(MAX_REG_ARG + 1, MAX_FLOAT_REG_ARG)] = {};
|
||||
} regArgTab[const_max(MAX_REG_ARG + 1, MAX_FLOAT_REG_ARG)] = {};
|
||||
|
||||
unsigned varNum;
|
||||
LclVarDsc* varDsc;
|
||||
|
|
|
@ -5659,7 +5659,7 @@ void Compiler::SplitTreesRandomly()
|
|||
rng.Init(info.compMethodHash() ^ 0x077cc4d4);
|
||||
|
||||
// Splitting creates a lot of new locals. Set a limit on how many we end up creating here.
|
||||
unsigned maxLvaCount = max(lvaCount * 2, 50000);
|
||||
unsigned maxLvaCount = max(lvaCount * 2, 50000u);
|
||||
|
||||
for (BasicBlock* block : Blocks())
|
||||
{
|
||||
|
@ -5721,7 +5721,7 @@ void Compiler::SplitTreesRandomly()
|
|||
void Compiler::SplitTreesRemoveCommas()
|
||||
{
|
||||
// Splitting creates a lot of new locals. Set a limit on how many we end up creating here.
|
||||
unsigned maxLvaCount = max(lvaCount * 2, 50000);
|
||||
unsigned maxLvaCount = max(lvaCount * 2, 50000u);
|
||||
|
||||
for (BasicBlock* block : Blocks())
|
||||
{
|
||||
|
@ -7532,7 +7532,7 @@ void Compiler::compInitVarScopeMap()
|
|||
compVarScopeMap = new (getAllocator()) VarNumToScopeDscMap(getAllocator());
|
||||
|
||||
// 599 prime to limit huge allocations; for ex: duplicated scopes on single var.
|
||||
compVarScopeMap->Reallocate(min(info.compVarScopesCount, 599));
|
||||
compVarScopeMap->Reallocate(min(info.compVarScopesCount, 599u));
|
||||
|
||||
for (unsigned i = 0; i < info.compVarScopesCount; ++i)
|
||||
{
|
||||
|
|
|
@ -350,7 +350,7 @@ class SsaDefArray
|
|||
void GrowArray(CompAllocator alloc)
|
||||
{
|
||||
unsigned oldSize = m_arraySize;
|
||||
unsigned newSize = max(2, oldSize * 2);
|
||||
unsigned newSize = max(2u, oldSize * 2);
|
||||
|
||||
T* newArray = alloc.allocate<T>(newSize);
|
||||
|
||||
|
|
|
@ -2600,7 +2600,8 @@ inline
|
|||
#else
|
||||
int outGoingArgSpaceSize = 0;
|
||||
#endif
|
||||
varOffset = outGoingArgSpaceSize + max(-varNum * TARGET_POINTER_SIZE, (int)lvaGetMaxSpillTempSize());
|
||||
varOffset =
|
||||
outGoingArgSpaceSize + max(-varNum * (int)TARGET_POINTER_SIZE, (int)lvaGetMaxSpillTempSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -6243,10 +6243,10 @@ void emitter::emitLoopAlignAdjustments()
|
|||
{
|
||||
|
||||
#if defined(TARGET_XARCH)
|
||||
unsigned newPadding = min(paddingToAdj, MAX_ENCODED_SIZE);
|
||||
unsigned newPadding = min(paddingToAdj, (unsigned)MAX_ENCODED_SIZE);
|
||||
alignInstrToAdj->idCodeSize(newPadding);
|
||||
#elif defined(TARGET_ARM64)
|
||||
unsigned newPadding = min(paddingToAdj, INSTR_ENCODED_SIZE);
|
||||
unsigned newPadding = min(paddingToAdj, (unsigned)INSTR_ENCODED_SIZE);
|
||||
if (newPadding == 0)
|
||||
{
|
||||
alignInstrToAdj->idInsOpt(INS_OPTS_NONE);
|
||||
|
|
|
@ -6504,7 +6504,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
|
|||
code |= (immHi << 16);
|
||||
code |= immLo;
|
||||
|
||||
disp = abs(disp);
|
||||
disp = std::abs(disp);
|
||||
assert((disp & 0x00fffffe) == disp);
|
||||
|
||||
callInstrSize = SafeCvtAssert<unsigned char>(emitOutput_Thumb2Instr(dst, code));
|
||||
|
|
|
@ -8964,7 +8964,7 @@ void emitter::emitIns_Call(EmitCallType callType,
|
|||
|
||||
// Our stack level should be always greater than the bytes of arguments we push. Just
|
||||
// a sanity test.
|
||||
assert((unsigned)abs(argSize) <= codeGen->genStackLevel);
|
||||
assert((unsigned)std::abs(argSize) <= codeGen->genStackLevel);
|
||||
|
||||
// Trim out any callee-trashed registers from the live set.
|
||||
regMaskTP savedSet = emitGetGCRegsSavedOrModified(methHnd);
|
||||
|
|
|
@ -2467,7 +2467,7 @@ bool Compiler::fgOptimizeUncondBranchToSimpleCond(BasicBlock* block, BasicBlock*
|
|||
//
|
||||
weight_t targetWeight = target->bbWeight;
|
||||
weight_t blockWeight = block->bbWeight;
|
||||
target->setBBProfileWeight(max(0, targetWeight - blockWeight));
|
||||
target->setBBProfileWeight(max(0.0, targetWeight - blockWeight));
|
||||
JITDUMP("Decreased " FMT_BB " profile weight from " FMT_WT " to " FMT_WT "\n", target->bbNum, targetWeight,
|
||||
target->bbWeight);
|
||||
}
|
||||
|
@ -3047,7 +3047,7 @@ bool Compiler::fgOptimizeSwitchJumps()
|
|||
blockToTargetEdge->setEdgeWeights(blockToTargetWeight, blockToTargetWeight, dominantTarget);
|
||||
blockToTargetEdge->setLikelihood(fraction);
|
||||
blockToNewBlockEdge->setEdgeWeights(blockToNewBlockWeight, blockToNewBlockWeight, block);
|
||||
blockToNewBlockEdge->setLikelihood(max(0, 1.0 - fraction));
|
||||
blockToNewBlockEdge->setLikelihood(max(0.0, 1.0 - fraction));
|
||||
|
||||
// There may be other switch cases that lead to this same block, but there's just
|
||||
// one edge in the flowgraph. So we need to subtract off the profile data that now flows
|
||||
|
|
|
@ -1353,7 +1353,7 @@ void ProfileSynthesis::GaussSeidelSolver()
|
|||
for (unsigned j = m_dfsTree->GetPostOrderCount(); j != 0; j--)
|
||||
{
|
||||
BasicBlock* const block = dfs->GetPostOrder(j - 1);
|
||||
block->setBBProfileWeight(max(0, countVector[block->bbNum]));
|
||||
block->setBBProfileWeight(max(0.0, countVector[block->bbNum]));
|
||||
}
|
||||
|
||||
m_approximate = !converged || (m_cappedCyclicProbabilities > 0);
|
||||
|
|
|
@ -5745,7 +5745,7 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
|
|||
{
|
||||
// Store to an enregistered local.
|
||||
costEx = op1->GetCostEx();
|
||||
costSz = max(3, op1->GetCostSz()); // 3 is an estimate for a reg-reg move.
|
||||
costSz = max(3, (int)op1->GetCostSz()); // 3 is an estimate for a reg-reg move.
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
|
@ -26906,7 +26906,7 @@ void ReturnTypeDesc::InitializeStructReturnType(Compiler* comp,
|
|||
assert(varTypeIsValidHfaType(hfaType));
|
||||
|
||||
// Note that the retail build issues a warning about a potential divsion by zero without this "max",
|
||||
unsigned elemSize = max(1, genTypeSize(hfaType));
|
||||
unsigned elemSize = max(1u, genTypeSize(hfaType));
|
||||
|
||||
// The size of this struct should be evenly divisible by elemSize
|
||||
assert((structSize % elemSize) == 0);
|
||||
|
|
|
@ -824,7 +824,7 @@ void hashBv::setAll(indexType numToSet)
|
|||
for (unsigned int i = 0; i < numToSet; i += BITS_PER_NODE)
|
||||
{
|
||||
hashBvNode* node = getOrAddNodeForIndex(i);
|
||||
indexType bits_to_set = min(BITS_PER_NODE, numToSet - i);
|
||||
indexType bits_to_set = min((indexType)BITS_PER_NODE, numToSet - i);
|
||||
node->setLowest(bits_to_set);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1049,7 +1049,7 @@ public:
|
|||
enum
|
||||
{
|
||||
ALWAYS_INLINE_SIZE = 16,
|
||||
IMPLEMENTATION_MAX_INLINE_SIZE = _UI16_MAX,
|
||||
IMPLEMENTATION_MAX_INLINE_SIZE = UINT16_MAX,
|
||||
IMPLEMENTATION_MAX_INLINE_DEPTH = 1000
|
||||
};
|
||||
|
||||
|
|
|
@ -702,19 +702,19 @@ inline unsigned int roundUp(unsigned size, unsigned mult)
|
|||
|
||||
inline unsigned int unsigned_abs(int x)
|
||||
{
|
||||
return ((unsigned int)abs(x));
|
||||
return ((unsigned int)std::abs(x));
|
||||
}
|
||||
|
||||
#ifdef TARGET_64BIT
|
||||
inline size_t unsigned_abs(ssize_t x)
|
||||
{
|
||||
return ((size_t)abs((__int64)x));
|
||||
return ((size_t)std::abs((__int64)x));
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
inline size_t unsigned_abs(__int64 x)
|
||||
{
|
||||
return ((size_t)abs(x));
|
||||
return ((size_t)std::abs(x));
|
||||
}
|
||||
#endif // __APPLE__
|
||||
#endif // TARGET_64BIT
|
||||
|
|
|
@ -1554,7 +1554,7 @@ EHblkDsc* Compiler::fgAddEHTableEntry(unsigned XTnum)
|
|||
// Double the table size. For stress, we could use +1. Note that if the table isn't allocated
|
||||
// yet, such as when we add an EH region for synchronized methods that don't already have one,
|
||||
// we start at zero, so we need to make sure the new table has at least one entry.
|
||||
unsigned newHndBBtabAllocCount = max(1, compHndBBtabAllocCount * 2);
|
||||
unsigned newHndBBtabAllocCount = max(1u, compHndBBtabAllocCount * 2);
|
||||
noway_assert(compHndBBtabAllocCount < newHndBBtabAllocCount); // check for overflow
|
||||
|
||||
if (newHndBBtabAllocCount > MAX_XCPTN_INDEX)
|
||||
|
|
|
@ -11,7 +11,15 @@
|
|||
#include <string.h>
|
||||
#include <float.h>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <intrin.h>
|
||||
#ifdef HOST_WINDOWS
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <algorithm>
|
||||
|
||||
using std::max;
|
||||
using std::min;
|
||||
|
||||
// Don't allow using the windows.h #defines for the BitScan* APIs. Using the #defines means our
|
||||
// `BitOperations::BitScan*` functions have their name mapped, which is confusing and messes up
|
||||
|
|
|
@ -14,7 +14,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|||
|
||||
#include "iterator.h"
|
||||
#include "functional.h"
|
||||
#include "clr_std/utility"
|
||||
#include <utility>
|
||||
|
||||
namespace jitstd
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "clr_std/type_traits"
|
||||
#include <type_traits>
|
||||
|
||||
namespace jitstd
|
||||
{
|
||||
|
|
|
@ -622,7 +622,7 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo, unsigned skipArgs, un
|
|||
const unsigned argSigLen = info.compMethodInfo->args.numArgs;
|
||||
|
||||
// We will process at most takeArgs arguments from the signature after skipping skipArgs arguments
|
||||
const int64_t numUserArgs = min(takeArgs, (argSigLen - (int64_t)skipArgs));
|
||||
const int64_t numUserArgs = min((int64_t)takeArgs, (argSigLen - (int64_t)skipArgs));
|
||||
|
||||
// If there are no user args or less than skipArgs args, return here since there's no work to do.
|
||||
if (numUserArgs <= 0)
|
||||
|
@ -2000,7 +2000,7 @@ bool Compiler::StructPromotionHelper::CanPromoteStructType(CORINFO_CLASS_HANDLE
|
|||
#if defined(FEATURE_SIMD)
|
||||
// getMaxVectorByteLength() represents the size of the largest primitive type that we can struct promote.
|
||||
const unsigned maxSize =
|
||||
MAX_NumOfFieldsInPromotableStruct * max(compiler->getMaxVectorByteLength(), sizeof(double));
|
||||
MAX_NumOfFieldsInPromotableStruct * max(compiler->getMaxVectorByteLength(), (uint32_t)sizeof(double));
|
||||
#else // !FEATURE_SIMD
|
||||
// sizeof(double) represents the size of the largest primitive type that we can struct promote.
|
||||
const unsigned maxSize = MAX_NumOfFieldsInPromotableStruct * sizeof(double);
|
||||
|
|
|
@ -2073,7 +2073,7 @@ void Compiler::optCloneLoop(FlowGraphNaturalLoop* loop, LoopCloneContext* contex
|
|||
FlowEdge* const falseEdge = fgAddRefPred(fastPreheader, condLast);
|
||||
condLast->SetFalseEdge(falseEdge);
|
||||
FlowEdge* const trueEdge = condLast->GetTrueEdge();
|
||||
falseEdge->setLikelihood(max(0, 1.0 - trueEdge->getLikelihood()));
|
||||
falseEdge->setLikelihood(max(0.0, 1.0 - trueEdge->getLikelihood()));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
|
|
@ -7153,7 +7153,7 @@ bool Lowering::TryLowerConstIntDivOrMod(GenTree* node, GenTree** nextNode)
|
|||
}
|
||||
|
||||
size_t absDivisorValue =
|
||||
(divisorValue == SSIZE_T_MIN) ? static_cast<size_t>(divisorValue) : static_cast<size_t>(abs(divisorValue));
|
||||
(divisorValue == SSIZE_T_MIN) ? static_cast<size_t>(divisorValue) : static_cast<size_t>(std::abs(divisorValue));
|
||||
|
||||
if (!isPow2(absDivisorValue))
|
||||
{
|
||||
|
@ -8950,7 +8950,7 @@ bool Lowering::OptimizeForLdp(GenTreeIndir* ind)
|
|||
|
||||
JITDUMP("[%06u] and [%06u] are indirs off the same base with offsets +%03u and +%03u\n",
|
||||
Compiler::dspTreeID(ind), Compiler::dspTreeID(prevIndir), (unsigned)offs, (unsigned)prev.Offset);
|
||||
if (abs(offs - prev.Offset) == genTypeSize(ind))
|
||||
if (std::abs(offs - prev.Offset) == genTypeSize(ind))
|
||||
{
|
||||
JITDUMP(" ..and they are amenable to ldp optimization\n");
|
||||
if (TryMakeIndirsAdjacent(prevIndir, ind))
|
||||
|
|
|
@ -2934,7 +2934,7 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
|
|||
#ifdef WINDOWS_AMD64_ABI
|
||||
// Whenever we pass an integer register argument
|
||||
// we skip the corresponding floating point register argument
|
||||
intArgRegNum = min(intArgRegNum + size, MAX_REG_ARG);
|
||||
intArgRegNum = min(intArgRegNum + size, (unsigned)MAX_REG_ARG);
|
||||
#endif // WINDOWS_AMD64_ABI
|
||||
// No supported architecture supports partial structs using float registers.
|
||||
assert(fltArgRegNum <= MAX_FLOAT_REG_ARG);
|
||||
|
@ -2945,7 +2945,7 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
|
|||
intArgRegNum += size;
|
||||
|
||||
#ifdef WINDOWS_AMD64_ABI
|
||||
fltArgRegNum = min(fltArgRegNum + size, MAX_FLOAT_REG_ARG);
|
||||
fltArgRegNum = min(fltArgRegNum + size, (unsigned)MAX_FLOAT_REG_ARG);
|
||||
#endif // WINDOWS_AMD64_ABI
|
||||
}
|
||||
}
|
||||
|
@ -3019,7 +3019,7 @@ void CallArgs::AddFinalArgsAndDetermineABIInfo(Compiler* comp, GenTreeCall* call
|
|||
unsigned CallArgs::OutgoingArgsStackSize() const
|
||||
{
|
||||
unsigned aligned = Compiler::GetOutgoingArgByteSize(m_nextStackByteOffset);
|
||||
return max(aligned, MIN_ARG_AREA_FOR_CALL);
|
||||
return max(aligned, (unsigned)MIN_ARG_AREA_FOR_CALL);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
|
|
@ -86,10 +86,11 @@ ABIPassingInformation Arm64Classifier::Classify(Compiler* comp,
|
|||
}
|
||||
else
|
||||
{
|
||||
unsigned alignment = compAppleArm64Abi() ? min(elemSize, TARGET_POINTER_SIZE) : TARGET_POINTER_SIZE;
|
||||
m_stackArgSize = roundUp(m_stackArgSize, alignment);
|
||||
info = ABIPassingInformation::FromSegment(comp, ABIPassingSegment::OnStack(m_stackArgSize, 0,
|
||||
structLayout->GetSize()));
|
||||
unsigned alignment =
|
||||
compAppleArm64Abi() ? min(elemSize, (unsigned)TARGET_POINTER_SIZE) : TARGET_POINTER_SIZE;
|
||||
m_stackArgSize = roundUp(m_stackArgSize, alignment);
|
||||
info = ABIPassingInformation::FromSegment(comp, ABIPassingSegment::OnStack(m_stackArgSize, 0,
|
||||
structLayout->GetSize()));
|
||||
m_stackArgSize += roundUp(structLayout->GetSize(), alignment);
|
||||
// After passing any float value on the stack, we should not enregister more float values.
|
||||
m_floatRegs.Clear();
|
||||
|
|
|
@ -4050,7 +4050,7 @@ T GetSignedMagic(T denom, int* shift /*out*/)
|
|||
UT t;
|
||||
T result_magic;
|
||||
|
||||
absDenom = abs(denom);
|
||||
absDenom = std::abs(denom);
|
||||
t = two_nminus1 + (UT(denom) >> bits_minus_1);
|
||||
absNc = t - 1 - (t % absDenom); // absolute value of nc
|
||||
p = bits_minus_1; // initialize p
|
||||
|
|
|
@ -16,7 +16,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
|
|||
#define _UTILS_H_
|
||||
|
||||
#include "safemath.h"
|
||||
#include "clr_std/type_traits"
|
||||
#include <type_traits>
|
||||
#include "iallocator.h"
|
||||
#include "hostallocator.h"
|
||||
#include "cycletimer.h"
|
||||
|
|
|
@ -211,7 +211,7 @@ char* CBlobFetcher::MakeNewBlock(unsigned len, unsigned align) {
|
|||
pChRet = m_pIndex[m_nIndexUsed].MakeNewBlock(len + pad, 0);
|
||||
|
||||
// Did we run out of memory?
|
||||
if (pChRet == NULL && m_pIndex[m_nIndexUsed].GetDataLen() == NULL)
|
||||
if (pChRet == NULL && m_pIndex[m_nIndexUsed].GetDataLen() == 0)
|
||||
return NULL;
|
||||
|
||||
if (pChRet == NULL) {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <stdlib.h> // for qsort
|
||||
#include <windows.h>
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include <corerror.h>
|
||||
#include <utilcode.h>
|
||||
|
@ -27,3 +28,6 @@
|
|||
|
||||
#include "ceegen.h"
|
||||
#include "ceesectionstring.h"
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
|
|
@ -2172,7 +2172,7 @@ STDMETHODIMP RegMeta::GetUserString( // S_OK or error.
|
|||
memcpy(
|
||||
wszString,
|
||||
userString.GetDataPointer(),
|
||||
min(userString.GetSize(), cbStringSize));
|
||||
min((ULONG)userString.GetSize(), cbStringSize));
|
||||
if (cbStringSize < userString.GetSize())
|
||||
{
|
||||
if ((wszString != NULL) && (cchStringSize > 0))
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <crtwrap.h>
|
||||
#include <winwrap.h>
|
||||
#include <algorithm>
|
||||
#include <utilcode.h>
|
||||
|
||||
#include <cor.h>
|
||||
|
@ -25,4 +26,7 @@
|
|||
|
||||
#include "utsem.h"
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
#endif // __STDAFX_H_
|
||||
|
|
|
@ -230,7 +230,7 @@ HRESULT HENUMInternal::EnumWithCount(
|
|||
}
|
||||
|
||||
// we can only fill the minimum of what caller asked for or what we have left
|
||||
cTokens = min ( (pEnum->u.m_ulEnd - pEnum->u.m_ulCur), cMax);
|
||||
cTokens = min ( (ULONG)(pEnum->u.m_ulEnd - pEnum->u.m_ulCur), cMax);
|
||||
|
||||
if (pEnum->m_EnumType == MDSimpleEnum)
|
||||
{
|
||||
|
@ -296,7 +296,7 @@ HRESULT HENUMInternal::EnumWithCount(
|
|||
_ASSERTE(! ((pEnum->u.m_ulEnd - pEnum->u.m_ulCur) % 2) );
|
||||
|
||||
// we can only fill the minimum of what caller asked for or what we have left
|
||||
cTokens = min ( (pEnum->u.m_ulEnd - pEnum->u.m_ulCur), cMax * 2);
|
||||
cTokens = min ( (ULONG)(pEnum->u.m_ulEnd - pEnum->u.m_ulCur), cMax * 2);
|
||||
|
||||
// get the embedded dynamic array
|
||||
TOKENLIST *pdalist = (TOKENLIST *)&(pEnum->m_cursor);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <crtwrap.h>
|
||||
#include <winwrap.h>
|
||||
#include <algorithm>
|
||||
#include <utilcode.h>
|
||||
|
||||
#include <cor.h>
|
||||
|
@ -26,4 +27,7 @@
|
|||
|
||||
#include "utsem.h"
|
||||
|
||||
using std::min;
|
||||
using std::max;
|
||||
|
||||
#endif // __STDAFX_H__
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <crtwrap.h>
|
||||
#include <winwrap.h>
|
||||
#include <algorithm>
|
||||
#include <utilcode.h>
|
||||
|
||||
#include <cor.h>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
if(WIN32)
|
||||
add_definitions(-DUNICODE=1)
|
||||
add_compile_definitions(NOMINMAX)
|
||||
endif (WIN32)
|
||||
|
||||
if(MSVC)
|
||||
|
|
|
@ -131,7 +131,6 @@ else()
|
|||
include_directories(unix)
|
||||
|
||||
# sal.h, pshpack/poppack.h
|
||||
add_definitions(-DPAL_STDCPP_COMPAT)
|
||||
include_directories(../../pal/inc/rt)
|
||||
|
||||
include(CheckIncludeFiles)
|
||||
|
|
|
@ -89,16 +89,6 @@ inline bool IS_ALIGNED(T* val, uintptr_t alignment);
|
|||
#define ZeroMemory(_dst, _size) memset((_dst), 0, (_size))
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// min/max
|
||||
|
||||
#ifndef min
|
||||
#define min(_a, _b) ((_a) < (_b) ? (_a) : (_b))
|
||||
#endif
|
||||
#ifndef max
|
||||
#define max(_a, _b) ((_a) < (_b) ? (_b) : (_a))
|
||||
#endif
|
||||
|
||||
#endif // !DACCESS_COMPILE
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -230,7 +230,7 @@ void SpinWait(int iteration, int usecLimit)
|
|||
int64_t ticksPerSecond = PalQueryPerformanceFrequency();
|
||||
int64_t endTicks = startTicks + (usecLimit * ticksPerSecond) / 1000000;
|
||||
|
||||
int l = min((unsigned)iteration, 30);
|
||||
int l = iteration >= 0 ? min(iteration, 30): 30;
|
||||
for (int i = 0; i < l; i++)
|
||||
{
|
||||
for (int j = 0; j < (1 << i); j++)
|
||||
|
|
|
@ -7,7 +7,6 @@ include_directories(${COREPAL_SOURCE_DIR}/src)
|
|||
include_directories(${COREPAL_SOURCE_DIR}/../inc)
|
||||
|
||||
add_compile_options(-fexceptions)
|
||||
add_definitions(-DUSE_STL)
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tests)
|
||||
|
|
|
@ -33,7 +33,6 @@ Abstract:
|
|||
#ifndef __PAL_H__
|
||||
#define __PAL_H__
|
||||
|
||||
#ifdef PAL_STDCPP_COMPAT
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
@ -42,12 +41,22 @@ Abstract:
|
|||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <strings.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C++"
|
||||
{
|
||||
|
||||
#include <new>
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -175,77 +184,13 @@ extern bool g_arm64_atomics_present;
|
|||
#define __has_cpp_attribute(x) (0)
|
||||
#endif
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
|
||||
#if __GNUC__
|
||||
|
||||
typedef __builtin_va_list va_list;
|
||||
|
||||
/* We should consider if the va_arg definition here is actually necessary.
|
||||
Could we use the standard va_arg definition? */
|
||||
|
||||
#define va_start __builtin_va_start
|
||||
#define va_arg __builtin_va_arg
|
||||
|
||||
#define va_copy __builtin_va_copy
|
||||
#define va_end __builtin_va_end
|
||||
|
||||
#define VOID void
|
||||
|
||||
#else // __GNUC__
|
||||
|
||||
typedef char * va_list;
|
||||
|
||||
#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
|
||||
|
||||
#if _MSC_VER >= 1400
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define _ADDRESSOF(v) ( &reinterpret_cast<const char &>(v) )
|
||||
#else
|
||||
#define _ADDRESSOF(v) ( &(v) )
|
||||
#endif
|
||||
|
||||
#define _crt_va_start(ap,v) ( ap = (va_list)_ADDRESSOF(v) + _INTSIZEOF(v) )
|
||||
#define _crt_va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
|
||||
#define _crt_va_end(ap) ( ap = (va_list)0 )
|
||||
|
||||
#define va_start _crt_va_start
|
||||
#define va_arg _crt_va_arg
|
||||
#define va_end _crt_va_end
|
||||
|
||||
#else // _MSC_VER
|
||||
|
||||
#define va_start(ap,v) (ap = (va_list) (&(v)) + _INTSIZEOF(v))
|
||||
#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
|
||||
#define va_end(ap)
|
||||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#define va_copy(dest,src) (dest = src)
|
||||
|
||||
#endif // __GNUC__
|
||||
|
||||
#define CHAR_BIT 8
|
||||
|
||||
#define SCHAR_MIN (-128)
|
||||
#define SCHAR_MAX 127
|
||||
#define UCHAR_MAX 0xff
|
||||
|
||||
#define SHRT_MIN (-32768)
|
||||
#define SHRT_MAX 32767
|
||||
#define USHRT_MAX 0xffff
|
||||
|
||||
#define INT_MIN (-2147483647 - 1)
|
||||
#define INT_MAX 2147483647
|
||||
#define UINT_MAX 0xffffffff
|
||||
|
||||
// LONG_MIN, LONG_MAX, ULONG_MAX -- use INT32_MIN etc. instead.
|
||||
|
||||
#define FLT_MAX 3.402823466e+38F
|
||||
#define DBL_MAX 1.7976931348623157e+308
|
||||
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
#ifndef FALLTHROUGH
|
||||
#if __has_cpp_attribute(fallthrough)
|
||||
#define FALLTHROUGH [[fallthrough]]
|
||||
#else // __has_cpp_attribute(fallthrough)
|
||||
#define FALLTHROUGH
|
||||
#endif // __has_cpp_attribute(fallthrough)
|
||||
#endif // FALLTHROUGH
|
||||
|
||||
/******************* PAL-Specific Entrypoints *****************************/
|
||||
|
||||
|
@ -256,44 +201,6 @@ BOOL
|
|||
PALAPI
|
||||
PAL_IsDebuggerPresent();
|
||||
|
||||
/* minimum signed 64 bit value */
|
||||
#define _I64_MIN (I64(-9223372036854775807) - 1)
|
||||
/* maximum signed 64 bit value */
|
||||
#define _I64_MAX I64(9223372036854775807)
|
||||
/* maximum unsigned 64 bit value */
|
||||
#define _UI64_MAX UI64(0xffffffffffffffff)
|
||||
|
||||
#define _I8_MAX SCHAR_MAX
|
||||
#define _I8_MIN SCHAR_MIN
|
||||
#define _I16_MAX SHRT_MAX
|
||||
#define _I16_MIN SHRT_MIN
|
||||
#define _I32_MAX INT_MAX
|
||||
#define _I32_MIN INT_MIN
|
||||
#define _UI8_MAX UCHAR_MAX
|
||||
#define _UI8_MIN UCHAR_MIN
|
||||
#define _UI16_MAX USHRT_MAX
|
||||
#define _UI16_MIN USHRT_MIN
|
||||
#define _UI32_MAX UINT_MAX
|
||||
#define _UI32_MIN UINT_MIN
|
||||
|
||||
#undef NULL
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((PVOID)0)
|
||||
#endif
|
||||
|
||||
#if defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
|
||||
#define nullptr NULL
|
||||
#endif // defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
|
||||
typedef __int64 time_t;
|
||||
#define _TIME_T_DEFINED
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
|
||||
#define DLL_PROCESS_ATTACH 1
|
||||
#define DLL_THREAD_ATTACH 2
|
||||
#define DLL_THREAD_DETACH 3
|
||||
|
@ -3934,31 +3841,6 @@ PAL_GetCurrentThreadAffinitySet(SIZE_T size, UINT_PTR* data);
|
|||
#endif //FEATURE_PAL_ANSI
|
||||
/******************* C Runtime Entrypoints *******************************/
|
||||
|
||||
/* Some C runtime functions needs to be reimplemented by the PAL.
|
||||
To avoid name collisions, those functions have been renamed using
|
||||
defines */
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
#define exit PAL_exit
|
||||
#define realloc PAL_realloc
|
||||
#define rand PAL_rand
|
||||
#define time PAL_time
|
||||
#define getenv PAL_getenv
|
||||
#define qsort PAL_qsort
|
||||
#define bsearch PAL_bsearch
|
||||
#define malloc PAL_malloc
|
||||
#define free PAL_free
|
||||
|
||||
#ifdef HOST_AMD64
|
||||
#define _mm_getcsr PAL__mm_getcsr
|
||||
#define _mm_setcsr PAL__mm_setcsr
|
||||
#endif // HOST_AMD64
|
||||
|
||||
// Forward declare functions that are in header files we can't include yet
|
||||
int printf(const char *, ...);
|
||||
int vprintf(const char *, va_list);
|
||||
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
|
||||
#ifndef _CONST_RETURN
|
||||
#ifdef __cplusplus
|
||||
#define _CONST_RETURN const
|
||||
|
@ -3971,134 +3853,16 @@ int vprintf(const char *, va_list);
|
|||
/* For backwards compatibility */
|
||||
#define _WConst_return _CONST_RETURN
|
||||
|
||||
#define EOF (-1)
|
||||
|
||||
typedef int errno_t;
|
||||
|
||||
#if defined(__WINT_TYPE__)
|
||||
typedef __WINT_TYPE__ wint_t;
|
||||
#else
|
||||
typedef unsigned int wint_t;
|
||||
#endif
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
PALIMPORT void * __cdecl memcpy(void *, const void *, size_t);
|
||||
PALIMPORT int __cdecl memcmp(const void *, const void *, size_t);
|
||||
PALIMPORT void * __cdecl memset(void *, int, size_t);
|
||||
PALIMPORT void * __cdecl memmove(void *, const void *, size_t);
|
||||
PALIMPORT void * __cdecl memchr(const void *, int, size_t);
|
||||
PALIMPORT long long int __cdecl atoll(const char *) MATH_THROW_DECL;
|
||||
PALIMPORT size_t __cdecl strlen(const char *);
|
||||
PALIMPORT int __cdecl strcmp(const char*, const char *);
|
||||
PALIMPORT int __cdecl strncmp(const char*, const char *, size_t);
|
||||
PALIMPORT int __cdecl strncasecmp(const char *, const char *, size_t);
|
||||
PALIMPORT char * __cdecl strcat(char *, const char *);
|
||||
PALIMPORT char * __cdecl strncat(char *, const char *, size_t);
|
||||
PALIMPORT char * __cdecl strcpy(char *, const char *);
|
||||
PALIMPORT char * __cdecl strncpy(char *, const char *, size_t);
|
||||
PALIMPORT char * __cdecl strchr(const char *, int);
|
||||
PALIMPORT char * __cdecl strrchr(const char *, int);
|
||||
PALIMPORT char * __cdecl strpbrk(const char *, const char *);
|
||||
PALIMPORT char * __cdecl strstr(const char *, const char *);
|
||||
PALIMPORT char * __cdecl strtok_r(char *, const char *, char **);
|
||||
PALIMPORT char * __cdecl strdup(const char*);
|
||||
PALIMPORT int __cdecl atoi(const char *);
|
||||
PALIMPORT unsigned long __cdecl strtoul(const char *, char **, int);
|
||||
PALIMPORT ULONGLONG __cdecl strtoull(const char *, char **, int);
|
||||
PALIMPORT double __cdecl atof(const char *);
|
||||
PALIMPORT double __cdecl strtod(const char *, char **);
|
||||
PALIMPORT size_t strnlen(const char *, size_t);
|
||||
PALIMPORT int __cdecl isprint(int);
|
||||
PALIMPORT int __cdecl isspace(int);
|
||||
PALIMPORT int __cdecl isalpha(int);
|
||||
PALIMPORT int __cdecl isalnum(int);
|
||||
PALIMPORT int __cdecl isdigit(int);
|
||||
PALIMPORT int __cdecl isxdigit(int);
|
||||
PALIMPORT int __cdecl tolower(int);
|
||||
PALIMPORT int __cdecl toupper(int);
|
||||
PALIMPORT int __cdecl iswalpha(wint_t);
|
||||
PALIMPORT int __cdecl iswdigit(wint_t);
|
||||
PALIMPORT int __cdecl iswupper(wint_t);
|
||||
PALIMPORT int __cdecl iswprint(wint_t);
|
||||
PALIMPORT int __cdecl iswspace(wint_t);
|
||||
PALIMPORT int __cdecl iswxdigit(wint_t);
|
||||
PALIMPORT wint_t __cdecl towupper(wint_t);
|
||||
PALIMPORT wint_t __cdecl towlower(wint_t);
|
||||
PALIMPORT int remove(const char*);
|
||||
|
||||
#define SEEK_SET 0
|
||||
#define SEEK_CUR 1
|
||||
#define SEEK_END 2
|
||||
|
||||
/* Locale categories */
|
||||
#define LC_ALL 0
|
||||
#define LC_COLLATE 1
|
||||
#define LC_CTYPE 2
|
||||
#define LC_MONETARY 3
|
||||
#define LC_NUMERIC 4
|
||||
#define LC_TIME 5
|
||||
|
||||
#define _IOFBF 0 /* setvbuf should set fully buffered */
|
||||
#define _IOLBF 1 /* setvbuf should set line buffered */
|
||||
#define _IONBF 2 /* setvbuf should set unbuffered */
|
||||
|
||||
struct _FILE;
|
||||
|
||||
#ifdef DEFINE_DUMMY_FILE_TYPE
|
||||
#define FILE _PAL_FILE
|
||||
struct _PAL_FILE;
|
||||
#else
|
||||
typedef _FILE FILE;
|
||||
#endif // DEFINE_DUMMY_FILE_TYPE
|
||||
|
||||
PALIMPORT int __cdecl fclose(FILE *);
|
||||
PALIMPORT int __cdecl fflush(FILE *);
|
||||
PALIMPORT size_t __cdecl fwrite(const void *, size_t, size_t, FILE *);
|
||||
PALIMPORT size_t __cdecl fread(void *, size_t, size_t, FILE *);
|
||||
PALIMPORT char * __cdecl fgets(char *, int, FILE *);
|
||||
PALIMPORT int __cdecl fputs(const char *, FILE *);
|
||||
PALIMPORT int __cdecl fprintf(FILE *, const char *, ...);
|
||||
PALIMPORT int __cdecl vfprintf(FILE *, const char *, va_list);
|
||||
PALIMPORT int __cdecl fseek(FILE *, LONG, int);
|
||||
PALIMPORT LONG __cdecl ftell(FILE *);
|
||||
PALIMPORT int __cdecl ferror(FILE *);
|
||||
PALIMPORT FILE * __cdecl fopen(const char *, const char *);
|
||||
PALIMPORT int __cdecl setvbuf(FILE *stream, char *, int, size_t);
|
||||
|
||||
// We need a PAL shim for errno and the standard streams as it's not possible to replicate these definition from the standard library
|
||||
// in all cases. Instead, we shim it and implement the PAL function where we can include the standard headers.
|
||||
// When we allow people to include the standard headers, then we can remove this.
|
||||
|
||||
PALIMPORT DLLEXPORT int * __cdecl PAL_errno();
|
||||
#define errno (*PAL_errno())
|
||||
|
||||
// Only provide a prototype for the PAL forwarders for the standard streams if we are not including the standard headers.
|
||||
#ifndef DEFINE_DUMMY_FILE_TYPE
|
||||
|
||||
extern "C" PALIMPORT DLLEXPORT FILE* __cdecl PAL_stdout();
|
||||
extern "C" PALIMPORT DLLEXPORT FILE* __cdecl PAL_stdin();
|
||||
extern "C" PALIMPORT DLLEXPORT FILE* __cdecl PAL_stderr();
|
||||
#define stdout PAL_stdout()
|
||||
#define stdin PAL_stdin()
|
||||
#define stderr PAL_stderr()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef DEFINE_DUMMY_FILE_TYPE
|
||||
#undef FILE
|
||||
#endif
|
||||
#endif // PAL_STDCPP_COMPAT
|
||||
|
||||
/* _TRUNCATE */
|
||||
#if !defined(_TRUNCATE)
|
||||
#define _TRUNCATE ((size_t)-1)
|
||||
#endif
|
||||
|
||||
// errno_t is only defined when the Secure CRT Extensions library is available (which no standard library that we build with implements anyway)
|
||||
typedef int errno_t;
|
||||
|
||||
PALIMPORT DLLEXPORT errno_t __cdecl memcpy_s(void *, size_t, const void *, size_t) THROW_DECL;
|
||||
PALIMPORT errno_t __cdecl memmove_s(void *, size_t, const void *, size_t);
|
||||
PALIMPORT DLLEXPORT int __cdecl strcasecmp(const char *, const char *);
|
||||
PALIMPORT char * __cdecl _gcvt_s(char *, int, double, int);
|
||||
PALIMPORT int __cdecl __iscsym(int);
|
||||
PALIMPORT DLLEXPORT int __cdecl _wcsicmp(const WCHAR *, const WCHAR*);
|
||||
PALIMPORT int __cdecl _wcsnicmp(const WCHAR *, const WCHAR *, size_t);
|
||||
PALIMPORT DLLEXPORT int __cdecl _vsnprintf_s(char *, size_t, size_t, const char *, va_list);
|
||||
|
@ -4125,10 +3889,7 @@ PALIMPORT DLLEXPORT double __cdecl PAL_wcstod(const WCHAR *, WCHAR **);
|
|||
PALIMPORT errno_t __cdecl _wcslwr_s(WCHAR *, size_t sz);
|
||||
PALIMPORT DLLEXPORT errno_t __cdecl _i64tow_s(long long, WCHAR *, size_t, int);
|
||||
PALIMPORT int __cdecl _wtoi(const WCHAR *);
|
||||
|
||||
#ifndef DEFINE_DUMMY_FILE_TYPE
|
||||
PALIMPORT FILE * __cdecl _wfopen(const WCHAR *, const WCHAR *);
|
||||
#endif
|
||||
|
||||
inline int _stricmp(const char* a, const char* b)
|
||||
{
|
||||
|
@ -4145,6 +3906,10 @@ inline char* _strdup(const char* a)
|
|||
return strdup(a);
|
||||
}
|
||||
|
||||
// Define the MSVC implementation of the alloca concept.
|
||||
// As this allocates on the current stack frame, use a macro instead of an inline function.
|
||||
#define _alloca(x) alloca(x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C++" {
|
||||
inline WCHAR *PAL_wcschr(WCHAR* S, WCHAR C)
|
||||
|
@ -4178,11 +3943,6 @@ unsigned int __cdecl _rotl(unsigned int value, int shift)
|
|||
}
|
||||
#endif // !__has_builtin(_rotl)
|
||||
|
||||
// On 64 bit unix, make the long an int.
|
||||
#ifdef HOST_64BIT
|
||||
#define _lrotl _rotl
|
||||
#endif
|
||||
|
||||
#if !__has_builtin(_rotr)
|
||||
|
||||
/*++
|
||||
|
@ -4205,137 +3965,7 @@ unsigned int __cdecl _rotr(unsigned int value, int shift)
|
|||
|
||||
#endif // !__has_builtin(_rotr)
|
||||
|
||||
PALIMPORT int __cdecl abs(int);
|
||||
// clang complains if this is declared with __int64
|
||||
PALIMPORT long long __cdecl llabs(long long);
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
|
||||
PALIMPORT double __cdecl copysign(double, double);
|
||||
PALIMPORT double __cdecl acos(double);
|
||||
PALIMPORT double __cdecl acosh(double) MATH_THROW_DECL;
|
||||
PALIMPORT double __cdecl asin(double);
|
||||
PALIMPORT double __cdecl asinh(double) MATH_THROW_DECL;
|
||||
PALIMPORT double __cdecl atan(double) MATH_THROW_DECL;
|
||||
PALIMPORT double __cdecl atanh(double) MATH_THROW_DECL;
|
||||
PALIMPORT double __cdecl atan2(double, double);
|
||||
PALIMPORT double __cdecl cbrt(double) MATH_THROW_DECL;
|
||||
PALIMPORT double __cdecl ceil(double);
|
||||
PALIMPORT double __cdecl cos(double);
|
||||
PALIMPORT double __cdecl cosh(double);
|
||||
PALIMPORT double __cdecl exp(double);
|
||||
PALIMPORT double __cdecl fabs(double);
|
||||
PALIMPORT double __cdecl floor(double);
|
||||
PALIMPORT double __cdecl fmod(double, double);
|
||||
PALIMPORT double __cdecl fma(double, double, double) MATH_THROW_DECL;
|
||||
PALIMPORT int __cdecl ilogb(double);
|
||||
PALIMPORT double __cdecl log(double);
|
||||
PALIMPORT double __cdecl log2(double) MATH_THROW_DECL;
|
||||
PALIMPORT double __cdecl log10(double);
|
||||
PALIMPORT double __cdecl modf(double, double*);
|
||||
PALIMPORT double __cdecl pow(double, double);
|
||||
PALIMPORT double __cdecl sin(double);
|
||||
PALIMPORT void __cdecl sincos(double, double*, double*);
|
||||
#ifdef __APPLE__
|
||||
PALIMPORT void __cdecl __sincos(double, double*, double*);
|
||||
#endif
|
||||
PALIMPORT double __cdecl sinh(double);
|
||||
PALIMPORT double __cdecl sqrt(double);
|
||||
PALIMPORT double __cdecl tan(double);
|
||||
PALIMPORT double __cdecl tanh(double);
|
||||
PALIMPORT double __cdecl trunc(double);
|
||||
|
||||
PALIMPORT float __cdecl copysignf(float, float);
|
||||
PALIMPORT float __cdecl acosf(float);
|
||||
PALIMPORT float __cdecl acoshf(float) MATH_THROW_DECL;
|
||||
PALIMPORT float __cdecl asinf(float);
|
||||
PALIMPORT float __cdecl asinhf(float) MATH_THROW_DECL;
|
||||
PALIMPORT float __cdecl atanf(float) MATH_THROW_DECL;
|
||||
PALIMPORT float __cdecl atanhf(float) MATH_THROW_DECL;
|
||||
PALIMPORT float __cdecl atan2f(float, float);
|
||||
PALIMPORT float __cdecl cbrtf(float) MATH_THROW_DECL;
|
||||
PALIMPORT float __cdecl ceilf(float);
|
||||
PALIMPORT float __cdecl cosf(float);
|
||||
PALIMPORT float __cdecl coshf(float);
|
||||
PALIMPORT float __cdecl expf(float);
|
||||
PALIMPORT float __cdecl fabsf(float);
|
||||
PALIMPORT float __cdecl floorf(float);
|
||||
PALIMPORT float __cdecl fmodf(float, float);
|
||||
PALIMPORT float __cdecl fmaf(float, float, float) MATH_THROW_DECL;
|
||||
PALIMPORT int __cdecl ilogbf(float);
|
||||
PALIMPORT float __cdecl logf(float);
|
||||
PALIMPORT float __cdecl log2f(float) MATH_THROW_DECL;
|
||||
PALIMPORT float __cdecl log10f(float);
|
||||
PALIMPORT float __cdecl modff(float, float*);
|
||||
PALIMPORT float __cdecl powf(float, float);
|
||||
PALIMPORT float __cdecl sinf(float);
|
||||
PALIMPORT void __cdecl sincosf(float, float*, float*);
|
||||
#ifdef __APPLE__
|
||||
PALIMPORT void __cdecl __sincosf(float, float*, float*);
|
||||
#endif
|
||||
PALIMPORT float __cdecl sinhf(float);
|
||||
PALIMPORT float __cdecl sqrtf(float);
|
||||
PALIMPORT float __cdecl tanf(float);
|
||||
PALIMPORT float __cdecl tanhf(float);
|
||||
PALIMPORT float __cdecl truncf(float);
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C++" {
|
||||
|
||||
inline __int64 abs(__int64 _X) {
|
||||
return llabs(_X);
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
inline __int64 abs(SSIZE_T _X) {
|
||||
return llabs((__int64)_X);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
PALIMPORT DLLEXPORT void * __cdecl malloc(size_t);
|
||||
PALIMPORT DLLEXPORT void __cdecl free(void *);
|
||||
PALIMPORT DLLEXPORT void * __cdecl realloc(void *, size_t);
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define alloca _alloca
|
||||
#else
|
||||
#define _alloca alloca
|
||||
#endif //_MSC_VER
|
||||
|
||||
#define alloca __builtin_alloca
|
||||
|
||||
#define max(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#define min(a, b) (((a) < (b)) ? (a) : (b))
|
||||
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
|
||||
PALIMPORT PAL_NORETURN void __cdecl exit(int);
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
|
||||
PALIMPORT DLLEXPORT void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *));
|
||||
PALIMPORT DLLEXPORT void * __cdecl bsearch(const void *, const void *, size_t, size_t,
|
||||
int(__cdecl *)(const void *, const void *));
|
||||
|
||||
PALIMPORT time_t __cdecl time(time_t *);
|
||||
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
|
||||
/* Maximum value that can be returned by the rand function. */
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
#define RAND_MAX 0x7fff
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
|
||||
PALIMPORT int __cdecl rand(void);
|
||||
PALIMPORT void __cdecl srand(unsigned int);
|
||||
|
||||
PALIMPORT DLLEXPORT char * __cdecl getenv(const char *);
|
||||
PALIMPORT DLLEXPORT char * __cdecl PAL_getenv(const char *);
|
||||
PALIMPORT DLLEXPORT int __cdecl _putenv(const char *);
|
||||
|
||||
#define ERANGE 34
|
||||
|
@ -4366,15 +3996,7 @@ PALAPI
|
|||
PAL_GetCpuTickCount();
|
||||
#endif // PAL_PERF
|
||||
|
||||
/******************* PAL functions for SIMD extensions *****************/
|
||||
|
||||
PALIMPORT
|
||||
unsigned int _mm_getcsr(void);
|
||||
|
||||
PALIMPORT
|
||||
void _mm_setcsr(unsigned int i);
|
||||
|
||||
/******************* PAL functions for CPU capability detection *******/
|
||||
/******************* PAL functions for exceptions *******/
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
|
|
@ -64,13 +64,15 @@ extern "C" {
|
|||
#define _cdecl
|
||||
#define CDECL
|
||||
|
||||
// On ARM __fastcall is ignored and causes a compile error
|
||||
#if !defined(PAL_STDCPP_COMPAT) || defined(__arm__)
|
||||
# undef __fastcall
|
||||
# undef _fastcall
|
||||
# define __fastcall
|
||||
# define _fastcall
|
||||
#endif // !defined(PAL_STDCPP_COMPAT) || defined(__arm__)
|
||||
// Some platforms (such as FreeBSD) define the __fastcall macro
|
||||
// on all targets, even when using it will fail.
|
||||
// Undefine it here so we can use it on all platforms without error.
|
||||
#ifdef __fastcall
|
||||
#undef __fastcall
|
||||
#endif
|
||||
|
||||
#define __fastcall
|
||||
#define _fastcall
|
||||
|
||||
#endif // !defined(__i386__)
|
||||
|
||||
|
@ -101,7 +103,9 @@ extern "C" {
|
|||
#else
|
||||
|
||||
#define PALIMPORT
|
||||
#ifndef DLLEXPORT
|
||||
#define DLLEXPORT __attribute__((visibility("default")))
|
||||
#endif
|
||||
#define PAL_NORETURN __attribute__((noreturn))
|
||||
|
||||
#endif
|
||||
|
@ -206,21 +210,6 @@ extern "C" {
|
|||
|
||||
#endif // _MSC_VER
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
// Defined in gnu's types.h. For non PAL_IMPLEMENTATION system
|
||||
// includes are not included, so we need to define them.
|
||||
#ifndef PAL_IMPLEMENTATION
|
||||
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
|
||||
#endif // PAL_IMPLEMENTATION
|
||||
|
||||
#ifndef _MSC_VER
|
||||
|
||||
|
@ -229,7 +218,6 @@ typedef long double LONG_DOUBLE;
|
|||
#endif
|
||||
|
||||
#endif // _MSC_VER
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
|
||||
typedef void VOID;
|
||||
|
||||
|
@ -565,49 +553,10 @@ static_assert(sizeof(SSIZE_T) == sizeof(void*), "SSIZE_T should be pointer sized
|
|||
#define SSIZE_T_MIN (ssize_t)I64(0x8000000000000000)
|
||||
#endif
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
#ifdef HOST_64BIT
|
||||
typedef unsigned long size_t;
|
||||
typedef long ssize_t;
|
||||
typedef long ptrdiff_t;
|
||||
#else // !HOST_64BIT
|
||||
typedef unsigned int size_t;
|
||||
typedef int ptrdiff_t;
|
||||
#endif // !HOST_64BIT
|
||||
#endif // !PAL_STDCPP_COMPAT
|
||||
#define _SIZE_T_DEFINED
|
||||
|
||||
typedef LONG_PTR LPARAM;
|
||||
|
||||
#define _PTRDIFF_T_DEFINED
|
||||
#ifdef _MINGW_
|
||||
// We need to define _PTRDIFF_T to make sure ptrdiff_t doesn't get defined
|
||||
// again by system headers - but only for MinGW.
|
||||
#define _PTRDIFF_T
|
||||
#endif
|
||||
|
||||
typedef char16_t WCHAR;
|
||||
|
||||
#ifndef PAL_STDCPP_COMPAT
|
||||
|
||||
#if defined(__linux__)
|
||||
#ifdef HOST_64BIT
|
||||
typedef long int intptr_t;
|
||||
typedef unsigned long int uintptr_t;
|
||||
#else // !HOST_64BIT
|
||||
typedef int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
#endif // !HOST_64BIT
|
||||
#else
|
||||
typedef long int intptr_t;
|
||||
typedef unsigned long int uintptr_t;
|
||||
#endif
|
||||
|
||||
#endif // PAL_STDCPP_COMPAT
|
||||
|
||||
#define _INTPTR_T_DEFINED
|
||||
#define _UINTPTR_T_DEFINED
|
||||
|
||||
typedef DWORD LCID;
|
||||
typedef PDWORD PLCID;
|
||||
typedef WORD LANGID;
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
//
|
||||
|
||||
//
|
||||
// ===========================================================================
|
||||
// File: assert.h
|
||||
//
|
||||
// ===========================================================================
|
||||
// dummy assert.h for PAL
|
||||
|
||||
#include "palrt.h"
|
|
@ -1,13 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
//
|
||||
// <OWNER>clrosdev</OWNER>
|
||||
//
|
||||
// ===========================================================================
|
||||
// File: cstdlib
|
||||
//
|
||||
// ===========================================================================
|
||||
// dummy cstdlib for PAL
|
||||
|
||||
#include "palrt.h"
|
|
@ -1,12 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
//
|
||||
|
||||
//
|
||||
// ===========================================================================
|
||||
// File: ctype.h
|
||||
//
|
||||
// ===========================================================================
|
||||
// dummy ctype.h for PAL
|
||||
|
||||
#include "palrt.h"
|
|
@ -1,128 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
|
||||
// From llvm-3.9/clang-3.9.1 emmintrin.h:
|
||||
|
||||
/*===---- emmintrin.h - SSE2 intrinsics ------------------------------------===
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
*===-----------------------------------------------------------------------===
|
||||
*/
|
||||
|
||||
#include "palrt.h"
|
||||
#ifdef __GNUC__
|
||||
#ifndef __EMMINTRIN_H
|
||||
#define __IMMINTRIN_H
|
||||
|
||||
typedef long long __m128i __attribute__((__vector_size__(16)));
|
||||
|
||||
typedef unsigned long long __v2du __attribute__ ((__vector_size__ (16)));
|
||||
typedef short __v8hi __attribute__((__vector_size__(16)));
|
||||
typedef char __v16qi __attribute__((__vector_size__(16)));
|
||||
|
||||
|
||||
/* Define the default attribute for the functions in this file. */
|
||||
#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, NODEBUG_ATTRIBUTE))
|
||||
|
||||
/// \brief Performs a bitwise OR of two 128-bit integer vectors.
|
||||
///
|
||||
/// \headerfile <x86intrin.h>
|
||||
///
|
||||
/// This intrinsic corresponds to the \c VPOR / POR instruction.
|
||||
///
|
||||
/// \param __a
|
||||
/// A 128-bit integer vector containing one of the source operands.
|
||||
/// \param __b
|
||||
/// A 128-bit integer vector containing one of the source operands.
|
||||
/// \returns A 128-bit integer vector containing the bitwise OR of the values
|
||||
/// in both operands.
|
||||
static __inline__ __m128i __DEFAULT_FN_ATTRS
|
||||
_mm_or_si128(__m128i __a, __m128i __b)
|
||||
{
|
||||
return (__m128i)((__v2du)__a | (__v2du)__b);
|
||||
}
|
||||
|
||||
/// \brief Compares each of the corresponding 16-bit values of the 128-bit
|
||||
/// integer vectors for equality. Each comparison yields 0h for false, FFFFh
|
||||
/// for true.
|
||||
///
|
||||
/// \headerfile <x86intrin.h>
|
||||
///
|
||||
/// This intrinsic corresponds to the \c VPCMPEQW / PCMPEQW instruction.
|
||||
///
|
||||
/// \param __a
|
||||
/// A 128-bit integer vector.
|
||||
/// \param __b
|
||||
/// A 128-bit integer vector.
|
||||
/// \returns A 128-bit integer vector containing the comparison results.
|
||||
static __inline__ __m128i __DEFAULT_FN_ATTRS
|
||||
_mm_cmpeq_epi16(__m128i __a, __m128i __b)
|
||||
{
|
||||
return (__m128i)((__v8hi)__a == (__v8hi)__b);
|
||||
}
|
||||
|
||||
/// \brief Moves packed integer values from an unaligned 128-bit memory location
|
||||
/// to elements in a 128-bit integer vector.
|
||||
///
|
||||
/// \headerfile <x86intrin.h>
|
||||
///
|
||||
/// This intrinsic corresponds to the \c VMOVDQU / MOVDQU instruction.
|
||||
///
|
||||
/// \param __p
|
||||
/// A pointer to a memory location containing integer values.
|
||||
/// \returns A 128-bit integer vector containing the moved values.
|
||||
static __inline__ __m128i __DEFAULT_FN_ATTRS
|
||||
_mm_loadu_si128(__m128i const *__p)
|
||||
{
|
||||
struct __loadu_si128 {
|
||||
__m128i __v;
|
||||
} __attribute__((__packed__, __may_alias__));
|
||||
return ((struct __loadu_si128*)__p)->__v;
|
||||
}
|
||||
|
||||
/// \brief Initializes all values in a 128-bit vector of [8 x i16] with the
|
||||
/// specified 16-bit value.
|
||||
///
|
||||
/// \headerfile <x86intrin.h>
|
||||
///
|
||||
/// This intrinsic is a utility function and does not correspond to a specific
|
||||
/// instruction.
|
||||
///
|
||||
/// \param __w
|
||||
/// A 16-bit value used to initialize the elements of the destination integer
|
||||
/// vector.
|
||||
/// \returns An initialized 128-bit vector of [8 x i16] with all elements
|
||||
/// containing the value provided in the operand.
|
||||
static __inline__ __m128i __DEFAULT_FN_ATTRS
|
||||
_mm_set1_epi16(short __w)
|
||||
{
|
||||
return (__m128i)(__v8hi){ __w, __w, __w, __w, __w, __w, __w, __w };
|
||||
}
|
||||
|
||||
static __inline__ int __DEFAULT_FN_ATTRS
|
||||
_mm_movemask_epi8(__m128i __a)
|
||||
{
|
||||
return __builtin_ia32_pmovmskb128((__v16qi)__a);
|
||||
}
|
||||
|
||||
#undef __DEFAULT_FN_ATTRS
|
||||
|
||||
#endif /* __EMMINTRIN_H */
|
||||
#endif // __GNUC__
|
|
@ -1,12 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
//
|
||||
|
||||
//
|
||||
// ===========================================================================
|
||||
// File: fcntl.h
|
||||
//
|
||||
// ===========================================================================
|
||||
// dummy fcntl.h for PAL
|
||||
|
||||
#include "palrt.h"
|
|
@ -1,12 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
//
|
||||
|
||||
//
|
||||
// ===========================================================================
|
||||
// File: float.h
|
||||
//
|
||||
// ===========================================================================
|
||||
// dummy float.h for PAL
|
||||
|
||||
#include "palrt.h"
|
|
@ -1,12 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
//
|
||||
|
||||
//
|
||||
// ===========================================================================
|
||||
// File: limits.h
|
||||
//
|
||||
// ===========================================================================
|
||||
// dummy limits.h for PAL
|
||||
|
||||
#include "palrt.h"
|
|
@ -1,12 +0,0 @@
|
|||
// Licensed to the .NET Foundation under one or more agreements.
|
||||
// The .NET Foundation licenses this file to you under the MIT license.
|
||||
//
|
||||
|
||||
//
|
||||
// ===========================================================================
|
||||
// File: malloc.h
|
||||
//
|
||||
// ===========================================================================
|
||||
// dummy malloc.h for PAL
|
||||
|
||||
#include "palrt.h"
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue