]> git.saurik.com Git - apple/security.git/blob - OSX/authd/debugging.h
0e0638b3a20563abe00f1713120f93f73aabd3ff
[apple/security.git] / OSX / authd / debugging.h
1 /* Copyright (c) 2012 Apple Inc. All Rights Reserved. */
2
3 #ifndef _SECURITY_AUTH_DEBUGGING_H_
4 #define _SECURITY_AUTH_DEBUGGING_H_
5
6 #if defined(__cplusplus)
7 extern "C" {
8 #endif
9
10 #include <os/log.h>
11 #include <os/activity.h>
12
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"); }); \
18 return log; \
19 };
20
21 #define AUTHD_LOG AUTHD_LOG_DEFAULT()
22
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
28 #define xpc_release_safe(obj) if (obj) { xpc_release(obj); obj = NULL; }
29 #define free_safe(obj) if (obj) { free(obj); obj = NULL; }
30
31 #if defined(__cplusplus)
32 }
33 #endif
34
35 #endif /* !_SECURITY_AUTH_DEBUGGING_H_ */