Add support for reference counting using C11 atomics Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> GH: #1500
diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c index 52816df..8f185b3 100644 --- a/crypto/dso/dso_lib.c +++ b/crypto/dso/dso_lib.c
@@ -65,7 +65,7 @@ if (dso == NULL) return (1); - if (CRYPTO_atomic_add(&dso->references, -1, &i, dso->lock) <= 0) + if (CRYPTO_DOWN_REF(&dso->references, &i, dso->lock) <= 0) return 0; REF_PRINT_COUNT("DSO", dso); @@ -107,7 +107,7 @@ return 0; } - if (CRYPTO_atomic_add(&dso->references, 1, &i, dso->lock) <= 0) + if (CRYPTO_UP_REF(&dso->references, &i, dso->lock) <= 0) return 0; REF_PRINT_COUNT("DSO", r);
diff --git a/crypto/dso/dso_locl.h b/crypto/dso/dso_locl.h index fbfad05..14a0ccb 100644 --- a/crypto/dso/dso_locl.h +++ b/crypto/dso/dso_locl.h
@@ -11,6 +11,7 @@ #include "internal/cryptlib.h" #include "internal/dso.h" #include "internal/dso_conf.h" +#include "internal/refcount.h" /**********************************************************************/ /* The low-level handle type used to refer to a loaded shared library */ @@ -24,7 +25,7 @@ * "Handles" and such go in a STACK. */ STACK_OF(void) *meth_data; - int references; + CRYPTO_REF_COUNT references; int flags; /* * For use by applications etc ... use this for your bits'n'pieces, don't