[openssl] master update
Richard Levitte
levitte at openssl.org
Thu Mar 14 15:26:41 UTC 2019
The branch master has been updated
via 503d4745a115b82db01c1fb22baaddb153d27cdb (commit)
from 085bef9f7cee8506cc9d438d4fbc3663f46c5fe2 (commit)
- Log -----------------------------------------------------------------
commit 503d4745a115b82db01c1fb22baaddb153d27cdb
Author: Richard Levitte <levitte at openssl.org>
Date: Thu Mar 14 09:59:00 2019 +0100
internal/refcount.h: allow non-atomic build
Configure with -DOPENSSL_DEV_NO_ATOMICS and you get refcount without
atomics. This is intended for internal development only, to check the
refcounting is properly coded. It should never become a configuration
option, hence the name of the macro.
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre at ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8479)
-----------------------------------------------------------------------
Summary of changes:
include/internal/refcount.h | 49 +++++++++++++++++++++++++++------------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/include/internal/refcount.h b/include/internal/refcount.h
index b6c9f9c..f8b0778 100644
--- a/include/internal/refcount.h
+++ b/include/internal/refcount.h
@@ -16,16 +16,17 @@
# endif
# endif
-# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
- && !defined(__STDC_NO_ATOMICS__)
-# include <stdatomic.h>
-# define HAVE_C11_ATOMICS
-# endif
+# ifndef OPENSSL_DEV_NO_ATOMICS
+# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
+ && !defined(__STDC_NO_ATOMICS__)
+# include <stdatomic.h>
+# define HAVE_C11_ATOMICS
+# endif
-# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \
- && ATOMIC_INT_LOCK_FREE > 0
+# if defined(HAVE_C11_ATOMICS) && defined(ATOMIC_INT_LOCK_FREE) \
+ && ATOMIC_INT_LOCK_FREE > 0
-# define HAVE_ATOMICS 1
+# define HAVE_ATOMICS 1
typedef _Atomic int CRYPTO_REF_COUNT;
@@ -53,9 +54,9 @@ static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)
return 1;
}
-# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0
+# elif defined(__GNUC__) && defined(__ATOMIC_RELAXED) && __GCC_ATOMIC_INT_LOCK_FREE > 0
-# define HAVE_ATOMICS 1
+# define HAVE_ATOMICS 1
typedef int CRYPTO_REF_COUNT;
@@ -73,17 +74,17 @@ static __inline__ int CRYPTO_DOWN_REF(int *val, int *ret, void *lock)
return 1;
}
-# elif defined(_MSC_VER) && _MSC_VER>=1200
+# elif defined(_MSC_VER) && _MSC_VER>=1200
-# define HAVE_ATOMICS 1
+# define HAVE_ATOMICS 1
typedef volatile int CRYPTO_REF_COUNT;
-# if (defined(_M_ARM) && _M_ARM>=7) || defined(_M_ARM64)
-# include <intrin.h>
-# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH)
-# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH
-# endif
+# if (defined(_M_ARM) && _M_ARM>=7) || defined(_M_ARM64)
+# include <intrin.h>
+# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH)
+# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH
+# endif
static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock)
{
@@ -98,8 +99,8 @@ static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock)
__dmb(_ARM_BARRIER_ISH);
return 1;
}
-# else
-# pragma intrinsic(_InterlockedExchangeAdd)
+# else
+# pragma intrinsic(_InterlockedExchangeAdd)
static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock)
{
@@ -112,9 +113,17 @@ static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock)
*ret = _InterlockedExchangeAdd(val, -1) - 1;
return 1;
}
+# endif
+
# endif
+# endif /* !OPENSSL_DEV_NO_ATOMICS */
-# else
+/*
+ * All the refcounting implementations above define HAVE_ATOMICS, so if it's
+ * still undefined here (such as when OPENSSL_DEV_NO_ATMOICS is defined), it
+ * means we need to implement a fallback. This fallback uses locks.
+ */
+# ifndef HAVE_ATOMICS
typedef int CRYPTO_REF_COUNT;
More information about the openssl-commits
mailing list