18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# Check if atomic headers are up-to-date
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciATOMICDIR=$(dirname $0)
78c2ecf20Sopenharmony_ciATOMICTBL=${ATOMICDIR}/atomics.tbl
88c2ecf20Sopenharmony_ciLINUXDIR=${ATOMICDIR}/../..
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciecho '' | sha1sum - > /dev/null 2>&1
118c2ecf20Sopenharmony_ciif [ $? -ne 0 ]; then
128c2ecf20Sopenharmony_ci	printf "sha1sum not available, skipping atomic header checks.\n"
138c2ecf20Sopenharmony_ci	exit 0
148c2ecf20Sopenharmony_cifi
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_cicat <<EOF |
178c2ecf20Sopenharmony_ciasm-generic/atomic-instrumented.h
188c2ecf20Sopenharmony_ciasm-generic/atomic-long.h
198c2ecf20Sopenharmony_cilinux/atomic-arch-fallback.h
208c2ecf20Sopenharmony_cilinux/atomic-fallback.h
218c2ecf20Sopenharmony_ciEOF
228c2ecf20Sopenharmony_ciwhile read header; do
238c2ecf20Sopenharmony_ci	OLDSUM="$(tail -n 1 ${LINUXDIR}/include/${header})"
248c2ecf20Sopenharmony_ci	OLDSUM="${OLDSUM#// }"
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci	NEWSUM="$(sed '$d' ${LINUXDIR}/include/${header} | sha1sum)"
278c2ecf20Sopenharmony_ci	NEWSUM="${NEWSUM%% *}"
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	if [ "${OLDSUM}" != "${NEWSUM}" ]; then
308c2ecf20Sopenharmony_ci		printf "warning: generated include/${header} has been modified.\n"
318c2ecf20Sopenharmony_ci	fi
328c2ecf20Sopenharmony_cidone
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciexit 0
35