Chris@16
|
1 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 //
|
Chris@16
|
3 // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
|
Chris@16
|
4 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 //
|
Chris@16
|
7 // See http://www.boost.org/libs/interprocess for documentation.
|
Chris@16
|
8 //
|
Chris@16
|
9 //////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
|
Chris@16
|
12 #define BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
|
Chris@16
|
13
|
Chris@101
|
14 #ifndef BOOST_CONFIG_HPP
|
Chris@101
|
15 # include <boost/config.hpp>
|
Chris@101
|
16 #endif
|
Chris@101
|
17 #
|
Chris@101
|
18 #if defined(BOOST_HAS_PRAGMA_ONCE)
|
Chris@101
|
19 # pragma once
|
Chris@101
|
20 #endif
|
Chris@101
|
21
|
Chris@16
|
22 #include <boost/interprocess/detail/config_begin.hpp>
|
Chris@16
|
23
|
Chris@16
|
24 #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
Chris@16
|
25 #define BOOST_INTERPROCESS_WINDOWS
|
Chris@16
|
26 #define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
|
Chris@16
|
27 #define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
|
Chris@16
|
28 //Define this to connect with shared memory created with versions < 1.54
|
Chris@16
|
29 //#define BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME
|
Chris@16
|
30 #else
|
Chris@16
|
31 #include <unistd.h>
|
Chris@16
|
32
|
Chris@101
|
33 //////////////////////////////////////////////////////
|
Chris@101
|
34 //Check for XSI shared memory objects. They are available in nearly all UNIX platforms
|
Chris@101
|
35 //////////////////////////////////////////////////////
|
Chris@101
|
36 #if !defined(__QNXNTO__) && !defined(__ANDROID__) && !defined(__HAIKU__)
|
Chris@101
|
37 #define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS
|
Chris@101
|
38 #endif
|
Chris@101
|
39
|
Chris@101
|
40 //////////////////////////////////////////////////////
|
Chris@101
|
41 // From SUSv3/UNIX 98, pthread_mutexattr_settype is mandatory
|
Chris@101
|
42 //////////////////////////////////////////////////////
|
Chris@101
|
43 #if defined(_XOPEN_UNIX) && ((_XOPEN_VERSION + 0) >= 500)
|
Chris@101
|
44 #define BOOST_INTERPROCESS_POSIX_RECURSIVE_MUTEXES
|
Chris@101
|
45 #endif
|
Chris@101
|
46
|
Chris@101
|
47 //////////////////////////////////////////////////////
|
Chris@101
|
48 // _POSIX_THREAD_PROCESS_SHARED (POSIX.1b/POSIX.4)
|
Chris@101
|
49 //////////////////////////////////////////////////////
|
Chris@101
|
50 #if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED + 0) > 0)
|
Chris@16
|
51 //Cygwin defines _POSIX_THREAD_PROCESS_SHARED but does not implement it.
|
Chris@16
|
52 #if defined(__CYGWIN__)
|
Chris@16
|
53 #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
|
Chris@16
|
54 //Mac Os X < Lion (10.7) might define _POSIX_THREAD_PROCESS_SHARED but there is no real support.
|
Chris@16
|
55 #elif defined(__APPLE__)
|
Chris@16
|
56 #include "TargetConditionals.h"
|
Chris@16
|
57 //Check we're on Mac OS target
|
Chris@16
|
58 #if defined(TARGET_OS_MAC)
|
Chris@16
|
59 #include "AvailabilityMacros.h"
|
Chris@16
|
60 //If minimum target for this compilation is older than Mac Os Lion, then we are out of luck
|
Chris@16
|
61 #if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
|
Chris@16
|
62 #define BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
|
Chris@16
|
63 #endif
|
Chris@16
|
64 #endif
|
Chris@16
|
65 #endif
|
Chris@16
|
66
|
Chris@16
|
67 //If buggy _POSIX_THREAD_PROCESS_SHARED is detected avoid using it
|
Chris@16
|
68 #if defined(BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED)
|
Chris@16
|
69 #undef BOOST_INTERPROCESS_BUGGY_POSIX_PROCESS_SHARED
|
Chris@16
|
70 #else
|
Chris@16
|
71 #define BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
|
Chris@16
|
72 #endif
|
Chris@16
|
73 #endif
|
Chris@16
|
74
|
Chris@101
|
75 //////////////////////////////////////////////////////
|
Chris@101
|
76 // _POSIX_SHARED_MEMORY_OBJECTS (POSIX.1b/POSIX.4)
|
Chris@101
|
77 //////////////////////////////////////////////////////
|
Chris@101
|
78 #if ( defined(_POSIX_SHARED_MEMORY_OBJECTS) && ((_POSIX_SHARED_MEMORY_OBJECTS + 0) > 0) ) ||\
|
Chris@101
|
79 (defined(__vms) && __CRTL_VER >= 70200000)
|
Chris@16
|
80 #define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
|
Chris@16
|
81 //Some systems have filesystem-based resources, so the
|
Chris@16
|
82 //portable "/shmname" format does not work due to permission issues
|
Chris@16
|
83 //For those systems we need to form a path to a temporary directory:
|
Chris@16
|
84 // hp-ux tru64 vms freebsd
|
Chris@16
|
85 #if defined(__hpux) || defined(__osf__) || defined(__vms) || (defined(__FreeBSD__) && (__FreeBSD__ < 7))
|
Chris@16
|
86 #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
|
Chris@16
|
87 //Some systems have "jailed" environments where shm usage is restricted at runtime
|
Chris@101
|
88 //and temporary file based shm is possible in those executions.
|
Chris@16
|
89 #elif defined(__FreeBSD__)
|
Chris@16
|
90 #define BOOST_INTERPROCESS_RUNTIME_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
|
Chris@16
|
91 #endif
|
Chris@16
|
92 #endif
|
Chris@16
|
93
|
Chris@101
|
94 //////////////////////////////////////////////////////
|
Chris@101
|
95 // _POSIX_MAPPED_FILES (POSIX.1b/POSIX.4)
|
Chris@101
|
96 //////////////////////////////////////////////////////
|
Chris@101
|
97 #if defined(_POSIX_MAPPED_FILES) && ((_POSIX_MAPPED_FILES + 0) > 0)
|
Chris@101
|
98 #define BOOST_INTERPROCESS_POSIX_MAPPED_FILES
|
Chris@101
|
99 #endif
|
Chris@101
|
100
|
Chris@101
|
101 //////////////////////////////////////////////////////
|
Chris@101
|
102 // _POSIX_SEMAPHORES (POSIX.1b/POSIX.4)
|
Chris@101
|
103 //////////////////////////////////////////////////////
|
Chris@101
|
104 #if ( defined(_POSIX_SEMAPHORES) && ((_POSIX_SEMAPHORES + 0) > 0) ) ||\
|
Chris@101
|
105 ( defined(__FreeBSD__) && (__FreeBSD__ >= 4)) || \
|
Chris@101
|
106 defined(__APPLE__)
|
Chris@101
|
107 #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
|
Chris@101
|
108 //MacOsX declares _POSIX_SEMAPHORES but sem_init returns ENOSYS
|
Chris@101
|
109 #if !defined(__APPLE__)
|
Chris@101
|
110 #define BOOST_INTERPROCESS_POSIX_UNNAMED_SEMAPHORES
|
Chris@101
|
111 #endif
|
Chris@16
|
112 #if defined(__osf__) || defined(__vms)
|
Chris@16
|
113 #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SEMAPHORES
|
Chris@16
|
114 #endif
|
Chris@16
|
115 #endif
|
Chris@16
|
116
|
Chris@101
|
117 //////////////////////////////////////////////////////
|
Chris@101
|
118 // _POSIX_BARRIERS (SUSv3/Unix03)
|
Chris@101
|
119 //////////////////////////////////////////////////////
|
Chris@101
|
120 #if defined(_POSIX_BARRIERS) && ((_POSIX_BARRIERS + 0) >= 200112L)
|
Chris@101
|
121 #define BOOST_INTERPROCESS_POSIX_BARRIERS
|
Chris@16
|
122 #endif
|
Chris@16
|
123
|
Chris@101
|
124 //////////////////////////////////////////////////////
|
Chris@101
|
125 // _POSIX_TIMEOUTS (SUSv3/Unix03)
|
Chris@101
|
126 //////////////////////////////////////////////////////
|
Chris@101
|
127 #if defined(_POSIX_TIMEOUTS) && ((_POSIX_TIMEOUTS + 0L) >= 200112L)
|
Chris@101
|
128 #define BOOST_INTERPROCESS_POSIX_TIMEOUTS
|
Chris@101
|
129 #endif
|
Chris@101
|
130
|
Chris@101
|
131 //////////////////////////////////////////////////////
|
Chris@101
|
132 // Detect BSD derivatives to detect sysctl
|
Chris@101
|
133 //////////////////////////////////////////////////////
|
Chris@16
|
134 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
|
Chris@16
|
135 #define BOOST_INTERPROCESS_BSD_DERIVATIVE
|
Chris@16
|
136 //Some *BSD systems (OpenBSD & NetBSD) need sys/param.h before sys/sysctl.h, whereas
|
Chris@16
|
137 //others (FreeBSD & Darwin) need sys/types.h
|
Chris@16
|
138 #include <sys/types.h>
|
Chris@16
|
139 #include <sys/param.h>
|
Chris@16
|
140 #include <sys/sysctl.h>
|
Chris@16
|
141 #if defined(CTL_KERN) && defined (KERN_BOOTTIME)
|
Chris@16
|
142 //#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
|
Chris@16
|
143 #endif
|
Chris@16
|
144 #endif
|
Chris@101
|
145
|
Chris@101
|
146 //////////////////////////////////////////////////////
|
Chris@101
|
147 //64 bit offset
|
Chris@101
|
148 //////////////////////////////////////////////////////
|
Chris@101
|
149 #if (defined (_V6_ILP32_OFFBIG) &&(_V6_ILP32_OFFBIG - 0 > 0)) ||\
|
Chris@101
|
150 (defined (_V6_LP64_OFF64) &&(_V6_LP64_OFF64 - 0 > 0)) ||\
|
Chris@101
|
151 (defined (_V6_LPBIG_OFFBIG) &&(_V6_LPBIG_OFFBIG - 0 > 0)) ||\
|
Chris@101
|
152 (defined (_XBS5_ILP32_OFFBIG)&&(_XBS5_ILP32_OFFBIG - 0 > 0)) ||\
|
Chris@101
|
153 (defined (_XBS5_LP64_OFF64) &&(_XBS5_LP64_OFF64 - 0 > 0)) ||\
|
Chris@101
|
154 (defined (_XBS5_LPBIG_OFFBIG)&&(_XBS5_LPBIG_OFFBIG - 0 > 0)) ||\
|
Chris@101
|
155 (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))||\
|
Chris@101
|
156 (defined (_FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))
|
Chris@101
|
157 #define BOOST_INTERPROCESS_UNIX_64_BIT_OR_BIGGER_OFF_T
|
Chris@101
|
158 #endif
|
Chris@16
|
159 #endif //!defined(BOOST_INTERPROCESS_WINDOWS)
|
Chris@16
|
160
|
Chris@101
|
161 #if defined(BOOST_INTERPROCESS_WINDOWS) || defined(BOOST_INTERPROCESS_POSIX_MAPPED_FILES)
|
Chris@101
|
162 # define BOOST_INTERPROCESS_MAPPED_FILES
|
Chris@16
|
163 #endif
|
Chris@16
|
164
|
Chris@16
|
165 //Now declare some Boost.Interprocess features depending on the implementation
|
Chris@16
|
166 #if defined(BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
|
Chris@16
|
167 #define BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES
|
Chris@16
|
168 #define BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES
|
Chris@16
|
169 #endif
|
Chris@16
|
170
|
Chris@101
|
171 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
Chris@101
|
172 #define BOOST_INTERPROCESS_PERFECT_FORWARDING
|
Chris@101
|
173 #endif
|
Chris@101
|
174
|
Chris@16
|
175 // Timeout duration use if BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING is set
|
Chris@16
|
176 #ifndef BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS
|
Chris@16
|
177 #define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS 10000
|
Chris@16
|
178 #endif
|
Chris@16
|
179
|
Chris@16
|
180 //Other switches
|
Chris@16
|
181 //BOOST_INTERPROCESS_MSG_QUEUE_USES_CIRC_INDEX
|
Chris@16
|
182 //message queue uses a circular queue as index instead of an array (better performance)
|
Chris@16
|
183 //Boost version < 1.52 uses an array, so undef this if you want to communicate
|
Chris@16
|
184 //with processes compiled with those versions.
|
Chris@16
|
185 #define BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX
|
Chris@16
|
186
|
Chris@101
|
187 //Macros for documentation purposes. For code, expands to the argument
|
Chris@101
|
188 #define BOOST_INTERPROCESS_IMPDEF(TYPE) TYPE
|
Chris@101
|
189 #define BOOST_INTERPROCESS_SEEDOC(TYPE) TYPE
|
Chris@16
|
190
|
Chris@16
|
191 #include <boost/interprocess/detail/config_end.hpp>
|
Chris@16
|
192
|
Chris@16
|
193 #endif //#ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
|