mirror of
https://github.com/ukui/kernel.git
synced 2026-03-09 10:07:04 -07:00
tools lib: Adopt zalloc()/zfree() from tools/perf
Eroding a bit more the tools/perf/util/util.h hodpodge header. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-natazosyn9rwjka25tvcnyi0@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
12
tools/include/linux/zalloc.h
Normal file
12
tools/include/linux/zalloc.h
Normal file
@@ -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
|
||||
15
tools/lib/zalloc.c
Normal file
15
tools/lib/zalloc.c
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <linux/coresight-pmu.h>
|
||||
#include <linux/zalloc.h>
|
||||
|
||||
#include "../../util/auxtrace.h"
|
||||
#include "../../util/evlist.h"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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-",
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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:"
|
||||
|
||||
@@ -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__)
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user