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@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8479)
This commit is contained in:
Richard Levitte 2019-03-14 09:59:00 +01:00
parent 085bef9f7c
commit 503d4745a1

View File

@ -16,6 +16,7 @@
# endif
# endif
# ifndef OPENSSL_DEV_NO_ATOMICS
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
&& !defined(__STDC_NO_ATOMICS__)
# include <stdatomic.h>
@ -114,7 +115,15 @@ static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock)
}
# endif
# else
# endif
# endif /* !OPENSSL_DEV_NO_ATOMICS */
/*
* 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;