Skip to content

Commit

Permalink
Remove various file reading (Linux specific) paths
Browse files Browse the repository at this point in the history
This removes a bunch of libc stuff from HelloWorld,
in addition to removing the actual file opening.
  • Loading branch information
SingleAccretion committed Jan 22, 2025
1 parent 4c716db commit b442c17
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/coreclr/gc/unix/gcenv.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,8 @@ uint64_t GetAvailablePhysicalMemory()
sysctlbyname("vm.stats.vm.v_free_count", &free_count, &sz, NULL, 0);

available = (inactive_count + laundry_count + free_count) * sysconf(_SC_PAGESIZE);
#elif defined(TARGET_WASM)
available = sysconf(SYSCONF_PAGES) * sysconf(_SC_PAGE_SIZE);
#else // Linux
static volatile bool tryReadMemInfo = true;

Expand Down
22 changes: 21 additions & 1 deletion src/coreclr/gc/wasm/gcenv.wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "common.h"
#include "gcenv.h"


// Flush write buffers of processors that are executing threads of the current process - a NOP for Wasm
void GCToOSInterface::FlushProcessWriteBuffers()
{
Expand Down Expand Up @@ -118,3 +117,24 @@ bool GCToOSInterface::VirtualReset(void* address, size_t size, bool unlock)
{
return false;
}

//
// CPU and memory limits - not avaliable on WASM (yet).
//
void InitializeCGroup()
{
}

void CleanupCGroup()
{
}

size_t GetRestrictedPhysicalMemoryLimit()
{
return 0; // 'Unlimited'.
}

bool GetPhysicalMemoryUsed(size_t* val)
{
return false; // 'Unknown'.
}
7 changes: 5 additions & 2 deletions src/coreclr/nativeaot/Runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,15 @@ else()
)

if (CLR_CMAKE_TARGET_ARCH_WASM)
list(REMOVE_ITEM COMMON_RUNTIME_SOURCES
${GC_DIR}/unix/cgroup.cpp
unix/PalCreateDump.cpp
)
list(APPEND COMMON_RUNTIME_SOURCES
${GC_DIR}/wasm/gcenv.wasm.cpp
wasm/PalCreateDump.cpp
unix/cgroupcpu.cpp
wasm/cgroupcpu.cpp
)
list(REMOVE_ITEM COMMON_RUNTIME_SOURCES unix/PalCreateDump.cpp)
endif()

list(APPEND FULL_RUNTIME_SOURCES
Expand Down
16 changes: 16 additions & 0 deletions src/coreclr/nativeaot/Runtime/wasm/cgroupcpu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#include <cstdint>

//
// No CPU or memory limits on WASM as yet.
//
void InitializeCpuCGroup()
{
}

bool GetCpuLimit(uint32_t* val)
{
return false;
}

0 comments on commit b442c17

Please sign in to comment.