linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc.
@ 2017-01-05  2:20 Masahiro Yamada
  2017-01-05  2:20 ` [PATCH v2 1/4] m68k: rename UL() to TO_UL() Masahiro Yamada
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Masahiro Yamada @ 2017-01-05  2:20 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,
	Pratyush Anand, Ard Biesheuvel, James Morse, Nicolas Pitre,
	linux-m68k, Guan Xuetao, Shaohua Li, Alexander Popov,
	Guoqing Jiang, linux-kernel, Santosh Shilimkar, 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 the 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.


Changes in v2:
  - Split out as a prerequisite patch

Masahiro Yamada (4):
  m68k: rename UL() to TO_UL()
  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] 9+ messages in thread

* [PATCH v2 1/4] m68k: rename UL() to TO_UL()
  2017-01-05  2:20 [PATCH v2 0/4] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
@ 2017-01-05  2:20 ` Masahiro Yamada
  2017-01-05  2:20 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Masahiro Yamada @ 2017-01-05  2:20 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,
	linux-m68k, linux-kernel

ARM, ARM64 and UniCore32 define UL(x) like follows:

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

While, M68K defines it differently:
  #define UL(x) ((unsigned long) (x))

I am moving the former to a common header in the next commit.
Beforehand, this commit renames the latter to avoid name conflict.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
---

Changes in v2:
  - Split out as a prerequisite patch

 arch/m68k/mm/init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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"
-- 
2.7.4

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

* [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h
  2017-01-05  2:20 [PATCH v2 0/4] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
  2017-01-05  2:20 ` [PATCH v2 1/4] m68k: rename UL() to TO_UL() Masahiro Yamada
@ 2017-01-05  2:20 ` Masahiro Yamada
  2017-01-05 11:18   ` Catalin Marinas
  2017-01-05 11:24   ` Russell King - ARM Linux
  2017-01-05  2:20 ` [PATCH v2 3/4] linux/const.h: refactor _BITUL and _BITULL a bit Masahiro Yamada
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 9+ messages in thread
From: Masahiro Yamada @ 2017-01-05  2:20 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, Alexander Popov,
	Neeraj Upadhyay, James Morse, linux-kernel, Santosh Shilimkar,
	Laura Abbott, Guan Xuetao, Nicolas Pitre, Pratyush Anand,
	Ard Biesheuvel

ARM, ARM64 and UniCore32 duplicate 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(), _ULL() and ULL() because _AC() is mostly
used in the form either _AC(..., UL) or _AC(..., ULL).  I expect
they will be replaced in later cleanups.  The underscore-prefixed
ones should be used for exported headers.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
---

Changes in v2: None

 arch/arm/include/asm/memory.h       | 6 ------
 arch/arm64/include/asm/memory.h     | 6 ------
 arch/unicore32/include/asm/memory.h | 6 ------
 include/linux/const.h               | 9 +++++++++
 include/uapi/linux/const.h          | 9 ++++++---
 5 files changed, 15 insertions(+), 21 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/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] 9+ messages in thread

* [PATCH v2 3/4] linux/const.h: refactor _BITUL and _BITULL a bit
  2017-01-05  2:20 [PATCH v2 0/4] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
  2017-01-05  2:20 ` [PATCH v2 1/4] m68k: rename UL() to TO_UL() Masahiro Yamada
  2017-01-05  2:20 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
@ 2017-01-05  2:20 ` Masahiro Yamada
  2017-01-05  2:20 ` [PATCH v2 4/4] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly Masahiro Yamada
  2017-01-06 10:45 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h David Howells
  4 siblings, 0 replies; 9+ messages in thread
From: Masahiro Yamada @ 2017-01-05  2:20 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, Guan Xuetao, linux-kernel

Minor cleanups available by _UL and _ULL.

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

Changes in v2: None

 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] 9+ messages in thread

* [PATCH v2 4/4] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly
  2017-01-05  2:20 [PATCH v2 0/4] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
                   ` (2 preceding siblings ...)
  2017-01-05  2:20 ` [PATCH v2 3/4] linux/const.h: refactor _BITUL and _BITULL a bit Masahiro Yamada
@ 2017-01-05  2:20 ` Masahiro Yamada
  2017-01-06 10:45 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h David Howells
  4 siblings, 0 replies; 9+ messages in thread
From: Masahiro Yamada @ 2017-01-05  2:20 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, Guan Xuetao, 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>
---

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 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] 9+ messages in thread

* Re: [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h
  2017-01-05  2:20 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
@ 2017-01-05 11:18   ` Catalin Marinas
  2017-01-05 11:24   ` Russell King - ARM Linux
  1 sibling, 0 replies; 9+ messages in thread
From: Catalin Marinas @ 2017-01-05 11:18 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Andrew Morton, Mark Rutland, Nicolas Pitre, Srinivas Pandruvada,
	Will Deacon, David Howells, H . Peter Anvin, Guan Xuetao,
	Pratyush Anand, x86, Russell King, Ingo Molnar, Laura Abbott,
	Neeraj Upadhyay, Alexander Popov, Arnd Bergmann,
	Santosh Shilimkar, Thomas Gleixner, linux-arm-kernel,
	Ard Biesheuvel, linux-kernel, James Morse, Olof Johansson

> 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.
>   */

For the arm64 bit:

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

* Re: [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h
  2017-01-05  2:20 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
  2017-01-05 11:18   ` Catalin Marinas
@ 2017-01-05 11:24   ` Russell King - ARM Linux
  1 sibling, 0 replies; 9+ messages in thread
From: Russell King - ARM Linux @ 2017-01-05 11:24 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Andrew Morton, Mark Rutland, Nicolas Pitre, Catalin Marinas,
	Srinivas Pandruvada, Will Deacon, David Howells, H . Peter Anvin,
	Guan Xuetao, Pratyush Anand, x86, Ingo Molnar, Laura Abbott,
	Neeraj Upadhyay, Alexander Popov, Arnd Bergmann,
	Santosh Shilimkar, Thomas Gleixner, linux-arm-kernel,
	Ard Biesheuvel, linux-kernel, James Morse, Olof Johansson

On Thu, Jan 05, 2017 at 11:20:07AM +0900, Masahiro Yamada wrote:
> ARM, ARM64 and UniCore32 duplicate 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(), _ULL() and ULL() because _AC() is mostly
> used in the form either _AC(..., UL) or _AC(..., ULL).  I expect
> they will be replaced in later cleanups.  The underscore-prefixed
> ones should be used for exported headers.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
> ---
> 
> Changes in v2: None
> 
>  arch/arm/include/asm/memory.h       | 6 ------
>  arch/arm64/include/asm/memory.h     | 6 ------
>  arch/unicore32/include/asm/memory.h | 6 ------
>  include/linux/const.h               | 9 +++++++++
>  include/uapi/linux/const.h          | 9 ++++++---
>  5 files changed, 15 insertions(+), 21 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)
>  

For ARM,

Acked-by: Russell King <rmk+kernel@armlinux.org.uk>

Thanks.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

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

* Re: [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h
  2017-01-05  2:20 [PATCH v2 0/4] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
                   ` (3 preceding siblings ...)
  2017-01-05  2:20 ` [PATCH v2 4/4] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly Masahiro Yamada
@ 2017-01-06 10:45 ` David Howells
  2017-01-08  6:27   ` Masahiro Yamada
  4 siblings, 1 reply; 9+ messages in thread
From: David Howells @ 2017-01-06 10:45 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: dhowells, Andrew Morton, H . Peter Anvin, Arnd Bergmann, x86,
	Thomas Gleixner, Russell King, Srinivas Pandruvada, Ingo Molnar,
	Will Deacon, Mark Rutland, Olof Johansson, Catalin Marinas,
	linux-arm-kernel, Alexander Popov, Neeraj Upadhyay, James Morse,
	linux-kernel, Santosh Shilimkar, Laura Abbott, Guan Xuetao,
	Nicolas Pitre, Pratyush Anand, Ard Biesheuvel

Masahiro Yamada <yamada.masahiro@socionext.com> wrote:

> 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

You need to be very careful doing this.  Some userspace stuff depends on the
guard macro names on the kernel header files.

>  /* 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))

How likely is this to collide with existing userspace code somewhere?  It
looks like the sort of thing that could collide with a C library.

David

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

* Re: [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h
  2017-01-06 10:45 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h David Howells
@ 2017-01-08  6:27   ` Masahiro Yamada
  0 siblings, 0 replies; 9+ messages in thread
From: Masahiro Yamada @ 2017-01-08  6:27 UTC (permalink / raw)
  To: David Howells, Andrew Morton
  Cc: H . Peter Anvin, Arnd Bergmann, X86 ML, Thomas Gleixner,
	Russell King, Srinivas Pandruvada, Ingo Molnar, Will Deacon,
	Mark Rutland, Olof Johansson, Catalin Marinas, linux-arm-kernel,
	Alexander Popov, Neeraj Upadhyay, James Morse,
	Linux Kernel Mailing List, Santosh Shilimkar, Laura Abbott,
	Guan Xuetao, Nicolas Pitre, Pratyush Anand, Ard Biesheuvel

Hi.

2017-01-06 19:45 GMT+09:00 David Howells <dhowells@redhat.com>:
> Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>
>> 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
>
> You need to be very careful doing this.  Some userspace stuff depends on the
> guard macro names on the kernel header files.

Oh...

>>  /* 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))
>
> How likely is this to collide with existing userspace code somewhere?  It
> looks like the sort of thing that could collide with a C library.

Sorry, I do not have enough insight to answer your questions.


Andrew,
If this seems dangerous, please feel free to drop the entire series
because it is not adding any value except some cleanups.



-- 
Best Regards
Masahiro Yamada

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

end of thread, other threads:[~2017-01-08  6:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-05  2:20 [PATCH v2 0/4] linux/const.h: cleanups of macros such as UL(), _BITUL(), BIT() etc Masahiro Yamada
2017-01-05  2:20 ` [PATCH v2 1/4] m68k: rename UL() to TO_UL() Masahiro Yamada
2017-01-05  2:20 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h Masahiro Yamada
2017-01-05 11:18   ` Catalin Marinas
2017-01-05 11:24   ` Russell King - ARM Linux
2017-01-05  2:20 ` [PATCH v2 3/4] linux/const.h: refactor _BITUL and _BITULL a bit Masahiro Yamada
2017-01-05  2:20 ` [PATCH v2 4/4] linux/const.h: move BIT(_ULL) to linux/const.h for use in assembly Masahiro Yamada
2017-01-06 10:45 ` [PATCH v2 2/4] linux/const.h: move UL() macro to include/linux/const.h David Howells
2017-01-08  6:27   ` 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).