From 2f545ae45d4b93649e40ff7f93e2c3e6ce3154ae Mon Sep 17 00:00:00 2001 From: Kurt Roeckx Date: Sat, 27 Aug 2016 16:01:08 +0200 Subject: Add support for reference counting using C11 atomics Reviewed-by: Andy Polyakov Reviewed-by: Rich Salz GH: #1500 --- crypto/dso/dso_lib.c | 4 ++-- crypto/dso/dso_locl.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'crypto/dso') diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c index 52816dfb9d..8f185b3828 100644 --- a/crypto/dso/dso_lib.c +++ b/crypto/dso/dso_lib.c @@ -65,7 +65,7 @@ int DSO_free(DSO *dso) 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 @@ int DSO_up_ref(DSO *dso) 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 fbfad0544a..14a0ccb7c0 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 @@ struct dso_st { * "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 -- cgit v1.2.3