From: Pauli Date: Mon, 21 Aug 2017 21:17:35 +0000 (+1000) Subject: Move the REF_PRINT support from e_os.h to internal/refcount.h. X-Git-Tag: OpenSSL_1_1_1-pre1~744 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd420b0b1f2336972e386eba1cccf23b47d99538;p=thirdparty%2Fopenssl.git 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) --- diff --git a/crypto/asn1/tasn_utl.c b/crypto/asn1/tasn_utl.c index 5f7e4fbde2e..cf434aa23cd 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 9e8877e2d7a..4530ce73453 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 efd98c21cf4..caaa65c1f53 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 3645c8d603a..3c83ab8e914 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 882c8822969..38745531791 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 6f754164252..c7557882fac 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 edea1f8810c..3863a61b020 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 266d8ca47b9..74539375be9 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 92d872886b2..45ec8133766 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 7d915aa7624..f45b06112d3 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 49f8651e9a6..c634670fa6e 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 63ad319181d..c870f392491 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 2310e32c84b..14089f56554 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 591561ffeeb..c1663a0f839 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 ad78545f8c9..bbffce0f93f 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 eb8603da1e8..cac8820013c 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 ea5309e8195..575cd70ef03 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"