• Bernardo Innocenti's avatar
    [PATCH] Fix do_div() for all architectures · f0a8aa74
    Bernardo Innocenti authored
    This offers a generic do_div64() that actually does the right thing,
    unlike some architectures that "optimized" the 64-by-32 divide into
    just a 32-bit divide.
    
    Both ppc and sh were already providing an assembly optimized
    __div64_32().  I called my function the same, so that their optimized
    versions will automatically override mine in lib.a.
    
    I've only tested extensively on m68knommu (uClinux) and made
    sure generated code is reasonably short. Should be ok also on
    parisc, since it's the same algorithm they were using before.
    
     - add generic C implementations of the do_div() for 32bit and 64bit
       archs in asm-generic/div64.h;
    
     - add generic library support function __div64_32() to handle the
       full 64/32 case on 32bit archs;
    
     - kill multiple copies of generic do_div() in architecture
       specific subdirs. Most copies were either buggy or not doing
       what they were supposed to do;
    
     - ensure all surviving instances of do_div() have their parameters
       correctly parenthesized to avoid funny side-effects;
    f0a8aa74
div64.h 1.16 KB