capabilities.hpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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/capabilities.hpp
  10. *
  11. * This header defines feature capabilities macros.
  12. */
  13. #ifndef BOOST_ATOMIC_CAPABILITIES_HPP_INCLUDED_
  14. #define BOOST_ATOMIC_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_EMULATED)
  22. #include BOOST_ATOMIC_DETAIL_BACKEND_HEADER(boost/atomic/detail/caps_)
  23. #endif
  24. #ifdef BOOST_HAS_PRAGMA_ONCE
  25. #pragma once
  26. #endif
  27. #ifndef BOOST_ATOMIC_INT8_LOCK_FREE
  28. #define BOOST_ATOMIC_INT8_LOCK_FREE 0
  29. #endif
  30. #ifndef BOOST_ATOMIC_INT16_LOCK_FREE
  31. #define BOOST_ATOMIC_INT16_LOCK_FREE 0
  32. #endif
  33. #ifndef BOOST_ATOMIC_INT32_LOCK_FREE
  34. #define BOOST_ATOMIC_INT32_LOCK_FREE 0
  35. #endif
  36. #ifndef BOOST_ATOMIC_INT64_LOCK_FREE
  37. #define BOOST_ATOMIC_INT64_LOCK_FREE 0
  38. #endif
  39. #ifndef BOOST_ATOMIC_INT128_LOCK_FREE
  40. #define BOOST_ATOMIC_INT128_LOCK_FREE 0
  41. #endif
  42. #ifndef BOOST_ATOMIC_CHAR_LOCK_FREE
  43. #define BOOST_ATOMIC_CHAR_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  44. #endif
  45. #ifndef BOOST_ATOMIC_CHAR16_T_LOCK_FREE
  46. #define BOOST_ATOMIC_CHAR16_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  47. #endif
  48. #ifndef BOOST_ATOMIC_CHAR32_T_LOCK_FREE
  49. #define BOOST_ATOMIC_CHAR32_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  50. #endif
  51. #ifndef BOOST_ATOMIC_WCHAR_T_LOCK_FREE
  52. #if BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 1
  53. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  54. #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 2
  55. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  56. #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 4
  57. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  58. #elif BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T == 8
  59. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  60. #else
  61. #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 0
  62. #endif
  63. #endif
  64. #ifndef BOOST_ATOMIC_SHORT_LOCK_FREE
  65. #if BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 1
  66. #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  67. #elif BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 2
  68. #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  69. #elif BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 4
  70. #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  71. #elif BOOST_ATOMIC_DETAIL_SIZEOF_SHORT == 8
  72. #define BOOST_ATOMIC_SHORT_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  73. #else
  74. #define BOOST_ATOMIC_SHORT_LOCK_FREE 0
  75. #endif
  76. #endif
  77. #ifndef BOOST_ATOMIC_INT_LOCK_FREE
  78. #if BOOST_ATOMIC_DETAIL_SIZEOF_INT == 1
  79. #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  80. #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 2
  81. #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  82. #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 4
  83. #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  84. #elif BOOST_ATOMIC_DETAIL_SIZEOF_INT == 8
  85. #define BOOST_ATOMIC_INT_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  86. #else
  87. #define BOOST_ATOMIC_INT_LOCK_FREE 0
  88. #endif
  89. #endif
  90. #ifndef BOOST_ATOMIC_LONG_LOCK_FREE
  91. #if BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 1
  92. #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  93. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 2
  94. #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  95. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 4
  96. #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  97. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG == 8
  98. #define BOOST_ATOMIC_LONG_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  99. #else
  100. #define BOOST_ATOMIC_LONG_LOCK_FREE 0
  101. #endif
  102. #endif
  103. #ifndef BOOST_ATOMIC_LLONG_LOCK_FREE
  104. #if BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 1
  105. #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  106. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 2
  107. #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  108. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 4
  109. #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  110. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LLONG == 8
  111. #define BOOST_ATOMIC_LLONG_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  112. #else
  113. #define BOOST_ATOMIC_LLONG_LOCK_FREE 0
  114. #endif
  115. #endif
  116. #ifndef BOOST_ATOMIC_POINTER_LOCK_FREE
  117. #if (BOOST_ATOMIC_DETAIL_SIZEOF_POINTER + 0) == 8
  118. #define BOOST_ATOMIC_POINTER_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  119. #elif (BOOST_ATOMIC_DETAIL_SIZEOF_POINTER + 0) == 4
  120. #define BOOST_ATOMIC_POINTER_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  121. #else
  122. #define BOOST_ATOMIC_POINTER_LOCK_FREE 0
  123. #endif
  124. #endif
  125. #define BOOST_ATOMIC_ADDRESS_LOCK_FREE BOOST_ATOMIC_POINTER_LOCK_FREE
  126. #ifndef BOOST_ATOMIC_BOOL_LOCK_FREE
  127. // We store bools in 1-byte storage in all backends
  128. #define BOOST_ATOMIC_BOOL_LOCK_FREE BOOST_ATOMIC_INT8_LOCK_FREE
  129. #endif
  130. #ifndef BOOST_ATOMIC_FLAG_LOCK_FREE
  131. #define BOOST_ATOMIC_FLAG_LOCK_FREE BOOST_ATOMIC_BOOL_LOCK_FREE
  132. #endif
  133. #if !defined(BOOST_ATOMIC_NO_FLOATING_POINT)
  134. #if !defined(BOOST_ATOMIC_FLOAT_LOCK_FREE) && defined(BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT)
  135. #if BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT == 2
  136. #define BOOST_ATOMIC_FLOAT_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  137. #elif BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT == 4
  138. #define BOOST_ATOMIC_FLOAT_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  139. #elif BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT == 8
  140. #define BOOST_ATOMIC_FLOAT_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  141. #elif BOOST_ATOMIC_DETAIL_SIZEOF_FLOAT == 16
  142. #define BOOST_ATOMIC_FLOAT_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE
  143. #else
  144. #define BOOST_ATOMIC_FLOAT_LOCK_FREE 0
  145. #endif
  146. #endif
  147. #if !defined(BOOST_ATOMIC_DOUBLE_LOCK_FREE) && defined(BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE)
  148. #if BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE == 2
  149. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  150. #elif BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE == 4
  151. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  152. #elif BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE == 8
  153. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  154. #elif BOOST_ATOMIC_DETAIL_SIZEOF_DOUBLE == 16
  155. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE
  156. #else
  157. #define BOOST_ATOMIC_DOUBLE_LOCK_FREE 0
  158. #endif
  159. #endif
  160. #if !defined(BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE) && defined(BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE)
  161. #if BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE == 2
  162. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT16_LOCK_FREE
  163. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE == 4
  164. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT32_LOCK_FREE
  165. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE == 8
  166. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT64_LOCK_FREE
  167. #elif BOOST_ATOMIC_DETAIL_SIZEOF_LONG_DOUBLE == 16
  168. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE BOOST_ATOMIC_INT128_LOCK_FREE
  169. #else
  170. #define BOOST_ATOMIC_LONG_DOUBLE_LOCK_FREE 0
  171. #endif
  172. #endif
  173. #endif // !defined(BOOST_ATOMIC_NO_FLOATING_POINT)
  174. #ifndef BOOST_ATOMIC_THREAD_FENCE
  175. #define BOOST_ATOMIC_THREAD_FENCE 0
  176. #endif
  177. #ifndef BOOST_ATOMIC_SIGNAL_FENCE
  178. #define BOOST_ATOMIC_SIGNAL_FENCE 0
  179. #endif
  180. #endif // BOOST_ATOMIC_CAPABILITIES_HPP_INCLUDED_