summaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorTyler Retzlaff <[email protected]>2024-03-04 09:52:06 -0800
committerDavid Marchand <[email protected]>2024-03-06 11:01:28 +0100
commitc6552d9a8deffa448de2d5e2e726f50508c1efd2 (patch)
tree84902e436741f68552ecbeca39f4c0f549bcac57 /devtools
parent45f1004f7e3399609175dc150ae224cec4d5e157 (diff)
lib: move alignment attribute on types for MSVC
The current location used for __rte_aligned(a) for alignment of types is not compatible with MSVC. There is only a single location accepted by both toolchains. The standard offers no alignment facility that compatibly interoperates with C and C++ but it may be achieved by relocating the placement of __rte_aligned(a) to the aforementioned location accepted by all currently supported toolchains. To allow alignment for both compilers, do the following: * Expand __rte_aligned(a) to __declspec(align(a)) when building with MSVC. * Move __rte_aligned from the end of {struct,union} definitions to be between {struct,union} and tag. The placement between {struct,union} and the tag allows the desired alignment to be imparted on the type regardless of the toolchain being used for all of GCC, LLVM, MSVC compilers building both C and C++. Note: this move has an additional benefit as Doxygen is not confused anymore like for the rte_event_vector struct definition. Signed-off-by: Tyler Retzlaff <[email protected]> Acked-by: Morten Brørup <[email protected]> Acked-by: Bruce Richardson <[email protected]> Acked-by: Konstantin Ananyev <[email protected]> Acked-by: Chengwen Feng <[email protected]> Reviewed-by: Maxime Coquelin <[email protected]> Signed-off-by: David Marchand <[email protected]>
Diffstat (limited to 'devtools')
-rwxr-xr-xdevtools/checkpatches.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/devtools/checkpatches.sh b/devtools/checkpatches.sh
index c47ea59501..8f245ebdab 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 use $token only 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