X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fbn%2Fbn_div.c;h=830da87f58e047f7156a0b2aacd2195bb3495480;hb=f18a93ab04f248de45a8bcdded9b91880c690dbd;hp=03b9152241798e5154c619c3f1b5ea0d332cd995;hpb=0dd25e3606f767381de8c8722b76f813c8e3b013;p=oweals%2Fopenssl.git diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index 03b9152241..830da87f58 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -202,17 +202,43 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor, { BN_ULONG q,l0; #ifdef BN_DIV3W - q=bn_div_3_words(wnump,d0,d1); + q=bn_div_3_words(wnump,d1,d0); #else - BN_ULONG n0,n1,rem; + +#if !defined(NO_ASM) && !defined(PEDANTIC) +# if defined(__GNUC__) && __GNUC__>=2 +# if defined(__i386) + /* + * There were two reasons for implementing this template: + * - GNU C generates a call to a function (__udivdi3 to be exact) + * in reply to ((((BN_ULLONG)n0)< + */ +# define bn_div_words(n0,n1,d0) \ + ({ asm volatile ( \ + "divl %4" \ + : "=a"(q), "=d"(rem) \ + : "a"(n1), "d"(n0), "g"(d0) \ + : "cc"); \ + q; \ + }) +# define REMINDER_IS_ALREADY_CALCULATED +# endif /* __ */ +# endif /* __GNUC__ */ +#endif /* NO_ASM */ + BN_ULONG n0,n1,rem=0; n0=wnump[0]; n1=wnump[-1]; if (n0 == d0) q=BN_MASK2; else -#if defined(BN_LLONG) && defined(BN_DIV2W) - q=((((BN_ULLONG)n0)<d,sdiv->d,div_n,q); + wnum.d--; wnum.top++; tmp->d[div_n]=l0; for (j=div_n+1; j>0; j--) if (tmp->d[j-1]) break;