X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/fa7225c82381bac4432a6edf16f53b5370238d85..refs/heads/master:/OSX/libsecurity_utilities/lib/seccfobject.h diff --git a/OSX/libsecurity_utilities/lib/seccfobject.h b/OSX/libsecurity_utilities/lib/seccfobject.h index 26c39288..6ea5445e 100644 --- a/OSX/libsecurity_utilities/lib/seccfobject.h +++ b/OSX/libsecurity_utilities/lib/seccfobject.h @@ -29,7 +29,11 @@ #include #include #include "threading.h" +#include + +#if( __cplusplus <= 201103L) #include +#endif namespace Security { @@ -42,13 +46,15 @@ operator APIPTR() const \ \ OBJTYPE *retain() \ { SecCFObject::handle(true); return this; } \ -APIPTR handle(bool retain = true) \ +APIPTR CF_RETURNS_RETAINED handle() \ +{ return (APIPTR)SecCFObject::handle(true); } \ +APIPTR handle(bool retain) \ { return (APIPTR)SecCFObject::handle(retain); } #define SECCFFUNCTIONS_CREATABLE(OBJTYPE, APIPTR, CFCLASS) \ SECCFFUNCTIONS_BASE(OBJTYPE, APIPTR)\ \ -void *operator new(size_t size) throw(std::bad_alloc) \ +void *operator new(size_t size)\ { return SecCFObject::allocate(size, CFCLASS); } #define SECCFFUNCTIONS(OBJTYPE, APIPTR, ERRCODE, CFCLASS) \ @@ -73,13 +79,13 @@ struct SecRuntimeBase: CFRuntimeBase class SecCFObject { private: - void *operator new(size_t) throw(std::bad_alloc); + void *operator new(size_t); // Align up to a multiple of 16 bytes static const size_t kAlignedRuntimeSize = SECALIGNUP(sizeof(SecRuntimeBase), 4); uint32_t mRetainCount; - OSSpinLock mRetainSpinLock; + os_unfair_lock mRetainLock; public: // For use by SecPointer only. Returns true once the first time it's called after the object has been created. @@ -91,23 +97,23 @@ public: return !atomic_flag_test_and_set(&(base->isOld)); } - static SecCFObject *optional(CFTypeRef) throw(); + static SecCFObject *optional(CFTypeRef) _NOEXCEPT; static SecCFObject *required(CFTypeRef, OSStatus error); - static void *allocate(size_t size, const CFClass &cfclass) throw(std::bad_alloc); + static void *allocate(size_t size, const CFClass &cfclass); SecCFObject(); virtual ~SecCFObject(); uint32_t updateRetainCount(intptr_t direction, uint32_t *oldCount); uint32_t getRetainCount() {return updateRetainCount(0, NULL);} - static void operator delete(void *object) throw(); - virtual operator CFTypeRef() const throw() + static void operator delete(void *object) _NOEXCEPT; + virtual operator CFTypeRef() const _NOEXCEPT { return reinterpret_cast(reinterpret_cast(this) - kAlignedRuntimeSize); } // This bumps up the retainCount by 1, by calling CFRetain(), iff retain is true - CFTypeRef handle(bool retain = true) throw(); + CFTypeRef handle(bool retain = true) _NOEXCEPT; virtual bool equal(SecCFObject &other); virtual CFHashCode hash(); @@ -150,10 +156,12 @@ public: T *yield() { T *result = static_cast(ptr); ptr = NULL; return result; } // dereference operations - T* get () const { return static_cast(ptr); } // mimic auto_ptr + T* get () const { return static_cast(ptr); } // mimic unique_ptr operator T * () const { return static_cast(ptr); } T * operator -> () const { return static_cast(ptr); } T & operator * () const { return *static_cast(ptr); } + + SecPointer& operator=(const SecPointer& other) { SecPointerBase::operator=(other); return *this; } }; template