|
21 | 21 |
|
22 | 22 | #if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) |
23 | 23 |
|
| 24 | +#if __STDC_HOSTED__ |
24 | 25 | #include <assert.h> |
| 26 | +#endif // __STDC_HOSTED__ |
25 | 27 |
|
26 | 28 | #if (defined(__GNUC__) || defined(__clang__)) && !defined(_MSC_VER) |
27 | 29 | #include <cpuid.h> |
@@ -245,8 +247,8 @@ struct __processor_model { |
245 | 247 | unsigned int __cpu_features[1]; |
246 | 248 | } __cpu_model = {0, 0, 0, {0}}; |
247 | 249 |
|
248 | | -static_assert(sizeof(__cpu_model) == 16, |
249 | | - "Wrong size of __cpu_model will result in ABI break"); |
| 250 | +_Static_assert(sizeof(__cpu_model) == 16, |
| 251 | + "Wrong size of __cpu_model will result in ABI break"); |
250 | 252 |
|
251 | 253 | // This code is copied from lib/Support/Host.cpp. |
252 | 254 | // Changes to either file should be mirrored in the other. |
@@ -1200,8 +1202,8 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) { |
1200 | 1202 | unsigned Vendor; |
1201 | 1203 | unsigned Model, Family; |
1202 | 1204 | unsigned Features[(CPU_FEATURE_MAX + 31) / 32] = {0}; |
1203 | | - static_assert(sizeof(Features) / sizeof(Features[0]) == 4, ""); |
1204 | | - static_assert(sizeof(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, ""); |
| 1205 | + _Static_assert(sizeof(Features) / sizeof(Features[0]) == 4, ""); |
| 1206 | + _Static_assert(sizeof(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, ""); |
1205 | 1207 |
|
1206 | 1208 | // This function needs to run just once. |
1207 | 1209 | if (__cpu_model.__cpu_vendor) |
@@ -1234,9 +1236,11 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) { |
1234 | 1236 | } else |
1235 | 1237 | __cpu_model.__cpu_vendor = VENDOR_OTHER; |
1236 | 1238 |
|
| 1239 | +#if __STDC_HOSTED__ |
1237 | 1240 | assert(__cpu_model.__cpu_vendor < VENDOR_MAX); |
1238 | 1241 | assert(__cpu_model.__cpu_type < CPU_TYPE_MAX); |
1239 | 1242 | assert(__cpu_model.__cpu_subtype < CPU_SUBTYPE_MAX); |
| 1243 | +#endif // __STDC_HOSTED__ |
1240 | 1244 |
|
1241 | 1245 | return 0; |
1242 | 1246 | } |
|
0 commit comments