From cd420b0b1f2336972e386eba1cccf23b47d99538 Mon Sep 17 00:00:00 2001 From: Pauli Date: Tue, 22 Aug 2017 07:17:35 +1000 Subject: [PATCH] Move the REF_PRINT support from e_os.h to internal/refcount.h. Reviewed-by: Andy Polyakov Reviewed-by: Richard Levitte (Merged from https://github.com/openssl/openssl/pull/4188) --- crypto/asn1/tasn_utl.c | 2 +- crypto/dh/dh_lib.c | 2 +- crypto/dsa/dsa_lib.c | 2 +- crypto/dso/dso_lib.c | 2 +- crypto/ec/ec_key.c | 2 +- crypto/ec/ec_mult.c | 2 +- crypto/ec/ecp_nistz256.c | 2 +- crypto/evp/p_lib.c | 2 +- crypto/rsa/rsa_lib.c | 2 +- crypto/x509/x509_lu.c | 2 +- crypto/x509/x509_set.c | 2 +- crypto/x509/x509cset.c | 2 +- e_os.h | 20 -------------------- include/internal/refcount.h | 22 ++++++++++++++++++++++ ssl/ssl_cert.c | 2 +- ssl/ssl_lib.c | 2 +- ssl/ssl_sess.c | 2 +- 17 files changed, 37 insertions(+), 35 deletions(-) diff --git a/crypto/asn1/tasn_utl.c b/crypto/asn1/tasn_utl.c index 5f7e4fbde2..cf434aa23c 100644 --- a/crypto/asn1/tasn_utl.c +++ b/crypto/asn1/tasn_utl.c @@ -10,7 +10,7 @@ #include #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include #include diff --git a/crypto/dh/dh_lib.c b/crypto/dh/dh_lib.c index 9e8877e2d7..4530ce7345 100644 --- a/crypto/dh/dh_lib.c +++ b/crypto/dh/dh_lib.c @@ -9,7 +9,7 @@ #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include "dh_locl.h" #include diff --git a/crypto/dsa/dsa_lib.c b/crypto/dsa/dsa_lib.c index efd98c21cf..caaa65c1f5 100644 --- a/crypto/dsa/dsa_lib.c +++ b/crypto/dsa/dsa_lib.c @@ -11,7 +11,7 @@ #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include "dsa_locl.h" #include diff --git a/crypto/dso/dso_lib.c b/crypto/dso/dso_lib.c index 3645c8d603..3c83ab8e91 100644 --- a/crypto/dso/dso_lib.c +++ b/crypto/dso/dso_lib.c @@ -8,7 +8,7 @@ */ #include "dso_locl.h" -#include "e_os.h" +#include "internal/refcount.h" static DSO_METHOD *default_DSO_meth = NULL; diff --git a/crypto/ec/ec_key.c b/crypto/ec/ec_key.c index 882c882296..3874553179 100644 --- a/crypto/ec/ec_key.c +++ b/crypto/ec/ec_key.c @@ -11,7 +11,7 @@ #include "internal/cryptlib.h" #include #include "ec_lcl.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index 6f75416425..c7557882fa 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -14,7 +14,7 @@ #include "internal/cryptlib.h" #include "internal/bn_int.h" #include "ec_lcl.h" -#include "e_os.h" +#include "internal/refcount.h" /* * This file implements the wNAF-based interleaving multi-exponentiation method diff --git a/crypto/ec/ecp_nistz256.c b/crypto/ec/ecp_nistz256.c index edea1f8810..3863a61b02 100644 --- a/crypto/ec/ecp_nistz256.c +++ b/crypto/ec/ecp_nistz256.c @@ -21,7 +21,7 @@ #include "internal/cryptlib.h" #include "internal/bn_int.h" #include "ec_lcl.h" -#include "e_os.h" +#include "internal/refcount.h" #if BN_BITS2 != 64 # define TOBN(hi,lo) lo,hi diff --git a/crypto/evp/p_lib.c b/crypto/evp/p_lib.c index 266d8ca47b..74539375be 100644 --- a/crypto/evp/p_lib.c +++ b/crypto/evp/p_lib.c @@ -9,7 +9,7 @@ #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include #include diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c index 92d872886b..45ec813376 100644 --- a/crypto/rsa/rsa_lib.c +++ b/crypto/rsa/rsa_lib.c @@ -10,7 +10,7 @@ #include #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include "internal/bn_int.h" #include diff --git a/crypto/x509/x509_lu.c b/crypto/x509/x509_lu.c index 7d915aa762..f45b06112d 100644 --- a/crypto/x509/x509_lu.c +++ b/crypto/x509/x509_lu.c @@ -9,7 +9,7 @@ #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include #include "internal/x509_int.h" diff --git a/crypto/x509/x509_set.c b/crypto/x509/x509_set.c index 49f8651e9a..c634670fa6 100644 --- a/crypto/x509/x509_set.c +++ b/crypto/x509/x509_set.c @@ -9,7 +9,7 @@ #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include #include diff --git a/crypto/x509/x509cset.c b/crypto/x509/x509cset.c index 63ad319181..c870f39249 100644 --- a/crypto/x509/x509cset.c +++ b/crypto/x509/x509cset.c @@ -9,7 +9,7 @@ #include #include "internal/cryptlib.h" -#include "e_os.h" +#include "internal/refcount.h" #include #include #include diff --git a/e_os.h b/e_os.h index 2310e32c84..14089f5655 100644 --- a/e_os.h +++ b/e_os.h @@ -25,13 +25,6 @@ extern "C" { #endif -/* 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 - /* * Format specifier for printing size_t. Original conundrum was to * get it working with -Wformat [-Werror], which can be considered @@ -59,19 +52,6 @@ extern "C" { * stand for in ILP32 and LP64 */ # endif -# if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO) -# define REF_ASSERT_ISNT(test) \ - (void)((test) ? (OPENSSL_die("refcount error", __FILE__, __LINE__), 1) : 0) -# else -# define REF_ASSERT_ISNT(i) -# endif -# ifdef REF_PRINT -# define REF_PRINT_COUNT(a, b) \ - fprintf(stderr, "%p:%4d:%s\n", b, b->references, a) -# else -# define REF_PRINT_COUNT(a, b) -# endif - # define OPENSSL_CONF "openssl.cnf" # ifndef DEVRANDOM diff --git a/include/internal/refcount.h b/include/internal/refcount.h index 591561ffee..c1663a0f83 100644 --- a/include/internal/refcount.h +++ b/include/internal/refcount.h @@ -9,6 +9,13 @@ #ifndef HEADER_INTERNAL_REFCOUNT_H # define HEADER_INTERNAL_REFCOUNT_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 + # if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \ && !defined(__STDC_NO_ATOMICS__) # include @@ -64,4 +71,19 @@ typedef int CRYPTO_REF_COUNT; # define CRYPTO_DOWN_REF(val, ret, lock) CRYPTO_atomic_add(val, -1, ret, lock) # endif + +# if !defined(NDEBUG) && !defined(OPENSSL_NO_STDIO) +# define REF_ASSERT_ISNT(test) \ + (void)((test) ? (OPENSSL_die("refcount error", __FILE__, __LINE__), 1) : 0) +# else +# define REF_ASSERT_ISNT(i) +# endif + +# ifdef REF_PRINT +# define REF_PRINT_COUNT(a, b) \ + fprintf(stderr, "%p:%4d:%s\n", b, b->references, a) +# else +# define REF_PRINT_COUNT(a, b) +# endif + #endif diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c index ad78545f8c..bbffce0f93 100644 --- a/ssl/ssl_cert.c +++ b/ssl/ssl_cert.c @@ -24,7 +24,7 @@ #include #include #include -#include "e_os.h" +#include "internal/refcount.h" #include "ssl_locl.h" #include "ssl_cert_table.h" #include "internal/thread_once.h" diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index eb8603da1e..cac8820013 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -10,7 +10,6 @@ */ #include -#include "e_os.h" #include "ssl_locl.h" #include #include @@ -23,6 +22,7 @@ #include #include "internal/cryptlib.h" #include "internal/rand.h" +#include "internal/refcount.h" const char SSL_version_str[] = OPENSSL_VERSION_TEXT; diff --git a/ssl/ssl_sess.c b/ssl/ssl_sess.c index ea5309e819..575cd70ef0 100644 --- a/ssl/ssl_sess.c +++ b/ssl/ssl_sess.c @@ -12,7 +12,7 @@ #include #include #include -#include "e_os.h" +#include "internal/refcount.h" #include "ssl_locl.h" #include "statem/statem_locl.h" -- 2.34.1