lkml.org 
[lkml]   [1998]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: new dentry feature in 2.1.78
   From: torvalds@transmeta.com (Linus Torvalds)
Date: 10 Jan 1998 23:16:34 GMT

Michael Elizabeth Chastain <mec@shout.net> wrote:
> #define i (((unsigned long) inode)/(sizeof(struct inode) & ~ (sizeof(struct inode) - 1)))
So, ten points to the person who can guess what the hell the above does ;)

(Hint: the calculation is not actually strictly necessary, it only tries
to aim for a better hash)

It was so easy, I had to answer. ;-)
It removes the non-significant bits from the inode address ;-)

And even when struct inode is not a strict power of 2 (which it
typically isn't) gcc still does a decent job since most of the
operations are constant and get optimized away. Gcc in this case,
has a very good idea what you are trying to do ;-)

Later,
David S. Miller
davem@dm.cobaltmicro.com

\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.109 / U:0.156 seconds]
©2003-2014 Jasper Spaans. Advertise on this site