BVB Source Codes

mars Show int_sizes.hpp Source code

Return Download mars: download int_sizes.hpp Source code - Download mars Source code - Type:.hpp
  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/int_sizes.hpp
  10.  *
  11.  * This header defines macros for testing buitin integer type sizes
  12.  */
  13.  
  14. #ifndef BOOST_ATOMIC_DETAIL_INT_SIZES_HPP_INCLUDED_
  15. #define BOOST_ATOMIC_DETAIL_INT_SIZES_HPP_INCLUDED_
  16.  
  17. #include <boost/atomic/detail/config.hpp>
  18.  
  19. #ifdef BOOST_HAS_PRAGMA_ONCE
  20. #pragma once
  21. #endif
  22.  
  23. // GCC and compatible compilers define internal macros with builtin type traits
  24. #if defined(__SIZEOF_SHORT__)
  25. #define BOOST_ATOMIC_DETAIL_SIZEOF_SHORT __SIZEOF_SHORT__
  26. #endif
  27. #if defined(__SIZEOF_INT__)
  28. #define BOOST_ATOMIC_DETAIL_SIZEOF_INT __SIZEOF_INT__
  29. #endif
  30. #if defined(__SIZEOF_LONG__)
  31. #define BOOST_ATOMIC_DETAIL_SIZEOF_LONG __SIZEOF_LONG__
  32. #endif
  33. #if defined(__SIZEOF_LONG_LONG__)
  34. #define BOOST_ATOMIC_DETAIL_SIZEOF_LLONG __SIZEOF_LONG_LONG__
  35. #endif
  36. #if defined(__SIZEOF_WCHAR_T__)
  37. #define BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T __SIZEOF_WCHAR_T__
  38. #endif
  39. #if defined(__SIZEOF_POINTER__)
  40. #define BOOST_ATOMIC_DETAIL_SIZEOF_POINTER __SIZEOF_POINTER__
  41. #elif defined(_MSC_VER)
  42. #if defined(_M_AMD64) || defined(_M_IA64)
  43. #define BOOST_ATOMIC_DETAIL_SIZEOF_POINTER 8
  44. #else
  45. #define BOOST_ATOMIC_DETAIL_SIZEOF_POINTER 4
  46. #endif
  47. #endif
  48.  
  49. #if !defined(BOOST_ATOMIC_DETAIL_SIZEOF_SHORT) || !defined(BOOST_ATOMIC_DETAIL_SIZEOF_INT) ||\
  50.     !defined(BOOST_ATOMIC_DETAIL_SIZEOF_LONG) || !defined(BOOST_ATOMIC_DETAIL_SIZEOF_LLONG)
  51.  
  52. // Try to deduce sizes from limits
  53. #include <limits.h>
  54. #include <boost/cstdint.hpp>
  55.  
  56. #if (USHRT_MAX + 0) == 0xff
  57. #define BOOST_ATOMIC_DETAIL_SIZEOF_SHORT 1
  58. #elif (USHRT_MAX + 0) == 0xffff
  59. #define BOOST_ATOMIC_DETAIL_SIZEOF_SHORT 2
  60. #elif (USHRT_MAX + 0) == 0xffffffff
  61. #define BOOST_ATOMIC_DETAIL_SIZEOF_SHORT 4
  62. #elif (USHRT_MAX + 0) == UINT64_C(0xffffffffffffffff)
  63. #define BOOST_ATOMIC_DETAIL_SIZEOF_SHORT 8
  64. #endif
  65.  
  66. #if (UINT_MAX + 0) == 0xff
  67. #define BOOST_ATOMIC_DETAIL_SIZEOF_INT 1
  68. #elif (UINT_MAX + 0) == 0xffff
  69. #define BOOST_ATOMIC_DETAIL_SIZEOF_INT 2
  70. #elif (UINT_MAX + 0) == 0xffffffff
  71. #define BOOST_ATOMIC_DETAIL_SIZEOF_INT 4
  72. #elif (UINT_MAX + 0) == UINT64_C(0xffffffffffffffff)
  73. #define BOOST_ATOMIC_DETAIL_SIZEOF_INT 8
  74. #endif
  75.  
  76. #if (ULONG_MAX + 0) == 0xff
  77. #define BOOST_ATOMIC_DETAIL_SIZEOF_LONG 1
  78. #elif (ULONG_MAX + 0) == 0xffff
  79. #define BOOST_ATOMIC_DETAIL_SIZEOF_LONG 2
  80. #elif (ULONG_MAX + 0) == 0xffffffff
  81. #define BOOST_ATOMIC_DETAIL_SIZEOF_LONG 4
  82. #elif (ULONG_MAX + 0) == UINT64_C(0xffffffffffffffff)
  83. #define BOOST_ATOMIC_DETAIL_SIZEOF_LONG 8
  84. #endif
  85.  
  86. #if defined(__hpux) // HP-UX's value of ULONG_LONG_MAX is unusable in preprocessor expressions
  87. #define BOOST_ATOMIC_DETAIL_SIZEOF_LLONG 8
  88. #else
  89.  
  90. // The list of the non-standard macros (the ones except ULLONG_MAX) is taken from cstdint.hpp
  91. #if defined(ULLONG_MAX)
  92. #define BOOST_ATOMIC_DETAIL_ULLONG_MAX ULLONG_MAX
  93. #elif defined(ULONG_LONG_MAX)
  94. #define BOOST_ATOMIC_DETAIL_ULLONG_MAX ULONG_LONG_MAX
  95. #elif defined(ULONGLONG_MAX)
  96. #define BOOST_ATOMIC_DETAIL_ULLONG_MAX ULONGLONG_MAX
  97. #elif defined(_LLONG_MAX) // strangely enough, this one seems to be holding the limit for the unsigned integer
  98. #define BOOST_ATOMIC_DETAIL_ULLONG_MAX _LLONG_MAX
  99. #endif
  100.  
  101. #if (BOOST_ATOMIC_DETAIL_ULLONG_MAX + 0) == 0xff
  102. #define BOOST_ATOMIC_DETAIL_SIZEOF_LLONG 1
  103. #elif (BOOST_ATOMIC_DETAIL_ULLONG_MAX + 0) == 0xffff
  104. #define BOOST_ATOMIC_DETAIL_SIZEOF_LLONG 2
  105. #elif (BOOST_ATOMIC_DETAIL_ULLONG_MAX + 0) == 0xffffffff
  106. #define BOOST_ATOMIC_DETAIL_SIZEOF_LLONG 4
  107. #elif (BOOST_ATOMIC_DETAIL_ULLONG_MAX + 0) == UINT64_C(0xffffffffffffffff)
  108. #define BOOST_ATOMIC_DETAIL_SIZEOF_LLONG 8
  109. #endif
  110.  
  111. #endif // defined(__hpux)
  112.  
  113. #endif
  114.  
  115. #if !defined(BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T)
  116.  
  117. #include <wchar.h>
  118. #include <boost/cstdint.hpp>
  119.  
  120.  #if defined(_MSC_VER) && ( _MSC_VER <= 1310 || defined(UNDER_CE) && _MSC_VER <= 1500 )
  121. // MSVC 7.1 and MSVC 8 (arm) define WCHAR_MAX to a value not suitable for constant expressions
  122. #define BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T 2
  123. #elif (WCHAR_MAX + 0) == 0xff || (WCHAR_MAX + 0) == 0x7f
  124. #define BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T 1
  125. #elif (WCHAR_MAX + 0) == 0xffff || (WCHAR_MAX + 0) == 0x7fff
  126. #define BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T 2
  127. #elif (WCHAR_MAX + 0) == 0xffffffff || (WCHAR_MAX + 0) == 0x7fffffff
  128. #define BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T 4
  129. #elif (WCHAR_MAX + 0) == UINT64_C(0xffffffffffffffff) || (WCHAR_MAX + 0) == INT64_C(0x7fffffffffffffff)
  130. #define BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T 8
  131. #endif
  132. #endif
  133.  
  134. #if !defined(BOOST_ATOMIC_DETAIL_SIZEOF_SHORT) || !defined(BOOST_ATOMIC_DETAIL_SIZEOF_INT) ||\
  135.     !defined(BOOST_ATOMIC_DETAIL_SIZEOF_LONG) || !defined(BOOST_ATOMIC_DETAIL_SIZEOF_LLONG) ||\
  136.     !defined(BOOST_ATOMIC_DETAIL_SIZEOF_WCHAR_T)
  137. #error Boost.Atomic: Failed to determine builtin integer sizes, the target platform is not supported. Please, report to the developers.
  138. #endif
  139.  
  140. #endif // BOOST_ATOMIC_DETAIL_INT_SIZES_HPP_INCLUDED_
  141.  
downloadint_sizes.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top