Fix Compiler error/warning for windows icl build
authorShane Lontis <shane.lontis@oracle.com>
Wed, 18 Sep 2019 05:26:19 +0000 (15:26 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Wed, 18 Sep 2019 05:26:19 +0000 (15:26 +1000)
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9907)

include/internal/refcount.h

index eddf12415fc79e5f5cc6de09b69701322f7bc6f3..1619b289326dfd29bd72d2d3837a6b7146484c07 100644 (file)
@@ -73,6 +73,21 @@ static __inline__ int CRYPTO_DOWN_REF(int *val, int *ret, void *lock)
         __atomic_thread_fence(__ATOMIC_ACQUIRE);
     return 1;
 }
+#  elif defined(__ICL) && defined(_WIN32)
+#   define HAVE_ATOMICS 1
+typedef volatile int CRYPTO_REF_COUNT;
+
+static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock)
+{
+    *ret = _InterlockedExchangeAdd((void *)val, 1) + 1;
+    return 1;
+}
+
+static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock)
+{
+    *ret = _InterlockedExchangeAdd((void *)val, -1) - 1;
+    return 1;
+}
 
 #  elif defined(_MSC_VER) && _MSC_VER>=1200