Experimental support for using the client on macOS (Darwin) (#1321)
Build on RHEL9 / build (push) Failing after 32s
Build on RHEL8 / build (push) Failing after 4m40s

* shorter SHM names on macOS
* fix segfault on macOS when string is empty
* apple version of read exe path
* ifdef for linux specific API
* fixed test for shm and udp socket
* updated release notes
This commit is contained in:
Erik Fröjdh
2025-10-22 15:19:36 +02:00
committed by GitHub
parent 9d40220274
commit 1d66f1d26d
10 changed files with 88 additions and 26 deletions
+21 -4
View File
@@ -25,15 +25,27 @@
#include <sys/stat.h> // fstat
#include <unistd.h>
namespace sls {
struct CtbConfig;
// struct sharedDetector;
// ********************** Defines for shared memory. **********************
// WARNING! before chaning these search the codebase for their usage!
#define SHM_IS_VALID_CHECK_VERSION 0x250820
//Max shared memory name length in macOS is 31 characters
#ifdef __APPLE__
#define SHM_DETECTOR_PREFIX "/sls_"
#define SHM_MODULE_PREFIX "_mod_"
#else
#define SHM_DETECTOR_PREFIX "/slsDetectorPackage_detector_"
#define SHM_MODULE_PREFIX "_module_"
#endif
#define SHM_ENV_NAME "SLSDETNAME"
// ************************************************************************
namespace sls {
class CtbConfig;
template <typename T, typename U> constexpr bool is_type() {
return std::is_same_v<std::decay_t<U>, T>;
@@ -267,6 +279,11 @@ template <typename T> class SharedMemory {
throw SharedMemoryError(msg);
}
#ifdef __APPLE__
// On macOS, fstat returns the allocated size and not the requested size.
// This means we can't check for size since we always get for example 16384 bytes.
return;
#endif
auto actual_size = static_cast<size_t>(sb.st_size);
auto expected_size = sizeof(T);
if (actual_size != expected_size) {