X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Farch%2Fhelpers.h;h=b478031003456503481e7d860da45e2d4dc6cb65;hb=3c283c4831c40c14d308a54cefb997832a860bca;hp=4d85fcb4d5f31aeaae7df3f1b9e89143c910bd94;hpb=51ab5f489bc356940c95cc936fd0508e8f07ea97;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/arch/helpers.h b/KernelLand/Kernel/arch/helpers.h index 4d85fcb4..b4780310 100644 --- a/KernelLand/Kernel/arch/helpers.h +++ b/KernelLand/Kernel/arch/helpers.h @@ -14,10 +14,10 @@ // > If the `N` value is greater than `D`, we can set this bit #define DEF_DIVMOD(s) Uint##s __divmod##s(Uint##s N, Uint##s D, Uint##s*Rem){\ Uint##s ret=0,add=1;\ - while(N>=D&&add) {D<<=1;add<<=1;}\ - while(add>1){\ - add>>=1;D>>=1;\ + while(N/2>=D&&add) {D<<=1;add<<=1;}\ + while(add>0){\ if(N>=D){ret+=add;N-=D;}\ + add>>=1;D>>=1;\ }\ if(Rem)*Rem = N;\ return ret;\