Check for atomic operations consistency in checklibs.sh

isc/atomic.h and its defined macros should be preferred over
stdatomic.h and explicit atomic operations.

Fix the redundant stdatomic.h header in histo.c found by the introduced
check.
This commit is contained in:
Aydın Mercan
2023-12-18 11:38:59 +03:00
parent 294329da3a
commit ca9a05f9ce
2 changed files with 22 additions and 1 deletions

View File

@@ -42,4 +42,26 @@ list=$(git grep -l uintptr_t lib bin \
echo "$list"
}
#
# Check for the direct usage of stdatomic.h
#
list=$(git grep -l stdatomic.h lib bin ':(exclude)lib/isc/include/isc/atomic\.h' \
| grep -e '\.c$' -e '\.h$')
[ -n "$list" ] && {
status=1
echo 'Use #include <isc/atomic.h> instead of #include <stdatomic.h>:'
echo "$list"
}
#
# Check for the usage of explicit memory ordering
#
list=$(git grep -l memory_order_.* lib bin ':(exclude)lib/isc/include/isc/atomic\.h' \
| grep -e '\.c$' -e '\.h$')
[ -n "$list" ] && {
status=1
echo 'Prefer the helpers in <isc/atomic.h> over specifying an explicit memory order:'
echo "$list"
}
exit $status