OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
get_ibuiltin_arch.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Macros

#define _FCALL

Functions

int parse_cpuinfo ()
void get_ibuiltin_arch (int *iarch)
void get_ibuiltin_arch_ (int *iarch)
void _FCALL GET_IBUILTIN_ARCH (int *iarch)

Macro Definition Documentation

◆ _FCALL

#define _FCALL

Definition at line 27 of file get_ibuiltin_arch.c.

Function Documentation

◆ GET_IBUILTIN_ARCH()

void _FCALL GET_IBUILTIN_ARCH ( int * iarch)

Definition at line 116 of file get_ibuiltin_arch.c.

116 {
117 get_ibuiltin_arch(iarch);
118}
void get_ibuiltin_arch(int *iarch)

◆ get_ibuiltin_arch()

void get_ibuiltin_arch ( int * iarch)

Definition at line 89 of file get_ibuiltin_arch.c.

90{
91 int os_type,arch_type;
92
93 os_type=OS_TYPE;
94 arch_type=ARCH_TYPE;
95
96 *iarch=0;
97 switch (arch_type){
98 case 1 : { if (os_type==1){
99 *iarch= parse_cpuinfo();
100 }else {
101 *iarch= 4;
102 }
103 }
104 break;
105
106 case 2 : *iarch=3;break;
107 }
108
109
110}
int parse_cpuinfo()

◆ get_ibuiltin_arch_()

void get_ibuiltin_arch_ ( int * iarch)

Definition at line 112 of file get_ibuiltin_arch.c.

112 {
113 get_ibuiltin_arch(iarch);
114}

◆ parse_cpuinfo()

int parse_cpuinfo ( )

Definition at line 120 of file get_ibuiltin_arch.c.

120 {
121
122 FILE * stream = NULL;
123 char ligne[2049];
124 char * compstr="flags :";
125 char * strptr;
126 int unknown;
127 int cmplen=strlen(compstr);
128
129 int instruction_set=0;
130
131 stream=fopen("/proc/cpuinfo","r");
132 unknown = 1;
133 while (fgets(ligne,2048,stream) && unknown){
134 if (strncmp(compstr,ligne,cmplen)==0){
135 unknown = 0;
136 break;
137 }
138 }
139 strptr = strstr(ligne,"avx512");
140
141 if (strptr !=NULL){
142 instruction_set=1;
143 }else{
144 strptr = strstr(ligne,"avx2");
145 if (strptr !=NULL){
146 instruction_set=0;
147 }else{
148 instruction_set=2;
149 }
150 }
151
152
153return instruction_set;
154}