[PATCH v4 6/6] devtools: forbid new direct use of GCC atomic builtins
Morten Brørup
mb at smartsharesystems.com
Thu Aug 17 13:57:01 CEST 2023
> From: Tyler Retzlaff [mailto:roretzla at linux.microsoft.com]
> Sent: Wednesday, 16 August 2023 23.39
>
> Refrain from using compiler __atomic_xxx builtins DPDK now requires
> the use of rte_atomic_<op>_explicit macros when operating on DPDK
> atomic variables.
There is probably no end to how much can be added to checkpatches.
You got the important stuff, so below are only further suggestions!
[...]
> - # refrain from using compiler __atomic_{add,and,nand,or,sub,xor}_fetch()
> + # refrain from using compiler __atomic_xxx builtins
> awk -v FOLDERS="lib drivers app examples" \
> - -v EXPRESSIONS="__atomic_(add|and|nand|or|sub|xor)_fetch\\\(" \
> + -v EXPRESSIONS="__atomic_.*\\\(" \
> -v RET_ON_FAIL=1 \
> - -v MESSAGE='Using __atomic_op_fetch, prefer __atomic_fetch_op' \
> + -v MESSAGE='Using __atomic_xxx builtins' \
Alternatively:
-v MESSAGE='Using __atomic_xxx built-ins, prefer rte_atomic_xxx' \
> -f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
> "$1" || res=1
>
> --
> 1.8.3.1
This could be updated too:
# refrain from using compiler __atomic_thread_fence()
# It should be avoided on x86 for SMP case.
awk -v FOLDERS="lib drivers app examples" \
-v EXPRESSIONS="__atomic_thread_fence\\\(" \
-v RET_ON_FAIL=1 \
- -v MESSAGE='Using __atomic_thread_fence' \
+ -v MESSAGE='Using __atomic_thread_fence built-in, prefer __rte_atomic_thread_fence' \
-f $(dirname $(readlink -f $0))/check-forbidden-tokens.awk \
"$1" || res=1
You could also add C11 variants of these tests...
atomic_(load|store|exchange|compare_exchange_(strong|weak)|fetch_(add|sub|and|xor|or|nand)|flag_(test_and_set|clear))[_explicit], and
atomic_thread_fence.
And a test for using "_Atomic".
-Morten
More information about the dev
mailing list