lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 30 May 2019 19:50:40 +0900
From:   Masahiro Yamada <yamada.masahiro@...ionext.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     X86 ML <x86@...nel.org>, Linux-sh list <linux-sh@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86,sh: use __builtin_constant_p() directly instead of IS_IMMEDIATE()

Hi Andrew,

On Fri, May 3, 2019 at 9:48 PM Masahiro Yamada
<yamada.masahiro@...ionext.com> wrote:
>
> __builtin_constant_p(nr) is used everywhere now. It does not make
> much sense to define IS_IMMEDIATE() as its alias.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>

Ping. Is this a good clean-up?

Thanks.

> ---
>
>  arch/sh/include/asm/bitops-op32.h | 8 +++-----
>  arch/x86/include/asm/bitops.h     | 7 +++----
>  2 files changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/arch/sh/include/asm/bitops-op32.h b/arch/sh/include/asm/bitops-op32.h
> index 4668803..cfe5465 100644
> --- a/arch/sh/include/asm/bitops-op32.h
> +++ b/arch/sh/include/asm/bitops-op32.h
> @@ -16,11 +16,9 @@
>  #define BYTE_OFFSET(nr)                ((nr) % BITS_PER_BYTE)
>  #endif
>
> -#define IS_IMMEDIATE(nr)       (__builtin_constant_p(nr))
> -
>  static inline void __set_bit(int nr, volatile unsigned long *addr)
>  {
> -       if (IS_IMMEDIATE(nr)) {
> +       if (__builtin_constant_p(nr)) {
>                 __asm__ __volatile__ (
>                         "bset.b %1, @(%O2,%0)           ! __set_bit\n\t"
>                         : "+r" (addr)
> @@ -37,7 +35,7 @@ static inline void __set_bit(int nr, volatile unsigned long *addr)
>
>  static inline void __clear_bit(int nr, volatile unsigned long *addr)
>  {
> -       if (IS_IMMEDIATE(nr)) {
> +       if (__builtin_constant_p(nr)) {
>                 __asm__ __volatile__ (
>                         "bclr.b %1, @(%O2,%0)           ! __clear_bit\n\t"
>                         : "+r" (addr)
> @@ -64,7 +62,7 @@ static inline void __clear_bit(int nr, volatile unsigned long *addr)
>   */
>  static inline void __change_bit(int nr, volatile unsigned long *addr)
>  {
> -       if (IS_IMMEDIATE(nr)) {
> +       if (__builtin_constant_p(nr)) {
>                 __asm__ __volatile__ (
>                         "bxor.b %1, @(%O2,%0)           ! __change_bit\n\t"
>                         : "+r" (addr)
> diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
> index 8e790ec..2621438 100644
> --- a/arch/x86/include/asm/bitops.h
> +++ b/arch/x86/include/asm/bitops.h
> @@ -45,7 +45,6 @@
>   * We do the locked ops that don't return the old value as
>   * a mask operation on a byte.
>   */
> -#define IS_IMMEDIATE(nr)               (__builtin_constant_p(nr))
>  #define CONST_MASK_ADDR(nr, addr)      WBYTE_ADDR((void *)(addr) + ((nr)>>3))
>  #define CONST_MASK(nr)                 (1 << ((nr) & 7))
>
> @@ -67,7 +66,7 @@
>  static __always_inline void
>  set_bit(long nr, volatile unsigned long *addr)
>  {
> -       if (IS_IMMEDIATE(nr)) {
> +       if (__builtin_constant_p(nr)) {
>                 asm volatile(LOCK_PREFIX "orb %1,%0"
>                         : CONST_MASK_ADDR(nr, addr)
>                         : "iq" ((u8)CONST_MASK(nr))
> @@ -105,7 +104,7 @@ static __always_inline void __set_bit(long nr, volatile unsigned long *addr)
>  static __always_inline void
>  clear_bit(long nr, volatile unsigned long *addr)
>  {
> -       if (IS_IMMEDIATE(nr)) {
> +       if (__builtin_constant_p(nr)) {
>                 asm volatile(LOCK_PREFIX "andb %1,%0"
>                         : CONST_MASK_ADDR(nr, addr)
>                         : "iq" ((u8)~CONST_MASK(nr)));
> @@ -186,7 +185,7 @@ static __always_inline void __change_bit(long nr, volatile unsigned long *addr)
>   */
>  static __always_inline void change_bit(long nr, volatile unsigned long *addr)
>  {
> -       if (IS_IMMEDIATE(nr)) {
> +       if (__builtin_constant_p(nr)) {
>                 asm volatile(LOCK_PREFIX "xorb %1,%0"
>                         : CONST_MASK_ADDR(nr, addr)
>                         : "iq" ((u8)CONST_MASK(nr)));
> --
> 2.7.4
>


-- 
Best Regards
Masahiro Yamada

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ