]> git.saurik.com Git - apple/xnu.git/blob - EXTERNAL_HEADERS/corecrypto/cc_debug.h
xnu-4903.221.2.tar.gz
[apple/xnu.git] / EXTERNAL_HEADERS / corecrypto / cc_debug.h
1 /*
2 * cc_debug.h
3 * corecrypto
4 *
5 * Created on 01/25/2012
6 *
7 * Copyright (c) 2012,2014,2015 Apple Inc. All rights reserved.
8 *
9 */
10
11 //debug configuration header file
12 #ifndef _CORECRYPTO_CCN_DEBUG_H_
13 #define _CORECRYPTO_CCN_DEBUG_H_
14
15 #include <corecrypto/cc_config.h>
16
17 // DO NOT INCLUDE this HEADER file in CoreCrypto files added for XNU project or headers
18 // included by external clients.
19
20 // ========================
21 // Printf for corecrypto
22 // ========================
23 #if CC_KERNEL
24 #include <pexpert/pexpert.h>
25 #define cc_printf(x...) kprintf(x)
26 #if !CONFIG_EMBEDDED
27 extern int printf(const char *format, ...) __printflike(1,2);
28 #endif
29 #elif CC_USE_S3 || CC_IBOOT || CC_RTKIT || CC_RTKITROM
30 #include <stdio.h>
31 #define cc_printf(x...) printf(x)
32 #elif defined(__ANDROID_API__)
33 #include <android/log.h>
34 #define cc_printf(x...) __android_log_print(ANDROID_LOG_DEBUG, "corecrypto", x);
35 #else
36 #include <stdio.h>
37 #define cc_printf(x...) fprintf(stderr, x)
38 #endif
39
40 // ========================
41 // Integer types
42 // ========================
43
44 #if CC_KERNEL
45 /* Those are not defined in libkern */
46 #define PRIx64 "llx"
47 #define PRIx32 "x"
48 #define PRIx16 "hx"
49 #define PRIx8 "hhx"
50 #else
51 #include <inttypes.h>
52 #endif
53
54 #if CCN_UNIT_SIZE == 8
55 #define CCPRIx_UNIT ".016" PRIx64
56 #elif CCN_UNIT_SIZE == 4
57 #define CCPRIx_UNIT ".08" PRIx32
58 #elif CCN_UNIT_SIZE == 2
59 #define CCPRIx_UNIT ".04" PRIx16
60 #elif CCN_UNIT_SIZE == 1
61 #define CCPRIx_UNIT ".02" PRIx8
62 #else
63 #error invalid CCN_UNIT_SIZE
64 #endif
65
66 // ========================
67 // Print utilities for corecrypto
68 // ========================
69
70 #include <corecrypto/cc.h>
71
72 /* Print a byte array of arbitrary size */
73 void cc_print(const char *label, size_t count, const uint8_t *s);
74
75 #endif /* _CORECRYPTO_CCN_DEBUG_H_ */