Line data Source code
1 0 : /* 2 : * Copyright (c) 2019 BayLibre SAS 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : 7 : /* 8 : * Basic macro definitions that gcc and clang provide on their own 9 : * but that xcc lacks. Only those that Zephyr requires are provided here. 10 : */ 11 : 12 : #ifndef ZEPHYR_INCLUDE_TOOLCHAIN_XCC_MISSING_DEFS_H_ 13 : #define ZEPHYR_INCLUDE_TOOLCHAIN_XCC_MISSING_DEFS_H_ 14 : 15 : #if __CHAR_BIT__ == 8 16 : #define __SCHAR_WIDTH__ 8 17 : #else 18 : #error "unexpected __CHAR_BIT__ value" 19 : #endif 20 : 21 : #if __SHRT_MAX__ == 32767 22 : #define __SHRT_WIDTH__ 16 23 : #define __SIZEOF_SHORT__ 2 24 : #else 25 : #error "unexpected __SHRT_WIDTH__ value" 26 : #endif 27 : 28 : #if __INT_MAX__ == 2147483647 29 : #define __INT_WIDTH__ 32 30 : #define __SIZEOF_INT__ 4 31 : #else 32 : #error "unexpected __INT_MAX__ value" 33 : #endif 34 : 35 : #if __LONG_MAX__ == 2147483647L 36 : #define __LONG_WIDTH__ 32 37 : #define __SIZEOF_LONG__ 4 38 : #else 39 : #error "unexpected __LONG_MAX__ value" 40 : #endif 41 : 42 : #if __LONG_LONG_MAX__ == 9223372036854775807LL 43 : #define __LONG_LONG_WIDTH__ 64 44 : #define __SIZEOF_LONG_LONG__ 8 45 : #else 46 : #error "unexpected __LONG_LONG_MAX__ value" 47 : #endif 48 : 49 : #if __INTMAX_MAX__ == 9223372036854775807LL 50 : #define __INTMAX_WIDTH__ 64 51 : #define __SIZEOF_INTMAX__ 8 52 : #define __UINTMAX_MAX__ 0xffffffffffffffffULL 53 : #define __UINTMAX_WIDTH__ 64 54 : #define __SIZEOF_UINTMAX__ 8 55 : #else 56 : #error "unexpected __INTMAX_MAX__ value" 57 : #endif 58 : 59 : /* 60 : * No xcc provided definitions related to pointers, so let's just enforce 61 : * the Zephyr expected type. 62 : */ 63 : 64 : #define __INTPTR_MAX__ 0x7fffffffL 65 : #define __INTPTR_TYPE__ long int 66 : #define __INTPTR_WIDTH__ 32 67 : #define __SIZEOF_POINTER__ 4 68 : 69 : #define __PTRDIFF_MAX__ 0x7fffffffL 70 : #define __PTRDIFF_WIDTH__ 32 71 : #define __SIZEOF_PTRDIFF_T__ 4 72 : 73 : #define __UINTPTR_MAX__ 0xffffffffLU 74 : #define __UINTPTR_TYPE__ long unsigned int 75 : 76 : /* 77 : * xcc already defines __SIZE_TYPE__ as "unsigned int" but there is no way 78 : * to safeguard that here with preprocessor equality. 79 : */ 80 : 81 : #define __SIZE_MAX__ 0xffffffffU 82 : #define __SIZE_WIDTH__ 32 83 : #define __SIZEOF_SIZE_T__ 4 84 : 85 : /* 86 : * The following defines are inferred from the xcc provided defines 87 : * already tested above. 88 : */ 89 : 90 : #define __INT8_MAX__ 0x7f 91 : #define __INT8_TYPE__ signed char 92 : 93 : #define __INT16_MAX__ 0x7fff 94 : #define __INT16_TYPE__ short int 95 : 96 : #define __INT32_MAX__ 0x7fffffff 97 : #define __INT32_TYPE__ int 98 : 99 : #define __INT64_MAX__ 0x7fffffffffffffffLL 100 : #define __INT64_TYPE__ long long int 101 : 102 : #define __INT_FAST8_MAX__ 0x7f 103 : #define __INT_FAST8_TYPE__ signed char 104 : #define __INT_FAST8_WIDTH__ 8 105 : 106 : #define __INT_FAST16_MAX__ 0x7fffffff 107 : #define __INT_FAST16_TYPE__ int 108 : #define __INT_FAST16_WIDTH__ 32 109 : 110 : #define __INT_FAST32_MAX__ 0x7fffffff 111 : #define __INT_FAST32_TYPE__ int 112 : #define __INT_FAST32_WIDTH__ 32 113 : 114 : #define __INT_FAST64_MAX__ 0x7fffffffffffffffLL 115 : #define __INT_FAST64_TYPE__ long long int 116 : #define __INT_FAST64_WIDTH__ 64 117 : 118 : #define __INT_LEAST8_MAX__ 0x7f 119 : #define __INT_LEAST8_TYPE__ signed char 120 : #define __INT_LEAST8_WIDTH__ 8 121 : 122 : #define __INT_LEAST16_MAX__ 0x7fff 123 : #define __INT_LEAST16_TYPE__ short int 124 : #define __INT_LEAST16_WIDTH__ 16 125 : 126 : #define __INT_LEAST32_MAX__ 0x7fffffff 127 : #define __INT_LEAST32_TYPE__ int 128 : #define __INT_LEAST32_WIDTH__ 32 129 : 130 : #define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL 131 : #define __INT_LEAST64_TYPE__ long long int 132 : #define __INT_LEAST64_WIDTH__ 64 133 : 134 : #define __UINT8_MAX__ 0xffU 135 : #define __UINT8_TYPE__ unsigned char 136 : 137 : #define __UINT16_MAX__ 0xffffU 138 : #define __UINT16_TYPE__ short unsigned int 139 : 140 : #define __UINT32_MAX__ 0xffffffffU 141 : #define __UINT32_TYPE__ unsigned int 142 : 143 : #define __UINT64_MAX__ 0xffffffffffffffffULL 144 : #define __UINT64_TYPE__ long long unsigned int 145 : 146 : #define __UINT_FAST8_MAX__ 0xffU 147 : #define __UINT_FAST8_TYPE__ unsigned char 148 : 149 : #define __UINT_FAST16_MAX__ 0xffffffffU 150 : #define __UINT_FAST16_TYPE__ unsigned int 151 : 152 : #define __UINT_FAST32_MAX__ 0xffffffffU 153 : #define __UINT_FAST32_TYPE__ unsigned int 154 : 155 : #define __UINT_FAST64_MAX__ 0xffffffffffffffffULL 156 : #define __UINT_FAST64_TYPE__ long long unsigned int 157 : 158 : #define __UINT_LEAST8_MAX__ 0xffU 159 : #define __UINT_LEAST8_TYPE__ unsigned char 160 : 161 : #define __UINT_LEAST16_MAX__ 0xffffU 162 : #define __UINT_LEAST16_TYPE__ short unsigned int 163 : 164 : #define __UINT_LEAST32_MAX__ 0xffffffffU 165 : #define __UINT_LEAST32_TYPE__ unsigned int 166 : 167 : #define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL 168 : #define __UINT_LEAST64_TYPE__ long long unsigned int 169 : 170 : #endif