tools lib: Adopt zalloc()/zfree() from tools/perf
tip-bot for Arnaldo Carvalho de Melo
merge botCommit-ID: 7f7c536f23e6afaa5d5d4b0e0958b0be8922491f Gitweb: https://git.kernel.org/tip/7f7c536f23e6afaa5d5d4b0e0958b0be8922491f Author: Arnaldo Carvalho de Melo <[email protected]> AuthorDate: Thu, 4 Jul 2019 11:32:27 -0300 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 9 Jul 2019 10:13:26 -0300
tools lib: Adopt zalloc()/zfree() from tools/perf
Eroding a bit more the tools/perf/util/util.h hodpodge header.
Cc Adrian Hunter <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
--- tools/include/linux/zalloc.h | 12 ++++++++++++ tools/lib/zalloc.c | 15 +++++++++++++++ tools/perf/MANIFEST | 1 + tools/perf/arch/arm/annotate/instructions.c | 1 + tools/perf/arch/arm/util/auxtrace.c | 1 + tools/perf/arch/arm/util/cs-etm.c | 1 + tools/perf/arch/arm64/util/arm-spe.c | 1 + tools/perf/arch/common.c | 2 +- tools/perf/arch/powerpc/util/perf_regs.c | 2 +- tools/perf/arch/s390/util/auxtrace.c | 1 + tools/perf/arch/s390/util/header.c | 2 +- tools/perf/arch/x86/util/event.c | 2 +- tools/perf/arch/x86/util/intel-bts.c | 2 +- tools/perf/arch/x86/util/intel-pt.c | 2 +- tools/perf/arch/x86/util/perf_regs.c | 2 +- tools/perf/bench/mem-functions.c | 2 +- tools/perf/bench/numa.c | 2 +- tools/perf/builtin-annotate.c | 2 +- tools/perf/builtin-bench.c | 2 +- tools/perf/builtin-c2c.c | 2 +- tools/perf/builtin-diff.c | 2 +- tools/perf/builtin-help.c | 1 + tools/perf/builtin-kmem.c | 2 +- tools/perf/builtin-kvm.c | 2 +- tools/perf/builtin-lock.c | 2 +- tools/perf/builtin-probe.c | 2 +- tools/perf/builtin-report.c | 2 +- tools/perf/builtin-sched.c | 2 +- tools/perf/builtin-script.c | 2 +- tools/perf/builtin-stat.c | 2 +- tools/perf/builtin-timechart.c | 4 +--- tools/perf/builtin-trace.c | 1 + tools/perf/perf.c | 2 +- tools/perf/tests/switch-tracking.c | 1 + tools/perf/ui/browser.c | 2 +- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/ui/browsers/hists.c | 2 +- tools/perf/ui/gtk/util.c | 3 +-- tools/perf/ui/stdio/hist.c | 2 +- tools/perf/util/Build | 5 +++++ tools/perf/util/arm-spe.c | 2 +- tools/perf/util/auxtrace.c | 2 +- tools/perf/util/bpf-loader.c | 1 + tools/perf/util/build-id.c | 1 + tools/perf/util/call-path.c | 3 ++- tools/perf/util/callchain.c | 2 +- tools/perf/util/cgroup.c | 2 +- tools/perf/util/comm.c | 2 +- tools/perf/util/config.c | 3 +-- tools/perf/util/counts.c | 2 +- tools/perf/util/cpumap.c | 2 +- tools/perf/util/cputopo.c | 2 +- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 1 + tools/perf/util/cs-etm.c | 1 + tools/perf/util/data-convert-bt.c | 2 +- tools/perf/util/data.c | 1 + tools/perf/util/db-export.c | 2 +- tools/perf/util/dso.c | 3 ++- tools/perf/util/env.c | 2 +- tools/perf/util/event.c | 1 + tools/perf/util/evlist.c | 2 +- tools/perf/util/evsel.c | 2 +- tools/perf/util/header.c | 2 +- tools/perf/util/help-unknown-cmd.c | 2 ++ tools/perf/util/hist.c | 2 +- tools/perf/util/intel-bts.c | 2 +- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 +- tools/perf/util/intel-pt.c | 2 +- tools/perf/util/llvm-utils.c | 1 + tools/perf/util/machine.c | 2 +- tools/perf/util/map.c | 2 +- tools/perf/util/mem2node.c | 2 +- tools/perf/util/mmap.c | 1 + tools/perf/util/namespaces.c | 2 +- tools/perf/util/parse-events.c | 1 + tools/perf/util/pmu.c | 2 +- tools/perf/util/probe-event.c | 2 +- tools/perf/util/probe-file.c | 2 +- tools/perf/util/probe-finder.c | 2 +- tools/perf/util/pstack.c | 2 +- tools/perf/util/python-ext-sources | 1 + tools/perf/util/s390-cpumsf.c | 2 +- tools/perf/util/session.c | 2 +- tools/perf/util/srcline.c | 2 +- tools/perf/util/stat.c | 1 + tools/perf/util/strbuf.c | 2 +- tools/perf/util/strfilter.c | 3 ++- tools/perf/util/strlist.c | 2 +- tools/perf/util/svghelper.c | 2 +- tools/perf/util/symbol-elf.c | 1 + tools/perf/util/symbol-minimal.c | 2 +- tools/perf/util/symbol.c | 1 + tools/perf/util/syscalltbl.c | 2 +- tools/perf/util/thread-stack.c | 2 +- tools/perf/util/thread.c | 2 +- tools/perf/util/thread_map.c | 2 +- tools/perf/util/trace-event-info.c | 1 + tools/perf/util/trace-event-scripting.c | 2 +- tools/perf/util/unwind-libdw.c | 1 + tools/perf/util/util.h | 9 --------- tools/perf/util/values.c | 2 +- tools/perf/util/vdso.c | 1 + tools/perf/util/xyarray.c | 2 +- 103 files changed, 135 insertions(+), 86 deletions(-)
tools/include/linux/zalloc.h new file +12 -0
@@ -0,0 +1,12 @@ +// SPDX-License-Identifier: LGPL-2.1 +#ifndef __TOOLS_LINUX_ZALLOC_H +#define __TOOLS_LINUX_ZALLOC_H + +#include <stddef.h> + +void *zalloc (size_t size); +void __zfree (void **ptr); + +#define zfree (ptr) __zfree((void **)(ptr)) + +#endif // __TOOLS_LINUX_ZALLOC_H
tools/lib/zalloc.c new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: LGPL-2.1 + +#include <stdlib.h> +#include <linux/zalloc.h> + +void *zalloc (size_t size) +{ +return calloc (1 , size); +} + +void __zfree (void **ptr) +{ +free (*ptr); + *ptr =NULL ; +}
tools/perf/MANIFEST +1 -0
@@ -18,3 +18,4 @@ tools/lib/find_bit.c tools/lib/bitmap.c tools/lib/str_error_r.c tools/lib/vsprintf.c +tools/lib/zalloc.c
tools/perf/arch/arm/annotate/instructions.c +1 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/compiler.h> +#include <linux/zalloc.h> #include <sys/types.h> #include <regex.h>
tools/perf/arch/arm/util/auxtrace.c +1 -0
@@ -6,6 +6,7 @@#include <stdbool.h> #include <linux/coresight-pmu.h> +#include <linux/zalloc.h> #include "../../util/auxtrace.h" #include "../../util/evlist.h"
tools/perf/arch/arm/util/cs-etm.c +1 -0
@@ -12,6 +12,7 @@#include <linux/kernel.h> #include <linux/log2.h> #include <linux/types.h> +#include <linux/zalloc.h> #include "cs-etm.h" #include "../../perf.h"
tools/perf/arch/arm64/util/arm-spe.c +1 -0
@@ -8,6 +8,7 @@#include <linux/types.h> #include <linux/bitops.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include <time.h> #include "../../util/cpumap.h"
tools/perf/arch/common.c +1 -1
@@ -3,8 +3,8 @@#include <stdlib.h> #include "common.h" #include "../util/env.h" -#include "../util/util.h" #include "../util/debug.h" +#include <linux/zalloc.h> const char *const arc_triplets[] = {"arc-linux-" ,
tools/perf/arch/powerpc/util/perf_regs.c +1 -1
@@ -2,9 +2,9 @@#include <errno.h> #include <string.h> #include <regex.h> +#include <linux/zalloc.h> #include "../../perf.h" -#include "../../util/util.h" #include "../../util/perf_regs.h" #include "../../util/debug.h"
tools/perf/arch/s390/util/auxtrace.c +1 -0
@@ -3,6 +3,7 @@#include <linux/types.h> #include <linux/bitops.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include "../../util/evlist.h" #include "../../util/auxtrace.h"
tools/perf/arch/s390/util/header.c +1 -1
@@ -13,9 +13,9 @@#include <string.h> #include <linux/ctype.h> #include <linux/kernel.h> +#include <linux/zalloc.h> #include "../../util/header.h" -#include "../../util/util.h" #define SYSINFO_MANU "Manufacturer:"#define SYSINFO_TYPE "Type:"
tools/perf/arch/x86/util/event.c +1 -1
@@ -1,11 +1,11 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/types.h> #include <linux/string.h> +#include <linux/zalloc.h> #include "../../util/machine.h" #include "../../util/tool.h" #include "../../util/map.h" -#include "../../util/util.h" #include "../../util/debug.h" #if defined(__x86_64__)
tools/perf/arch/x86/util/intel-bts.c +1 -1
@@ -9,12 +9,12 @@#include <linux/types.h> #include <linux/bitops.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include "../../util/cpumap.h" #include "../../util/evsel.h" #include "../../util/evlist.h" #include "../../util/session.h" -#include "../../util/util.h" #include "../../util/pmu.h" #include "../../util/debug.h" #include "../../util/tsc.h"
tools/perf/arch/x86/util/intel-pt.c +1 -1
@@ -10,6 +10,7 @@#include <linux/types.h> #include <linux/bitops.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include <cpuid.h> #include "../../perf.h"
@@ -25,7 +26,6 @@#include "../../util/auxtrace.h" #include "../../util/tsc.h" #include "../../util/intel-pt.h" -#include "../../util/util.h" #define KiB (x) ((x) * 1024)#define MiB (x) ((x) * 1024 * 1024)
tools/perf/arch/x86/util/perf_regs.c +1 -1
@@ -2,9 +2,9 @@#include <errno.h> #include <string.h> #include <regex.h> +#include <linux/zalloc.h> #include "../../perf.h" -#include "../../util/util.h" #include "../../util/perf_regs.h" #include "../../util/debug.h"
tools/perf/bench/mem-functions.c +1 -1
@@ -9,7 +9,6 @@#include "debug.h" #include "../perf.h" -#include "../util/util.h" #include <subcmd/parse-options.h> #include "../util/header.h" #include "../util/cloexec.h"
@@ -24,6 +23,7 @@#include <sys/time.h> #include <errno.h> #include <linux/time64.h> +#include <linux/zalloc.h> #define K 1024
tools/perf/bench/numa.c +1 -1
@@ -11,7 +11,6 @@#include "../perf.h" #include "../builtin.h" -#include "../util/util.h" #include <subcmd/parse-options.h> #include "../util/cloexec.h"
@@ -35,6 +34,7 @@#include <linux/kernel.h> #include <linux/time64.h> #include <linux/numa.h> +#include <linux/zalloc.h> #include <numa.h> #include <numaif.h>
tools/perf/builtin-annotate.c +1 -1
@@ -8,11 +8,11 @@*/ #include "builtin.h" -#include "util/util.h" #include "util/color.h" #include <linux/list.h> #include "util/cache.h" #include <linux/rbtree.h> +#include <linux/zalloc.h> #include "util/symbol.h" #include "perf.h"
tools/perf/builtin-bench.c +1 -1
@@ -17,7 +17,6 @@* epoll ... Event poll performance */ #include "perf.h" -#include "util/util.h" #include <subcmd/parse-options.h> #include "builtin.h" #include "bench/bench.h"
@@ -26,6 +25,7 @@#include <stdlib.h> #include <string.h> #include <sys/prctl.h> +#include <linux/zalloc.h> typedef int (*bench_fn_t )(int argc,const char **argv);
tools/perf/builtin-c2c.c +1 -1
@@ -15,9 +15,9 @@#include <linux/compiler.h> #include <linux/kernel.h> #include <linux/stringify.h> +#include <linux/zalloc.h> #include <asm/bug.h> #include <sys/param.h> -#include "util.h" #include "debug.h" #include "builtin.h" #include <subcmd/parse-options.h>
tools/perf/builtin-diff.c +1 -1
@@ -16,12 +16,12 @@#include "util/tool.h" #include "util/sort.h" #include "util/symbol.h" -#include "util/util.h" #include "util/data.h" #include "util/config.h" #include "util/time-utils.h" #include "util/annotate.h" #include "util/map.h" +#include <linux/zalloc.h> #include <errno.h> #include <inttypes.h>
tools/perf/builtin-help.c +1 -0
@@ -14,6 +14,7 @@#include <subcmd/help.h> #include "util/debug.h" #include <linux/kernel.h> +#include <linux/zalloc.h> #include <errno.h> #include <stdio.h> #include <stdlib.h>
tools/perf/builtin-kmem.c +1 -1
@@ -4,7 +4,6 @@#include "util/evlist.h" #include "util/evsel.h" -#include "util/util.h" #include "util/config.h" #include "util/map.h" #include "util/symbol.h"
@@ -26,6 +25,7 @@#include <linux/kernel.h> #include <linux/rbtree.h> #include <linux/string.h> +#include <linux/zalloc.h> #include <errno.h> #include <inttypes.h> #include <locale.h>
tools/perf/builtin-kvm.c +1 -1
@@ -5,7 +5,6 @@#include "util/evsel.h" #include "util/evlist.h" #include "util/term.h" -#include "util/util.h" #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
@@ -32,6 +31,7 @@#include <linux/kernel.h> #include <linux/time64.h> +#include <linux/zalloc.h> #include <errno.h> #include <inttypes.h> #include <poll.h>
tools/perf/builtin-lock.c +1 -1
@@ -6,7 +6,6 @@#include "util/evlist.h" #include "util/evsel.h" -#include "util/util.h" #include "util/cache.h" #include "util/symbol.h" #include "util/thread.h"
@@ -30,6 +29,7 @@#include <linux/list.h> #include <linux/hash.h> #include <linux/kernel.h> +#include <linux/zalloc.h> static struct perf_session *session;
tools/perf/builtin-probe.c +1 -1
@@ -19,7 +19,6 @@#include "perf.h" #include "builtin.h" #include "namespaces.h" -#include "util/util.h" #include "util/strlist.h" #include "util/strfilter.h" #include "util/symbol.h"
@@ -28,6 +27,7 @@#include "util/probe-finder.h" #include "util/probe-event.h" #include "util/probe-file.h" +#include <linux/zalloc.h> #define DEFAULT_VAR_FILTER "!__k???tab_* & !__crc_*"#define DEFAULT_FUNC_FILTER "!_*"
tools/perf/builtin-report.c +1 -1
@@ -8,7 +8,6 @@*/ #include "builtin.h" -#include "util/util.h" #include "util/config.h" #include "util/annotate.h"
@@ -16,6 +15,7 @@#include <linux/list.h> #include <linux/rbtree.h> #include <linux/err.h> +#include <linux/zalloc.h> #include "util/map.h" #include "util/symbol.h" #include "util/callchain.h"
tools/perf/builtin-sched.c +1 -1
@@ -2,7 +2,6 @@#include "builtin.h" #include "perf.h" -#include "util/util.h" #include "util/evlist.h" #include "util/cache.h" #include "util/evsel.h"
@@ -26,6 +25,7 @@#include <linux/kernel.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include <sys/prctl.h> #include <sys/resource.h> #include <inttypes.h>
tools/perf/builtin-script.c +1 -1
@@ -14,7 +14,6 @@#include "util/symbol.h" #include "util/thread.h" #include "util/trace-event.h" -#include "util/util.h" #include "util/evlist.h" #include "util/evsel.h" #include "util/sort.h"
@@ -34,6 +33,7 @@#include <linux/kernel.h> #include <linux/stringify.h> #include <linux/time64.h> +#include <linux/zalloc.h> #include <sys/utsname.h> #include "asm/bug.h" #include "util/mem-events.h"
tools/perf/builtin-stat.c +1 -1
@@ -43,7 +43,6 @@#include "perf.h" #include "builtin.h" #include "util/cgroup.h" -#include "util/util.h" #include <subcmd/parse-options.h> #include "util/parse-events.h" #include "util/pmu.h"
@@ -67,6 +66,7 @@#include "asm/bug.h" #include <linux/time64.h> +#include <linux/zalloc.h> #include <api/fs/fs.h> #include <errno.h> #include <signal.h>
tools/perf/builtin-timechart.c +1 -3
@@ -13,9 +13,6 @@#include <traceevent/event-parse.h> #include "builtin.h" - -#include "util/util.h" -#include "util/color.h" #include <linux/list.h> #include "util/cache.h"
@@ -24,6 +21,7 @@#include <linux/kernel.h> #include <linux/rbtree.h> #include <linux/time64.h> +#include <linux/zalloc.h> #include "util/symbol.h" #include "util/thread.h" #include "util/callchain.h"
tools/perf/builtin-trace.c +1 -0
@@ -61,6 +61,7 @@#include <linux/random.h> #include <linux/stringify.h> #include <linux/time64.h> +#include <linux/zalloc.h> #include <fcntl.h> #include <sys/sysmacros.h>
tools/perf/perf.c +1 -1
@@ -18,7 +18,6 @@#include "util/bpf-loader.h" #include "util/debug.h" #include "util/event.h" -#include "util/util.h" #include <api/fs/fs.h> #include <api/fs/tracing_path.h> #include <errno.h>
@@ -30,6 +29,7 @@#include <sys/stat.h> #include <unistd.h> #include <linux/kernel.h> +#include <linux/zalloc.h> const char perf_usage_string[] ="perf [--version] [--help] [OPTIONS] COMMAND [ARGS]" ;
tools/perf/tests/switch-tracking.c +1 -0
@@ -4,6 +4,7 @@#include <errno.h> #include <time.h> #include <stdlib.h> +#include <linux/zalloc.h> #include "parse-events.h" #include "evlist.h"
tools/perf/ui/browser.c +1 -1
@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include "../util.h" #include "../string2.h" #include "../config.h" #include "../../perf.h"
@@ -17,6 +16,7 @@#include "keysyms.h" #include "../color.h" #include <linux/ctype.h> +#include <linux/zalloc.h> static int ui_browser__percent_color (struct ui_browser *browser,double percent,bool current)
tools/perf/ui/browsers/annotate.c +1 -1
@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include "../../util/util.h" #include "../browser.h" #include "../helpline.h" #include "../ui.h"
@@ -15,6 +14,7 @@#include <pthread.h> #include <linux/kernel.h> #include <linux/string.h> +#include <linux/zalloc.h> #include <sys/ttydefaults.h> #include <asm/bug.h>
tools/perf/ui/browsers/hists.c +1 -1
@@ -9,6 +9,7 @@#include <linux/string.h> #include <sys/ttydefaults.h> #include <linux/time64.h> +#include <linux/zalloc.h> #include "../../util/callchain.h" #include "../../util/evsel.h"
@@ -18,7 +19,6 @@#include "../../util/symbol.h" #include "../../util/pstack.h" #include "../../util/sort.h" -#include "../../util/util.h" #include "../../util/top.h" #include "../../util/thread.h" #include "../../arch/common.h"
tools/perf/ui/gtk/util.c +1 -2
@@ -1,11 +1,10 @@// SPDX-License-Identifier: GPL-2.0 #include "../util.h" -#include "../../util/util.h" #include "../../util/debug.h" #include "gtk.h" #include <string.h> - +#include <linux/zalloc.h> struct perf_gtk_context *pgctx;
tools/perf/ui/stdio/hist.c +1 -1
@@ -3,7 +3,6 @@#include <linux/string.h> #include "../../util/callchain.h" -#include "../../util/util.h" #include "../../util/hist.h" #include "../../util/map.h" #include "../../util/map_groups.h"
@@ -14,6 +13,7 @@#include "../../util/string2.h" #include "../../util/thread.h" #include <linux/ctype.h> +#include <linux/zalloc.h> static size_t callchain__fprintf_left_margin (FILE *fp,int left_margin) {
tools/perf/util/Build +5 -0
@@ -25,6 +25,7 @@ perf-y += rbtree.o perf-y += libstring.o perf-y += bitmap.o perf-y += hweight.o +perf-y += zalloc.o perf-y += smt.o perf-y += strbuf.o perf-y += string.o
@@ -241,3 +242,7 @@ $(OUTPUT)util/hweight.o: ../lib/hweight.c FORCE $(OUTPUT)util/vsprintf.o: ../lib/vsprintf.c FORCE $(call rule_mkdir) $(call if_changed_dep,cc_o_c) + +$(OUTPUT)util/zalloc.o: ../lib/zalloc.c FORCE + $(call rule_mkdir) + $(call if_changed_dep,cc_o_c)
tools/perf/util/arm-spe.c +1 -1
@@ -12,6 +12,7 @@#include <linux/types.h> #include <linux/bitops.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include "cpumap.h" #include "color.h"
@@ -19,7 +20,6 @@#include "evlist.h" #include "machine.h" #include "session.h" -#include "util.h" #include "thread.h" #include "debug.h" #include "auxtrace.h"
tools/perf/util/auxtrace.c +1 -1
@@ -24,9 +24,9 @@#include <stdlib.h> #include <stdio.h> #include <linux/list.h> +#include <linux/zalloc.h> #include "../perf.h" -#include "util.h" #include "evlist.h" #include "dso.h" #include "map.h"
tools/perf/util/bpf-loader.c +1 -0
@@ -12,6 +12,7 @@#include <linux/err.h> #include <linux/kernel.h> #include <linux/string.h> +#include <linux/zalloc.h> #include <errno.h> #include "perf.h" #include "debug.h"
tools/perf/util/build-id.c +1 -0
@@ -30,6 +30,7 @@#include "strlist.h" #include <linux/ctype.h> +#include <linux/zalloc.h> static bool no_buildid_cache;
tools/perf/util/call-path.c +2 -1
@@ -6,8 +6,9 @@#include <linux/rbtree.h> #include <linux/list.h> +#include <linux/zalloc.h> +#include <stdlib.h> -#include "util.h" #include "call-path.h" static void call_path__init(struct call_path *cp, struct call_path *parent,
tools/perf/util/callchain.c +1 -1
@@ -16,11 +16,11 @@#include <stdbool.h> #include <errno.h> #include <math.h> +#include <linux/zalloc.h> #include "asm/bug.h" #include "hist.h" -#include "util.h" #include "sort.h" #include "machine.h" #include "map.h"
tools/perf/util/cgroup.c +1 -1
@@ -1,11 +1,11 @@// SPDX-License-Identifier: GPL-2.0 -#include "util.h" #include "../perf.h" #include <subcmd/parse-options.h> #include "evsel.h" #include "cgroup.h" #include "evlist.h" #include <linux/stringify.h> +#include <linux/zalloc.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>
tools/perf/util/comm.c +1 -1
@@ -1,12 +1,12 @@// SPDX-License-Identifier: GPL-2.0 #include "comm.h" -#include "util.h" #include <errno.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <linux/refcount.h> #include <linux/rbtree.h> +#include <linux/zalloc.h> #include "rwsem.h" struct comm_str {
tools/perf/util/config.c +1 -2
@@ -11,7 +11,6 @@*/ #include <errno.h> #include <sys/param.h> -#include "util.h" #include "cache.h" #include "callchain.h" #include <subcmd/exec-cmd.h>
@@ -23,7 +22,7 @@#include <sys/stat.h> #include <unistd.h> #include <linux/string.h> - +#include <linux/zalloc.h> #include <linux/ctype.h> #define MAXNAME (256)
tools/perf/util/counts.c +1 -1
@@ -3,7 +3,7 @@#include <stdlib.h> #include "evsel.h" #include "counts.h" -#include "util.h" +#include <linux/zalloc.h> struct perf_counts *perf_counts__new (int ncpus,int nthreads) {
tools/perf/util/cpumap.c +1 -1
@@ -1,5 +1,4 @@// SPDX-License-Identifier: GPL-2.0 -#include "util.h" #include <api/fs/fs.h> #include "../perf.h" #include "cpumap.h"
@@ -11,6 +10,7 @@#include "asm/bug.h" #include <linux/ctype.h> +#include <linux/zalloc.h> static int max_cpu_num;static int max_present_cpu_num;
tools/perf/util/cputopo.c +1 -1
@@ -4,10 +4,10 @@#include <inttypes.h> #include <stdlib.h> #include <api/fs/fs.h> +#include <linux/zalloc.h> #include "cputopo.h" #include "cpumap.h" -#include "util.h" #include "env.h" #define CORE_SIB_FMT \
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +1 -0
@@ -8,6 +8,7 @@#include <linux/err.h> #include <linux/list.h> +#include <linux/zalloc.h> #include <stdlib.h> #include <opencsd/c_api/opencsd_c_api.h> #include <opencsd/etmv4/trc_pkt_types_etmv4.h>
tools/perf/util/cs-etm.c +1 -0
@@ -11,6 +11,7 @@#include <linux/kernel.h> #include <linux/log2.h> #include <linux/types.h> +#include <linux/zalloc.h> #include <opencsd/ocsd_if_types.h> #include <stdlib.h>
tools/perf/util/data-convert-bt.c +1 -1
@@ -10,6 +10,7 @@#include <inttypes.h> #include <linux/compiler.h> #include <linux/kernel.h> +#include <linux/zalloc.h> #include <babeltrace/ctf-writer/writer.h> #include <babeltrace/ctf-writer/clock.h> #include <babeltrace/ctf-writer/stream.h>
@@ -22,7 +23,6 @@#include "asm/bug.h" #include "data-convert-bt.h" #include "session.h" -#include "util.h" #include "debug.h" #include "tool.h" #include "evlist.h"
tools/perf/util/data.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/compiler.h> #include <linux/kernel.h> +#include <linux/zalloc.h> #include <sys/types.h> #include <sys/stat.h> #include <errno.h>
tools/perf/util/db-export.c +1 -1
@@ -14,11 +14,11 @@#include "symbol.h" #include "map.h" #include "event.h" -#include "util.h" #include "thread-stack.h" #include "callchain.h" #include "call-path.h" #include "db-export.h" +#include <linux/zalloc.h> struct deferred_export {struct list_head node;
tools/perf/util/dso.c +2 -1
@@ -2,6 +2,7 @@#include <asm/bug.h> #include <linux/kernel.h> #include <linux/string.h> +#include <linux/zalloc.h> #include <sys/time.h> #include <sys/resource.h> #include <sys/types.h>
@@ -21,7 +22,7 @@#include "dso.h" #include "machine.h" #include "auxtrace.h" -#include "util.h" +#include "util.h" /* O_CLOEXEC for older systems */ #include "debug.h" #include "string2.h" #include "vdso.h"
tools/perf/util/env.c +1 -1
@@ -2,7 +2,7 @@#include "cpumap.h" #include "env.h" #include <linux/ctype.h> -#include "util.h" +#include <linux/zalloc.h> #include "bpf-event.h" #include <errno.h> #include <sys/utsname.h>
tools/perf/util/event.c +1 -0
@@ -11,6 +11,7 @@#include <uapi/linux/mman.h> /* To get things like MAP_HUGETLB even on older libc headers */ #include <api/fs/fs.h> #include <linux/perf_event.h> +#include <linux/zalloc.h> #include "event.h" #include "debug.h" #include "hist.h"
tools/perf/util/evlist.c +1 -1
@@ -5,7 +5,6 @@* Parts came from builtin-{top,stat,record}.c, see those files for further * copyright notes. */ -#include "util.h" #include <api/fs/fs.h> #include <errno.h> #include <inttypes.h>
@@ -33,6 +32,7 @@#include <linux/hash.h> #include <linux/log2.h> #include <linux/err.h> +#include <linux/zalloc.h> #ifdef LACKS_SIGQUEUE_PROTOTYPE int sigqueue (pid_t pid,int sig,const union sigval value);
tools/perf/util/evsel.c +1 -1
@@ -17,6 +17,7 @@#include <linux/perf_event.h> #include <linux/compiler.h> #include <linux/err.h> +#include <linux/zalloc.h> #include <sys/ioctl.h> #include <sys/resource.h> #include <sys/types.h>
@@ -27,7 +28,6 @@#include "event.h" #include "evsel.h" #include "evlist.h" -#include "util.h" #include "cpumap.h" #include "thread_map.h" #include "target.h"
tools/perf/util/header.c +1 -1
@@ -1,7 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <errno.h> #include <inttypes.h> -#include "util.h" #include "string2.h" #include <sys/param.h> #include <sys/types.h>
@@ -15,6 +14,7 @@#include <linux/bitops.h> #include <linux/string.h> #include <linux/stringify.h> +#include <linux/zalloc.h> #include <sys/stat.h> #include <sys/utsname.h> #include <linux/time64.h>
tools/perf/util/help-unknown-cmd.c +2 -0
@@ -3,9 +3,11 @@#include "config.h" #include <poll.h> #include <stdio.h> +#include <stdlib.h> #include <subcmd/help.h> #include "../builtin.h" #include "levenshtein.h" +#include <linux/zalloc.h> static int autocorrect;
tools/perf/util/hist.c +1 -1
@@ -1,6 +1,5 @@// SPDX-License-Identifier: GPL-2.0 #include "callchain.h" -#include "util.h" #include "build-id.h" #include "hist.h" #include "map.h"
@@ -20,6 +19,7 @@#include <inttypes.h> #include <sys/param.h> #include <linux/time64.h> +#include <linux/zalloc.h> static bool hists__filter_entry_by_dso (struct hists *hists,struct hist_entry *he);
tools/perf/util/intel-bts.c +1 -1
@@ -12,6 +12,7 @@#include <linux/types.h> #include <linux/bitops.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include "cpumap.h" #include "color.h"
@@ -21,7 +22,6 @@#include "map.h" #include "symbol.h" #include "session.h" -#include "util.h" #include "thread.h" #include "thread-stack.h" #include "debug.h"
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +1 -1
@@ -14,9 +14,9 @@#include <stdint.h> #include <inttypes.h> #include <linux/compiler.h> +#include <linux/zalloc.h> #include "../cache.h" -#include "../util.h" #include "../auxtrace.h" #include "intel-pt-insn-decoder.h"
tools/perf/util/intel-pt.c +1 -1
@@ -10,6 +10,7 @@#include <errno.h> #include <linux/kernel.h> #include <linux/types.h> +#include <linux/zalloc.h> #include "../perf.h" #include "session.h"
@@ -22,7 +23,6 @@#include "evsel.h" #include "map.h" #include "color.h" -#include "util.h" #include "thread.h" #include "thread-stack.h" #include "symbol.h"
tools/perf/util/llvm-utils.c +1 -0
@@ -9,6 +9,7 @@#include <stdio.h> #include <stdlib.h> #include <linux/err.h> +#include <linux/zalloc.h> #include "debug.h" #include "llvm-utils.h" #include "config.h"
tools/perf/util/machine.c +1 -1
@@ -15,7 +15,6 @@#include "strlist.h" #include "thread.h" #include "vdso.h" -#include "util.h" #include <stdbool.h> #include <sys/types.h> #include <sys/stat.h>
@@ -28,6 +27,7 @@#include <linux/ctype.h> #include <symbol/kallsyms.h> #include <linux/mman.h> +#include <linux/zalloc.h> static void __machine__remove_thread (struct machine *machine,struct thread *th,bool lock);
tools/perf/util/map.c +1 -1
@@ -12,10 +12,10 @@#include "thread.h" #include "vdso.h" #include "build-id.h" -#include "util.h" #include "debug.h" #include "machine.h" #include <linux/string.h> +#include <linux/zalloc.h> #include "srcline.h" #include "namespaces.h" #include "unwind.h"
tools/perf/util/mem2node.c +1 -1
@@ -1,8 +1,8 @@#include <errno.h> #include <inttypes.h> #include <linux/bitmap.h> +#include <linux/zalloc.h> #include "mem2node.h" -#include "util.h" struct phys_entry {struct rb_node rb_node;
tools/perf/util/mmap.c +1 -0
@@ -9,6 +9,7 @@#include <sys/mman.h> #include <inttypes.h> #include <asm/bug.h> +#include <linux/zalloc.h> #ifdef HAVE_LIBNUMA_SUPPORT #include <numaif.h> #endif
tools/perf/util/namespaces.c +1 -1
@@ -5,7 +5,6 @@*/ #include "namespaces.h" -#include "util.h" #include "event.h" #include "get_current_dir_name.h" #include <sys/types.h>
@@ -18,6 +17,7 @@#include <string.h> #include <unistd.h> #include <asm/bug.h> +#include <linux/zalloc.h> struct namespaces *namespaces__new (struct namespaces_event *event) {
tools/perf/util/parse-events.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include <linux/hw_breakpoint.h> #include <linux/err.h> +#include <linux/zalloc.h> #include <dirent.h> #include <errno.h> #include <sys/ioctl.h>
tools/perf/util/pmu.c +1 -1
@@ -2,6 +2,7 @@#include <linux/list.h> #include <linux/compiler.h> #include <linux/string.h> +#include <linux/zalloc.h> #include <sys/types.h> #include <errno.h> #include <fcntl.h>
@@ -14,7 +15,6 @@#include <api/fs/fs.h> #include <locale.h> #include <regex.h> -#include "util.h" #include "pmu.h" #include "parse-events.h" #include "cpumap.h"
tools/perf/util/probe-event.c +1 -1
@@ -19,7 +19,6 @@#include <limits.h> #include <elf.h> -#include "util.h" #include "event.h" #include "namespaces.h" #include "strlist.h"
@@ -40,6 +39,7 @@#include "string2.h" #include <linux/ctype.h> +#include <linux/zalloc.h> #define PERFPROBE_GROUP "probe"
tools/perf/util/probe-file.c +1 -1
@@ -10,8 +10,8 @@#include <sys/types.h> #include <sys/uio.h> #include <unistd.h> +#include <linux/zalloc.h> #include "namespaces.h" -#include "util.h" #include "event.h" #include "strlist.h" #include "strfilter.h"
tools/perf/util/probe-finder.c +1 -1
@@ -19,11 +19,11 @@#include <dwarf-regs.h> #include <linux/bitops.h> +#include <linux/zalloc.h> #include "event.h" #include "dso.h" #include "debug.h" #include "intlist.h" -#include "util.h" #include "strlist.h" #include "symbol.h" #include "probe-finder.h"
tools/perf/util/pstack.c +1 -1
@@ -5,10 +5,10 @@* (c) 2010 Arnaldo Carvalho de Melo <[email protected]> */ -#include "util.h" #include "pstack.h" #include "debug.h" #include <linux/kernel.h> +#include <linux/zalloc.h> #include <stdlib.h> struct pstack {
tools/perf/util/python-ext-sources +1 -0
@@ -18,6 +18,7 @@ util/namespaces.c ../lib/hweight.c ../lib/string.c ../lib/vsprintf.c +../lib/zalloc.c util/thread_map.c util/util.c util/xyarray.c
tools/perf/util/s390-cpumsf.c +1 -1
@@ -146,6 +146,7 @@#include <linux/types.h> #include <linux/bitops.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include <sys/stat.h> #include <sys/types.h>
@@ -156,7 +157,6 @@#include "evlist.h" #include "machine.h" #include "session.h" -#include "util.h" #include "thread.h" #include "debug.h" #include "auxtrace.h"
tools/perf/util/session.c +1 -1
@@ -2,6 +2,7 @@#include <errno.h> #include <inttypes.h> #include <linux/kernel.h> +#include <linux/zalloc.h> #include <traceevent/event-parse.h> #include <api/fs/fs.h>
@@ -18,7 +19,6 @@#include "session.h" #include "tool.h" #include "sort.h" -#include "util.h" #include "cpumap.h" #include "perf_regs.h" #include "asm/bug.h"
tools/perf/util/srcline.c +1 -1
@@ -6,9 +6,9 @@#include <linux/kernel.h> #include <linux/string.h> +#include <linux/zalloc.h> #include "util/dso.h" -#include "util/util.h" #include "util/debug.h" #include "util/callchain.h" #include "util/symbol_conf.h"
tools/perf/util/stat.c +1 -0
@@ -6,6 +6,7 @@#include "evlist.h" #include "evsel.h" #include "thread_map.h" +#include <linux/zalloc.h> void update_stats (struct stats *stats,u64 val) {
tools/perf/util/strbuf.c +1 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0 #include "debug.h" -#include "util.h" #include <linux/kernel.h> +#include <linux/zalloc.h> #include <errno.h> #include <stdlib.h>
tools/perf/util/strfilter.c +2 -1
@@ -1,11 +1,12 @@// SPDX-License-Identifier: GPL-2.0 -#include "util.h" #include "string2.h" #include "strfilter.h" #include <errno.h> +#include <stdlib.h> #include <linux/ctype.h> #include <linux/string.h> +#include <linux/zalloc.h> /* Operators */ static const char *OP_and ="&" ;/* Logical AND */
tools/perf/util/strlist.c +1 -1
@@ -4,12 +4,12 @@*/ #include "strlist.h" -#include "util.h" #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <linux/zalloc.h> static struct rb_node *strlist__node_new (struct rblist *rblist,const void *entry)
tools/perf/util/svghelper.c +1 -1
@@ -15,10 +15,10 @@#include <string.h> #include <linux/bitmap.h> #include <linux/time64.h> +#include <linux/zalloc.h> #include "perf.h" #include "svghelper.h" -#include "util.h" #include "cpumap.h" static u64 first_time, last_time;
tools/perf/util/symbol-elf.c +1 -0
@@ -17,6 +17,7 @@#include "debug.h" #include "util.h" #include <linux/ctype.h> +#include <linux/zalloc.h> #include <symbol/kallsyms.h> #ifndef EM_AARCH64
tools/perf/util/symbol-minimal.c +1 -1
@@ -10,7 +10,7 @@#include <stdlib.h> #include <byteswap.h> #include <sys/stat.h> - +#include <linux/zalloc.h> static bool check_need_swap (int file_endian) {
tools/perf/util/symbol.c +1 -0
@@ -26,6 +26,7 @@#include "header.h" #include "path.h" #include <linux/ctype.h> +#include <linux/zalloc.h> #include <elf.h> #include <limits.h>
tools/perf/util/syscalltbl.c +1 -1
@@ -10,9 +10,9 @@#include <linux/compiler.h> #ifdef HAVE_SYSCALL_TABLE_SUPPORT +#include <linux/zalloc.h> #include <string.h> #include "string2.h" -#include "util.h" #if defined(__x86_64__)#include <asm/syscalls_64.c>
tools/perf/util/thread-stack.c +1 -1
@@ -7,13 +7,13 @@#include <linux/rbtree.h> #include <linux/list.h> #include <linux/log2.h> +#include <linux/zalloc.h> #include <errno.h> #include <stdlib.h> #include "thread.h" #include "event.h" #include "machine.h" #include "env.h" -#include "util.h" #include "debug.h" #include "symbol.h" #include "comm.h"
tools/perf/util/thread.c +1 -1
@@ -5,10 +5,10 @@#include <stdio.h> #include <string.h> #include <linux/kernel.h> +#include <linux/zalloc.h> #include "session.h" #include "thread.h" #include "thread-stack.h" -#include "util.h" #include "debug.h" #include "namespaces.h" #include "comm.h"
tools/perf/util/thread_map.c +1 -1
@@ -13,9 +13,9 @@#include <string.h> #include <api/fs/fs.h> #include <linux/string.h> +#include <linux/zalloc.h> #include "asm/bug.h" #include "thread_map.h" -#include "util.h" #include "debug.h" #include "event.h"
tools/perf/util/trace-event-info.c +1 -0
@@ -18,6 +18,7 @@#include <stdbool.h> #include <linux/list.h> #include <linux/kernel.h> +#include <linux/zalloc.h> #include "../perf.h" #include "trace-event.h"
tools/perf/util/trace-event-scripting.c +1 -1
@@ -12,8 +12,8 @@#include "../perf.h" #include "debug.h" -#include "util.h" #include "trace-event.h" +#include <linux/zalloc.h> struct scripting_context *scripting_context;
tools/perf/util/unwind-libdw.c +1 -0
@@ -12,6 +12,7 @@#include "symbol.h" #include "thread.h" #include <linux/types.h> +#include <linux/zalloc.h> #include "event.h" #include "perf_regs.h" #include "callchain.h"
tools/perf/util/util.h +0 -9
@@ -9,8 +9,6 @@#include <fcntl.h> #include <stdbool.h> #include <stddef.h> -#include <stdlib.h> -#include <stdarg.h> #include <linux/compiler.h> #include <sys/types.h>
@@ -18,13 +16,6 @@void usage (const char *err)__noreturn ; void die(const char *err, ...) __noreturn __printf(1, 2); -static inline void *zalloc (size_t size) -{ -return calloc (1 , size); -} - -#define zfree (ptr) ({ free(*ptr); *ptr = NULL; }) -struct dirent ;struct nsinfo ;struct strlist ;
tools/perf/util/values.c +1 -1
@@ -3,8 +3,8 @@#include <stdio.h> #include <stdlib.h> #include <errno.h> +#include <linux/zalloc.h> -#include "util.h" #include "values.h" #include "debug.h"
tools/perf/util/vdso.c +1 -0
@@ -16,6 +16,7 @@#include "machine.h" #include "thread.h" #include "linux/string.h" +#include <linux/zalloc.h> #include "debug.h" /*
tools/perf/util/xyarray.c +1 -1
@@ -1,8 +1,8 @@// SPDX-License-Identifier: GPL-2.0 #include "xyarray.h" -#include "util.h" #include <stdlib.h> #include <string.h> +#include <linux/zalloc.h> struct xyarray *xyarray__new (int xlen,int ylen,size_t entry_size) {