On Mon, Mar 4, 2024 at 6:53 PM Tyler Retzlaff <roret...@linux.microsoft.com> wrote: > > The current location used for __rte_aligned(a) for alignment of types > and variables is not compatible with MSVC. There is only a single > location accepted by both toolchains. > > For variables standard C11 offers alignas(a) supported by conformant > compilers i.e. both MSVC and GCC. > > For types the standard offers no alignment facility that compatibly > interoperates with C and C++ but may be achieved by relocating the > placement of __rte_aligned(a) to the aforementioned location accepted > by all currently supported toolchains. > > ** NOTE ** > > Finally, In the interest of not creating more API (internal or not) the > series does not introduce a wrapper for C11 alignas. If we don't introduce > a macro an application can't take a dependency.
I have been looking into adding some check so that we catch new introductions of __rte_*aligned calls... Wdyt of: diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh index c47ea59501..632397f42d 100755 --- a/devtools/checkpatches.sh +++ b/devtools/checkpatches.sh @@ -336,6 +336,21 @@ check_internal_tags() { # <patch> return $res } +check_aligned_attributes() { # <patch> + res=0 + + for token in __rte_aligned __rte_cache_aligned __rte_cache_min_aligned; do + if [ $(grep -E '^\+.*\<'$token'\>' "$1" | \ + grep -vE '\<(struct|union)[[:space:]]*'$token'\>' | \ + wc -l) != 0 ]; then + echo "Please only use $token for struct or union types alignment." + res=1 + fi + done + + return $res +} + check_release_notes() { # <patch> rel_notes_prefix=doc/guides/rel_notes/release_ IFS=. read year month release < VERSION @@ -445,6 +460,14 @@ check () { # <patch-file> <commit> ret=1 fi + ! $verbose || printf '\nChecking alignment attributes:\n' + report=$(check_aligned_attributes "$tmpinput") + if [ $? -ne 0 ] ; then + $headline_printed || print_headline "$subject" + printf '%s\n' "$report" + ret=1 + fi + ! $verbose || printf '\nChecking release notes updates:\n' report=$(check_release_notes "$tmpinput") if [ $? -ne 0 ] ; then -- David Marchand