#ifndef _CK_FEEDEBUG_H_
#define _CK_FEEDEBUG_H_
#include "giantIntegers.h"
#include "elliptic.h"
#include "curveParams.h"
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef NDEBUG
#define FEE_DEBUG 0
#else
#define FEE_DEBUG 1
#endif
extern void printGiant(const giant x);
extern void printGiantHex(const giant x);
extern void printGiantExp(const giant x);
extern void printKey(const key k);
extern void printCurveParams(const curveParams *p);
#if FEE_DEBUG
#define dbgLog(x) printf x
#else
#define dbgLog(x)
#endif
#define FEE_PROFILE 0
#define ELL_PROFILE 0
#if (FEE_PROFILE || ELL_PROFILE)
#include <kern/time_stamp.h>
#endif
#define CPROF_START \
struct tsval _profStartTime; \
struct tsval _profEndTime; \
kern_timestamp(&_profStartTime);
#define CPROF_END(accum) \
kern_timestamp(&_profEndTime); \
accum += (_profEndTime.low_val - _profStartTime.low_val);
#define CPROF_INCR(ctr) ctr++
#if FEE_PROFILE
#define PROF_START CPROF_START
#define PROF_END(a) CPROF_END(a)
#define PROF_INCR(ctr) CPROF_INCR(ctr)
#define PROF_TIME_MULGS 0
extern unsigned ellAddTime;
extern unsigned whichCurveTime;
extern unsigned ellipticTime;
extern unsigned sigCompTime;
extern unsigned numerDoubleTime;
extern unsigned numerPlusTime;
extern unsigned numerTimesTime;
extern unsigned denomDoubleTime;
extern unsigned denomTimesTime;
extern unsigned powerModTime;
extern unsigned modgTime;
extern unsigned binvauxTime;
extern unsigned numMulg;
extern unsigned numFeemod;
extern unsigned numGsquare;
extern unsigned numBorrows;
extern void clearProfile();
#else
#define PROF_START
#define PROF_END(a)
#define PROF_INCR(ctr)
#endif
#if ELL_PROFILE
extern unsigned ellOddTime;
extern unsigned ellEvenTime;
extern unsigned numEllOdds;
extern unsigned numEllEvens;
extern void clearEllProfile();
#define EPROF_START CPROF_START
#define EPROF_END(a) CPROF_END(a)
#define EPROF_INCR(ctr) CPROF_INCR(ctr)
#else
#define EPROF_START
#define EPROF_END(a)
#define EPROF_INCR(ctr)
#endif
#if !FEE_DEBUG
#ifndef NULL
#define NULL ((void *)0)
#endif
#endif
#if FEE_DEBUG
#include "platform.h"
#define CKASSERT(expression) \
((expression) ? (void)0 : \
(printf ("Assertion failed: " #expression \
", file " __FILE__ ", line %d.\n", __LINE__), \
CKRaise("Assertion Failure")))
#else
#define CKASSERT(expression)
#endif
#ifdef __cplusplus
}
#endif
#endif