Add BIO_get_new_index()

Reviewed-by: Dr. Stephen Henson <steve@openssl.org>
diff --git a/crypto/bio/bio_meth.c b/crypto/bio/bio_meth.c
index d172047..7754b00 100644
--- a/crypto/bio/bio_meth.c
+++ b/crypto/bio/bio_meth.c
@@ -9,6 +9,18 @@
 
 #include "bio_lcl.h"
 
+CRYPTO_RWLOCK *bio_type_lock;
+static int bio_count = BIO_TYPE_START;
+
+int BIO_get_new_index()
+{
+    int newval;
+
+    if (!CRYPTO_atomic_add(&bio_count, 1, &newval, bio_type_lock))
+        return -1;
+    return newval;
+}
+
 BIO_METHOD *BIO_meth_new(int type, const char *name)
 {
     BIO_METHOD *biom = OPENSSL_zalloc(sizeof(BIO_METHOD));