[lkml]   [1998]   [Jan]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: new dentry feature in 2.1.78

On Sat, 10 Jan 1998, David S. Miller wrote:
> #define i (((unsigned long) inode)/(sizeof(struct inode) & ~ (sizeof(struct inode) - 1)))
> 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 ;-)

Note that even when the size is not a strict power of two, the sequence
will find the largest power of two that the size is divisible by - which
tends to be just the size of an "unsigned long", but instead of just using
that directly the above at least has a small chance of finding a larger
power of two if one were to be available.

Whether the calculation helps I can't really say, but it may help, and it
certainly cannot make matters worse.


 \ /
  Last update: 2005-03-22 13:41    [W:0.019 / U:7.432 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site