Revert the size_t modifications from HEAD that had led to more
[openssl.git] / crypto / rand / md_rand.c
index 6e10f6ef676184ffb7d18b2fb55641dbb7bbe0b6..810b4c2d4a61a25d4635453fa9ed6ab83e2c5025 100644 (file)
@@ -145,14 +145,14 @@ static unsigned int crypto_lock_rand = 0; /* may be set only when a thread
                                            * holds CRYPTO_LOCK_RAND
                                            * (to prevent double locking) */
 /* access to lockin_thread is synchronized by CRYPTO_LOCK_RAND2 */
-static unsigned long locking_thread = 0; /* valid iff crypto_lock_rand is set */
+static CRYPTO_THREADID locking_threadid; /* valid iff crypto_lock_rand is set */
 
 
 #ifdef PREDICT
 int rand_predictable=0;
 #endif
 
-const char *RAND_version="RAND" OPENSSL_VERSION_PTEXT;
+const char RAND_version[]="RAND" OPENSSL_VERSION_PTEXT;
 
 static void ssleay_rand_cleanup(void);
 static void ssleay_rand_seed(const void *buf, int num);
@@ -213,8 +213,10 @@ static void ssleay_rand_add(const void *buf, int num, double add)
        /* check if we already have the lock */
        if (crypto_lock_rand)
                {
+               CRYPTO_THREADID cur;
+               CRYPTO_THREADID_current(&cur);
                CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
-               do_not_lock = (locking_thread == CRYPTO_thread_id());
+               do_not_lock = !CRYPTO_THREADID_cmp(&locking_threadid, &cur);
                CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
                }
        else
@@ -372,7 +374,7 @@ static int ssleay_rand_bytes(unsigned char *buf, int num)
 
        /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
        CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
-       locking_thread = CRYPTO_thread_id();
+       CRYPTO_THREADID_current(&locking_threadid);
        CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
        crypto_lock_rand = 1;
 
@@ -527,15 +529,17 @@ static int ssleay_rand_pseudo_bytes(unsigned char *buf, int num)
 
 static int ssleay_rand_status(void)
        {
+       CRYPTO_THREADID cur;
        int ret;
        int do_not_lock;
 
+       CRYPTO_THREADID_current(&cur);
        /* check if we already have the lock
         * (could happen if a RAND_poll() implementation calls RAND_status()) */
        if (crypto_lock_rand)
                {
                CRYPTO_r_lock(CRYPTO_LOCK_RAND2);
-               do_not_lock = (locking_thread == CRYPTO_thread_id());
+               do_not_lock = !CRYPTO_THREADID_cmp(&locking_threadid, &cur);
                CRYPTO_r_unlock(CRYPTO_LOCK_RAND2);
                }
        else
@@ -547,7 +551,7 @@ static int ssleay_rand_status(void)
                
                /* prevent ssleay_rand_bytes() from trying to obtain the lock again */
                CRYPTO_w_lock(CRYPTO_LOCK_RAND2);
-               locking_thread = CRYPTO_thread_id();
+               CRYPTO_THREADID_cpy(&locking_threadid, &cur);
                CRYPTO_w_unlock(CRYPTO_LOCK_RAND2);
                crypto_lock_rand = 1;
                }