Skip to content

Commit 12cad6c

Browse files
committed
Fix wrong assignment in compiler_rt
1 parent 4f4bee4 commit 12cad6c

File tree

1 file changed

+11
-10
lines changed
  • compiler-rt/lib/builtins/cpu_model

1 file changed

+11
-10
lines changed

compiler-rt/lib/builtins/cpu_model/x86.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ enum VendorSignatures {
3636
SIG_AMD = 0x68747541, // Auth
3737
};
3838

39-
enum ProcessorVendors {
39+
enum ProcessorVendors : unsigned int {
4040
VENDOR_INTEL = 1,
4141
VENDOR_AMD,
4242
VENDOR_OTHER,
4343
VENDOR_MAX
4444
};
4545

46-
enum ProcessorTypes {
46+
enum ProcessorTypes : unsigned int {
4747
INTEL_BONNELL = 1,
4848
INTEL_CORE2,
4949
INTEL_COREI7,
@@ -322,8 +322,8 @@ static void detectX86FamilyModel(unsigned EAX, unsigned *Family,
322322
static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
323323
unsigned Model,
324324
const unsigned *Features,
325-
unsigned *Type,
326-
unsigned *Subtype) {
325+
enum ProcessorTypes *Type,
326+
enum ProcessorSubtypes *Subtype) {
327327
// We select CPU strings to match the code in Host.cpp, but we don't use them
328328
// in compiler-rt.
329329
const char *CPU = 0;
@@ -616,8 +616,7 @@ static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
616616
// Clearwaterforest:
617617
case 0xdd:
618618
CPU = "clearwaterforest";
619-
*Type = INTEL_COREI7;
620-
*Subtype = INTEL_CLEARWATERFOREST;
619+
*Type = INTEL_CLEARWATERFOREST;
621620
break;
622621

623622
case 0x57:
@@ -670,8 +669,8 @@ static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
670669
static const char *getAMDProcessorTypeAndSubtype(unsigned Family,
671670
unsigned Model,
672671
const unsigned *Features,
673-
unsigned *Type,
674-
unsigned *Subtype) {
672+
enum ProcessorTypes *Type,
673+
enum ProcessorSubtypes *Subtype) {
675674
const char *CPU = 0;
676675

677676
switch (Family) {
@@ -1162,11 +1161,13 @@ __attribute__((visibility("hidden")))
11621161
#endif
11631162
struct __processor_model {
11641163
unsigned int __cpu_vendor;
1165-
unsigned int __cpu_type;
1166-
unsigned int __cpu_subtype;
1164+
enum ProcessorTypes __cpu_type;
1165+
enum ProcessorSubtypes __cpu_subtype;
11671166
unsigned int __cpu_features[1];
11681167
} __cpu_model = {0, 0, 0, {0}};
11691168

1169+
static_assert(sizeof(__cpu_model) == 16, "Wrong size of __cpu_model will result in ABI break");
1170+
11701171
#ifndef _WIN32
11711172
__attribute__((visibility("hidden")))
11721173
#endif

0 commit comments

Comments
 (0)