diff --git a/src/shm.h b/src/shm.h index 42ed5f13c..e1256b26a 100644 --- a/src/shm.h +++ b/src/shm.h @@ -36,7 +36,7 @@ #include #include -#if !defined(_WIN32) && !defined(__ANDROID__) +#if defined(__linux__) && !defined(__ANDROID__) #include "shm_linux.h" #endif @@ -60,7 +60,7 @@ #define NOMINMAX #endif #include -#else +#elif defined(__linux__) #include #include #include @@ -407,7 +407,7 @@ class SharedMemoryBackend { std::string last_error_message; }; -#elif !defined(__ANDROID__) +#elif defined(__linux__) && !defined(__ANDROID__) template class SharedMemoryBackend { @@ -538,7 +538,7 @@ struct SystemWideSharedConstant { std::snprintf(buf, sizeof(buf), "Local\\sf_%zu$%zu$%zu", content_hash, executable_hash, discriminator); std::string shm_name = buf; -#if !defined(_WIN32) +#if defined(__linux__) && !defined(__ANDROID__) // POSIX shared memory names must start with a slash shm_name = "/sf_" + createHashString(shm_name); diff --git a/src/shm_linux.h b/src/shm_linux.h index 22a62b823..296ab678f 100644 --- a/src/shm_linux.h +++ b/src/shm_linux.h @@ -19,6 +19,10 @@ #ifndef SHM_LINUX_H_INCLUDED #define SHM_LINUX_H_INCLUDED +#if !defined(__linux__) || defined(__ANDROID__) +#error shm_linux.h should not be included on this platform. +#endif + #include #include #include @@ -40,15 +44,8 @@ #include #include #include - -#if defined(__NetBSD__) || defined(__DragonFly__) || defined(__linux__) - #include - #define SF_MAX_SEM_NAME_LEN NAME_MAX -#elif defined(__APPLE__) - #define SF_MAX_SEM_NAME_LEN 31 -#else - #define SF_MAX_SEM_NAME_LEN 255 -#endif +#include +#define SF_MAX_SEM_NAME_LEN NAME_MAX #include "misc.h"