* [PATCH] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8
@ 2025-08-07 8:09 Wake Liu
2025-08-12 3:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Wake Liu @ 2025-08-07 8:09 UTC (permalink / raw)
To: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Shuah Khan, Nathan Chancellor
Cc: Simon Horman, Nick Desaulniers, Bill Wendling, Justin Stitt,
netdev, linux-kselftest, linux-kernel, llvm, wakel
The `__WORDSIZE` macro, defined in the non-standard `<bits/wordsize.h>`
header, is a GNU extension and not universally available with all
toolchains, such as Clang when used with musl libc.
This can lead to build failures in environments where this header is
missing.
The intention of the code is to determine the bit width of a C `long`.
Replace the non-portable `__WORDSIZE` with the standard and portable
`sizeof(long) * 8` expression to achieve the same result.
This change also removes the inclusion of the now-unused
`<bits/wordsize.h>` header.
Signed-off-by: Wake Liu <wakel@google.com>
---
tools/testing/selftests/net/psock_tpacket.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/psock_tpacket.c b/tools/testing/selftests/net/psock_tpacket.c
index 221270cee3ea..0dd909e325d9 100644
--- a/tools/testing/selftests/net/psock_tpacket.c
+++ b/tools/testing/selftests/net/psock_tpacket.c
@@ -33,7 +33,6 @@
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
-#include <bits/wordsize.h>
#include <net/ethernet.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
@@ -785,7 +784,7 @@ static int test_kernel_bit_width(void)
static int test_user_bit_width(void)
{
- return __WORDSIZE;
+ return sizeof(long) * 8;
}
static const char *tpacket_str[] = {
--
2.50.1.703.g449372360f-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8
2025-08-07 8:09 [PATCH] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8 Wake Liu
@ 2025-08-12 3:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-12 3:20 UTC (permalink / raw)
To: Wake Liu
Cc: davem, edumazet, kuba, pabeni, shuah, nathan, horms,
nick.desaulniers+lkml, morbo, justinstitt, netdev,
linux-kselftest, linux-kernel, llvm
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 7 Aug 2025 16:09:32 +0800 you wrote:
> The `__WORDSIZE` macro, defined in the non-standard `<bits/wordsize.h>`
> header, is a GNU extension and not universally available with all
> toolchains, such as Clang when used with musl libc.
>
> This can lead to build failures in environments where this header is
> missing.
>
> [...]
Here is the summary with links:
- selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8
https://git.kernel.org/netdev/net-next/c/c36748e8733e
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-12 3:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-07 8:09 [PATCH] selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8 Wake Liu
2025-08-12 3:20 ` patchwork-bot+netdevbpf
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).