@@ -73,6 +73,15 @@ const char *odp_cpu_model_str_id(int id);
uint64_t odp_cpu_hz(void);
/**
+ * Maximum CPU frequency in Hz
+ *
+ * Returns maximum frequency of this CPU
+ *
+ * @return CPU frequency in Hz
+ */
+uint64_t odp_cpu_hz_max(void);
+
+/**
* @}
*/
@@ -121,35 +121,27 @@ static int cpuinfo_x86(FILE *file, odp_system_info_t *sysinfo)
{
char str[1024];
char *pos;
- double mhz = 0.0;
+ double ghz = 0.0;
int model = 0;
- int count = 2;
+ int count = 1;
while (fgets(str, sizeof(str), file) != NULL && count > 0) {
- if (!mhz) {
- pos = strstr(str, "cpu MHz");
- if (pos) {
- sscanf(pos, "cpu MHz : %lf", &mhz);
- count--;
- }
- }
-
if (!model) {
pos = strstr(str, "model name");
if (pos) {
- int len;
pos = strchr(str, ':');
strncpy(sysinfo->model_str[0], pos + 2,
sizeof(sysinfo->model_str[0]));
- len = strlen(sysinfo->model_str[0]);
- sysinfo->model_str[0][len - 1] = 0;
+ pos = strchr(sysinfo->model_str[0], '@');
+ *(pos - 1) = '\0';
+ sscanf(pos, "@ %lfGHz", &ghz);
model = 1;
count--;
}
}
}
- sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0);
+ sysinfo->cpu_hz[0] = (uint64_t)(ghz * 1000000000.0);
return 0;
}
@@ -379,6 +371,11 @@ uint64_t odp_cpu_hz(void)
return odp_global_data.system_info.cpu_hz[0];
}
+uint64_t odp_cpu_hz_max(void)
+{
+ return odp_global_data.system_info.cpu_hz[0];
+}
+
uint64_t odp_sys_huge_page_size(void)
{
return odp_global_data.system_info.huge_page_size;