lkml.org 
[lkml]   [2002]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] bring sanity to div64.h and do_div usage
Hi,

Troy Benjegerdes wrote:

> +#else /* USE_SLOW_64BIT_DIVIDES */
> + /*
> + * Nasty ugly generic C 64 bit divide on 32 bit machine
> + * No one seems to want to take credit for this
> + */
> + unsigned long low, low2, high;
> + low = (t) & 0xffffffff;
> + high = (t) >> 32;
> + res = high % base;
> + high = high / base;
> + low2 = low >> 16;
> + low2 += res << 16;
> + res = low2 % base;
> + low2 = low2 / base;
> + low = low & 0xffff;
> + low += res << 16;
> + res = low % base;
> + low = low / base;
> + t = low + ((long long)low2 << 16) +
> + ((long long) high << 32);


IMO this is large enough to put under lib/..., the rest could also be
put into asm-generic, from where the archs could include it, this would
avoid this:

> +#ifdef __USE_ASM
> +/* yeah, this is a mess, and leaves out m68k.... */
> +# if defined(CONFIG_X86) || define(CONFIG_ARCH_S390) ||
defined(CONFIG_MIPS)
> +# define __USE_ASM__
> +# endif
> +#endif

bye, Roman

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

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