]>
git.saurik.com Git - apple/security.git/blob - OSX/libsecurity_cryptkit/lib/feeDebug.h
4 Contains: Debug macros.
7 Copyright: Copyright (c) 1998,2011,2014 Apple Inc.
10 Change History (most recent first):
12 <9> 10/06/98 ap Changed to compile with C++.
17 /* Copyright (c) 1998,2011,2014 Apple Inc. All Rights Reserved.
19 * NOTICE: USE OF THE MATERIALS ACCOMPANYING THIS NOTICE IS SUBJECT
20 * TO THE TERMS OF THE SIGNED "FAST ELLIPTIC ENCRYPTION (FEE) REFERENCE
21 * SOURCE CODE EVALUATION AGREEMENT" BETWEEN APPLE, INC. AND THE
22 * ORIGINAL LICENSEE THAT OBTAINED THESE MATERIALS FROM APPLE,
23 * INC. ANY USE OF THESE MATERIALS NOT PERMITTED BY SUCH AGREEMENT WILL
24 * EXPOSE YOU TO LIABILITY.
25 ***************************************************************************
28 #ifndef _CK_FEEDEBUG_H_
29 #define _CK_FEEDEBUG_H_
31 #include "giantIntegers.h"
33 #include "curveParams.h"
49 extern void printGiant(const giant x
);
50 extern void printGiantHex(const giant x
);
51 extern void printGiantExp(const giant x
);
52 extern void printKey(const key k
);
53 extern void printCurveParams(const curveParams
*p
);
57 #define dbgLog(x) printf x
64 #endif /* FEE_DEBUG */
69 #define FEE_PROFILE 0 /* general purpose profile */
70 #define ELL_PROFILE 0 /* ell_even/ell_odd only */
72 #if (FEE_PROFILE || ELL_PROFILE)
73 #include <kern/time_stamp.h>
74 #endif /* (FEE_PROFILE || ELL_PROFILE) */
77 * Place this macro after the last local and before any code in a routine
81 struct tsval _profStartTime; \
82 struct tsval _profEndTime; \
83 kern_timestamp(&_profStartTime);
86 * This one goes at the end of the routine, just before the (only) return.
87 * There must be a static accumulator (an unsigned int) on a per-routine basis.
89 #define CPROF_END(accum) \
90 kern_timestamp(&_profEndTime); \
91 accum += (_profEndTime.low_val - _profStartTime.low_val);
94 * Increment a profiling counter.
96 #define CPROF_INCR(ctr) ctr++
100 #define PROF_START CPROF_START
101 #define PROF_END(a) CPROF_END(a)
102 #define PROF_INCR(ctr) CPROF_INCR(ctr)
105 * As of 14 Apr 1998, we no longer time mulg or gsquare calls with this
106 * mechanism; the time overhead is the same magnitude as the mulg. Instead
107 * we'll just count the mulgs and gsquares.
109 #define PROF_TIME_MULGS 0
115 extern unsigned ellAddTime
;
116 extern unsigned whichCurveTime
;
117 extern unsigned ellipticTime
;
118 extern unsigned sigCompTime
;
121 * low-level primitives
123 extern unsigned numerDoubleTime
;
124 extern unsigned numerPlusTime
;
125 extern unsigned numerTimesTime
;
126 extern unsigned denomDoubleTime
;
127 extern unsigned denomTimesTime
;
128 extern unsigned powerModTime
;
129 extern unsigned modgTime
;
130 extern unsigned binvauxTime
;
133 * Counters for calculating microseconds per {mulg, feemod, ...}
135 extern unsigned numMulg
;
136 extern unsigned numFeemod
;
137 extern unsigned numGsquare
;
138 extern unsigned numBorrows
;
140 extern void clearProfile();
142 #else /* FEE_PROFILE */
145 #define PROF_INCR(ctr)
146 #endif /* FEE_PROFILE */
149 extern unsigned ellOddTime
;
150 extern unsigned ellEvenTime
;
151 extern unsigned numEllOdds
;
152 extern unsigned numEllEvens
;
153 extern void clearEllProfile();
155 #define EPROF_START CPROF_START
156 #define EPROF_END(a) CPROF_END(a)
157 #define EPROF_INCR(ctr) CPROF_INCR(ctr)
159 #else /* ELL_PROFILE */
162 #define EPROF_INCR(ctr)
163 #endif /* ELL_PROFILE */
166 * NULL gets defined externally if FEE_DEBUG is true..
170 #define NULL ((void *)0)
172 #endif /* !FEE_DEBUG */
176 #include "platform.h"
178 #define CKASSERT(expression) \
179 ((expression) ? (void)0 : \
180 (printf ("Assertion failed: " #expression \
181 ", file " __FILE__ ", line %d.\n", __LINE__), \
182 CKRaise("Assertion Failure")))
184 #else /* FEE_DEBUG */
186 #define CKASSERT(expression)
188 #endif /* FEE_DEBUG */
194 #endif /* _CK_FEEDEBUG_H_ */