Browse Source

get MSA capability from feature flags

tags/v0.3.19
Martin Kroeker GitHub 3 years ago
parent
commit
d6194d6a0c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 72 additions and 0 deletions
  1. +36
    -0
      cpuid_mips.c
  2. +36
    -0
      cpuid_mips64.c

+ 36
- 0
cpuid_mips.c View File

@@ -165,6 +165,7 @@ void get_cpuconfig(void){
}else{ }else{
printf("#define UNKNOWN\n"); printf("#define UNKNOWN\n");
} }
if (!get_feature(msa)) printf("#define NO_MSA\n");
} }


void get_libname(void){ void get_libname(void){
@@ -178,3 +179,38 @@ void get_libname(void){
printf("mips\n"); printf("mips\n");
} }
} }

int get_feature(char *search)
{

#ifdef __linux
FILE *infile;
char buffer[2048], *p,*t;
p = (char *) NULL ;

infile = fopen("/proc/cpuinfo", "r");

while (fgets(buffer, sizeof(buffer), infile))
{

if (!strncmp("Features", buffer, 8))
{
p = strchr(buffer, ':') + 2;
break;
}
}

fclose(infile);

if( p == NULL ) return 0;

t = strtok(p," ");
while( t = strtok(NULL," "))
{
if (!strcmp(t, search)) { return(1); }
}

#endif
return(0);
}


+ 36
- 0
cpuid_mips64.c View File

@@ -201,6 +201,7 @@ void get_cpuconfig(void){
printf("#define DTB_SIZE 4096\n"); printf("#define DTB_SIZE 4096\n");
printf("#define L2_ASSOCIATIVE 8\n"); printf("#define L2_ASSOCIATIVE 8\n");
} }
if (!get_feature(msa)) printf("#define NO_MSA\n");
} }


void get_libname(void){ void get_libname(void){
@@ -218,3 +219,38 @@ void get_libname(void){
printf("mips64\n"); printf("mips64\n");
} }
} }

int get_feature(char *search)
{

#ifdef __linux
FILE *infile;
char buffer[2048], *p,*t;
p = (char *) NULL ;

infile = fopen("/proc/cpuinfo", "r");

while (fgets(buffer, sizeof(buffer), infile))
{

if (!strncmp("Features", buffer, 8))
{
p = strchr(buffer, ':') + 2;
break;
}
}

fclose(infile);

if( p == NULL ) return 0;

t = strtok(p," ");
while( t = strtok(NULL," "))
{
if (!strcmp(t, search)) { return(1); }
}

#endif
return(0);
}


Loading…
Cancel
Save