Commit 503d4745 authored by Richard Levitte's avatar Richard Levitte
Browse files

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: default avatarMatthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/8479)
parent 085bef9f
Loading
Loading
Loading
Loading
+29 −20
Original line number Diff line number Diff line
@@ -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;