| 1 | ////////////////////////////////////////////////////////////////////////////// |
| 2 | // |
| 3 | // (C) Copyright Ion Gaztanaga 2005-2015. Distributed under the Boost |
| 4 | // Software License, Version 1.0. (See accompanying file |
| 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | // |
| 7 | // See http://www.boost.org/libs/interprocess for documentation. |
| 8 | // |
| 9 | ////////////////////////////////////////////////////////////////////////////// |
| 10 | |
| 11 | #ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP |
| 12 | #define BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP |
| 13 | |
| 14 | #ifndef BOOST_CONFIG_HPP |
| 15 | # include <boost/config.hpp> |
| 16 | #endif |
| 17 | # |
| 18 | #if defined(BOOST_HAS_PRAGMA_ONCE) |
| 19 | # pragma once |
| 20 | #endif |
| 21 | |
| 22 | #if defined(BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION) && defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) |
| 23 | #error "BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION && BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION can't be defined at the same time" |
| 24 | #endif |
| 25 | |
| 26 | //#define BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION |
| 27 | |
| 28 | #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) |
| 29 | #define BOOST_INTERPROCESS_WINDOWS |
| 30 | #if !defined(BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION) && !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) |
| 31 | #define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION |
| 32 | #endif |
| 33 | #define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME |
| 34 | #else |
| 35 | #include <unistd.h> |
| 36 | |
| 37 | ////////////////////////////////////////////////////// |
| 38 | //Check for XSI shared memory objects. They are available in nearly all UNIX platforms |
| 39 | ////////////////////////////////////////////////////// |
| 40 | #if !defined(__QNXNTO__) && !defined(__ANDROID__) && !defined(__HAIKU__) && !(__VXWORKS__) && !(__EMSCRIPTEN__) |
| 41 | #define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS |
| 42 | #endif |
| 43 | |
| 44 | ////////////////////////////////////////////////////// |
| 45 | // From SUSv3/UNIX 98, pthread_mutexattr_settype is mandatory |
| 46 | ////////////////////////////////////////////////////// |
| 47 | #if defined(_XOPEN_UNIX) && ((_XOPEN_VERSION + 0) >= 500) |
| 48 | #define BOOST_INTERPROCESS_POSIX_RECURSIVE_MUTEXES |
| 49 | #endif |
| 50 | |
| 51 | ////////////////////////////////////////////////////// |
| 52 | // _POSIX_THREAD_PROCESS_SHARED (POSIX.1b/POSIX.4) |
| 53 | ////////////////////////////////////////////////////// |
| 54 | #if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0) |
| 55 | //Cygwin defines _POSIX_THREAD_PROCESS_SHARED but does not implement it. |
| 56 | #if defined(__CYGWIN__) |
| 57 | #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED |
| 58 | #elif defined(__APPLE__) |
| 59 | //The pthreads implementation of darwin stores a pointer to a mutex inside the condition |
| 60 | //structure so real sharing between processes is broken. See: |
| 61 | //https://opensource.apple.com/source/libpthread/libpthread-301.30.1/src/pthread_cond.c.auto.html |
| 62 | //in method pthread_cond_wait |
| 63 | #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED |
| 64 | #endif |
| 65 | |
| 66 | //If buggy _POSIX_THREAD_PROCESS_SHARED is detected avoid using it |
| 67 | #if defined(BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED) |
| 68 | #undef BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED |
| 69 | #else |
| 70 | #define BOOST_INTERPROCESS_POSIX_PROCESS_SHARED |
| 71 | #endif |
| 72 | #endif |
| 73 | |
| 74 | ////////////////////////////////////////////////////// |
| 75 | // BOOST_INTERPROCESS_POSIX_ROBUST_MUTEXES |
| 76 | ////////////////////////////////////////////////////// |
| 77 | #if (_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L) |
| 78 | #define BOOST_INTERPROCESS_POSIX_ROBUST_MUTEXES |
| 79 | #endif |
| 80 | |
| 81 | ////////////////////////////////////////////////////// |
| 82 | // _POSIX_SHARED_MEMORY_OBJECTS (POSIX.1b/POSIX.4) |
| 83 | ////////////////////////////////////////////////////// |
| 84 | #if ( defined(_POSIX_SHARED_MEMORY_OBJECTS) && ((_POSIX_SHARED_MEMORY_OBJECTS + 0) > 0) ) ||\ |
| 85 | (defined(__vms) && __CRTL_VER >= 70200000) |
| 86 | #define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS |
| 87 | //Some systems have filesystem-based resources, so the |
| 88 | //portable "/shmname" format does not work due to permission issues |
| 89 | //For those systems we need to form a path to a temporary directory: |
| 90 | // hp-ux tru64 vms freebsd |
| 91 | #if defined(__hpux) || defined(__osf__) || defined(__vms) || (defined(__FreeBSD__) && (__FreeBSD__ < 7)) |
| 92 | #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY |
| 93 | //Some systems have "jailed" environments where shm usage is restricted at runtime |
| 94 | //and temporary file based shm is possible in those executions. |
| 95 | #elif defined(__FreeBSD__) |
| 96 | #define BOOST_INTERPROCESS_RUNTIME_FILESYSTEM_BASED_POSIX_SHARED_MEMORY |
| 97 | #endif |
| 98 | #endif |
| 99 | |
| 100 | ////////////////////////////////////////////////////// |
| 101 | // _POSIX_MAPPED_FILES (POSIX.1b/POSIX.4) |
| 102 | ////////////////////////////////////////////////////// |
| 103 | #if defined(_POSIX_MAPPED_FILES) && ((_POSIX_MAPPED_FILES + 0) > 0) |
| 104 | #define BOOST_INTERPROCESS_POSIX_MAPPED_FILES |
| 105 | #endif |
| 106 | |
| 107 | ////////////////////////////////////////////////////// |
| 108 | // _POSIX_SEMAPHORES (POSIX.1b/POSIX.4) |
| 109 | ////////////////////////////////////////////////////// |
| 110 | #if ( defined(_POSIX_SEMAPHORES) && ((_POSIX_SEMAPHORES + 0) > 0) ) ||\ |
| 111 | ( defined(__FreeBSD__) && (__FreeBSD__ >= 4)) || \ |
| 112 | defined(__APPLE__) |
| 113 | #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES |
| 114 | //MacOsX declares _POSIX_SEMAPHORES but sem_init returns ENOSYS |
| 115 | #if !defined(__APPLE__) |
| 116 | #define BOOST_INTERPROCESS_POSIX_UNNAMED_SEMAPHORES |
| 117 | #endif |
| 118 | #if defined(__osf__) || defined(__vms) |
| 119 | #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SEMAPHORES |
| 120 | #endif |
| 121 | #endif |
| 122 | |
| 123 | ////////////////////////////////////////////////////// |
| 124 | // _POSIX_BARRIERS (SUSv3/Unix03) |
| 125 | ////////////////////////////////////////////////////// |
| 126 | #if defined(_POSIX_BARRIERS) && ((_POSIX_BARRIERS + 0) >= 200112L) |
| 127 | #define BOOST_INTERPROCESS_POSIX_BARRIERS |
| 128 | #endif |
| 129 | |
| 130 | ////////////////////////////////////////////////////// |
| 131 | // _POSIX_TIMEOUTS (SUSv3/Unix03) |
| 132 | ////////////////////////////////////////////////////// |
| 133 | #if defined(_POSIX_TIMEOUTS) && ((_POSIX_TIMEOUTS + 0L) >= 200112L) |
| 134 | #define BOOST_INTERPROCESS_POSIX_TIMEOUTS |
| 135 | #endif |
| 136 | |
| 137 | ////////////////////////////////////////////////////// |
| 138 | // Detect BSD derivatives to detect sysctl |
| 139 | ////////////////////////////////////////////////////// |
| 140 | #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) |
| 141 | #define BOOST_INTERPROCESS_BSD_DERIVATIVE |
| 142 | //Some *BSD systems (OpenBSD & NetBSD) need sys/param.h before sys/sysctl.h, whereas |
| 143 | //others (FreeBSD & Darwin) need sys/types.h |
| 144 | #include <sys/types.h> |
| 145 | #include <sys/param.h> |
| 146 | #include <sys/sysctl.h> |
| 147 | #if defined(CTL_KERN) && defined (KERN_BOOTTIME) |
| 148 | //#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME |
| 149 | #endif |
| 150 | #endif |
| 151 | |
| 152 | ////////////////////////////////////////////////////// |
| 153 | //64 bit offset |
| 154 | ////////////////////////////////////////////////////// |
| 155 | #if (defined (_V6_ILP32_OFFBIG) &&(_V6_ILP32_OFFBIG - 0 > 0)) ||\ |
| 156 | (defined (_V6_LP64_OFF64) &&(_V6_LP64_OFF64 - 0 > 0)) ||\ |
| 157 | (defined (_V6_LPBIG_OFFBIG) &&(_V6_LPBIG_OFFBIG - 0 > 0)) ||\ |
| 158 | (defined (_XBS5_ILP32_OFFBIG)&&(_XBS5_ILP32_OFFBIG - 0 > 0)) ||\ |
| 159 | (defined (_XBS5_LP64_OFF64) &&(_XBS5_LP64_OFF64 - 0 > 0)) ||\ |
| 160 | (defined (_XBS5_LPBIG_OFFBIG)&&(_XBS5_LPBIG_OFFBIG - 0 > 0)) ||\ |
| 161 | (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))||\ |
| 162 | (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64)) |
| 163 | #define BOOST_INTERPROCESS_UNIX_64_BIT_OR_BIGGER_OFF_T |
| 164 | #endif |
| 165 | |
| 166 | ////////////////////////////////////////////////////// |
| 167 | //posix_fallocate |
| 168 | ////////////////////////////////////////////////////// |
| 169 | #if (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) |
| 170 | #define BOOST_INTERPROCESS_POSIX_FALLOCATE |
| 171 | #endif |
| 172 | |
| 173 | #endif //!defined(BOOST_INTERPROCESS_WINDOWS) |
| 174 | |
| 175 | #if defined(BOOST_INTERPROCESS_WINDOWS) || defined(BOOST_INTERPROCESS_POSIX_MAPPED_FILES) |
| 176 | # define BOOST_INTERPROCESS_MAPPED_FILES |
| 177 | #endif |
| 178 | |
| 179 | //Now declare some Boost.Interprocess features depending on the implementation |
| 180 | #if defined(BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK) |
| 181 | #define BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES |
| 182 | #define BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES |
| 183 | #endif |
| 184 | |
| 185 | #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) |
| 186 | #define BOOST_INTERPROCESS_PERFECT_FORWARDING |
| 187 | #endif |
| 188 | |
| 189 | // Timeout duration use if BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING is set |
| 190 | #ifndef BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS |
| 191 | #define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS 10000 |
| 192 | #endif |
| 193 | |
| 194 | |
| 195 | // Max open or create tries with managed memory segments |
| 196 | #ifndef BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_MAX_TRIES |
| 197 | #define BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_MAX_TRIES 20u |
| 198 | #endif |
| 199 | |
| 200 | // Maximum timeout in seconds with open or create tries with managed memory segments |
| 201 | // waiting the creator to initialize the shared memory |
| 202 | #ifndef BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_TIMEOUT_SEC |
| 203 | #define BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_TIMEOUT_SEC 300u |
| 204 | #endif |
| 205 | |
| 206 | //Other switches |
| 207 | //BOOST_INTERPROCESS_MSG_QUEUE_USES_CIRC_INDEX |
| 208 | //message queue uses a circular queue as index instead of an array (better performance) |
| 209 | //Boost version < 1.52 uses an array, so undef this if you want to communicate |
| 210 | //with processes compiled with those versions. |
| 211 | #define BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX |
| 212 | |
| 213 | //Macros for documentation purposes. For code, expands to the argument |
| 214 | #define BOOST_INTERPROCESS_IMPDEF(TYPE) TYPE |
| 215 | #define BOOST_INTERPROCESS_SEEDOC(TYPE) TYPE |
| 216 | #define BOOST_INTERPROCESS_DOC1ST(TYPE1, TYPE2) TYPE2 |
| 217 | #define BOOST_INTERPROCESS_I , |
| 218 | #define BOOST_INTERPROCESS_DOCIGN(T1) T1 |
| 219 | |
| 220 | //#define BOOST_INTERPROCESS_DISABLE_FORCEINLINE |
| 221 | |
| 222 | #if defined(BOOST_INTERPROCESS_DISABLE_FORCEINLINE) |
| 223 | #define BOOST_INTERPROCESS_FORCEINLINE inline |
| 224 | #elif defined(BOOST_INTERPROCESS_FORCEINLINE_IS_BOOST_FORCELINE) |
| 225 | #define BOOST_INTERPROCESS_FORCEINLINE BOOST_FORCEINLINE |
| 226 | #elif defined(BOOST_MSVC) && (_MSC_VER < 1900 || defined(_DEBUG)) |
| 227 | //"__forceinline" and MSVC seems to have some bugs in old versions and in debug mode |
| 228 | #define BOOST_INTERPROCESS_FORCEINLINE inline |
| 229 | #elif defined(BOOST_CLANG) || (defined(BOOST_GCC) && ((__GNUC__ <= 5) || defined(__MINGW32__))) |
| 230 | //Older GCCs have problems with forceinline |
| 231 | //Clang can have code bloat issues with forceinline, see |
| 232 | //https://lists.boost.org/boost-users/2023/04/91445.php and |
| 233 | //https://github.com/llvm/llvm-project/issues/62202 |
| 234 | #define BOOST_INTERPROCESS_FORCEINLINE inline |
| 235 | #else |
| 236 | #define BOOST_INTERPROCESS_FORCEINLINE BOOST_FORCEINLINE |
| 237 | #endif |
| 238 | |
| 239 | #ifdef BOOST_WINDOWS |
| 240 | |
| 241 | #define BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES |
| 242 | |
| 243 | #ifdef __clang__ |
| 244 | #define BOOST_INTERPROCESS_DISABLE_DEPRECATED_WARNING _Pragma("clang diagnostic push") \ |
| 245 | _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") |
| 246 | #define BOOST_INTERPROCESS_RESTORE_WARNING _Pragma("clang diagnostic pop") |
| 247 | #else // __clang__ |
| 248 | #define BOOST_INTERPROCESS_DISABLE_DEPRECATED_WARNING __pragma(warning(push)) \ |
| 249 | __pragma(warning(disable : 4996)) |
| 250 | #define BOOST_INTERPROCESS_RESTORE_WARNING __pragma(warning(pop)) |
| 251 | #endif // __clang__ |
| 252 | |
| 253 | #endif |
| 254 | |
| 255 | #if defined(BOOST_HAS_THREADS) |
| 256 | # if defined(_MSC_VER) || defined(__MWERKS__) || defined(__MINGW32__) || defined(__BORLANDC__) |
| 257 | //no reentrant posix functions (eg: localtime_r) |
| 258 | # elif (!defined(__hpux) || (defined(__hpux) && defined(_REENTRANT))) |
| 259 | # define BOOST_INTERPROCESS_HAS_REENTRANT_STD_FUNCTIONS |
| 260 | # endif |
| 261 | #endif |
| 262 | |
| 263 | #include <boost/core/no_exceptions_support.hpp> |
| 264 | |
| 265 | #endif //#ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP |
| 266 | |