Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions eng/native/tryrun.browser.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# to significantly speed up the CMake configure phase for WebAssembly builds.
#
# IMPORTANT: This file is specific to the Emscripten version and WebAssembly target.
#
#
# Valid for:
# - Emscripten version: 6.0.2
# - Target: wasm32-unknown-emscripten (browser-wasm)
Expand Down Expand Up @@ -249,9 +249,6 @@ set(HAVE_PROCFS_H "" CACHE INTERNAL "")
set(HAVE_PROCFS_STAT_COMPILED TRUE CACHE INTERNAL "")
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
set(HAVE_PROCFS_STAT "" CACHE INTERNAL "")
set(HAVE_PROCFS_STATM_COMPILED TRUE CACHE INTERNAL "")
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1)
set(HAVE_PROCFS_STATM "" CACHE INTERNAL "")
set(HAVE_PT_REGS FALSE CACHE INTERNAL "")
set(HAVE_PTHREAD_ATTR_GET_NP "" CACHE INTERNAL "")
set(HAVE_PTHREAD_CONDATTR_SETCLOCK 1 CACHE INTERNAL "")
Expand Down Expand Up @@ -351,9 +348,3 @@ set(HAVE_VM_FLAGS_SUPERPAGE_SIZE_ANY "" CACHE INTERNAL "")
set(HAVE_VM_READ "" CACHE INTERNAL "")
set(HAVE_XSW_USAGE "" CACHE INTERNAL "")
set(HAVE_XSWDEV "" CACHE INTERNAL "")
set(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_COMPILED TRUE CACHE INTERNAL "")
set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
set(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS "" CACHE INTERNAL "")
set(REALPATH_SUPPORTS_NONEXISTENT_FILES_COMPILED TRUE CACHE INTERNAL "")
set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
set(REALPATH_SUPPORTS_NONEXISTENT_FILES "" CACHE INTERNAL "")
11 changes: 0 additions & 11 deletions eng/native/tryrun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ if(DARWIN AND NOT DEFINED ANDROID_BUILD)
set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1)
set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 1)
set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 1)
else()
message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm64 or x64 is supported for OSX cross build!")
Expand All @@ -75,11 +72,8 @@ else()
set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 0)
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 0)
set_cache_value(HAVE_SCHED_GETCPU_EXITCODE 0)
set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
if(ALPINE_LINUX)
set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 1)
else()
Expand All @@ -90,19 +84,14 @@ else()
set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP 1)
set_cache_value(HAVE_CLOCK_REALTIME 1)
set_cache_value(HAVE_PROCFS_STAT 0)
set_cache_value(HAVE_PROCFS_STATM 0)
elseif(OPENBSD)
set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP 1)
set_cache_value(HAVE_CLOCK_REALTIME 1)
set_cache_value(HAVE_PROCFS_STAT 0)
set_cache_value(HAVE_PROCFS_STATM 0)
elseif(ILLUMOS)
set_cache_value(HAVE_PROCFS_CTL_EXITCODE 0)
elseif (TIZEN)
elseif(HAIKU)
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1)
elseif(ANDROID_BUILD)
set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS 0)
endif()
endif()
3 changes: 0 additions & 3 deletions eng/native/tryrun_ios_tvos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ set_cache_value(HAVE_CLOCK_REALTIME_EXITCODE 0)
set_cache_value(HAVE_CLOCK_THREAD_CPUTIME_EXITCODE 0)
set_cache_value(HAVE_PROCFS_CTL_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STAT_EXITCODE 1)
set_cache_value(HAVE_PROCFS_STATM_EXITCODE 1)
set_cache_value(HAVE_SCHED_GET_PRIORITY_EXITCODE 0)
set_cache_value(ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS_EXITCODE 1)
set_cache_value(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1)
set_cache_value(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP_EXITCODE 1)
4 changes: 0 additions & 4 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ if(CLR_CMAKE_TARGET_WASI)
add_compile_definitions(_WASI_EMULATED_MMAN)
add_compile_definitions(_WASI_EMULATED_GETPID)
include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/pal/src/include/pal/wasi)
# Cross-compile try_run() answers — wasm32 binaries cannot execute on
# the build host, so pre-seed the cache.
set(REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 1 CACHE STRING "" FORCE)
set(HAVE_PROCFS_STATM_EXITCODE 1 CACHE STRING "" FORCE)
endif()

OPTION(CLR_CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/debug/createdump/createdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,4 @@ extern MINIDUMP_TYPE GetMiniDumpType(DumpType dumpType);
#ifdef HOST_WINDOWS
extern std::string GetLastErrorString();
extern DWORD GetTempPathWrapper(IN DWORD nBufferLength, OUT LPSTR lpBuffer);
#else
#define GetTempPathWrapper GetTempPathA
#endif
15 changes: 15 additions & 0 deletions src/coreclr/debug/createdump/createdumpmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,26 @@ void print_trace_timestamp()

bool GetDefaultDumpPath(char* buffer, size_t bufferSize)
{
#ifdef HOST_WINDOWS
if (bufferSize > MAXDWORD || GetTempPathWrapper(static_cast<DWORD>(bufferSize), buffer) == 0)
{
printf_error("GetTempPath failed\n");
return false;
}
#else
const char* tmpDir = getenv("TMPDIR");
if (tmpDir == nullptr || tmpDir[0] == '\0')
{
tmpDir = "/tmp/";
}
const char* slash = (tmpDir[strlen(tmpDir) - 1] == '/') ? "" : "/";
int len = snprintf(buffer, bufferSize, "%s%s", tmpDir, slash);
if (len < 0 || static_cast<size_t>(len) >= bufferSize)
{
printf_error("TMPDIR is too long\n");
return false;
}
#endif
int exitCode = strcat_s(buffer, bufferSize, DEFAULT_DUMP_TEMPLATE);
if (exitCode != 0)
{
Expand Down
29 changes: 0 additions & 29 deletions src/coreclr/debug/createdump/createdumppal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,6 @@ DEFINE_GUID(IID_IUnknown, 0x00000000, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x
bool g_arm64_atomics_present = false;
#endif

#define TEMP_DIRECTORY_PATH "/tmp/"

// Used to construct the default dump path.
DWORD
PALAPI
GetTempPathA(
IN DWORD nBufferLength,
OUT LPSTR lpBuffer)
{
DWORD dwPathLen = 0;
const char *tempDir = getenv("TMPDIR");
if (tempDir == nullptr)
{
tempDir = TEMP_DIRECTORY_PATH;
}
size_t tempDirLen = strlen(tempDir);
if (tempDirLen < nBufferLength)
{
dwPathLen = tempDirLen;
strcpy_s(lpBuffer, nBufferLength, tempDir);
}
else
{
// Get the required length
dwPathLen = tempDirLen + 1;
}
return dwPathLen;
}

//
// Used in pal\inc\rt\safecrt.h's _invalid_parameter handler
//
Expand Down
15 changes: 0 additions & 15 deletions src/coreclr/dlls/mscordac/mscordac_unixexports.src
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,10 @@ nativeStringResourceTable_mscorrc
#memcpy_s
#sscanf_s

#CreateFileMappingW
#CreateFileA
#CreateFileW
#CreateThread
#CloseHandle
#DebugBreak
#DuplicateHandle
#FlushFileBuffers
#FlushInstructionCache
#FormatMessageW
#FreeEnvironmentStringsW
Expand All @@ -74,33 +70,22 @@ nativeStringResourceTable_mscorrc
#GetEnvironmentStringsW
#GetEnvironmentVariableA
#GetEnvironmentVariableW
#GetFileSize
#GetFullPathNameW
#GetLastError
#GetModuleFileNameW
#GetProcAddress
#GetStdHandle
#GetSystemInfo
#GetTempPathA
#LoadLibraryExA
#LoadLibraryExW
#MapViewOfFile
#MapViewOfFileEx
#MultiByteToWideChar
#OutputDebugStringW
#OutputDebugStringA
#RaiseException
#RaiseFailFastException
#ReadFile
#ResumeThread
#SearchPathW
#SetFilePointer
#SetLastError
#SetThreadDescription
#SwitchToThread
#TerminateProcess
#UnmapViewOfFile
#WideCharToMultiByte
#WriteFile

#GUID_NULL
1 change: 0 additions & 1 deletion src/coreclr/gc/unix/config.gc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@
#cmakedefine01 HAVE_XSW_USAGE
#cmakedefine01 HAVE_XSWDEV
#cmakedefine01 HAVE_NON_LEGACY_STATFS
#cmakedefine01 HAVE_PROCFS_STATM

#endif // __CONFIG_H__
17 changes: 0 additions & 17 deletions src/coreclr/gc/unix/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -159,21 +159,4 @@ check_prototype_definition(
${STATFS_INCLUDES}
HAVE_NON_LEGACY_STATFS)

set(CMAKE_REQUIRED_LIBRARIES)
check_cxx_source_runs("
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

int main(void) {
int fd;

fd = open(\"/proc/self/statm\", O_RDONLY);
if (fd == -1) {
exit(1);
}
exit(0);
}" HAVE_PROCFS_STATM)

configure_file(${CMAKE_CURRENT_LIST_DIR}/config.gc.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.gc.h)
8 changes: 4 additions & 4 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ const AffinitySet* GCToOSInterface::SetGCThreadsAffinitySet(uintptr_t configAffi
return &g_processAffinitySet;
}

#if HAVE_PROCFS_STATM
#ifdef RLIMIT_AS
// Return the size of the user-mode portion of the virtual address space of this process.
static size_t GetCurrentVirtualMemorySize()
{
Expand Down Expand Up @@ -1016,7 +1016,7 @@ static size_t GetCurrentVirtualMemorySize()

return result;
}
#endif // HAVE_PROCFS_STATM
#endif // RLIMIT_AS

// Return the size of the available user-mode portion of the virtual address space of this process.
// Return:
Expand Down Expand Up @@ -1321,7 +1321,7 @@ void GCToOSInterface::GetMemoryStatus(uint64_t restricted_limit, uint32_t* memor
load = (uint32_t)(((float)used * 100) / (float)total);
}

#if HAVE_PROCFS_STATM
#ifdef RLIMIT_AS
rlimit addressSpaceLimit;
if ((getrlimit(RLIMIT_AS, &addressSpaceLimit) == 0) && (addressSpaceLimit.rlim_cur != RLIM_INFINITY))
{
Expand All @@ -1337,7 +1337,7 @@ void GCToOSInterface::GetMemoryStatus(uint64_t restricted_limit, uint32_t* memor
}
}
}
#endif // HAVE_PROCFS_STATM
#endif // RLIMIT_AS
}
}

Expand Down
44 changes: 20 additions & 24 deletions src/coreclr/ilasm/asmparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#define asmparse_h

#include <stdio.h> // for FILE
#include "minipal.h"

#include "assembler.h" // for ErrorReporter Labels
//class Assembler;
Expand Down Expand Up @@ -95,9 +96,9 @@ class MappedFileStream : public ReadStream {
public:
MappedFileStream(_In_ __nullterminated WCHAR* wFileName)
: m_fileNameUtf8(NULL)
, m_hFile(INVALID_HANDLE_VALUE)
, m_hFile(VMToOSInterface::InvalidFileHandle)
, m_FileSize(0)
, m_hMapFile(NULL)
, m_hMapFile(VMToOSInterface::InvalidMemoryMapHandle)
{
m_pStart = open(wFileName);
m_pCurr = m_pStart;
Expand All @@ -112,17 +113,17 @@ class MappedFileStream : public ReadStream {
}
~MappedFileStream()
{
if (m_hFile != INVALID_HANDLE_VALUE)
if (m_hFile != VMToOSInterface::InvalidFileHandle)
{
if (m_pStart)
UnmapViewOfFile((void*)m_pStart);
if (m_hMapFile)
CloseHandle(m_hMapFile);
CloseHandle(m_hFile);
VMToOSInterface::UnmapMemory((void*)m_pStart, m_FileSize);
if (m_hMapFile != VMToOSInterface::InvalidMemoryMapHandle)
VMToOSInterface::CloseMemoryMapping(m_hMapFile);
VMToOSInterface::CloseFile(m_hFile);

m_pStart = NULL;
m_hMapFile = NULL;
m_hFile = INVALID_HANDLE_VALUE;
m_hMapFile = VMToOSInterface::InvalidMemoryMapHandle;
m_hFile = VMToOSInterface::InvalidFileHandle;
m_FileSize = 0;
}

Expand Down Expand Up @@ -173,35 +174,32 @@ class MappedFileStream : public ReadStream {
private:
char* map_file()
{
DWORD dwFileSizeLow;
uint64_t fileSize;

dwFileSizeLow = GetFileSize( m_hFile, NULL);
if (dwFileSizeLow == INVALID_FILE_SIZE)
if (!VMToOSInterface::GetFileSize(m_hFile, &fileSize) || fileSize == 0 || fileSize > UINT32_MAX)
return NULL;
m_FileSize = dwFileSizeLow;
m_FileSize = (DWORD)fileSize;

// No difference between A and W in this case: last param (LPCTSTR) is NULL
m_hMapFile = CreateFileMapping(m_hFile, NULL, PAGE_READONLY, 0, 0, NULL);
if (m_hMapFile == NULL)
m_hMapFile = VMToOSInterface::CreateMemoryMapping(m_hFile, 0, VMToOSInterface::MemoryProtection::ReadOnly);
if (m_hMapFile == VMToOSInterface::InvalidMemoryMapHandle)
return NULL;

return (char*)(HMODULE) MapViewOfFile(m_hMapFile, FILE_MAP_READ, 0, 0, 0);
return (char*)VMToOSInterface::MapMemory(m_hMapFile, 0, nullptr, m_FileSize, VMToOSInterface::MemoryProtection::ReadOnly, true);
}
char* open(const WCHAR* moduleName)
{
_ASSERTE(moduleName);
if (!moduleName)
return NULL;

m_hFile = WszCreateFile(moduleName, GENERIC_READ, FILE_SHARE_READ,
0, OPEN_EXISTING, 0, 0);
return (m_hFile == INVALID_HANDLE_VALUE) ? NULL : map_file();
m_hFile = VMToOSInterface::OpenFile(reinterpret_cast<const char16_t*>(moduleName));
return (m_hFile == VMToOSInterface::InvalidFileHandle) ? NULL : map_file();
}

char* m_fileNameUtf8; // FileName (for error reporting)
HANDLE m_hFile; // File we are reading from
VMToOSInterface::MemoryMapHandle m_hFile; // File we are reading from
DWORD m_FileSize;
HANDLE m_hMapFile;
VMToOSInterface::MemoryMapHandle m_hMapFile;
char* m_pStart;
char* m_pEnd;
char* m_pCurr;
Expand Down Expand Up @@ -299,8 +297,6 @@ class AsmParse : public ErrorReporter
BinStr* MakeTypeArray(CorElementType kind, BinStr* elemType, BinStr* bounds);

char* fillBuff(_In_opt_z_ char* curPos); // refill the input buffer
HANDLE hstdout;
HANDLE hstderr;

private:
friend void yyerror(_In_ __nullterminated const char* str);
Expand Down
Loading
Loading