Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions compiler-rt/lib/builtins/cpu_model/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)

#if __STDC_HOSTED__
#include <assert.h>
#endif // __STDC_HOSTED__

#if (defined(__GNUC__) || defined(__clang__)) && !defined(_MSC_VER)
#include <cpuid.h>
Expand Down Expand Up @@ -245,8 +247,8 @@ struct __processor_model {
unsigned int __cpu_features[1];
} __cpu_model = {0, 0, 0, {0}};

static_assert(sizeof(__cpu_model) == 16,
"Wrong size of __cpu_model will result in ABI break");
_Static_assert(sizeof(__cpu_model) == 16,
"Wrong size of __cpu_model will result in ABI break");

// This code is copied from lib/Support/Host.cpp.
// Changes to either file should be mirrored in the other.
Expand Down Expand Up @@ -1200,8 +1202,8 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
unsigned Vendor;
unsigned Model, Family;
unsigned Features[(CPU_FEATURE_MAX + 31) / 32] = {0};
static_assert(sizeof(Features) / sizeof(Features[0]) == 4, "");
static_assert(sizeof(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, "");
_Static_assert(sizeof(Features) / sizeof(Features[0]) == 4, "");
_Static_assert(sizeof(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, "");

// This function needs to run just once.
if (__cpu_model.__cpu_vendor)
Expand Down Expand Up @@ -1234,9 +1236,11 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
} else
__cpu_model.__cpu_vendor = VENDOR_OTHER;

#if __STDC_HOSTED__
assert(__cpu_model.__cpu_vendor < VENDOR_MAX);
assert(__cpu_model.__cpu_type < CPU_TYPE_MAX);
assert(__cpu_model.__cpu_subtype < CPU_SUBTYPE_MAX);
#endif // __STDC_HOSTED__

return 0;
}
Expand Down
Loading