From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH 1/2] devtools/linux-uapi: conform to kernel headers install
Date: Tue, 10 Jun 2025 08:11:20 -0700 [thread overview]
Message-ID: <20250610151158.209572-2-stephen@networkplumber.org> (raw)
In-Reply-To: <20250610151158.209572-1-stephen@networkplumber.org>
The Linux kernel has an existing script to sanitize headers which
uses more steps to clean up the header file. Make the DPDK header
import script use the same regular expression. The kernel script
is GPL-2.0 so ok.
Not necessary for current vduse.h header only but useful if more
headers are added later. Want the distro and DPDK header to
be exact match.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
devtools/linux-uapi.sh | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/devtools/linux-uapi.sh b/devtools/linux-uapi.sh
index ccd8b6816e..e739bdb1f4 100755
--- a/devtools/linux-uapi.sh
+++ b/devtools/linux-uapi.sh
@@ -79,9 +79,21 @@ import_header()
fixup_includes()
{
local path=$1
+ local tmpfile=$path.tmp
- sed -i "s|^#include <linux/compiler.h>||g" $path
- sed -i "s|\<__user[[:space:]]||" $path
+ # script to sanitize see kernel script
+ # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/headers_install.sh
+
+ sed -E -e '
+ s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
+ s/__attribute_const__([[:space:]]|$)/\1/g
+ s@^#include <linux/compiler(|_types).h>@@
+ s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
+ s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
+ s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' $path >$tmpfile
+
+ unifdef -U__KERNEL__ -D__EXPORTED_HEADERS $tmpfile >$path
+ rm $tmpfile
# Prepend include path with "uapi/" if the header is imported
for include in $(sed -ne 's/^#include <\(.*\)>$/\1/p' $path); do
--
2.47.2
next prev parent reply other threads:[~2025-06-10 15:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 15:11 [PATCH 0/2] uapi: script and header update Stephen Hemminger
2025-06-10 15:11 ` Stephen Hemminger [this message]
2025-06-10 15:11 ` [PATCH 2/2] uapi: update headers to 6.15 kernel Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250610151158.209572-2-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).