Matthew Wilcox wrote:
> On Thu, Aug 31, 2000 at 12:26:29AM +0200, Rogier Wolff wrote:
> > int mr (unsigned int rate, int r)
> > {
> > int e = 16+9;
> > static int round[4]={0, 0, 0xffff, 0x8000};
> > if (!rate) return 0;
> > for (; rate & 0xfc000000 ;rate >>= 1, e++);
> > for (;!(rate & 0xfe000000);rate <<= 1, e--);
> > return ((rate & ~0x02000000) | (e << (16+9)) + round[r]) >> 16;
> > }
> >
> > Dense code, right? Floating point in the kernel.... Aaargh.
>
> you've failed Chapter 3 of CodingStyle:
>
> HOWEVER, while mixed-case names are frowned upon, descriptive names for
> global variables are a must. To call a global function "foo" is a
> shooting offense.
>
> what the hell does a function called `mr' do?
This was taken out-of-context, and I'm afraid I have to admit that
it was me that did that.
It's "make_rate", "r" is "rounding". "e" is "exponent". The "original"
and the routine that this is going to replace is indeed called
"make_rate".
It converts a 32bit "rate" (cells per second) into a 16-bit floating
point format, that is recommended by the ATM forum.
Roger.
-- ** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 ** *-- BitWizard writes Linux device drivers for any device you may have! --* * Common sense is the collection of * ****** prejudices acquired by age eighteen. -- Albert Einstein ******** - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Thu Aug 31 2000 - 21:00:27 EST