Skip to content

Commit bcefbb2

Browse files
committed
Replace global with pointer to struct
1 parent 97122fd commit bcefbb2

File tree

1 file changed

+14
-12
lines changed
  • compiler-rt/lib/builtins/cpu_model

1 file changed

+14
-12
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,10 @@ static void detectX86FamilyModel(unsigned EAX, unsigned *Family,
332332

333333
#define testFeature(F) (Features[F / 32] & (1 << (F % 32))) != 0
334334

335-
static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
336-
unsigned Model,
337-
const unsigned *Features) {
335+
static const char *
336+
getIntelProcessorTypeAndSubtype(unsigned Family, unsigned Model,
337+
const unsigned *Features,
338+
struct __processor_model *CpuModel) {
338339
// We select CPU strings to match the code in Host.cpp, but we don't use them
339340
// in compiler-rt.
340341
const char *CPU = 0;
@@ -678,16 +679,17 @@ static const char *getIntelProcessorTypeAndSubtype(unsigned Family,
678679
}
679680

680681
if (Type != CPU_TYPE_MAX)
681-
__cpu_model.__cpu_type = Type;
682+
CpuModel->__cpu_type = Type;
682683
if (Subtype != CPU_SUBTYPE_MAX)
683-
__cpu_model.__cpu_subtype = Subtype;
684+
CpuModel->__cpu_subtype = Subtype;
684685

685686
return CPU;
686687
}
687688

688-
static const char *getAMDProcessorTypeAndSubtype(unsigned Family,
689-
unsigned Model,
690-
const unsigned *Features) {
689+
static const char *
690+
getAMDProcessorTypeAndSubtype(unsigned Family, unsigned Model,
691+
const unsigned *Features,
692+
struct __processor_model *CpuModel) {
691693
const char *CPU = 0;
692694

693695
enum ProcessorTypes Type = CPU_TYPE_MAX;
@@ -856,9 +858,9 @@ static const char *getAMDProcessorTypeAndSubtype(unsigned Family,
856858
}
857859

858860
if (Type != CPU_TYPE_MAX)
859-
__cpu_model.__cpu_type = Type;
861+
CpuModel->__cpu_type = Type;
860862
if (Subtype != CPU_SUBTYPE_MAX)
861-
__cpu_model.__cpu_subtype = Subtype;
863+
CpuModel->__cpu_subtype = Subtype;
862864

863865
return CPU;
864866
}
@@ -1223,11 +1225,11 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
12231225

12241226
if (Vendor == SIG_INTEL) {
12251227
// Get CPU type.
1226-
getIntelProcessorTypeAndSubtype(Family, Model, &Features[0]);
1228+
getIntelProcessorTypeAndSubtype(Family, Model, &Features[0], &__cpu_model);
12271229
__cpu_model.__cpu_vendor = VENDOR_INTEL;
12281230
} else if (Vendor == SIG_AMD) {
12291231
// Get CPU type.
1230-
getAMDProcessorTypeAndSubtype(Family, Model, &Features[0]);
1232+
getAMDProcessorTypeAndSubtype(Family, Model, &Features[0], &__cpu_model);
12311233
__cpu_model.__cpu_vendor = VENDOR_AMD;
12321234
} else
12331235
__cpu_model.__cpu_vendor = VENDOR_OTHER;

0 commit comments

Comments
 (0)