commit 8f5922912809fb738ef5a19ab2b00e2c0067897e
Author: Fedor Indutny <fedor.indutny@gmail.com>
Date:   Tue Oct 9 18:14:34 2012 +0700

    crypto: use atomic operations on gcc

diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c
index 0f05743..90de6b8 100644
--- a/crypto/cryptlib.c
+++ b/crypto/cryptlib.c
@@ -629,6 +629,10 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
 		}
 	else
 		{
+#if defined(__GNUC__) && \
+    ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
+		return __sync_add_and_fetch(pointer, amount);
+#else
 		CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,file,line);
 
 		ret= *pointer+amount;
@@ -645,6 +649,7 @@ int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
 #endif
 		*pointer=ret;
 		CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line);
+#endif
 		}
 	return(ret);
 	}
