summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2021-05-19 11:09:49 -0400
committerRichard Levitte <levitte@openssl.org>2021-05-28 10:04:31 +0200
commita935791d54078f43209ffbc1886ac5e68772ce34 (patch)
tree3f130fe3e12b6671584ff421984542579d5268a8 /include
parent6bf3692d311ad15d3667e7015bbe1a8f849f3c7b (diff)
Rework and make DEBUG macros consistent.
Remove unused -DCONF_DEBUG and -DBN_CTX_DEBUG. Rename REF_PRINT to REF_DEBUG for consistency, and add a new tracing category and use it for printing reference counts. Rename -DDEBUG_UNUSED to -DUNUSED_RESULT_DEBUG Fix BN_DEBUG_RAND so it compiles and, when set, force DEBUG_RAND to be set also. Rename engine_debug_ref to be ENGINE_REF_PRINT also for consistency. Fixes #15357 Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15353)
Diffstat (limited to 'include')
-rw-r--r--include/internal/refcount.h18
-rw-r--r--include/openssl/e_os2.h2
-rw-r--r--include/openssl/trace.h4
3 files changed, 9 insertions, 15 deletions
diff --git a/include/internal/refcount.h b/include/internal/refcount.h
index ee506e592d..7412d62f56 100644
--- a/include/internal/refcount.h
+++ b/include/internal/refcount.h
@@ -11,13 +11,7 @@
# pragma once
# include <openssl/e_os2.h>
-
-/* Used to checking reference counts, most while doing perl5 stuff :-) */
-# if defined(OPENSSL_NO_STDIO)
-# if defined(REF_PRINT)
-# error "REF_PRINT requires stdio"
-# endif
-# endif
+# include <openssl/trace.h>
# ifndef OPENSSL_DEV_NO_ATOMICS
# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
@@ -176,11 +170,9 @@ typedef int CRYPTO_REF_COUNT;
# define REF_ASSERT_ISNT(i)
# endif
-# ifdef REF_PRINT
-# define REF_PRINT_COUNT(a, b) \
- fprintf(stderr, "%p:%4d:%s\n", (void*)b, b->references, a)
-# else
-# define REF_PRINT_COUNT(a, b)
-# endif
+# define REF_PRINT_EX(text, count, object) \
+ OSSL_TRACE3(REF_COUNT, "%p:%4d:%s\n", (object), (count), (text));
+# define REF_PRINT_COUNT(text, object) \
+ REF_PRINT_EX(text, object->references, (void *)object)
#endif
diff --git a/include/openssl/e_os2.h b/include/openssl/e_os2.h
index 4ee41cad26..49e6dad73c 100644
--- a/include/openssl/e_os2.h
+++ b/include/openssl/e_os2.h
@@ -210,7 +210,7 @@ extern "C" {
# endif
# endif
-# ifdef DEBUG_UNUSED
+# if defined(UNUSEDRESULT_DEBUG)
# define __owur __attribute__((__warn_unused_result__))
# else
# define __owur
diff --git a/include/openssl/trace.h b/include/openssl/trace.h
index ad57babe4f..58e5cc8f11 100644
--- a/include/openssl/trace.h
+++ b/include/openssl/trace.h
@@ -56,7 +56,9 @@ extern "C" {
# define OSSL_TRACE_CATEGORY_STORE 14
# define OSSL_TRACE_CATEGORY_DECODER 15
# define OSSL_TRACE_CATEGORY_ENCODER 16
-# define OSSL_TRACE_CATEGORY_NUM 17
+# define OSSL_TRACE_CATEGORY_REF_COUNT 17
+/* Count of available categories. */
+# define OSSL_TRACE_CATEGORY_NUM 18
/* Returns the trace category number for the given |name| */
int OSSL_trace_get_category_num(const char *name);