Skip to content

Commit 53bfa51

Browse files
committedJun 12, 2014
Ref #385: fixed warnings in dynamic.c
1 parent ff9cfca commit 53bfa51

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed
 

‎driver/others/dynamic.c

+16-10
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,24 @@ extern void openblas_warning(int verbose, const char * msg);
116116

117117
static int get_vendor(void){
118118
int eax, ebx, ecx, edx;
119-
char vendor[13];
119+
120+
union
121+
{
122+
char vchar[16];
123+
int vint[4];
124+
} vendor;
120125

121126
cpuid(0, &eax, &ebx, &ecx, &edx);
122-
123-
*(int *)(&vendor[0]) = ebx;
124-
*(int *)(&vendor[4]) = edx;
125-
*(int *)(&vendor[8]) = ecx;
126-
vendor[12] = (char)0;
127127

128-
if (!strcmp(vendor, "GenuineIntel")) return VENDOR_INTEL;
129-
if (!strcmp(vendor, "AuthenticAMD")) return VENDOR_AMD;
130-
if (!strcmp(vendor, "CentaurHauls")) return VENDOR_CENTAUR;
128+
*(&vendor.vint[0]) = ebx;
129+
*(&vendor.vint[1]) = edx;
130+
*(&vendor.vint[2]) = ecx;
131+
132+
vendor.vchar[12] = '\0';
133+
134+
if (!strcmp(vendor.vchar, "GenuineIntel")) return VENDOR_INTEL;
135+
if (!strcmp(vendor.vchar, "AuthenticAMD")) return VENDOR_AMD;
136+
if (!strcmp(vendor.vchar, "CentaurHauls")) return VENDOR_CENTAUR;
131137

132138
if ((eax == 0) || ((eax & 0x500) != 0)) return VENDOR_INTEL;
133139

@@ -232,7 +238,7 @@ static gotoblas_t *get_coretype(void){
232238
if (family <= 0xe) {
233239
// Verify that CPU has 3dnow and 3dnowext before claiming it is Athlon
234240
cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
235-
if (eax & 0xffff >= 0x01) {
241+
if ( (eax & 0xffff) >= 0x01) {
236242
cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
237243
if ((edx & (1 << 30)) == 0 || (edx & (1 << 31)) == 0)
238244
return NULL;

0 commit comments

Comments
 (0)
Please sign in to comment.