From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Stanislav Fomichev <sdf@fomichev.me>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>,
Eric Dumazet <edumazet@google.com>,
netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: Re: [PATCH] tcp: don't use __constant_cpu_to_be32
Date: Sat, 16 Mar 2019 23:26:46 +0900 [thread overview]
Message-ID: <20190316142646.GA10815@tigerII.localdomain> (raw)
In-Reply-To: <20190316051902.GA27630@tigerII.localdomain>
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__ */
next prev parent reply other threads:[~2019-03-16 14:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-14 6:15 [PATCH] tcp: don't use __constant_cpu_to_be32 Sergey Senozhatsky
2019-03-14 12:42 ` Eric Dumazet
2019-03-15 1:20 ` Sergey Senozhatsky
2019-03-15 17:24 ` Stanislav Fomichev
2019-03-16 5:19 ` Sergey Senozhatsky
2019-03-16 7:18 ` Sergey Senozhatsky
2019-03-16 14:26 ` Sergey Senozhatsky [this message]
2019-03-18 16:32 ` Stanislav Fomichev
2019-03-19 1:29 ` Sergey Senozhatsky
2019-03-18 16:28 ` Stanislav Fomichev
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=20190316142646.GA10815@tigerII.localdomain \
--to=sergey.senozhatsky@gmail.com \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=sergey.senozhatsky.work@gmail.com \
/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).