]> git.saurik.com Git - apple/security.git/blob - OSX/authd/debugging.h
Security-59306.41.2.tar.gz
[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 #define CFAssignRetained(VAR,CF) ({ \
28 __typeof__(VAR) *const _pvar = &(VAR); \
29 __typeof__(CF) _cf = (CF); \
30 (*_pvar) = *_pvar ? (CFRelease(*_pvar), _cf) : _cf; \
31 })
32
33 #define xpc_release_safe(obj) if (obj) { xpc_release(obj); obj = NULL; }
34 #define free_safe(obj) if (obj) { free(obj); obj = NULL; }
35
36 #if defined(__cplusplus)
37 }
38 #endif
39
40 #endif /* !_SECURITY_AUTH_DEBUGGING_H_ */