]>
git.saurik.com Git - apple/security.git/blob - OSX/authd/debugging.h
1 /* Copyright (c) 2012 Apple Inc. All Rights Reserved. */
3 #ifndef _SECURITY_AUTH_DEBUGGING_H_
4 #define _SECURITY_AUTH_DEBUGGING_H_
6 #if defined(__cplusplus)
11 #include <os/activity.h>
13 #define AUTHD_DEFINE_LOG \
14 static os_log_t AUTHD_LOG_DEFAULT() { \
15 static dispatch_once_t once; \
16 static os_log_t log; \
17 dispatch_once(&once, ^{ log = os_log_create("com.apple.Authorization", "authd"); }); \
21 #define AUTHD_LOG AUTHD_LOG_DEFAULT()
23 #define CFReleaseSafe(CF) { CFTypeRef _cf = (CF); if (_cf) CFRelease(_cf); }
24 #define CFReleaseNull(CF) { CFTypeRef _cf = (CF); \
25 if (_cf) { (CF) = NULL; CFRelease(_cf); } }
26 #define CFRetainSafe(CF) { CFTypeRef _cf = (CF); if (_cf) CFRetain(_cf); }
27 #define CFAssignRetained(VAR,CF) ({ \
28 __typeof__(VAR) *const _pvar = &(VAR); \
29 __typeof__(CF) _cf = (CF); \
30 (*_pvar) = *_pvar ? (CFRelease(*_pvar), _cf) : _cf; \
33 #define xpc_release_safe(obj) if (obj) { xpc_release(obj); obj = NULL; }
34 #define free_safe(obj) if (obj) { free(obj); obj = NULL; }
36 #if defined(__cplusplus)
40 #endif /* !_SECURITY_AUTH_DEBUGGING_H_ */