Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:53:27

0001 //////////////////////////////////////////////////////////////////////////////
0002 //
0003 // (C) Copyright Ion Gaztanaga 2005-2015. Distributed under the Boost
0004 // Software License, Version 1.0. (See accompanying file
0005 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 // See http://www.boost.org/libs/interprocess for documentation.
0008 //
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
0012 #define BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
0013 
0014 #ifndef BOOST_CONFIG_HPP
0015 #  include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 #  pragma once
0020 #endif
0021 
0022 #if defined(BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION) && defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION) 
0023 #error "BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION && BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION can't be defined at the same time"
0024 #endif
0025 
0026 //#define BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION
0027 
0028 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
0029    #define BOOST_INTERPROCESS_WINDOWS
0030    #if !defined(BOOST_INTERPROCESS_FORCE_NATIVE_EMULATION) && !defined(BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION)
0031       #define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
0032    #endif
0033    #define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
0034 #else
0035    #include <unistd.h>
0036 
0037    #if defined (__CYGWIN__) && (!defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE < 200112L))
0038    #error "Error: Compiling on Cygwin without POSIX is not supported. Please define _XOPEN_SOURCE >= 600 or _POSIX_C_SOURCE >= 200112 when compiling"
0039    #endif
0040 
0041    //////////////////////////////////////////////////////
0042    //Check for XSI shared memory objects. They are available in nearly all UNIX platforms
0043    //////////////////////////////////////////////////////
0044    #if !defined(__QNXNTO__) && !defined(__ANDROID__) && !defined(__HAIKU__) && !(__VXWORKS__) && !(__EMSCRIPTEN__)
0045       #define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS
0046    #endif
0047 
0048    //////////////////////////////////////////////////////
0049    // From SUSv3/UNIX 98, pthread_mutexattr_settype is mandatory
0050    //////////////////////////////////////////////////////
0051    #if defined(_XOPEN_UNIX) && ((_XOPEN_VERSION + 0) >= 500)
0052       #define BOOST_INTERPROCESS_POSIX_RECURSIVE_MUTEXES
0053    #endif
0054 
0055    //////////////////////////////////////////////////////
0056    // _POSIX_THREAD_PROCESS_SHARED (POSIX.1b/POSIX.4)
0057    //////////////////////////////////////////////////////
0058    #if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
0059       //Cygwin defines _POSIX_THREAD_PROCESS_SHARED but does not implement it.
0060       #if defined(__CYGWIN__)
0061          #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
0062       #elif defined(__APPLE__)
0063          //The pthreads implementation of darwin stores a pointer to a mutex inside the condition
0064          //structure so real sharing between processes is broken. See:
0065          //https://opensource.apple.com/source/libpthread/libpthread-301.30.1/src/pthread_cond.c.auto.html
0066          //in method pthread_cond_wait
0067          #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
0068       #endif
0069 
0070       //If buggy _POSIX_THREAD_PROCESS_SHARED is detected avoid using it
0071       #if defined(BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED)
0072          #undef BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
0073       #else
0074          #define BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
0075       #endif
0076    #endif
0077 
0078    //////////////////////////////////////////////////////
0079    //    BOOST_INTERPROCESS_POSIX_ROBUST_MUTEXES
0080    //////////////////////////////////////////////////////
0081    #if (_XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L)
0082       #define BOOST_INTERPROCESS_POSIX_ROBUST_MUTEXES
0083    #endif
0084 
0085    //////////////////////////////////////////////////////
0086    // _POSIX_SHARED_MEMORY_OBJECTS (POSIX.1b/POSIX.4)
0087    //////////////////////////////////////////////////////
0088    #if ( defined(_POSIX_SHARED_MEMORY_OBJECTS) && ((_POSIX_SHARED_MEMORY_OBJECTS + 0) > 0) ) ||\
0089          (defined(__vms) && __CRTL_VER >= 70200000)
0090       #define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
0091       //Some systems have filesystem-based resources, so the
0092       //portable "/shmname" format does not work due to permission issues
0093       //For those systems we need to form a path to a temporary directory:
0094       //          hp-ux               tru64               vms               freebsd
0095       #if defined(__hpux) || defined(__osf__) || defined(__vms) || (defined(__FreeBSD__) && (__FreeBSD__ < 7))
0096          #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
0097       //Some systems have "jailed" environments where shm usage is restricted at runtime
0098       //and temporary file based shm is possible in those executions.
0099       #elif defined(__FreeBSD__)
0100          #define BOOST_INTERPROCESS_RUNTIME_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
0101       #endif
0102    #endif
0103 
0104    //////////////////////////////////////////////////////
0105    // _POSIX_MAPPED_FILES (POSIX.1b/POSIX.4)
0106    //////////////////////////////////////////////////////
0107    #if defined(_POSIX_MAPPED_FILES) && ((_POSIX_MAPPED_FILES + 0) > 0)
0108       #define BOOST_INTERPROCESS_POSIX_MAPPED_FILES
0109    #endif
0110 
0111    //////////////////////////////////////////////////////
0112    // _POSIX_SEMAPHORES (POSIX.1b/POSIX.4)
0113    //////////////////////////////////////////////////////
0114    #if ( defined(_POSIX_SEMAPHORES) && ((_POSIX_SEMAPHORES + 0) > 0) ) ||\
0115        ( defined(__FreeBSD__) && (__FreeBSD__ >= 4)) || \
0116          defined(__APPLE__)
0117       #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
0118       //MacOsX declares _POSIX_SEMAPHORES but sem_init returns ENOSYS
0119       #if !defined(__APPLE__)
0120          #define BOOST_INTERPROCESS_POSIX_UNNAMED_SEMAPHORES
0121       #endif
0122       #if defined(__osf__) || defined(__vms)
0123          #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SEMAPHORES
0124       #endif
0125    #endif
0126 
0127    //////////////////////////////////////////////////////
0128    // _POSIX_BARRIERS (SUSv3/Unix03)
0129    //////////////////////////////////////////////////////
0130    #if defined(_POSIX_BARRIERS) && ((_POSIX_BARRIERS + 0) >= 200112L)
0131       #define BOOST_INTERPROCESS_POSIX_BARRIERS
0132    #endif
0133 
0134    //////////////////////////////////////////////////////
0135    // _POSIX_TIMEOUTS (SUSv3/Unix03)
0136    //////////////////////////////////////////////////////
0137    #if defined(_POSIX_TIMEOUTS) && ((_POSIX_TIMEOUTS + 0L) >= 200112L)
0138       #define BOOST_INTERPROCESS_POSIX_TIMEOUTS
0139    #endif
0140 
0141    //////////////////////////////////////////////////////
0142    // Detect BSD derivatives to detect sysctl
0143    //////////////////////////////////////////////////////
0144    #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
0145       #define BOOST_INTERPROCESS_BSD_DERIVATIVE
0146       //Some *BSD systems (OpenBSD & NetBSD) need sys/param.h before sys/sysctl.h, whereas
0147       //others (FreeBSD & Darwin) need sys/types.h
0148       #include <sys/types.h>
0149       #include <sys/param.h>
0150       #include <sys/sysctl.h>
0151       #if defined(CTL_KERN) && defined (KERN_BOOTTIME)
0152          //#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
0153       #endif
0154    #endif
0155 
0156    //////////////////////////////////////////////////////
0157    //64 bit offset
0158    //////////////////////////////////////////////////////
0159    #if (defined (_V6_ILP32_OFFBIG)  &&(_V6_ILP32_OFFBIG   - 0 > 0)) ||\
0160        (defined (_V6_LP64_OFF64)    &&(_V6_LP64_OFF64     - 0 > 0)) ||\
0161        (defined (_V6_LPBIG_OFFBIG)  &&(_V6_LPBIG_OFFBIG   - 0 > 0)) ||\
0162        (defined (_XBS5_ILP32_OFFBIG)&&(_XBS5_ILP32_OFFBIG - 0 > 0)) ||\
0163        (defined (_XBS5_LP64_OFF64)  &&(_XBS5_LP64_OFF64   - 0 > 0)) ||\
0164        (defined (_XBS5_LPBIG_OFFBIG)&&(_XBS5_LPBIG_OFFBIG - 0 > 0)) ||\
0165        (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS  - 0 >= 64))||\
0166        (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS  - 0 >= 64))
0167       #define BOOST_INTERPROCESS_UNIX_64_BIT_OR_BIGGER_OFF_T
0168    #endif
0169 
0170    //////////////////////////////////////////////////////
0171    //posix_fallocate
0172    //////////////////////////////////////////////////////
0173    #if (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L)
0174    #define BOOST_INTERPROCESS_POSIX_FALLOCATE
0175    #endif
0176 
0177 #endif   //!defined(BOOST_INTERPROCESS_WINDOWS)
0178 
0179 #if defined(BOOST_INTERPROCESS_WINDOWS) || defined(BOOST_INTERPROCESS_POSIX_MAPPED_FILES)
0180 #  define BOOST_INTERPROCESS_MAPPED_FILES
0181 #endif
0182 
0183 //Now declare some Boost.Interprocess features depending on the implementation
0184 #if defined(BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
0185    #define BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES
0186    #define BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES
0187 #endif
0188 
0189 #if    !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
0190    #define BOOST_INTERPROCESS_PERFECT_FORWARDING
0191 #endif
0192 
0193 // Timeout duration use if BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING is set
0194 #ifndef BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS
0195    #define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS 10000
0196 #endif
0197 
0198 
0199 // Max open or create tries with managed memory segments
0200 #ifndef BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_MAX_TRIES
0201    #define BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_MAX_TRIES 20u
0202 #endif
0203 
0204 // Maximum timeout in seconds with open or create tries with managed memory segments
0205 // waiting the creator to initialize the shared memory
0206 #ifndef BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_TIMEOUT_SEC
0207    #define BOOST_INTERPROCESS_MANAGED_OPEN_OR_CREATE_INITIALIZE_TIMEOUT_SEC 300u
0208 #endif
0209 
0210 //Other switches
0211 //BOOST_INTERPROCESS_MSG_QUEUE_USES_CIRC_INDEX
0212 //message queue uses a circular queue as index instead of an array (better performance)
0213 //Boost version < 1.52 uses an array, so undef this if you want to communicate
0214 //with processes compiled with those versions.
0215 #define BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX
0216 
0217 //Macros for documentation purposes. For code, expands to the argument
0218 #define BOOST_INTERPROCESS_IMPDEF(TYPE) TYPE
0219 #define BOOST_INTERPROCESS_SEEDOC(TYPE) TYPE
0220 #define BOOST_INTERPROCESS_DOC1ST(TYPE1, TYPE2) TYPE2
0221 #define BOOST_INTERPROCESS_I ,
0222 #define BOOST_INTERPROCESS_DOCIGN(T1) T1
0223 
0224 //#define BOOST_INTERPROCESS_DISABLE_FORCEINLINE
0225 
0226 #if defined(BOOST_INTERPROCESS_DISABLE_FORCEINLINE)
0227    #define BOOST_INTERPROCESS_FORCEINLINE inline
0228 #elif defined(BOOST_INTERPROCESS_FORCEINLINE_IS_BOOST_FORCELINE)
0229    #define BOOST_INTERPROCESS_FORCEINLINE BOOST_FORCEINLINE
0230 #elif defined(BOOST_MSVC) && (_MSC_VER < 1900 || defined(_DEBUG))
0231    //"__forceinline" and MSVC seems to have some bugs in old versions and in debug mode
0232    #define BOOST_INTERPROCESS_FORCEINLINE inline
0233 #elif defined(BOOST_CLANG) || (defined(BOOST_GCC) && ((__GNUC__ <= 5) || defined(__MINGW32__)))
0234    //Older GCCs have problems with forceinline
0235    //Clang can have code bloat issues with forceinline, see
0236    //https://lists.boost.org/boost-users/2023/04/91445.php and
0237    //https://github.com/llvm/llvm-project/issues/62202
0238    #define BOOST_INTERPROCESS_FORCEINLINE inline
0239 #else
0240    #define BOOST_INTERPROCESS_FORCEINLINE BOOST_FORCEINLINE
0241 #endif
0242 
0243 #ifdef BOOST_WINDOWS
0244 
0245 #define BOOST_INTERPROCESS_WCHAR_NAMED_RESOURCES
0246 
0247 #ifdef __clang__
0248    #define BOOST_INTERPROCESS_DISABLE_DEPRECATED_WARNING _Pragma("clang diagnostic push") \
0249                                                          _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
0250    #define BOOST_INTERPROCESS_RESTORE_WARNING            _Pragma("clang diagnostic pop")
0251 #else // __clang__
0252    #define BOOST_INTERPROCESS_DISABLE_DEPRECATED_WARNING __pragma(warning(push)) \
0253                                                          __pragma(warning(disable : 4996))
0254    #define BOOST_INTERPROCESS_RESTORE_WARNING            __pragma(warning(pop))
0255 #endif // __clang__
0256 
0257 #endif
0258 
0259 #if defined(BOOST_HAS_THREADS) 
0260 #  if defined(_MSC_VER) || defined(__MWERKS__) || defined(__MINGW32__) ||  defined(__BORLANDC__)
0261      //no reentrant posix functions (eg: localtime_r)
0262 #  elif (!defined(__hpux) || (defined(__hpux) && defined(_REENTRANT)))
0263 #   define BOOST_INTERPROCESS_HAS_REENTRANT_STD_FUNCTIONS
0264 #  endif
0265 #endif
0266 
0267 namespace boost {
0268 namespace interprocess {
0269 
0270 template <typename T1>
0271 BOOST_FORCEINLINE BOOST_CXX14_CONSTEXPR void ignore(T1 const&)
0272 {}
0273 
0274 }} //namespace boost::interprocess {
0275 
0276 #if !(defined BOOST_NO_EXCEPTIONS)
0277 #    define BOOST_INTERPROCESS_TRY { try
0278 #    define BOOST_INTERPROCESS_CATCH(x) catch(x)
0279 #    define BOOST_INTERPROCESS_RETHROW throw;
0280 #    define BOOST_INTERPROCESS_CATCH_END }
0281 #else
0282 #    if !defined(BOOST_MSVC) || BOOST_MSVC >= 1900
0283 #        define BOOST_INTERPROCESS_TRY { if (true)
0284 #        define BOOST_INTERPROCESS_CATCH(x) else if (false)
0285 #    else
0286 // warning C4127: conditional expression is constant
0287 #        define BOOST_INTERPROCESS_TRY { \
0288              __pragma(warning(push)) \
0289              __pragma(warning(disable: 4127)) \
0290              if (true) \
0291              __pragma(warning(pop))
0292 #        define BOOST_INTERPROCESS_CATCH(x) else \
0293              __pragma(warning(push)) \
0294              __pragma(warning(disable: 4127)) \
0295              if (false) \
0296              __pragma(warning(pop))
0297 #    endif
0298 #    define BOOST_INTERPROCESS_RETHROW
0299 #    define BOOST_INTERPROCESS_CATCH_END }
0300 #endif
0301 
0302 #ifndef BOOST_NO_CXX11_STATIC_ASSERT
0303 #  ifndef BOOST_NO_CXX11_VARIADIC_MACROS
0304 #     define BOOST_INTERPROCESS_STATIC_ASSERT( ... ) static_assert(__VA_ARGS__, #__VA_ARGS__)
0305 #  else
0306 #     define BOOST_INTERPROCESS_STATIC_ASSERT( B ) static_assert(B, #B)
0307 #  endif
0308 #else
0309 namespace boost {
0310    namespace interprocess {
0311       namespace dtl {
0312 
0313          template<bool B>
0314          struct STATIC_ASSERTION_FAILURE;
0315 
0316          template<>
0317          struct STATIC_ASSERTION_FAILURE<true> {};
0318 
0319          template<unsigned> struct static_assert_test {};
0320 
0321       }
0322    }
0323 }
0324 
0325 #define BOOST_INTERPROCESS_STATIC_ASSERT(B) \
0326          typedef ::boost::interprocess::dtl::static_assert_test<\
0327             (unsigned)sizeof(::boost::interprocess::dtl::STATIC_ASSERTION_FAILURE<bool(B)>)>\
0328                BOOST_JOIN(boost_container_static_assert_typedef_, __LINE__) BOOST_ATTRIBUTE_UNUSED
0329 
0330 #endif
0331 
0332 #ifndef BOOST_NO_CXX11_STATIC_ASSERT
0333 #  ifndef BOOST_NO_CXX11_VARIADIC_MACROS
0334 #     define BOOST_INTERPROCESS_STATIC_ASSERT_MSG( ... ) static_assert(__VA_ARGS__)
0335 #  else
0336 #     define BOOST_INTERPROCESS_STATIC_ASSERT_MSG( B, Msg ) static_assert( B, Msg )
0337 #  endif
0338 #else
0339 #     define BOOST_INTERPROCESS_STATIC_ASSERT_MSG( B, Msg ) BOOST_INTERPROCESS_STATIC_ASSERT( B )
0340 #endif
0341 
0342 #if !defined(BOOST_NO_CXX17_INLINE_VARIABLES)
0343 #  define BOOST_INTERPROCESS_CONSTANT_VAR BOOST_INLINE_CONSTEXPR
0344 #else
0345 #  define BOOST_INTERPROCESS_CONSTANT_VAR static BOOST_CONSTEXPR_OR_CONST
0346 #endif
0347 
0348 #if defined(__GNUC__) && ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40600)
0349 #define BOOST_INTERPROCESS_GCC_COMPATIBLE_HAS_DIAGNOSTIC_IGNORED
0350 #elif defined(__clang__)
0351 #define BOOST_INTERPROCESS_GCC_COMPATIBLE_HAS_DIAGNOSTIC_IGNORED
0352 #endif
0353 
0354 
0355 ////////////////////////////////////////////
0356 //
0357 //    BOOST_INTERPROCESS_EINTR_RETRY
0358 //
0359 ////////////////////////////////////////////
0360 
0361 //#define DISABLE_BOOST_INTERPROCESS_EINTR_RETRY
0362 #if !defined(DISABLE_BOOST_INTERPROCESS_EINTR_RETRY) && defined(__GNUC__)
0363 
0364 /* taken from glibc unistd.h and fixes musl */
0365 #define BOOST_INTERPROCESS_EINTR_RETRY(RESULTTYPE, FAILUREVALUE, EXPRESSION) \
0366   (__extension__                                   \
0367     ({ RESULTTYPE __result;                        \
0368        do __result = (RESULTTYPE) (EXPRESSION);    \
0369        while (__result == FAILUREVALUE && errno == EINTR);  \
0370        __result; }))
0371 
0372 #else    //!defined(DISABLE_BOOST_INTERPROCESS_EINTR_RETRY) && defined(__GNUC__)
0373 
0374 #define BOOST_INTERPROCESS_EINTR_RETRY(RESULTTYPE, FAILUREVALUE, EXPRESSION) ((RESULTTYPE)(EXPRESSION))
0375 
0376 #endif   //!defined(DISABLE_BOOST_INTERPROCESS_EINTR_RETRY) && defined(__GNUC__)
0377 
0378 #endif   //#ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP