|
| 1 | +cfg_data = configuration_data() |
| 2 | + |
| 3 | +gcc_overflow_math_extensions = ''' |
| 4 | +#include <stdbool.h> |
| 5 | +bool foo(int a, int b, int *c) { |
| 6 | + return __builtin_mul_overflow(a, b, c); |
| 7 | +} |
| 8 | +
|
| 9 | +int main() { |
| 10 | + int out; |
| 11 | + if (foo(1, 2, &out)) { |
| 12 | + return 0; |
| 13 | + } |
| 14 | +
|
| 15 | + return 0; |
| 16 | +} |
| 17 | +''' |
| 18 | + |
| 19 | +cfg_data.set( |
| 20 | + 'AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS', |
| 21 | + cc.links( |
| 22 | + gcc_overflow_math_extensions, |
| 23 | + name: 'gcc_overflow_math_extensions', |
| 24 | + ), |
| 25 | +) |
| 26 | + |
| 27 | +gcc_inline_asm = ''' |
| 28 | +int main() { |
| 29 | + int foo = 42, bar = 24; |
| 30 | + __asm__ __volatile__(\"\":\"=r\"(foo):\"r\"(bar):\"memory\"); |
| 31 | +} |
| 32 | +''' |
| 33 | + |
| 34 | +cfg_data.set( |
| 35 | + 'AWS_HAVE_GCC_INLINE_ASM', |
| 36 | + cc.compiles( |
| 37 | + gcc_inline_asm, |
| 38 | + name: 'gcc_inline_asm', |
| 39 | + ), |
| 40 | +) |
| 41 | + |
| 42 | +msvc_intrinsics_x64 = ''' |
| 43 | +#include <intrin.h> |
| 44 | +int main() { |
| 45 | + unsigned __int64 a = 0x0fffffffffffffffI64; |
| 46 | + unsigned __int64 b = 0xf0000000I64; |
| 47 | + unsigned __int64 c, d; |
| 48 | + d = _umul128(a, b, &c); |
| 49 | + return 0; |
| 50 | +} |
| 51 | +''' |
| 52 | + |
| 53 | +cfg_data.set( |
| 54 | + 'AWS_HAVE_MSVC_INTRINSICS_X64', |
| 55 | + cc.links( |
| 56 | + msvc_intrinsics_x64, |
| 57 | + name: 'msvc_intrinsics_x64', |
| 58 | + ), |
| 59 | +) |
| 60 | +cfg_data.set('AWS_HAVE_POSIX_LARGE_FILE_SUPPORT', true) |
| 61 | +cfg_data.set( |
| 62 | + 'AWS_HAVE_EXECINFO', |
| 63 | + cc.has_function( |
| 64 | + 'backtrace', |
| 65 | + prefix: '#include <execinfo.h>', |
| 66 | + ), |
| 67 | +) |
| 68 | + |
| 69 | +winapi_desktop = ''' |
| 70 | +#include <windows.h> |
| 71 | +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
| 72 | +int main() { |
| 73 | + return 0; |
| 74 | +} |
| 75 | +#else |
| 76 | +it's not windows desktop |
| 77 | +#endif |
| 78 | +''' |
| 79 | + |
| 80 | +cfg_data.set( |
| 81 | + 'AWS_HAVE_WINAPI_DESKTOP', |
| 82 | + cc.compiles( |
| 83 | + winapi_desktop, |
| 84 | + name: 'winapi_desktop', |
| 85 | + ), |
| 86 | +) |
| 87 | +cfg_data.set('AWS_HAVE_LINUX_IF_LINK_H', cc.has_header('linux/if_link.h')) |
| 88 | + |
| 89 | +avx2_intrinsics = ''' |
| 90 | +#include <immintrin.h> |
| 91 | +#include <emmintrin.h> |
| 92 | +#include <string.h> |
| 93 | +
|
| 94 | +int main() { |
| 95 | + __m256i vec; |
| 96 | + memset(&vec, 0, sizeof(vec)); |
| 97 | +
|
| 98 | + _mm256_shuffle_epi8(vec, vec); |
| 99 | + _mm256_set_epi32(1,2,3,4,5,6,7,8); |
| 100 | + _mm256_permutevar8x32_epi32(vec, vec); |
| 101 | +
|
| 102 | + return 0; |
| 103 | +} |
| 104 | +''' |
| 105 | + |
| 106 | +cfg_data.set( |
| 107 | + 'AWS_HAVE_AVX2_INTRINSICS', |
| 108 | + cc.links( |
| 109 | + avx2_intrinsics, |
| 110 | + name: 'avx2_intrinsics', |
| 111 | + ), |
| 112 | +) |
| 113 | + |
| 114 | +avx512_intrinsics = ''' |
| 115 | +#include <immintrin.h> |
| 116 | +
|
| 117 | +int main() { |
| 118 | + __m512 a = _mm512_setzero_ps(); |
| 119 | + return 0; |
| 120 | +} |
| 121 | +''' |
| 122 | + |
| 123 | +cfg_data.set( |
| 124 | + 'AWS_HAVE_AVX512_INTRINSICS', |
| 125 | + cc.links( |
| 126 | + avx512_intrinsics, |
| 127 | + name: 'avx512_intrinsics', |
| 128 | + ), |
| 129 | +) |
| 130 | + |
| 131 | +mm256_extract_epi64 = ''' |
| 132 | +#include <immintrin.h> |
| 133 | +#include <string.h> |
| 134 | +
|
| 135 | +int main() { |
| 136 | + __m256i vec; |
| 137 | + memset(&vec, 0, sizeof(vec)); |
| 138 | + return (int)_mm256_extract_epi64(vec, 2); |
| 139 | +} |
| 140 | +''' |
| 141 | + |
| 142 | +cfg_data.set( |
| 143 | + 'AWS_HAVE_MM256_EXTRACT_EPI64', |
| 144 | + cc.links( |
| 145 | + mm256_extract_epi64, |
| 146 | + name: 'mm256_extract_epi64', |
| 147 | + ), |
| 148 | +) |
| 149 | + |
| 150 | +clmul = ''' |
| 151 | +#include <wmmintrin.h> |
| 152 | +#include <emmintrin.h> |
| 153 | +int main() { |
| 154 | + __m128i a = _mm_setzero_si128(); |
| 155 | + __m128i b = _mm_setzero_si128(); |
| 156 | + __m128i result = _mm_clmulepi64_si128(a, b, 0x00); |
| 157 | + (void)result; |
| 158 | + return 0; |
| 159 | +} |
| 160 | +''' |
| 161 | + |
| 162 | +cfg_data.set( |
| 163 | + 'AWS_HAVE_CLMUL', |
| 164 | + cc.links( |
| 165 | + clmul, |
| 166 | + name: 'clmul', |
| 167 | + ), |
| 168 | +) |
| 169 | + |
| 170 | +arm32_crc = ''' |
| 171 | +#include <arm_acle.h> |
| 172 | +int main() { |
| 173 | + int crc = __crc32d(0, 1); |
| 174 | + return 0; |
| 175 | +} |
| 176 | +''' |
| 177 | + |
| 178 | +cfg_data.set( |
| 179 | + 'AWS_HAVE_ARM32_CRC', |
| 180 | + cc.links( |
| 181 | + arm32_crc, |
| 182 | + name: 'arm32_crc', |
| 183 | + ), |
| 184 | +) |
| 185 | + |
| 186 | +armv8_1 = ''' |
| 187 | +#include <stdatomic.h> |
| 188 | +int main() { |
| 189 | + _Atomic int var = 0; |
| 190 | + atomic_fetch_add_explicit(&var, 1, memory_order_relaxed); |
| 191 | + return 0; |
| 192 | +} |
| 193 | +''' |
| 194 | + |
| 195 | +cfg_data.set( |
| 196 | + 'AWS_HAVE_ARMv8_1', |
| 197 | + cc.links( |
| 198 | + armv8_1, |
| 199 | + name: 'armv8_1', |
| 200 | + ), |
| 201 | +) |
| 202 | + |
| 203 | +cfg_data.set('AWS_ARCH_INTEL', host_machine.cpu_family() in ['x86', 'x86_64']) |
| 204 | +cfg_data.set('AWS_ARCH_INTEL64', host_machine.cpu_family() == 'x86_64') |
| 205 | + |
| 206 | +cfg_data.set('AWS_ARCH_ARM64', host_machine.cpu_family() == 'aarch64') |
| 207 | + |
| 208 | +configure_file( |
| 209 | + input: 'config.h.in', |
| 210 | + output: 'config.h', |
| 211 | + configuration: cfg_data, |
| 212 | + install: true, |
| 213 | + install_dir: get_option('includedir') / 'aws/common', |
| 214 | + format: 'cmake', |
| 215 | +) |
| 216 | +headers = [ |
| 217 | + 'allocator.h', |
| 218 | + 'array_list.h', |
| 219 | + 'array_list.inl', |
| 220 | + 'assert.h', |
| 221 | + 'atomics.h', |
| 222 | + 'atomics.inl', |
| 223 | + 'atomics_fallback.inl', |
| 224 | + 'atomics_gnu.inl', |
| 225 | + 'atomics_gnu_old.inl', |
| 226 | + 'atomics_msvc.inl', |
| 227 | + 'byte_buf.h', |
| 228 | + 'byte_order.h', |
| 229 | + 'byte_order.inl', |
| 230 | + 'cache.h', |
| 231 | + 'cbor.h', |
| 232 | + 'clock.h', |
| 233 | + 'clock.inl', |
| 234 | + 'command_line_parser.h', |
| 235 | + 'common.h', |
| 236 | + 'condition_variable.h', |
| 237 | + 'config.h.in', |
| 238 | + 'cpuid.h', |
| 239 | + 'cross_process_lock.h', |
| 240 | + 'date_time.h', |
| 241 | + 'device_random.h', |
| 242 | + 'encoding.h', |
| 243 | + 'encoding.inl', |
| 244 | + 'environment.h', |
| 245 | + 'error.h', |
| 246 | + 'error.inl', |
| 247 | + 'exports.h', |
| 248 | + 'fifo_cache.h', |
| 249 | + 'file.h', |
| 250 | + 'hash_table.h', |
| 251 | + 'host_utils.h', |
| 252 | + 'json.h', |
| 253 | + 'lifo_cache.h', |
| 254 | + 'linked_hash_table.h', |
| 255 | + 'linked_list.h', |
| 256 | + 'linked_list.inl', |
| 257 | + 'log_channel.h', |
| 258 | + 'log_formatter.h', |
| 259 | + 'log_writer.h', |
| 260 | + 'logging.h', |
| 261 | + 'lru_cache.h', |
| 262 | + 'macros.h', |
| 263 | + 'math.cbmc.inl', |
| 264 | + 'math.fallback.inl', |
| 265 | + 'math.gcc_arm64_asm.inl', |
| 266 | + 'math.gcc_builtin.inl', |
| 267 | + 'math.gcc_overflow.inl', |
| 268 | + 'math.gcc_x64_asm.inl', |
| 269 | + 'math.h', |
| 270 | + 'math.inl', |
| 271 | + 'math.msvc_x64.inl', |
| 272 | + 'mutex.h', |
| 273 | + 'package.h', |
| 274 | + 'platform.h', |
| 275 | + 'posix/common.inl', |
| 276 | + 'predicates.h', |
| 277 | + 'priority_queue.h', |
| 278 | + 'private/array_list.h', |
| 279 | + 'private/byte_buf.h', |
| 280 | + 'private/dlloads.h', |
| 281 | + 'private/external_module_impl.h', |
| 282 | + 'private/hash_table_impl.h', |
| 283 | + 'private/lookup3.inl', |
| 284 | + 'private/system_info_priv.h', |
| 285 | + 'private/thread_shared.h', |
| 286 | + 'private/xml_parser_impl.h', |
| 287 | + 'process.h', |
| 288 | + 'ref_count.h', |
| 289 | + 'ring_buffer.h', |
| 290 | + 'ring_buffer.inl', |
| 291 | + 'rw_lock.h', |
| 292 | + 'shutdown_types.h', |
| 293 | + 'statistics.h', |
| 294 | + 'stdbool.h', |
| 295 | + 'stdint.h', |
| 296 | + 'string.h', |
| 297 | + 'string.inl', |
| 298 | + 'system_info.h', |
| 299 | + 'system_resource_util.h', |
| 300 | + 'task_scheduler.h', |
| 301 | + 'thread.h', |
| 302 | + 'thread_scheduler.h', |
| 303 | + 'time.h', |
| 304 | + 'uri.h', |
| 305 | + 'uuid.h', |
| 306 | + 'xml_parser.h', |
| 307 | + 'zero.h', |
| 308 | + 'zero.inl', |
| 309 | +] |
| 310 | + |
| 311 | +install_headers( |
| 312 | + headers, |
| 313 | + preserve_path: true, |
| 314 | + install_dir: get_option('includedir') / 'aws/common', |
| 315 | +) |
0 commit comments