60 #if defined( INC_ALL )
81 #if defined( __APPLE__ ) && defined( __GNUC__ ) && \
82 ( __GNUC__ == 4 ) && ( __GNUC_MINOR__ == 0 ) && defined( __i386__ )
83 #pragma optimization_level 2
106 {
if (
BN_copy(rem,m) == NULL)
return(0); }
115 if (D == NULL || dv == NULL || rem == NULL)
120 if (
BN_copy(D,d) == NULL)
goto end;
121 if (
BN_copy(rem,m) == NULL)
goto end;
130 for (i=nm-nd; i>=0; i--)
136 if (!
BN_usub(rem,rem,D))
goto end;
151 #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \
152 && !defined(PEDANTIC) && !defined(BN_DIV3W)
153 # if defined(__GNUC__) && __GNUC__>=2
154 # if defined(__i386) || defined (__i386__)
165 # define bn_div_words(n0,n1,d0) \
168 : "=a"(q), "=d"(rem) \
169 : "a"(n1), "d"(n0), "g"(d0) \
173 # define REMAINDER_IS_ALREADY_CALCULATED
174 # elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG)
179 # define bn_div_words(n0,n1,d0) \
182 : "=a"(q), "=d"(rem) \
183 : "a"(n1), "d"(n0), "g"(d0) \
187 # define REMAINDER_IS_ALREADY_CALCULATED
203 int norm_shift,i,loop;
204 BIGNUM *tmp,wnum,*snum,*sdiv,*res;
225 {
if (
BN_copy(rm,num) == NULL)
return(0); }
238 if (sdiv == NULL || res == NULL)
goto err;
240 if (sdiv == NULL || res == NULL || \
241 tmp == NULL || snum == NULL)
goto err;
246 if (!(
BN_lshift(sdiv,divisor,norm_shift)))
goto err;
249 if (!(
BN_lshift(snum,num,norm_shift)))
goto err;
258 wnum.
d = &(snum->
d[loop]);
266 d1=(div_n == 1)?0:sdiv->
d[div_n-2];
269 wnump= &(snum->
d[num_n-1]);
275 resp= &(res->
d[loop-1]);
298 for (i=0; i<loop-1; i++, wnump--, resp--)
304 #if defined(BN_DIV3W) && !defined(OPENSSL_NO_ASM)
306 q=bn_div_3_words(wnump,d1,d0);
319 #if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)
323 #ifdef BN_DEBUG_LEVITTE
324 fprintf(stderr,
"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\
330 #ifndef REMAINDER_IS_ALREADY_CALCULATED
341 if (t2 <= ((((BN_ULLONG)rem)<<
BN_BITS2)|wnump[-2]))
350 #if !defined( BN_UMULT_LOHI ) && !defined( BN_UMULT_HIGH )
355 #ifdef BN_DEBUG_LEVITTE
356 fprintf(stderr,
"DEBUG: bn_div_words(0x%08X,0x%08X,0x%08\
360 #ifndef REMAINDER_IS_ALREADY_CALCULATED
364 #if defined(BN_UMULT_LOHI)
365 BN_UMULT_LOHI(t2l,t2h,d1,q);
366 #elif defined(BN_UMULT_HIGH)
368 t2h = BN_UMULT_HIGH(d1,q);
372 mul64(t2l,t2h,ql,qh);
378 ((t2h == rem) && (t2l <= wnump[-2])))
383 if (t2l < d1) t2h--; t2l -= d1;