capabilities.hpp 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. /*
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * Copyright (c) 2014 Andrey Semashev
  7. */
  8. /*!
  9. * \file atomic/detail/capabilities.hpp
  10. *
  11. * This header defines core feature capabilities macros.
  12. */
  13. #ifndef BOOST_ATOMIC_DETAIL_CAPABILITIES_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_DETAIL_CAPABILITIES_HPP_INCLUDED_
  15. #include <boost/atomic/detail/config.hpp>
  16. #include <boost/atomic/detail/platform.hpp>
  17. #include <boost/atomic/detail/int_sizes.hpp>
  18. #if !defined(BOOST_ATOMIC_NO_FLOATING_POINT)
  19. #include <boost/atomic/detail/float_sizes.hpp>
  20. #endif
  21. #if defined(BOOST_ATOMIC_DETAIL_CORE_BACKEND_HEADER)
  22. #include BOOST_ATOMIC_DETAIL_CORE_BACKEND_HEADER(boost/atomic/detail/caps_)
  23. #elif defined(BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND_HEADER)
  24. #include BOOST_ATOMIC_DETAIL_CORE_ARCH_BACKEND_HEADER(boost/atomic/detail/caps_arch_)
  25. #endif
  26. #ifdef BOOST_HAS_PRAGMA_ONCE
  27. #pragma once
  28. #endif
  29. #ifndef BOOST_ATOMIC_INT8_LOCK_FREE
  30. #define BOOST_ATOMIC_INT8_LOCK_FREE 0
  31. #endif
  32. #ifndef BOOST_ATOMIC_INT16_LOCK_FREE
  33. #define BOOST_ATOMIC_INT16_LOCK_FREE 0
  34. #endif
  35. #ifndef BOOST_ATOMIC_INT32_LOCK_FREE
  36. #define BOOST_ATOMIC_INT32_LOCK_FREE 0
  37. #endif
  38. #ifndef BOOST_ATOMIC_INT64_LOCK_FREE
  39. #define BOOST_ATOMIC_INT64_LOCK_FREE 0
  40. #endif
  41. #ifndef BOOST_ATOMIC_INT128_LOCK_FREE
  42. #define BOOST_ATOMIC_INT128_LOCK_FREE 0
  43. #endif
  44. #ifndef BOOST_ATOMIC_CHAR_LOCK_FREE
  45. #define BOOST_ATOMIC_CHAR_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  46. #endif
  47. #ifndef BOOST_ATOMIC_CHAR8_T_LOCK_FREE
  48. #define BOOST_ATOMIC_CHAR8_T_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  49. #endif
  50. #ifndef BOOST_ATOMIC_CHAR16_T_LOCK_FREE
  51. #define BOOST_ATOMIC_CHAR16_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  52. #endif
  53. #ifndef BOOST_ATOMIC_CHAR32_T_LOCK_FREE
  54. #define BOOST_ATOMIC_CHAR32_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  55. #endif
  56. #ifndef BOOST_ATOMIC_WCHAR_T_LOCK_FREE
  57. #if BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 1
  58. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  59. #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 2
  60. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  61. #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 4
  62. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  63. #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 8
  64. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  65. #else
  66. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0
  67. #endif
  68. #endif
  69. #ifndef BOOST_ATOMIC_SHORT_LOCK_FREE
  70. #if BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 1
  71. #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  72. #elif BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 2
  73. #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  74. #elif BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 4
  75. #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  76. #elif BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 8
  77. #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  78. #else
  79. #define BOOST_ATOMIC_SHORT_LOCK_FREE 0
  80. #endif
  81. #endif
  82. #ifndef BOOST_ATOMIC_INT_LOCK_FREE
  83. #if BOOST_ATOMIC_DETAIL_SIZEOF_INT == 1
  84. #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  85. #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 2
  86. #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  87. #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 4
  88. #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  89. #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 8
  90. #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  91. #else
  92. #define BOOST_ATOMIC_INT_LOCK_FREE 0
  93. #endif
  94. #endif
  95. #ifndef BOOST_ATOMIC_LONG_LOCK_FREE
  96. #if BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 1
  97. #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  98. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 2
  99. #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  100. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 4
  101. #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  102. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 8
  103. #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  104. #else
  105. #define BOOST_ATOMIC_LONG_LOCK_FREE 0
  106. #endif
  107. #endif
  108. #ifndef BOOST_ATOMIC_LLONG_LOCK_FREE
  109. #if BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 1
  110. #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  111. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 2
  112. #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  113. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 4
  114. #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  115. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 8
  116. #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  117. #else
  118. #define BOOST_ATOMIC_LLONG_LOCK_FREE 0
  119. #endif
  120. #endif
  121. #ifndef BOOST_ATOMIC_POINTER_LOCK_FREE
  122. #if (BOOST_ATOMIC_DETAIL_SIZEOF_POINTER + 0) == 8
  123. #define BOOST_ATOMIC_POINTER_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  124. #elif (BOOST_ATOMIC_DETAIL_SIZEOF_POINTER + 0) == 4
  125. #define BOOST_ATOMIC_POINTER_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  126. #else
  127. #define BOOST_ATOMIC_POINTER_LOCK_FREE 0
  128. #endif
  129. #endif
  130. #define BOOST_ATOMIC_ADDRESS_LOCK_FREE BOOST_ATOMIC_POINTER_LOCK_FREE
  131. #ifndef BOOST_ATOMIC_BOOL_LOCK_FREE
  132. // We store bools in 1-byte storage in all backends
  133. #define BOOST_ATOMIC_BOOL_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  134. #endif
  135. #ifndef BOOST_ATOMIC_FLAG_LOCK_FREE
  136. // atomic_flag uses 4-byte storage
  137. #define BOOST_ATOMIC_FLAG_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  138. #endif
  139. #if !defined(BOOST_ATOMIC_NO_FLOATING_POINT)
  140. #if !defined(BOOST_ATOMIC_FLOAT_LOCK_FREE) && defined(BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT)
  141. #if BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT == 2
  142. #define BOOST_ATOMIC_FLOAT_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  143. #elif BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT == 4
  144. #define BOOST_ATOMIC_FLOAT_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  145. #elif BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT == 8
  146. #define BOOST_ATOMIC_FLOAT_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  147. #elif BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT > 8 && BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT <= 16
  148. #define BOOST_ATOMIC_FLOAT_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE
  149. #else
  150. #define BOOST_ATOMIC_FLOAT_LOCK_FREE 0
  151. #endif
  152. #endif
  153. #if !defined(BOOST_ATOMIC_DOUBLE_LOCK_FREE) && defined(BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE)
  154. #if BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE == 2
  155. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  156. #elif BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE == 4
  157. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  158. #elif BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE == 8
  159. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  160. #elif BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE > 8 && BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE <= 16
  161. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE
  162. #else
  163. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE 0
  164. #endif
  165. #endif
  166. #if !defined(BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE) && defined(BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE)
  167. #if BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE == 2
  168. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  169. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE == 4
  170. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  171. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE == 8
  172. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  173. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE > 8 && BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE <= 16
  174. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE
  175. #else
  176. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE 0
  177. #endif
  178. #endif
  179. #endif // !defined(BOOST_ATOMIC_NO_FLOATING_POINT)
  180. #ifndef BOOST_ATOMIC_THREAD_FENCE
  181. #define BOOST_ATOMIC_THREAD_FENCE 0
  182. #endif
  183. #ifndef BOOST_ATOMIC_SIGNAL_FENCE
  184. #define BOOST_ATOMIC_SIGNAL_FENCE 0
  185. #endif
  186. #endif // BOOST_ATOMIC_DETAIL_CAPABILITIES_HPP_INCLUDED_