block/include/nil/crypto3/detail/predef.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
3 //
4 // MIT License
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //---------------------------------------------------------------------------//
24 // @file This particular header is responsible for defining current architecture's
25 // (the architecture the library being compiled for) properties such as amount of
26 // bits target machine CPU's machine word is being represented with.
27 // This particular header is a pretty temporary one, and is present in Crypto3 library
28 // until following PR's are not accepted: https://github.com/boostorg/predef/pull/108,
29 // https://github.com/boostorg/predef/pull/107.
30 //---------------------------------------------------------------------------//
31 
32 #ifndef CRYPTO3_DETAIL_PREDEF_HPP
33 #define CRYPTO3_DETAIL_PREDEF_HPP
34 
35 #include <boost/predef/architecture.h>
36 
37 #if defined(BOOST_ARCH_ALPHA_AVAILABLE) && defined(BOOST_ARCH_ALPHA_NAME)
38 #define BOOST_ARCH_ALPHA_WORD_BITS 64
39 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_ALPHA_NAME
40 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_ALPHA_WORD_BITS
41 #elif defined(BOOST_ARCH_ARM_AVAILABLE) && defined(BOOST_ARCH_ARM_NAME)
42 #if defined(__ARM_ARCH) || defined(__TARGET_ARCH_ARM) || defined(__TARGET_ARCH_THUMB) || defined(_M_ARM) || \
43  defined(__arm__) || defined(__arm64) || defined(__thumb__) || defined(_M_ARM64) || defined(__aarch64__) || \
44  defined(__AARCH64EL__) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || \
45  defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6KZ__) || \
46  defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__) || \
47  defined(__ARM_ARCH_4T__) || defined(__ARM_ARCH_4__)
48 #if (defined(__arm64) || defined(_M_ARM64) || defined(__aarch64__) || defined(__AARCH64EL__))
49 #define BOOST_ARCH_ARM_WORD_BITS 64
50 #endif
51 #if (defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__))
52 #define BOOST_ARCH_ARM_WORD_BITS 32
53 #endif
54 #if (defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6KZ__) || defined(__ARM_ARCH_6T2__))
55 #define BOOST_ARCH_ARM_WORD_BITS 32
56 #endif
57 #if (defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__))
58 #define BOOST_ARCH_ARM_WORD_BITS 32
59 #endif
60 #if (defined(__ARM_ARCH_4T__) || defined(__ARM_ARCH_4__))
61 #define BOOST_ARCH_ARM_WORD_BITS 32
62 #endif
63 #endif
64 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_ARM_NAME
65 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_ARM_WORD_BITS
66 #elif defined(BOOST_ARCH_BLACKFIN_AVAILABLE) && defined(BOOST_ARCH_BLACKFIN_NAME)
67 #define BOOST_ARCH_BLACKFIN_WORD_BITS 16
68 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_BLACKFIN_NAME
69 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_BLACKFIN_WORD_BITS
70 #elif defined(BOOST_ARCH_CONVEX_AVAILABLE) && defined(BOOST_ARCH_CONVEX_NAME)
71 #define BOOST_ARCH_CONVEX_WORD_BITS 32
72 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_CONVEX_NAME
73 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_CONVEX_WORD_BITS
74 #elif defined(BOOST_ARCH_IA64_AVAILABLE) && defined(BOOST_ARCH_IA64_NAME)
75 #define BOOST_ARCH_IA64_WORD_BITS 64
76 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_IA64_NAME
77 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_IA64_WORD_BITS
78 #elif defined(BOOST_ARCH_M68K_AVAILABLE) && defined(BOOST_ARCH_M68K_NAME)
79 #define BOOST_ARCH_M68K_WORD_BITS 32
80 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_M68K_NAME
81 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_M68K_WORD_BITS
82 #elif defined(BOOST_ARCH_MIPS_AVAILABLE) && defined(BOOST_ARCH_MIPS_NAME)
83 #if defined(__mips__) || defined(__mips) || defined(__MIPS__)
84 #if !defined(BOOST_ARCH_MIPS) && (defined(_MIPS_ISA_MIPS1) || defined(_R3000))
85 #define BOOST_ARCH_MIPS_WORD_BITS 32
86 #endif
87 #if !defined(BOOST_ARCH_MIPS) && (defined(_MIPS_ISA_MIPS2) || defined(__MIPS_ISA2__) || defined(_R4000))
88 #define BOOST_ARCH_MIPS_WORD_BITS 32
89 #endif
90 #if !defined(BOOST_ARCH_MIPS) && (defined(_MIPS_ISA_MIPS3) || defined(__MIPS_ISA3__))
91 #define BOOST_ARCH_MIPS_WORD_BITS 64
92 #endif
93 #if !defined(BOOST_ARCH_MIPS) && (defined(_MIPS_ISA_MIPS4) || defined(__MIPS_ISA4__))
94 #define BOOST_ARCH_MIPS_WORD_BITS 64
95 #endif
96 #endif
97 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_MIPS_NAME
98 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_MIPS_WORD_BITS
99 #elif defined(BOOST_ARCH_PARISC_AVAILABLE) && defined(BOOST_ARCH_PARISC_NAME)
100 #define BOOST_ARCH_PARISC_WORD_BITS 32
101 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_PARISC_NAME
102 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_PARISC_WORD_BITS
103 #elif defined(BOOST_ARCH_PPC_AVAILABLE) && defined(BOOST_ARCH_PPC_NAME)
104 #if defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || defined(__ppc__) || defined(_M_PPC) || \
105  defined(_ARCH_PPC) || defined(__PPCGECKO__) || defined(__PPCBROADWAY__) || defined(_XENON)
106 #if !defined(BOOST_ARCH_PPC) && (defined(__ppc601__) || defined(_ARCH_601))
107 #define BOOST_ARCH_PPC_WORD_BITS 32
108 #endif
109 #if !defined(BOOST_ARCH_PPC) && (defined(__ppc603__) || defined(_ARCH_603))
110 #define BOOST_ARCH_PPC_WORD_BITS 32
111 #endif
112 #if !defined(BOOST_ARCH_PPC) && (defined(__ppc604__) || defined(__ppc604__))
113 #define BOOST_ARCH_PPC_WORD_BITS 32
114 #endif
115 #endif
116 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_PPC_NAME
117 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_PPC_WORD_BITS
118 #elif defined(BOOST_ARCH_PTX_AVAILABLE) && defined(BOOST_ARCH_PTX_NAME)
119 #define BOOST_ARCH_PTX_WORD_BITS 64
120 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_PTX_NAME
121 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_PTX_WORD_BITS
122 #elif defined(BOOST_ARCH_PYRAMID_AVAILABLE) && defined(BOOST_ARCH_PYRAMID_NAME)
123 #define BOOST_ARCH_PYRAMID_WORD_BITS 32
124 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_PYRAMID_NAME
125 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_PYRAMID_WORD_BITS
126 #elif defined(BOOST_ARCH_RISCV_AVAILABLE) && defined(BOOST_ARCH_RISCV_NAME)
127 #define BOOST_ARCH_RISCV_WORD_BITS 32
128 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_RISCV_NAME
129 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_RISCV_WORD_BITS
130 #elif defined(BOOST_ARCH_RS6K_AVAILABLE) && defined(BOOST_ARCH_RS6K_NAME)
131 #define BOOST_ARCH_PWR BOOST_ARCH_RS6000
132 #define BOOST_ARCH_PWR_NAME BOOST_ARCH_RS6000_NAME
133 #define BOOST_ARCH_PWR_WORD_BITS 32
134 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_RS6K_NAME
135 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_RS6K_WORD_BITS
136 #elif defined(BOOST_ARCH_SPARC_AVAILABLE) && defined(BOOST_ARCH_SPARC_NAME)
137 #if defined(__sparc__) || defined(__sparc)
138 #undef BOOST_ARCH_SPARC
139 #if !defined(BOOST_ARCH_SPARC) && defined(__sparcv9)
140 #define BOOST_ARCH_SPARC_WORD_BITS 64
141 #endif
142 #if !defined(BOOST_ARCH_SPARC) && defined(__sparcv8)
143 #define BOOST_ARCH_SPARC_WORD_BITS 32
144 #endif
145 #endif
146 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_SPARC_NAME
147 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_SPARC_WORD_BITS
148 #elif defined(BOOST_ARCH_SUPERH_AVAILABLE) && defined(BOOST_ARCH_SUPERH_NAME)
149 #if defined(__sh__)
150 #undef BOOST_ARCH_SH
151 #if !defined(BOOST_ARCH_SH) && (defined(__SH5__))
152 #define BOOST_ARCH_SH_WORD_BITS 64
153 #endif
154 #if !defined(BOOST_ARCH_SH) && (defined(__SH4__))
155 #define BOOST_ARCH_SH_WORD_BITS 32
156 #endif
157 #if !defined(BOOST_ARCH_SH) && (defined(__sh3__) || defined(__SH3__))
158 #define BOOST_ARCH_SH_WORD_BITS 32
159 #endif
160 #if !defined(BOOST_ARCH_SH) && (defined(__sh2__))
161 #define BOOST_ARCH_SH_WORD_BITS 16
162 #endif
163 #if !defined(BOOST_ARCH_SH) && (defined(__sh1__))
164 #define BOOST_ARCH_SH_WORD_BITS 16
165 #endif
166 #endif
167 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_SUPERH_NAME
168 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_SUPERH_WORD_BITS
169 #elif defined(BOOST_ARCH_SYS370_AVAILABLE) && defined(BOOST_ARCH_SYS370_NAME)
170 #define BOOST_ARCH_SYS370_WORD_BITS 32
171 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_SYS370_NAME
172 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_SYS370_WORD_BITS
173 #elif defined(BOOST_ARCH_SYS390_AVAILABLE) && defined(BOOST_ARCH_SYS390_NAME)
174 #define BOOST_ARCH_SYS390_WORD_BITS 32
175 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_SYS390_NAME
176 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_SYS390_WORD_BITS
177 #elif defined(BOOST_ARCH_X86_AVAILABLE) && defined(BOOST_ARCH_X86_NAME)
178 #define BOOST_ARCH_X86_32_WORD_BITS 32
179 #define BOOST_ARCH_X86_64_WORD_BITS 64
180 #if defined(BOOST_ARCH_x86_32)
181 #define BOOST_ARCH_X86_WORD_BITS BOOST_ARCH_X86_32_WORD_BITS
182 #define BOOST_ARCH_X86_NAME BOOST_ARCH_X86_32_NAME
183 #elif defined(BOOST_ARCH_X86_64)
184 #define BOOST_ARCH_X86_WORD_BITS BOOST_ARCH_X86_64_WORD_BITS
185 #endif
186 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_X86_NAME
187 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_X86_WORD_BITS
188 #elif defined(BOOST_ARCH_Z_AVAILABLE) && defined(BOOST_ARCH_Z_NAME)
189 #define BOOST_ARCH_Z_WORD_BITS 64
190 #define BOOST_ARCH_CURRENT_NAME BOOST_ARCH_Z_NAME
191 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_Z_WORD_BITS
192 #elif defined(__EMSCRIPTEN__)
193 #define BOOST_ARCH_EMSCRIPTEN_WORD_BITS 32
194 #define BOOST_ARCH_CURRENT_NAME "Emscripten"
195 #define BOOST_ARCH_CURRENT_WORD_BITS BOOST_ARCH_EMSCRIPTEN_WORD_BITS
196 #endif
197 
198 #endif // CRYPTO3_PREDEF_HPP