All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: Shuah Khan <shuah@kernel.org>, Alexei Starovoitov <ast@kernel.org>
Cc: Stanislav Fomichev <sdf@google.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
	bpf@vger.kernel.org,
	Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Subject: [PATCHv2 bpf-next 2/3] bpf, tests: drop unused __bpf_constant_foo defines
Date: Wed, 20 Mar 2019 21:53:34 +0900	[thread overview]
Message-ID: <20190320125335.19621-2-sergey.senozhatsky@gmail.com> (raw)
In-Reply-To: <20190320125335.19621-1-sergey.senozhatsky@gmail.com>

Additionally, simplify bpf_ntohs/bpf_ntohl/bpf_htons/bpf_htonl
by switching to UAPI swab().

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 tools/testing/selftests/bpf/bpf_endian.h | 37 +++++-------------------
 1 file changed, 8 insertions(+), 29 deletions(-)

diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h
index 1ed268b2002b..ba06222963d5 100644
--- a/tools/testing/selftests/bpf/bpf_endian.h
+++ b/tools/testing/selftests/bpf/bpf_endian.h
@@ -20,38 +20,17 @@
  * use different targets.
  */
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-# define __bpf_ntohs(x)			__swab16(x)
-# define __bpf_htons(x)			__swab16(x)
-# define __bpf_constant_ntohs(x)	___constant_swab16(x)
-# define __bpf_constant_htons(x)	___constant_swab16(x)
-# define __bpf_ntohl(x)			__swab32(x)
-# define __bpf_htonl(x)			__swab32(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)
+# define bpf_ntohs(x)		(x)
+# define bpf_htons(x)		(x)
+# define bpf_ntohl(x)		(x)
+# define bpf_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))
-
 #endif /* __BPF_ENDIAN__ */
-- 
2.21.0


WARNING: multiple messages have this Message-ID (diff)
From: sergey.senozhatsky at gmail.com (Sergey Senozhatsky)
Subject: [PATCHv2 bpf-next 2/3] bpf, tests: drop unused __bpf_constant_foo defines
Date: Wed, 20 Mar 2019 21:53:34 +0900	[thread overview]
Message-ID: <20190320125335.19621-2-sergey.senozhatsky@gmail.com> (raw)
In-Reply-To: <20190320125335.19621-1-sergey.senozhatsky@gmail.com>

Additionally, simplify bpf_ntohs/bpf_ntohl/bpf_htons/bpf_htonl
by switching to UAPI swab().

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky at gmail.com>
---
 tools/testing/selftests/bpf/bpf_endian.h | 37 +++++-------------------
 1 file changed, 8 insertions(+), 29 deletions(-)

diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h
index 1ed268b2002b..ba06222963d5 100644
--- a/tools/testing/selftests/bpf/bpf_endian.h
+++ b/tools/testing/selftests/bpf/bpf_endian.h
@@ -20,38 +20,17 @@
  * use different targets.
  */
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-# define __bpf_ntohs(x)			__swab16(x)
-# define __bpf_htons(x)			__swab16(x)
-# define __bpf_constant_ntohs(x)	___constant_swab16(x)
-# define __bpf_constant_htons(x)	___constant_swab16(x)
-# define __bpf_ntohl(x)			__swab32(x)
-# define __bpf_htonl(x)			__swab32(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)
+# define bpf_ntohs(x)		(x)
+# define bpf_htons(x)		(x)
+# define bpf_ntohl(x)		(x)
+# define bpf_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))
-
 #endif /* __BPF_ENDIAN__ */
-- 
2.21.0

WARNING: multiple messages have this Message-ID (diff)
From: sergey.senozhatsky@gmail.com (Sergey Senozhatsky)
Subject: [PATCHv2 bpf-next 2/3] bpf, tests: drop unused __bpf_constant_foo defines
Date: Wed, 20 Mar 2019 21:53:34 +0900	[thread overview]
Message-ID: <20190320125335.19621-2-sergey.senozhatsky@gmail.com> (raw)
Message-ID: <20190320125334.Gwze4pfzxkp_SAPcC3KMw_wYwNT_vILmrdsekrThLz8@z> (raw)
In-Reply-To: <20190320125335.19621-1-sergey.senozhatsky@gmail.com>

Additionally, simplify bpf_ntohs/bpf_ntohl/bpf_htons/bpf_htonl
by switching to UAPI swab().

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky at gmail.com>
---
 tools/testing/selftests/bpf/bpf_endian.h | 37 +++++-------------------
 1 file changed, 8 insertions(+), 29 deletions(-)

diff --git a/tools/testing/selftests/bpf/bpf_endian.h b/tools/testing/selftests/bpf/bpf_endian.h
index 1ed268b2002b..ba06222963d5 100644
--- a/tools/testing/selftests/bpf/bpf_endian.h
+++ b/tools/testing/selftests/bpf/bpf_endian.h
@@ -20,38 +20,17 @@
  * use different targets.
  */
 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
-# define __bpf_ntohs(x)			__swab16(x)
-# define __bpf_htons(x)			__swab16(x)
-# define __bpf_constant_ntohs(x)	___constant_swab16(x)
-# define __bpf_constant_htons(x)	___constant_swab16(x)
-# define __bpf_ntohl(x)			__swab32(x)
-# define __bpf_htonl(x)			__swab32(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)
+# define bpf_ntohs(x)		(x)
+# define bpf_htons(x)		(x)
+# define bpf_ntohl(x)		(x)
+# define bpf_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))
-
 #endif /* __BPF_ENDIAN__ */
-- 
2.21.0

  reply	other threads:[~2019-03-20 12:53 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 12:53 [PATCHv2 bpf-next 1/3] bpf, tests: tweak endianness selection Sergey Senozhatsky
2019-03-20 12:53 ` Sergey Senozhatsky
2019-03-20 12:53 ` sergey.senozhatsky
2019-03-20 12:53 ` Sergey Senozhatsky [this message]
2019-03-20 12:53   ` [PATCHv2 bpf-next 2/3] bpf, tests: drop unused __bpf_constant_foo defines Sergey Senozhatsky
2019-03-20 12:53   ` sergey.senozhatsky
2019-03-20 12:56   ` Sergey Senozhatsky
2019-03-20 12:56     ` Sergey Senozhatsky
2019-03-20 12:56     ` sergey.senozhatsky
2019-03-20 12:53 ` [PATCHv2 bpf-next 3/3] bpf, tests: don't use __bpf_constant_htons() Sergey Senozhatsky
2019-03-20 12:53   ` Sergey Senozhatsky
2019-03-20 12:53   ` sergey.senozhatsky
2019-03-20 12:55   ` Sergey Senozhatsky
2019-03-20 12:55     ` Sergey Senozhatsky
2019-03-20 12:55     ` sergey.senozhatsky
2019-03-20 17:13 ` [PATCHv2 bpf-next 1/3] bpf, tests: tweak endianness selection Stanislav Fomichev
2019-03-20 17:13   ` Stanislav Fomichev
2019-03-20 17:13   ` sdf
2019-03-20 22:20   ` Yonghong Song
2019-03-20 22:20     ` Yonghong Song
2019-03-20 22:20     ` yhs
2019-03-20 22:27     ` Stanislav Fomichev
2019-03-20 22:27       ` Stanislav Fomichev
2019-03-20 22:27       ` sdf
2019-03-20 22:45       ` Yonghong Song
2019-03-20 22:45         ` Yonghong Song
2019-03-20 22:45         ` yhs
2019-03-20 23:08         ` Daniel Borkmann
2019-03-20 23:08           ` Daniel Borkmann
2019-03-20 23:08           ` daniel
2019-03-21  0:03           ` Stanislav Fomichev
2019-03-21  0:03             ` Stanislav Fomichev
2019-03-21  0:03             ` sdf
2019-03-21  0:23             ` Yonghong Song
2019-03-21  0:23               ` Yonghong Song
2019-03-21  0:23               ` yhs
2019-03-21  0:34       ` Sergey Senozhatsky
2019-03-21  0:34         ` Sergey Senozhatsky
2019-03-21  0:34         ` sergey.senozhatsky.work
2019-03-21  0:22   ` Sergey Senozhatsky
2019-03-21  0:22     ` Sergey Senozhatsky
2019-03-21  0:22     ` sergey.senozhatsky.work
2019-03-21  3:24 ` Alexei Starovoitov
2019-03-21  3:24   ` Alexei Starovoitov
2019-03-21  3:24   ` alexei.starovoitov
2019-03-21  5:08   ` Sergey Senozhatsky
2019-03-21  5:08     ` Sergey Senozhatsky
2019-03-21  5:08     ` sergey.senozhatsky.work
2019-03-21 15:49     ` Stanislav Fomichev
2019-03-21 15:49       ` Stanislav Fomichev
2019-03-21 15:49       ` sdf
2019-03-22  2:46       ` Sergey Senozhatsky
2019-03-22  2:46         ` Sergey Senozhatsky
2019-03-22  2:46         ` sergey.senozhatsky.work
2019-03-22  3:12         ` Alexei Starovoitov
2019-03-22  3:12           ` Alexei Starovoitov
2019-03-22  3:12           ` alexei.starovoitov

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=20190320125335.19621-2-sergey.senozhatsky@gmail.com \
    --to=sergey.senozhatsky@gmail.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=shuah@kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.