1 //////////////////////////////////////////////////////////////////////////////
3 // (C) Copyright Ion Gaztanaga 2005-2012. 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)
7 // See http://www.boost.org/libs/interprocess for documentation.
9 //////////////////////////////////////////////////////////////////////////////
11 #ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
12 #define BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
18 #include <boost/interprocess/detail/config_begin.hpp>
20 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
21 #define BOOST_INTERPROCESS_WINDOWS
22 #define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
23 #define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
24 //Define this to connect with shared memory created with versions < 1.54
25 //#define BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME
29 #if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED - 0) > 0)
30 //Cygwin defines _POSIX_THREAD_PROCESS_SHARED but does not implement it.
31 #if defined(__CYGWIN__)
32 #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
33 //Mac Os X < Lion (10.7) might define _POSIX_THREAD_PROCESS_SHARED but there is no real support.
34 #elif defined(__APPLE__)
35 #include "TargetConditionals.h"
36 //Check we're on Mac OS target
37 #if defined(TARGET_OS_MAC)
38 #include "AvailabilityMacros.h"
39 //If minimum target for this compilation is older than Mac Os Lion, then we are out of luck
40 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
41 #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
46 //If buggy _POSIX_THREAD_PROCESS_SHARED is detected avoid using it
47 #if defined(BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED)
48 #undef BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
50 #define BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
54 #if defined(_POSIX_BARRIERS) && ((_POSIX_BARRIERS - 0) > 0)
55 #define BOOST_INTERPROCESS_POSIX_BARRIERS
58 #if defined(_POSIX_SEMAPHORES) && ((_POSIX_SEMAPHORES - 0) > 0)
59 #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
60 #if defined(__CYGWIN__)
61 #define BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK
63 //Some platforms have a limited (name length) named semaphore support
64 #elif (defined(__FreeBSD__) && (__FreeBSD__ >= 4)) || defined(__APPLE__)
65 #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
68 #if (defined (_V6_ILP32_OFFBIG) &&(_V6_ILP32_OFFBIG - 0 > 0)) ||\
69 (defined (_V6_LP64_OFF64) &&(_V6_LP64_OFF64 - 0 > 0)) ||\
70 (defined (_V6_LPBIG_OFFBIG) &&(_V6_LPBIG_OFFBIG - 0 > 0)) ||\
71 (defined (_XBS5_ILP32_OFFBIG)&&(_XBS5_ILP32_OFFBIG - 0 > 0)) ||\
72 (defined (_XBS5_LP64_OFF64) &&(_XBS5_LP64_OFF64 - 0 > 0)) ||\
73 (defined (_XBS5_LPBIG_OFFBIG)&&(_XBS5_LPBIG_OFFBIG - 0 > 0)) ||\
74 (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))||\
75 (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))
76 #define BOOST_INTERPROCESS_UNIX_64_BIT_OR_BIGGER_OFF_T
79 //Check for XSI shared memory objects. They are available in nearly all UNIX platforms
80 #if !defined(__QNXNTO__) && !defined(__ANDROID__)
81 #define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS
84 #if defined(_POSIX_SHARED_MEMORY_OBJECTS) && ((_POSIX_SHARED_MEMORY_OBJECTS - 0) > 0)
85 #define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
87 //VMS and MACOS don't define it but they have shm_open/close interface
89 #if __CRTL_VER >= 70200000
90 #define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
92 //Mac OS has some non-conformant features like names limited to SHM_NAME_MAX
93 #elif defined (__APPLE__)
94 //#define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
95 //#define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS_NO_GROW
99 //Now check if we have only XSI shared memory
100 #if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS) &&\
101 !defined(BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS)
102 //#define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS_ONLY
105 #if defined(_POSIX_TIMEOUTS) && ((_POSIX_TIMEOUTS - 0) > 0)
106 #define BOOST_INTERPROCESS_POSIX_TIMEOUTS
109 #ifdef BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
110 //Some systems have filesystem-based resources, so the
111 //portable "/shmname" format does not work due to permission issues
112 //For those systems we need to form a path to a temporary directory:
113 // hp-ux tru64 vms freebsd
114 #if defined(__hpux) || defined(__osf__) || defined(__vms) || (defined(__FreeBSD__) && (__FreeBSD__ < 7))
115 #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
116 //Some systems have "jailed" environments where shm usage is restricted at runtime
117 //and temporary file file based shm is possible in those executions.
118 #elif defined(__FreeBSD__)
119 #define BOOST_INTERPROCESS_RUNTIME_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
123 #ifdef BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
124 #if defined(__osf__) || defined(__vms)
125 #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SEMAPHORES
129 #if defined(_POSIX_VERSION) && defined(_XOPEN_VERSION) && \
130 (((_POSIX_VERSION + 0)>= 200112L || (_XOPEN_VERSION + 0)>= 500))
131 #define BOOST_INTERPROCESS_POSIX_RECURSIVE_MUTEXES
134 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
135 #define BOOST_INTERPROCESS_BSD_DERIVATIVE
136 //Some *BSD systems (OpenBSD & NetBSD) need sys/param.h before sys/sysctl.h, whereas
137 //others (FreeBSD & Darwin) need sys/types.h
138 #include <sys/types.h>
139 #include <sys/param.h>
140 #include <sys/sysctl.h>
141 #if defined(CTL_KERN) && defined (KERN_BOOTTIME)
142 //#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
145 #endif //!defined(BOOST_INTERPROCESS_WINDOWS)
147 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
148 #define BOOST_INTERPROCESS_PERFECT_FORWARDING
151 //Now declare some Boost.Interprocess features depending on the implementation
152 #if defined(BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
153 #define BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES
154 #define BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES
157 // Timeout duration use if BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING is set
158 #ifndef BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS
159 #define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS 10000
163 //BOOST_INTERPROCESS_MSG_QUEUE_USES_CIRC_INDEX
164 //message queue uses a circular queue as index instead of an array (better performance)
165 //Boost version < 1.52 uses an array, so undef this if you want to communicate
166 //with processes compiled with those versions.
167 #define BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX
170 #if defined(_MSC_VER)
171 #define BOOST_INTERPROCESS_ALWAYS_INLINE __forceinline
172 #elif defined (__GNUC__)
173 #define BOOST_INTERPROCESS_ALWAYS_INLINE __attribute__((__always_inline__))
175 #define BOOST_INTERPROCESS_ALWAYS_INLINE inline
178 #if defined(_MSC_VER)
179 #define BOOST_INTERPROCESS_NEVER_INLINE __declspec(noinline)
180 #elif defined (__GNUC__)
181 #define BOOST_INTERPROCESS_NEVER_INLINE __attribute__((__noinline__))
184 //Macros for documentation purposes. For code, expands to the argument
185 #define BOOST_INTERPROCESS_IMPDEF(TYPE) TYPE
186 #define BOOST_INTERPROCESS_SEEDOC(TYPE) TYPE
188 #if defined(BOOST_NO_CXX11_NOEXCEPT)
189 #if defined(BOOST_MSVC)
190 #define BOOST_INTERPROCESS_NOEXCEPT throw()
192 #define BOOST_INTERPROCESS_NOEXCEPT
194 #define BOOST_INTERPROCESS_NOEXCEPT_IF(x)
196 #define BOOST_INTERPROCESS_NOEXCEPT noexcept
197 #define BOOST_INTERPROCESS_NOEXCEPT_IF(x) noexcept(x)
200 #include <boost/interprocess/detail/config_end.hpp>
202 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP