All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Howells <dhowells@redhat.com>,
	linux-arm-kernel@lists.infradead.org,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v3 5/5] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly
Date: Thu, 22 Feb 2018 21:15:15 +0900	[thread overview]
Message-ID: <1519301715-31798-6-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1519301715-31798-1-git-send-email-yamada.masahiro@socionext.com>

Commit 2fc016c5bd8a ("linux/const.h: Add _BITUL() and _BITULL()")
introduced _BITUL() and _BITULL().  Its git-log says the difference
from the already existing BIT() are:

  1. The namespace is such that they can be used in uapi definitions.
  2. The type is set with the _AC() macro to allow it to be used in
     assembly.
  3. The type is explicitly specified to be UL or ULL.

However, I found _BITUL() is mostly used in kernel-space since it is
handy to share headers between C and assembly.  If we only need '2.',
we can improve the existing BIT() for use in assembly, allowing us to
avoid unnecessary underscore prefixes.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
V2: https://patchwork.kernel.org/patch/9498271/

Changes in v3: None
Changes in v2: None

 include/linux/bitops.h | 3 +--
 include/linux/const.h  | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 4cac4e1..8a856be 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -1,11 +1,10 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _LINUX_BITOPS_H
 #define _LINUX_BITOPS_H
+#include <linux/const.h>
 #include <asm/types.h>
 
 #ifdef	__KERNEL__
-#define BIT(nr)			(1UL << (nr))
-#define BIT_ULL(nr)		(1ULL << (nr))
 #define BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
 #define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
 #define BIT_ULL_MASK(nr)	(1ULL << ((nr) % BITS_PER_LONG_LONG))
diff --git a/include/linux/const.h b/include/linux/const.h
index 7b55a55..200892d 100644
--- a/include/linux/const.h
+++ b/include/linux/const.h
@@ -6,4 +6,7 @@
 #define UL(x)		(_UL(x))
 #define ULL(x)		(_ULL(x))
 
+#define BIT(x)		(_BITUL(x))
+#define BIT_ULL(x)	(_BITULL(x))
+
 #endif /* _LINUX_CONST_H */
-- 
2.7.4

WARNING: multiple messages have this Message-ID (diff)
From: yamada.masahiro@socionext.com (Masahiro Yamada)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 5/5] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly
Date: Thu, 22 Feb 2018 21:15:15 +0900	[thread overview]
Message-ID: <1519301715-31798-6-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1519301715-31798-1-git-send-email-yamada.masahiro@socionext.com>

Commit 2fc016c5bd8a ("linux/const.h: Add _BITUL() and _BITULL()")
introduced _BITUL() and _BITULL().  Its git-log says the difference
from the already existing BIT() are:

  1. The namespace is such that they can be used in uapi definitions.
  2. The type is set with the _AC() macro to allow it to be used in
     assembly.
  3. The type is explicitly specified to be UL or ULL.

However, I found _BITUL() is mostly used in kernel-space since it is
handy to share headers between C and assembly.  If we only need '2.',
we can improve the existing BIT() for use in assembly, allowing us to
avoid unnecessary underscore prefixes.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
V2: https://patchwork.kernel.org/patch/9498271/

Changes in v3: None
Changes in v2: None

 include/linux/bitops.h | 3 +--
 include/linux/const.h  | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 4cac4e1..8a856be 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -1,11 +1,10 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef _LINUX_BITOPS_H
 #define _LINUX_BITOPS_H
+#include <linux/const.h>
 #include <asm/types.h>
 
 #ifdef	__KERNEL__
-#define BIT(nr)			(1UL << (nr))
-#define BIT_ULL(nr)		(1ULL << (nr))
 #define BIT_MASK(nr)		(1UL << ((nr) % BITS_PER_LONG))
 #define BIT_WORD(nr)		((nr) / BITS_PER_LONG)
 #define BIT_ULL_MASK(nr)	(1ULL << ((nr) % BITS_PER_LONG_LONG))
diff --git a/include/linux/const.h b/include/linux/const.h
index 7b55a55..200892d 100644
--- a/include/linux/const.h
+++ b/include/linux/const.h
@@ -6,4 +6,7 @@
 #define UL(x)		(_UL(x))
 #define ULL(x)		(_ULL(x))
 
+#define BIT(x)		(_BITUL(x))
+#define BIT_ULL(x)	(_BITULL(x))
+
 #endif /* _LINUX_CONST_H */
-- 
2.7.4

  parent reply	other threads:[~2018-02-22 12:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-22 12:15 [PATCH v3 0/5] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
2018-02-22 12:15 ` Masahiro Yamada
2018-02-22 12:15 ` [PATCH v3 1/5] linux/const.h: prefix include guard of uapi/linux/const.h with _UAPI Masahiro Yamada
2018-02-22 12:15   ` Masahiro Yamada
2018-02-22 12:15 ` [PATCH v3 2/5] m68k: rename UL() to TO_UL() Masahiro Yamada
2018-02-22 12:15   ` Masahiro Yamada
2018-02-22 13:20   ` Geert Uytterhoeven
2018-02-22 13:20     ` Geert Uytterhoeven
2018-02-22 16:58     ` Masahiro Yamada
2018-02-22 16:58       ` Masahiro Yamada
2018-02-26  9:49       ` Geert Uytterhoeven
2018-02-26  9:49         ` Geert Uytterhoeven
2018-02-22 12:15 ` [PATCH v3 3/5] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
2018-02-22 12:15   ` Masahiro Yamada
2018-02-22 12:15 ` [PATCH v3 4/5] linux/const.h: refactor _BITUL and _BITULL a bit Masahiro Yamada
2018-02-22 12:15   ` Masahiro Yamada
2018-02-22 12:15 ` Masahiro Yamada [this message]
2018-02-22 12:15   ` [PATCH v3 5/5] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly Masahiro Yamada
2018-02-24  5:00   ` kbuild test robot
2018-02-24  5:00     ` kbuild test robot
2018-02-26  2:13     ` Masahiro Yamada
2018-02-26  2:13       ` Masahiro Yamada
2018-03-13  8:39   ` Masahiro Yamada
2018-03-13  8:39     ` Masahiro Yamada

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=1519301715-31798-6-git-send-email-yamada.masahiro@socionext.com \
    --to=yamada.masahiro@socionext.com \
    --cc=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /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.