wordsize.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Copyright Rene Ferdinand Rivera Morell 2020-2021
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #ifndef BOOST_PREDEF_OTHER_WORD_SIZE_H
  8. #define BOOST_PREDEF_OTHER_WORD_SIZE_H
  9. #include <boost/predef/architecture.h>
  10. #include <boost/predef/version_number.h>
  11. #include <boost/predef/make.h>
  12. /* tag::reference[]
  13. = `BOOST_ARCH_WORD_BITS`
  14. Detects the native word size, in bits, for the current architecture. There are
  15. two types of macros for this detection:
  16. * `BOOST_ARCH_WORD_BITS`, gives the number of word size bits
  17. (16, 32, 64).
  18. * `BOOST_ARCH_WORD_BITS_16`, `BOOST_ARCH_WORD_BITS_32`, and
  19. `BOOST_ARCH_WORD_BITS_64`, indicate when the given word size is
  20. detected.
  21. They allow for both single checks and direct use of the size in code.
  22. NOTE: The word size is determined manually on each architecture. Hence use of
  23. the `wordsize.h` header will also include all the architecture headers.
  24. */ // end::reference[]
  25. #if !defined(BOOST_ARCH_WORD_BITS_64)
  26. # define BOOST_ARCH_WORD_BITS_64 BOOST_VERSION_NUMBER_NOT_AVAILABLE
  27. #elif !defined(BOOST_ARCH_WORD_BITS)
  28. # define BOOST_ARCH_WORD_BITS 64
  29. #endif
  30. #if !defined(BOOST_ARCH_WORD_BITS_32)
  31. # define BOOST_ARCH_WORD_BITS_32 BOOST_VERSION_NUMBER_NOT_AVAILABLE
  32. #elif !defined(BOOST_ARCH_WORD_BITS)
  33. # define BOOST_ARCH_WORD_BITS 32
  34. #endif
  35. #if !defined(BOOST_ARCH_WORD_BITS_16)
  36. # define BOOST_ARCH_WORD_BITS_16 BOOST_VERSION_NUMBER_NOT_AVAILABLE
  37. #elif !defined(BOOST_ARCH_WORD_BITS)
  38. # define BOOST_ARCH_WORD_BITS 16
  39. #endif
  40. #if !defined(BOOST_ARCH_WORD_BITS)
  41. # define BOOST_ARCH_WORD_BITS 0
  42. #endif
  43. #define BOOST_ARCH_WORD_BITS_NAME "Word Bits"
  44. #define BOOST_ARCH_WORD_BITS_16_NAME "16-bit Word Size"
  45. #define BOOST_ARCH_WORD_BITS_32_NAME "32-bit Word Size"
  46. #define BOOST_ARCH_WORD_BITS_64_NAME "64-bit Word Size"
  47. #endif
  48. #include <boost/predef/detail/test.h>
  49. BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_WORD_BITS,BOOST_ARCH_WORD_BITS_NAME)
  50. #include <boost/predef/detail/test.h>
  51. BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_WORD_BITS_16,BOOST_ARCH_WORD_BITS_16_NAME)
  52. #include <boost/predef/detail/test.h>
  53. BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_WORD_BITS_32,BOOST_ARCH_WORD_BITS_32_NAME)
  54. #include <boost/predef/detail/test.h>
  55. BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_WORD_BITS_64,BOOST_ARCH_WORD_BITS_64_NAME)