lkml.org 
[lkml]   [1996]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 64-bit math in the kernel

On Tue, 26 Nov 1996, Werner Almesberger wrote:
> Albert Cahalan wrote:
> > What is the best way to divide a __u64 by a __u32 in the kernel?
> > The result will fit in a __u32.
> In one of my ATM drivers, I have the following non-portable and therefore
> ugly solution (inspired by arch/i386/kernel/time.c:do_fast_gettimeoffset):

Oh, Please be careful with anything coming out of
do_fast_gettimeoffset, As this call if not done
right on an AMD5k86-P90, you will not get what you want.

If this will never reach the Processor(s) then my point is
moot. Just an FYI. JimL

>
>
> *
> * zatm_dev->factor = (interval << TIMER_SHIFT)/
> * (ticks-zatm_dev->last_clk);
> */
> #define S(x) #x /* "stringification" ... */
> #define SX(x) S(x)
> asm("movl %2,%%ebx\n\t"
> "subl %3,%%ebx\n\t"
> "xorl %%edx,%%edx\n\t"
> "shldl $" SX(TIMER_SHIFT) ",%1,%%edx\n\t"
> "shl $" SX(TIMER_SHIFT) ",%1\n\t"
> "divl %%ebx\n\t"
> : "=eax" (zatm_dev->factor)
> : "eax" (interval-diff),"g" (ticks),
> "g" (zatm_dev->last_clk)
> : "ebx","edx","cc");
> #undef S
> #undef SX
>
> > It seems gcc requires libgcc to do that, but libgcc is not available.
>
> Right, I didn't dare to link the kernel with libgcc either. I think it
> would be a very good idea to have basic 64 bit arithmetic available in
> the kernel too.
>
> - Werner
>
> --
> _________________________________________________________________________
> / Werner Almesberger, DI-LRC,EPFL,CH werner.almesberger@lrc.di.epfl.ch /
> /_IN_R_133__Tel_+41_21_693_6621__Fax_+41_21_693_6610_____________________/
>

_________________________________________
| James W. Laferriere | Network Engineer |
| babydr@nwrain.net | System Techniques |
| 25416 - 22nd S. | Kent, WA 98032 |
| Give me VMS -or- Give me Linux |
| but only on AXP |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



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