diff options
author | Pauli <pauli@openssl.org> | 2022-01-12 14:25:46 +1100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-01-13 21:46:34 +1100 |
commit | 5c41cee225094e6298799b709278b0431643fb1f (patch) | |
tree | 1a432ab12ba1ad45dc161d9f7a07375ef68c8005 /crypto/mem.c | |
parent | e6b8f359e79cdbe09033d02eaad7ecb4e24adb73 (diff) | |
download | openssl-5c41cee225094e6298799b709278b0431643fb1f.tar.gz |
mem: do not produce usage counts when tsan is unavailable.
Doing the tsan operations under lock would be difficult to arrange here (locks
require memory allocation).
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/17479)
Diffstat (limited to 'crypto/mem.c')
-rw-r--r-- | crypto/mem.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/crypto/mem.c b/crypto/mem.c index d682a3686f..242d88470a 100644 --- a/crypto/mem.c +++ b/crypto/mem.c @@ -26,11 +26,17 @@ static CRYPTO_free_fn free_impl = CRYPTO_free; #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODULE) # include "internal/tsan_assist.h" +# ifdef TSAN_REQUIRES_LOCKING +# define INCREMENT(x) /* empty */ +# define LOAD(x) 0 +# else /* TSAN_REQUIRES_LOCKING */ static TSAN_QUALIFIER int malloc_count; static TSAN_QUALIFIER int realloc_count; static TSAN_QUALIFIER int free_count; -# define INCREMENT(x) tsan_counter(&(x)) +# define INCREMENT(x) tsan_counter(&(x)) +# define LOAD(x) tsan_load(&x) +# endif /* TSAN_REQUIRES_LOCKING */ static char *md_failstring; static long md_count; @@ -79,11 +85,11 @@ void CRYPTO_get_mem_functions(CRYPTO_malloc_fn *malloc_fn, void CRYPTO_get_alloc_counts(int *mcount, int *rcount, int *fcount) { if (mcount != NULL) - *mcount = tsan_load(&malloc_count); + *mcount = LOAD(malloc_count); if (rcount != NULL) - *rcount = tsan_load(&realloc_count); + *rcount = LOAD(realloc_count); if (fcount != NULL) - *fcount = tsan_load(&free_count); + *fcount = LOAD(free_count); } /* |