xref: /linux/tools/perf/check-headers.sh (revision 172cdcaefea5c297fdb3d20b7d5aff60ae4fbce6)
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3
4FILES='
5include/uapi/linux/const.h
6include/uapi/drm/drm.h
7include/uapi/drm/i915_drm.h
8include/uapi/linux/fadvise.h
9include/uapi/linux/fcntl.h
10include/uapi/linux/fs.h
11include/uapi/linux/fscrypt.h
12include/uapi/linux/kcmp.h
13include/uapi/linux/kvm.h
14include/uapi/linux/in.h
15include/uapi/linux/mount.h
16include/uapi/linux/openat2.h
17include/uapi/linux/perf_event.h
18include/uapi/linux/prctl.h
19include/uapi/linux/sched.h
20include/uapi/linux/stat.h
21include/uapi/linux/usbdevice_fs.h
22include/uapi/linux/vhost.h
23include/uapi/sound/asound.h
24include/linux/bits.h
25include/vdso/bits.h
26include/linux/const.h
27include/vdso/const.h
28include/linux/hash.h
29include/uapi/linux/hw_breakpoint.h
30arch/x86/include/asm/disabled-features.h
31arch/x86/include/asm/required-features.h
32arch/x86/include/asm/cpufeatures.h
33arch/x86/include/asm/inat_types.h
34arch/x86/include/asm/emulate_prefix.h
35arch/x86/include/asm/irq_vectors.h
36arch/x86/include/asm/msr-index.h
37arch/x86/include/uapi/asm/prctl.h
38arch/x86/lib/x86-opcode-map.txt
39arch/x86/tools/gen-insn-attr-x86.awk
40arch/arm/include/uapi/asm/perf_regs.h
41arch/arm64/include/uapi/asm/perf_regs.h
42arch/powerpc/include/uapi/asm/perf_regs.h
43arch/s390/include/uapi/asm/perf_regs.h
44arch/x86/include/uapi/asm/perf_regs.h
45arch/x86/include/uapi/asm/kvm.h
46arch/x86/include/uapi/asm/kvm_perf.h
47arch/x86/include/uapi/asm/svm.h
48arch/x86/include/uapi/asm/unistd.h
49arch/x86/include/uapi/asm/vmx.h
50arch/powerpc/include/uapi/asm/kvm.h
51arch/s390/include/uapi/asm/kvm.h
52arch/s390/include/uapi/asm/kvm_perf.h
53arch/s390/include/uapi/asm/ptrace.h
54arch/s390/include/uapi/asm/sie.h
55arch/arm/include/uapi/asm/kvm.h
56arch/arm64/include/uapi/asm/kvm.h
57arch/arm64/include/uapi/asm/unistd.h
58arch/alpha/include/uapi/asm/errno.h
59arch/mips/include/asm/errno.h
60arch/mips/include/uapi/asm/errno.h
61arch/parisc/include/uapi/asm/errno.h
62arch/powerpc/include/uapi/asm/errno.h
63arch/sparc/include/uapi/asm/errno.h
64arch/x86/include/uapi/asm/errno.h
65include/asm-generic/bitops/arch_hweight.h
66include/asm-generic/bitops/const_hweight.h
67include/asm-generic/bitops/__fls.h
68include/asm-generic/bitops/fls.h
69include/asm-generic/bitops/fls64.h
70include/linux/coresight-pmu.h
71include/uapi/asm-generic/errno.h
72include/uapi/asm-generic/errno-base.h
73include/uapi/asm-generic/ioctls.h
74include/uapi/asm-generic/mman-common.h
75include/uapi/asm-generic/unistd.h
76'
77
78SYNC_CHECK_FILES='
79arch/x86/include/asm/inat.h
80arch/x86/include/asm/insn.h
81arch/x86/lib/inat.c
82arch/x86/lib/insn.c
83'
84
85# These copies are under tools/perf/trace/beauty/ as they are not used to in
86# building object files only by scripts in tools/perf/trace/beauty/ to generate
87# tables that then gets included in .c files for things like id->string syscall
88# tables (and the reverse lookup as well: string -> id)
89
90BEAUTY_FILES='
91include/linux/socket.h
92'
93
94check_2 () {
95  file1=$1
96  file2=$2
97
98  shift
99  shift
100
101  cmd="diff $* $file1 $file2 > /dev/null"
102
103  test -f $file2 && {
104    eval $cmd || {
105      echo "Warning: Kernel ABI header at '$file1' differs from latest version at '$file2'" >&2
106      echo diff -u $file1 $file2
107    }
108  }
109}
110
111check () {
112  file=$1
113
114  shift
115
116  check_2 tools/$file $file $*
117}
118
119beauty_check () {
120  file=$1
121
122  shift
123
124  check_2 tools/perf/trace/beauty/$file $file $*
125}
126
127# Check if we have the kernel headers (tools/perf/../../include), else
128# we're probably on a detached tarball, so no point in trying to check
129# differences.
130test -d ../../include || exit 0
131
132cd ../..
133
134# simple diff check
135for i in $FILES; do
136  check $i -B
137done
138
139for i in $SYNC_CHECK_FILES; do
140  check $i '-I "^.*\/\*.*__ignore_sync_check__.*\*\/.*$"'
141done
142
143# diff with extra ignore lines
144check arch/x86/lib/memcpy_64.S        '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memcpy_\(erms\|orig\))"'
145check arch/x86/lib/memset_64.S        '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>" -I"^SYM_FUNC_START\(_LOCAL\)*(memset_\(erms\|orig\))"'
146check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"'
147check include/uapi/linux/mman.h       '-I "^#include <\(uapi/\)*asm/mman.h>"'
148check include/linux/build_bug.h       '-I "^#\(ifndef\|endif\)\( \/\/\)* static_assert$"'
149check include/linux/ctype.h	      '-I "isdigit("'
150check lib/ctype.c		      '-I "^EXPORT_SYMBOL" -I "^#include <linux/export.h>" -B'
151
152# diff non-symmetric files
153check_2 tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
154check_2 tools/perf/arch/powerpc/entry/syscalls/syscall.tbl arch/powerpc/kernel/syscalls/syscall.tbl
155check_2 tools/perf/arch/s390/entry/syscalls/syscall.tbl arch/s390/kernel/syscalls/syscall.tbl
156check_2 tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl arch/mips/kernel/syscalls/syscall_n64.tbl
157
158for i in $BEAUTY_FILES; do
159  beauty_check $i -B
160done
161
162# check duplicated library files
163check_2 tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
164check_2 tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
165
166cd tools/perf
167