diff options
author | Andy Polyakov <appro@openssl.org> | 2018-08-03 10:46:03 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2018-08-07 09:08:50 +0200 |
commit | 8f15498563658726a7c2bce7abcf01bea08515de (patch) | |
tree | a6f0b02b123cd6ef5719eb4c2617b738d23c2ec0 /crypto/mem.c | |
parent | e519d6b563d95d630723784a5737ebe5ef74e4f3 (diff) |
crypto/mem.c: switch to tsan_assist.h in CRYPTO_MDEBUG.
Rationale is that it wasn't providing accurate statistics anyway.
For statistics to be accurate CRYPTO_get_alloc_counts should acquire
a lock and lock-free additions should not be an option.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6786)
Diffstat (limited to 'crypto/mem.c')
-rw-r--r-- | crypto/mem.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/crypto/mem.c b/crypto/mem.c index 336446789c..780053ffef 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -31,13 +31,13 @@ static void (*free_impl)(void *, const char *, int) = CRYPTO_free; #ifndef OPENSSL_NO_CRYPTO_MDEBUG -static int malloc_count; -static int realloc_count; -static int free_count; -static int dummy; +# include "internal/tsan_assist.h" -# define INCREMENT(x) CRYPTO_atomic_add(&x, 1, &dummy, memdbg_lock) -# define GET(ret, val) CRYPTO_atomic_read(&val, ret, memdbg_lock) +static TSAN_QUALIFIER int malloc_count; +static TSAN_QUALIFIER int realloc_count; +static TSAN_QUALIFIER int free_count; + +# define INCREMENT(x) tsan_counter(&(x)) static char *md_failstring; static long md_count; @@ -98,11 +98,11 @@ void CRYPTO_get_mem_functions( void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount) { if (mcount != NULL) - GET(mcount, malloc_count); + *mcount = tsan_load(&malloc_count); if (rcount != NULL) - GET(rcount, realloc_count); + *rcount = tsan_load(&realloc_count); if (fcount != NULL) - GET(fcount, free_count); + *fcount = tsan_load(&free_count); } /* |