| 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 | |
| 8 | #ifndef BOOST_PREDEF_OTHER_WORD_SIZE_H |
| 9 | #define BOOST_PREDEF_OTHER_WORD_SIZE_H |
| 10 | |
| 11 | #include <boost/predef/architecture.h> |
| 12 | #include <boost/predef/version_number.h> |
| 13 | #include <boost/predef/make.h> |
| 14 | |
| 15 | /* tag::reference[] |
| 16 | = `BOOST_ARCH_WORD_BITS` |
| 17 | |
| 18 | Detects the native word size, in bits, for the current architecture. There are |
| 19 | two types of macros for this detection: |
| 20 | |
| 21 | * `BOOST_ARCH_WORD_BITS`, gives the number of word size bits |
| 22 | (16, 32, 64). |
| 23 | * `BOOST_ARCH_WORD_BITS_16`, `BOOST_ARCH_WORD_BITS_32`, and |
| 24 | `BOOST_ARCH_WORD_BITS_64`, indicate when the given word size is |
| 25 | detected. |
| 26 | |
| 27 | They allow for both single checks and direct use of the size in code. |
| 28 | |
| 29 | NOTE: The word size is determined manually on each architecture. Hence use of |
| 30 | the `wordsize.h` header will also include all the architecture headers. |
| 31 | |
| 32 | */ // end::reference[] |
| 33 | |
| 34 | #if !defined(BOOST_ARCH_WORD_BITS_64) |
| 35 | # define BOOST_ARCH_WORD_BITS_64 BOOST_VERSION_NUMBER_NOT_AVAILABLE |
| 36 | #elif !defined(BOOST_ARCH_WORD_BITS) |
| 37 | # define BOOST_ARCH_WORD_BITS 64 |
| 38 | #endif |
| 39 | |
| 40 | #if !defined(BOOST_ARCH_WORD_BITS_32) |
| 41 | # define BOOST_ARCH_WORD_BITS_32 BOOST_VERSION_NUMBER_NOT_AVAILABLE |
| 42 | #elif !defined(BOOST_ARCH_WORD_BITS) |
| 43 | # define BOOST_ARCH_WORD_BITS 32 |
| 44 | #endif |
| 45 | |
| 46 | #if !defined(BOOST_ARCH_WORD_BITS_16) |
| 47 | # define BOOST_ARCH_WORD_BITS_16 BOOST_VERSION_NUMBER_NOT_AVAILABLE |
| 48 | #elif !defined(BOOST_ARCH_WORD_BITS) |
| 49 | # define BOOST_ARCH_WORD_BITS 16 |
| 50 | #endif |
| 51 | |
| 52 | #if !defined(BOOST_ARCH_WORD_BITS) |
| 53 | # define BOOST_ARCH_WORD_BITS 0 |
| 54 | #endif |
| 55 | |
| 56 | #define BOOST_ARCH_WORD_BITS_NAME "Word Bits" |
| 57 | #define BOOST_ARCH_WORD_BITS_16_NAME "16-bit Word Size" |
| 58 | #define BOOST_ARCH_WORD_BITS_32_NAME "32-bit Word Size" |
| 59 | #define BOOST_ARCH_WORD_BITS_64_NAME "64-bit Word Size" |
| 60 | |
| 61 | #endif |
| 62 | |
| 63 | #include <boost/predef/detail/test.h> |
| 64 | BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_WORD_BITS,BOOST_ARCH_WORD_BITS_NAME) |
| 65 | |
| 66 | #include <boost/predef/detail/test.h> |
| 67 | BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_WORD_BITS_16,BOOST_ARCH_WORD_BITS_16_NAME) |
| 68 | |
| 69 | #include <boost/predef/detail/test.h> |
| 70 | BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_WORD_BITS_32,BOOST_ARCH_WORD_BITS_32_NAME) |
| 71 | |
| 72 | #include <boost/predef/detail/test.h> |
| 73 | BOOST_PREDEF_DECLARE_TEST(BOOST_ARCH_WORD_BITS_64,BOOST_ARCH_WORD_BITS_64_NAME) |
| 74 | |