Convert reference counts in crypto/

This change converts the reference counts in crypto/ to use
|CRYPTO_refcount_t|. The reference counts in |X509_PKEY| and |X509_INFO|
were never actually used and so were dropped.

Change-Id: I75d572cdac1f8c1083c482e29c9519282d7fd16c
Reviewed-on: https://boringssl-review.googlesource.com/4772
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/include/openssl/x509.h b/include/openssl/x509.h
index ef1d7fb..69c7da6 100644
--- a/include/openssl/x509.h
+++ b/include/openssl/x509.h
@@ -73,13 +73,14 @@
 #include <openssl/cipher.h>
 #include <openssl/dh.h>
 #include <openssl/dsa.h>
-#include <openssl/ec.h>
 #include <openssl/ecdh.h>
 #include <openssl/ecdsa.h>
+#include <openssl/ec.h>
 #include <openssl/evp.h>
 #include <openssl/rsa.h>
 #include <openssl/sha.h>
 #include <openssl/stack.h>
+#include <openssl/thread.h>
 
 #ifdef  __cplusplus
 extern "C" {
@@ -204,7 +205,7 @@
 	X509_REQ_INFO *req_info;
 	X509_ALGOR *sig_alg;
 	ASN1_BIT_STRING *signature;
-	int references;
+	CRYPTO_refcount_t references;
 	} X509_REQ;
 
 typedef struct x509_cinf_st
@@ -243,7 +244,7 @@
 	X509_ALGOR *sig_alg;
 	ASN1_BIT_STRING *signature;
 	int valid;
-	int references;
+	CRYPTO_refcount_t references;
 	char *name;
 	CRYPTO_EX_DATA ex_data;
 	/* These contain copies of various extension values */
@@ -420,7 +421,7 @@
 	X509_CRL_INFO *crl;
 	X509_ALGOR *sig_alg;
 	ASN1_BIT_STRING *signature;
-	int references;
+	CRYPTO_refcount_t references;
 	int flags;
 	/* Copies of various extensions */
 	AUTHORITY_KEYID *akid;
@@ -457,8 +458,6 @@
 
 	/* expanded version of 'enc_algor' */
 	EVP_CIPHER_INFO cipher;
-
-	int references;
 	} X509_PKEY;
 
 #ifndef OPENSSL_NO_EVP
@@ -472,7 +471,6 @@
 	int enc_len;
 	char *enc_data;
 
-	int references;
 	} X509_INFO;
 
 DECLARE_STACK_OF(X509_INFO)