@@ -9,15 +9,15 @@ x86. There are already implementations of replacements for other
99functions, such as InterlockedOr64(). Apply the same approach to
1010fix the errors.
1111
12- Inspired by openssl/openssl# 24326.
12+ Inspired by https://github.com/ openssl/openssl/pull/ 24326.
1313
1414(cherry picked from commit 03111c77b640febbfaefc9ab6519e85f8b595100)
1515---
1616 crypto/threads_win.c | 81 ++++++++++++++++++++++++++++++++++++++------
1717 1 file changed, 71 insertions(+), 10 deletions(-)
1818
1919diff --git a/crypto/threads_win.c b/crypto/threads_win.c
20- index 64354dc42f..62b63a4aad 100644
20+ index bc430ef..30ca914 100644
2121--- a/crypto/threads_win.c
2222+++ b/crypto/threads_win.c
2323@@ -23,7 +23,7 @@
@@ -29,7 +29,7 @@ index 64354dc42f..62b63a4aad 100644
2929 # define NO_INTERLOCKEDOR64
3030 #endif
3131
32- @@ -104 ,8 +104 ,15 @@ struct rcu_lock_st {
32+ @@ -103 ,8 +103 ,15 @@
3333 CRYPTO_CONDVAR *alloc_signal;
3434 CRYPTO_MUTEX *prior_lock;
3535 CRYPTO_CONDVAR *prior_signal;
@@ -42,18 +42,18 @@ index 64354dc42f..62b63a4aad 100644
4242+ static int CRYPTO_atomic_and(uint64_t *val, uint64_t op, uint64_t *ret,
4343+ CRYPTO_RWLOCK *lock);
4444+
45- /*
46- * Called on thread exit to free the pthread key
47- * associated with this thread, if any
48- @@ -154,6 +161,7 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers)
49- return NULL;
45+ static struct rcu_qp *allocate_new_qp_group(struct rcu_lock_st *lock,
46+ int count)
47+ {
48+ @@ -133,6 +140,7 @@
5049
50+ new->ctx = ctx;
5151 new->write_lock = ossl_crypto_mutex_new();
5252+ new->rw_lock = CRYPTO_THREAD_lock_new();
5353 new->alloc_signal = ossl_crypto_condvar_new();
5454 new->prior_signal = ossl_crypto_condvar_new();
5555 new->alloc_lock = ossl_crypto_mutex_new();
56- @@ -164 ,13 +172 ,15 @@ CRYPTO_RCU_LOCK *ossl_rcu_lock_new(int num_writers)
56+ @@ -143 ,13 +151 ,15 @@
5757 || new->prior_signal == NULL
5858 || new->write_lock == NULL
5959 || new->alloc_lock == NULL
@@ -70,7 +70,7 @@ index 64354dc42f..62b63a4aad 100644
7070 OPENSSL_free(new);
7171 new = NULL;
7272 }
73- @@ -186 ,20 +196 ,27 @@ void ossl_rcu_lock_free(CRYPTO_RCU_LOCK *lock)
73+ @@ -165 ,20 +175 ,27 @@
7474 ossl_crypto_mutex_free(&lock->alloc_lock);
7575 ossl_crypto_mutex_free(&lock->prior_lock);
7676 ossl_crypto_mutex_free(&lock->write_lock);
@@ -102,7 +102,7 @@ index 64354dc42f..62b63a4aad 100644
102102 }
103103
104104 return &lock->qp_group[qp_idx];
105- @@ -263 ,7 +280 ,9 @@ void ossl_rcu_read_unlock(CRYPTO_RCU_LOCK *lock)
105+ @@ -254 ,7 +271 ,9 @@
106106 if (data->thread_qps[i].lock == lock) {
107107 data->thread_qps[i].depth--;
108108 if (data->thread_qps[i].depth == 0) {
@@ -113,15 +113,15 @@ index 64354dc42f..62b63a4aad 100644
113113 OPENSSL_assert(ret >= 0);
114114 data->thread_qps[i].qp = NULL;
115115 data->thread_qps[i].lock = NULL;
116- @@ -278 ,6 +297 ,7 @@ static struct rcu_qp *update_qp(CRYPTO_RCU_LOCK *lock)
116+ @@ -269 ,6 +288 ,7 @@
117117 uint64_t new_id;
118118 uint32_t current_idx;
119119 uint32_t tmp;
120120+ uint64_t tmp64;
121121
122122 ossl_crypto_mutex_lock(lock->alloc_lock);
123123 /*
124- @@ -301 ,8 +321 ,10 @@ static struct rcu_qp *update_qp(CRYPTO_RCU_LOCK *lock)
124+ @@ -292 ,8 +312 ,10 @@
125125 lock->id_ctr++;
126126
127127 new_id = VAL_ID(new_id);
@@ -134,7 +134,7 @@ index 64354dc42f..62b63a4aad 100644
134134
135135 /* update the reader index to be the prior qp */
136136 tmp = lock->current_alloc_idx;
137- @@ -337 ,7 +359 ,7 @@ void ossl_synchronize_rcu(CRYPTO_RCU_LOCK *lock)
137+ @@ -328 ,7 +350 ,7 @@
138138
139139 /* wait for the reader count to reach zero */
140140 do {
@@ -143,7 +143,7 @@ index 64354dc42f..62b63a4aad 100644
143143 } while (READER_COUNT(count) != 0);
144144
145145 /* retire in order */
146- @@ -565 ,6 +587 ,45 @@ int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b)
146+ @@ -556 ,6 +578 ,45 @@
147147 return (a == b);
148148 }
149149
0 commit comments