diff --git a/common/lib/CMakeLists.txt b/common/lib/CMakeLists.txt index 3fffb6281..45ed67108 100644 --- a/common/lib/CMakeLists.txt +++ b/common/lib/CMakeLists.txt @@ -26,10 +26,6 @@ add_library(villas-common SHARED memory.cpp memory_manager.cpp - kernel/kernel.c - kernel/pci.c - kernel/vfio.cpp - utils.c list.c log.c @@ -37,6 +33,14 @@ add_library(villas-common SHARED log_helper.c ) +if(${CMAKE_SYSTEM_NAME} STREQUAL Linux) + target_sources(villas-common + kernel/kernel.c + kernel/pci.c + kernel/vfio.cpp + ) +endif() + target_include_directories(villas-common PUBLIC ${villas-common_SOURCE_DIR}/include ${villas-common_SOURCE_DIR}/thirdparty/spdlog/include diff --git a/common/lib/memory.cpp b/common/lib/memory.cpp index 3bf07cb78..561db44fe 100644 --- a/common/lib/memory.cpp +++ b/common/lib/memory.cpp @@ -39,9 +39,13 @@ HostRam::HostRamAllocator::allocateBlock(size_t size) size &= size_t(~0xFFF); } - const int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_32BIT; + const int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS; const int mmap_protection = PROT_READ | PROT_WRITE; +#ifdef __linux__ + mmap_flags |= MAP_32BIT; +#endif + const void* addr = mmap(nullptr, size, mmap_protection, mmap_flags, 0, 0); if(addr == nullptr) { throw std::bad_alloc();