Don't use inline assembler on x86 Solaris (would need a different syntax).
[openssl.git] / crypto / bn / bn_div.c
index 150dd289a5833a399fb3a7b2aafa046ba4bf5ec0..36beea2296b822901cb27f47380704daa444eb9a 100644 (file)
@@ -202,12 +202,12 @@ 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
 
 #if !defined(NO_ASM) && !defined(PEDANTIC)
 # if defined(__GNUC__) && __GNUC__>=2
-#  if defined(__i386)
+#  if defined(__i386) && !defined(__sun)
    /*
     * There were two reasons for implementing this template:
     * - GNU C generates a call to a function (__udivdi3 to be exact)
@@ -238,7 +238,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
                        q=BN_MASK2;
                else
 #if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)
-                       q=((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0;
+                       q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
 #else
                        q=bn_div_words(n0,n1,d0);
 #endif
@@ -291,8 +291,8 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
 #endif
                }
 #endif /* !BN_DIV3W */
-               wnum.d--; wnum.top++;
                l0=bn_mul_words(tmp->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;