bn/asm/rsaz-avx2.pl: fix digit correction bug in rsaz_1024_mul_avx2.
[openssl.git] / crypto / threads_win.c
index ff4aae4f32fdf2d2729aee850a55909556f851f0..f222aa5d03c00f6f09e07bfa9bc334ec6686d31d 100644 (file)
@@ -7,6 +7,10 @@
  * https://www.openssl.org/source/license.html
  */
 
+#if defined(_WIN32)
+# include <windows.h>
+#endif
+
 #include <openssl/crypto.h>
 
 #if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && defined(OPENSSL_SYS_WINDOWS)
@@ -55,12 +59,14 @@ void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
     return;
 }
 
-# if _WIN32_WINNT < 0x0600
-
 #  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
+ * we still have to support.
+ */
 int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
 {
     LONG volatile *lock = (LONG *)once;
@@ -81,27 +87,6 @@ int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
     return (*lock == ONCE_DONE);
 }
 
-# else
-
-BOOL CALLBACK once_cb(PINIT_ONCE once, PVOID p, PVOID *pp)
-{
-    void (*init)(void) = p;
-
-    init();
-
-    return TRUE;
-}
-
-int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
-{
-    if (InitOnceExecuteOnce(once, once_cb, init, NULL))
-        return 1;
-
-    return 0;
-}
-
-# endif
-
 int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))
 {
     *key = TlsAlloc();
@@ -148,4 +133,21 @@ int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
     return 1;
 }
 
+int CRYPTO_atomic_read(int *val, int *ret, CRYPTO_RWLOCK *lock)
+{
+    *ret = InterlockedCompareExchange(val, 0, 0);
+    return 1;
+}
+
+int CRYPTO_atomic_write(int *val, int n, CRYPTO_RWLOCK *lock)
+{
+    InterlockedExchange(val, n);
+    return 1;
+}
+
+int openssl_init_fork_handlers(void)
+{
+    return 0;
+}
+
 #endif