]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/perf/util/util.c
Merge branches 'pm-core', 'pm-qos', 'pm-domains' and 'pm-opp'
[linux.git] / tools / perf / util / util.c
index 9ddd98827d12dffa0b4482deb72be3749dc33145..d8b45cea54d08233c3d743cc38c6c0ef7af90328 100644 (file)
@@ -85,7 +85,7 @@ int mkdir_p(char *path, mode_t mode)
        return (stat(path, &st) && mkdir(path, mode)) ? -1 : 0;
 }
 
-int rm_rf(char *path)
+int rm_rf(const char *path)
 {
        DIR *dir;
        int ret = 0;
@@ -789,3 +789,16 @@ int is_printable_array(char *p, unsigned int len)
        }
        return 1;
 }
+
+int unit_number__scnprintf(char *buf, size_t size, u64 n)
+{
+       char unit[4] = "BKMG";
+       int i = 0;
+
+       while (((n / 1024) > 1) && (i < 3)) {
+               n /= 1024;
+               i++;
+       }
+
+       return scnprintf(buf, size, "%" PRIu64 "%c", n, unit[i]);
+}