1 /* Copyright (c) 1997 Apple Computer, Inc.
14 * enable general debugging printfs and error checking.
20 #define ddprintf(x) printf x
28 #define COM_SCAN_DEBUG 0
30 #define scprintf(x) printf x
36 * 2nd-level comcrypt debug
38 #define LEVEL2_DEBUG 0
42 #define l2printf(x) printf x
48 * lookahead queue debug
50 #define COM_LA_DEBUG 0
51 #define COM_LA_PRINTF 0
53 #define laprintf(x) printf x
59 * Statistics measurements. This is a private API.
70 * Info obtained via a call to getComStats()
73 unsigned level1blocks
;
74 unsigned plaintextBytes
;
75 unsigned ciphertextBytes
;
76 unsigned oneByteFrags
; // 1st level only
77 unsigned twoByteFrags
; // ditto
78 unsigned level2oneByteFrags
; // second level only
79 unsigned level2twoByteFrags
; // ditto
80 unsigned level2byteCode
; // bytes, pre-encrypted
81 unsigned level2cipherText
; // bytes, post-encrypt
82 unsigned level2blocks
; // 2nd-level blocks
83 unsigned level2jmatch
; // total jmatch (at first level) of
87 extern comStats _comStats
;
88 #define incrComStat(stat, num) _comStats.stat += num;
90 #define incr1byteFrags(recursLevel) { \
91 if(recursLevel == 1) { \
92 incrComStat(level2oneByteFrags, 1); \
95 incrComStat(oneByteFrags, 1); \
98 #define incr2byteFrags(recursLevel) { \
99 if(recursLevel == 1) { \
100 incrComStat(level2twoByteFrags, 1); \
103 incrComStat(twoByteFrags, 1); \
107 extern void resetComStats();
108 extern void getComStats(comStats
*stats
);
111 #define incrComStat(stat, num)
112 #define incr1byteFrags(recursLevel)
113 #define incr2byteFrags(recursLevel)
117 * Profiling measurement. A private API when enabled.
120 #define COM_PROFILE 0
122 #define COM_PROFILE 0
127 #include <kern/time_stamp.h>
130 * Global profiling enable. It turns out the the cost of doing the
131 * kern_timestamp() call twice per codeword is way more expensive
132 * than the actual comcryption code. Setting this variable to zero
133 * avoids the cost of all the timestamps for reference without
134 * rebuilding. Also, the cmcPerWordOhead calibrates the actual
135 * cost of the two kern_timestamp() calls per word.
137 extern unsigned comProfEnable
;
140 * Profiling accumulators.
142 typedef unsigned comprof_t
;
144 extern comprof_t cmcTotal
;
145 extern comprof_t cmcQueSearch
;
146 extern comprof_t cmcQueMatchMove
;
147 extern comprof_t cmcQueMissMove
;
148 extern comprof_t cmcPerWordOhead
;
149 extern comprof_t cmcLevel2
;
153 * Place one of these in the local variable declaration list of each routine
154 * which will do profiling.
156 #define COMPROF_LOCALS \
157 struct tsval _profStartTime; \
158 struct tsval _profEndTime;
163 #define COMPROF_START \
164 if(comProfEnable) { \
165 kern_timestamp(&_profStartTime); \
169 * Stop the clock and gather elapsed time to specified accumulator.
171 #define COMPROF_END(accum) \
172 if(comProfEnable) { \
173 kern_timestamp(&_profEndTime); \
174 accum += (_profEndTime.low_val - _profStartTime.low_val); \
180 #define COMPROF_LOCALS
181 #define COMPROF_START
182 #define COMPROF_END(accum)
184 #endif /* COM_PROFILE */
187 * Get/set parameter API, private, for debug only.
190 #define COM_PARAM_ENABLE 1
192 #define COM_PARAM_ENABLE 0
197 extern unsigned getF1(comcryptObj cobj
);
198 extern void setF1(comcryptObj cobj
, unsigned f1
);
199 extern unsigned getF2(comcryptObj cobj
);
200 extern void setF2(comcryptObj cobj
, unsigned f2
);
201 extern unsigned getJmatchThresh(comcryptObj cobj
);
202 extern void setJmatchThresh(comcryptObj cobj
, unsigned jmatchThresh
);
203 extern unsigned getMinByteCode(comcryptObj cobj
);
204 extern void setMinByteCode(comcryptObj cobj
, unsigned minByteCode
);
206 #endif /*COM_PARAM_ENABLE*/
212 #endif /*_COM_DEBUG_H_*/