Messages in this thread | | | Date | Wed, 2 Jul 2003 09:16:40 -0700 (PDT) | From | Linus Torvalds <> | Subject | Re: [PATCH] Kill div64.h dupes, parenthesize do_div() macro params |
| |
On Wed, 2 Jul 2003, Bernardo Innocenti wrote: > +#elif BITS_PER_LONG == 32 > + > +# define do_div(n,base) ({ \ > + \ > + uint32_t __low, __low2, __high, __rem; \ > + __low = (n) & 0xffffffff; \ > + __high = (n) >> 32; \ > + if (__high) { \ > + __rem = __high % (uint32_t)(base); \ > + __high = __high / (uint32_t)(base); \ > + __low2 = __low >> 16; \ > + __low2 += __rem << 16; \ > + __rem = __low2 % (uint32_t)(base); \ > + __low2 = __low2 / (uint32_t)(base); \ > + __low = __low & 0xffff; \ > + __low += __rem << 16; \ > + __rem = __low % (uint32_t)(base); \ > + __low = __low / (uint32_t)(base); \ > + (n) = __low + ((uint64_t)__low2 << 16) + \ > + ((uint64_t) __high << 32); \ > + } else { \ > + __rem = __low % (uint32_t)(base); \ > + (n) = (__low / (uint32_t)(base)); \ > + } \ > + __rem; \ > + })
Don't do this as a in-line thing. Do it as an out-of-line function, something like
#define do_div64(n,base) ({ \ u32 __rem; \ n = lib_do_div64(n, base, &__rem); \ __rem; })
instead. Add the out-of-line thing to lib/lib.a or something.
Linus
- 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/
| |