1 /* 2 * Copyright (c) 2014-2017, Siemens AG. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, 8 * this list of conditions and the following disclaimer. 9 * 10 * 2. Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 * POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef EMBB_BASE_C_INTERNAL_CONFIG_H_ 28 #define EMBB_BASE_C_INTERNAL_CONFIG_H_ 29 30 #include <embb/base/c/internal/cmake_config.h> 31 32 /* Define names: 33 * - threading platforms: EMBB_THREADING_ 34 * - compilers: EMBB_COMPILER_ 35 * - operating systems: EMBB_OS_ 36 */ 37 38 #ifdef DOXYGEN 39 /* For Doxygen, simulate GNU compiler on 64 bit */ 40 #define __GNUC__ 41 #define __x86_64__ 42 #endif 43 44 /* Most processors have cache lines with up to 64 Bytes, except for Itanium 45 * which has 128 bytes. 46 */ 47 #if defined(_M_IA64) || defined(_IA64) 48 #define EMBB_PLATFORM_CACHE_LINE_SIZE 128 49 #else 50 #define EMBB_PLATFORM_CACHE_LINE_SIZE 64 51 #endif 52 53 /* For MSVC, if _DEBUG is set, set also EMBB_DEBUG. 54 * There is no such flag for GCC. Instead, cmake sets 55 * the EMBB_DEBUG flag... 56 */ 57 #ifdef _DEBUG 58 #define EMBB_DEBUG 59 #endif 60 61 #ifdef __GNUC__ 62 #define EMBB_PLATFORM_ALIGN(size) __attribute__ ((aligned(size))) 63 #elif defined _MSC_VER || defined __INTEL_COMPILER 64 #define EMBB_PLATFORM_ALIGN(size) __declspec(align(size)) 65 #else 66 #error "Unsupported compiler" 67 #endif 68 69 #if __GNUC__ 70 #define EMBB_PLATFORM_INLINE static inline 71 #define EMBB_PLATFORM_COMPILER_GNUC 72 #elif _MSC_VER 73 #define EMBB_PLATFORM_INLINE __inline 74 #define EMBB_PLATFORM_COMPILER_MSVC 75 #else 76 #define EMBB_PLATFORM_INLINE inline 77 #define EMBB_PLATFORM_COMPILER_UNKNOWN 78 #endif 79 80 #if (__cplusplus >= 201103) && defined(EMBB_PLATFORM_USE_C11_CXX11) 81 #define EMBB_PLATFORM_ARCH_CXX11 82 #elif (__STDC_VERSION__ >= 201112) && defined(EMBB_PLATFORM_USE_C11_CXX11) 83 #define EMBB_PLATFORM_ARCH_C11 84 #elif defined(__x86_64__) || defined(_M_X64) 85 #define EMBB_PLATFORM_ARCH_X86_64 86 #define EMBB_PLATFORM_ARCH_X86 87 #define EMBB_PLATFORM_HAS_CAS_64 88 #elif defined(__i386) || defined(_M_IX86) 89 #define EMBB_PLATFORM_ARCH_X86_32 90 #define EMBB_PLATFORM_ARCH_X86 91 #elif defined(__arm__) 92 #define EMBB_PLATFORM_ARCH_ARM 93 #else 94 #define EMBB_PLATFORM_ARCH_UNKNOWN 95 #endif 96 97 #if defined(EMBB_PLATFORM_COMPILER_MSVC) 98 #define EMBB_PLATFORM_THREADING_WINTHREADS 99 #elif defined(EMBB_PLATFORM_COMPILER_GNUC) 100 #define EMBB_PLATFORM_THREADING_POSIXTHREADS 101 #else 102 #error "No thread implementation could be determined" 103 #endif 104 105 #endif /* EMBB_BASE_C_INTERNAL_CONFIG_H_ */ 106