From 5c4e2a301ec1dd8ef75a3ba98e5be1ff2cea0130 Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Wed, 3 Apr 2024 20:31:21 -0700 Subject: [PATCH] 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) --- eng/native/configurecompiler.cmake | 1 - eng/native/functions.cmake | 6 + src/coreclr/CMakeLists.txt | 13 +- src/coreclr/binder/assemblyname.cpp | 2 +- src/coreclr/clrdefinitions.cmake | 1 + src/coreclr/debug/createdump/CMakeLists.txt | 2 - src/coreclr/debug/daccess/daccess.cpp | 2 +- src/coreclr/debug/dbgutil/CMakeLists.txt | 2 - src/coreclr/debug/debug-pal/CMakeLists.txt | 2 - src/coreclr/debug/di/rspriv.h | 4 +- src/coreclr/debug/di/rsthread.cpp | 10 +- src/coreclr/debug/di/rstype.cpp | 2 +- src/coreclr/debug/di/shimcallback.cpp | 2 +- src/coreclr/debug/di/stdafx.h | 3 + src/coreclr/debug/ee/debugger.cpp | 2 +- src/coreclr/debug/ee/funceval.cpp | 2 +- src/coreclr/debug/ee/stdafx.h | 2 + src/coreclr/debug/inc/dbgipcevents.h | 2 +- .../debug/shared/dbgtransportsession.cpp | 2 +- .../dlls/mscordac/mscordac_unixexports.src | 8 - src/coreclr/dlls/mscorpe/stdafx.h | 4 + src/coreclr/gc/env/common.h | 3 + src/coreclr/gc/env/gcenv.base.h | 9 - src/coreclr/gc/gc.cpp | 112 ++-- src/coreclr/gc/gcpriv.h | 9 +- src/coreclr/gc/sample/CMakeLists.txt | 1 + src/coreclr/gc/sample/GCSample.cpp | 2 +- src/coreclr/gc/sample/GCSample.vcxproj | 6 +- src/coreclr/gc/vxsort/defs.h | 14 +- src/coreclr/gc/windows/gcenv.windows.cpp | 10 +- src/coreclr/hosts/coreshim/CoreShim.h | 1 - src/coreclr/ildasm/dasm.cpp | 8 +- src/coreclr/ildasm/dis.cpp | 4 +- src/coreclr/ildasm/ildasmpch.h | 4 + src/coreclr/inc/allocacheck.h | 11 +- src/coreclr/inc/check.h | 2 +- src/coreclr/inc/clr_std/algorithm | 118 ---- src/coreclr/inc/clr_std/string | 425 ------------ src/coreclr/inc/clr_std/type_traits | 627 ------------------ src/coreclr/inc/clr_std/utility | 253 ------- src/coreclr/inc/clr_std/vector | 462 ------------- src/coreclr/inc/contract.h | 1 - src/coreclr/inc/contract.inl | 6 +- src/coreclr/inc/crtwrap.h | 2 +- src/coreclr/inc/daccess.h | 8 +- src/coreclr/inc/dacprivate.h | 4 +- src/coreclr/inc/holder.h | 5 - src/coreclr/inc/loaderheap.h | 2 +- src/coreclr/inc/random.h | 4 +- src/coreclr/inc/safemath.h | 8 +- src/coreclr/inc/utilcode.h | 81 +-- src/coreclr/jit/alloc.cpp | 6 +- src/coreclr/jit/assertionprop.cpp | 2 +- src/coreclr/jit/codegenarm64.cpp | 2 +- src/coreclr/jit/codegencommon.cpp | 8 +- src/coreclr/jit/compiler.cpp | 6 +- src/coreclr/jit/compiler.h | 2 +- src/coreclr/jit/compiler.hpp | 3 +- src/coreclr/jit/emit.cpp | 4 +- src/coreclr/jit/emitarm.cpp | 2 +- src/coreclr/jit/emitarm64.cpp | 2 +- src/coreclr/jit/fgopt.cpp | 4 +- src/coreclr/jit/fgprofilesynthesis.cpp | 2 +- src/coreclr/jit/gentree.cpp | 4 +- src/coreclr/jit/hashbv.cpp | 2 +- src/coreclr/jit/inline.h | 2 +- src/coreclr/jit/jit.h | 6 +- src/coreclr/jit/jiteh.cpp | 2 +- src/coreclr/jit/jitpch.h | 8 + src/coreclr/jit/jitstd/list.h | 2 +- src/coreclr/jit/jitstd/utility.h | 2 +- src/coreclr/jit/lclvars.cpp | 4 +- src/coreclr/jit/loopcloning.cpp | 2 +- src/coreclr/jit/lower.cpp | 4 +- src/coreclr/jit/morph.cpp | 6 +- src/coreclr/jit/targetarm64.cpp | 9 +- src/coreclr/jit/utils.cpp | 2 +- src/coreclr/jit/utils.h | 2 +- src/coreclr/md/ceefilegen/blobfetcher.cpp | 2 +- src/coreclr/md/ceefilegen/stdafx.h | 4 + src/coreclr/md/compiler/import.cpp | 2 +- src/coreclr/md/compiler/stdafx.h | 4 + src/coreclr/md/enc/rwutil.cpp | 4 +- src/coreclr/md/enc/stdafx.h | 4 + src/coreclr/md/runtime/stdafx.h | 1 + src/coreclr/nativeaot/CMakeLists.txt | 1 + src/coreclr/nativeaot/Runtime/CMakeLists.txt | 1 - src/coreclr/nativeaot/Runtime/CommonMacros.h | 10 - src/coreclr/nativeaot/Runtime/threadstore.cpp | 2 +- src/coreclr/pal/CMakeLists.txt | 1 - src/coreclr/pal/inc/pal.h | 430 +----------- src/coreclr/pal/inc/pal_mstypes.h | 73 +- src/coreclr/pal/inc/rt/cpp/assert.h | 12 - src/coreclr/pal/inc/rt/cpp/cstdlib | 13 - src/coreclr/pal/inc/rt/cpp/ctype.h | 12 - src/coreclr/pal/inc/rt/cpp/emmintrin.h | 128 ---- src/coreclr/pal/inc/rt/cpp/fcntl.h | 12 - src/coreclr/pal/inc/rt/cpp/float.h | 12 - src/coreclr/pal/inc/rt/cpp/limits.h | 12 - src/coreclr/pal/inc/rt/cpp/malloc.h | 12 - src/coreclr/pal/inc/rt/cpp/math.h | 12 - src/coreclr/pal/inc/rt/cpp/memory.h | 12 - src/coreclr/pal/inc/rt/cpp/stdarg.h | 12 - src/coreclr/pal/inc/rt/cpp/stdbool.h | 4 - src/coreclr/pal/inc/rt/cpp/stddef.h | 12 - src/coreclr/pal/inc/rt/cpp/stdint.h | 4 - src/coreclr/pal/inc/rt/cpp/stdio.h | 12 - src/coreclr/pal/inc/rt/cpp/stdlib.h | 12 - src/coreclr/pal/inc/rt/cpp/string.h | 12 - src/coreclr/pal/inc/rt/cpp/time.h | 12 - src/coreclr/pal/inc/rt/cpp/wchar.h | 12 - src/coreclr/pal/inc/rt/cpp/xmmintrin.h | 117 ---- src/coreclr/pal/inc/rt/palrt.h | 14 - src/coreclr/pal/inc/rt/safecrt.h | 24 +- src/coreclr/pal/inc/rt/sal.h | 10 +- src/coreclr/pal/inc/rt/specstrings.h | 2 - src/coreclr/pal/inc/rt/specstrings_strict.h | 1 - src/coreclr/pal/inc/rt/specstrings_undef.h | 3 - src/coreclr/pal/inc/strsafe.h | 9 - src/coreclr/pal/src/CMakeLists.txt | 3 - src/coreclr/pal/src/cruntime/malloc.cpp | 106 --- src/coreclr/pal/src/cruntime/misc.cpp | 264 -------- src/coreclr/pal/src/cruntime/thread.cpp | 38 -- src/coreclr/pal/src/cruntime/wchar.cpp | 24 +- src/coreclr/pal/src/debug/debug.cpp | 3 +- .../dummyprovider/CMakeLists.txt | 1 - .../lttngprovider/CMakeLists.txt | 1 - src/coreclr/pal/src/file/directory.cpp | 10 +- src/coreclr/pal/src/file/file.cpp | 2 +- src/coreclr/pal/src/file/find.cpp | 2 +- src/coreclr/pal/src/handlemgr/handlemgr.cpp | 4 +- src/coreclr/pal/src/include/pal/file.h | 1 + src/coreclr/pal/src/include/pal/malloc.hpp | 95 +-- src/coreclr/pal/src/include/pal/misc.h | 17 - src/coreclr/pal/src/include/pal/palinternal.h | 430 ------------ .../pal/src/include/pal/stackstring.hpp | 4 +- src/coreclr/pal/src/include/pal/utils.h | 2 +- src/coreclr/pal/src/init/pal.cpp | 6 +- src/coreclr/pal/src/loader/module.cpp | 6 +- src/coreclr/pal/src/map/map.cpp | 9 +- src/coreclr/pal/src/map/virtual.cpp | 2 +- src/coreclr/pal/src/misc/cgroup.cpp | 42 +- src/coreclr/pal/src/misc/environ.cpp | 24 +- src/coreclr/pal/src/misc/fmtmessage.cpp | 6 +- src/coreclr/pal/src/misc/miscpalapi.cpp | 1 + src/coreclr/pal/src/misc/perftrace.cpp | 44 +- src/coreclr/pal/src/misc/strutil.cpp | 2 +- src/coreclr/pal/src/misc/utils.cpp | 8 +- src/coreclr/pal/src/objmgr/palobjbase.cpp | 4 +- src/coreclr/pal/src/objmgr/shmobject.cpp | 2 +- src/coreclr/pal/src/safecrt/input.inl | 6 +- .../pal/src/sharedmemory/sharedmemory.cpp | 2 +- src/coreclr/pal/src/synchmgr/synchmanager.cpp | 1 + src/coreclr/pal/src/synchmgr/synchmanager.hpp | 2 +- src/coreclr/pal/src/thread/process.cpp | 16 +- src/coreclr/pal/src/thread/thread.cpp | 4 +- src/coreclr/pal/src/thread/threadsusp.cpp | 1 + src/coreclr/pal/tests/palsuite/CMakeLists.txt | 11 - .../c_runtime/__iscsym/test1/__iscsym.cpp | 92 --- .../c_runtime/_putenv/test1/test1.cpp | 4 +- .../c_runtime/_putenv/test2/test2.cpp | 4 +- .../c_runtime/_putenv/test3/test3.cpp | 4 +- .../c_runtime/bsearch/test1/test1.cpp | 47 -- .../c_runtime/bsearch/test2/test2.cpp | 56 -- .../palsuite/c_runtime/exit/test1/test1.cpp | 36 - .../palsuite/c_runtime/exit/test2/test2.cpp | 37 -- .../palsuite/c_runtime/free/test1/test1.cpp | 61 -- .../palsuite/c_runtime/malloc/test1/test1.cpp | 51 -- .../palsuite/c_runtime/malloc/test2/test2.cpp | 40 -- .../palsuite/c_runtime/qsort/test1/test1.cpp | 47 -- .../palsuite/c_runtime/qsort/test2/test2.cpp | 48 -- .../c_runtime/rand_srand/test1/test1.cpp | 99 --- .../c_runtime/realloc/test1/test1.cpp | 65 -- .../palsuite/c_runtime/time/test1/test1.cpp | 50 -- .../c_runtime/wcstoul/test5/test5.cpp | 8 +- .../pal/tests/palsuite/compilableTests.txt | 13 - .../OutputDebugStringA/test1/test1.cpp | 3 - .../tests/palsuite/manual-unautomatable.dat | 3 - .../pal/tests/palsuite/paltestlist.txt | 12 - .../palsuite/paltestlist_to_be_reviewed.txt | 1 - src/coreclr/pal/tests/palsuite/runpaltests.sh | 2 +- .../pal/tests/palsuite/tests-manual.dat | 1 - .../CriticalSectionFunctions/test8/test8.cpp | 1 + .../WaitForMultipleObjectsEx/test6/test6.cpp | 1 + src/coreclr/palrt/memorystream.cpp | 6 +- src/coreclr/scripts/genDummyProvider.py | 2 - src/coreclr/scripts/genLttngProvider.py | 2 - .../tools/StressLogAnalyzer/StressLogDump.cpp | 4 + .../StressLogAnalyzer/StressLogPlugin.cpp | 10 +- src/coreclr/tools/StressLogAnalyzer/util.h | 1 - src/coreclr/tools/metainfo/mdinfo.cpp | 3 +- .../superpmi-shared/methodcontext.cpp | 2 +- .../superpmi-shared/spmidumphelper.cpp | 2 +- .../superpmi/superpmi-shared/spmidumphelper.h | 4 +- .../superpmi/superpmi-shared/standardpch.h | 16 +- src/coreclr/utilcode/clrconfig.cpp | 4 + .../utilcode/clrhost_nodependencies.cpp | 5 + src/coreclr/utilcode/loaderheap.cpp | 2 +- src/coreclr/utilcode/md5.cpp | 2 +- src/coreclr/utilcode/stdafx.h | 3 + src/coreclr/utilcode/stgpool.cpp | 6 +- src/coreclr/utilcode/stresslog.cpp | 4 +- src/coreclr/utilcode/util.cpp | 2 +- src/coreclr/utilcode/utsem.cpp | 2 +- src/coreclr/vm/.vscode/c_cpp_properties.json | 1 + src/coreclr/vm/appdomain.cpp | 4 +- src/coreclr/vm/callcounting.cpp | 2 +- src/coreclr/vm/castcache.cpp | 1 + src/coreclr/vm/ceeload.cpp | 12 +- src/coreclr/vm/ceemain.cpp | 2 +- src/coreclr/vm/cgensys.h | 2 - src/coreclr/vm/classhash.cpp | 4 +- src/coreclr/vm/classlayoutinfo.cpp | 4 +- src/coreclr/vm/codeman.cpp | 34 +- src/coreclr/vm/codeman.h | 5 + src/coreclr/vm/common.h | 7 +- src/coreclr/vm/dacenumerablehash.inl | 2 +- src/coreclr/vm/dllimportcallback.h | 4 +- src/coreclr/vm/dynamicmethod.cpp | 2 +- src/coreclr/vm/eetwain.cpp | 4 +- .../vm/eventing/eventpipe/ds-rt-coreclr.h | 6 +- src/coreclr/vm/interpreter.h | 2 +- src/coreclr/vm/jithelpers.cpp | 7 +- src/coreclr/vm/jitinterface.cpp | 6 +- src/coreclr/vm/methodtable.cpp | 2 +- src/coreclr/vm/methodtablebuilder.cpp | 4 +- src/coreclr/vm/object.inl | 2 +- src/coreclr/vm/perfmap.cpp | 4 + src/coreclr/vm/profdetach.cpp | 4 +- src/coreclr/vm/proftoeeinterfaceimpl.cpp | 2 +- src/coreclr/vm/qcall.h | 2 +- src/coreclr/vm/stackingallocator.cpp | 2 +- src/coreclr/vm/stringliteralmap.cpp | 2 +- src/coreclr/vm/syncblk.cpp | 2 +- src/coreclr/vm/threadstatics.cpp | 4 +- src/coreclr/vm/util.hpp | 2 +- src/coreclr/vm/vars.hpp | 40 -- src/coreclr/vm/virtualcallstub.cpp | 2 + src/coreclr/vm/virtualcallstub.h | 2 +- src/mono/dlls/mscordbi/CMakeLists.txt | 1 - 240 files changed, 559 insertions(+), 5127 deletions(-) delete mode 100644 src/coreclr/inc/clr_std/algorithm delete mode 100644 src/coreclr/inc/clr_std/string delete mode 100644 src/coreclr/inc/clr_std/type_traits delete mode 100644 src/coreclr/inc/clr_std/utility delete mode 100644 src/coreclr/inc/clr_std/vector delete mode 100644 src/coreclr/pal/inc/rt/cpp/assert.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/cstdlib delete mode 100644 src/coreclr/pal/inc/rt/cpp/ctype.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/emmintrin.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/fcntl.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/float.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/limits.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/malloc.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/math.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/memory.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/stdarg.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/stdbool.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/stddef.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/stdint.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/stdio.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/stdlib.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/string.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/time.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/wchar.h delete mode 100644 src/coreclr/pal/inc/rt/cpp/xmmintrin.h delete mode 100644 src/coreclr/pal/src/cruntime/malloc.cpp delete mode 100644 src/coreclr/pal/src/cruntime/misc.cpp delete mode 100644 src/coreclr/pal/src/cruntime/thread.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/__iscsym/test1/__iscsym.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/bsearch/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/bsearch/test2/test2.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/exit/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/exit/test2/test2.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/free/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/malloc/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/malloc/test2/test2.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/qsort/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/qsort/test2/test2.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/rand_srand/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/realloc/test1/test1.cpp delete mode 100644 src/coreclr/pal/tests/palsuite/c_runtime/time/test1/test1.cpp diff --git a/eng/native/configurecompiler.cmake b/eng/native/configurecompiler.cmake index f7144a028a80d..bdf370fdf966b 100644 --- a/eng/native/configurecompiler.cmake +++ b/eng/native/configurecompiler.cmake @@ -28,7 +28,6 @@ if (CLR_CMAKE_HOST_UNIX) add_compile_options(-Wno-null-conversion) add_compile_options(-glldb) else() - add_compile_options($<$:-Werror=conversion-null>) add_compile_options(-g) endif() endif() diff --git a/eng/native/functions.cmake b/eng/native/functions.cmake index e10e008d775e4..d4a7e1bee92ed 100644 --- a/eng/native/functions.cmake +++ b/eng/native/functions.cmake @@ -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} diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt index 4aa45914ff54b..aaf4005aa7394 100644 --- a/src/coreclr/CMakeLists.txt +++ b/src/coreclr/CMakeLists.txt @@ -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($<$:-Wno-null-arithmetic>) + add_compile_options($<$:-Wno-conversion-null>) + add_compile_options($<$:-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}) diff --git a/src/coreclr/binder/assemblyname.cpp b/src/coreclr/binder/assemblyname.cpp index 9eea2ee8ba736..0c96f6be47ec2 100644 --- a/src/coreclr/binder/assemblyname.cpp +++ b/src/coreclr/binder/assemblyname.cpp @@ -11,10 +11,10 @@ // // ============================================================ +#include "common.h" #include "assemblyname.hpp" #include "assemblybindercommon.hpp" -#include "common.h" #include "utils.hpp" #include "textualidentityparser.hpp" diff --git a/src/coreclr/clrdefinitions.cmake b/src/coreclr/clrdefinitions.cmake index e69da7ed4ac41..0040f9575de27 100644 --- a/src/coreclr/clrdefinitions.cmake +++ b/src/coreclr/clrdefinitions.cmake @@ -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)) diff --git a/src/coreclr/debug/createdump/CMakeLists.txt b/src/coreclr/debug/createdump/CMakeLists.txt index 71e5b78b08e52..3c72b8a0fa42b 100644 --- a/src/coreclr/debug/createdump/CMakeLists.txt +++ b/src/coreclr/debug/createdump/CMakeLists.txt @@ -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}) diff --git a/src/coreclr/debug/daccess/daccess.cpp b/src/coreclr/debug/daccess/daccess.cpp index eb5127cdfa4f3..d6b8d99d7c37e 100644 --- a/src/coreclr/debug/daccess/daccess.cpp +++ b/src/coreclr/debug/daccess/daccess.cpp @@ -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++) diff --git a/src/coreclr/debug/dbgutil/CMakeLists.txt b/src/coreclr/debug/dbgutil/CMakeLists.txt index 2d8e02b07fc7f..0ad223630a583 100644 --- a/src/coreclr/debug/dbgutil/CMakeLists.txt +++ b/src/coreclr/debug/dbgutil/CMakeLists.txt @@ -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) diff --git a/src/coreclr/debug/debug-pal/CMakeLists.txt b/src/coreclr/debug/debug-pal/CMakeLists.txt index baa11c163dffe..adc8efacab4ae 100644 --- a/src/coreclr/debug/debug-pal/CMakeLists.txt +++ b/src/coreclr/debug/debug-pal/CMakeLists.txt @@ -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) diff --git a/src/coreclr/debug/di/rspriv.h b/src/coreclr/debug/di/rspriv.h index 68080a65cb8a6..63886b56bfa5a 100644 --- a/src/coreclr/debug/di/rspriv.h +++ b/src/coreclr/debug/di/rspriv.h @@ -3975,9 +3975,9 @@ class CordbProcess : // 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 diff --git a/src/coreclr/debug/di/rsthread.cpp b/src/coreclr/debug/di/rsthread.cpp index 3c5024fc80fab..1f455dad376d1 100644 --- a/src/coreclr/debug/di/rsthread.cpp +++ b/src/coreclr/debug/di/rsthread.cpp @@ -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++) diff --git a/src/coreclr/debug/di/rstype.cpp b/src/coreclr/debug/di/rstype.cpp index 45ccd44be6565..ae686064e96cb 100644 --- a/src/coreclr/debug/di/rstype.cpp +++ b/src/coreclr/debug/di/rstype.cpp @@ -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++) diff --git a/src/coreclr/debug/di/shimcallback.cpp b/src/coreclr/debug/di/shimcallback.cpp index 4e8f029209def..bf6c817fc880d 100644 --- a/src/coreclr/debug/di/shimcallback.cpp +++ b/src/coreclr/debug/di/shimcallback.cpp @@ -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); } diff --git a/src/coreclr/debug/di/stdafx.h b/src/coreclr/debug/di/stdafx.h index 061c576c4725b..8ee806f88f271 100644 --- a/src/coreclr/debug/di/stdafx.h +++ b/src/coreclr/debug/di/stdafx.h @@ -10,6 +10,9 @@ #include #include #include +#include +using std::min; +using std::max; #include diff --git a/src/coreclr/debug/ee/debugger.cpp b/src/coreclr/debug/ee/debugger.cpp index 62b9f3c99c9c2..79aa2d5f13fc4 100644 --- a/src/coreclr/debug/ee/debugger.cpp +++ b/src/coreclr/debug/ee/debugger.cpp @@ -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 rguiILOffsetTemp = new (nothrow) UINT[cMap]; diff --git a/src/coreclr/debug/ee/funceval.cpp b/src/coreclr/debug/ee/funceval.cpp index 7844edbe8b306..a7e888452c781 100644 --- a/src/coreclr/debug/ee/funceval.cpp +++ b/src/coreclr/debug/ee/funceval.cpp @@ -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]; diff --git a/src/coreclr/debug/ee/stdafx.h b/src/coreclr/debug/ee/stdafx.h index f21a670e210bf..21ef5f0efa329 100644 --- a/src/coreclr/debug/ee/stdafx.h +++ b/src/coreclr/debug/ee/stdafx.h @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include diff --git a/src/coreclr/debug/inc/dbgipcevents.h b/src/coreclr/debug/inc/dbgipcevents.h index 0eb393c37fce9..1545aa2808370 100644 --- a/src/coreclr/debug/inc/dbgipcevents.h +++ b/src/coreclr/debug/inc/dbgipcevents.h @@ -768,7 +768,7 @@ class MSLAYOUT VMPTR_Base // // 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() { diff --git a/src/coreclr/debug/shared/dbgtransportsession.cpp b/src/coreclr/debug/shared/dbgtransportsession.cpp index 8b8ca6203c957..3bebb8282aed7 100644 --- a/src/coreclr/debug/shared/dbgtransportsession.cpp +++ b/src/coreclr/debug/shared/dbgtransportsession.cpp @@ -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; diff --git a/src/coreclr/dlls/mscordac/mscordac_unixexports.src b/src/coreclr/dlls/mscordac/mscordac_unixexports.src index 8d94292d5c572..ad056eb1104e3 100644 --- a/src/coreclr/dlls/mscordac/mscordac_unixexports.src +++ b/src/coreclr/dlls/mscordac/mscordac_unixexports.src @@ -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 diff --git a/src/coreclr/dlls/mscorpe/stdafx.h b/src/coreclr/dlls/mscorpe/stdafx.h index 996113b500154..bd78a49013c94 100644 --- a/src/coreclr/dlls/mscorpe/stdafx.h +++ b/src/coreclr/dlls/mscorpe/stdafx.h @@ -11,6 +11,7 @@ #include #include #include +#include #define FEATURE_NO_HOST // Do not use host interface #include @@ -21,3 +22,6 @@ #include "ceegen.h" #include "ceefilegenwriter.h" #include "ceesectionstring.h" + +using std::min; +using std::max; diff --git a/src/coreclr/gc/env/common.h b/src/coreclr/gc/env/common.h index a3f6539aa3a49..5d8cff7f77904 100644 --- a/src/coreclr/gc/env/common.h +++ b/src/coreclr/gc/env/common.h @@ -25,6 +25,9 @@ #include #include +#include +#include +#include #ifdef TARGET_UNIX #include diff --git a/src/coreclr/gc/env/gcenv.base.h b/src/coreclr/gc/env/gcenv.base.h index 623cee0413450..1603448ae2a4f 100644 --- a/src/coreclr/gc/env/gcenv.base.h +++ b/src/coreclr/gc/env/gcenv.base.h @@ -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 // ----------------------------------------------------------------------------------------------------------- diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 67d6fa75e051f..e43047cf6e113 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -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 @@ BOOL gc_heap::background_process_mark_overflow (BOOL concurrent_p) 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 @@ BOOL gc_heap::process_mark_overflow(int condemned_gen_number) 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 @@ BOOL gc_heap::best_fit (size_t free_space, #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 diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index 6a3b600f8633f..6db2e06d04c00 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -3345,8 +3345,8 @@ class gc_heap 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 @@ class gc_heap #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 @@ class card_marking_enumerator #else #define THIS_ARG #endif // FEATURE_CARD_MARKING_STEALING + +using std::min; +using std::max; diff --git a/src/coreclr/gc/sample/CMakeLists.txt b/src/coreclr/gc/sample/CMakeLists.txt index 94a736e8c8126..1f297fd231332 100644 --- a/src/coreclr/gc/sample/CMakeLists.txt +++ b/src/coreclr/gc/sample/CMakeLists.txt @@ -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) diff --git a/src/coreclr/gc/sample/GCSample.cpp b/src/coreclr/gc/sample/GCSample.cpp index 41e275035b914..0f2afc7c20a71 100644 --- a/src/coreclr/gc/sample/GCSample.cpp +++ b/src/coreclr/gc/sample/GCSample.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; diff --git a/src/coreclr/gc/sample/GCSample.vcxproj b/src/coreclr/gc/sample/GCSample.vcxproj index 6e33738d18d0d..0b7e657b35f80 100644 --- a/src/coreclr/gc/sample/GCSample.vcxproj +++ b/src/coreclr/gc/sample/GCSample.vcxproj @@ -51,7 +51,7 @@ Use Level3 Disabled - WIN32;HOST_X86;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WIN32;HOST_X86;NOMINMAX;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true common.h .;..;..\env @@ -68,7 +68,7 @@ MaxSpeed true true - WIN32;HOST_X86;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) + WIN32;HOST_X86;NOMINMAX;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) true .;..;..\env @@ -109,4 +109,4 @@ - \ No newline at end of file + diff --git a/src/coreclr/gc/vxsort/defs.h b/src/coreclr/gc/vxsort/defs.h index d048185884770..d6373a21ad269 100644 --- a/src/coreclr/gc/vxsort/defs.h +++ b/src/coreclr/gc/vxsort/defs.h @@ -45,16 +45,6 @@ #define NOINLINE __attribute__((noinline)) #endif -#include - -#ifndef max -template -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 diff --git a/src/coreclr/gc/windows/gcenv.windows.cpp b/src/coreclr/gc/windows/gcenv.windows.cpp index 0aae8e035bbb4..608751dd169af 100644 --- a/src/coreclr/gc/windows/gcenv.windows.cpp +++ b/src/coreclr/gc/windows/gcenv.windows.cpp @@ -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; diff --git a/src/coreclr/hosts/coreshim/CoreShim.h b/src/coreclr/hosts/coreshim/CoreShim.h index 97b630bdb9e19..9be052926ec57 100644 --- a/src/coreclr/hosts/coreshim/CoreShim.h +++ b/src/coreclr/hosts/coreshim/CoreShim.h @@ -5,7 +5,6 @@ #define _CORESHIM_H_ // Platform -#define NOMINMAX #include #include diff --git a/src/coreclr/ildasm/dasm.cpp b/src/coreclr/ildasm/dasm.cpp index 21dff99a38123..da3aa514c0dca 100644 --- a/src/coreclr/ildasm/dasm.cpp +++ b/src/coreclr/ildasm/dasm.cpp @@ -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 diff --git a/src/coreclr/ildasm/dis.cpp b/src/coreclr/ildasm/dis.cpp index 21fc8c8679028..2ad1ecd2d200a 100644 --- a/src/coreclr/ildasm/dis.cpp +++ b/src/coreclr/ildasm/dis.cpp @@ -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!!!! diff --git a/src/coreclr/ildasm/ildasmpch.h b/src/coreclr/ildasm/ildasmpch.h index 9d89ba46db52c..5bb192dd14e10 100644 --- a/src/coreclr/ildasm/ildasmpch.h +++ b/src/coreclr/ildasm/ildasmpch.h @@ -12,6 +12,10 @@ #include #include #include +#include + +using std::min; +using std::max; #ifndef Debug_ReportError #define Debug_ReportError(strMessage) diff --git a/src/coreclr/inc/allocacheck.h b/src/coreclr/inc/allocacheck.h index ea7e6df316f01..1c4f0a5849713 100644 --- a/src/coreclr/inc/allocacheck.h +++ b/src/coreclr/inc/allocacheck.h @@ -23,7 +23,16 @@ #ifndef AllocaCheck_h #define AllocaCheck_h -#include // for alloca itself + +#if defined(HOST_WINDOWS) +#include // for alloca itself +#else +#if defined(__has_include) +#if __has_include() +#include +#endif // __has_include(alloca.h) +#endif // defined(__has_include) +#endif // defined(HOST_WINDOWS) #if defined(assert) && !defined(_ASSERTE) #define _ASSERTE assert diff --git a/src/coreclr/inc/check.h b/src/coreclr/inc/check.h index 6951e2a41837b..30ea0fdaf4d81 100644 --- a/src/coreclr/inc/check.h +++ b/src/coreclr/inc/check.h @@ -111,7 +111,7 @@ class CHECK #ifdef _DEBUG , m_condition (NULL) , m_file(NULL) - , m_line(NULL) + , m_line(0) , m_pCount(NULL) #endif {} diff --git a/src/coreclr/inc/clr_std/algorithm b/src/coreclr/inc/clr_std/algorithm deleted file mode 100644 index ebd21b09c5e58..0000000000000 --- a/src/coreclr/inc/clr_std/algorithm +++ /dev/null @@ -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 -#else -#ifndef __clr_std_algorithm_h__ -#define __clr_std_algorithm_h__ - -namespace std -{ - template - iter find_if ( iter first, iter last, CompareFunc comp ) - { - for ( ; first!=last ; first++ ) - if ( comp(*first) ) - break; - return first; - } - - template - iter find(iter first, iter last, const T& val) - { - for (;first != last; first++) - { - if (*first == val) - break; - } - return first; - } - - template - 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 - 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 - 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 - 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 diff --git a/src/coreclr/inc/clr_std/string b/src/coreclr/inc/clr_std/string deleted file mode 100644 index 59ac67b98653c..0000000000000 --- a/src/coreclr/inc/clr_std/string +++ /dev/null @@ -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 -#else -#ifndef __clr_std_string_h__ -#define __clr_std_string_h__ - -#include "clr_std/vector" - -namespace std -{ - -template -class basic_string -{ -public: - typedef T value_type; - typedef size_t size_type; - typedef typename vector::iterator iterator; - typedef typename vector::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& _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& operator=(const basic_string& _Right) - { - if (this != &_Right) - { - assign(_Right); - } - return (*this); - } - - basic_string& assign(const basic_string& _Right) - { - m_string.resize(_Right.size() + 1); // +1 for null terminator - copy(_Right); - return (*this); - } - - // - // Basic data copying - // - - void copy(const basic_string& _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& 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& operator+=(const basic_string& _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& 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 substr(size_type _Off = 0, size_type _Count = npos) const - { - size_type cursize = size(); - if (_Off >= cursize) - { - // result will be empty - return basic_string(); - } - 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(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& _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 m_string; // use a vector<> to represent the string, to avoid reimplementing similar functionality - -}; // class basic_string - -// -// String class instantiations -// - -typedef basic_string string; - -// -// Numeric conversions -// - -// convert integer T to string -template 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 inline -bool operator==( - const basic_string& _Left, - const basic_string& _Right) -{ - return (_Left.compare(_Right) == 0); -} - -template inline -bool operator!=( - const basic_string& _Left, - const basic_string& _Right) -{ - return (!(_Left == _Right)); -} - -template inline -bool operator<( - const basic_string& _Left, - const basic_string& _Right) -{ - return (_Left.compare(_Right) < 0); -} - -template inline -bool operator>( - const basic_string& _Left, - const basic_string& _Right) -{ - return (_Right < _Left); -} - -template inline -bool operator<=( - const basic_string& _Left, - const basic_string& _Right) -{ - return (!(_Right < _Left)); -} - -template inline -bool operator>=( - const basic_string& _Left, - const basic_string& _Right) -{ - return (!(_Left < _Right)); -} - -// -// String concatenation and other string operations -// - -template inline -basic_string operator+( - const basic_string& _Left, - const basic_string& _Right) -{ - basic_string 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 diff --git a/src/coreclr/inc/clr_std/type_traits b/src/coreclr/inc/clr_std/type_traits deleted file mode 100644 index ba007c32d9fef..0000000000000 --- a/src/coreclr/inc/clr_std/type_traits +++ /dev/null @@ -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 - -#else - -namespace std -{ - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS remove_const - template - struct remove_const - { // remove top level const qualifier - typedef _Ty type; - }; - - template - struct remove_const - { // remove top level const qualifier - typedef _Ty type; - }; - - template - struct remove_const - { // remove top level const qualifier - typedef _Ty type[]; - }; - - template - struct remove_const - { // remove top level const qualifier - typedef _Ty type[_Nx]; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS remove_volatile - template - struct remove_volatile - { // remove top level volatile qualifier - typedef _Ty type; - }; - - template - struct remove_volatile - { // remove top level volatile qualifier - typedef _Ty type; - }; - - template - struct remove_volatile - { // remove top level volatile qualifier - typedef _Ty type[]; - }; - - template - struct remove_volatile - { // remove top level volatile qualifier - typedef _Ty type[_Nx]; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS remove_cv - template - struct remove_cv - { // remove top level const and volatile qualifiers - typedef typename remove_const::type>::type type; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE remove_reference - template - struct remove_reference - { // remove reference - typedef T type; - }; - - template - struct remove_reference - { // remove reference - typedef T type; - }; - - template - struct remove_reference - { // remove rvalue reference - typedef T type; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE remove_pointer - template - struct remove_pointer - { // remove pointer - typedef T type; - }; - - template - struct remove_pointer - { // remove pointer - typedef T type; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE FUNCTION identity - template - 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 - 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 true_type; - typedef integral_constant false_type; - - // TEMPLATE CLASS _Cat_base - template - struct _Cat_base - : false_type - { // base class for type predicates - }; - - template<> - struct _Cat_base - : true_type - { // base class for type predicates - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS enable_if - template - struct enable_if - { // type is undefined for assumed !_Test - }; - - template - struct enable_if - { // type is _Type for _Test - typedef _Type type; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS conditional - template - struct conditional - { // type is _Ty2 for assumed !_Test - typedef _Ty2 type; - }; - - template - struct conditional - { // type is _Ty1 for _Test - typedef _Ty1 type; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS make_unsigned - template - struct make_unsigned - { - }; - - template<> - struct make_unsigned - { - typedef unsigned int type; - }; - -#ifndef HOST_UNIX - - template<> - struct make_unsigned - { - typedef unsigned long type; - }; - -#endif // !HOST_UNIX - - template<> - struct make_unsigned<__int64> - { - typedef unsigned __int64 type; - }; - - template<> - struct make_unsigned - { - typedef size_t type; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS make_signed - template - struct make_signed - { - }; - - template<> - struct make_signed - { - typedef signed int type; - }; - -#ifndef HOST_UNIX - - template<> - struct make_signed - { - typedef signed long type; - }; - -#endif // !HOST_UNIX - - template<> - struct make_signed - { - typedef signed __int64 type; - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS is_lvalue_reference - template - struct is_lvalue_reference - : false_type - { // determine whether _Ty is an lvalue reference - }; - - template - struct is_lvalue_reference<_Ty&> - : true_type - { // determine whether _Ty is an lvalue reference - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS is_rvalue_reference - template - struct is_rvalue_reference - : false_type - { // determine whether _Ty is an rvalue reference - }; - - template - struct is_rvalue_reference<_Ty&&> - : true_type - { // determine whether _Ty is an rvalue reference - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS is_reference - template - 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 - struct is_pointer - : false_type - { // determine whether _Ty is a pointer - }; - - template - struct is_pointer<_Ty *> - : true_type - { // determine whether _Ty is a pointer - }; - - // TEMPLATE CLASS _Is_integral - template - struct _Is_integral - : false_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : 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 and _Is_integral. -#if !defined(HOST_UNIX) || defined(__APPLE__) - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; -#endif /* !HOST_UNIX || __APPLE__ */ - - #if _HAS_CHAR16_T_LANGUAGE_SUPPORT - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - #endif /* _HAS_CHAR16_T_LANGUAGE_SUPPORT */ - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - template<> - struct _Is_integral - : true_type - { // determine whether _Ty is integral - }; - - // TEMPLATE CLASS is_integral - template - struct is_integral - : _Is_integral::type> - { // determine whether _Ty is integral - }; - - // TEMPLATE CLASS _Is_floating_point - template - struct _Is_floating_point - : false_type - { // determine whether _Ty is floating point - }; - - template<> - struct _Is_floating_point - : true_type - { // determine whether _Ty is floating point - }; - - template<> - struct _Is_floating_point - : 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 - : true_type - { // determine whether _Ty is floating point - }; -#endif - - // TEMPLATE CLASS is_floating_point - template - struct is_floating_point - : _Is_floating_point::type> - { // determine whether _Ty is floating point - }; - - // TEMPLATE CLASS is_arithmetic - template - struct is_arithmetic - : _Cat_base::value - || is_floating_point<_Ty>::value> - { // determine whether _Ty is an arithmetic type - }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS is_signed - template - struct is_signed : conditional< - static_cast::type>(-1) < 0, true_type, false_type>::type {}; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS is_same - template - struct is_same : false_type { }; - - //----------------------------------------------------------------------------------------- - template - struct is_same : true_type { }; - - //----------------------------------------------------------------------------------------- - // TEMPLATE CLASS is_base_of -#ifdef _MSC_VER - - template - 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 - 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::exists - // returns (at compile time) true if there is an implicit conversion from T - // to U (example: Derived to Base) - // b) conversion::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::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 - struct conversion - { - typedef detail::conversion_helper H; - static const bool exists = sizeof(typename H::Small) == sizeof((H::Test(H::MakeT()))); - static const bool exists2Way = exists && conversion::exists; - static const bool sameType = false; - }; - - template - struct conversion - { - static const bool exists = true; - static const bool exists2Way = true; - static const bool sameType = true; - }; - - template - struct conversion - { - static const bool exists = false; - static const bool exists2Way = false; - static const bool sameType = false; - }; - - template - struct conversion - { - static const bool exists = false; - static const bool exists2Way = false; - static const bool sameType = false; - }; - - template <> - struct conversion - { - 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 - struct is_base_of : - conditional::exists, true_type, false_type>::type {}; - - // Specialization to handle type parameters that are already pointers. - template - struct is_base_of : - conditional::exists, true_type, false_type>::type {}; - - // Specialization to handle invalid mixing of pointer types. - template - struct is_base_of : - false_type {}; - - // Specialization to handle invalid mixing of pointer types. - template - struct is_base_of : - false_type {}; - -#endif - - namespace detail - { - template - using void_t = void; - } - // Always false dependent-value for static_asserts. - template - struct _Always_false - { - const bool value = false; - }; - - template - struct _Add_reference { // add reference (non-referenceable type) - using _Lvalue = _Ty; - using _Rvalue = _Ty; - }; - - template - struct _Add_reference<_Ty, detail::void_t<_Ty&>> { // (referenceable type) - using _Lvalue = _Ty&; - using _Rvalue = _Ty&&; - }; - - template - struct add_lvalue_reference { - using type = typename _Add_reference<_Ty>::_Lvalue; - }; - - template - struct add_rvalue_reference { - using type = typename _Add_reference<_Ty>::_Rvalue; - }; - - template - 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 diff --git a/src/coreclr/inc/clr_std/utility b/src/coreclr/inc/clr_std/utility deleted file mode 100644 index 1b6b5a7b72c1e..0000000000000 --- a/src/coreclr/inc/clr_std/utility +++ /dev/null @@ -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 -#else -#ifndef __clr_std_utility_h__ -#define __clr_std_utility_h__ - -#include "clr_std/type_traits" - -namespace std -{ - //----------------------------------------------------------------------------------------- - // TEMPLATE FUNCTION move - template inline - typename remove_reference::type&& - move(T&& arg) - { // forward _Arg as movable - return ((typename remove_reference::type&&)arg); - } - - //----------------------------------------------------------------------------------------- - // TEMPLATE FUNCTION swap (from ) - template 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 inline - T&& - forward(typename identity::type& _Arg) - { // forward _Arg, given explicitly specified type parameter - return ((T&&)_Arg); - } -} - -namespace std -{ - //----------------------------------------------------------------------------------------- - // TEMPLATE STRUCT pair - template - 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 - pair(pair<_Other1, _Other2>& _Right) - : first(_Right.first), second(_Right.second) - { // construct from compatible pair - } - - template - 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 - pair(_Other1&& _Val1, _Other2&& _Val2) - : first(std::move(_Val1)), - second(std::move(_Val2)) - { // construct from moved values - } - - template - 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 inline - void swap(pair<_Ty1, _Ty2>& _Left, pair<_Ty1, _Ty2>& _Right) - { // swap _Left and _Right pairs - _Left.swap(_Right); - } - - template 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 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 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 inline - bool operator!=( - const pair<_Ty1, _Ty2>& _Left, - const pair<_Ty1, _Ty2>& _Right) - { // test for pair inequality - return (!(_Left == _Right)); - } - - template 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 inline - bool operator>( - const pair<_Ty1, _Ty2>& _Left, - const pair<_Ty1, _Ty2>& _Right) - { // test if _Left > _Right for pairs - return (_Right < _Left); - } - - template inline - bool operator<=( - const pair<_Ty1, _Ty2>& _Left, - const pair<_Ty1, _Ty2>& _Right) - { // test if _Left <= _Right for pairs - return (!(_Right < _Left)); - } - - template inline - bool operator>=( - const pair<_Ty1, _Ty2>& _Left, - const pair<_Ty1, _Ty2>& _Right) - { // test if _Left >= _Right for pairs - return (!(_Left < _Right)); - } - - template inline - _InIt begin( - const pair<_InIt, _InIt>& _Pair) - { // return first element of pair - return (_Pair.first); - } - - template 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 diff --git a/src/coreclr/inc/clr_std/vector b/src/coreclr/inc/clr_std/vector deleted file mode 100644 index c2d1caba890aa..0000000000000 --- a/src/coreclr/inc/clr_std/vector +++ /dev/null @@ -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 -#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 vector - { - public: - class const_iterator; - - class iterator - { - friend class std::vector::const_iterator; - public: - typedef T value_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef T& reference; - - typedef class vector::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::const_iterator _MyIter; - typedef class vector::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&) = delete; - vector& operator=(const vector&) = delete; - - vector(vector&& 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& operator=(vector&& 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 diff --git a/src/coreclr/inc/contract.h b/src/coreclr/inc/contract.h index a3017ab9cb1b0..6658d4a999cda 100644 --- a/src/coreclr/inc/contract.h +++ b/src/coreclr/inc/contract.h @@ -232,7 +232,6 @@ #include "specstrings.h" #include "clrtypes.h" -#include "malloc.h" #include "check.h" #include "debugreturn.h" #include "staticcontract.h" diff --git a/src/coreclr/inc/contract.inl b/src/coreclr/inc/contract.inl index d614f84e74f2a..211b6b5a1d701 100644 --- a/src/coreclr/inc/contract.inl +++ b/src/coreclr/inc/contract.inl @@ -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) diff --git a/src/coreclr/inc/crtwrap.h b/src/coreclr/inc/crtwrap.h index d3ab3a28be7c6..59b68d7d46694 100644 --- a/src/coreclr/inc/crtwrap.h +++ b/src/coreclr/inc/crtwrap.h @@ -11,11 +11,11 @@ #define __CrtWrap_h__ #include +#include #include #include #include "debugmacros.h" #include -#include #include #include diff --git a/src/coreclr/inc/daccess.h b/src/coreclr/inc/daccess.h index fcd5f5bbf1ff1..ef6af6f2be034 100644 --- a/src/coreclr/inc/daccess.h +++ b/src/coreclr/inc/daccess.h @@ -561,6 +561,10 @@ #ifndef NATIVEAOT #include +#if !defined(HOST_WINDOWS) +#include +#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 -#else -#include "clr_std/type_traits" #include "crosscomp.h" -#endif #include diff --git a/src/coreclr/inc/dacprivate.h b/src/coreclr/inc/dacprivate.h index e8d0be5aba07e..ae91e940ce22f 100644 --- a/src/coreclr/inc/dacprivate.h +++ b/src/coreclr/inc/dacprivate.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[] diff --git a/src/coreclr/inc/holder.h b/src/coreclr/inc/holder.h index 16551b141ca1a..984260308d04a 100644 --- a/src/coreclr/inc/holder.h +++ b/src/coreclr/inc/holder.h @@ -11,13 +11,8 @@ #include "volatile.h" #include "palclr.h" -#ifdef PAL_STDCPP_COMPAT #include #include -#else -#include "clr_std/utility" -#include "clr_std/type_traits" -#endif #if defined(FEATURE_COMINTEROP) && !defined(STRIKE) #include diff --git a/src/coreclr/inc/loaderheap.h b/src/coreclr/inc/loaderheap.h index 216668315cbff..b155d0188b84e 100644 --- a/src/coreclr/inc/loaderheap.h +++ b/src/coreclr/inc/loaderheap.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 diff --git a/src/coreclr/inc/random.h b/src/coreclr/inc/random.h index 99936c6177b0a..6a8d7001b2043 100644 --- a/src/coreclr/inc/random.h +++ b/src/coreclr/inc/random.h @@ -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 diff --git a/src/coreclr/inc/safemath.h b/src/coreclr/inc/safemath.h index fcd51af3de8cb..ff1fcbee78115 100644 --- a/src/coreclr/inc/safemath.h +++ b/src/coreclr/inc/safemath.h @@ -31,11 +31,11 @@ #include "static_assert.h" -#ifdef PAL_STDCPP_COMPAT #include -#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 diff --git a/src/coreclr/inc/utilcode.h b/src/coreclr/inc/utilcode.h index fe5db13f6b971..55713550aedc4 100644 --- a/src/coreclr/inc/utilcode.h +++ b/src/coreclr/inc/utilcode.h @@ -10,14 +10,16 @@ #ifndef __UtilCode_h__ #define __UtilCode_h__ +#include +#include +#include +#include + #include "crtwrap.h" #include "winwrap.h" #include -#include -#include #include #include -#include #include "clrtypes.h" #include "safewrap.h" #include "volatile.h" @@ -29,12 +31,6 @@ #include "safemath.h" #include "new.hpp" -#ifdef PAL_STDCPP_COMPAT -#include -#else -#include "clr_std/type_traits" -#endif - #include "contract.h" #include @@ -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 @@ class CHashTableAndData : public CHashTable ~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::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(comparand)); } -// NULL pointer variants of the above to avoid having to cast NULL -// to the appropriate pointer type. -template -inline T* InterlockedExchangeT( - T* volatile * target, - int value) // When NULL is provided as argument. -{ - //STATIC_ASSERT(value == 0); - return InterlockedExchangeT(target, nullptr); -} - -template -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 -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 diff --git a/src/coreclr/jit/alloc.cpp b/src/coreclr/jit/alloc.cpp index 7178066ab584c..2fcb3f877418b 100644 --- a/src/coreclr/jit/alloc.cpp +++ b/src/coreclr/jit/alloc.cpp @@ -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(); diff --git a/src/coreclr/jit/assertionprop.cpp b/src/coreclr/jit/assertionprop.cpp index e4e73adc58c6c..ebcb101663a30 100644 --- a/src/coreclr/jit/assertionprop.cpp +++ b/src/coreclr/jit/assertionprop.cpp @@ -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(getAllocator(CMK_AssertionProp), max(1, lvaCount)); + new (this, CMK_AssertionProp) JitExpandArray(getAllocator(CMK_AssertionProp), max(1u, lvaCount)); if (optCrossBlockLocalAssertionProp) { diff --git a/src/coreclr/jit/codegenarm64.cpp b/src/coreclr/jit/codegenarm64.cpp index 5447fc34724c2..ca9ab73224d7a 100644 --- a/src/coreclr/jit/codegenarm64.cpp +++ b/src/coreclr/jit/codegenarm64.cpp @@ -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 diff --git a/src/coreclr/jit/codegencommon.cpp b/src/coreclr/jit/codegencommon.cpp index 62fe40ed3c587..5c733c5457d94 100644 --- a/src/coreclr/jit/codegencommon.cpp +++ b/src/coreclr/jit/codegencommon.cpp @@ -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; diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index ef45fa5ca81ab..10dc0ef5f07e5 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -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) { diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 539629086f747..30fedcd9cd56c 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -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(newSize); diff --git a/src/coreclr/jit/compiler.hpp b/src/coreclr/jit/compiler.hpp index 336c95f752761..b1329e88b0436 100644 --- a/src/coreclr/jit/compiler.hpp +++ b/src/coreclr/jit/compiler.hpp @@ -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 { diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index 6b6b96b026546..cabad877f8383 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -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); diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index 4dd1d470887a2..5a20f8a1f940a 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -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(emitOutput_Thumb2Instr(dst, code)); diff --git a/src/coreclr/jit/emitarm64.cpp b/src/coreclr/jit/emitarm64.cpp index 54e2fcb503589..181b9706e4161 100644 --- a/src/coreclr/jit/emitarm64.cpp +++ b/src/coreclr/jit/emitarm64.cpp @@ -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); diff --git a/src/coreclr/jit/fgopt.cpp b/src/coreclr/jit/fgopt.cpp index 433a512469816..9a98ea7f619cd 100644 --- a/src/coreclr/jit/fgopt.cpp +++ b/src/coreclr/jit/fgopt.cpp @@ -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 diff --git a/src/coreclr/jit/fgprofilesynthesis.cpp b/src/coreclr/jit/fgprofilesynthesis.cpp index 77803454f0cfd..70b7ab6448b30 100644 --- a/src/coreclr/jit/fgprofilesynthesis.cpp +++ b/src/coreclr/jit/fgprofilesynthesis.cpp @@ -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); diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index ee41985df53bc..5125c3ad42fcf 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -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); diff --git a/src/coreclr/jit/hashbv.cpp b/src/coreclr/jit/hashbv.cpp index 203219a7ec20c..87acddf099bcb 100644 --- a/src/coreclr/jit/hashbv.cpp +++ b/src/coreclr/jit/hashbv.cpp @@ -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); } } diff --git a/src/coreclr/jit/inline.h b/src/coreclr/jit/inline.h index a87b2de79c058..8c1cb56124ad2 100644 --- a/src/coreclr/jit/inline.h +++ b/src/coreclr/jit/inline.h @@ -1049,7 +1049,7 @@ class InlineStrategy enum { ALWAYS_INLINE_SIZE = 16, - IMPLEMENTATION_MAX_INLINE_SIZE = _UI16_MAX, + IMPLEMENTATION_MAX_INLINE_SIZE = UINT16_MAX, IMPLEMENTATION_MAX_INLINE_DEPTH = 1000 }; diff --git a/src/coreclr/jit/jit.h b/src/coreclr/jit/jit.h index 754e6b27f4441..1094740a8e25d 100644 --- a/src/coreclr/jit/jit.h +++ b/src/coreclr/jit/jit.h @@ -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 diff --git a/src/coreclr/jit/jiteh.cpp b/src/coreclr/jit/jiteh.cpp index fc12d55c35a46..573191fecb38c 100644 --- a/src/coreclr/jit/jiteh.cpp +++ b/src/coreclr/jit/jiteh.cpp @@ -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) diff --git a/src/coreclr/jit/jitpch.h b/src/coreclr/jit/jitpch.h index 63f12133f61bf..6e9a0a6f80023 100644 --- a/src/coreclr/jit/jitpch.h +++ b/src/coreclr/jit/jitpch.h @@ -11,7 +11,15 @@ #include #include #include +#include #include +#ifdef HOST_WINDOWS +#include +#endif +#include + +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 diff --git a/src/coreclr/jit/jitstd/list.h b/src/coreclr/jit/jitstd/list.h index f00c159645255..77b5f893bea10 100644 --- a/src/coreclr/jit/jitstd/list.h +++ b/src/coreclr/jit/jitstd/list.h @@ -14,7 +14,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include "iterator.h" #include "functional.h" -#include "clr_std/utility" +#include namespace jitstd { diff --git a/src/coreclr/jit/jitstd/utility.h b/src/coreclr/jit/jitstd/utility.h index 624bb7bc7c39a..0df302a9352a5 100644 --- a/src/coreclr/jit/jitstd/utility.h +++ b/src/coreclr/jit/jitstd/utility.h @@ -5,7 +5,7 @@ #pragma once -#include "clr_std/type_traits" +#include namespace jitstd { diff --git a/src/coreclr/jit/lclvars.cpp b/src/coreclr/jit/lclvars.cpp index 2753ce1978e41..0de4f52eee756 100644 --- a/src/coreclr/jit/lclvars.cpp +++ b/src/coreclr/jit/lclvars.cpp @@ -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); diff --git a/src/coreclr/jit/loopcloning.cpp b/src/coreclr/jit/loopcloning.cpp index 4c5ffe247634a..2001f396c6f22 100644 --- a/src/coreclr/jit/loopcloning.cpp +++ b/src/coreclr/jit/loopcloning.cpp @@ -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())); } //------------------------------------------------------------------------- diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index e5e7aa9dbd301..5d3a504175ee9 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -7153,7 +7153,7 @@ bool Lowering::TryLowerConstIntDivOrMod(GenTree* node, GenTree** nextNode) } size_t absDivisorValue = - (divisorValue == SSIZE_T_MIN) ? static_cast(divisorValue) : static_cast(abs(divisorValue)); + (divisorValue == SSIZE_T_MIN) ? static_cast(divisorValue) : static_cast(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)) diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 6bd3ede0cc495..2144869b1ce40 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -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); } //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/targetarm64.cpp b/src/coreclr/jit/targetarm64.cpp index cef1e95780695..a0e4dfb5c3cf4 100644 --- a/src/coreclr/jit/targetarm64.cpp +++ b/src/coreclr/jit/targetarm64.cpp @@ -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(); diff --git a/src/coreclr/jit/utils.cpp b/src/coreclr/jit/utils.cpp index 23b8d0000b800..c3234e5524dea 100644 --- a/src/coreclr/jit/utils.cpp +++ b/src/coreclr/jit/utils.cpp @@ -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 diff --git a/src/coreclr/jit/utils.h b/src/coreclr/jit/utils.h index 39001f32215ef..6a0362bbbf067 100644 --- a/src/coreclr/jit/utils.h +++ b/src/coreclr/jit/utils.h @@ -16,7 +16,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #define _UTILS_H_ #include "safemath.h" -#include "clr_std/type_traits" +#include #include "iallocator.h" #include "hostallocator.h" #include "cycletimer.h" diff --git a/src/coreclr/md/ceefilegen/blobfetcher.cpp b/src/coreclr/md/ceefilegen/blobfetcher.cpp index 7a110eeeeaf59..f08908147de75 100644 --- a/src/coreclr/md/ceefilegen/blobfetcher.cpp +++ b/src/coreclr/md/ceefilegen/blobfetcher.cpp @@ -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) { diff --git a/src/coreclr/md/ceefilegen/stdafx.h b/src/coreclr/md/ceefilegen/stdafx.h index 36f42f95aa529..4026a47f14107 100644 --- a/src/coreclr/md/ceefilegen/stdafx.h +++ b/src/coreclr/md/ceefilegen/stdafx.h @@ -17,6 +17,7 @@ #include // for qsort #include #include +#include #include #include @@ -27,3 +28,6 @@ #include "ceegen.h" #include "ceesectionstring.h" + +using std::min; +using std::max; diff --git a/src/coreclr/md/compiler/import.cpp b/src/coreclr/md/compiler/import.cpp index 9c7d4c5a01b8c..060d3261af6ab 100644 --- a/src/coreclr/md/compiler/import.cpp +++ b/src/coreclr/md/compiler/import.cpp @@ -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)) diff --git a/src/coreclr/md/compiler/stdafx.h b/src/coreclr/md/compiler/stdafx.h index 56e29559cafe0..b8ae250e008cd 100644 --- a/src/coreclr/md/compiler/stdafx.h +++ b/src/coreclr/md/compiler/stdafx.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -25,4 +26,7 @@ #include "utsem.h" +using std::min; +using std::max; + #endif // __STDAFX_H_ diff --git a/src/coreclr/md/enc/rwutil.cpp b/src/coreclr/md/enc/rwutil.cpp index 69ad55f571c3e..a828249fea6b2 100644 --- a/src/coreclr/md/enc/rwutil.cpp +++ b/src/coreclr/md/enc/rwutil.cpp @@ -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); diff --git a/src/coreclr/md/enc/stdafx.h b/src/coreclr/md/enc/stdafx.h index e1b3962a14e60..10d1cf0f32d69 100644 --- a/src/coreclr/md/enc/stdafx.h +++ b/src/coreclr/md/enc/stdafx.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -26,4 +27,7 @@ #include "utsem.h" +using std::min; +using std::max; + #endif // __STDAFX_H__ diff --git a/src/coreclr/md/runtime/stdafx.h b/src/coreclr/md/runtime/stdafx.h index aca84b431773e..957cbd7e006d0 100644 --- a/src/coreclr/md/runtime/stdafx.h +++ b/src/coreclr/md/runtime/stdafx.h @@ -13,6 +13,7 @@ #include #include +#include #include #include diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt index 4b10cefe57387..74ee982ab9805 100644 --- a/src/coreclr/nativeaot/CMakeLists.txt +++ b/src/coreclr/nativeaot/CMakeLists.txt @@ -1,5 +1,6 @@ if(WIN32) add_definitions(-DUNICODE=1) + add_compile_definitions(NOMINMAX) endif (WIN32) if(MSVC) diff --git a/src/coreclr/nativeaot/Runtime/CMakeLists.txt b/src/coreclr/nativeaot/Runtime/CMakeLists.txt index c1bb58caa30b9..f070214054f7f 100644 --- a/src/coreclr/nativeaot/Runtime/CMakeLists.txt +++ b/src/coreclr/nativeaot/Runtime/CMakeLists.txt @@ -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) diff --git a/src/coreclr/nativeaot/Runtime/CommonMacros.h b/src/coreclr/nativeaot/Runtime/CommonMacros.h index 27f14f09eae4f..a2b4183fb1ecd 100644 --- a/src/coreclr/nativeaot/Runtime/CommonMacros.h +++ b/src/coreclr/nativeaot/Runtime/CommonMacros.h @@ -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 //------------------------------------------------------------------------------------------------- diff --git a/src/coreclr/nativeaot/Runtime/threadstore.cpp b/src/coreclr/nativeaot/Runtime/threadstore.cpp index 259d07e7ab0bb..d94ef850a1c9b 100644 --- a/src/coreclr/nativeaot/Runtime/threadstore.cpp +++ b/src/coreclr/nativeaot/Runtime/threadstore.cpp @@ -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++) diff --git a/src/coreclr/pal/CMakeLists.txt b/src/coreclr/pal/CMakeLists.txt index 4509e9fc0f8b5..9213941ba6da0 100644 --- a/src/coreclr/pal/CMakeLists.txt +++ b/src/coreclr/pal/CMakeLists.txt @@ -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) diff --git a/src/coreclr/pal/inc/pal.h b/src/coreclr/pal/inc/pal.h index 7d27a1109b450..9a1d25515bb32 100644 --- a/src/coreclr/pal/inc/pal.h +++ b/src/coreclr/pal/inc/pal.h @@ -33,7 +33,6 @@ Module Name: #ifndef __PAL_H__ #define __PAL_H__ -#ifdef PAL_STDCPP_COMPAT #include #include #include @@ -42,12 +41,22 @@ Module Name: #include #include #include +#include #include #include #include #include #include #include +#include + +#ifdef __cplusplus +extern "C++" +{ + +#include + +} #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(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 diff --git a/src/coreclr/pal/inc/pal_mstypes.h b/src/coreclr/pal/inc/pal_mstypes.h index 1eee6b2bbbd24..d59103002d18a 100644 --- a/src/coreclr/pal/inc/pal_mstypes.h +++ b/src/coreclr/pal/inc/pal_mstypes.h @@ -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; diff --git a/src/coreclr/pal/inc/rt/cpp/assert.h b/src/coreclr/pal/inc/rt/cpp/assert.h deleted file mode 100644 index 7493b151d6a0f..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/assert.h +++ /dev/null @@ -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" diff --git a/src/coreclr/pal/inc/rt/cpp/cstdlib b/src/coreclr/pal/inc/rt/cpp/cstdlib deleted file mode 100644 index 1cfd40828a47c..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/cstdlib +++ /dev/null @@ -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. - -// -// clrosdev -// -// =========================================================================== -// File: cstdlib -// -// =========================================================================== -// dummy cstdlib for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/ctype.h b/src/coreclr/pal/inc/rt/cpp/ctype.h deleted file mode 100644 index cb41fcd88e6e0..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/ctype.h +++ /dev/null @@ -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" diff --git a/src/coreclr/pal/inc/rt/cpp/emmintrin.h b/src/coreclr/pal/inc/rt/cpp/emmintrin.h deleted file mode 100644 index f2e8e0c1fd662..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/emmintrin.h +++ /dev/null @@ -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 -/// -/// 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 -/// -/// 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 -/// -/// 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 -/// -/// 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__ diff --git a/src/coreclr/pal/inc/rt/cpp/fcntl.h b/src/coreclr/pal/inc/rt/cpp/fcntl.h deleted file mode 100644 index 556145a9f0847..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/fcntl.h +++ /dev/null @@ -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" diff --git a/src/coreclr/pal/inc/rt/cpp/float.h b/src/coreclr/pal/inc/rt/cpp/float.h deleted file mode 100644 index a1dc803380e44..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/float.h +++ /dev/null @@ -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" diff --git a/src/coreclr/pal/inc/rt/cpp/limits.h b/src/coreclr/pal/inc/rt/cpp/limits.h deleted file mode 100644 index bd667f14eaf99..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/limits.h +++ /dev/null @@ -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" diff --git a/src/coreclr/pal/inc/rt/cpp/malloc.h b/src/coreclr/pal/inc/rt/cpp/malloc.h deleted file mode 100644 index 255a2c7f2fa22..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/malloc.h +++ /dev/null @@ -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" diff --git a/src/coreclr/pal/inc/rt/cpp/math.h b/src/coreclr/pal/inc/rt/cpp/math.h deleted file mode 100644 index e42c1852c1399..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/math.h +++ /dev/null @@ -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: math.h -// -// =========================================================================== -// dummy math.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/memory.h b/src/coreclr/pal/inc/rt/cpp/memory.h deleted file mode 100644 index bcc0d7d9c5d5b..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/memory.h +++ /dev/null @@ -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: memory.h -// -// =========================================================================== -// dummy memory.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/stdarg.h b/src/coreclr/pal/inc/rt/cpp/stdarg.h deleted file mode 100644 index 59d0d046d5f91..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/stdarg.h +++ /dev/null @@ -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: stdarg.h -// -// =========================================================================== -// dummy stdarg.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/stdbool.h b/src/coreclr/pal/inc/rt/cpp/stdbool.h deleted file mode 100644 index b23533a2940dd..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/stdbool.h +++ /dev/null @@ -1,4 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/stddef.h b/src/coreclr/pal/inc/rt/cpp/stddef.h deleted file mode 100644 index b347dbf414970..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/stddef.h +++ /dev/null @@ -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: stddef.h -// -// =========================================================================== -// dummy stddef.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/stdint.h b/src/coreclr/pal/inc/rt/cpp/stdint.h deleted file mode 100644 index b23533a2940dd..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/stdint.h +++ /dev/null @@ -1,4 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/stdio.h b/src/coreclr/pal/inc/rt/cpp/stdio.h deleted file mode 100644 index 33c1912bb2b72..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/stdio.h +++ /dev/null @@ -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: stdio.h -// -// =========================================================================== -// dummy stdio.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/stdlib.h b/src/coreclr/pal/inc/rt/cpp/stdlib.h deleted file mode 100644 index d2d49357b88e0..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/stdlib.h +++ /dev/null @@ -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: stdlib.h -// -// =========================================================================== -// dummy stdlib.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/string.h b/src/coreclr/pal/inc/rt/cpp/string.h deleted file mode 100644 index b66d883338e10..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/string.h +++ /dev/null @@ -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: string.h -// -// =========================================================================== -// dummy string.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/time.h b/src/coreclr/pal/inc/rt/cpp/time.h deleted file mode 100644 index 00c83f99d3438..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/time.h +++ /dev/null @@ -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: time.h -// -// =========================================================================== -// dummy time.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/wchar.h b/src/coreclr/pal/inc/rt/cpp/wchar.h deleted file mode 100644 index 5497d729e43b8..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/wchar.h +++ /dev/null @@ -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: wchar.h -// -// =========================================================================== -// dummy wchar.h for PAL - -#include "palrt.h" diff --git a/src/coreclr/pal/inc/rt/cpp/xmmintrin.h b/src/coreclr/pal/inc/rt/cpp/xmmintrin.h deleted file mode 100644 index 826d2d788676f..0000000000000 --- a/src/coreclr/pal/inc/rt/cpp/xmmintrin.h +++ /dev/null @@ -1,117 +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 xmmintrin.h: - -/*===---- xmmintrin.h - SSE 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. -* -*===-----------------------------------------------------------------------=== -*/ - -#ifdef __GNUC__ - -typedef float __m128 __attribute__((__vector_size__(16))); - -/* Define the default attributes for the functions in this file. */ -#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, NODEBUG_ATTRIBUTE)) - -/// \brief Loads a 128-bit floating-point vector of [4 x float] from an aligned -/// memory location. -/// -/// \headerfile -/// -/// This intrinsic corresponds to the \c VMOVAPS / MOVAPS instruction. -/// -/// \param __p -/// A pointer to a 128-bit memory location. The address of the memory -/// location has to be 128-bit aligned. -/// \returns A 128-bit vector of [4 x float] containing the loaded valus. -static __inline__ __m128 __DEFAULT_FN_ATTRS -_mm_load_ps(const float *__p) -{ - return *(__m128*)__p; -} - -/// \brief Loads a 128-bit floating-point vector of [4 x float] from an -/// unaligned memory location. -/// -/// \headerfile -/// -/// This intrinsic corresponds to the \c VMOVUPS / MOVUPS instruction. -/// -/// \param __p -/// A pointer to a 128-bit memory location. The address of the memory -/// location does not have to be aligned. -/// \returns A 128-bit vector of [4 x float] containing the loaded values. -static __inline__ __m128 __DEFAULT_FN_ATTRS -_mm_loadu_ps(const float *__p) -{ - struct __loadu_ps - { - __m128 __v; - } __attribute__((__packed__, __may_alias__)); - return ((struct __loadu_ps*)__p)->__v; -} - -/// \brief Stores float values from a 128-bit vector of [4 x float] to an -/// unaligned memory location. -/// -/// \headerfile -/// -/// This intrinsic corresponds to the \c VMOVUPS / MOVUPS instruction. -/// -/// \param __p -/// A pointer to a 128-bit memory location. The address of the memory -/// location does not have to be aligned. -/// \param __a -/// A 128-bit vector of [4 x float] containing the values to be stored. -static __inline__ void __DEFAULT_FN_ATTRS -_mm_storeu_ps(float *__p, __m128 __a) -{ - struct __storeu_ps - { - __m128 __v; - } __attribute__((__packed__, __may_alias__)); - ((struct __storeu_ps*)__p)->__v = __a; -} - -/// \brief Stores the lower 32 bits of a 128-bit vector of [4 x float] into -/// four contiguous elements in an aligned memory location. -/// -/// \headerfile -/// -/// This intrinsic corresponds to \c VMOVAPS / MOVAPS + \c shuffling -/// instruction. -/// -/// \param __p -/// A pointer to a 128-bit memory location. -/// \param __a -/// A 128-bit vector of [4 x float] whose lower 32 bits are stored to each -/// of the four contiguous elements pointed by __p. -static __inline__ void __DEFAULT_FN_ATTRS -_mm_store_ps(float *__p, __m128 __a) -{ - *(__m128*)__p = __a; -} - -#undef __DEFAULT_FN_ATTRS - -#endif // __GNUC__ diff --git a/src/coreclr/pal/inc/rt/palrt.h b/src/coreclr/pal/inc/rt/palrt.h index 1f7f413456965..18e25222c5db8 100644 --- a/src/coreclr/pal/inc/rt/palrt.h +++ b/src/coreclr/pal/inc/rt/palrt.h @@ -135,18 +135,6 @@ typedef enum tagEFaultRepRetVal #include "pal.h" -#ifndef PAL_STDCPP_COMPAT -#ifdef __cplusplus -#ifndef __PLACEMENT_NEW_INLINE -#define __PLACEMENT_NEW_INLINE -inline void *__cdecl operator new(size_t, void *_P) -{ - return (_P); -} -#endif // __PLACEMENT_NEW_INLINE -#endif // __cplusplus -#endif // !PAL_STDCPP_COMPAT - #include #define NTAPI __cdecl @@ -280,9 +268,7 @@ typedef union _ULARGE_INTEGER { DWORD HighPart; #endif } -#ifndef PAL_STDCPP_COMPAT u -#endif // PAL_STDCPP_COMPAT ; ULONGLONG QuadPart; } ULARGE_INTEGER, *PULARGE_INTEGER; diff --git a/src/coreclr/pal/inc/rt/safecrt.h b/src/coreclr/pal/inc/rt/safecrt.h index 12b5eceaad589..df31623d903c8 100644 --- a/src/coreclr/pal/inc/rt/safecrt.h +++ b/src/coreclr/pal/inc/rt/safecrt.h @@ -86,15 +86,6 @@ #endif #endif -/* NULL */ -#if !defined(NULL) -#if !defined(__cplusplus) -#define NULL 0 -#else -#define NULL ((void *)0) -#endif -#endif - /* _W64 */ #if !defined(_W64) #if !defined(__midl) && (defined(HOST_X86) || defined(_M_IX86)) && _MSC_VER >= 1300 @@ -104,16 +95,6 @@ #endif #endif -/* uintptr_t */ -#if !defined(_UINTPTR_T_DEFINED) -#if defined(HOST_64BIT) -typedef unsigned __int64 uintptr_t; -#else -typedef _W64 unsigned int uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif - #ifdef __GNUC__ #define SAFECRT_DEPRECATED __attribute__((deprecated)) #else @@ -1116,10 +1097,8 @@ errno_t __cdecl _wcsnset_s(WCHAR *_Dst, size_t _SizeInWords, WCHAR _Value, size_ #endif -#ifndef PAL_STDCPP_COMPAT - /* wcsnlen */ -_SAFECRT__EXTERN_C +extern size_t __cdecl wcsnlen(const WCHAR *inString, size_t inMaxSize); #if _SAFECRT_USE_INLINES || _SAFECRT_IMPL @@ -1140,7 +1119,6 @@ size_t __cdecl wcsnlen(const WCHAR *inString, size_t inMaxSize) } #endif -#endif // PAL_STDCPP_COMPAT /* _wmakepath_s */ _SAFECRT__EXTERN_C diff --git a/src/coreclr/pal/inc/rt/sal.h b/src/coreclr/pal/inc/rt/sal.h index bec3352aa3f16..9d461e8050f57 100644 --- a/src/coreclr/pal/inc/rt/sal.h +++ b/src/coreclr/pal/inc/rt/sal.h @@ -2399,19 +2399,14 @@ extern "C" { #define _SA_SPECSTRIZE( x ) #x /* - __null p __notnull p __maybenull p - Annotates a pointer p. States that pointer p is null. Commonly used - in the negated form __notnull or the possibly null form __maybenull. + Annotates a pointer p. States that pointer p is never null or maybe null. */ -#ifndef PAL_STDCPP_COMPAT - #define __null _Null_impl_ #define __notnull _Notnull_impl_ #define __maybenull _Maybenull_impl_ -#endif // !PAL_STDCPP_COMPAT /* __readonly l @@ -2598,11 +2593,8 @@ extern "C" { #else // ][ -#ifndef PAL_STDCPP_COMPAT - #define __null #define __notnull #define __deref -#endif // !PAL_STDCPP_COMPAT #define __maybenull #define __readonly #define __notreadonly diff --git a/src/coreclr/pal/inc/rt/specstrings.h b/src/coreclr/pal/inc/rt/specstrings.h index 21a40d91a0dd5..1cccb42e1554d 100644 --- a/src/coreclr/pal/inc/rt/specstrings.h +++ b/src/coreclr/pal/inc/rt/specstrings.h @@ -309,11 +309,9 @@ __ANNOTATION(SAL_failureDefault(enum __SAL_failureKind)); __byte_readableTo((expr) ? (size) : (size) * 2) #define __post_invalid _Post_ __notvalid /* integer related macros */ -#ifndef PAL_STDCPP_COMPAT #define __allocator __inner_allocator #define __deallocate(kind) _Pre_ __notnull __post_invalid #define __deallocate_opt(kind) _Pre_ __maybenull __post_invalid -#endif #define __bound __inner_bound #define __range(lb,ub) __inner_range(lb,ub) #define __in_bound _Pre_ __inner_bound diff --git a/src/coreclr/pal/inc/rt/specstrings_strict.h b/src/coreclr/pal/inc/rt/specstrings_strict.h index 52ade79cde13c..d066f76b3c43b 100644 --- a/src/coreclr/pal/inc/rt/specstrings_strict.h +++ b/src/coreclr/pal/inc/rt/specstrings_strict.h @@ -655,7 +655,6 @@ /*************************************************************************** * Expert Macros ***************************************************************************/ -#define __null __allowed(on_typedecl) #define __notnull __allowed(on_typedecl) #define __maybenull __allowed(on_typedecl) #define __exceptthat __allowed(on_typedecl) diff --git a/src/coreclr/pal/inc/rt/specstrings_undef.h b/src/coreclr/pal/inc/rt/specstrings_undef.h index 374b10069c1bf..884ad919bc7b8 100644 --- a/src/coreclr/pal/inc/rt/specstrings_undef.h +++ b/src/coreclr/pal/inc/rt/specstrings_undef.h @@ -5,10 +5,8 @@ */ -#ifndef PAL_STDCPP_COMPAT #undef __in #undef __out -#endif // !PAL_STDCPP_COMPAT #undef _At_ #undef _Deref_out_ @@ -387,7 +385,6 @@ #undef __notnull #undef __notreadonly #undef __notvalid -#undef __null #undef __nullnullterminated #undef __nullterminated #undef __out_awcount diff --git a/src/coreclr/pal/inc/strsafe.h b/src/coreclr/pal/inc/strsafe.h index b69feb73c2512..b833526e61777 100644 --- a/src/coreclr/pal/inc/strsafe.h +++ b/src/coreclr/pal/inc/strsafe.h @@ -27,15 +27,6 @@ #include // for memset #include // for va_start, etc. -#ifndef _SIZE_T_DEFINED -#ifdef HOST_64BIT -typedef unsigned __int64 size_t; -#else -typedef __w64 unsigned int size_t; -#endif // !HOST_64BIT -#define _SIZE_T_DEFINED -#endif // !_SIZE_T_DEFINED - #ifndef SUCCEEDED #define SUCCEEDED(hr) ((HRESULT)(hr) >= 0) #endif diff --git a/src/coreclr/pal/src/CMakeLists.txt b/src/coreclr/pal/src/CMakeLists.txt index 745162987a42e..cb3693655dcad 100644 --- a/src/coreclr/pal/src/CMakeLists.txt +++ b/src/coreclr/pal/src/CMakeLists.txt @@ -129,9 +129,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND (CLR_CMAKE_HOST_ARCH_AMD64 OR CLR_CM endif() set(SOURCES - cruntime/malloc.cpp - cruntime/misc.cpp - cruntime/thread.cpp cruntime/wchar.cpp debug/debug.cpp exception/seh.cpp diff --git a/src/coreclr/pal/src/cruntime/malloc.cpp b/src/coreclr/pal/src/cruntime/malloc.cpp deleted file mode 100644 index c4b3797e0b30a..0000000000000 --- a/src/coreclr/pal/src/cruntime/malloc.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - malloc.cpp - -Abstract: - - Implementation of suspension safe memory allocation functions. - -Revision History: - - - ---*/ - -#include "pal/corunix.hpp" -#include "pal/thread.hpp" -#include "pal/malloc.hpp" -#include "pal/dbgmsg.h" - -#include - -SET_DEFAULT_DEBUG_CHANNEL(CRT); - -using namespace CorUnix; - -void * -__cdecl -PAL_realloc( - void* pvMemblock, - size_t szSize - ) -{ - return InternalRealloc(pvMemblock, szSize); -} - -void * -CorUnix::InternalRealloc( - void* pvMemblock, - size_t szSize - ) -{ - void *pvMem; - - PERF_ENTRY(InternalRealloc); - ENTRY("realloc (memblock:%p size=%d)\n", pvMemblock, szSize); - - if (szSize == 0) - { - // If pvMemblock is NULL, there's no reason to call free. - if (pvMemblock != NULL) - { - free(pvMemblock); - } - pvMem = NULL; - } - else - { - pvMem = realloc(pvMemblock, szSize); - } - - LOGEXIT("realloc returns void * %p\n", pvMem); - PERF_EXIT(InternalRealloc); - return pvMem; -} - -void -__cdecl -PAL_free( - void *pvMem - ) -{ - free(pvMem); -} - -void * -__cdecl -PAL_malloc( - size_t szSize - ) -{ - return InternalMalloc(szSize); -} - -void * -CorUnix::InternalMalloc( - size_t szSize - ) -{ - void *pvMem; - - if (szSize == 0) - { - // malloc may return null for a requested size of zero bytes. Force a nonzero size to get a valid pointer. - szSize = 1; - } - - pvMem = (void*)malloc(szSize); - return pvMem; -} diff --git a/src/coreclr/pal/src/cruntime/misc.cpp b/src/coreclr/pal/src/cruntime/misc.cpp deleted file mode 100644 index d079cd0abc4d6..0000000000000 --- a/src/coreclr/pal/src/cruntime/misc.cpp +++ /dev/null @@ -1,264 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - cruntime/misc.cpp - -Abstract: - - Implementation of C runtime functions that don't fit anywhere else. - - - ---*/ - -#include "pal/thread.hpp" -#include "pal/threadsusp.hpp" -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -#include "pal/misc.h" - -#include -/* needs to be included after "palinternal.h" to avoid name - collision for va_start and va_end */ -#include -#include -#include - -#if defined(HOST_AMD64) || defined(_x86_) -#include -#endif // defined(HOST_AMD64) || defined(_x86_) -#if defined(_DEBUG) -#include -#endif //defined(_DEBUG) - -SET_DEFAULT_DEBUG_CHANNEL(CRT); - -using namespace CorUnix; - -/*++ -Function: - _gcvt_s - -See MSDN doc. ---*/ -char * -__cdecl -_gcvt_s( char * buffer, int iSize, double value, int digits ) -{ - PERF_ENTRY(_gcvt); - ENTRY( "_gcvt( value:%f digits=%d, buffer=%p )\n", value, digits, buffer ); - - if ( !buffer ) - { - ERROR( "buffer was an invalid pointer.\n" ); - } - - switch ( digits ) - { - case 7 : - /* Fall through */ - case 8 : - /* Fall through */ - case 15 : - /* Fall through */ - case 17 : - - sprintf_s( buffer, iSize, "%.*g", digits, value ); - break; - - default : - ASSERT( "Only the digits 7, 8, 15, and 17 are valid.\n" ); - *buffer = '\0'; - } - - LOGEXIT( "_gcvt returns %p (%s)\n", buffer , buffer ); - PERF_EXIT(_gcvt); - return buffer; -} - - -/*++ -Function : - - __iscsym - -See MSDN for more details. ---*/ -int -__cdecl -__iscsym( int c ) -{ - PERF_ENTRY(__iscsym); - ENTRY( "__iscsym( c=%d )\n", c ); - - if ( isalnum( c ) || c == '_' ) - { - LOGEXIT( "__iscsym returning 1\n" ); - PERF_EXIT(__iscsym); - return 1; - } - - LOGEXIT( "__iscsym returning 0\n" ); - PERF_EXIT(__iscsym); - return 0; -} -/*++ - -PAL forwarders for standard macro headers. - ---*/ -PALIMPORT DLLEXPORT int * __cdecl PAL_errno() -{ - return &errno; -} - -extern "C" PALIMPORT DLLEXPORT FILE* __cdecl PAL_stdout() -{ - return stdout; -} - -extern "C" PALIMPORT DLLEXPORT FILE* __cdecl PAL_stdin() -{ - return stdin; -} - -extern "C" PALIMPORT DLLEXPORT FILE* __cdecl PAL_stderr() -{ - return stderr; -} - -/*++ -Function: - - rand - - The RAND_MAX value can vary by platform. - -See MSDN for more details. ---*/ -int -__cdecl -PAL_rand(void) -{ - int ret; - PERF_ENTRY(rand); - ENTRY("rand(void)\n"); - - ret = (rand() % (PAL_RAND_MAX + 1)); - - LOGEXIT("rand() returning %d\n", ret); - PERF_EXIT(rand); - return ret; -} - - -/*++ -Function: - - time - -See MSDN for more details. ---*/ -PAL_time_t -__cdecl -PAL_time(PAL_time_t *tloc) -{ - time_t result; - - PERF_ENTRY(time); - ENTRY( "time( tloc=%p )\n",tloc ); - - time_t t; - result = time(&t); - if (tloc != NULL) - { - *tloc = t; - } - - LOGEXIT( "time returning %#lx\n",result ); - PERF_EXIT(time); - return result; -} - -PALIMPORT -void __cdecl -PAL_qsort(void *base, size_t nmemb, size_t size, - int (__cdecl *compar )(const void *, const void *)) -{ - PERF_ENTRY(qsort); - ENTRY("qsort(base=%p, nmemb=%lu, size=%lu, compar=%p\n", - base,(unsigned long) nmemb,(unsigned long) size, compar); - -/* reset ENTRY nesting level back to zero, qsort will invoke app-defined - callbacks and we want their entry traces... */ -#if _ENABLE_DEBUG_MESSAGES_ -{ - int old_level; - old_level = DBG_change_entrylevel(0); -#endif /* _ENABLE_DEBUG_MESSAGES_ */ - - qsort(base,nmemb,size,compar); - -/* ...and set nesting level back to what it was */ -#if _ENABLE_DEBUG_MESSAGES_ - DBG_change_entrylevel(old_level); -} -#endif /* _ENABLE_DEBUG_MESSAGES_ */ - - LOGEXIT("qsort returns\n"); - PERF_EXIT(qsort); -} - -PALIMPORT -void * __cdecl -PAL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, - int (__cdecl *compar)(const void *, const void *)) -{ - void *retval; - - PERF_ENTRY(bsearch); - ENTRY("bsearch(key=%p, base=%p, nmemb=%lu, size=%lu, compar=%p\n", - key, base, (unsigned long) nmemb, (unsigned long) size, compar); - -/* reset ENTRY nesting level back to zero, bsearch will invoke app-defined - callbacks and we want their entry traces... */ -#if _ENABLE_DEBUG_MESSAGES_ -{ - int old_level; - old_level = DBG_change_entrylevel(0); -#endif /* _ENABLE_DEBUG_MESSAGES_ */ - - retval = bsearch(key,base,nmemb,size,compar); - -/* ...and set nesting level back to what it was */ -#if _ENABLE_DEBUG_MESSAGES_ - DBG_change_entrylevel(old_level); -} -#endif /* _ENABLE_DEBUG_MESSAGES_ */ - - LOGEXIT("bsearch returns %p\n",retval); - PERF_EXIT(bsearch); - return retval; -} - -#ifdef HOST_AMD64 - -PALIMPORT -unsigned int PAL__mm_getcsr(void) -{ - return _mm_getcsr(); -} - -PALIMPORT -void PAL__mm_setcsr(unsigned int i) -{ - _mm_setcsr(i); -} - -#endif // HOST_AMD64 diff --git a/src/coreclr/pal/src/cruntime/thread.cpp b/src/coreclr/pal/src/cruntime/thread.cpp deleted file mode 100644 index 883c5d1b00190..0000000000000 --- a/src/coreclr/pal/src/cruntime/thread.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*++ - - - -Module Name: - - thread.c - -Abstract: - - Implementation of the threads/process functions in the C runtime library - that are Windows specific. - - - ---*/ - -#include "pal/palinternal.h" -#include "pal/dbgmsg.h" -#include "pal/init.h" - -SET_DEFAULT_DEBUG_CHANNEL(CRT); - -void -PAL_exit(int status) -{ - PERF_ENTRY(exit); - ENTRY ("exit(status=%d)\n", status); - - /* should also clean up any resources allocated by pal/cruntime, if any */ - ExitProcess(status); - - LOGEXIT ("exit returns void"); - PERF_EXIT(exit); -} diff --git a/src/coreclr/pal/src/cruntime/wchar.cpp b/src/coreclr/pal/src/cruntime/wchar.cpp index d5704ef0ca9d8..88340538ebca2 100644 --- a/src/coreclr/pal/src/cruntime/wchar.cpp +++ b/src/coreclr/pal/src/cruntime/wchar.cpp @@ -55,10 +55,10 @@ _wtoi( GetLastError()); return -1; } - tempStr = (char *) PAL_malloc(len); + tempStr = (char *) malloc(len); if (!tempStr) { - ERROR("PAL_malloc failed\n"); + ERROR("malloc failed\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return -1; } @@ -67,12 +67,12 @@ _wtoi( { ASSERT("WideCharToMultiByte failed. Error is %d\n", GetLastError()); - PAL_free(tempStr); + free(tempStr); return -1; } ret = atoi(tempStr); - PAL_free(tempStr); + free(tempStr); LOGEXIT("_wtoi returns int %d\n", ret); PERF_EXIT(_wtoi); return ret; @@ -261,10 +261,10 @@ PAL_wcstoul( res = 0; goto PAL_wcstoulExit; } - s_nptr = (char *)PAL_malloc(size); + s_nptr = (char *)malloc(size); if (!s_nptr) { - ERROR("PAL_malloc failed\n"); + ERROR("malloc failed\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); res = 0; goto PAL_wcstoulExit; @@ -310,7 +310,7 @@ PAL_wcstoul( } PAL_wcstoulExit: - PAL_free(s_nptr); + free(s_nptr); LOGEXIT("wcstoul returning unsigned long %lu\n", res); PERF_EXIT(wcstoul); @@ -351,10 +351,10 @@ PAL__wcstoui64( res = 0; goto PAL__wcstoui64Exit; } - s_nptr = (char *)PAL_malloc(size); + s_nptr = (char *)malloc(size); if (!s_nptr) { - ERROR("PAL_malloc failed\n"); + ERROR("malloc failed\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); res = 0; goto PAL__wcstoui64Exit; @@ -381,7 +381,7 @@ PAL__wcstoui64( } PAL__wcstoui64Exit: - PAL_free(s_nptr); + free(s_nptr); LOGEXIT("_wcstoui64 returning unsigned long long %llu\n", res); PERF_EXIT(_wcstoui64); @@ -896,7 +896,7 @@ PAL_wcstod( const wchar_16 * nptr, wchar_16 **endptr ) if ( lpEndOfExpression != lpStartOfExpression ) { Length = lpEndOfExpression - lpStartOfExpression; - lpStringRep = (LPSTR)PAL_malloc( Length + 1); + lpStringRep = (LPSTR)malloc( Length + 1); if ( lpStringRep ) { @@ -939,7 +939,7 @@ PAL_wcstod( const wchar_16 * nptr, wchar_16 **endptr ) *endptr = lpEndOfExpression; } - PAL_free( lpStringRep ); + free( lpStringRep ); LOGEXIT( "wcstod returning %f.\n", RetVal ); PERF_EXIT(wcstod); return RetVal; diff --git a/src/coreclr/pal/src/debug/debug.cpp b/src/coreclr/pal/src/debug/debug.cpp index f0a504452c59b..b38810864a587 100644 --- a/src/coreclr/pal/src/debug/debug.cpp +++ b/src/coreclr/pal/src/debug/debug.cpp @@ -40,6 +40,7 @@ SET_DEFAULT_DEBUG_CHANNEL(DEBUG); // some headers have code with asserts, so do #include #include +#include #if HAVE_PROCFS_CTL #include #elif defined(HAVE_TTRACE) // HAVE_PROCFS_CTL @@ -203,7 +204,7 @@ OutputDebugStringW( } /* strLen includes the null terminator */ - if ((lpOutputStringA = (LPSTR) InternalMalloc((strLen * sizeof(CHAR)))) == NULL) + if ((lpOutputStringA = (LPSTR) malloc((strLen * sizeof(CHAR)))) == NULL) { ERROR("Insufficient memory available !\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); diff --git a/src/coreclr/pal/src/eventprovider/dummyprovider/CMakeLists.txt b/src/coreclr/pal/src/eventprovider/dummyprovider/CMakeLists.txt index e0105865f9aec..09986597b7c1b 100644 --- a/src/coreclr/pal/src/eventprovider/dummyprovider/CMakeLists.txt +++ b/src/coreclr/pal/src/eventprovider/dummyprovider/CMakeLists.txt @@ -24,7 +24,6 @@ foreach(DUMMY_PROVIDER_FILE ${DUMMY_PROVIDER_OUTPUT}) list(APPEND DUMMY_PROVIDER_SOURCES ${DUMMY_PROVIDER_FILE}) endforeach() -add_definitions(-DPAL_STDCPP_COMPAT=1) include_directories(${COREPAL_SOURCE_DIR}/inc/rt) include_directories(${CMAKE_CURRENT_BINARY_DIR}/dummy) diff --git a/src/coreclr/pal/src/eventprovider/lttngprovider/CMakeLists.txt b/src/coreclr/pal/src/eventprovider/lttngprovider/CMakeLists.txt index d116c0095ea55..40f65bf171142 100644 --- a/src/coreclr/pal/src/eventprovider/lttngprovider/CMakeLists.txt +++ b/src/coreclr/pal/src/eventprovider/lttngprovider/CMakeLists.txt @@ -30,7 +30,6 @@ foreach(LTTNG_PROVIDER_FILE ${LTTNG_PROVIDER_OUTPUT}) endif() endforeach() -add_definitions(-DPAL_STDCPP_COMPAT=1) include_directories(${COREPAL_SOURCE_DIR}/inc/rt) include_directories(${CMAKE_CURRENT_BINARY_DIR}/lttng) diff --git a/src/coreclr/pal/src/file/directory.cpp b/src/coreclr/pal/src/file/directory.cpp index 4cd0600e5cf60..e06afd0b19e1c 100644 --- a/src/coreclr/pal/src/file/directory.cpp +++ b/src/coreclr/pal/src/file/directory.cpp @@ -75,11 +75,11 @@ CreateDirectoryW( goto done; } - if (((mb_dir = (char *)PAL_malloc(mb_size)) == NULL) || + if (((mb_dir = (char *)malloc(mb_size)) == NULL) || (WideCharToMultiByte( CP_ACP, 0, lpPathName, -1, mb_dir, mb_size, NULL, NULL) != mb_size)) { - ASSERT("WideCharToMultiByte or PAL_malloc failure! LastError:%d errno:%d\n", + ASSERT("WideCharToMultiByte or malloc failure! LastError:%d errno:%d\n", GetLastError(), errno); dwLastError = ERROR_INTERNAL_ERROR; goto done; @@ -93,7 +93,7 @@ CreateDirectoryW( } if (mb_dir != NULL) { - PAL_free(mb_dir); + free(mb_dir); } LOGEXIT("CreateDirectoryW returns BOOL %d\n", bRet); PERF_EXIT(CreateDirectoryW); @@ -280,7 +280,7 @@ GetCurrentDirectoryA(PathCharString& lpBuffer) dwDirLen = strlen( current_dir ); lpBuffer.Set(current_dir, dwDirLen); - PAL_free(current_dir); + free(current_dir); done: if ( dwLastError ) @@ -486,7 +486,7 @@ CreateDirectoryA( { SetLastError( dwLastError ); } - PAL_free( unixPathName ); + free( unixPathName ); LOGEXIT("CreateDirectoryA returns BOOL %d\n", bRet); PERF_EXIT(CreateDirectoryA); return bRet; diff --git a/src/coreclr/pal/src/file/file.cpp b/src/coreclr/pal/src/file/file.cpp index 8139f87c5d861..1712be93f698f 100644 --- a/src/coreclr/pal/src/file/file.cpp +++ b/src/coreclr/pal/src/file/file.cpp @@ -2881,7 +2881,7 @@ GetTempFileNameW( prefix_stringPS.CloseBuffer(prefix_size - 1); } - tempfile_name = (char*)InternalMalloc(MAX_LONGPATH); + tempfile_name = (char*)malloc(MAX_LONGPATH); if (tempfile_name == NULL) { pThread->SetLastError(ERROR_NOT_ENOUGH_MEMORY); diff --git a/src/coreclr/pal/src/file/find.cpp b/src/coreclr/pal/src/file/find.cpp index b874885992f8c..ead5c4335e76e 100644 --- a/src/coreclr/pal/src/file/find.cpp +++ b/src/coreclr/pal/src/file/find.cpp @@ -138,7 +138,7 @@ FindFirstFileA( goto done; } - find_data = (find_obj *)InternalMalloc(sizeof(find_obj)); + find_data = (find_obj *)malloc(sizeof(find_obj)); if ( find_data == NULL ) { ERROR("Unable to allocate memory for find_data\n"); diff --git a/src/coreclr/pal/src/handlemgr/handlemgr.cpp b/src/coreclr/pal/src/handlemgr/handlemgr.cpp index 5dc198c7f5a3a..09405f1ec514b 100644 --- a/src/coreclr/pal/src/handlemgr/handlemgr.cpp +++ b/src/coreclr/pal/src/handlemgr/handlemgr.cpp @@ -51,7 +51,7 @@ CSimpleHandleManager::Initialize( field, with the head in the global 'm_hiFreeListStart'. */ m_dwTableSize = m_dwTableGrowthRate; - m_rghteHandleTable = reinterpret_cast(InternalMalloc((m_dwTableSize * sizeof(HANDLE_TABLE_ENTRY)))); + m_rghteHandleTable = reinterpret_cast(malloc((m_dwTableSize * sizeof(HANDLE_TABLE_ENTRY)))); if(NULL == m_rghteHandleTable) { ERROR("Unable to create initial handle table array"); @@ -108,7 +108,7 @@ CSimpleHandleManager::AllocateHandle( } /* grow handle table */ - rghteTempTable = reinterpret_cast(InternalRealloc( + rghteTempTable = reinterpret_cast(realloc( m_rghteHandleTable, (m_dwTableSize + m_dwTableGrowthRate) * sizeof(HANDLE_TABLE_ENTRY))); diff --git a/src/coreclr/pal/src/include/pal/file.h b/src/coreclr/pal/src/include/pal/file.h index 9b6e319536404..0ec765317d48f 100644 --- a/src/coreclr/pal/src/include/pal/file.h +++ b/src/coreclr/pal/src/include/pal/file.h @@ -25,6 +25,7 @@ Revision History: #include "pal/stackstring.hpp" #include #include +#include #ifdef __cplusplus extern "C" diff --git a/src/coreclr/pal/src/include/pal/malloc.hpp b/src/coreclr/pal/src/include/pal/malloc.hpp index 4e7b96da0e228..65715fa9387ae 100644 --- a/src/coreclr/pal/src/include/pal/malloc.hpp +++ b/src/coreclr/pal/src/include/pal/malloc.hpp @@ -26,96 +26,17 @@ Module Name: #include #include -extern "C" -{ - void * - __cdecl - PAL_realloc( - void* pvMemblock, - size_t szSize - ); - - void * - __cdecl - PAL_malloc( - size_t szSize - ); - - void - __cdecl - PAL_free( - void *pvMem - ); -} - namespace CorUnix{ - - void * - InternalRealloc( - void *pvMemblock, - size_t szSize - ); - - void * - InternalMalloc( - size_t szSize - ); - - // Define common code for "new" style allocators below. -#define INTERNAL_NEW_COMMON() \ - T *pMem = (T*)InternalMalloc(sizeof(T)); \ - if (pMem == NULL) \ - return NULL; - - // Define "new" style allocators (which allocate then call a constructor) for different numbers of - // constructor arguments. Added based on usage. - - // Default constructor (0 args) case. - template - T* InternalNew() + // Define "new" style allocators (which allocate then call a constructor). + template + T* InternalNew(Ts... args) { - INTERNAL_NEW_COMMON(); - return new (pMem) T(); - } + T* pMem = (T*)malloc(sizeof(T)); - // 1 arg case. - template - T* InternalNew(A1 arg1) - { - INTERNAL_NEW_COMMON(); - return new (pMem) T(arg1); - } - - // 2 args case. - template - T* InternalNew(A1 arg1, A2 arg2) - { - INTERNAL_NEW_COMMON(); - return new (pMem) T(arg1, arg2); - } - - // 3 args case. - template - T* InternalNew(A1 arg1, A2 arg2, A3 arg3) - { - INTERNAL_NEW_COMMON(); - return new (pMem) T(arg1, arg2, arg3); - } - - // 4 args case. - template - T* InternalNew(A1 arg1, A2 arg2, A3 arg3, A4 arg4) - { - INTERNAL_NEW_COMMON(); - return new (pMem) T(arg1, arg2, arg3, arg4); - } + if (pMem == NULL) + return NULL; - // 5 args case. - template - T* InternalNew(A1 arg1, A2 arg2, A3 arg3, A4 arg4, A5 arg5) - { - INTERNAL_NEW_COMMON(); - return new (pMem) T(arg1, arg2, arg3, arg4, arg5); + return new (pMem) T(args...); } template T* InternalNewArray(size_t cElements) @@ -123,7 +44,7 @@ namespace CorUnix{ size_t cbSize = (cElements * sizeof(T)) + sizeof(size_t); T *pMem; - pMem = (T*)InternalMalloc(cbSize); + pMem = (T*)malloc(cbSize); if (pMem == NULL) return NULL; diff --git a/src/coreclr/pal/src/include/pal/misc.h b/src/coreclr/pal/src/include/pal/misc.h index aa5b2b4852b6e..ffa6448ed7d30 100644 --- a/src/coreclr/pal/src/include/pal/misc.h +++ b/src/coreclr/pal/src/include/pal/misc.h @@ -25,23 +25,6 @@ extern "C" { #endif // __cplusplus -/*++ -Function : - - PAL_rand - - Calls rand and mitigates the difference between RAND_MAX - on Windows and FreeBSD. ---*/ -int __cdecl PAL_rand(void); - -/*++ -Function : - - PAL_time ---*/ -PAL_time_t __cdecl PAL_time(PAL_time_t*); - /*++ Function : MsgBoxInitialize diff --git a/src/coreclr/pal/src/include/pal/palinternal.h b/src/coreclr/pal/src/include/pal/palinternal.h index 15887d0377382..3fa16f38cfbe7 100644 --- a/src/coreclr/pal/src/include/pal/palinternal.h +++ b/src/coreclr/pal/src/include/pal/palinternal.h @@ -161,190 +161,6 @@ function_name() to call the system's implementation #include "pal_perf.h" #endif -/* C runtime functions needed to be renamed to avoid duplicate definition - of those functions when including standard C header files */ -#define memcpy DUMMY_memcpy -#define memcmp DUMMY_memcmp -#define memset DUMMY_memset -#define memmove DUMMY_memmove -#define memchr DUMMY_memchr -#define atoll DUMMY_atoll -#define strlen DUMMY_strlen -#define stricmp DUMMY_stricmp -#define strstr DUMMY_strstr -#define strcmp DUMMY_strcmp -#define strcat DUMMY_strcat -#define strncat DUMMY_strncat -#define strcpy DUMMY_strcpy -#define strncmp DUMMY_strncmp -#define strncpy DUMMY_strncpy -#define strchr DUMMY_strchr -#define strrchr DUMMY_strrchr -#define strpbrk DUMMY_strpbrk -#define strtod DUMMY_strtod -#define strtoul DUMMY_strtoul -#define strtoull DUMMY_strtoull -#define strnlen DUMMY_strnlen -#define strcasecmp DUMMY_strcasecmp -#define strncasecmp DUMMY_strncasecmp -#define strdup DUMMY_strdup -#define strtok_r DUMMY_strtok_r -#define tolower DUMMY_tolower -#define toupper DUMMY_toupper -#define isprint DUMMY_isprint -#define isdigit DUMMY_isdigit -#define iswalpha DUMMY_iswalpha -#define iswdigit DUMMY_iswdigit -#define iswupper DUMMY_iswupper -#define towupper DUMMY_towupper -#define towlower DUMMY_towlower -#define iswprint DUMMY_iswprint -#define iswspace DUMMY_iswspace -#define iswxdigit DUMMY_iswxdigit -#define wint_t DUMMY_wint_t -#define srand DUMMY_srand -#define atoi DUMMY_atoi -#define atof DUMMY_atof -#define size_t DUMMY_size_t -#define time_t PAL_time_t -#define va_list DUMMY_va_list -#define abs DUMMY_abs -#define llabs DUMMY_llabs -#define ceil DUMMY_ceil -#define cos DUMMY_cos -#define cosh DUMMY_cosh -#define fabs DUMMY_fabs -#define floor DUMMY_floor -#define fmod DUMMY_fmod -#define modf DUMMY_modf -#define sin DUMMY_sin -#define sinh DUMMY_sinh -#define sqrt DUMMY_sqrt -#define tan DUMMY_tan -#define tanh DUMMY_tanh -#define trunc DUMMY_trunc -#define ceilf DUMMY_ceilf -#define cosf DUMMY_cosf -#define coshf DUMMY_coshf -#define fabsf DUMMY_fabsf -#define floorf DUMMY_floorf -#define fmodf DUMMY_fmodf -#define modff DUMMY_modff -#define sinf DUMMY_sinf -#define sinhf DUMMY_sinhf -#define sqrtf DUMMY_sqrtf -#define tanf DUMMY_tanf -#define tanhf DUMMY_tanhf -#define truncf DUMMY_truncf -#define acos DUMMMY_acos -#define asin DUMMMY_asin -#define atan2 DUMMMY_atan2 -#define exp DUMMMY_exp -#define ilogb DUMMMY_ilogb -#define log DUMMMY_log -#define log10 DUMMMY_log10 -#define pow DUMMMY_pow -#define sincos DUMMMY_sincos -#define acosf DUMMMY_acosf -#define asinf DUMMMY_asinf -#define atan2f DUMMMY_atan2f -#define expf DUMMMY_expf -#define ilogbf DUMMMY_ilogbf -#define logf DUMMMY_logf -#define log10f DUMMMY_log10f -#define powf DUMMMY_powf -#define sincosf DUMMMY_sincosf -#define copysign DUMMY_copysign -#define copysignf DUMMY_copysignf -#define remove DUMMY_remove -#define printf DUMMY_printf -#define vprintf DUMMY_vprintf -#define fopen DUMMY_fopen -#define setvbuf DUMMY_setvbuf -#define fprintf DUMMY_fprintf -#define vfprintf DUMMY_vfprintf -#define fgets DUMMY_fgets -#define ferror DUMMY_ferror -#define fread DUMMY_fread -#define fwrite DUMMY_fwrite -#define ftell DUMMY_ftell -#define fclose DUMMY_fclose -#define fflush DUMMY_fflush -#define fputs DUMMY_fputs -#define fseek DUMMY_fseek -#define fgetpos DUMMY_fgetpos -#define fsetpos DUMMY_fsetpos - -/* RAND_MAX needed to be renamed to avoid duplicate definition when including - stdlib.h header files. PAL_RAND_MAX should have the same value as RAND_MAX - defined in pal.h */ -#define PAL_RAND_MAX 0x7fff - -/* The standard headers define isspace and isxdigit as macros and functions, - To avoid redefinition problems, undefine those macros. */ -#ifdef isspace -#undef isspace -#endif -#ifdef isxdigit -#undef isxdigit -#endif -#ifdef isalpha -#undef isalpha -#endif -#ifdef isalnum -#undef isalnum -#endif -#define isspace DUMMY_isspace -#define isxdigit DUMMY_isxdigit -#define isalpha DUMMY_isalpha -#define isalnum DUMMY_isalnum - -#ifdef stdin -#undef stdin -#endif -#ifdef stdout -#undef stdout -#endif -#ifdef stderr -#undef stderr -#endif - -#ifdef SCHAR_MIN -#undef SCHAR_MIN -#endif -#ifdef SCHAR_MAX -#undef SCHAR_MAX -#endif -#ifdef SHRT_MIN -#undef SHRT_MIN -#endif -#ifdef SHRT_MAX -#undef SHRT_MAX -#endif -#ifdef UCHAR_MAX -#undef UCHAR_MAX -#endif -#ifdef USHRT_MAX -#undef USHRT_MAX -#endif -#ifdef ULONG_MAX -#undef ULONG_MAX -#endif -#ifdef LONG_MIN -#undef LONG_MIN -#endif -#ifdef LONG_MAX -#undef LONG_MAX -#endif -#ifdef RAND_MAX -#undef RAND_MAX -#endif -#ifdef DBL_MAX -#undef DBL_MAX -#endif -#ifdef FLT_MAX -#undef FLT_MAX -#endif #ifdef __record_type_class #undef __record_type_class #endif @@ -352,24 +168,6 @@ function_name() to call the system's implementation #undef __real_type_class #endif -// The standard headers define va_start and va_end as macros, -// To avoid redefinition problems, undefine those macros. -#ifdef va_start -#undef va_start -#endif -#ifdef va_end -#undef va_end -#endif -#ifdef va_copy -#undef va_copy -#endif - -#define ptrdiff_t PAL_ptrdiff_t -#define intptr_t PAL_intptr_t -#define uintptr_t PAL_uintptr_t -#define timeval PAL_timeval - -#define DEFINE_DUMMY_FILE_TYPE #include "pal.h" #include "palprivate.h" @@ -386,222 +184,6 @@ function_name() to call the system's implementation #undef _BitScanReverse64 #endif -/* pal.h defines alloca(3) as a compiler builtin. - Redefining it to native libc will result in undefined breakage because - a compiler is allowed to make assumptions about the stack and frame - pointers. */ - -/* Undef all functions and types previously defined so those functions and - types could be mapped to the C runtime and socket implementation of the - native OS */ -#undef exit -#undef memcpy -#undef memcmp -#undef memset -#undef memmove -#undef memchr -#undef atoll -#undef strlen -#undef strnlen -#undef wcsnlen -#undef stricmp -#undef strstr -#undef strcmp -#undef strcat -#undef strncat -#undef strcpy -#undef strncmp -#undef strncpy -#undef strchr -#undef strrchr -#undef strpbrk -#undef strtoul -#undef strtoull -#undef strcasecmp -#undef strncasecmp -#undef strdup -#undef strtod -#undef strtok_r -#undef strdup -#undef tolower -#undef toupper -#undef isprint -#undef isdigit -#undef isspace -#undef iswdigit -#undef iswxdigit -#undef iswalpha -#undef iswprint -#undef isxdigit -#undef isalpha -#undef isalnum -#undef iswalpha -#undef iswdigit -#undef iswupper -#undef towupper -#undef towlower -#undef wint_t -#undef atoi -#undef atof -#undef malloc -#undef realloc -#undef free -#undef qsort -#undef bsearch -#undef time -#undef fclose -#undef fopen -#undef fread -#undef ferror -#undef ftell -#undef fflush -#undef fwrite -#undef fgets -#undef fputs -#undef fseek -#undef fgetpos -#undef fsetpos -#undef getcwd -#undef setvbuf -#undef unlink -#undef size_t -#undef time_t -#undef va_list -#undef va_start -#undef va_end -#undef va_copy -#undef va_arg -#undef stdin -#undef stdout -#undef stderr -#undef abs -#undef llabs -#undef acos -#undef acosh -#undef asin -#undef asinh -#undef atan -#undef atanh -#undef atan2 -#undef cbrt -#undef ceil -#undef cos -#undef cosh -#undef exp -#undef fabs -#undef floor -#undef fmod -#undef fma -#undef ilogb -#undef log -#undef log2 -#undef log10 -#undef modf -#undef pow -#undef sin -#undef sincos -#undef copysign -#undef sinh -#undef sqrt -#undef tan -#undef tanh -#undef trunc -#undef acosf -#undef acoshf -#undef asinf -#undef asinhf -#undef atanf -#undef atanhf -#undef atan2f -#undef cbrtf -#undef ceilf -#undef cosf -#undef coshf -#undef expf -#undef fabsf -#undef floorf -#undef fmodf -#undef fmaf -#undef ilogbf -#undef logf -#undef log2f -#undef log10f -#undef modff -#undef powf -#undef sinf -#undef sincosf -#undef copysignf -#undef sinhf -#undef sqrtf -#undef tanf -#undef tanhf -#undef truncf -#undef acos -#undef asin -#undef atan2 -#undef exp -#undef ilogb -#undef log -#undef log10 -#undef pow -#undef sincos -#undef acosf -#undef asinf -#undef atan2f -#undef expf -#undef ilogbf -#undef logf -#undef log10f -#undef powf -#undef sincosf -#undef rand -#undef srand -#undef errno -#undef getenv -#undef open -#undef glob -#undef remove -#undef printf -#undef vprintf -#undef ptrdiff_t -#undef intptr_t -#undef uintptr_t -#undef timeval - -#undef fprintf -#undef vfprintf -#undef iswupper -#undef iswspace -#undef towlower -#undef towupper - -#ifdef HOST_AMD64 -#undef _mm_getcsr -#undef _mm_setcsr -#endif // HOST_AMD64 - -#undef min -#undef max - -#undef SCHAR_MIN -#undef SCHAR_MAX -#undef UCHAR_MAX -#undef SHRT_MIN -#undef SHRT_MAX -#undef USHRT_MAX -#undef LONG_MIN -#undef LONG_MAX -#undef ULONG_MAX -#undef RAND_MAX -#undef DBL_MAX -#undef FLT_MAX -#undef __record_type_class -#undef __real_type_class - -#if HAVE_CHAR_BIT -#undef CHAR_BIT -#endif - // We need a sigsetjmp prototype in pal.h for the SEH macros, but we // can't use the "real" prototype (because we don't want to define sigjmp_buf). // So we must rename the "real" sigsetjmp to avoid redefinition errors. @@ -623,18 +205,6 @@ function_name() to call the system's implementation // https://gcc.gnu.org/ml/libstdc++/2016-01/msg00025.html #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS 1 -#define _WITH_GETLINE -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifdef __APPLE__ #undef GetCurrentThread diff --git a/src/coreclr/pal/src/include/pal/stackstring.hpp b/src/coreclr/pal/src/include/pal/stackstring.hpp index 4a27a15579c7d..22e79a571502a 100644 --- a/src/coreclr/pal/src/include/pal/stackstring.hpp +++ b/src/coreclr/pal/src/include/pal/stackstring.hpp @@ -21,7 +21,7 @@ class StackString void DeleteBuffer() { if (m_innerBuffer != m_buffer) - PAL_free(m_buffer); + free(m_buffer); m_buffer = NULL; return; @@ -44,7 +44,7 @@ class StackString m_buffer = NULL; } - T * newBuffer = (T *)PAL_realloc(m_buffer, (count_allocated + 1) * sizeof(T)); + T * newBuffer = (T *)realloc(m_buffer, (count_allocated + 1) * sizeof(T)); if (NULL == newBuffer) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); diff --git a/src/coreclr/pal/src/include/pal/utils.h b/src/coreclr/pal/src/include/pal/utils.h index fdd5b3b965a16..980cdf56ab6c6 100644 --- a/src/coreclr/pal/src/include/pal/utils.h +++ b/src/coreclr/pal/src/include/pal/utils.h @@ -194,7 +194,7 @@ class StringHolder StringHolder() : data(NULL) { } ~StringHolder() { - PAL_free( data); + free( data); } operator LPSTR () { return data;} diff --git a/src/coreclr/pal/src/init/pal.cpp b/src/coreclr/pal/src/init/pal.cpp index 9d0c82ac4ae53..67fcbb92bd251 100644 --- a/src/coreclr/pal/src/init/pal.cpp +++ b/src/coreclr/pal/src/init/pal.cpp @@ -1170,7 +1170,7 @@ static LPWSTR INIT_FormatCommandLine (int argc, const char * const *argv) length+=3; length+=strlen(argv[i])*2; } - command_line = reinterpret_cast(InternalMalloc(length)); + command_line = reinterpret_cast(malloc(length != 0 ? length : 1)); if(!command_line) { @@ -1222,7 +1222,7 @@ static LPWSTR INIT_FormatCommandLine (int argc, const char * const *argv) return nullptr; } - retval = reinterpret_cast(InternalMalloc((sizeof(WCHAR)*i))); + retval = reinterpret_cast(malloc((sizeof(WCHAR)*i))); if(retval == nullptr) { ERROR("can't allocate memory for Unicode command line!\n"); @@ -1278,7 +1278,7 @@ static LPWSTR INIT_GetCurrentEXEPath() return nullptr; } - return_value = reinterpret_cast(InternalMalloc((return_size*sizeof(WCHAR)))); + return_value = reinterpret_cast(malloc((return_size*sizeof(WCHAR)))); if (nullptr == return_value) { ERROR("Not enough memory to create full path\n"); diff --git a/src/coreclr/pal/src/loader/module.cpp b/src/coreclr/pal/src/loader/module.cpp index f0651d3bad586..0cda5045e01ef 100644 --- a/src/coreclr/pal/src/loader/module.cpp +++ b/src/coreclr/pal/src/loader/module.cpp @@ -1548,7 +1548,7 @@ static MODSTRUCT *LOADAllocModule(NATIVE_LIBRARY_HANDLE dl_handle, LPCSTR name) LPWSTR wide_name; /* no match found : try to create a new module structure */ - module = (MODSTRUCT *)InternalMalloc(sizeof(MODSTRUCT)); + module = (MODSTRUCT *)malloc(sizeof(MODSTRUCT)); if (nullptr == module) { ERROR("malloc() failed! errno is %d (%s)\n", errno, strerror(errno)); @@ -1805,11 +1805,11 @@ MODSTRUCT *LOADGetPalLibrary() if (g_szCoreCLRPath == nullptr) { size_t cbszCoreCLRPath = strlen(info.dli_fname) + 1; - g_szCoreCLRPath = (char*) InternalMalloc(cbszCoreCLRPath); + g_szCoreCLRPath = (char*) malloc(cbszCoreCLRPath); if (g_szCoreCLRPath == nullptr) { - ERROR("LOADGetPalLibrary: InternalMalloc failed!"); + ERROR("LOADGetPalLibrary: malloc failed!"); goto exit; } diff --git a/src/coreclr/pal/src/map/map.cpp b/src/coreclr/pal/src/map/map.cpp index 707284b58fad9..4f8cb6190c6d9 100644 --- a/src/coreclr/pal/src/map/map.cpp +++ b/src/coreclr/pal/src/map/map.cpp @@ -35,6 +35,7 @@ Module Name: #include #include #include +#include #include #include "rt/ntimage.h" @@ -1128,7 +1129,7 @@ CorUnix::InternalMapViewOfFile( // the global list. // - PMAPPED_VIEW_LIST pNewView = (PMAPPED_VIEW_LIST)InternalMalloc(sizeof(*pNewView)); + PMAPPED_VIEW_LIST pNewView = (PMAPPED_VIEW_LIST)malloc(sizeof(*pNewView)); if (NULL != pNewView) { pNewView->lpAddress = pvBaseAddress; @@ -1832,7 +1833,7 @@ static PMAPPED_VIEW_LIST FindSharedMappingReplacement( /* The new desired mapping is fully contained in the one just found: we can reuse this one */ - pNewView = (PMAPPED_VIEW_LIST)InternalMalloc(sizeof(MAPPED_VIEW_LIST)); + pNewView = (PMAPPED_VIEW_LIST)malloc(sizeof(MAPPED_VIEW_LIST)); if (pNewView) { memcpy(pNewView, pView, sizeof(*pNewView)); @@ -1867,7 +1868,7 @@ static NativeMapHolder * NewNativeMapHolder(CPalThread *pThread, LPVOID address, } pThisMapHolder = - (NativeMapHolder *)InternalMalloc(sizeof(NativeMapHolder)); + (NativeMapHolder *)malloc(sizeof(NativeMapHolder)); if (pThisMapHolder) { @@ -1933,7 +1934,7 @@ MAPRecordMapping( PAL_ERROR palError = NO_ERROR; PMAPPED_VIEW_LIST pNewView; - pNewView = (PMAPPED_VIEW_LIST)InternalMalloc(sizeof(*pNewView)); + pNewView = (PMAPPED_VIEW_LIST)malloc(sizeof(*pNewView)); if (NULL != pNewView) { pNewView->lpAddress = addr; diff --git a/src/coreclr/pal/src/map/virtual.cpp b/src/coreclr/pal/src/map/virtual.cpp index 364f3bba1f025..3145faac5f505 100644 --- a/src/coreclr/pal/src/map/virtual.cpp +++ b/src/coreclr/pal/src/map/virtual.cpp @@ -401,7 +401,7 @@ static BOOL VIRTUALStoreAllocationInfo( return FALSE; } - if (!(pNewEntry = (PCMI)InternalMalloc(sizeof(*pNewEntry)))) + if (!(pNewEntry = (PCMI)malloc(sizeof(*pNewEntry)))) { ERROR( "Unable to allocate memory for the structure.\n"); return FALSE; diff --git a/src/coreclr/pal/src/misc/cgroup.cpp b/src/coreclr/pal/src/misc/cgroup.cpp index f23ff4c970fe9..ecdbccf2ee669 100644 --- a/src/coreclr/pal/src/misc/cgroup.cpp +++ b/src/coreclr/pal/src/misc/cgroup.cpp @@ -54,7 +54,7 @@ class CGroup static void Cleanup() { - PAL_free(s_cpu_cgroup_path); + free(s_cpu_cgroup_path); } static bool GetCpuLimit(UINT *val) @@ -129,7 +129,7 @@ class CGroup len = strlen(hierarchy_mount); len += strlen(cgroup_path_relative_to_mount); - cgroup_path = (char*)PAL_malloc(len+1); + cgroup_path = (char*)malloc(len+1); if (cgroup_path == nullptr) goto done; @@ -160,8 +160,8 @@ class CGroup strcat_s(cgroup_path, len+1, cgroup_path_relative_to_mount + common_path_prefix_len); done: - PAL_free(hierarchy_root); - PAL_free(cgroup_path_relative_to_mount); + free(hierarchy_root); + free(cgroup_path_relative_to_mount); *pcgroup_path = cgroup_path; if (pcgroup_hierarchy_mount != nullptr) { @@ -169,7 +169,7 @@ class CGroup } else { - PAL_free(hierarchy_mount); + free(hierarchy_mount); } } @@ -190,14 +190,14 @@ class CGroup { if (filesystemType == nullptr || lineLen > maxLineLen) { - PAL_free(filesystemType); + free(filesystemType); filesystemType = nullptr; - PAL_free(options); + free(options); options = nullptr; - filesystemType = (char*)PAL_malloc(lineLen+1); + filesystemType = (char*)malloc(lineLen+1); if (filesystemType == nullptr) goto done; - options = (char*)PAL_malloc(lineLen+1); + options = (char*)malloc(lineLen+1); if (options == nullptr) goto done; maxLineLen = lineLen; @@ -230,10 +230,10 @@ class CGroup } if (isSubsystemMatch) { - mountpath = (char*)PAL_malloc(lineLen+1); + mountpath = (char*)malloc(lineLen+1); if (mountpath == nullptr) goto done; - mountroot = (char*)PAL_malloc(lineLen+1); + mountroot = (char*)malloc(lineLen+1); if (mountroot == nullptr) goto done; @@ -252,10 +252,10 @@ class CGroup } } done: - PAL_free(mountpath); - PAL_free(mountroot); - PAL_free(filesystemType); - PAL_free(options); + free(mountpath); + free(mountroot); + free(filesystemType); + free(options); free(line); if (mountinfofile) fclose(mountinfofile); @@ -278,14 +278,14 @@ class CGroup { if (subsystem_list == nullptr || lineLen > maxLineLen) { - PAL_free(subsystem_list); + free(subsystem_list); subsystem_list = nullptr; - PAL_free(cgroup_path); + free(cgroup_path); cgroup_path = nullptr; - subsystem_list = (char*)PAL_malloc(lineLen+1); + subsystem_list = (char*)malloc(lineLen+1); if (subsystem_list == nullptr) goto done; - cgroup_path = (char*)PAL_malloc(lineLen+1); + cgroup_path = (char*)malloc(lineLen+1); if (cgroup_path == nullptr) goto done; maxLineLen = lineLen; @@ -335,10 +335,10 @@ class CGroup } } done: - PAL_free(subsystem_list); + free(subsystem_list); if (!result) { - PAL_free(cgroup_path); + free(cgroup_path); cgroup_path = nullptr; } free(line); diff --git a/src/coreclr/pal/src/misc/environ.cpp b/src/coreclr/pal/src/misc/environ.cpp index a31d6b177760b..4980d213fa3bc 100644 --- a/src/coreclr/pal/src/misc/environ.cpp +++ b/src/coreclr/pal/src/misc/environ.cpp @@ -183,7 +183,7 @@ GetEnvironmentVariableW( goto done; } - inBuff = (CHAR *)PAL_malloc(inBuffSize); + inBuff = (CHAR *)malloc(inBuffSize); if (inBuff == nullptr) { ERROR("malloc failed\n"); @@ -193,7 +193,7 @@ GetEnvironmentVariableW( if (nSize) { - outBuff = (CHAR *)PAL_malloc(nSize*2); + outBuff = (CHAR *)malloc(nSize*2); if (outBuff == nullptr) { ERROR("malloc failed\n"); @@ -243,8 +243,8 @@ GetEnvironmentVariableW( } done: - PAL_free(outBuff); - PAL_free(inBuff); + free(outBuff); + free(inBuff); LOGEXIT("GetEnvironmentVariableW returns DWORD 0x%x\n", size); PERF_EXIT(GetEnvironmentVariableW); @@ -310,7 +310,7 @@ SetEnvironmentVariableW( goto done; } - name = (PCHAR)PAL_malloc(sizeof(CHAR)* nameSize); + name = (PCHAR)malloc(sizeof(CHAR)* nameSize); if (name == nullptr) { ERROR("malloc failed\n"); @@ -336,7 +336,7 @@ SetEnvironmentVariableW( goto done; } - value = (PCHAR)PAL_malloc(sizeof(CHAR)*valueSize); + value = (PCHAR)malloc(sizeof(CHAR)*valueSize); if (value == nullptr) { @@ -356,8 +356,8 @@ SetEnvironmentVariableW( bRet = SetEnvironmentVariableA(name, value); done: - PAL_free(value); - PAL_free(name); + free(value); + free(name); LOGEXIT("SetEnvironmentVariableW returning BOOL %d\n", bRet); PERF_EXIT(SetEnvironmentVariableW); @@ -414,7 +414,7 @@ GetEnvironmentStringsW( envNum += len; } - wenviron = (WCHAR *)PAL_malloc(sizeof(WCHAR)* (envNum + 1)); + wenviron = (WCHAR *)malloc(sizeof(WCHAR)* (envNum + 1)); if (wenviron == nullptr) { ERROR("malloc failed\n"); @@ -476,7 +476,7 @@ FreeEnvironmentStringsW( if (lpValue != nullptr) { - PAL_free(lpValue); + free(lpValue); } LOGEXIT("FreeEnvironmentStringW returning BOOL TRUE\n"); @@ -559,7 +559,7 @@ SetEnvironmentVariableA( { // All the conditions are met. Set the variable. int iLen = strlen(lpName) + strlen(lpValue) + 2; - LPSTR string = (LPSTR) PAL_malloc(iLen); + LPSTR string = (LPSTR) malloc(iLen); if (string == nullptr) { bRet = FALSE; @@ -571,7 +571,7 @@ SetEnvironmentVariableA( sprintf_s(string, iLen, "%s=%s", lpName, lpValue); nResult = EnvironPutenv(string, FALSE) ? 0 : -1; - PAL_free(string); + free(string); string = nullptr; // If EnvironPutenv returns FALSE, it almost certainly failed to allocate memory. diff --git a/src/coreclr/pal/src/misc/fmtmessage.cpp b/src/coreclr/pal/src/misc/fmtmessage.cpp index c7de98718c1d3..0598914b06cb5 100644 --- a/src/coreclr/pal/src/misc/fmtmessage.cpp +++ b/src/coreclr/pal/src/misc/fmtmessage.cpp @@ -61,7 +61,7 @@ static LPWSTR FMTMSG_GetMessageString( DWORD dwErrCode ) allocChars = MAX_ERROR_STRING_LENGTH + 1; } - LPWSTR lpRetVal = (LPWSTR)PAL_malloc(allocChars * sizeof(WCHAR)); + LPWSTR lpRetVal = (LPWSTR)malloc(allocChars * sizeof(WCHAR)); if (lpRetVal) { @@ -140,7 +140,7 @@ static INT FMTMSG__watoi( LPWSTR str ) UINT NumOfBytes = 0; \ nSize *= 2; \ NumOfBytes = nSize * sizeof( WCHAR ); \ - lpTemp = static_cast( PAL_malloc( NumOfBytes ) ); \ + lpTemp = static_cast( malloc( NumOfBytes ) ); \ TRACE( "Growing the buffer.\n" );\ \ if ( !lpTemp ) \ @@ -327,7 +327,7 @@ FormatMessageW( } lpWorkingString = static_cast( - PAL_malloc( nSize * sizeof( WCHAR ) ) ); + malloc( nSize * sizeof( WCHAR ) ) ); if ( !lpWorkingString ) { ERROR( "Unable to allocate memory for the working string.\n" ); diff --git a/src/coreclr/pal/src/misc/miscpalapi.cpp b/src/coreclr/pal/src/misc/miscpalapi.cpp index 06129210ef9c9..f0d32f0388e86 100644 --- a/src/coreclr/pal/src/misc/miscpalapi.cpp +++ b/src/coreclr/pal/src/misc/miscpalapi.cpp @@ -29,6 +29,7 @@ Revision History: #include #include +#include #include #include #include diff --git a/src/coreclr/pal/src/misc/perftrace.cpp b/src/coreclr/pal/src/misc/perftrace.cpp index a0d52a415017b..9419005099f41 100644 --- a/src/coreclr/pal/src/misc/perftrace.cpp +++ b/src/coreclr/pal/src/misc/perftrace.cpp @@ -321,7 +321,7 @@ PERFInitialize(LPWSTR command_line, LPWSTR exe_path) if( ret == TRUE ) { - pal_function_map = (char*)PAL_malloc(PAL_API_NUMBER); + pal_function_map = (char*)malloc(PAL_API_NUMBER); if(pal_function_map != NULL) { bRead = PERFReadSetting( ); // we don't quit even we failed to read the file. @@ -355,7 +355,7 @@ void PERFTerminate( ) PERFlushAllLogs(); pthread_key_delete(PERF_tlsTableKey ); - PAL_free(pal_function_map); + free(pal_function_map); } @@ -376,21 +376,21 @@ BOOL PERFAllocThreadInfo( ) memory resources could be exhausted. If this ever becomes a problem, the memory allocated per thread should be freed when a thread exits. */ - node = ( pal_thread_list_node * )PAL_malloc(sizeof(pal_thread_list_node)); + node = ( pal_thread_list_node * )malloc(sizeof(pal_thread_list_node)); if(node == NULL) { ret = FALSE; goto PERFAllocThreadInfoExit; } - local_info = (pal_perf_thread_info *)PAL_malloc(sizeof(pal_perf_thread_info)); + local_info = (pal_perf_thread_info *)malloc(sizeof(pal_perf_thread_info)); if (local_info == NULL) { ret = FALSE; goto PERFAllocThreadInfoExit; } - apiTable = (pal_perf_api_info *)PAL_malloc( PAL_API_NUMBER * sizeof(pal_perf_api_info)); + apiTable = (pal_perf_api_info *)malloc( PAL_API_NUMBER * sizeof(pal_perf_api_info)); if (apiTable == NULL) { ret = FALSE; @@ -411,7 +411,7 @@ BOOL PERFAllocThreadInfo( ) apiTable[i].sum_of_square_duration = 0.0; if (pal_perf_histogram_size > 0) { - apiTable[i].histograms = (DWORD *)PAL_malloc(pal_perf_histogram_size*sizeof(DWORD)); + apiTable[i].histograms = (DWORD *)malloc(pal_perf_histogram_size*sizeof(DWORD)); if (apiTable[i].histograms == NULL) { ret = FALSE; @@ -425,7 +425,7 @@ BOOL PERFAllocThreadInfo( ) } } - log_buf = (char * )PAL_malloc( PAL_PERF_PROFILE_BUFFER_SIZE ); + log_buf = (char * )malloc( PAL_PERF_PROFILE_BUFFER_SIZE ); if(log_buf == NULL) { @@ -454,11 +454,11 @@ BOOL PERFAllocThreadInfo( ) { if (node != NULL) { - PAL_free(node); + free(node); } if (local_info != NULL) { - PAL_free(local_info); + free(local_info); } if (apiTable != NULL) { @@ -466,14 +466,14 @@ BOOL PERFAllocThreadInfo( ) { if (apiTable[i].histograms != NULL) { - PAL_free(apiTable[i].histograms); + free(apiTable[i].histograms); } } - PAL_free(apiTable); + free(apiTable); } if (log_buf != NULL) { - PAL_free(log_buf); + free(log_buf); } } return ret; @@ -554,26 +554,26 @@ PERFlushAllLogs( ) PERFUpdateProgramInfo(current->thread_info); if (table1->histograms != NULL) { - PAL_free(table1->histograms); + free(table1->histograms); } - PAL_free(table1); + free(table1); } PERFFlushLog(current->thread_info, FALSE); - PAL_free(current->thread_info->pal_write_buf); - PAL_free(current->thread_info); + free(current->thread_info->pal_write_buf); + free(current->thread_info); } - PAL_free(current); + free(current); } PERFWriteCounters(table0); if (table0->histograms != NULL) { - PAL_free(table0->histograms); + free(table0->histograms); } - PAL_free(table0); + free(table0); PERFFlushLog(node->thread_info, FALSE); - PAL_free(node->thread_info->pal_write_buf); - PAL_free(node->thread_info); - PAL_free(node); + free(node->thread_info->pal_write_buf); + free(node->thread_info); + free(node); } static diff --git a/src/coreclr/pal/src/misc/strutil.cpp b/src/coreclr/pal/src/misc/strutil.cpp index ed29831232cab..e665e22b65291 100644 --- a/src/coreclr/pal/src/misc/strutil.cpp +++ b/src/coreclr/pal/src/misc/strutil.cpp @@ -53,7 +53,7 @@ CPalString::CopyString( _ASSERTE(psSource->GetMaxLength() > psSource->GetStringLength()); WCHAR *pwsz = reinterpret_cast( - InternalMalloc(psSource->GetMaxLength() * sizeof(WCHAR)) + malloc(psSource->GetMaxLength() * sizeof(WCHAR)) ); if (NULL != pwsz) diff --git a/src/coreclr/pal/src/misc/utils.cpp b/src/coreclr/pal/src/misc/utils.cpp index 0d96cc991305a..261be25bcabaa 100644 --- a/src/coreclr/pal/src/misc/utils.cpp +++ b/src/coreclr/pal/src/misc/utils.cpp @@ -190,7 +190,7 @@ LPSTR UTIL_WCToMB_Alloc(LPCWSTR lpWideCharStr, int cchWideChar) } /* allocate required buffer */ - lpMultiByteStr = (LPSTR)PAL_malloc(length); + lpMultiByteStr = (LPSTR)malloc(length); if(NULL == lpMultiByteStr) { ERROR("malloc() failed! errno is %d (%s)\n", errno,strerror(errno)); @@ -204,7 +204,7 @@ LPSTR UTIL_WCToMB_Alloc(LPCWSTR lpWideCharStr, int cchWideChar) if(0 == length) { ASSERT("WCToMB error; GetLastError returns %#x\n", GetLastError()); - PAL_free(lpMultiByteStr); + free(lpMultiByteStr); return NULL; } return lpMultiByteStr; @@ -250,7 +250,7 @@ LPWSTR UTIL_MBToWC_Alloc(LPCSTR lpMultiByteStr, int cbMultiByte) return NULL; } - lpWideCharStr = (LPWSTR)PAL_malloc(fullsize); + lpWideCharStr = (LPWSTR)malloc(fullsize); if(NULL == lpWideCharStr) { ERROR("malloc() failed! errno is %d (%s)\n", errno,strerror(errno)); @@ -264,7 +264,7 @@ LPWSTR UTIL_MBToWC_Alloc(LPCSTR lpMultiByteStr, int cbMultiByte) if(0 >= length) { ASSERT("MCToMB error; GetLastError returns %#x\n", GetLastError()); - PAL_free(lpWideCharStr); + free(lpWideCharStr); return NULL; } return lpWideCharStr; diff --git a/src/coreclr/pal/src/objmgr/palobjbase.cpp b/src/coreclr/pal/src/objmgr/palobjbase.cpp index dbfdf3b0c7156..c39b5df7e268f 100644 --- a/src/coreclr/pal/src/objmgr/palobjbase.cpp +++ b/src/coreclr/pal/src/objmgr/palobjbase.cpp @@ -58,7 +58,7 @@ CPalObjectBase::Initialize( if (0 != m_pot->GetImmutableDataSize()) { - m_pvImmutableData = InternalMalloc(m_pot->GetImmutableDataSize()); + m_pvImmutableData = malloc(m_pot->GetImmutableDataSize()); if (NULL != m_pvImmutableData) { ZeroMemory(m_pvImmutableData, m_pot->GetImmutableDataSize()); @@ -80,7 +80,7 @@ CPalObjectBase::Initialize( goto InitializeExit; } - m_pvLocalData = InternalMalloc(m_pot->GetProcessLocalDataSize()); + m_pvLocalData = malloc(m_pot->GetProcessLocalDataSize()); if (NULL != m_pvLocalData) { ZeroMemory(m_pvLocalData, m_pot->GetProcessLocalDataSize()); diff --git a/src/coreclr/pal/src/objmgr/shmobject.cpp b/src/coreclr/pal/src/objmgr/shmobject.cpp index 55b0e87c088a1..282dd113da2e2 100644 --- a/src/coreclr/pal/src/objmgr/shmobject.cpp +++ b/src/coreclr/pal/src/objmgr/shmobject.cpp @@ -119,7 +119,7 @@ CSharedMemoryObject::Initialize( // Allocate local memory to hold the shared data // - m_pvSharedData = InternalMalloc(m_pot->GetSharedDataSize()); + m_pvSharedData = malloc(m_pot->GetSharedDataSize()); if (NULL == m_pvSharedData) { ERROR("Failure allocating m_pvSharedData (local copy)\n"); diff --git a/src/coreclr/pal/src/safecrt/input.inl b/src/coreclr/pal/src/safecrt/input.inl index 9934eeb33f54f..556fafa6f6b4f 100644 --- a/src/coreclr/pal/src/safecrt/input.inl +++ b/src/coreclr/pal/src/safecrt/input.inl @@ -46,9 +46,9 @@ #define _istspace(x) isspace((unsigned char)x) -#define _malloc_crt PAL_malloc -#define _realloc_crt PAL_realloc -#define _free_crt PAL_free +#define _malloc_crt malloc +#define _realloc_crt realloc +#define _free_crt free #define _FASSIGN(flag, argument, number, dec_point, locale) _safecrt_fassign((flag), (argument), (number)) #define _WFASSIGN(flag, argument, number, dec_point, locale) _safecrt_wfassign((flag), (argument), (number)) diff --git a/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp b/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp index ea5aae444dad0..ba9447b889c39 100644 --- a/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp +++ b/src/coreclr/pal/src/sharedmemory/sharedmemory.cpp @@ -139,7 +139,7 @@ const UINT64 SharedMemoryHelpers::InvalidSharedThreadId = static_cast(-1 void *SharedMemoryHelpers::Alloc(SIZE_T byteCount) { - void *buffer = InternalMalloc(byteCount); + void *buffer = malloc(byteCount != 0 ? byteCount : 1); if (buffer == nullptr) { throw SharedMemoryException(static_cast(SharedMemoryError::OutOfMemory)); diff --git a/src/coreclr/pal/src/synchmgr/synchmanager.cpp b/src/coreclr/pal/src/synchmgr/synchmanager.cpp index c34aa4e27fc8c..c6b0b3db1cfd6 100644 --- a/src/coreclr/pal/src/synchmgr/synchmanager.cpp +++ b/src/coreclr/pal/src/synchmgr/synchmanager.cpp @@ -28,6 +28,7 @@ SET_DEFAULT_DEBUG_CHANNEL(SYNC); // some headers have code with asserts, so do t #include #include #include +#include #include #include #include diff --git a/src/coreclr/pal/src/synchmgr/synchmanager.hpp b/src/coreclr/pal/src/synchmgr/synchmanager.hpp index 925b896e7e572..ce325f75ecc1e 100644 --- a/src/coreclr/pal/src/synchmgr/synchmanager.hpp +++ b/src/coreclr/pal/src/synchmgr/synchmanager.hpp @@ -496,7 +496,7 @@ namespace CorUnix class CPalSynchronizationManager : public IPalSynchronizationManager { friend class CPalSynchMgrController; - template friend T *CorUnix::InternalNew(); + template friend T *CorUnix::InternalNew(Ts... args); public: // types diff --git a/src/coreclr/pal/src/thread/process.cpp b/src/coreclr/pal/src/thread/process.cpp index 757ed25ade1d6..033996645cb5e 100644 --- a/src/coreclr/pal/src/thread/process.cpp +++ b/src/coreclr/pal/src/thread/process.cpp @@ -44,6 +44,7 @@ SET_DEFAULT_DEBUG_CHANNEL(PROCESS); // some headers have code with asserts, so d #endif // HAVE_POLL #include +#include #include #include #include @@ -84,6 +85,7 @@ SET_DEFAULT_DEBUG_CHANNEL(PROCESS); // some headers have code with asserts, so d #ifdef __APPLE__ #include +#include #include #include #include @@ -732,7 +734,7 @@ CorUnix::InternalCreateProcess( } } EnvironmentEntries++; - EnvironmentArray = (char **)InternalMalloc(EnvironmentEntries * sizeof(char *)); + EnvironmentArray = (char **)malloc(EnvironmentEntries * sizeof(char *)); EnvironmentEntries = 0; // Convert the environment block to array of strings @@ -2026,7 +2028,7 @@ PROCNotifyProcessShutdownDestructor() char* PROCFormatInt(ULONG32 value) { - char* buffer = (char*)InternalMalloc(128); + char* buffer = (char*)malloc(128); if (buffer != nullptr) { if (sprintf_s(buffer, 128, "%d", value) == -1) @@ -2048,7 +2050,7 @@ PROCFormatInt(ULONG32 value) char* PROCFormatInt64(ULONG64 value) { - char* buffer = (char*)InternalMalloc(128); + char* buffer = (char*)malloc(128); if (buffer != nullptr) { if (sprintf_s(buffer, 128, "%lld", value) == -1) @@ -2087,7 +2089,7 @@ PROCBuildCreateDumpCommandLine( } const char* DumpGeneratorName = "createdump"; int programLen = strlen(g_szCoreCLRPath) + strlen(DumpGeneratorName) + 1; - char* program = *pprogram = (char*)InternalMalloc(programLen); + char* program = *pprogram = (char*)malloc(programLen); if (program == nullptr) { return FALSE; @@ -2833,7 +2835,7 @@ CorUnix::InitializeProcessCommandLine( size_t n = PAL_wcslen(lpwstrFullPath) + 1; size_t iLen = n; - initial_dir = reinterpret_cast(InternalMalloc(iLen*sizeof(WCHAR))); + initial_dir = reinterpret_cast(malloc(iLen*sizeof(WCHAR))); if (NULL == initial_dir) { ERROR("malloc() failed! (initial_dir) \n"); @@ -3760,7 +3762,7 @@ buildArgv( pThread = InternalGetCurrentThread(); /* make sure to allocate enough space, up for the worst case scenario */ int iLength = (iWlen + lpAppPath.GetCount() + 2); - lpAsciiCmdLine = (char *) InternalMalloc(iLength); + lpAsciiCmdLine = (char *) malloc(iLength); if (lpAsciiCmdLine == NULL) { @@ -3940,7 +3942,7 @@ buildArgv( /* allocate lppargv according to the number of arguments in the command line */ - lppArgv = (char **) InternalMalloc((((*pnArg)+1) * sizeof(char *))); + lppArgv = (char **) malloc((((*pnArg)+1) * sizeof(char *))); if (lppArgv == NULL) { diff --git a/src/coreclr/pal/src/thread/thread.cpp b/src/coreclr/pal/src/thread/thread.cpp index 9420a442c1f6a..d388521da1605 100644 --- a/src/coreclr/pal/src/thread/thread.cpp +++ b/src/coreclr/pal/src/thread/thread.cpp @@ -1564,7 +1564,7 @@ CorUnix::InternalSetThreadDescription( goto InternalSetThreadDescriptionExit; } - nameBuf = (char *)PAL_malloc(nameSize); + nameBuf = (char *)malloc(nameSize); if (nameBuf == NULL) { palError = ERROR_OUTOFMEMORY; @@ -1616,7 +1616,7 @@ CorUnix::InternalSetThreadDescription( } if (NULL != nameBuf) { - PAL_free(nameBuf); + free(nameBuf); } #endif //defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) diff --git a/src/coreclr/pal/src/thread/threadsusp.cpp b/src/coreclr/pal/src/thread/threadsusp.cpp index d2fae05c4256f..867f46b3fa38f 100644 --- a/src/coreclr/pal/src/thread/threadsusp.cpp +++ b/src/coreclr/pal/src/thread/threadsusp.cpp @@ -29,6 +29,7 @@ Revision History: #include #include +#include #include #include #include diff --git a/src/coreclr/pal/tests/palsuite/CMakeLists.txt b/src/coreclr/pal/tests/palsuite/CMakeLists.txt index 4b9960f910c5c..3d5dc9a749089 100644 --- a/src/coreclr/pal/tests/palsuite/CMakeLists.txt +++ b/src/coreclr/pal/tests/palsuite/CMakeLists.txt @@ -65,9 +65,6 @@ add_executable_clr(paltests #composite/wfmo/mutex.cpp c_runtime/atof/test1/test1.cpp c_runtime/atoi/test1/test1.cpp - c_runtime/bsearch/test1/test1.cpp - c_runtime/bsearch/test2/test2.cpp - c_runtime/free/test1/test1.cpp c_runtime/isalnum/test1/test1.cpp c_runtime/isalpha/test1/test1.cpp c_runtime/isdigit/test1/test1.cpp @@ -80,16 +77,10 @@ add_executable_clr(paltests c_runtime/iswupper/test1/test1.cpp c_runtime/isxdigit/test1/test1.cpp c_runtime/llabs/test1/test1.cpp - c_runtime/malloc/test1/test1.cpp - c_runtime/malloc/test2/test2.cpp c_runtime/memchr/test1/test1.cpp c_runtime/memcmp/test1/test1.cpp c_runtime/memmove/test1/test1.cpp c_runtime/memset/test1/test1.cpp - c_runtime/qsort/test1/test1.cpp - c_runtime/qsort/test2/test2.cpp - c_runtime/rand_srand/test1/test1.cpp - c_runtime/realloc/test1/test1.cpp c_runtime/sscanf_s/test1/test1.cpp c_runtime/sscanf_s/test10/test10.cpp c_runtime/sscanf_s/test11/test11.cpp @@ -118,7 +109,6 @@ add_executable_clr(paltests c_runtime/strpbrk/test1/test1.cpp c_runtime/strrchr/test1/test1.cpp c_runtime/strstr/test1/test1.cpp - c_runtime/time/test1/test1.cpp c_runtime/tolower/test1/test1.cpp c_runtime/toupper/test1/test1.cpp c_runtime/towlower/test1/test1.cpp @@ -178,7 +168,6 @@ add_executable_clr(paltests c_runtime/_wfopen/test6/test6.cpp c_runtime/_wfopen/test7/test7.cpp c_runtime/_wtoi/test1/test1.cpp - c_runtime/__iscsym/test1/__iscsym.cpp #debug_api/DebugBreak/test1/test1.cpp debug_api/OutputDebugStringA/test1/helper.cpp debug_api/OutputDebugStringA/test1/test1.cpp diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/__iscsym/test1/__iscsym.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/__iscsym/test1/__iscsym.cpp deleted file mode 100644 index 9244c5f0a32e2..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/__iscsym/test1/__iscsym.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================= -** -** Source: __iscsym.c -** -** Purpose: Positive test the __iscsym API. -** Call __iscsym to letter, digit and underscore -** -** -**============================================================*/ -#include - -PALTEST(c_runtime___iscsym_test1_paltest_iscsym_test1, "c_runtime/__iscsym/test1/paltest_iscsym_test1") -{ - int err; - int index; - char non_letter_set[]= - {'~','`','!','@','#','$','%','^','&','*','(',')',')', - '-','+','=','|','\\',';',':','"','\'','<','>', - ',','.','?','/','\0'}; - char errBuffer[200]; - - /*Initialize the PAL environment*/ - err = PAL_Initialize(argc, argv); - if(0 != err) - { - return FAIL; - } - - /*To check if the parameter passed in is a character*/ - for(index = 'a'; index <= 'z'; index++) - { - err = __iscsym(index); - if(0 == err) - { - Fail("\n__iscsym failed to recognize a " - "lower-case letter:%c!\n", index); - } - } - - /*To check if the parameter passed in is a character*/ - for(index = 'A'; index <= 'Z'; index++) - { - err = __iscsym(index); - if(0 == err) - { - Fail("\n__iscsym failed to recognize an " - "upper-case letter: %c!\n", index); - } - } - - /*To check if the parameter passed in is a digit*/ - for(index = '0'; index <= '9'; index++) - { - err = __iscsym(index); - if(0 == err) - { - Fail("\n__iscsym failed to recognize a digit %c!\n", - index); - } - } - - /*To check if the parameter passed in is a underscore*/ - err = __iscsym('_'); - if(0 == err) - { - Fail("\n__iscsym failed to recognize an underscore!\n"); - } - - memset(errBuffer, 0, 200); - - for(index = 0; non_letter_set[index]; index++) - { - err = __iscsym(non_letter_set[index]); - if(0 != err) - { - strncat(errBuffer, &non_letter_set[index], 1); - strcat(errBuffer, ", "); - } - } - - if(strlen(errBuffer) > 0) - { - Fail("\n__iscsym failed to identify the characters '%s' " - "as not letters, digits " - "or underscores\n", errBuffer); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp index a7ebbe4fa6189..6b9b6d94ee530 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test1/test1.cpp @@ -56,7 +56,7 @@ PALTEST(c_runtime__putenv_test1_paltest_putenv_test1, "c_runtime/_putenv/test1/p */ if (TestCases[i].bValidString == TRUE) { - variableValue = getenv(TestCases[i].varName); + variableValue = PAL_getenv(TestCases[i].varName); if (variableValue == NULL) { @@ -81,7 +81,7 @@ PALTEST(c_runtime__putenv_test1_paltest_putenv_test1, "c_runtime/_putenv/test1/p * Check to see that putenv fails for malformed _putenvString values */ { - variableValue = getenv(TestCases[i].varName); + variableValue = PAL_getenv(TestCases[i].varName); if (variableValue != NULL) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp index ee84e375c2e2e..ef118e513260b 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test2/test2.cpp @@ -35,7 +35,7 @@ PALTEST(c_runtime__putenv_test2_paltest_putenv_test2, "c_runtime/_putenv/test2/p "_putenv(%s)\n", _putenvString0); } - variableValue = getenv(variable); + variableValue = PAL_getenv(variable); if (variableValue == NULL) { @@ -60,7 +60,7 @@ PALTEST(c_runtime__putenv_test2_paltest_putenv_test2, "c_runtime/_putenv/test2/p "_putenv(%s)\n", _putenvString1); } - variableValue = getenv(variable); + variableValue = PAL_getenv(variable); if (variableValue != NULL) { diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp index ab1397193ce3e..07380e1a51452 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/_putenv/test3/test3.cpp @@ -50,7 +50,7 @@ PALTEST(c_runtime__putenv_test3_paltest_putenv_test3, "c_runtime/_putenv/test3/p differing only by case, returns it's own value. */ - result = getenv(FirstVarName); + result = PAL_getenv(FirstVarName); if(result == NULL) { Fail("ERROR: The result of getenv on a valid Environment Variable " @@ -77,7 +77,7 @@ PALTEST(c_runtime__putenv_test3_paltest_putenv_test3, "c_runtime/_putenv/test3/p /* Verify that the environment variables */ - result = getenv(FirstVarName); + result = PAL_getenv(FirstVarName); if(result == NULL) { Fail("ERROR: The result of getenv on a valid Environment Variable " diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/bsearch/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/bsearch/test1/test1.cpp deleted file mode 100644 index eacb660dee096..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/bsearch/test1/test1.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls bsearch to find a character in a sorted buffer, and -** verifies that the correct position is returned. -** -** -**==========================================================================*/ - -#include - -int __cdecl charcmp_bsearch_test1(const void *pa, const void *pb) -{ - return memcmp(pa, pb, 1); -} - -PALTEST(c_runtime_bsearch_test1_paltest_bsearch_test1, "c_runtime/bsearch/test1/paltest_bsearch_test1") -{ - - const char array[] = "abcdefghij"; - char * found=NULL; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - found = (char *)bsearch(&"d", array, sizeof(array) - 1, (sizeof(char)) - , charcmp_bsearch_test1); - if (found != array + 3) - { - Fail ("bsearch was unable to find a specified character in a " - "sorted list.\n"); - } - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/bsearch/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/bsearch/test2/test2.cpp deleted file mode 100644 index a916e61362ee4..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/bsearch/test2/test2.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls bsearch to find a character in a sorted buffer, -** that does not exist. -** -** -**==========================================================================*/ - -#include - -int __cdecl charcmp_bsearch_test2(const void *pa, const void *pb) -{ - return *(const char *)pa - *(const char *)pb; -} - -PALTEST(c_runtime_bsearch_test2_paltest_bsearch_test2, "c_runtime/bsearch/test2/paltest_bsearch_test2") -{ - - const char array[] = "abcefghij"; - const char missing[] = "0dz"; - char * found=NULL; - const char * candidate = missing; - - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - while (*candidate) { - found = (char *)bsearch(candidate, array, sizeof(array) - 1, - (sizeof(char)), charcmp_bsearch_test2); - if (found != NULL) - { - Fail ("ERROR: bsearch was able to find a specified character '%c' " - "in a sorted list '%s' as '%c' " - "even though the character is not in the list.\n", - *candidate, array, *found); - } - - candidate++; - } - - PAL_Terminate(); - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/exit/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/exit/test1/test1.cpp deleted file mode 100644 index 2bb42e3563c42..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/exit/test1/test1.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls exit, and verifies that it actually stops program execution. -** -** -**==========================================================================*/ - -#include - -PALTEST(c_runtime_exit_test1_paltest_exit_test1, "c_runtime/exit/test1/paltest_exit_test1") -{ - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /*should return 0*/ - exit(0); - - Fail ("Exit didn't actually stop execution.\n"); - - return FAIL; -} - - - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/exit/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/exit/test2/test2.cpp deleted file mode 100644 index 6125b3c38899d..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/exit/test2/test2.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Calls exit on fail, and verifies that it actually -** stops program execution and return 1. - -** -**==========================================================================*/ - -#include - -PALTEST(c_runtime_exit_test2_paltest_exit_test2, "c_runtime/exit/test2/paltest_exit_test2") -{ - /* - * Initialize the PAL and return FAIL if this fails - */ - if (0 != (PAL_Initialize(argc, argv))) - { - return FAIL; - } - - /*should return 1*/ - exit(1); - -} - - - - - - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/free/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/free/test1/test1.cpp deleted file mode 100644 index dc8d13158862e..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/free/test1/test1.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Repeatedly allocates and frees a chunk of memory, to verify -** that free is really returning memory to the heap -** -** -**==========================================================================*/ - -#include - -PALTEST(c_runtime_free_test1_paltest_free_test1, "c_runtime/free/test1/paltest_free_test1") -{ - - char *testA; - - long i; - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - /* check that free really returns memory to the heap. */ - for(i=1; i<1000000; i++) - { - testA = (char *)malloc(1000*sizeof(char)); - if (testA==NULL) - { - Fail("Either free is failing to return memory to the heap, or" - " the system is running out of memory for some other " - "reason.\n"); - } - free(testA); - } - - free(NULL); /*should do nothing*/ - PAL_Terminate(); - return PASS; -} - - - - - - - - - - - - - - - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/malloc/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/malloc/test1/test1.cpp deleted file mode 100644 index 067791fe866df..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/malloc/test1/test1.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Test that malloc returns usable memory -** -** -**==========================================================================*/ - -#include - - -PALTEST(c_runtime_malloc_test1_paltest_malloc_test1, "c_runtime/malloc/test1/paltest_malloc_test1") -{ - - char *testA; - int i; - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* check that malloc really gives us addressable memory */ - testA = (char *)malloc(20 * sizeof(char)); - if (testA == NULL) - { - Fail("Call to malloc failed.\n"); - } - for (i = 0; i < 20; i++) - { - testA[i] = 'a'; - } - for (i = 0; i < 20; i++) - { - if (testA[i] != 'a') - { - Fail("The memory doesn't seem to be properly allocated.\n"); - } - } - free(testA); - - PAL_Terminate(); - - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/malloc/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/malloc/test2/test2.cpp deleted file mode 100644 index 9f94f1050d6ac..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/malloc/test2/test2.cpp +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Test that malloc(0) returns non-zero value -** -**==========================================================================*/ - -#include - - -PALTEST(c_runtime_malloc_test2_paltest_malloc_test2, "c_runtime/malloc/test2/paltest_malloc_test2") -{ - - char *testA; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* check that malloc(0) returns non-zero value */ - testA = (char *)malloc(0); - if (testA == NULL) - { - Fail("Call to malloc(0) failed.\n"); - } - - free(testA); - - PAL_Terminate(); - - return PASS; -} - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/qsort/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/qsort/test1/test1.cpp deleted file mode 100644 index 57b288a809ea5..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/qsort/test1/test1.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls qsort to sort a buffer, and verifies that it has done -** the job correctly. -** -** -**==========================================================================*/ - -#include - -int __cdecl charcmp_qsort_test1(const void *pa, const void *pb) -{ - return memcmp(pa, pb, 1); -} - -PALTEST(c_runtime_qsort_test1_paltest_qsort_test1, "c_runtime/qsort/test1/paltest_qsort_test1") -{ - char before[] = "cgaiehdbjf"; - const char after[] = "abcdefghij"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - qsort(before, sizeof(before) - 1, sizeof(char), charcmp_qsort_test1); - - if (memcmp(before, after, sizeof(before)) != 0) - { - Fail("qsort did not correctly sort an array of characters.\n"); - } - - PAL_Terminate(); - return PASS; - -} - - - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/qsort/test2/test2.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/qsort/test2/test2.cpp deleted file mode 100644 index 20d76c5677e3d..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/qsort/test2/test2.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test2.c -** -** Purpose: Calls qsort to sort a buffer, and verifies that it has done -** the job correctly. -** -** -**==========================================================================*/ - -#include - -int __cdecl twocharcmp_qsort_test2(const void *pa, const void *pb) -{ - return memcmp(pa, pb, 2); -} - -PALTEST(c_runtime_qsort_test2_paltest_qsort_test2, "c_runtime/qsort/test2/paltest_qsort_test2") -{ - char before[] = "ccggaaiieehhddbbjjff"; - const char after[] = "aabbccddeeffgghhiijj"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - qsort(before, (sizeof(before) - 1) / 2, 2 * sizeof(char), twocharcmp_qsort_test2); - - if (memcmp(before, after, sizeof(before)) != 0) - { - Fail("qsort did not correctly sort an array of 2-character " - "buffers.\n"); - } - - PAL_Terminate(); - return PASS; - -} - - - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/rand_srand/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/rand_srand/test1/test1.cpp deleted file mode 100644 index cd752c39f5396..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/rand_srand/test1/test1.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================= -** -** Source: test1.c -** -** Purpose: Test to ensure that srand provide random -** number to rand. Also make sure that rand result from a -** srand with seed 1 and no call to srand are the same. -** -** Dependencies: PAL_Initialize -** PAL_Terminate -** Fail -** srand() -** - -** -**===========================================================================*/ - -#include - - -PALTEST(c_runtime_rand_srand_test1_paltest_rand_srand_test1, "c_runtime/rand_srand/test1/paltest_rand_srand_test1") -{ - int RandNumber[10]; - int TempRandNumber; - int i; - int SRAND_SEED; - int SRAND_REINIT = 1; - - /* - * Initialize the PAL and return FAILURE if this fails - */ - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - SRAND_SEED = time(NULL); - - /* does not initialize srand and call rand. */ - for (i=0; i<10; i++) - { - /* keep the value in an array */ - RandNumber[i]=rand(); - if (RandNumber[i] < 0 || RandNumber[i] > RAND_MAX) - { - Fail("1) ERROR: random generated an invalid value: %d", RandNumber[i]); - } - } - - - /* initialize random generator */ - srand(SRAND_SEED); - - - /* choose 10 numbers with a different seed. - the numbers should be different than - those the previously generated one */ - for(i = 0; i < 10; i++) - { - TempRandNumber=rand(); - if (TempRandNumber < 0 || TempRandNumber > RAND_MAX) - { - Fail("2) ERROR: random generated an invalid value: %d", TempRandNumber); - } - } - - - - /* renitialize the srand with 1 */ - srand(SRAND_REINIT); - - - - /* choose 10 numbers with seed 1, - the number should be the same as those we kept in the array. */ - for( i = 0; i < 10;i++ ) - { - /* pick the random number*/ - TempRandNumber=rand(); - /* test if it is the same number generated in the first sequences*/ - if(RandNumber[i]!=TempRandNumber) - { - Fail ("ERROR: rand should return the same value when srand " - "is initialized with 1 or not initialized at all"); - } - if (TempRandNumber < 0 || TempRandNumber > RAND_MAX) - { - Fail("3) ERROR: random generated an invalid value: %d", TempRandNumber); - } - } - - - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/realloc/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/realloc/test1/test1.cpp deleted file mode 100644 index edd075da23f70..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/realloc/test1/test1.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Uses realloc to allocate and realloate memory, checking -** that memory contents are copied when the memory is reallocated. -** -** -**==========================================================================*/ - -#include - -PALTEST(c_runtime_realloc_test1_paltest_realloc_test1, "c_runtime/realloc/test1/paltest_realloc_test1") -{ - char *testA; - const int len1 = 10; - const char str1[] = "aaaaaaaaaa"; - - const int len2 = 20; - const char str2[] = "bbbbbbbbbbbbbbbbbbbb"; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - /* this should work like malloc */ - testA = (char *)realloc(NULL, len1*sizeof(char)); - memcpy(testA, str1, len1); - if (testA == NULL) - { - Fail("We ran out of memory (unlikely), or realloc is broken.\n"); - } - - if (memcmp(testA, str1, len1) != 0) - { - Fail("realloc doesn't properly allocate new memory.\n"); - } - - testA = (char *)realloc(testA, len2*sizeof(char)); - if (memcmp(testA, str1, len1) != 0) - { - Fail("realloc doesn't move the contents of the original memory " - "block to the newly allocated block.\n"); - } - - memcpy(testA, str2, len2); - if (memcmp(testA, str2, len2) != 0) - { - Fail("Couldn't write to memory allocated by realloc.\n"); - } - - /* free the buffer */ - testA = (char*)realloc(testA, 0); - if (testA != NULL) - { - Fail("Realloc didn't return NULL when called with a length " - "of zero.\n"); - } - PAL_Terminate(); - return PASS; -} diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/time/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/time/test1/test1.cpp deleted file mode 100644 index 72d905be0a51e..0000000000000 --- a/src/coreclr/pal/tests/palsuite/c_runtime/time/test1/test1.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -/*============================================================================ -** -** Source: test1.c -** -** Purpose: Calls the time function and verifies that the time returned -** is at least a positive value. -** -** -**==========================================================================*/ - -#include - -PALTEST(c_runtime_time_test1_paltest_time_test1, "c_runtime/time/test1/paltest_time_test1") -{ - time_t t = 0; - - if (PAL_Initialize(argc, argv)) - { - return FAIL; - } - - - time(&t); - /*I was going to test that the time returned didn't exceed some - reasonable value, but decided not to, for fear of creating my own - little Y2K-style disaster.*/ - - if (t <= 0) - { - Fail("time() function doesn't return a time.\n"); - } - t = 0; - t = time(NULL); - if (t <= 0) - { - Fail("time() function doesn't return a time.\n"); - } - PAL_Terminate(); - return PASS; -} - - - - - - - diff --git a/src/coreclr/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.cpp b/src/coreclr/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.cpp index 2ffab4b9de051..428a5f24caa66 100644 --- a/src/coreclr/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.cpp +++ b/src/coreclr/pal/tests/palsuite/c_runtime/wcstoul/test5/test5.cpp @@ -32,9 +32,9 @@ PALTEST(c_runtime_wcstoul_test5_paltest_wcstoul_test5, "c_runtime/wcstoul/test5/ errno = 0; l = wcstoul(overstr, &end, 10); - if (l != _UI32_MAX) + if (l != UINT32_MAX) { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", _UI32_MAX, l); + Fail("ERROR: Expected wcstoul to return %u, got %u\n", UINT32_MAX, l); } if (end != overstr + 10) { @@ -49,9 +49,9 @@ PALTEST(c_runtime_wcstoul_test5_paltest_wcstoul_test5, "c_runtime/wcstoul/test5/ errno = 0; l = wcstoul(understr, &end, 10); - if (l != _UI32_MAX) + if (l != UINT32_MAX) { - Fail("ERROR: Expected wcstoul to return %u, got %u\n", _UI32_MAX, l); + Fail("ERROR: Expected wcstoul to return %u, got %u\n", UINT32_MAX, l); } if (end != understr + 2) { diff --git a/src/coreclr/pal/tests/palsuite/compilableTests.txt b/src/coreclr/pal/tests/palsuite/compilableTests.txt index 9a26d82106530..4d865fc63417e 100644 --- a/src/coreclr/pal/tests/palsuite/compilableTests.txt +++ b/src/coreclr/pal/tests/palsuite/compilableTests.txt @@ -1,7 +1,5 @@ c_runtime/atof/test1/paltest_atof_test1 c_runtime/atoi/test1/paltest_atoi_test1 -c_runtime/bsearch/test1/paltest_bsearch_test1 -c_runtime/bsearch/test2/paltest_bsearch_test2 c_runtime/cbrt/test1/paltest_cbrt_test1 c_runtime/cbrtf/test1/paltest_cbrtf_test1 c_runtime/ceil/test1/paltest_ceil_test1 @@ -12,9 +10,6 @@ c_runtime/cosh/test1/paltest_cosh_test1 c_runtime/coshf/test1/paltest_coshf_test1 c_runtime/errno/test1/paltest_errno_test1 c_runtime/errno/test2/paltest_errno_test2 -c_runtime/exit/test1/paltest_exit_test1 -c_runtime/exit/test2/paltest_exit_test2 -c_runtime/free/test1/paltest_free_test1 c_runtime/isalnum/test1/paltest_isalnum_test1 c_runtime/isalpha/test1/paltest_isalpha_test1 c_runtime/isdigit/test1/paltest_isdigit_test1 @@ -26,16 +21,10 @@ c_runtime/iswspace/test1/paltest_iswspace_test1 c_runtime/iswupper/test1/paltest_iswupper_test1 c_runtime/isxdigit/test1/paltest_isxdigit_test1 c_runtime/llabs/test1/paltest_llabs_test1 -c_runtime/malloc/test1/paltest_malloc_test1 -c_runtime/malloc/test2/paltest_malloc_test2 c_runtime/memchr/test1/paltest_memchr_test1 c_runtime/memcmp/test1/paltest_memcmp_test1 c_runtime/memmove/test1/paltest_memmove_test1 c_runtime/memset/test1/paltest_memset_test1 -c_runtime/qsort/test1/paltest_qsort_test1 -c_runtime/qsort/test2/paltest_qsort_test2 -c_runtime/rand_srand/test1/paltest_rand_srand_test1 -c_runtime/realloc/test1/paltest_realloc_test1 c_runtime/sscanf_s/test1/paltest_sscanf_test1 c_runtime/sscanf_s/test10/paltest_sscanf_test10 c_runtime/sscanf_s/test11/paltest_sscanf_test11 @@ -64,7 +53,6 @@ c_runtime/strncpy/test1/paltest_strncpy_test1 c_runtime/strpbrk/test1/paltest_strpbrk_test1 c_runtime/strrchr/test1/paltest_strrchr_test1 c_runtime/strstr/test1/paltest_strstr_test1 -c_runtime/time/test1/paltest_time_test1 c_runtime/tolower/test1/paltest_tolower_test1 c_runtime/toupper/test1/paltest_toupper_test1 c_runtime/towlower/test1/paltest_towlower_test1 @@ -122,7 +110,6 @@ c_runtime/_wfopen/test5/paltest_wfopen_test5 c_runtime/_wfopen/test6/paltest_wfopen_test6 c_runtime/_wfopen/test7/paltest_wfopen_test7 c_runtime/_wtoi/test1/paltest_wtoi_test1 -c_runtime/__iscsym/test1/paltest_iscsym_test1 debug_api/OutputDebugStringA/test1/paltest_outputdebugstringa_test1 debug_api/OutputDebugStringW/test1/paltest_outputdebugstringw_test1 exception_handling/RaiseException/test1/paltest_raiseexception_test1 diff --git a/src/coreclr/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/test1.cpp b/src/coreclr/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/test1.cpp index 98f0a1b95b0a3..a8f55d7f9c04c 100644 --- a/src/coreclr/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/test1.cpp +++ b/src/coreclr/pal/tests/palsuite/debug_api/OutputDebugStringA/test1/test1.cpp @@ -44,13 +44,10 @@ PALTEST(debug_api_OutputDebugStringA_test1_paltest_outputdebugstringa_test1, "de FALSE, 0, NULL, NULL, &si, &pi)) { DWORD dwError = GetLastError(); - free(name); Fail("ERROR: CreateProcess failed to load executable 'helper'. " "GetLastError() returned %d.\n", dwError); } - free(name); - /* This is the main loop. It exits when the process which is being debugged is finished executing. */ diff --git a/src/coreclr/pal/tests/palsuite/manual-unautomatable.dat b/src/coreclr/pal/tests/palsuite/manual-unautomatable.dat index c7a2a3913e7b2..78e1831fbc6a4 100644 --- a/src/coreclr/pal/tests/palsuite/manual-unautomatable.dat +++ b/src/coreclr/pal/tests/palsuite/manual-unautomatable.dat @@ -1,9 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -#This test is negative and will exit with exit(1). -#Therefore, the harness would record it as a failure -c_runtime/exit/test2,1 # A successful DebugBreak test run dumps core or throws up an ASSERT # dialog box (or...) and returns an exit code != 0 debug_api/debugbreak/test1,1 diff --git a/src/coreclr/pal/tests/palsuite/paltestlist.txt b/src/coreclr/pal/tests/palsuite/paltestlist.txt index 0a0bd955f3adb..e141789e71f06 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist.txt @@ -1,8 +1,5 @@ c_runtime/atof/test1/paltest_atof_test1 c_runtime/atoi/test1/paltest_atoi_test1 -c_runtime/bsearch/test1/paltest_bsearch_test1 -c_runtime/bsearch/test2/paltest_bsearch_test2 -c_runtime/free/test1/paltest_free_test1 c_runtime/isalnum/test1/paltest_isalnum_test1 c_runtime/isalpha/test1/paltest_isalpha_test1 c_runtime/isdigit/test1/paltest_isdigit_test1 @@ -13,17 +10,10 @@ c_runtime/iswdigit/test1/paltest_iswdigit_test1 c_runtime/iswspace/test1/paltest_iswspace_test1 c_runtime/iswupper/test1/paltest_iswupper_test1 c_runtime/isxdigit/test1/paltest_isxdigit_test1 -c_runtime/llabs/test1/paltest_llabs_test1 -c_runtime/malloc/test1/paltest_malloc_test1 -c_runtime/malloc/test2/paltest_malloc_test2 c_runtime/memchr/test1/paltest_memchr_test1 c_runtime/memcmp/test1/paltest_memcmp_test1 c_runtime/memmove/test1/paltest_memmove_test1 c_runtime/memset/test1/paltest_memset_test1 -c_runtime/qsort/test1/paltest_qsort_test1 -c_runtime/qsort/test2/paltest_qsort_test2 -c_runtime/rand_srand/test1/paltest_rand_srand_test1 -c_runtime/realloc/test1/paltest_realloc_test1 c_runtime/sscanf_s/test1/paltest_sscanf_test1 c_runtime/sscanf_s/test10/paltest_sscanf_test10 c_runtime/sscanf_s/test11/paltest_sscanf_test11 @@ -52,7 +42,6 @@ c_runtime/strncpy/test1/paltest_strncpy_test1 c_runtime/strpbrk/test1/paltest_strpbrk_test1 c_runtime/strrchr/test1/paltest_strrchr_test1 c_runtime/strstr/test1/paltest_strstr_test1 -c_runtime/time/test1/paltest_time_test1 c_runtime/tolower/test1/paltest_tolower_test1 c_runtime/toupper/test1/paltest_toupper_test1 c_runtime/towlower/test1/paltest_towlower_test1 @@ -110,7 +99,6 @@ c_runtime/_wfopen/test5/paltest_wfopen_test5 c_runtime/_wfopen/test6/paltest_wfopen_test6 c_runtime/_wfopen/test7/paltest_wfopen_test7 c_runtime/_wtoi/test1/paltest_wtoi_test1 -c_runtime/__iscsym/test1/paltest_iscsym_test1 debug_api/OutputDebugStringW/test1/paltest_outputdebugstringw_test1 exception_handling/RaiseException/test1/paltest_raiseexception_test1 exception_handling/RaiseException/test2/paltest_raiseexception_test2 diff --git a/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt b/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt index 2dbbd64e9f2b1..bc5589f4323c1 100644 --- a/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt +++ b/src/coreclr/pal/tests/palsuite/paltestlist_to_be_reviewed.txt @@ -1,7 +1,6 @@ This is a list of failing PAL tests that need to be reviewed because. They should either be fixed or deleted if they are no longer applicable. -c_runtime/exit/test2/paltest_exit_test2 c_runtime/ferror/test1/paltest_ferror_test1 c_runtime/ferror/test2/paltest_ferror_test2 c_runtime/fputs/test2/paltest_fputs_test2 diff --git a/src/coreclr/pal/tests/palsuite/runpaltests.sh b/src/coreclr/pal/tests/palsuite/runpaltests.sh index c10930e2acc39..39c492212bc88 100755 --- a/src/coreclr/pal/tests/palsuite/runpaltests.sh +++ b/src/coreclr/pal/tests/palsuite/runpaltests.sh @@ -9,7 +9,7 @@ then echo "runpaltests.sh [] []" echo echo "For example:" - echo "runpaltests.sh /projectk/build/debug" + echo "runpaltests.sh artifacts/bin/coreclr/linux.x64.Debug/paltests/" echo exit 1 fi diff --git a/src/coreclr/pal/tests/palsuite/tests-manual.dat b/src/coreclr/pal/tests/palsuite/tests-manual.dat index b87a39486af1b..3f32f49df043c 100644 --- a/src/coreclr/pal/tests/palsuite/tests-manual.dat +++ b/src/coreclr/pal/tests/palsuite/tests-manual.dat @@ -1,7 +1,6 @@ # Licensed to the .NET Foundation under one or more agreements. # The .NET Foundation licenses this file to you under the MIT license. -c_runtime/exit/test2,1 pal_specific/pal_get_stderr/test1,1 pal_specific/pal_get_stdin/test1,1 pal_specific/pal_get_stdout/test1,1 diff --git a/src/coreclr/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/test8.cpp b/src/coreclr/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/test8.cpp index 24f22afa456ce..8081b69109a9a 100644 --- a/src/coreclr/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/test8.cpp +++ b/src/coreclr/pal/tests/palsuite/threading/CriticalSectionFunctions/test8/test8.cpp @@ -12,6 +12,7 @@ ** **===================================================================*/ #include +#include #define MAX_THREAD_COUNT 128 #define DEFAULT_THREAD_COUNT 10 diff --git a/src/coreclr/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/test6.cpp b/src/coreclr/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/test6.cpp index 80ecbaa2016c0..6ac838bd24b04 100644 --- a/src/coreclr/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/test6.cpp +++ b/src/coreclr/pal/tests/palsuite/threading/WaitForMultipleObjectsEx/test6/test6.cpp @@ -12,6 +12,7 @@ **=========================================================*/ #include +#include #define MAX_COUNT 10000 #define MAX_THREADS 256 diff --git a/src/coreclr/palrt/memorystream.cpp b/src/coreclr/palrt/memorystream.cpp index 0ed06547f3bfa..91a5ca8b2d318 100644 --- a/src/coreclr/palrt/memorystream.cpp +++ b/src/coreclr/palrt/memorystream.cpp @@ -23,6 +23,10 @@ Revision History: #include "common.h" #include "objidl.h" +#include + +using std::min; +using std::max; class MemoryStream : public IStream { @@ -44,7 +48,7 @@ class MemoryStream : public IStream n = min(2 * n, n + n / 4 + 0x100000); // don't allocate tiny chunks - n = max(n, 0x100); + n = max(n, (ULONG)0x100); // compare with the hard limit nNewData = max(n, nNewData); diff --git a/src/coreclr/scripts/genDummyProvider.py b/src/coreclr/scripts/genDummyProvider.py index ccf421421ca0b..90ec297b0bf08 100644 --- a/src/coreclr/scripts/genDummyProvider.py +++ b/src/coreclr/scripts/genDummyProvider.py @@ -124,8 +124,6 @@ def generateDummyFiles(etwmanifest, out_dirname, runtimeFlavor, extern, dryRun): #include "pal_mstypes.h" #include "pal_error.h" #include "pal.h" -#define PAL_free free -#define PAL_realloc realloc #include "pal/stackstring.hpp" #endif diff --git a/src/coreclr/scripts/genLttngProvider.py b/src/coreclr/scripts/genLttngProvider.py index d75a222a27b8a..fc93f240315c3 100644 --- a/src/coreclr/scripts/genLttngProvider.py +++ b/src/coreclr/scripts/genLttngProvider.py @@ -580,8 +580,6 @@ def generateLttngFiles(etwmanifest, eventprovider_directory, runtimeFlavor, dryR #include "pal_mstypes.h" #include "pal_error.h" #include "pal.h" -#define PAL_free free -#define PAL_realloc realloc #include "pal/stackstring.hpp" """) lttngimpl_file.write("#include \"" + lttngevntheadershortname + "\"\n\n") diff --git a/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp b/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp index 49bf662c21dde..eadc27e2557c2 100644 --- a/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp +++ b/src/coreclr/tools/StressLogAnalyzer/StressLogDump.cpp @@ -24,6 +24,10 @@ class MapViewHolder #include "../../../inc/stresslog.h" #include "StressMsgReader.h" +#ifdef HOST_WINDOWS +#include +#endif + void GcHistClear(); void GcHistAddLog(LPCSTR msg, StressMsgReader stressMsg); diff --git a/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp b/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp index dc4a63c0e8db1..20d0f1b6b2291 100644 --- a/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp +++ b/src/coreclr/tools/StressLogAnalyzer/StressLogPlugin.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #ifndef INFINITY #define INFINITY 1e300 // Practically good enough - not sure why we miss this in our Linux build. @@ -42,6 +43,9 @@ bool IsInCantAllocStressLogRegion() #include "../../../inc/stresslog.h" #include "StressMsgReader.h" +using std::min; +using std::max; + size_t StressLog::writing_base_address; size_t StressLog::reading_base_address; @@ -1323,7 +1327,7 @@ int ProcessStressLog(void* baseAddress, int argc, char* argv[]) double latestTime = FindLatestTime(hdr); if (s_timeFilterStart < 0) { - s_timeFilterStart = max(latestTime + s_timeFilterStart, 0); + s_timeFilterStart = max(latestTime + s_timeFilterStart, 0.0); s_timeFilterEnd = latestTime; } for (ThreadStressLog* tsl = StressLog::TranslateMemoryMappedPointer(hdr->logs.t); tsl != nullptr; tsl = StressLog::TranslateMemoryMappedPointer(tsl->next)) @@ -1346,7 +1350,7 @@ int ProcessStressLog(void* baseAddress, int argc, char* argv[]) SYSTEM_INFO systemInfo; GetSystemInfo(&systemInfo); - DWORD threadCount = min(systemInfo.dwNumberOfProcessors, MAXIMUM_WAIT_OBJECTS); + DWORD threadCount = min(systemInfo.dwNumberOfProcessors, (DWORD)MAXIMUM_WAIT_OBJECTS); HANDLE threadHandle[64]; for (DWORD i = 0; i < threadCount; i++) { @@ -1361,7 +1365,7 @@ int ProcessStressLog(void* baseAddress, int argc, char* argv[]) // the interlocked increment may have increased s_msgCount beyond MAX_MESSAGE_COUNT - // make sure we don't go beyond the end of the buffer - s_msgCount = min(s_msgCount, MAX_MESSAGE_COUNT); + s_msgCount = min((LONG64)s_msgCount, MAX_MESSAGE_COUNT); if (s_gcFilterStart != 0) { diff --git a/src/coreclr/tools/StressLogAnalyzer/util.h b/src/coreclr/tools/StressLogAnalyzer/util.h index 6999676c2e7cc..752509277a770 100644 --- a/src/coreclr/tools/StressLogAnalyzer/util.h +++ b/src/coreclr/tools/StressLogAnalyzer/util.h @@ -12,7 +12,6 @@ typedef void* CRITSEC_COOKIE; #define STRESS_LOG_ANALYZER -#include #include "staticcontract.h" // This macro is used to standardize the wide character string literals between UNIX and Windows. diff --git a/src/coreclr/tools/metainfo/mdinfo.cpp b/src/coreclr/tools/metainfo/mdinfo.cpp index 579a5362f96d5..84d7f8d50f265 100644 --- a/src/coreclr/tools/metainfo/mdinfo.cpp +++ b/src/coreclr/tools/metainfo/mdinfo.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -3772,7 +3773,7 @@ int MDInfo::DumpHex( ++nLines; // Calculate spacing. - nPrint = min(cbData, nLine); + nPrint = std::min(cbData, nLine); nSpace = nLine - nPrint; // dump in hex. diff --git a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp index 6f7952477d064..7b0ddc8ded5ae 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp @@ -6632,7 +6632,7 @@ size_t MethodContext::repPrint( size_t bytesWritten = 0; if ((buffer != nullptr) && (bufferSize > 0)) { - bytesWritten = min(bufferSize - 1, res.stringBufferSize); + bytesWritten = min(bufferSize - 1, (size_t)res.stringBufferSize); if (bytesWritten > 0) { // The "full buffer" check above ensures this given that diff --git a/src/coreclr/tools/superpmi/superpmi-shared/spmidumphelper.cpp b/src/coreclr/tools/superpmi/superpmi-shared/spmidumphelper.cpp index 725f52cbcc74c..4a2d55c1dbb23 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/spmidumphelper.cpp +++ b/src/coreclr/tools/superpmi/superpmi-shared/spmidumphelper.cpp @@ -93,7 +93,7 @@ void SpmiDumpHelper::FormatHandleArray(char*& pbuf, int& sizeOfBuffer, const Den sizeOfBuffer -= cch; const unsigned int maxHandleArrayDisplayElems = 5; // Don't display more than this. - const unsigned int handleArrayDisplayElems = min(maxHandleArrayDisplayElems, count); + const unsigned int handleArrayDisplayElems = min(maxHandleArrayDisplayElems, (unsigned int)count); bool first = true; for (DWORD i = startIndex; i < startIndex + handleArrayDisplayElems; i++) diff --git a/src/coreclr/tools/superpmi/superpmi-shared/spmidumphelper.h b/src/coreclr/tools/superpmi/superpmi-shared/spmidumphelper.h index 4dc1f28991a75..b989fb50d1c46 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/spmidumphelper.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/spmidumphelper.h @@ -110,8 +110,8 @@ inline std::string SpmiDumpHelper::DumpPSig( pbuf += cch; sizeOfBuffer -= cch; - const unsigned int maxSigDisplayBytes = 25; // Don't display more than this. - const unsigned int sigDisplayBytes = min(maxSigDisplayBytes, cbSig); + const size_t maxSigDisplayBytes = 25; // Don't display more than this. + const size_t sigDisplayBytes = min(maxSigDisplayBytes, (size_t)cbSig); // TODO: display character representation of the types? diff --git a/src/coreclr/tools/superpmi/superpmi-shared/standardpch.h b/src/coreclr/tools/superpmi/superpmi-shared/standardpch.h index 8c511b45e91b9..9b926556fdbb6 100644 --- a/src/coreclr/tools/superpmi/superpmi-shared/standardpch.h +++ b/src/coreclr/tools/superpmi/superpmi-shared/standardpch.h @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -59,21 +58,11 @@ #include #include -// Getting STL to work with PAL is difficult, so reimplement STL functionality to not require it. -#ifdef TARGET_UNIX -#include "clr_std/utility" -#include "clr_std/string" -#include "clr_std/algorithm" -#include "clr_std/vector" -#else // !TARGET_UNIX -#ifndef USE_STL -#define USE_STL -#endif // USE_STL #include #include #include #include -#endif // !TARGET_UNIX + #ifdef USE_MSVCDIS #define DISLIB @@ -128,6 +117,9 @@ static inline void __debugbreak() } #endif +using std::min; +using std::max; + #include #endif // STANDARDPCH_H diff --git a/src/coreclr/utilcode/clrconfig.cpp b/src/coreclr/utilcode/clrconfig.cpp index 8ea705a917e83..b531018eb08ae 100644 --- a/src/coreclr/utilcode/clrconfig.cpp +++ b/src/coreclr/utilcode/clrconfig.cpp @@ -201,7 +201,11 @@ namespace // Validate the cache and no-cache logic result in the same answer SString nameToConvert(name); +#ifdef HOST_WINDOWS CLRConfigNoCache nonCache = CLRConfigNoCache::Get(nameToConvert.GetUTF8(), noPrefix); +#else + CLRConfigNoCache nonCache = CLRConfigNoCache::Get(nameToConvert.GetUTF8(), noPrefix, &PAL_getenv); +#endif LPCSTR valueNoCache = nonCache.AsString(); _ASSERTE(SString::_stricmp(valueNoCache, temp.GetUTF8()) == 0); diff --git a/src/coreclr/utilcode/clrhost_nodependencies.cpp b/src/coreclr/utilcode/clrhost_nodependencies.cpp index b385474b6dc0c..7aceae763c43b 100644 --- a/src/coreclr/utilcode/clrhost_nodependencies.cpp +++ b/src/coreclr/utilcode/clrhost_nodependencies.cpp @@ -246,6 +246,11 @@ FORCEINLINE void* ClrMalloc(size_t size) p = HeapAlloc(hHeap, 0, size); #else + if (size == 0) + { + // Allocate at least one byte. + size = 1; + } p = malloc(size); #endif diff --git a/src/coreclr/utilcode/loaderheap.cpp b/src/coreclr/utilcode/loaderheap.cpp index 72d0d1a6f6f7f..985df665be6f4 100644 --- a/src/coreclr/utilcode/loaderheap.cpp +++ b/src/coreclr/utilcode/loaderheap.cpp @@ -1154,7 +1154,7 @@ BOOL UnlockedLoaderHeap::UnlockedReservePages(size_t dwSizeToCommit) } // Figure out how much to reserve - dwSizeToReserve = max(dwSizeToCommit, m_dwReserveBlockSize); + dwSizeToReserve = max(dwSizeToCommit, m_dwReserveBlockSize); // Round to VIRTUAL_ALLOC_RESERVE_GRANULARITY dwSizeToReserve = ALIGN_UP(dwSizeToReserve, VIRTUAL_ALLOC_RESERVE_GRANULARITY); diff --git a/src/coreclr/utilcode/md5.cpp b/src/coreclr/utilcode/md5.cpp index 7297114f21feb..cc86a48bedc2c 100644 --- a/src/coreclr/utilcode/md5.cpp +++ b/src/coreclr/utilcode/md5.cpp @@ -141,7 +141,7 @@ void MD5::GetHashValue(MD5HASHDATA* phash) // // but our compiler has an intrinsic! - #if (defined(HOST_X86) || defined(HOST_ARM)) && defined(TARGET_UNIX) + #if (defined(HOST_X86) || defined(HOST_ARM) || !defined(__clang__)) && defined(TARGET_UNIX) #define ROL(x, n) (((x) << (n)) | ((x) >> (32-(n)))) #define ROTATE_LEFT(x,n) (x) = ROL(x,n) #else diff --git a/src/coreclr/utilcode/stdafx.h b/src/coreclr/utilcode/stdafx.h index 18b820306f775..78e9840575819 100644 --- a/src/coreclr/utilcode/stdafx.h +++ b/src/coreclr/utilcode/stdafx.h @@ -12,6 +12,9 @@ #include #include #include +#include +using std::min; +using std::max; #define IN_WINFIX_CPP diff --git a/src/coreclr/utilcode/stgpool.cpp b/src/coreclr/utilcode/stgpool.cpp index f04f6e9e7b3bf..e7aebc55d6ca9 100644 --- a/src/coreclr/utilcode/stgpool.cpp +++ b/src/coreclr/utilcode/stgpool.cpp @@ -1938,7 +1938,7 @@ CInMemoryStream::CopyTo( _ASSERTE(cb.QuadPart <= UINT32_MAX); ULONG cbTotal = min(static_cast(cb.QuadPart), m_cbSize - m_cbCurrent); - ULONG cbRead=min(1024, cbTotal); + ULONG cbRead=min((ULONG)1024, cbTotal); CQuickBytes rBuf; void *pBuf = rBuf.AllocNoThrow(cbRead); if (pBuf == 0) @@ -2061,7 +2061,7 @@ CGrowableStream::CGrowableStream(float multiplicativeGrowthRate, DWORD additiveG m_multiplicativeGrowthRate = min(max(1.0F, multiplicativeGrowthRate), 2.0F); _ASSERTE(additiveGrowthRate >= 1); - m_additiveGrowthRate = max(1, additiveGrowthRate); + m_additiveGrowthRate = max((DWORD)1, additiveGrowthRate); } // CGrowableStream::CGrowableStream #ifndef DACCESS_COMPILE @@ -2115,7 +2115,7 @@ HRESULT CGrowableStream::EnsureCapacity(DWORD newLogicalSize) multSize = (DWORD)multSizeF; } - DWORD newBufferSize = max(max(newLogicalSize, multSize), addSize.Value()); + DWORD newBufferSize = max(max(newLogicalSize, multSize), (DWORD)addSize.Value()); char *tmp = new (nothrow) char[newBufferSize]; if(tmp == NULL) diff --git a/src/coreclr/utilcode/stresslog.cpp b/src/coreclr/utilcode/stresslog.cpp index 90ad5900473ed..37abeb2cb92f4 100644 --- a/src/coreclr/utilcode/stresslog.cpp +++ b/src/coreclr/utilcode/stresslog.cpp @@ -227,7 +227,7 @@ void StressLog::Initialize(unsigned facilities, unsigned level, unsigned maxByte // in this case, interpret the number as GB maxBytesPerThread *= (1024 * 1024 * 1024); } - theLog.MaxSizePerThread = (unsigned)min(maxBytesPerThread,0xffffffff); + theLog.MaxSizePerThread = (unsigned)min(maxBytesPerThread,(size_t)0xffffffff); size_t maxBytesTotal = maxBytesTotalArg; if (maxBytesTotal < STRESSLOG_CHUNK_SIZE * 256) @@ -235,7 +235,7 @@ void StressLog::Initialize(unsigned facilities, unsigned level, unsigned maxByte // in this case, interpret the number as GB maxBytesTotal *= (1024 * 1024 * 1024); } - theLog.MaxSizeTotal = (unsigned)min(maxBytesTotal, 0xffffffff); + theLog.MaxSizeTotal = (unsigned)min(maxBytesTotal, (size_t)0xffffffff); theLog.totalChunk = 0; theLog.facilitiesToLog = facilities | LF_ALWAYS; theLog.levelToLog = level; diff --git a/src/coreclr/utilcode/util.cpp b/src/coreclr/utilcode/util.cpp index 13668d244135e..1819f38e0a438 100644 --- a/src/coreclr/utilcode/util.cpp +++ b/src/coreclr/utilcode/util.cpp @@ -816,7 +816,7 @@ DWORD LCM(DWORD u, DWORD v) DWORD currentProcsInGroup = 0; for (WORD i = 0; i < m_nGroups; i++) { - currentProcsInGroup = max(currentProcsInGroup, m_CPUGroupInfoArray[i].nr_active); + currentProcsInGroup = max(currentProcsInGroup, (DWORD)m_CPUGroupInfoArray[i].nr_active); } *max_procs_per_group = currentProcsInGroup; return true; diff --git a/src/coreclr/utilcode/utsem.cpp b/src/coreclr/utilcode/utsem.cpp index 94c1636dbe6ea..e8e786cc3af91 100644 --- a/src/coreclr/utilcode/utsem.cpp +++ b/src/coreclr/utilcode/utsem.cpp @@ -84,7 +84,7 @@ SpinConstants g_SpinConstants = { inline void InitializeSpinConstants_NoHost() { - g_SpinConstants.dwMaximumDuration = max(2, g_SystemInfo.dwNumberOfProcessors) * 20000; + g_SpinConstants.dwMaximumDuration = max((DWORD)2, g_SystemInfo.dwNumberOfProcessors) * 20000; } #else //!SELF_NO_HOST diff --git a/src/coreclr/vm/.vscode/c_cpp_properties.json b/src/coreclr/vm/.vscode/c_cpp_properties.json index d8abc20bf0bcb..4192e236e3548 100644 --- a/src/coreclr/vm/.vscode/c_cpp_properties.json +++ b/src/coreclr/vm/.vscode/c_cpp_properties.json @@ -31,6 +31,7 @@ "_UNICODE", "_WIN32", "_WIN32_WINNT=0x0602", + "NOMINMAX", "HOST_64BIT", "AMD64", "HOST_64BIT=1", diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index dd8a98eb4583d..07f24361dccca 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -313,7 +313,7 @@ OBJECTREF* PinnedHeapHandleTable::AllocateHandles(DWORD nRequested) // Retrieve the remaining number of handles in the bucket. DWORD numRemainingHandlesInBucket = (m_pHead != NULL) ? m_pHead->GetNumRemainingHandles() : 0; PTRARRAYREF pinnedHandleArrayObj = NULL; - DWORD nextBucketSize = min(m_NextBucketSize * 2, MAX_BUCKETSIZE); + DWORD nextBucketSize = min(m_NextBucketSize * 2, MAX_BUCKETSIZE); // create a new block if this request doesn't fit in the current block if (nRequested > numRemainingHandlesInBucket) @@ -4177,7 +4177,7 @@ void DomainLocalModule::EnsureDynamicClassIndex(DWORD dwID) return; } - SIZE_T aDynamicEntries = max(16, oldDynamicEntries); + SIZE_T aDynamicEntries = max(16, oldDynamicEntries); while (aDynamicEntries <= dwID) { aDynamicEntries *= 2; diff --git a/src/coreclr/vm/callcounting.cpp b/src/coreclr/vm/callcounting.cpp index c464949f7aeee..a6577fd42de34 100644 --- a/src/coreclr/vm/callcounting.cpp +++ b/src/coreclr/vm/callcounting.cpp @@ -664,7 +664,7 @@ bool CallCountingManager::SetCodeEntryPoint( // direct calls in codegen and they need to be promoted earlier than their callers. if (methodDesc->GetMethodTable() == g_pCastHelpers) { - callCountThreshold = max(1, (CallCount)(callCountThreshold / 2)); + callCountThreshold = max(1, (CallCount)(callCountThreshold / 2)); } NewHolder callCountingInfoHolder = new CallCountingInfo(activeCodeVersion, callCountThreshold); diff --git a/src/coreclr/vm/castcache.cpp b/src/coreclr/vm/castcache.cpp index 1e59f7862d72f..27105f3d25efa 100644 --- a/src/coreclr/vm/castcache.cpp +++ b/src/coreclr/vm/castcache.cpp @@ -12,6 +12,7 @@ BASEARRAYREF* CastCache::s_pTableRef = NULL; OBJECTHANDLE CastCache::s_sentinelTable = NULL; DWORD CastCache::s_lastFlushSize = INITIAL_CACHE_SIZE; +const DWORD CastCache::INITIAL_CACHE_SIZE; BASEARRAYREF CastCache::CreateCastCache(DWORD size) { diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 4b5fa46e483b1..0696635e90273 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -946,26 +946,26 @@ void Module::BuildStaticsOffsets(AllocMemTracker *pamTracker) case ELEMENT_TYPE_I2: case ELEMENT_TYPE_U2: case ELEMENT_TYPE_CHAR: - dwAlignment[kk] = max(2, dwAlignment[kk]); + dwAlignment[kk] = max(2, dwAlignment[kk]); dwClassNonGCBytes[kk] += 2; break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: case ELEMENT_TYPE_R4: - dwAlignment[kk] = max(4, dwAlignment[kk]); + dwAlignment[kk] = max(4, dwAlignment[kk]); dwClassNonGCBytes[kk] += 4; break; case ELEMENT_TYPE_FNPTR: case ELEMENT_TYPE_PTR: case ELEMENT_TYPE_I: case ELEMENT_TYPE_U: - dwAlignment[kk] = max((1 << LOG2_PTRSIZE), dwAlignment[kk]); + dwAlignment[kk] = max((1 << LOG2_PTRSIZE), dwAlignment[kk]); dwClassNonGCBytes[kk] += (1 << LOG2_PTRSIZE); break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: case ELEMENT_TYPE_R8: - dwAlignment[kk] = max(8, dwAlignment[kk]); + dwAlignment[kk] = max(8, dwAlignment[kk]); dwClassNonGCBytes[kk] += 8; break; case ELEMENT_TYPE_VAR: @@ -989,7 +989,7 @@ void Module::BuildStaticsOffsets(AllocMemTracker *pamTracker) { // We'll have to be pessimistic here dwClassNonGCBytes[kk] += MAX_PRIMITIVE_FIELD_SIZE; - dwAlignment[kk] = max(MAX_PRIMITIVE_FIELD_SIZE, dwAlignment[kk]); + dwAlignment[kk] = max(MAX_PRIMITIVE_FIELD_SIZE, dwAlignment[kk]); dwClassGCHandles[kk] += 1; break; @@ -1532,7 +1532,7 @@ DWORD Module::AllocateDynamicEntry(MethodTable *pMT) if (newId >= m_maxDynamicEntries) { - SIZE_T maxDynamicEntries = max(16, m_maxDynamicEntries); + SIZE_T maxDynamicEntries = max(16, m_maxDynamicEntries); while (maxDynamicEntries <= newId) { maxDynamicEntries *= 2; diff --git a/src/coreclr/vm/ceemain.cpp b/src/coreclr/vm/ceemain.cpp index a9bb4e3bbbe86..1c29942942c05 100644 --- a/src/coreclr/vm/ceemain.cpp +++ b/src/coreclr/vm/ceemain.cpp @@ -933,7 +933,7 @@ void EEStartupHelper() // retrieve configured max size for the mini-metadata buffer (defaults to 64KB) g_MiniMetaDataBuffMaxSize = CLRConfig::GetConfigValue(CLRConfig::INTERNAL_MiniMdBufferCapacity); // align up to GetOsPageSize(), with a maximum of 1 MB - g_MiniMetaDataBuffMaxSize = (DWORD) min(ALIGN_UP(g_MiniMetaDataBuffMaxSize, GetOsPageSize()), 1024 * 1024); + g_MiniMetaDataBuffMaxSize = (DWORD) min(ALIGN_UP(g_MiniMetaDataBuffMaxSize, GetOsPageSize()), (DWORD)(1024 * 1024)); // allocate the buffer. this is never touched while the process is running, so it doesn't // contribute to the process' working set. it is needed only as a "shadow" for a mini-metadata // buffer that will be set up and reported / updated in the Watson process (the diff --git a/src/coreclr/vm/cgensys.h b/src/coreclr/vm/cgensys.h index 1396d7558c29f..a3accc91a9973 100644 --- a/src/coreclr/vm/cgensys.h +++ b/src/coreclr/vm/cgensys.h @@ -84,8 +84,6 @@ BOOL GetAnyThunkTarget (T_CONTEXT *pctx, TADDR *pTarget, TADDR *pTargetMethodDes #endif // DACCESS_COMPILE - - // // ResetProcessorStateHolder saves/restores processor state around calls to // CoreLib during exception handling. diff --git a/src/coreclr/vm/classhash.cpp b/src/coreclr/vm/classhash.cpp index 5d2be11c9b328..1a2af02a05741 100644 --- a/src/coreclr/vm/classhash.cpp +++ b/src/coreclr/vm/classhash.cpp @@ -234,7 +234,7 @@ VOID EEClassHashTable::ConstructKeyFromData(PTR_EEClassHashEntry pEntry, // IN #endif // If IsCaseInsensitiveTable() is true for the hash table, strings passed to the ConstructKeyCallback instance - // will be dynamically allocated. This is to prevent wasting bytes in the Loader Heap. Thusly, it is important + // will be dynamically allocated. This is to prevent wasting bytes in the Loader Heap. Thusly, it is important // to note that in this case, the lifetime of Key is bounded by the lifetime of the single call to UseKeys, and // will be freed when that function returns. @@ -452,7 +452,7 @@ EEClassHashTable *EEClassHashTable::MakeCaseInsensitiveTable(Module *pModule, Al // Allocate the table and verify that we actually got one. EEClassHashTable * pCaseInsTable = EEClassHashTable::Create(pModule, - max(BaseGetElementCount() / 2, 11), + max(BaseGetElementCount() / 2, (DWORD)11), this, pamTracker); diff --git a/src/coreclr/vm/classlayoutinfo.cpp b/src/coreclr/vm/classlayoutinfo.cpp index 468dc63d59de3..8336f89066032 100644 --- a/src/coreclr/vm/classlayoutinfo.cpp +++ b/src/coreclr/vm/classlayoutinfo.cpp @@ -136,7 +136,7 @@ namespace ) { UINT32 cbCurOffset = parentSize; - BYTE LargestAlignmentRequirement = max(1, min(packingSize, parentAlignmentRequirement)); + BYTE LargestAlignmentRequirement = max(1, min(packingSize, parentAlignmentRequirement)); // Start with the size inherited from the parent (if any). uint32_t calcTotalSize = parentSize; @@ -198,7 +198,7 @@ namespace COMPlusThrowOM(); // size must be large enough to accommodate layout. If not, we use the layout size instead. - calcTotalSize = max(classSize, calcTotalSize); + calcTotalSize = max((uint32_t)classSize, calcTotalSize); } else { diff --git a/src/coreclr/vm/codeman.cpp b/src/coreclr/vm/codeman.cpp index c6bac693c679a..228c65f004129 100644 --- a/src/coreclr/vm/codeman.cpp +++ b/src/coreclr/vm/codeman.cpp @@ -2302,7 +2302,7 @@ VOID EEJitManager::EnsureJumpStubReserve(BYTE * pImageBase, SIZE_T imageSize, SI int allocMode = 0; // Try to reserve at least 16MB at a time - SIZE_T allocChunk = max(ALIGN_UP(reserveSize, VIRTUAL_ALLOC_RESERVE_GRANULARITY), 16*1024*1024); + SIZE_T allocChunk = max(ALIGN_UP(reserveSize, VIRTUAL_ALLOC_RESERVE_GRANULARITY), 16*1024*1024); while (reserveSize > 0) { @@ -2820,11 +2820,11 @@ void EEJitManager::allocCode(MethodDesc* pMD, size_t blockSize, size_t reserveFo if ((flag & CORJIT_ALLOCMEM_FLG_32BYTE_ALIGN) != 0) { - alignment = max(alignment, 32); + alignment = max(alignment, 32u); } else if ((flag & CORJIT_ALLOCMEM_FLG_16BYTE_ALIGN) != 0) { - alignment = max(alignment, 16); + alignment = max(alignment, 16u); } #if defined(TARGET_X86) @@ -2832,7 +2832,7 @@ void EEJitManager::allocCode(MethodDesc* pMD, size_t blockSize, size_t reserveFo // the JIT can in turn 8-byte align the loop entry headers. else if ((g_pConfig->GenOptimizeType() != OPT_SIZE)) { - alignment = max(alignment, 8); + alignment = max(alignment, 8u); } #endif @@ -3206,7 +3206,7 @@ JumpStubBlockHeader * EEJitManager::allocJumpStubBlock(MethodDesc* pMD, DWORD n CrstHolder ch(&m_CodeHeapCritSec); mem = (TADDR) allocCodeRaw(&requestInfo, sizeof(CodeHeader), blockSize, CODE_SIZE_ALIGN, &pCodeHeap); - if (mem == NULL) + if (mem == (TADDR)0) { _ASSERTE(!throwOnOutOfMemoryWithinRange); RETURN(NULL); @@ -3755,7 +3755,7 @@ static CodeHeader * GetCodeHeaderFromDebugInfoRequest(const DebugInfoRequest & r } CONTRACTL_END; TADDR address = (TADDR) request.GetStartAddress(); - _ASSERTE(address != NULL); + _ASSERTE(address != (TADDR)0); CodeHeader * pHeader = dac_cast(address & ~3) - 1; _ASSERTE(pHeader != NULL); @@ -3925,7 +3925,7 @@ BOOL EEJitManager::JitCodeToMethodInfo( return FALSE; TADDR start = dac_cast(pRangeSection->_pjit)->FindMethodCode(pRangeSection, currentPC); - if (start == NULL) + if (start == (TADDR)0) return FALSE; CodeHeader * pCHdr = PTR_CodeHeader(start - sizeof(CodeHeader)); @@ -3970,7 +3970,7 @@ StubCodeBlockKind EEJitManager::GetStubCodeBlockKind(RangeSection * pRangeSectio } TADDR start = dac_cast(pRangeSection->_pjit)->FindMethodCode(pRangeSection, currentPC); - if (start == NULL) + if (start == (TADDR)0) return STUB_CODE_BLOCK_NOCODE; CodeHeader * pCHdr = PTR_CodeHeader(start - sizeof(CodeHeader)); return pCHdr->IsStubCodeBlock() ? pCHdr->GetStubCodeBlockKind() : STUB_CODE_BLOCK_MANAGED; @@ -4425,7 +4425,7 @@ ExecutionManager::FindCodeRange(PCODE currentPC, ScanFlag scanFlag) SUPPORTS_DAC; } CONTRACTL_END; - if (currentPC == NULL) + if (currentPC == (PCODE)NULL) return NULL; if (scanFlag == ScanReaderLock) @@ -4463,7 +4463,7 @@ ExecutionManager::FindCodeRangeWithLock(PCODE currentPC) PCODE ExecutionManager::GetCodeStartAddress(PCODE currentPC) { WRAPPER_NO_CONTRACT; - _ASSERTE(currentPC != NULL); + _ASSERTE(currentPC != (PCODE)NULL); EECodeInfo codeInfo(currentPC); if (!codeInfo.IsValid()) @@ -4511,7 +4511,7 @@ BOOL ExecutionManager::IsManagedCode(PCODE currentPC) GC_NOTRIGGER; } CONTRACTL_END; - if (currentPC == NULL) + if (currentPC == (PCODE)NULL) return FALSE; if (GetScanFlags() == ScanReaderLock) @@ -4568,7 +4568,7 @@ BOOL ExecutionManager::IsManagedCodeWorker(PCODE currentPC, RangeSectionLockStat // but on we could also be in a stub, so we check for that // as well and we don't consider stub to be real managed code. TADDR start = dac_cast(pRS->_pjit)->FindMethodCode(pRS, currentPC); - if (start == NULL) + if (start == (TADDR)0) return FALSE; CodeHeader * pCHdr = PTR_CodeHeader(start - sizeof(CodeHeader)); if (!pCHdr->IsStubCodeBlock()) @@ -4968,7 +4968,7 @@ PCODE ExecutionManager::jumpStub(MethodDesc* pMD, PCODE target, POSTCONDITION((RETVAL != NULL) || !throwOnOutOfMemoryWithinRange); } CONTRACT_END; - PCODE jumpStub = NULL; + PCODE jumpStub = (PCODE)NULL; if (pLoaderAllocator == NULL) { @@ -5018,7 +5018,7 @@ PCODE ExecutionManager::jumpStub(MethodDesc* pMD, PCODE target, { jumpStub = i->m_jumpStub; - _ASSERTE(jumpStub != NULL); + _ASSERTE(jumpStub != (PCODE)NULL); // Is the matching entry with the requested range? if (((TADDR)loAddr <= jumpStub) && (jumpStub <= (TADDR)hiAddr)) @@ -5030,10 +5030,10 @@ PCODE ExecutionManager::jumpStub(MethodDesc* pMD, PCODE target, // If we get here we need to create a new jump stub // add or change the jump stub table to point at the new one jumpStub = getNextJumpStub(pMD, target, loAddr, hiAddr, pLoaderAllocator, throwOnOutOfMemoryWithinRange); // this statement can throw - if (jumpStub == NULL) + if (jumpStub == (PCODE)NULL) { _ASSERTE(!throwOnOutOfMemoryWithinRange); - RETURN(NULL); + RETURN((PCODE)NULL); } _ASSERTE(((TADDR)loAddr <= jumpStub) && (jumpStub <= (TADDR)hiAddr)); @@ -5133,7 +5133,7 @@ PCODE ExecutionManager::getNextJumpStub(MethodDesc* pMD, PCODE target, if (curBlock == NULL) { _ASSERTE(!throwOnOutOfMemoryWithinRange); - RETURN(NULL); + RETURN((PCODE)NULL); } curBlockWriterHolder.AssignExecutableWriterHolder(curBlock, sizeof(JumpStubBlockHeader) + ((size_t) (curBlock->m_used + 1) * BACK_TO_BACK_JUMP_ALLOCATE_SIZE)); diff --git a/src/coreclr/vm/codeman.h b/src/coreclr/vm/codeman.h index 038ce3fe875ec..3319d3e0c3003 100644 --- a/src/coreclr/vm/codeman.h +++ b/src/coreclr/vm/codeman.h @@ -1358,7 +1358,12 @@ class RangeSectionMap // This level is completely empty. Free it, and then null out the pointer to it. pointerToLevelData->Uninstall(); +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wfree-nonheap-object" // The compiler can't tell that this pointer always comes from a malloc call. free((void*)rawData); +#pragma GCC diagnostic pop +#endif } } diff --git a/src/coreclr/vm/common.h b/src/coreclr/vm/common.h index f0edc0f15cd00..8b8ff9e842b3a 100644 --- a/src/coreclr/vm/common.h +++ b/src/coreclr/vm/common.h @@ -58,7 +58,7 @@ #include #include #include - +#include #include #include @@ -66,13 +66,16 @@ #include #include #include -#include +#include #include #include #include #include +using std::max; +using std::min; + #ifdef _MSC_VER //non inline intrinsics are faster #pragma function(memcpy,memcmp,strcmp,strcpy,strlen,strcat) diff --git a/src/coreclr/vm/dacenumerablehash.inl b/src/coreclr/vm/dacenumerablehash.inl index a6083e26fda4e..93d63116e0f42 100644 --- a/src/coreclr/vm/dacenumerablehash.inl +++ b/src/coreclr/vm/dacenumerablehash.inl @@ -7,7 +7,7 @@ // See DacEnumerableHash.h for a more detailed description. // -#include "clr_std/type_traits" +#include // Our implementation embeds entry data supplied by the hash sub-class into a larger entry structure // containing DacEnumerableHash metadata. We often end up returning pointers to the inner entry to sub-class code and diff --git a/src/coreclr/vm/dllimportcallback.h b/src/coreclr/vm/dllimportcallback.h index fb2214a8c18d5..ac2f2e93cdfd0 100644 --- a/src/coreclr/vm/dllimportcallback.h +++ b/src/coreclr/vm/dllimportcallback.h @@ -185,7 +185,7 @@ class UMEntryThunk uMThunkMarshInfoWriterHolder.GetRW()->RunTimeInit(); // Ensure that we have either the managed target or the delegate. - if (m_pObjectHandle == NULL && m_pManagedTarget == NULL) + if (m_pObjectHandle == NULL && m_pManagedTarget == (TADDR)0) m_pManagedTarget = m_pMD->GetMultiCallableAddrOfCode(); m_code.Encode(&pUMEntryThunkRX->m_code, (BYTE*)m_pUMThunkMarshInfo->GetExecStubEntryPoint(), pUMEntryThunkRX); @@ -223,7 +223,7 @@ class UMEntryThunk } else { - if (m_pManagedTarget != NULL) + if (m_pManagedTarget != (TADDR)0) { RETURN m_pManagedTarget; } diff --git a/src/coreclr/vm/dynamicmethod.cpp b/src/coreclr/vm/dynamicmethod.cpp index 065d80d57fcc1..beeb0cd64b2a8 100644 --- a/src/coreclr/vm/dynamicmethod.cpp +++ b/src/coreclr/vm/dynamicmethod.cpp @@ -515,7 +515,7 @@ HostCodeHeap::TrackAllocation* HostCodeHeap::AllocFromFreeList(size_t header, si // The space left is not big enough for a new block, let's just // update the TrackAllocation record for the current block - if (pCurrent->size - realSize < max(HOST_CODEHEAP_SIZE_ALIGN, sizeof(TrackAllocation))) + if (pCurrent->size - realSize < max(HOST_CODEHEAP_SIZE_ALIGN, sizeof(TrackAllocation))) { LOG((LF_BCL, LL_INFO100, "Level2 - CodeHeap [0x%p] - Item removed %p, size 0x%X\n", this, pCurrent, pCurrent->size)); // remove current diff --git a/src/coreclr/vm/eetwain.cpp b/src/coreclr/vm/eetwain.cpp index b12aac718c84b..4cdfc0852a6a3 100644 --- a/src/coreclr/vm/eetwain.cpp +++ b/src/coreclr/vm/eetwain.cpp @@ -430,7 +430,7 @@ HRESULT EECodeManager::FixContextForEnC(PCONTEXT pCtx, { // This is an explicit (not special) var, so add its varNumber + 1 to our // max count ("+1" because varNumber is zero-based). - oldNumVars = max(oldNumVars, unsigned(-ICorDebugInfo::UNKNOWN_ILNUM) + varNumber + 1); + oldNumVars = max(oldNumVars, (unsigned)(unsigned(-ICorDebugInfo::UNKNOWN_ILNUM) + varNumber + 1)); } } @@ -484,7 +484,7 @@ HRESULT EECodeManager::FixContextForEnC(PCONTEXT pCtx, { // This is an explicit (not special) var, so add its varNumber + 1 to our // max count ("+1" because varNumber is zero-based). - newNumVars = max(newNumVars, unsigned(-ICorDebugInfo::UNKNOWN_ILNUM) + varNumber + 1); + newNumVars = max(newNumVars, (unsigned)(unsigned(-ICorDebugInfo::UNKNOWN_ILNUM) + varNumber + 1)); } } diff --git a/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h b/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h index e6036353d8b9f..fb6c0c3feeda0 100644 --- a/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h +++ b/src/coreclr/vm/eventing/eventpipe/ds-rt-coreclr.h @@ -391,7 +391,11 @@ ds_rt_server_log_pause_message (void) STATIC_CONTRACT_NOTHROW; const char diagPortsName[] = "DiagnosticPorts"; - CLRConfigNoCache diagPorts = CLRConfigNoCache::Get(diagPortsName); +#ifdef HOST_WINDOWS + CLRConfigNoCache diagPorts = CLRConfigNoCache::Get(diagPortsName); +#else + CLRConfigNoCache diagPorts = CLRConfigNoCache::Get(diagPortsName, /* noPrefix */ false, &PAL_getenv); +#endif LPCSTR ports = nullptr; if (diagPorts.IsSet()) { diff --git a/src/coreclr/vm/interpreter.h b/src/coreclr/vm/interpreter.h index 86a0a36efe452..7f7eed175dea0 100644 --- a/src/coreclr/vm/interpreter.h +++ b/src/coreclr/vm/interpreter.h @@ -13,7 +13,7 @@ #include "crst.h" #include "callhelpers.h" #include "codeversion.h" -#include "clr_std/type_traits" +#include typedef SSIZE_T NativeInt; typedef SIZE_T NativeUInt; diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 9f2ed013aa1db..18629a0da2414 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -58,6 +58,9 @@ #include "exinfo.h" +using std::isfinite; +using std::isnan; + //======================================================================== // // This file contains implementation of all JIT helpers. The helpers are @@ -264,7 +267,7 @@ HCIMPL2(INT32, JIT_Div, INT32 dividend, INT32 divisor) } else if (divisor == -1) { - if (dividend == _I32_MIN) + if (dividend == INT32_MIN) { ehKind = kOverflowException; goto ThrowExcep; @@ -296,7 +299,7 @@ HCIMPL2(INT32, JIT_Mod, INT32 dividend, INT32 divisor) } else if (divisor == -1) { - if (dividend == _I32_MIN) + if (dividend == INT32_MIN) { ehKind = kOverflowException; goto ThrowExcep; diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index bcaf0351e52b3..0889e131f037c 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -700,7 +700,7 @@ size_t CEEInfo::printObjectDescription ( const UTF8* utf8data = stackStr.GetUTF8(); if (bufferSize > 0) { - bytesWritten = min(bufferSize - 1, stackStr.GetCount()); + bytesWritten = min(bufferSize - 1, stackStr.GetCount()); memcpy((BYTE*)buffer, (BYTE*)utf8data, bytesWritten); // Always null-terminate @@ -11452,7 +11452,7 @@ void CEEJitInfo::recordRelocation(void * location, // Keep track of conservative estimate of how much memory may be needed by jump stubs. We will use it to reserve extra memory // on retry to increase chances that the retry succeeds. - m_reserveForJumpStubs = max(0x400, m_reserveForJumpStubs + 0x10); + m_reserveForJumpStubs = max((size_t)0x400, m_reserveForJumpStubs + 0x10); } } @@ -11511,7 +11511,7 @@ void CEEJitInfo::recordRelocation(void * location, // Keep track of conservative estimate of how much memory may be needed by jump stubs. We will use it to reserve extra memory // on retry to increase chances that the retry succeeds. - m_reserveForJumpStubs = max(0x400, m_reserveForJumpStubs + 2*BACK_TO_BACK_JUMP_ALLOCATE_SIZE); + m_reserveForJumpStubs = max((size_t)0x400, m_reserveForJumpStubs + 2*BACK_TO_BACK_JUMP_ALLOCATE_SIZE); if (jumpStubAddr == 0) { diff --git a/src/coreclr/vm/methodtable.cpp b/src/coreclr/vm/methodtable.cpp index a59440400b634..67903433833b5 100644 --- a/src/coreclr/vm/methodtable.cpp +++ b/src/coreclr/vm/methodtable.cpp @@ -9586,7 +9586,7 @@ int MethodTable::GetFieldAlignmentRequirement() { return GetClass()->GetOverriddenFieldAlignmentRequirement(); } - return min(GetNumInstanceFieldBytes(), TARGET_POINTER_SIZE); + return min((int)GetNumInstanceFieldBytes(), TARGET_POINTER_SIZE); } UINT32 MethodTable::GetNativeSize() diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 5a9670b19f2da..69d2a105ecd8d 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -8419,7 +8419,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach else #endif // FEATURE_64BIT_ALIGNMENT if (dwNumInstanceFieldBytes > TARGET_POINTER_SIZE) { - minAlign = containsGCPointers ? TARGET_POINTER_SIZE : (unsigned)largestAlignmentRequirement; + minAlign = (unsigned)(containsGCPointers ? TARGET_POINTER_SIZE : largestAlignmentRequirement); } else { minAlign = 1; @@ -8427,7 +8427,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach minAlign *= 2; } - if (minAlign != min(dwNumInstanceFieldBytes, TARGET_POINTER_SIZE)) + if (minAlign != min(dwNumInstanceFieldBytes, (DWORD)TARGET_POINTER_SIZE)) { EnsureOptionalFieldsAreAllocated(GetHalfBakedClass(), m_pAllocMemTracker, GetLoaderAllocator()->GetLowFrequencyHeap()); GetHalfBakedClass()->GetOptionalFields()->m_requiredFieldAlignment = (BYTE)minAlign; diff --git a/src/coreclr/vm/object.inl b/src/coreclr/vm/object.inl index 7f58c122097be..491aab1d4c873 100644 --- a/src/coreclr/vm/object.inl +++ b/src/coreclr/vm/object.inl @@ -91,7 +91,7 @@ inline void Object::EnumMemoryRegions(void) // Unfortunately, DacEnumMemoryRegion takes only ULONG32 as size argument while (size > 0) { // Use 0x10000000 instead of MAX_ULONG32 so that the chunks stays aligned - SIZE_T chunk = min(size, 0x10000000); + SIZE_T chunk = min(size, (SIZE_T)0x10000000); // If for any reason we can't enumerate the memory, stop. This would generally mean // that we have target corruption, or that the target is executing, etc. if (!DacEnumMemoryRegion(ptr, chunk)) diff --git a/src/coreclr/vm/perfmap.cpp b/src/coreclr/vm/perfmap.cpp index 4ede16efca076..d032dc6031dce 100644 --- a/src/coreclr/vm/perfmap.cpp +++ b/src/coreclr/vm/perfmap.cpp @@ -46,7 +46,11 @@ void PerfMap::Initialize() const char * PerfMap::InternalConstructPath() { +#ifdef HOST_WINDOWS CLRConfigNoCache value = CLRConfigNoCache::Get("PerfMapJitDumpPath"); +#else + CLRConfigNoCache value = CLRConfigNoCache::Get("PerfMapJitDumpPath", /* noPrefix */ false, &PAL_getenv); +#endif if (value.IsSet()) { return value.AsString(); diff --git a/src/coreclr/vm/profdetach.cpp b/src/coreclr/vm/profdetach.cpp index 09f11458c3887..7bfcba8ed2cc6 100644 --- a/src/coreclr/vm/profdetach.cpp +++ b/src/coreclr/vm/profdetach.cpp @@ -446,8 +446,8 @@ void ProfilingAPIDetach::SleepWhileProfilerEvacuates(ProfilerDetachInfo *pDetach } // ...but keep it in bounds! - ui64SleepMilliseconds = min( - max(ui64SleepMilliseconds, s_dwMinSleepMs), + ui64SleepMilliseconds = min( + max(ui64SleepMilliseconds, s_dwMinSleepMs), s_dwMaxSleepMs); // At this point it's safe to cast ui64SleepMilliseconds down to a DWORD since we diff --git a/src/coreclr/vm/proftoeeinterfaceimpl.cpp b/src/coreclr/vm/proftoeeinterfaceimpl.cpp index 8c94aca1c4089..e57cba3c597d7 100644 --- a/src/coreclr/vm/proftoeeinterfaceimpl.cpp +++ b/src/coreclr/vm/proftoeeinterfaceimpl.cpp @@ -5605,7 +5605,7 @@ HRESULT ProfToEEInterfaceImpl::GetAssemblyInfo(AssemblyID assemblyId, if ((NULL != szName) && (cchName > 0)) { - wcsncpy_s(szName, cchName, name.GetUnicode(), min(nameLength, cchName - 1)); + wcsncpy_s(szName, cchName, name.GetUnicode(), min((size_t)nameLength, (size_t)(cchName - 1))); } if (NULL != pcchName) diff --git a/src/coreclr/vm/qcall.h b/src/coreclr/vm/qcall.h index d5f355ad9662b..e3154c7b1334c 100644 --- a/src/coreclr/vm/qcall.h +++ b/src/coreclr/vm/qcall.h @@ -7,7 +7,7 @@ #ifndef __QCall_h__ #define __QCall_h__ -#include "clr_std/type_traits" +#include // // QCALLS diff --git a/src/coreclr/vm/stackingallocator.cpp b/src/coreclr/vm/stackingallocator.cpp index cee2b40049100..7db829eb1b441 100644 --- a/src/coreclr/vm/stackingallocator.cpp +++ b/src/coreclr/vm/stackingallocator.cpp @@ -188,7 +188,7 @@ bool StackingAllocator::AllocNewBlockForBytes(unsigned n) // request is larger than MaxBlockSize then allocate exactly that // amount. unsigned lower = MinBlockSize; - size_t allocSize = sizeof(StackBlock) + max(n, min(max(n * 4, lower), MaxBlockSize)); + size_t allocSize = sizeof(StackBlock) + max(n, min(max(n * 4, lower), (unsigned)MaxBlockSize)); // Allocate the block. // @todo: Is it worth implementing a non-thread safe standard heap for diff --git a/src/coreclr/vm/stringliteralmap.cpp b/src/coreclr/vm/stringliteralmap.cpp index 29d457207bf8d..55d2267f02c8c 100644 --- a/src/coreclr/vm/stringliteralmap.cpp +++ b/src/coreclr/vm/stringliteralmap.cpp @@ -442,7 +442,7 @@ static void LogStringLiteral(_In_z_ const char* action, EEStringData *pStringDat STATIC_CONTRACT_FORBID_FAULT; ULONG length = pStringData->GetCharCount(); - length = min(length, 128); + length = min(length, (ULONG)128); WCHAR *szString = (WCHAR *)_alloca((length + 1) * sizeof(WCHAR)); memcpyNoGCRefs((void*)szString, (void*)pStringData->GetStringBuffer(), length * sizeof(WCHAR)); szString[length] = '\0'; diff --git a/src/coreclr/vm/syncblk.cpp b/src/coreclr/vm/syncblk.cpp index 2cc7de6bd2b09..eb0b29fafdd02 100644 --- a/src/coreclr/vm/syncblk.cpp +++ b/src/coreclr/vm/syncblk.cpp @@ -2681,7 +2681,7 @@ BOOL AwareLock::EnterEpilogHelper(Thread* pCurThread, INT32 timeOut) { duration = end - start; } - duration = min(duration, (DWORD)timeOut); + duration = min(duration, (ULONGLONG)timeOut); timeOut -= (INT32)duration; } } diff --git a/src/coreclr/vm/threadstatics.cpp b/src/coreclr/vm/threadstatics.cpp index 94088ba399947..6a8a43a0821ef 100644 --- a/src/coreclr/vm/threadstatics.cpp +++ b/src/coreclr/vm/threadstatics.cpp @@ -125,7 +125,7 @@ void ThreadLocalBlock::EnsureModuleIndex(ModuleIndex index) return; } - SIZE_T aModuleIndices = max(16, m_TLMTableSize); + SIZE_T aModuleIndices = max((SIZE_T)16, m_TLMTableSize); while (aModuleIndices <= index.m_dwIndex) { aModuleIndices *= 2; @@ -411,7 +411,7 @@ void ThreadLocalModule::EnsureDynamicClassIndex(DWORD dwID) return; } - SIZE_T aDynamicEntries = max(16, m_aDynamicEntries); + SIZE_T aDynamicEntries = max((SIZE_T)16, m_aDynamicEntries); while (aDynamicEntries <= dwID) { aDynamicEntries *= 2; diff --git a/src/coreclr/vm/util.hpp b/src/coreclr/vm/util.hpp index e7b311d8724d4..ef05074b186a4 100644 --- a/src/coreclr/vm/util.hpp +++ b/src/coreclr/vm/util.hpp @@ -16,7 +16,7 @@ #include "clrdata.h" #include "xclrdata.h" #include "posterror.h" -#include "clr_std/type_traits" +#include // Hot cache lines need to be aligned to cache line size to improve performance #if defined(TARGET_ARM64) diff --git a/src/coreclr/vm/vars.hpp b/src/coreclr/vm/vars.hpp index 63a27a8701e54..51533187c8b65 100644 --- a/src/coreclr/vm/vars.hpp +++ b/src/coreclr/vm/vars.hpp @@ -16,46 +16,6 @@ typedef DPTR(SLOT) PTR_SLOT; typedef LPVOID DictionaryEntry; -/* Define the implementation dependent size types */ - -#ifndef _INTPTR_T_DEFINED -#ifdef HOST_64BIT -typedef __int64 intptr_t; -#else -typedef int intptr_t; -#endif -#define _INTPTR_T_DEFINED -#endif - -#ifndef _UINTPTR_T_DEFINED -#ifdef HOST_64BIT -typedef unsigned __int64 uintptr_t; -#else -typedef unsigned int uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif - -#ifndef _PTRDIFF_T_DEFINED -#ifdef HOST_64BIT -typedef __int64 ptrdiff_t; -#else -typedef int ptrdiff_t; -#endif -#define _PTRDIFF_T_DEFINED -#endif - - -#ifndef _SIZE_T_DEFINED -#ifdef HOST_64BIT -typedef unsigned __int64 size_t; -#else -typedef unsigned int size_t; -#endif -#define _SIZE_T_DEFINED -#endif - - #include "util.hpp" #include #include diff --git a/src/coreclr/vm/virtualcallstub.cpp b/src/coreclr/vm/virtualcallstub.cpp index e82f8b84a580b..a87eac54f607c 100644 --- a/src/coreclr/vm/virtualcallstub.cpp +++ b/src/coreclr/vm/virtualcallstub.cpp @@ -823,6 +823,8 @@ void VirtualCallStubManager::ReclaimAll() g_reclaim_counter++; } +const UINT32 VirtualCallStubManager::counter_block::MAX_COUNTER_ENTRIES; + /* reclaim/rearrange any structures that can only be done during a gc sync point i.e. need to be serialized and non-concurrant. */ void VirtualCallStubManager::Reclaim() diff --git a/src/coreclr/vm/virtualcallstub.h b/src/coreclr/vm/virtualcallstub.h index e6d89dcf50381..156353b6c1862 100644 --- a/src/coreclr/vm/virtualcallstub.h +++ b/src/coreclr/vm/virtualcallstub.h @@ -282,7 +282,7 @@ class VirtualCallStubManager : public StubManager m_counters(NULL), m_cur_counter_block(NULL), m_cur_counter_block_for_reclaim(NULL), - m_cur_counter_block_for_reclaim_index(NULL), + m_cur_counter_block_for_reclaim_index(0), m_pNext(NULL) { LIMITED_METHOD_CONTRACT; diff --git a/src/mono/dlls/mscordbi/CMakeLists.txt b/src/mono/dlls/mscordbi/CMakeLists.txt index 52b4e62ad3412..e39aeac5ac6d2 100644 --- a/src/mono/dlls/mscordbi/CMakeLists.txt +++ b/src/mono/dlls/mscordbi/CMakeLists.txt @@ -110,7 +110,6 @@ if (CLR_CMAKE_HOST_UNIX) add_subdirectory(${CLR_DIR}/pal pal) include_directories(${CLR_DIR}/pal/inc/rt/cpp) - add_compile_options(-nostdinc) endif (CLR_CMAKE_HOST_UNIX) if (CLR_CMAKE_HOST_UNIX)