Commit d0ab8a25 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Namespace the helper macro in folly/ssl/OpenSSLPtrTypes.h

Summary: [Folly] Namespace the helper macro in `folly/ssl/OpenSSLPtrTypes.h`.

Reviewed By: Orvid

Differential Revision: D15370971

fbshipit-source-id: aa907f60fee5ef58c5484838a3bde0d68e65b249
parent b66fc0c7
...@@ -24,71 +24,97 @@ ...@@ -24,71 +24,97 @@
namespace folly { namespace folly {
namespace ssl { namespace ssl {
// helper which translates (DEFINE_SSL_PTR_TYPE(Foo, FOO, FOO_free); into // helper which translates:
// using FooDeleter = folly::static_function_deleter<FOO, &FOO_free>; // FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(Foo, FOO, FOO_free);
// using FooUniquePtr = std::unique_ptr<FOO, FooDeleter>; // into
#define DEFINE_SSL_PTR_TYPE(alias, object, deleter) \ // using FooDeleter = folly::static_function_deleter<FOO, &FOO_free>;
// using FooUniquePtr = std::unique_ptr<FOO, FooDeleter>;
#define FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(alias, object, deleter) \
using alias##Deleter = folly::static_function_deleter<object, &deleter>; \ using alias##Deleter = folly::static_function_deleter<object, &deleter>; \
using alias##UniquePtr = std::unique_ptr<object, alias##Deleter> using alias##UniquePtr = std::unique_ptr<object, alias##Deleter>
// ASN1 // ASN1
DEFINE_SSL_PTR_TYPE(ASN1Time, ASN1_TIME, ASN1_TIME_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(ASN1Time, ASN1_TIME, ASN1_TIME_free);
DEFINE_SSL_PTR_TYPE(ASN1Ia5Str, ASN1_IA5STRING, ASN1_IA5STRING_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
DEFINE_SSL_PTR_TYPE(ASN1Int, ASN1_INTEGER, ASN1_INTEGER_free); ASN1Ia5Str,
DEFINE_SSL_PTR_TYPE(ASN1Obj, ASN1_OBJECT, ASN1_OBJECT_free); ASN1_IA5STRING,
DEFINE_SSL_PTR_TYPE(ASN1Str, ASN1_STRING, ASN1_STRING_free); ASN1_IA5STRING_free);
DEFINE_SSL_PTR_TYPE(ASN1Type, ASN1_TYPE, ASN1_TYPE_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(ASN1Int, ASN1_INTEGER, ASN1_INTEGER_free);
DEFINE_SSL_PTR_TYPE(ASN1UTF8Str, ASN1_UTF8STRING, ASN1_UTF8STRING_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(ASN1Obj, ASN1_OBJECT, ASN1_OBJECT_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(ASN1Str, ASN1_STRING, ASN1_STRING_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(ASN1Type, ASN1_TYPE, ASN1_TYPE_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
ASN1UTF8Str,
ASN1_UTF8STRING,
ASN1_UTF8STRING_free);
// X509 // X509
DEFINE_SSL_PTR_TYPE(X509, X509, X509_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(X509, X509, X509_free);
DEFINE_SSL_PTR_TYPE(X509Extension, X509_EXTENSION, X509_EXTENSION_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
DEFINE_SSL_PTR_TYPE(X509Store, X509_STORE, X509_STORE_free); X509Extension,
DEFINE_SSL_PTR_TYPE(X509StoreCtx, X509_STORE_CTX, X509_STORE_CTX_free); X509_EXTENSION,
X509_EXTENSION_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(X509Store, X509_STORE, X509_STORE_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
X509StoreCtx,
X509_STORE_CTX,
X509_STORE_CTX_free);
using X509VerifyParamDeleter = using X509VerifyParamDeleter =
folly::static_function_deleter<X509_VERIFY_PARAM, &X509_VERIFY_PARAM_free>; folly::static_function_deleter<X509_VERIFY_PARAM, &X509_VERIFY_PARAM_free>;
using X509VerifyParam = using X509VerifyParam =
std::unique_ptr<X509_VERIFY_PARAM, X509VerifyParamDeleter>; std::unique_ptr<X509_VERIFY_PARAM, X509VerifyParamDeleter>;
DEFINE_SSL_PTR_TYPE(GeneralName, GENERAL_NAME, GENERAL_NAME_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(GeneralName, GENERAL_NAME, GENERAL_NAME_free);
DEFINE_SSL_PTR_TYPE(GeneralNames, GENERAL_NAMES, GENERAL_NAMES_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
DEFINE_SSL_PTR_TYPE( GeneralNames,
GENERAL_NAMES,
GENERAL_NAMES_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
AccessDescription, AccessDescription,
ACCESS_DESCRIPTION, ACCESS_DESCRIPTION,
ACCESS_DESCRIPTION_free); ACCESS_DESCRIPTION_free);
DEFINE_SSL_PTR_TYPE( FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
AuthorityInfoAccess, AuthorityInfoAccess,
AUTHORITY_INFO_ACCESS, AUTHORITY_INFO_ACCESS,
AUTHORITY_INFO_ACCESS_free); AUTHORITY_INFO_ACCESS_free);
DEFINE_SSL_PTR_TYPE(DistPointName, DIST_POINT_NAME, DIST_POINT_NAME_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
DEFINE_SSL_PTR_TYPE(DistPoint, DIST_POINT, DIST_POINT_free); DistPointName,
DEFINE_SSL_PTR_TYPE(CrlDistPoints, CRL_DIST_POINTS, CRL_DIST_POINTS_free); DIST_POINT_NAME,
DEFINE_SSL_PTR_TYPE(X509Crl, X509_CRL, X509_CRL_free); DIST_POINT_NAME_free);
DEFINE_SSL_PTR_TYPE(X509Name, X509_NAME, X509_NAME_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(DistPoint, DIST_POINT, DIST_POINT_free);
DEFINE_SSL_PTR_TYPE(X509Req, X509_REQ, X509_REQ_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
DEFINE_SSL_PTR_TYPE(X509Revoked, X509_REVOKED, X509_REVOKED_free); CrlDistPoints,
CRL_DIST_POINTS,
CRL_DIST_POINTS_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(X509Crl, X509_CRL, X509_CRL_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(X509Name, X509_NAME, X509_NAME_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(X509Req, X509_REQ, X509_REQ_free);
FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(X509Revoked, X509_REVOKED, X509_REVOKED_free);
// EVP // EVP
DEFINE_SSL_PTR_TYPE(EvpPkey, EVP_PKEY, EVP_PKEY_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(EvpPkey, EVP_PKEY, EVP_PKEY_free);
using EvpPkeySharedPtr = std::shared_ptr<EVP_PKEY>; using EvpPkeySharedPtr = std::shared_ptr<EVP_PKEY>;
// No EVP_PKEY_CTX <= 0.9.8b // No EVP_PKEY_CTX <= 0.9.8b
#if OPENSSL_VERSION_NUMBER >= 0x10000002L #if OPENSSL_VERSION_NUMBER >= 0x10000002L
DEFINE_SSL_PTR_TYPE(EvpPkeyCtx, EVP_PKEY_CTX, EVP_PKEY_CTX_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(EvpPkeyCtx, EVP_PKEY_CTX, EVP_PKEY_CTX_free);
#else #else
struct EVP_PKEY_CTX; struct EVP_PKEY_CTX;
#endif #endif
DEFINE_SSL_PTR_TYPE(EvpMdCtx, EVP_MD_CTX, EVP_MD_CTX_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(EvpMdCtx, EVP_MD_CTX, EVP_MD_CTX_free);
DEFINE_SSL_PTR_TYPE(EvpCipherCtx, EVP_CIPHER_CTX, EVP_CIPHER_CTX_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(
EvpCipherCtx,
EVP_CIPHER_CTX,
EVP_CIPHER_CTX_free);
// HMAC // HMAC
DEFINE_SSL_PTR_TYPE(HmacCtx, HMAC_CTX, HMAC_CTX_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(HmacCtx, HMAC_CTX, HMAC_CTX_free);
// BIO // BIO
DEFINE_SSL_PTR_TYPE(BioMethod, BIO_METHOD, BIO_meth_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(BioMethod, BIO_METHOD, BIO_meth_free);
DEFINE_SSL_PTR_TYPE(Bio, BIO, BIO_vfree); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(Bio, BIO, BIO_vfree);
DEFINE_SSL_PTR_TYPE(BioChain, BIO, BIO_free_all); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(BioChain, BIO, BIO_free_all);
inline void BIO_free_fb(BIO* bio) { inline void BIO_free_fb(BIO* bio) {
CHECK_EQ(1, BIO_free(bio)); CHECK_EQ(1, BIO_free(bio));
} }
...@@ -96,22 +122,22 @@ using BioDeleterFb = folly::static_function_deleter<BIO, &BIO_free_fb>; ...@@ -96,22 +122,22 @@ using BioDeleterFb = folly::static_function_deleter<BIO, &BIO_free_fb>;
using BioUniquePtrFb = std::unique_ptr<BIO, BioDeleterFb>; using BioUniquePtrFb = std::unique_ptr<BIO, BioDeleterFb>;
// RSA and EC // RSA and EC
DEFINE_SSL_PTR_TYPE(Rsa, RSA, RSA_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(Rsa, RSA, RSA_free);
#ifndef OPENSSL_NO_EC #ifndef OPENSSL_NO_EC
DEFINE_SSL_PTR_TYPE(EcKey, EC_KEY, EC_KEY_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(EcKey, EC_KEY, EC_KEY_free);
DEFINE_SSL_PTR_TYPE(EcGroup, EC_GROUP, EC_GROUP_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(EcGroup, EC_GROUP, EC_GROUP_free);
DEFINE_SSL_PTR_TYPE(EcPoint, EC_POINT, EC_POINT_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(EcPoint, EC_POINT, EC_POINT_free);
DEFINE_SSL_PTR_TYPE(EcdsaSig, ECDSA_SIG, ECDSA_SIG_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(EcdsaSig, ECDSA_SIG, ECDSA_SIG_free);
#endif #endif
// BIGNUMs // BIGNUMs
DEFINE_SSL_PTR_TYPE(BIGNUM, BIGNUM, BN_clear_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(BIGNUM, BIGNUM, BN_clear_free);
DEFINE_SSL_PTR_TYPE(BNCtx, BN_CTX, BN_CTX_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(BNCtx, BN_CTX, BN_CTX_free);
// SSL and SSL_CTX // SSL and SSL_CTX
DEFINE_SSL_PTR_TYPE(SSL, SSL, SSL_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(SSL, SSL, SSL_free);
DEFINE_SSL_PTR_TYPE(SSLSession, SSL_SESSION, SSL_SESSION_free); FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE(SSLSession, SSL_SESSION, SSL_SESSION_free);
#undef DEFINE_SSL_PTR_TYPE #undef FOLLY_SSL_DETAIL_DEFINE_PTR_TYPE
} // namespace ssl } // namespace ssl
} // namespace folly } // namespace folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment