r600/sfn: Add a mapping table for atomics
[mesa.git] / src / gallium / auxiliary / hud / hud_diskstat.c
index 940758a3480b5d7323cc47731b22c2ac45983f88..b5d9710ef11e4690b6a8b50bd15489018ac56d58 100644 (file)
@@ -26,7 +26,7 @@
  *
  **************************************************************************/
 
-#if HAVE_GALLIUM_EXTRA_HUD
+#ifdef HAVE_GALLIUM_EXTRA_HUD
 
 /* Purpose: Reading /sys/block/<*>/stat MB/s read/write throughput per second,
  * displaying on the HUD.
 
 #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 "util/u_string.h"
 #include <stdio.h>
 #include <unistd.h>
 #include <dirent.h>
@@ -117,7 +118,7 @@ get_file_values(const char *fn, struct stat_s *s)
 }
 
 static void
-query_dsi_load(struct hud_graph *gr)
+query_dsi_load(struct hud_graph *gr, struct pipe_context *pipe)
 {
    /* The framework calls us periodically, compensate for the
     * calling interval accordingly when reporting per second.
@@ -196,8 +197,10 @@ hud_diskstat_graph_install(struct hud_pane *pane, const char *dev_name,
    else if (dsi->mode == DISKSTAT_WR) {
       snprintf(gr->name, sizeof(gr->name), "%s-Write-MB/s", dsi->name);
    }
-   else
+   else {
+      free(gr);
       return;
+   }
 
    gr->query_data = dsi;
    gr->query_new_value = query_dsi_load;
@@ -211,7 +214,7 @@ add_object_part(const char *basename, const char *name, int objmode)
 {
    struct diskstat_info *dsi = CALLOC_STRUCT(diskstat_info);
 
-   strcpy(dsi->name, name);
+   snprintf(dsi->name, sizeof(dsi->name), "%s", name);
    snprintf(dsi->sysfs_filename, sizeof(dsi->sysfs_filename), "%s/%s/stat",
       basename, name);
    dsi->mode = objmode;
@@ -224,7 +227,7 @@ add_object(const char *basename, const char *name, int objmode)
 {
    struct diskstat_info *dsi = CALLOC_STRUCT(diskstat_info);
 
-   strcpy(dsi->name, name);
+   snprintf(dsi->name, sizeof(dsi->name), "%s", name);
    snprintf(dsi->sysfs_filename, sizeof(dsi->sysfs_filename), "%s/stat",
       basename);
    dsi->mode = objmode;
@@ -248,7 +251,7 @@ hud_get_num_disks(bool displayhelp)
    /* Return the number of block devices and partitions. */
    mtx_lock(&gdiskstat_mutex);
    if (gdiskstat_count) {
-      pipe_mutex_unlock(gdiskstat_mutex);
+      mtx_unlock(&gdiskstat_mutex);
       return gdiskstat_count;
    }
 
@@ -258,7 +261,7 @@ hud_get_num_disks(bool displayhelp)
    list_inithead(&gdiskstat_list);
    DIR *dir = opendir("/sys/block/");
    if (!dir) {
-      pipe_mutex_unlock(gdiskstat_mutex);
+      mtx_unlock(&gdiskstat_mutex);
       return 0;
    }
 
@@ -285,7 +288,7 @@ hud_get_num_disks(bool displayhelp)
       struct dirent *dpart;
       DIR *pdir = opendir(basename);
       if (!pdir) {
-         pipe_mutex_unlock(gdiskstat_mutex);
+         mtx_unlock(&gdiskstat_mutex);
          closedir(dir);
          return 0;
       }
@@ -320,7 +323,7 @@ hud_get_num_disks(bool displayhelp)
          puts(line);
       }
    }
-   pipe_mutex_unlock(gdiskstat_mutex);
+   mtx_unlock(&gdiskstat_mutex);
 
    return gdiskstat_count;
 }