lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon,  7 Dec 2015 22:21:44 -0600
From:	Josh Poimboeuf <jpoimboe@...hat.com>
To:	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...hat.com>,
	Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:	linux-kernel@...r.kernel.org, Jiri Olsa <jolsa@...hat.com>,
	Namhyung Kim <namhyung@...nel.org>
Subject: [PATCH v2 06/14] perf: Split up cache.h

cache.h is a hodgepodge which consists of:

1) some macros
2) some includes
3) declarations for other .c files

Move the macros and declarations to more appropriate places.  This makes
the code more organized and makes it easier to separate out the
components later.  Some of the components will be moved out of perf into
a separate library.

Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
---
 tools/perf/perf.h         | 12 ++++++++
 tools/perf/util/abspath.h | 11 ++++++++
 tools/perf/util/alias.h   |  7 +++++
 tools/perf/util/cache.h   | 72 ++++-------------------------------------------
 tools/perf/util/config.h  |  9 ++++++
 tools/perf/util/pager.h   |  7 +++++
 tools/perf/util/path.h    | 17 +++++++++++
 tools/perf/util/wrapper.h | 20 +++++++++++++
 8 files changed, 88 insertions(+), 67 deletions(-)
 create mode 100644 tools/perf/util/abspath.h
 create mode 100644 tools/perf/util/alias.h
 create mode 100644 tools/perf/util/pager.h
 create mode 100644 tools/perf/util/path.h

diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 90129ac..501acb4 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -6,6 +6,18 @@
 #include <linux/types.h>
 #include <linux/perf_event.h>
 
+#define CMD_EXEC_PATH "--exec-path"
+#define CMD_PERF_DIR "--perf-dir="
+#define CMD_WORK_TREE "--work-tree="
+#define CMD_DEBUGFS_DIR "--debugfs-dir="
+
+#define PERF_DIR_ENVIRONMENT "PERF_DIR"
+#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"
+#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
+#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
+#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
+#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
+
 extern bool test_attr__enabled;
 void test_attr__init(void);
 void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu,
diff --git a/tools/perf/util/abspath.h b/tools/perf/util/abspath.h
new file mode 100644
index 0000000..13549fb
--- /dev/null
+++ b/tools/perf/util/abspath.h
@@ -0,0 +1,11 @@
+#ifndef __PERF_ABSPATH_H
+#define __PERF_ABSPATH_H
+
+static inline int is_absolute_path(const char *path)
+{
+	return path[0] == '/';
+}
+
+const char *make_nonrelative_path(const char *path);
+
+#endif /* __PERF_ABSPATH_H */
diff --git a/tools/perf/util/alias.h b/tools/perf/util/alias.h
new file mode 100644
index 0000000..23d4f84
--- /dev/null
+++ b/tools/perf/util/alias.h
@@ -0,0 +1,7 @@
+#ifndef __PERF_ALIAS_H
+#define __PERF_ALIAS_H
+
+char *alias_lookup(const char *alias);
+int split_cmdline(char *cmdline, const char ***argv);
+
+#endif /* __PERF_ALIAS_H */
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 4c2b764..32e1f52 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -7,72 +7,10 @@
 #include "../perf.h"
 #include "../ui/ui.h"
 
-#define CMD_EXEC_PATH "--exec-path"
-#define CMD_PERF_DIR "--perf-dir="
-#define CMD_WORK_TREE "--work-tree="
-#define CMD_DEBUGFS_DIR "--debugfs-dir="
-
-#define PERF_DIR_ENVIRONMENT "PERF_DIR"
-#define PERF_WORK_TREE_ENVIRONMENT "PERF_WORK_TREE"
-#define EXEC_PATH_ENVIRONMENT "PERF_EXEC_PATH"
-#define DEFAULT_PERF_DIR_ENVIRONMENT ".perf"
-#define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR"
-#define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR"
-
-typedef int (*config_fn_t)(const char *, const char *, void *);
-extern int perf_default_config(const char *, const char *, void *);
-extern int perf_config(config_fn_t fn, void *);
-extern int perf_config_int(const char *, const char *);
-extern u64 perf_config_u64(const char *, const char *);
-extern int perf_config_bool(const char *, const char *);
-extern int config_error_nonbool(const char *);
-extern const char *perf_config_dirname(const char *, const char *);
-
-/* pager.c */
-extern void setup_pager(void);
-extern int pager_in_use(void);
-
-char *alias_lookup(const char *alias);
-int split_cmdline(char *cmdline, const char ***argv);
-
-#define alloc_nr(x) (((x)+16)*3/2)
-
-/*
- * Realloc the buffer pointed at by variable 'x' so that it can hold
- * at least 'nr' entries; the number of entries currently allocated
- * is 'alloc', using the standard growing factor alloc_nr() macro.
- *
- * DO NOT USE any expression with side-effect for 'x' or 'alloc'.
- */
-#define ALLOC_GROW(x, nr, alloc) \
-	do { \
-		if ((nr) > alloc) { \
-			if (alloc_nr(alloc) < (nr)) \
-				alloc = (nr); \
-			else \
-				alloc = alloc_nr(alloc); \
-			x = xrealloc((x), alloc * sizeof(*(x))); \
-		} \
-	} while(0)
-
-
-static inline int is_absolute_path(const char *path)
-{
-	return path[0] == '/';
-}
-
-const char *make_nonrelative_path(const char *path);
-char *strip_path_suffix(const char *path, const char *suffix);
-
-extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
-extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
-
-extern char *perf_pathdup(const char *fmt, ...)
-	__attribute__((format (printf, 1, 2)));
-
-#ifndef __UCLIBC__
-/* Matches the libc/libbsd function attribute so we declare this unconditionally: */
-extern size_t strlcpy(char *dest, const char *src, size_t size);
-#endif
+#include "abspath.h"
+#include "alias.h"
+#include "config.h"
+#include "pager.h"
+#include "path.h"
 
 #endif /* __PERF_CACHE_H */
diff --git a/tools/perf/util/config.h b/tools/perf/util/config.h
index d48c647..8e53f6f 100644
--- a/tools/perf/util/config.h
+++ b/tools/perf/util/config.h
@@ -6,4 +6,13 @@
 extern char buildid_dir[];
 extern void set_buildid_dir(const char *dir);
 
+typedef int (*config_fn_t)(const char *, const char *, void *);
+extern int perf_default_config(const char *, const char *, void *);
+extern int perf_config(config_fn_t fn, void *);
+extern int perf_config_int(const char *, const char *);
+extern u64 perf_config_u64(const char *, const char *);
+extern int perf_config_bool(const char *, const char *);
+extern int config_error_nonbool(const char *);
+extern const char *perf_config_dirname(const char *, const char *);
+
 #endif /* __PERF_CONFIG_H */
diff --git a/tools/perf/util/pager.h b/tools/perf/util/pager.h
new file mode 100644
index 0000000..2794a83
--- /dev/null
+++ b/tools/perf/util/pager.h
@@ -0,0 +1,7 @@
+#ifndef __PERF_PAGER_H
+#define __PERF_PAGER_H
+
+extern void setup_pager(void);
+extern int pager_in_use(void);
+
+#endif /* __PERF_PAGER_H */
diff --git a/tools/perf/util/path.h b/tools/perf/util/path.h
new file mode 100644
index 0000000..3604e82f
--- /dev/null
+++ b/tools/perf/util/path.h
@@ -0,0 +1,17 @@
+#ifndef __PERF_PATH_H
+#define __PERF_PATH_H
+
+char *strip_path_suffix(const char *path, const char *suffix);
+
+extern char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
+extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
+
+extern char *perf_pathdup(const char *fmt, ...)
+	__attribute__((format (printf, 1, 2)));
+
+#ifndef __UCLIBC__
+/* Matches the libc/libbsd function attribute so we declare this unconditionally: */
+extern size_t strlcpy(char *dest, const char *src, size_t size);
+#endif
+
+#endif /* __PERF_PATH_H */
diff --git a/tools/perf/util/wrapper.h b/tools/perf/util/wrapper.h
index 510781b..e2fa014 100644
--- a/tools/perf/util/wrapper.h
+++ b/tools/perf/util/wrapper.h
@@ -11,4 +11,24 @@ static inline void *zalloc(size_t size)
 
 #define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
 
+#define alloc_nr(x) (((x)+16)*3/2)
+
+/*
+ * Realloc the buffer pointed at by variable 'x' so that it can hold
+ * at least 'nr' entries; the number of entries currently allocated
+ * is 'alloc', using the standard growing factor alloc_nr() macro.
+ *
+ * DO NOT USE any expression with side-effect for 'x' or 'alloc'.
+ */
+#define ALLOC_GROW(x, nr, alloc) \
+	do { \
+		if ((nr) > alloc) { \
+			if (alloc_nr(alloc) < (nr)) \
+				alloc = (nr); \
+			else \
+				alloc = alloc_nr(alloc); \
+			x = xrealloc((x), alloc * sizeof(*(x))); \
+		} \
+	} while(0)
+
 #endif /* __PERF_WRAPPER_H */
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ