Optimize bn_correct_top.
[openssl.git] / crypto / bn / bn.h
index 65202ae9f2d6436f028c583b5245411c780b07cf..dc0debb85afbe2a079632216d4fd64c0a410115b 100644 (file)
 #ifndef OPENSSL_NO_FP_API
 #include <stdio.h> /* FILE */
 #endif
-#include <openssl/crypto.h>
 #include <openssl/ossl_typ.h>
+#include <openssl/crypto.h>
 
 #ifdef  __cplusplus
 extern "C" {
@@ -569,8 +569,7 @@ int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
 unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
 void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
 #endif
-void BN_BLINDING_set_thread(BN_BLINDING *);
-int BN_BLINDING_cmp_thread(const BN_BLINDING *, const CRYPTO_THREADID *);
+CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
 unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
 void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long);
 BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b,
@@ -753,10 +752,12 @@ int RAND_pseudo_bytes(unsigned char *buf,int num);
 #define bn_correct_top(a) \
         { \
         BN_ULONG *ftl; \
-       if ((a)->top > 0) \
+       int top = (a)->top; \
+       if (top > 0) \
                { \
-               for (ftl= &((a)->d[(a)->top-1]); (a)->top > 0; (a)->top--) \
-               if (*(ftl--)) break; \
+               for (ftl= &((a)->d[top-1]); top > 0; top--) \
+                       if (*(ftl--)) break; \
+               (a)->top = top; \
                } \
        bn_pollute(a); \
        }