diff --git a/CMakeLists.txt b/CMakeLists.txt index 02668e08..d675e610 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,6 +144,26 @@ FetchContent_Declare( EXCLUDE_FROM_ALL ) +# ZeroMQ (libzmq): fetch it here, at the top level, so that THIS project - not +# slsDetectorPackage - controls the version. slsDetectorPackage bundles its own libzmq +# archive, but only populates it behind `if(NOT libzmq_POPULATED)`; by making libzmq +# available before sls below, sls reuses this copy and a single libzmq-static target is +# built (no duplicate target / double-symbol clash). A future viewer-only / Windows build +# (which does not build sls) fetches the same libzmq standalone. +SET(BUILD_SHARED OFF CACHE BOOL "" FORCE) # libzmq: static only (matches sls) +SET(BUILD_TESTS OFF CACHE BOOL "" FORCE) # libzmq: no test build +SET(WITH_PERF_TOOL OFF CACHE BOOL "" FORCE) # libzmq: no perf tools +SET(WITH_DOCS OFF CACHE BOOL "" FORCE) # libzmq: no docs +SET(ENABLE_CPACK OFF CACHE BOOL "" FORCE) # libzmq: no CPack injection +FetchContent_Declare( + libzmq + GIT_REPOSITORY https://github.com/zeromq/libzmq.git + GIT_TAG v4.3.5 + EXCLUDE_FROM_ALL +) + +# libzmq must be made available BEFORE sls_detector_package for the override above to take effect. +FetchContent_MakeAvailable(libzmq) FetchContent_MakeAvailable(zstd sls_detector_package catch2 hdf5 spdlog httplib) ADD_SUBDIRECTORY(jungfrau) diff --git a/common/ImageBuffer.cpp b/common/ImageBuffer.cpp index e3ced97f..3145998b 100644 --- a/common/ImageBuffer.cpp +++ b/common/ImageBuffer.cpp @@ -6,28 +6,27 @@ #include "JFJochException.h" #include "ZeroCopyReturnValue.h" +#include + #ifdef JFJOCH_USE_NUMA #include #endif -#include ImageBuffer::ImageBuffer(size_t buffer_size_bytes) : buffer_size(buffer_size_bytes) { #ifdef JFJOCH_USE_NUMA + // Interleave the buffer across NUMA nodes - throughput-critical path (receiver), Linux-only. buffer = static_cast(numa_alloc_interleaved(buffer_size)); +#else + // The non-NUMA mapping carried no huge-page / mbind flags, so a plain heap allocation is + // equivalent (and portable). The buffer is zeroed below. + buffer = static_cast(std::malloc(buffer_size)); +#endif if (buffer == nullptr) - throw JFJochException(JFJochExceptionCategory::MemAllocFailed, - "Failed to allocate image buffer"); - - #else - buffer = (uint8_t *) mmap (nullptr, buffer_size, PROT_READ | PROT_WRITE, - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) ; - if (buffer == MAP_FAILED) throw JFJochException(JFJochExceptionCategory::MemAllocFailed, "Failed to allocate image buffer"); -#endif memset(buffer, 0, buffer_size); } @@ -39,7 +38,7 @@ ImageBuffer::~ImageBuffer() { #ifdef JFJOCH_USE_NUMA numa_free(buffer, buffer_size); #else - munmap(buffer, buffer_size); + std::free(buffer); #endif } diff --git a/common/NetworkAddressConvert.cpp b/common/NetworkAddressConvert.cpp index 9d58b1d0..baa920db 100644 --- a/common/NetworkAddressConvert.cpp +++ b/common/NetworkAddressConvert.cpp @@ -1,7 +1,12 @@ // SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute // SPDX-License-Identifier: GPL-3.0-only +#ifdef _WIN32 +#include +#include +#else #include +#endif #include #include