Merge branch 'stable/for-linus-5.15' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / scripts / atomic / check-atomics.sh
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
3 #
4 # Check if atomic headers are up-to-date
5
6 ATOMICDIR=$(dirname $0)
7 ATOMICTBL=${ATOMICDIR}/atomics.tbl
8 LINUXDIR=${ATOMICDIR}/../..
9
10 echo '' | sha1sum - > /dev/null 2>&1
11 if [ $? -ne 0 ]; then
12         printf "sha1sum not available, skipping atomic header checks.\n"
13         exit 0
14 fi
15
16 cat <<EOF |
17 linux/atomic/atomic-instrumented.h
18 linux/atomic/atomic-long.h
19 linux/atomic/atomic-arch-fallback.h
20 EOF
21 while read header; do
22         OLDSUM="$(tail -n 1 ${LINUXDIR}/include/${header})"
23         OLDSUM="${OLDSUM#// }"
24
25         NEWSUM="$(sed '$d' ${LINUXDIR}/include/${header} | sha1sum)"
26         NEWSUM="${NEWSUM%% *}"
27
28         if [ "${OLDSUM}" != "${NEWSUM}" ]; then
29                 printf "warning: generated include/${header} has been modified.\n"
30         fi
31 done
32
33 exit 0