radeonsi: always use Wave64 for HS/GS/VS shader stages (except GS fast launch)
[mesa.git] / src / gallium / auxiliary / hud / hud_cpufreq.c
index 19a6f08c4fc06a2f9f0ec5c30342d86e9c1dfb92..9c7b90f7351accceb2ce70f1ae988f0f902ad442 100644 (file)
@@ -26,7 +26,7 @@
  *
  **************************************************************************/
 
-#if HAVE_GALLIUM_EXTRA_HUD
+#ifdef HAVE_GALLIUM_EXTRA_HUD
 
 /* Purpose:
  * Reading /sys/devices/system/cpu/cpu?/cpufreq/scaling_???_freq
@@ -35,7 +35,7 @@
 
 #include "hud/hud_private.h"
 #include "util/list.h"
-#include "os/os_time.h"
+#include "util/os_time.h"
 #include "os/os_thread.h"
 #include "util/u_memory.h"
 #include <stdio.h>
@@ -62,7 +62,7 @@ struct cpufreq_info
 
 static int gcpufreq_count = 0;
 static struct list_head gcpufreq_list;
-pipe_static_mutex(gcpufreq_mutex);
+static mtx_t gcpufreq_mutex = _MTX_INITIALIZER_NP;
 
 static struct cpufreq_info *
 find_cfi_by_index(int cpu_index, int mode)
@@ -91,7 +91,7 @@ get_file_value(const char *fn, uint64_t *KHz)
 }
 
 static void
-query_cfi_load(struct hud_graph *gr)
+query_cfi_load(struct hud_graph *gr, struct pipe_context *pipe)
 {
    struct cpufreq_info *cfi = gr->query_data;
 
@@ -149,7 +149,9 @@ hud_cpufreq_graph_install(struct hud_pane *pane, int cpu_index,
       break;
    case CPUFREQ_MAXIMUM:
       snprintf(gr->name, sizeof(gr->name), "%s-Max", cfi->name);
+      break;
    default:
+      free(gr);
       return;
    }
 
@@ -188,9 +190,9 @@ hud_get_num_cpufreq(bool displayhelp)
    int cpu_index;
 
    /* Return the number of CPU metrics we support. */
-   pipe_mutex_lock(gcpufreq_mutex);
+   mtx_lock(&gcpufreq_mutex);
    if (gcpufreq_count) {
-      pipe_mutex_unlock(gcpufreq_mutex);
+      mtx_unlock(&gcpufreq_mutex);
       return gcpufreq_count;
    }
 
@@ -200,14 +202,18 @@ hud_get_num_cpufreq(bool displayhelp)
    list_inithead(&gcpufreq_list);
    DIR *dir = opendir("/sys/devices/system/cpu");
    if (!dir) {
-      pipe_mutex_unlock(gcpufreq_mutex);
+      mtx_unlock(&gcpufreq_mutex);
       return 0;
    }
 
    while ((dp = readdir(dir)) != NULL) {
 
-      /* Avoid 'lo' and '..' and '.' */
-      if (strlen(dp->d_name) <= 2)
+      size_t d_name_len = strlen(dp->d_name);
+
+      /* Avoid 'lo' and '..' and '.', and avoid overlong names that
+       * would  result in a buffer overflow in add_object.
+       */
+      if (d_name_len <= 2 || d_name_len > 15)
          continue;
 
       if (sscanf(dp->d_name, "cpu%d\n", &cpu_index) != 1)
@@ -246,7 +252,7 @@ hud_get_num_cpufreq(bool displayhelp)
       }
    }
 
-   pipe_mutex_unlock(gcpufreq_mutex);
+   mtx_unlock(&gcpufreq_mutex);
    return gcpufreq_count;
 }