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: <20070726035433.69146262.akpm@linux-foundation.org>
Date:	Thu, 26 Jul 2007 03:54:33 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Stephen Hemminger <shemminger@...ux-foundation.org>
Cc:	"David S. Miller" <davem@...emloft.net>,
	Adrian Bunk <bunk@...sta.de>,
	Robert Olsson <Robert.Olsson@...a.slu.se>,
	"Paul E. McKenney" <paulmck@...ux.vnet.ibm.com>,
	Ingo Molnar <mingo@...e.hu>, Josh Triplett <josh@...nel.org>,
	netdev@...r.kernel.org
Subject: Re: [RFT] fib_trie: macro cleanup

On Thu, 26 Jul 2007 11:43:34 +0100 Stephen Hemminger <shemminger@...ux-foundation.org> wrote:

> This patch converts the messy macro for MASK_PFX to inline function
> and expands TKEY_GET_MASK in the one place it is used.
> 
> 
> --- a/net/ipv4/fib_trie.c	2007-07-26 09:26:19.000000000 +0100
> +++ b/net/ipv4/fib_trie.c	2007-07-26 10:17:21.000000000 +0100
> @@ -85,8 +85,6 @@
>  #define MAX_STAT_DEPTH 32
>  
>  #define KEYLENGTH (8*sizeof(t_key))
> -#define MASK_PFX(k, l) (((l)==0)?0:(k >> (KEYLENGTH-l)) << (KEYLENGTH-l))
> -#define TKEY_GET_MASK(offset, bits) (((bits)==0)?0:((t_key)(-1) << (KEYLENGTH - bits) >> offset))
>  
>  typedef unsigned int t_key;
>  
> @@ -192,6 +190,11 @@ static inline int tnode_child_length(con
>  	return 1 << tn->bits;
>  }
>  
> +static inline t_key mask_pfx(t_key k, unsigned short l)
> +{
> +	return (l == 0) ? 0 : k >> (KEYLENGTH-l) << (KEYLENGTH-l);
> +}

that's a funy way of doing the masking, isn't it?  I suppose gcc will turn
it into the single and-immediate.

>  static inline t_key tkey_extract_bits(t_key a, int offset, int bits)
>  {
>  	if (offset < KEYLENGTH)
> @@ -676,7 +679,7 @@ static struct tnode *inflate(struct trie
>  		    inode->pos == oldtnode->pos + oldtnode->bits &&
>  		    inode->bits > 1) {
>  			struct tnode *left, *right;
> -			t_key m = TKEY_GET_MASK(inode->pos, 1);
> +			t_key m = ~0U << (KEYLENGTH - 1) >> inode->pos;

hm, so we "know" that t_key is an unsigned int.  It makes the typedef a bit
pointless.

<wonders what an inode is doing in there>

<oh>


-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ