public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation•org>
To: Stephen Hemminger <shemminger@linux-foundation•org>
Cc: "David S. Miller" <davem@davemloft•net>,
	Adrian Bunk <bunk@stusta•de>,
	Robert Olsson <Robert.Olsson@data•slu.se>,
	"Paul E. McKenney" <paulmck@linux•vnet.ibm.com>,
	Ingo Molnar <mingo@elte•hu>, Josh Triplett <josh@kernel•org>,
	netdev@vger•kernel.org
Subject: Re: [RFT] fib_trie: macro cleanup
Date: Thu, 26 Jul 2007 03:54:33 -0700	[thread overview]
Message-ID: <20070726035433.69146262.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070726114334.1e3e446c@oldman.hamilton.local>

On Thu, 26 Jul 2007 11:43:34 +0100 Stephen Hemminger <shemminger@linux-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>



  reply	other threads:[~2007-07-26 10:55 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20070725040304.111550f4.akpm@linux-foundation.org>
2007-07-25 13:36 ` [-mm patch] one e1000 driver should be enough for everyone Adrian Bunk
2007-07-25 13:48   ` Jeff Garzik
2007-07-25 14:46     ` Adrian Bunk
2007-07-25 15:05       ` Jeff Garzik
2007-07-25 15:21         ` Kok, Auke
2007-07-25 15:23           ` Jeff Garzik
2007-07-25 20:50           ` Andrew Morton
2007-07-25 18:15 ` 2.6.23-rc1-mm1: net/ipv4/fib_trie.c compile error Adrian Bunk
2007-07-26  8:46   ` [RFT] fib_trie: cleanup Stephen Hemminger
2007-07-26  8:49     ` David Miller
2007-07-26 10:32       ` Robert Olsson
2007-07-26  9:04     ` Andrew Morton
2007-07-26  9:15       ` Stephen Hemminger
2007-07-26 10:49       ` [RFC] fib_trie: whitespace cleanup Stephen Hemminger
2007-07-26 15:44         ` Paul E. McKenney
2007-07-27  4:56           ` Andrew Morton
2007-07-30 17:07             ` Paul E. McKenney
2007-07-26 10:43     ` [RFT] fib_trie: macro cleanup Stephen Hemminger
2007-07-26 10:54       ` Andrew Morton [this message]
2007-07-28 15:44 ` NETPOLL=y , NETDEVICES=n compile error ( Re: 2.6.23-rc1-mm1 ) Gabriel C
2007-07-28 17:26   ` Andrew Morton
2007-07-28 18:42     ` Gabriel C
2007-07-31  8:32       ` Jarek Poplawski
2007-07-31 10:14         ` Gabriel C
2007-07-31 11:44           ` Jason Wessel
2007-07-31 12:47             ` Jarek Poplawski
2007-07-31 12:17           ` Jarek Poplawski
2007-07-31 15:05             ` Gabriel C
2007-08-01  9:59               ` Jarek Poplawski
2007-08-02  2:02                 ` Matt Mackall
2007-08-02  9:00                   ` Jarek Poplawski
2007-08-02 15:59                     ` Matt Mackall
2007-08-03  7:30                       ` Jarek Poplawski
2007-08-02  9:36                   ` Sam Ravnborg
2007-08-02 10:32                     ` Satyam Sharma
2007-08-02 11:40                       ` Satyam Sharma
2007-08-02 11:40                       ` Jarek Poplawski
2007-08-02 11:56                         ` Satyam Sharma
2007-08-02 12:52                           ` Jarek Poplawski
2007-08-06 11:51                     ` [PATCH] docs: note about select in kconfig-language.txt Jarek Poplawski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070726035433.69146262.akpm@linux-foundation.org \
    --to=akpm@linux-foundation$(echo .)org \
    --cc=Robert.Olsson@data$(echo .)slu.se \
    --cc=bunk@stusta$(echo .)de \
    --cc=davem@davemloft$(echo .)net \
    --cc=josh@kernel$(echo .)org \
    --cc=mingo@elte$(echo .)hu \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=paulmck@linux$(echo .)vnet.ibm.com \
    --cc=shemminger@linux-foundation$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox