workaround.hpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  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)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
  11. #define BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP
  12. #include <boost/interprocess/detail/config_begin.hpp>
  13. #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
  14. #define BOOST_INTERPROCESS_WINDOWS
  15. #define BOOST_INTERPROCESS_FORCE_GENERIC_EMULATION
  16. #define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
  17. #else
  18. #include <unistd.h>
  19. #if defined(_POSIX_THREAD_PROCESS_SHARED) && ((_POSIX_THREAD_PROCESS_SHARED - 0) > 0)
  20. //Cygwin defines _POSIX_THREAD_PROCESS_SHARED but does not implement it.
  21. //Mac Os X >= Leopard defines _POSIX_THREAD_PROCESS_SHARED but does not seems to work.
  22. #if !defined(__CYGWIN__) && !defined(__APPLE__)
  23. #define BOOST_INTERPROCESS_POSIX_PROCESS_SHARED
  24. #endif
  25. #endif
  26. #if defined(_POSIX_BARRIERS) && ((_POSIX_BARRIERS - 0) > 0)
  27. #define BOOST_INTERPROCESS_POSIX_BARRIERS
  28. #endif
  29. #if defined(_POSIX_SEMAPHORES) && ((_POSIX_SEMAPHORES - 0) > 0)
  30. #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
  31. #if defined(__CYGWIN__)
  32. #define BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK
  33. #endif
  34. //Some platforms have a limited (name length) named semaphore support
  35. #elif (defined(__FreeBSD__) && (__FreeBSD__ >= 4)) || defined(__APPLE__)
  36. #define BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
  37. #endif
  38. #if ((defined _V6_ILP32_OFFBIG) &&(_V6_ILP32_OFFBIG - 0 > 0)) ||\
  39. ((defined _V6_LP64_OFF64) &&(_V6_LP64_OFF64 - 0 > 0)) ||\
  40. ((defined _V6_LPBIG_OFFBIG) &&(_V6_LPBIG_OFFBIG - 0 > 0)) ||\
  41. ((defined _XBS5_ILP32_OFFBIG)&&(_XBS5_ILP32_OFFBIG - 0 > 0)) ||\
  42. ((defined _XBS5_LP64_OFF64) &&(_XBS5_LP64_OFF64 - 0 > 0)) ||\
  43. ((defined _XBS5_LPBIG_OFFBIG)&&(_XBS5_LPBIG_OFFBIG - 0 > 0)) ||\
  44. ((defined _FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))||\
  45. ((defined _FILE_OFFSET_BITS) &&(_FILE_OFFSET_BITS - 0 >= 64))
  46. #define BOOST_INTERPROCESS_UNIX_64_BIT_OR_BIGGER_OFF_T
  47. #endif
  48. //Check for XSI shared memory objects. They are available in nearly all UNIX platforms
  49. #if !defined(__QNXNTO__)
  50. #define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS
  51. #endif
  52. #if defined(_POSIX_SHARED_MEMORY_OBJECTS) && ((_POSIX_SHARED_MEMORY_OBJECTS - 0) > 0)
  53. #define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
  54. #else
  55. //VMS and MACOS don't define it but they have shm_open/close interface
  56. #if defined(__vms)
  57. #if __CRTL_VER >= 70200000
  58. #define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
  59. #endif
  60. //Mac OS has some non-conformant features like names limited to SHM_NAME_MAX
  61. #elif defined (__APPLE__)
  62. //#define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
  63. //#define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS_NO_GROW
  64. #endif
  65. #endif
  66. //Now check if we have only XSI shared memory
  67. #if defined(BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS) &&\
  68. !defined(BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS)
  69. //#define BOOST_INTERPROCESS_XSI_SHARED_MEMORY_OBJECTS_ONLY
  70. #endif
  71. #if defined(_POSIX_TIMEOUTS) && ((_POSIX_TIMEOUTS - 0) > 0)
  72. #define BOOST_INTERPROCESS_POSIX_TIMEOUTS
  73. #endif
  74. #ifdef BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
  75. //Some systems have filesystem-based resources, so the
  76. //portable "/shmname" format does not work due to permission issues
  77. //For those systems we need to form a path to a temporary directory:
  78. // hp-ux tru64 vms freebsd
  79. #if defined(__hpux) || defined(__osf__) || defined(__vms) || (defined(__FreeBSD__) && (__FreeBSD__ < 7))
  80. #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
  81. //Some systems have "jailed" environments where shm usage is restricted at runtime
  82. //and temporary file file based shm is possible in those executions.
  83. #elif defined(__FreeBSD__)
  84. #define BOOST_INTERPROCESS_RUNTIME_FILESYSTEM_BASED_POSIX_SHARED_MEMORY
  85. #endif
  86. #endif
  87. #ifdef BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES
  88. #if defined(__osf__) || defined(__vms)
  89. #define BOOST_INTERPROCESS_FILESYSTEM_BASED_POSIX_SEMAPHORES
  90. #endif
  91. #endif
  92. #if defined(_POSIX_VERSION) && defined(_XOPEN_VERSION) && \
  93. (((_POSIX_VERSION + 0)>= 200112L || (_XOPEN_VERSION + 0)>= 500))
  94. #define BOOST_INTERPROCESS_POSIX_RECURSIVE_MUTEXES
  95. #endif
  96. #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
  97. #define BOOST_INTERPROCESS_BSD_DERIVATIVE
  98. #include <sys/sysctl.h>
  99. #if defined(CTL_KERN) && defined (KERN_BOOTTIME)
  100. //#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME
  101. #endif
  102. #endif
  103. #endif //!defined(BOOST_INTERPROCESS_WINDOWS)
  104. #if !defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_NO_VARIADIC_TEMPLATES)
  105. #define BOOST_INTERPROCESS_PERFECT_FORWARDING
  106. #endif
  107. //Now declare some Boost.Interprocess features depending on the implementation
  108. #if defined(BOOST_INTERPROCESS_POSIX_NAMED_SEMAPHORES) && !defined(BOOST_INTERPROCESS_POSIX_SEMAPHORES_NO_UNLINK)
  109. #define BOOST_INTERPROCESS_NAMED_MUTEX_USES_POSIX_SEMAPHORES
  110. #define BOOST_INTERPROCESS_NAMED_SEMAPHORE_USES_POSIX_SEMAPHORES
  111. #endif
  112. // Timeout duration use if BOOST_INTERPROCESS_ENABLE_TIMEOUT_WHEN_LOCKING is set
  113. #ifndef BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS
  114. #define BOOST_INTERPROCESS_TIMEOUT_WHEN_LOCKING_DURATION_MS 10000
  115. #endif
  116. //Other switches
  117. //BOOST_INTERPROCESS_MSG_QUEUE_USES_CIRC_INDEX
  118. //message queue uses a circular queue as index instead of an array (better performance)
  119. //Boost version < 1.52 uses an array, so undef this if you want to communicate
  120. //with processes compiled with those versions.
  121. #define BOOST_INTERPROCESS_MSG_QUEUE_CIRCULAR_INDEX
  122. //Inline attributes
  123. #if defined(_MSC_VER)
  124. #define BOOST_INTERPROCESS_ALWAYS_INLINE __forceinline
  125. #elif defined (__GNUC__)
  126. #define BOOST_INTERPROCESS_ALWAYS_INLINE __attribute__((__always_inline__))
  127. #else
  128. #define BOOST_INTERPROCESS_ALWAYS_INLINE inline
  129. #endif
  130. #if defined(_MSC_VER)
  131. #define BOOST_INTERPROCESS_NEVER_INLINE __declspec(noinline)
  132. #elif defined (__GNUC__)
  133. #define BOOST_INTERPROCESS_NEVER_INLINE __attribute__((__noinline__))
  134. #endif
  135. #include <boost/interprocess/detail/config_end.hpp>
  136. #endif //#ifndef BOOST_INTERPROCESS_DETAIL_WORKAROUND_HPP