Messages in this thread Patch in this message | | | From | Sergey Senozhatsky <> | Date | Sat, 16 Mar 2019 23:26:46 +0900 | Subject | Re: [PATCH] tcp: don't use __constant_cpu_to_be32 |
| |
On (03/16/19 14:19), Sergey Senozhatsky wrote: > # define __bpf_ntohs(x) __builtin_bswap16(x) > # define __bpf_htons(x) __builtin_bswap16(x) > > So I sort of suspect that what should have been done was that > __HAVE_BUILTIN_BSWAP16__ ifdef, just like what include/uapi/linux/swab.h > does.
E.g. use uapi __swab16/__swab32 in selftests/bpf/bpf_endian.h?
-=-=-=-=-=-
tools/testing/selftests/bpf/bpf_endian.h | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-)
diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h index b25595ea4a78..68789b4c7ef0 100644 --- a/tools/testing/selftests/bpf/bpf_endian.h +++ b/tools/testing/selftests/bpf/bpf_endian.h @@ -20,38 +20,22 @@ * use different targets. */ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define __bpf_ntohs(x) __builtin_bswap16(x) -# define __bpf_htons(x) __builtin_bswap16(x) -# define __bpf_constant_ntohs(x) ___constant_swab16(x) -# define __bpf_constant_htons(x) ___constant_swab16(x) -# define __bpf_ntohl(x) __builtin_bswap32(x) -# define __bpf_htonl(x) __builtin_bswap32(x) -# define __bpf_constant_ntohl(x) ___constant_swab32(x) -# define __bpf_constant_htonl(x) ___constant_swab32(x) +# define __bpf_ntohs(x) __swab16(x) +# define __bpf_htons(x) __swab16(x) +# define __bpf_ntohl(x) __swab32(x) +# define __bpf_htonl(x) __swab32(x) #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ # define __bpf_ntohs(x) (x) # define __bpf_htons(x) (x) -# define __bpf_constant_ntohs(x) (x) -# define __bpf_constant_htons(x) (x) # define __bpf_ntohl(x) (x) # define __bpf_htonl(x) (x) -# define __bpf_constant_ntohl(x) (x) -# define __bpf_constant_htonl(x) (x) #else # error "Fix your compiler's __BYTE_ORDER__?!" #endif -#define bpf_htons(x) \ - (__builtin_constant_p(x) ? \ - __bpf_constant_htons(x) : __bpf_htons(x)) -#define bpf_ntohs(x) \ - (__builtin_constant_p(x) ? \ - __bpf_constant_ntohs(x) : __bpf_ntohs(x)) -#define bpf_htonl(x) \ - (__builtin_constant_p(x) ? \ - __bpf_constant_htonl(x) : __bpf_htonl(x)) -#define bpf_ntohl(x) \ - (__builtin_constant_p(x) ? \ - __bpf_constant_ntohl(x) : __bpf_ntohl(x)) +#define bpf_htons(x) __bpf_htons((x)) +#define bpf_ntohs(x) __bpf_ntohs((x)) +#define bpf_htonl(x) __bpf_htonl((x)) +#define bpf_ntohl(x) __bpf_ntohl((x)) #endif /* __BPF_ENDIAN__ */
| |