Skip to contentSkip to conversation

selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8

PATCH Applied Wake Liu 2 participants 2 messages Aug 7, 2025 – Aug 12, 2025

Subsystems (3)
lore
Share & tools
lore

Wake Liu

author
#0 lore raw

PATCH 1/1 selftests/net: Replace non-standard __WORDSIZE with sizeof(long) * 8

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.

---
 tools/testing/selftests/net/psock_tpacket.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/testing/selftests/net/psock_tpacket.c +1 -2
index 221270cee3ea..0dd909e325d9 100644
@@ -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[] = {
Signature · 1 line
2.50.1.703.g449372360f-goog
#1 lore raw
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · 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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html