linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc.
@ 2017-01-04  8:55 Masahiro Yamada
  2017-01-04  8:55 ` [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Masahiro Yamada @ 2017-01-04  8:55 UTC (permalink / raw)
  To: Andrew Morton
  Cc: H . Peter Anvin, Arnd Bergmann, David Howells, x86,
	Thomas Gleixner, Russell King, Srinivas Pandruvada, Ingo Molnar,
	Will Deacon, Mark Rutland, Olof Johansson, Catalin Marinas,
	linux-arm-kernel, Masahiro Yamada, Geert Uytterhoeven,
	Ard Biesheuvel, James Morse, Nicolas Pitre, NeilBrown,
	linux-m68k, Guan Xuetao, Shaohua Li, Guoqing Jiang, linux-kernel,
	Santosh Shilimkar, Chris Brandt, zijun_hu, Laura Abbott,
	Neeraj Upadhyay


ARM, arm64, unicore32 define UL() as a shorthand of _AC(..., UL).
In the future, more architectures may introduce it, so move
the definition to include/linux/const.h.

The _AC() is used for either (likely) UL or (unlikely) ULL.
Having UL(L) in a common place can avoid direct use of _AC().

The _AC() is defined under uapi directory, so it compels
underscore-prefixed macros even for unexported headers.

I see similar situation for _BITUL().  This is available in
both C and assembly.  However, it is defined in an uapi header,
so direct use of the underscore macro is needed even for unexported
headers.  The 3/3 makes BIT() available in assembly too, which will
be more suitable for use in unexported headers.



Masahiro Yamada (3):
  linux/const.h: move UL() macro to include/linux/const.h
  linux/const.h: refactor _BITUL and _BITULL a bit
  linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly

 arch/arm/include/asm/memory.h       |  6 ------
 arch/arm64/include/asm/memory.h     |  6 ------
 arch/m68k/mm/init.c                 |  6 +++---
 arch/unicore32/include/asm/memory.h |  6 ------
 include/linux/bitops.h              |  3 +--
 include/linux/const.h               | 12 ++++++++++++
 include/uapi/linux/const.h          | 13 ++++++++-----
 7 files changed, 24 insertions(+), 28 deletions(-)
 create mode 100644 include/linux/const.h

-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h
  2017-01-04  8:55 [PATCH 0/3] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
@ 2017-01-04  8:55 ` Masahiro Yamada
  2017-01-04  9:27   ` Geert Uytterhoeven
  2017-01-05  1:42   ` Xuetao Guan
  2017-01-04  8:55 ` [PATCH 2/3] linux/const.h: refactor _BITUL and _BITULL a bit Masahiro Yamada
  2017-01-04  8:55 ` [PATCH 3/3] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly Masahiro Yamada
  2 siblings, 2 replies; 7+ messages in thread
From: Masahiro Yamada @ 2017-01-04  8:55 UTC (permalink / raw)
  To: Andrew Morton
  Cc: H . Peter Anvin, Arnd Bergmann, David Howells, x86,
	Thomas Gleixner, Russell King, Srinivas Pandruvada, Ingo Molnar,
	Will Deacon, Mark Rutland, Olof Johansson, Catalin Marinas,
	linux-arm-kernel, Masahiro Yamada, Chris Brandt, James Morse,
	linux-kernel, Santosh Shilimkar, Geert Uytterhoeven, linux-m68k,
	Laura Abbott, Guan Xuetao, Nicolas Pitre, Neeraj Upadhyay,
	Ard Biesheuvel

Some architectures are duplicating the definition of UL():

  #define UL(x) _AC(x, UL)

This is not actually arch-specific, so it will be useful to move it
to a common header.  Currently, we only have the uapi variant for
linux/const.h, so I am creating include/linux/const.h.

I am also adding _UL(x), _ULL(x), ULL(x) because _AC() is used for
UL in most places (and ULL in some places).  I expect _AC(..., UL)
will be replaced with _UL(...) or UL(...).  The underscore-prefixed
one should be used for exported headers.

Note:
I renamed UL(x) in arch/m68k/mm/init.c, where it is used for a
different meaning.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 arch/arm/include/asm/memory.h       | 6 ------
 arch/arm64/include/asm/memory.h     | 6 ------
 arch/m68k/mm/init.c                 | 6 +++---
 arch/unicore32/include/asm/memory.h | 6 ------
 include/linux/const.h               | 9 +++++++++
 include/uapi/linux/const.h          | 9 ++++++---
 6 files changed, 18 insertions(+), 24 deletions(-)
 create mode 100644 include/linux/const.h

diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 76cbd9c..7558247 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -22,12 +22,6 @@
 #include <mach/memory.h>
 #endif
 
-/*
- * Allow for constants defined here to be used from assembly code
- * by prepending the UL suffix only with actual C code compilation.
- */
-#define UL(x) _AC(x, UL)
-
 /* PAGE_OFFSET - the virtual address of the start of the kernel image */
 #define PAGE_OFFSET		UL(CONFIG_PAGE_OFFSET)
 
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h
index bfe6328..4310bcc 100644
--- a/arch/arm64/include/asm/memory.h
+++ b/arch/arm64/include/asm/memory.h
@@ -28,12 +28,6 @@
 #include <asm/sizes.h>
 
 /*
- * Allow for constants defined here to be used from assembly code
- * by prepending the UL suffix only with actual C code compilation.
- */
-#define UL(x) _AC(x, UL)
-
-/*
  * Size of the PCI I/O space. This must remain a power of two so that
  * IO_SPACE_LIMIT acts as a mask for the low bits of I/O addresses.
  */
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index 9c1e656..a625144 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -121,9 +121,9 @@ void free_initmem(void)
 
 void __init print_memmap(void)
 {
-#define UL(x) ((unsigned long) (x))
-#define MLK(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 10
-#define MLM(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 20
+#define TO_UL(x) ((unsigned long) (x))
+#define MLK(b, t) TO_UL(b), TO_UL(t), (TO_UL(t) - TO_UL(b)) >> 10
+#define MLM(b, t) TO_UL(b), TO_UL(t), (TO_UL(t) - TO_UL(b)) >> 20
 #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), 1024)
 
 	pr_notice("Virtual kernel memory layout:\n"
diff --git a/arch/unicore32/include/asm/memory.h b/arch/unicore32/include/asm/memory.h
index 3bb0a29..66bb9f6 100644
--- a/arch/unicore32/include/asm/memory.h
+++ b/arch/unicore32/include/asm/memory.h
@@ -20,12 +20,6 @@
 #include <mach/memory.h>
 
 /*
- * Allow for constants defined here to be used from assembly code
- * by prepending the UL suffix only with actual C code compilation.
- */
-#define UL(x) _AC(x, UL)
-
-/*
  * PAGE_OFFSET - the virtual address of the start of the kernel image
  * TASK_SIZE - the maximum size of a user space task.
  * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area
diff --git a/include/linux/const.h b/include/linux/const.h
new file mode 100644
index 0000000..7b55a55
--- /dev/null
+++ b/include/linux/const.h
@@ -0,0 +1,9 @@
+#ifndef _LINUX_CONST_H
+#define _LINUX_CONST_H
+
+#include <uapi/linux/const.h>
+
+#define UL(x)		(_UL(x))
+#define ULL(x)		(_ULL(x))
+
+#endif /* _LINUX_CONST_H */
diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h
index c872bfd..76fb0f9 100644
--- a/include/uapi/linux/const.h
+++ b/include/uapi/linux/const.h
@@ -1,7 +1,7 @@
 /* const.h: Macros for dealing with constants.  */
 
-#ifndef _LINUX_CONST_H
-#define _LINUX_CONST_H
+#ifndef _UAPI_LINUX_CONST_H
+#define _UAPI_LINUX_CONST_H
 
 /* Some constant macros are used in both assembler and
  * C code.  Therefore we cannot annotate them always with
@@ -21,7 +21,10 @@
 #define _AT(T,X)	((T)(X))
 #endif
 
+#define _UL(x)		(_AC(x, UL))
+#define _ULL(x)		(_AC(x, ULL))
+
 #define _BITUL(x)	(_AC(1,UL) << (x))
 #define _BITULL(x)	(_AC(1,ULL) << (x))
 
-#endif /* !(_LINUX_CONST_H) */
+#endif /* _UAPI_LINUX_CONST_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] linux/const.h: refactor _BITUL and _BITULL a bit
  2017-01-04  8:55 [PATCH 0/3] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
  2017-01-04  8:55 ` [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
@ 2017-01-04  8:55 ` Masahiro Yamada
  2017-01-04  8:55 ` [PATCH 3/3] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly Masahiro Yamada
  2 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2017-01-04  8:55 UTC (permalink / raw)
  To: Andrew Morton
  Cc: H . Peter Anvin, Arnd Bergmann, David Howells, x86,
	Thomas Gleixner, Russell King, Srinivas Pandruvada, Ingo Molnar,
	Will Deacon, Mark Rutland, Olof Johansson, Catalin Marinas,
	linux-arm-kernel, Masahiro Yamada, linux-kernel

Minor cleanups available by _UL and _ULL.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 include/uapi/linux/const.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h
index 76fb0f9..13e5165 100644
--- a/include/uapi/linux/const.h
+++ b/include/uapi/linux/const.h
@@ -24,7 +24,7 @@
 #define _UL(x)		(_AC(x, UL))
 #define _ULL(x)		(_AC(x, ULL))
 
-#define _BITUL(x)	(_AC(1,UL) << (x))
-#define _BITULL(x)	(_AC(1,ULL) << (x))
+#define _BITUL(x)	(_UL(1) << (x))
+#define _BITULL(x)	(_ULL(1) << (x))
 
 #endif /* _UAPI_LINUX_CONST_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly
  2017-01-04  8:55 [PATCH 0/3] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
  2017-01-04  8:55 ` [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
  2017-01-04  8:55 ` [PATCH 2/3] linux/const.h: refactor _BITUL and _BITULL a bit Masahiro Yamada
@ 2017-01-04  8:55 ` Masahiro Yamada
  2 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2017-01-04  8:55 UTC (permalink / raw)
  To: Andrew Morton
  Cc: H . Peter Anvin, Arnd Bergmann, David Howells, x86,
	Thomas Gleixner, Russell King, Srinivas Pandruvada, Ingo Molnar,
	Will Deacon, Mark Rutland, Olof Johansson, Catalin Marinas,
	linux-arm-kernel, Masahiro Yamada, Guoqing Jiang, linux-kernel,
	zijun_hu, NeilBrown, Shaohua Li

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 often used for "2. use in assembly",
while "1. use in uapi" is unneeded.  If we address only "2.", we can
improve the existing BIT() for that.  It will allow us to replace
many _BITUL() instances with BIT(), i.e. avoid needless use of
underscore-prefixed macros, in the end, for better de-couple of
userspace/kernel headers.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 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 a83c822..5f45fa5 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -1,10 +1,9 @@
 #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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h
  2017-01-04  8:55 ` [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
@ 2017-01-04  9:27   ` Geert Uytterhoeven
  2017-01-05  2:22     ` Masahiro Yamada
  2017-01-05  1:42   ` Xuetao Guan
  1 sibling, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2017-01-04  9:27 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Andrew Morton, Mark Rutland, Nicolas Pitre, Catalin Marinas,
	Srinivas Pandruvada, Will Deacon, David Howells, Chris Brandt,
	H . Peter Anvin, Guan Xuetao, the arch/x86 maintainers,
	Russell King, Ingo Molnar, Laura Abbott, Neeraj Upadhyay,
	Arnd Bergmann, linux-m68k, Santosh Shilimkar, Thomas Gleixner,
	linux-arm-kernel, Ard Biesheuvel, linux-kernel, James Morse,
	Olof Johansson

Hi Yamada-san,

On Wed, Jan 4, 2017 at 9:55 AM, Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
> Some architectures are duplicating the definition of UL():
>
>   #define UL(x) _AC(x, UL)
>
> This is not actually arch-specific, so it will be useful to move it
> to a common header.  Currently, we only have the uapi variant for
> linux/const.h, so I am creating include/linux/const.h.
>
> I am also adding _UL(x), _ULL(x), ULL(x) because _AC() is used for
> UL in most places (and ULL in some places).  I expect _AC(..., UL)
> will be replaced with _UL(...) or UL(...).  The underscore-prefixed
> one should be used for exported headers.
>
> Note:
> I renamed UL(x) in arch/m68k/mm/init.c, where it is used for a
> different meaning.

Shouldn't that be a separate (prerequisite) patch?

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  arch/arm/include/asm/memory.h       | 6 ------
>  arch/arm64/include/asm/memory.h     | 6 ------
>  arch/m68k/mm/init.c                 | 6 +++---
>  arch/unicore32/include/asm/memory.h | 6 ------
>  include/linux/const.h               | 9 +++++++++
>  include/uapi/linux/const.h          | 9 ++++++---
>  6 files changed, 18 insertions(+), 24 deletions(-)
>  create mode 100644 include/linux/const.h

For the m68k change:

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] linux/const.h: move UL() macro to  include/linux/const.h
  2017-01-04  8:55 ` [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
  2017-01-04  9:27   ` Geert Uytterhoeven
@ 2017-01-05  1:42   ` Xuetao Guan
  1 sibling, 0 replies; 7+ messages in thread
From: Xuetao Guan @ 2017-01-05  1:42 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Andrew Morton, H . Peter Anvin, Arnd Bergmann, David Howells,
	x86, Thomas Gleixner, Russell King, Srinivas Pandruvada,
	Ingo Molnar, Will Deacon, Mark Rutland, Olof Johansson,
	Catalin Marinas, linux-arm-kernel, Masahiro Yamada, Chris Brandt,
	James Morse, linux-kernel, Santosh Shilimkar, Geert Uytterhoeven,
	linux-m68k, Laura Abbott, Guan Xuetao, Nicolas Pitre,
	Neeraj Upadhyay, Ard Biesheuvel

> Some architectures are duplicating the definition of UL():
>
>   #define UL(x) _AC(x, UL)
>
> This is not actually arch-specific, so it will be useful to move it
> to a common header.  Currently, we only have the uapi variant for
> linux/const.h, so I am creating include/linux/const.h.
>
> I am also adding _UL(x), _ULL(x), ULL(x) because _AC() is used for
> UL in most places (and ULL in some places).  I expect _AC(..., UL)
> will be replaced with _UL(...) or UL(...).  The underscore-prefixed
> one should be used for exported headers.
>
> Note:
> I renamed UL(x) in arch/m68k/mm/init.c, where it is used for a
> different meaning.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  arch/arm/include/asm/memory.h       | 6 ------
>  arch/arm64/include/asm/memory.h     | 6 ------
>  arch/m68k/mm/init.c                 | 6 +++---
>  arch/unicore32/include/asm/memory.h | 6 ------
>  include/linux/const.h               | 9 +++++++++
>  include/uapi/linux/const.h          | 9 ++++++---
>  6 files changed, 18 insertions(+), 24 deletions(-)
>  create mode 100644 include/linux/const.h
>
> diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
> index 76cbd9c..7558247 100644
> --- a/arch/arm/include/asm/memory.h
> +++ b/arch/arm/include/asm/memory.h
> @@ -22,12 +22,6 @@
>  #include <mach/memory.h>
>  #endif
>
> -/*
> - * Allow for constants defined here to be used from assembly code
> - * by prepending the UL suffix only with actual C code compilation.
> - */
> -#define UL(x) _AC(x, UL)
> -
>  /* PAGE_OFFSET - the virtual address of the start of the kernel image */
>  #define PAGE_OFFSET		UL(CONFIG_PAGE_OFFSET)
>
> diff --git a/arch/arm64/include/asm/memory.h
> b/arch/arm64/include/asm/memory.h
> index bfe6328..4310bcc 100644
> --- a/arch/arm64/include/asm/memory.h
> +++ b/arch/arm64/include/asm/memory.h
> @@ -28,12 +28,6 @@
>  #include <asm/sizes.h>
>
>  /*
> - * Allow for constants defined here to be used from assembly code
> - * by prepending the UL suffix only with actual C code compilation.
> - */
> -#define UL(x) _AC(x, UL)
> -
> -/*
>   * Size of the PCI I/O space. This must remain a power of two so that
>   * IO_SPACE_LIMIT acts as a mask for the low bits of I/O addresses.
>   */
> diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
> index 9c1e656..a625144 100644
> --- a/arch/m68k/mm/init.c
> +++ b/arch/m68k/mm/init.c
> @@ -121,9 +121,9 @@ void free_initmem(void)
>
>  void __init print_memmap(void)
>  {
> -#define UL(x) ((unsigned long) (x))
> -#define MLK(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 10
> -#define MLM(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 20
> +#define TO_UL(x) ((unsigned long) (x))
> +#define MLK(b, t) TO_UL(b), TO_UL(t), (TO_UL(t) - TO_UL(b)) >> 10
> +#define MLM(b, t) TO_UL(b), TO_UL(t), (TO_UL(t) - TO_UL(b)) >> 20
>  #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), 1024)
>
>  	pr_notice("Virtual kernel memory layout:\n"
> diff --git a/arch/unicore32/include/asm/memory.h
> b/arch/unicore32/include/asm/memory.h
> index 3bb0a29..66bb9f6 100644
> --- a/arch/unicore32/include/asm/memory.h
> +++ b/arch/unicore32/include/asm/memory.h
> @@ -20,12 +20,6 @@
>  #include <mach/memory.h>
>
>  /*
> - * Allow for constants defined here to be used from assembly code
> - * by prepending the UL suffix only with actual C code compilation.
> - */
> -#define UL(x) _AC(x, UL)
> -
> -/*
>   * PAGE_OFFSET - the virtual address of the start of the kernel image
>   * TASK_SIZE - the maximum size of a user space task.
>   * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area

For UniCore32 codes:
Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>

Thanks.

Xuetao

> diff --git a/include/linux/const.h b/include/linux/const.h
> new file mode 100644
> index 0000000..7b55a55
> --- /dev/null
> +++ b/include/linux/const.h
> @@ -0,0 +1,9 @@
> +#ifndef _LINUX_CONST_H
> +#define _LINUX_CONST_H
> +
> +#include <uapi/linux/const.h>
> +
> +#define UL(x)		(_UL(x))
> +#define ULL(x)		(_ULL(x))
> +
> +#endif /* _LINUX_CONST_H */
> diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h
> index c872bfd..76fb0f9 100644
> --- a/include/uapi/linux/const.h
> +++ b/include/uapi/linux/const.h
> @@ -1,7 +1,7 @@
>  /* const.h: Macros for dealing with constants.  */
>
> -#ifndef _LINUX_CONST_H
> -#define _LINUX_CONST_H
> +#ifndef _UAPI_LINUX_CONST_H
> +#define _UAPI_LINUX_CONST_H
>
>  /* Some constant macros are used in both assembler and
>   * C code.  Therefore we cannot annotate them always with
> @@ -21,7 +21,10 @@
>  #define _AT(T,X)	((T)(X))
>  #endif
>
> +#define _UL(x)		(_AC(x, UL))
> +#define _ULL(x)		(_AC(x, ULL))
> +
>  #define _BITUL(x)	(_AC(1,UL) << (x))
>  #define _BITULL(x)	(_AC(1,ULL) << (x))
>
> -#endif /* !(_LINUX_CONST_H) */
> +#endif /* _UAPI_LINUX_CONST_H */
> --
> 2.7.4
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h
  2017-01-04  9:27   ` Geert Uytterhoeven
@ 2017-01-05  2:22     ` Masahiro Yamada
  0 siblings, 0 replies; 7+ messages in thread
From: Masahiro Yamada @ 2017-01-05  2:22 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Andrew Morton, Mark Rutland, Nicolas Pitre, Catalin Marinas,
	Srinivas Pandruvada, Will Deacon, David Howells, Chris Brandt,
	H . Peter Anvin, Guan Xuetao, the arch/x86 maintainers,
	Russell King, Ingo Molnar, Laura Abbott, Neeraj Upadhyay,
	Arnd Bergmann, linux-m68k, Santosh Shilimkar, Thomas Gleixner,
	linux-arm-kernel, Ard Biesheuvel, linux-kernel, James Morse,
	Olof Johansson

Hi Geert,

2017-01-04 18:27 GMT+09:00 Geert Uytterhoeven <geert@linux-m68k.org>:
> Hi Yamada-san,
>
> On Wed, Jan 4, 2017 at 9:55 AM, Masahiro Yamada
> <yamada.masahiro@socionext.com> wrote:
>> Some architectures are duplicating the definition of UL():
>>
>>   #define UL(x) _AC(x, UL)
>>
>> This is not actually arch-specific, so it will be useful to move it
>> to a common header.  Currently, we only have the uapi variant for
>> linux/const.h, so I am creating include/linux/const.h.
>>
>> I am also adding _UL(x), _ULL(x), ULL(x) because _AC() is used for
>> UL in most places (and ULL in some places).  I expect _AC(..., UL)
>> will be replaced with _UL(...) or UL(...).  The underscore-prefixed
>> one should be used for exported headers.
>>
>> Note:
>> I renamed UL(x) in arch/m68k/mm/init.c, where it is used for a
>> different meaning.
>
> Shouldn't that be a separate (prerequisite) patch?


Yes, I did so in v2.

Thanks!



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-01-05  2:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-04  8:55 [PATCH 0/3] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
2017-01-04  8:55 ` [PATCH 1/3] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
2017-01-04  9:27   ` Geert Uytterhoeven
2017-01-05  2:22     ` Masahiro Yamada
2017-01-05  1:42   ` Xuetao Guan
2017-01-04  8:55 ` [PATCH 2/3] linux/const.h: refactor _BITUL and _BITULL a bit Masahiro Yamada
2017-01-04  8:55 ` [PATCH 3/3] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly Masahiro Yamada

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).