summaryrefslogtreecommitdiff
path: root/scripts/atomic/check-atomics.sh
blob: 0e7bab3eb0d11b808301187258e7d12b7ee2050f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# Check if atomic headers are up-to-date

ATOMICDIR=$(dirname $0)
ATOMICTBL=${ATOMICDIR}/atomics.tbl
LINUXDIR=${ATOMICDIR}/../..

echo '' | sha1sum - > /dev/null 2>&1
if [ $? -ne 0 ]; then
	printf "sha1sum not available, skipping atomic header checks.\n"
	exit 0
fi

cat <<EOF |
linux/atomic/atomic-instrumented.h
linux/atomic/atomic-long.h
linux/atomic/atomic-arch-fallback.h
EOF
while read header; do
	OLDSUM="$(tail -n 1 ${LINUXDIR}/include/${header})"
	OLDSUM="${OLDSUM#// }"

	NEWSUM="$(sed '$d' ${LINUXDIR}/include/${header} | sha1sum)"
	NEWSUM="${NEWSUM%% *}"

	if [ "${OLDSUM}" != "${NEWSUM}" ]; then
		printf "warning: generated include/${header} has been modified.\n"
	fi
done

exit 0