diff options
author | Matt Caswell <matt@openssl.org> | 2020-12-22 17:43:07 +0000 |
---|---|---|
committer | Dmitry Belyavskiy <beldmit@gmail.com> | 2020-12-31 13:14:38 +0100 |
commit | d5e742de653954bfae88f0e5f6c8f0a7a5f6c437 (patch) | |
tree | b1482462356926eb9e213f2c0294f45cea517e01 /crypto/threads_win.c | |
parent | 30af356df487b2dad571be15574b454daf70743c (diff) |
Add some more CRYPTO_atomic functions
We add an implementation for CRYPTO_atomic_or() and CRYPTO_atomic_load()
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/13733)
Diffstat (limited to 'crypto/threads_win.c')
-rw-r--r-- | crypto/threads_win.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/crypto/threads_win.c b/crypto/threads_win.c index a008831a3e..ef68fe2d24 100644 --- a/crypto/threads_win.c +++ b/crypto/threads_win.c @@ -66,9 +66,9 @@ void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock) return; } -# define ONCE_UNINITED 0 -# define ONCE_ININIT 1 -# define ONCE_DONE 2 +# define ONCE_UNINITED 0 +# define ONCE_ININIT 1 +# define ONCE_DONE 2 /* * We don't use InitOnceExecuteOnce because that isn't available in WinXP which @@ -159,6 +159,19 @@ int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock) return 1; } +int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret, + CRYPTO_RWLOCK *lock) +{ + *ret = (uint64_t)InterlockedOr64((LONG64 volatile *)val, (LONG64)op) | op; + return 1; +} + +int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock) +{ + *ret = (uint64_t)InterlockedOr64((LONG64 volatile *)val, 0); + return 1; +} + int openssl_init_fork_handlers(void) { return 0; |