Commit c36748e8 authored by Wake Liu's avatar Wake Liu Committed by Jakub Kicinski
Browse files

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.

Signed-off-by: default avatarWake Liu <wakel@google.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 37816488
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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[] = {