diff --git a/common/memory/ksm.cpp b/common/memory/ksm.cpp index 874ebedc9..0179a2426 100644 --- a/common/memory/ksm.cpp +++ b/common/memory/ksm.cpp @@ -25,7 +25,6 @@ #include // For sysconf, sbrk #endif - #ifdef _WIN32 // Windows-specific functionality @@ -48,6 +47,38 @@ size_t PageAlignedAllocatorBase::getPageSize() const return sysInfo.dwPageSize; // Page size in bytes } +namespace KSM { + +// Windows-specific placeholder functions (no-op) +void CheckPageAlignment(void* ptr) +{ +} + +void* AllocatePageAligned(size_t size) +{ + return memset(malloc(size), 0, size); +} + +void MarkMemoryForKSM(void* start, size_t size) +{ +} + +void AlignHeapToPageBoundary() +{ +} + +void* MarkHeapStart() +{ + return nullptr; +} + +size_t MeasureHeapUsage(void* start) +{ + return 0; +} + +} // namespace KSM + #else // Linux-specific functionality @@ -69,6 +100,8 @@ size_t PageAlignedAllocatorBase::getPageSize() const return static_cast(sysconf(_SC_PAGESIZE)); } +namespace KSM { + void CheckPageAlignment(void* ptr) { size_t page_size = sysconf(_SC_PAGESIZE); @@ -154,4 +187,6 @@ size_t MeasureHeapUsage(void* start) return static_cast(current_break) - static_cast(start); } +} // namespace KSM + #endif diff --git a/common/memory/ksm.h b/common/memory/ksm.h index 7f03c9f87..2d9c272ba 100644 --- a/common/memory/ksm.h +++ b/common/memory/ksm.h @@ -64,38 +64,6 @@ bool operator!=(const PageAlignedAllocator&, const PageAlignedAllocator&) // Kernel Samepage Merging (KSM) functionality namespace KSM { -#ifdef _WIN32 - -// Windows-specific placeholder functions (no-op) -inline void CheckPageAlignment(void* ptr) -{ -} - -inline void* AllocatePageAligned(size_t size) -{ - return memset(malloc(size), 0, size); -} - -inline void MarkMemoryForKSM(void* start, size_t size) -{ -} - -inline void AlignHeapToPageBoundary() -{ -} - -inline void* MarkHeapStart() -{ - return nullptr; -} - -inline size_t MeasureHeapUsage(void* start) -{ - return 0; -} - -#else - void CheckPageAlignment(void* ptr); void* AllocatePageAligned(size_t size); void MarkMemoryForKSM(void* start, size_t size); @@ -103,5 +71,4 @@ void AlignHeapToPageBoundary(); void* MarkHeapStart(); size_t MeasureHeapUsage(void* start); -#endif -} +} // namespace KSM