]> git.saurik.com Git - apple/security.git/blobdiff - OSX/libsecurity_utilities/lib/seccfobject.cpp
Security-59754.80.3.tar.gz
[apple/security.git] / OSX / libsecurity_utilities / lib / seccfobject.cpp
index 11220f456f5fb572deee35662b5ef720afa8dd10..04972e7c303951406e4446752c974e45785f782b 100644 (file)
 #include <security_utilities/cfclass.h>
 #include <security_utilities/errors.h>
 #include <security_utilities/debugging.h>
+#include <os/lock.h>
 
 #include <list>
 #include <security_utilities/globalizer.h>
+#if( __cplusplus <= 201103L)
 #include <stdatomic.h>
+#endif
 
 SecPointerBase::SecPointerBase(const SecPointerBase& p)
 {
@@ -109,7 +112,7 @@ void SecPointerBase::copy(SecCFObject * p)
 // SecCFObject
 //
 SecCFObject *
-SecCFObject::optional(CFTypeRef cfTypeRef) throw()
+SecCFObject::optional(CFTypeRef cfTypeRef) _NOEXCEPT
 {
        if (!cfTypeRef)
                return NULL;
@@ -128,7 +131,7 @@ SecCFObject::required(CFTypeRef cfTypeRef, OSStatus error)
 }
 
 void *
-SecCFObject::allocate(size_t size, const CFClass &cfclass) throw(std::bad_alloc)
+SecCFObject::allocate(size_t size, const CFClass &cfclass)
 {
        CFTypeRef p = _CFRuntimeCreateInstance(NULL, cfclass.typeID,
                size + kAlignedRuntimeSize - sizeof(CFRuntimeBase), NULL);
@@ -143,14 +146,10 @@ SecCFObject::allocate(size_t size, const CFClass &cfclass) throw(std::bad_alloc)
 }
 
 void
-SecCFObject::operator delete(void *object) throw()
+SecCFObject::operator delete(void *object) _NOEXCEPT
 {
        CFTypeRef cfType = reinterpret_cast<CFTypeRef>(reinterpret_cast<const uint8_t *>(object) - kAlignedRuntimeSize);
-    if (CF_IS_COLLECTABLE(cfType))
-    {
-        return;
-    }
-    
+
     CFAllocatorRef allocator = CFGetAllocator(cfType);
     CFAllocatorDeallocate(allocator, (void*) cfType);
 }
@@ -158,12 +157,12 @@ SecCFObject::operator delete(void *object) throw()
 SecCFObject::SecCFObject()
 {
     mRetainCount = 1;
-    mRetainSpinLock = OS_SPINLOCK_INIT;
+    mRetainLock = OS_UNFAIR_LOCK_INIT;
 }
 
 uint32_t SecCFObject::updateRetainCount(intptr_t direction, uint32_t *oldCount)
 {
-    OSSpinLockLock(&mRetainSpinLock);
+    os_unfair_lock_lock(&mRetainLock);
 
     if (oldCount != NULL)
     {
@@ -181,7 +180,7 @@ uint32_t SecCFObject::updateRetainCount(intptr_t direction, uint32_t *oldCount)
     
     uint32_t result = mRetainCount;
 
-    OSSpinLockUnlock(&mRetainSpinLock);
+    os_unfair_lock_unlock(&mRetainLock);
     
     return result;
 }
@@ -218,7 +217,7 @@ SecCFObject::copyDebugDesc()
 }
 
 CFTypeRef
-SecCFObject::handle(bool retain) throw()
+SecCFObject::handle(bool retain) _NOEXCEPT
 {
        CFTypeRef cfType = *this;
        if (retain && !isNew()) CFRetain(cfType);