diff options
author | Rama Krishnan Raghupathy <ramarag@microsoft.com> | 2016-10-07 16:55:19 -0700 |
---|---|---|
committer | DDCloud <ramarag@microsoft.com> | 2016-10-25 15:00:50 -0700 |
commit | f2ac449d96ae21abf5b458645ff79ed328fe4ebc (patch) | |
tree | 8c52c966ebfae02e480b488c466bdb75245b105f | |
parent | 9735854c9e1222ba63340b0c62afefebd779ee66 (diff) | |
download | coreclr-f2ac449d96ae21abf5b458645ff79ed328fe4ebc.tar.gz coreclr-f2ac449d96ae21abf5b458645ff79ed328fe4ebc.tar.bz2 coreclr-f2ac449d96ae21abf5b458645ff79ed328fe4ebc.zip |
Making MemoryFailPoint functional on xplat
Expose GlobalMemoryStatusEx on Xplat
8 files changed, 83 insertions, 1 deletions
diff --git a/src/dlls/mscoree/mscorwks_unixexports.src b/src/dlls/mscoree/mscorwks_unixexports.src index 9c151a942c..f7862d3afe 100644 --- a/src/dlls/mscoree/mscorwks_unixexports.src +++ b/src/dlls/mscoree/mscorwks_unixexports.src @@ -98,6 +98,7 @@ UnlockFile UnmapViewOfFile VirtualAlloc VirtualFree +GlobalMemoryStatusEx VirtualQuery WideCharToMultiByte WriteFile diff --git a/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs b/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs index 6e35568310..4ae6047661 100644 --- a/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs +++ b/src/mscorlib/src/System/Runtime/MemoryFailPoint.cs @@ -324,6 +324,9 @@ namespace System.Runtime [System.Security.SecurityCritical] // auto-generated private static unsafe bool CheckForFreeAddressSpace(ulong size, bool shouldThrow) { +#if FEATURE_PAL // Remove this when GlobalMemoryStatusEx is able to provide legitimate estimates + return true; +#endif // Start walking the address space at 0. VirtualAlloc may wrap // around the address space. We don't need to find the exact // pages that VirtualAlloc would return - we just need to diff --git a/src/pal/src/map/virtual.cpp b/src/pal/src/map/virtual.cpp index 4b5209642c..316dfba93b 100644 --- a/src/pal/src/map/virtual.cpp +++ b/src/pal/src/map/virtual.cpp @@ -1096,6 +1096,7 @@ VIRTUALCommitMemory( } StartBoundary = pInformation->startBoundary + runStart * VIRTUAL_PAGE_SIZE; + pRetVal = (void *)StartBoundary; MemSize = runLength * VIRTUAL_PAGE_SIZE; if (allocationType != MEM_COMMIT) diff --git a/src/pal/src/misc/sysinfo.cpp b/src/pal/src/misc/sysinfo.cpp index 515ccf1cdb..e7589e8583 100644 --- a/src/pal/src/misc/sysinfo.cpp +++ b/src/pal/src/misc/sysinfo.cpp @@ -172,7 +172,7 @@ GetSystemInfo( #ifdef VM_MAXUSER_ADDRESS lpSystemInfo->lpMaximumApplicationAddress = (PVOID) VM_MAXUSER_ADDRESS; #elif defined(__sun__) || defined(_AIX) || defined(__hppa__) || ( defined (_IA64_) && defined (_HPUX_) ) || defined(__linux__) - lpSystemInfo->lpMaximumApplicationAddress = (PVOID) -1; + lpSystemInfo->lpMaximumApplicationAddress = (PVOID) (1ull << 47); #elif defined(USERLIMIT) lpSystemInfo->lpMaximumApplicationAddress = (PVOID) USERLIMIT; #elif defined(_WIN64) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt index eafaa66856..b2cafde93a 100644 --- a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/CMakeLists.txt @@ -14,6 +14,7 @@ add_subdirectory(test19) add_subdirectory(test2) add_subdirectory(test20) add_subdirectory(test21) +add_subdirectory(test22) add_subdirectory(test3) add_subdirectory(test4) add_subdirectory(test5) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/CMakeLists.txt b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/CMakeLists.txt new file mode 100644 index 0000000000..cdad2ca19d --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + VirtualAlloc.cpp +) + +add_executable(paltest_virtualalloc_test22 + ${SOURCES} +) + +add_dependencies(paltest_virtualalloc_test22 coreclrpal) + +target_link_libraries(paltest_virtualalloc_test22 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/VirtualAlloc.cpp b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/VirtualAlloc.cpp new file mode 100644 index 0000000000..489926f48d --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/VirtualAlloc.cpp @@ -0,0 +1,44 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*============================================================= +** +** Source: virtualalloc.c +** +** Purpose: Negative test the VirtualAlloc API. +** Call VirtualAlloc with MEM_COMMIT allocation type +** and PAGE_READWRITE access protection + +** +**============================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + int err; + LPVOID lpVirtualAddress; + + + //Initialize the PAL environment + err = PAL_Initialize(argc, argv); + if(0 != err) + { + ExitProcess(FAIL); + } + + //Allocate the physical storage in memory or in the paging file on disk + lpVirtualAddress = VirtualAlloc(NULL,//system determine where to allocate the region + (SIZE_T)(2147483647000000), //specify the size to be int32.maxvalue mega bytes + MEM_COMMIT, //allocation type + PAGE_READWRITE); //access protection + if(NULL != lpVirtualAddress) + { + Fail("\nWelcome to the Future, where Unlimited Memory is Available, disregard this test!\n"); + } + + + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/testinfo.dat b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/testinfo.dat new file mode 100644 index 0000000000..3d5962c7af --- /dev/null +++ b/src/pal/tests/palsuite/filemapping_memmgt/VirtualAlloc/test22/testinfo.dat @@ -0,0 +1,13 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = Filemapping_memmgt +Function = VirtualAlloc +Name = Negative test for VirtualAlloc API +TYPE = DEFAULT +EXE1 = virtualalloc +Description +=Test the VirtualAlloc with MEM_COMMIT allocation type +=and PAGE_READWRITEaccess protection |