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] [thread-next>] [day] [month] [year] [list]
Message-ID: <48904284-14d7-45c2-cf41-0c0b311ccf7e@infradead.org>
Date:   Fri, 6 Jul 2018 10:48:55 -0700
From:   Randy Dunlap <rdunlap@...radead.org>
To:     Chris Wilson <chris@...is-wilson.co.uk>,
        linux-kernel@...r.kernel.org
Cc:     Jani Nikula <jani.nikula@...ux.intel.com>,
        Andy Gospodarek <gospo@...adcom.com>,
        "David S . Miller" <davem@...emloft.net>,
        Thomas Gleixner <tglx@...utronix.de>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH] bitops: Introduce BITS_PER_TYPE

On 07/06/18 02:44, Chris Wilson wrote:
> net_dim.h has a rather useful extension to BITS_PER_BYTE to compute the
> number of bits in a type (BITS_PER_BYTE * sizeof(T)), so promote the
> macro to bitops.h, alongside BITS_PER_BYTE, for wider usage.
> 
> Signed-off-by: Chris Wilson <chris@...is-wilson.co.uk>
> Cc: Jani Nikula <jani.nikula@...ux.intel.com>
> Cc: Andy Gospodarek <gospo@...adcom.com>
> Cc: David S. Miller <davem@...emloft.net>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> Cc: Ingo Molnar <mingo@...nel.org>
> ---
>  include/linux/bitops.h  | 3 ++-
>  include/linux/net_dim.h | 1 -
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index 4cac4e1a72ff..091cb17d1a9b 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -11,7 +11,8 @@
>  #define BIT_ULL_MASK(nr)	(1ULL << ((nr) % BITS_PER_LONG_LONG))
>  #define BIT_ULL_WORD(nr)	((nr) / BITS_PER_LONG_LONG)
>  #define BITS_PER_BYTE		8
> -#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
> +#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
> +#define BITS_TO_LONGS(nr)	DIV_ROUND_UP(nr, BITS_PER_TYPE(long))
>  #endif
>  
>  /*

doesn't <linux/net_dim.h> need to #include <linux/bitops.h> ?


> diff --git a/include/linux/net_dim.h b/include/linux/net_dim.h
> index 29ed8fd6379a..14f1734e740a 100644
> --- a/include/linux/net_dim.h
> +++ b/include/linux/net_dim.h
> @@ -326,7 +326,6 @@ static inline void net_dim_sample(u16 event_ctr,
>  }
>  
>  #define NET_DIM_NEVENTS 64
> -#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
>  #define BIT_GAP(bits, end, start) ((((end) - (start)) + BIT_ULL(bits)) & (BIT_ULL(bits) - 1))
>  
>  static inline void net_dim_calc_stats(struct net_dim_sample *start,
> 


-- 
~Randy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ