Add infrastructure for reference counts.
OpenSSL has traditionally done reference counting with |int|s and the
|CRYPTO_add| function. Unless a special callback is installed (rare),
this is implemented by doing the reference count operations under a
lock.
This change adds infrastructure for handling reference counts and uses
atomic operations when C11 support is available.
Change-Id: Ia023ce432319efd00f77a7340da27d16ee4b63c3
Reviewed-on: https://boringssl-review.googlesource.com/4771
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt
index 6433dc6..7430b62 100644
--- a/crypto/CMakeLists.txt
+++ b/crypto/CMakeLists.txt
@@ -145,15 +145,17 @@
crypto
crypto.c
+ directory_posix.c
+ directory_win.c
+ ex_data.c
mem.c
+ refcount_c11.c
+ refcount_lock.c
thread.c
thread_none.c
thread_pthread.c
thread_win.c
- ex_data.c
time_support.c
- directory_posix.c
- directory_win.c
${CRYPTO_ARCH_SOURCES}
@@ -217,5 +219,13 @@
target_link_libraries(thread_test crypto)
+add_executable(
+ refcount_test
+
+ refcount_test.c
+)
+
+target_link_libraries(refcount_test crypto)
+
perlasm(cpu-x86_64-asm.${ASM_EXT} cpu-x86_64-asm.pl)
perlasm(cpu-x86-asm.${ASM_EXT} cpu-x86-asm.pl)