Unify all counter registration code on uint16_t counter id's.

remotes/origin/master-1.0.x
Victor Julien 16 years ago
parent 244f5d547a
commit 63bc68ee90

@ -22,7 +22,7 @@ static PerfOPIfaceContext *perf_op_ctx = NULL;
* \brief Initializes the perf counter api. Things are hard coded currently. * \brief Initializes the perf counter api. Things are hard coded currently.
* More work to be done when we implement multiple interfaces * More work to be done when we implement multiple interfaces
*/ */
void PerfInitCounterApi() void PerfInitCounterApi(void)
{ {
PerfInitOPCtx(); PerfInitOPCtx();
@ -32,7 +32,7 @@ void PerfInitCounterApi()
/** /**
* \brief Initializes the output interface context * \brief Initializes the output interface context
*/ */
void PerfInitOPCtx() void PerfInitOPCtx(void)
{ {
if ( (perf_op_ctx = malloc(sizeof(PerfOPIfaceContext))) == NULL) { if ( (perf_op_ctx = malloc(sizeof(PerfOPIfaceContext))) == NULL) {
printf("error allocating memory\n"); printf("error allocating memory\n");
@ -67,7 +67,7 @@ void PerfInitOPCtx()
/** /**
* \brief Spawns the wakeup, and the management thread * \brief Spawns the wakeup, and the management thread
*/ */
void PerfSpawnThreads() void PerfSpawnThreads(void)
{ {
ThreadVars *tv_wakeup = NULL; ThreadVars *tv_wakeup = NULL;
ThreadVars *tv_mgmt = NULL; ThreadVars *tv_mgmt = NULL;
@ -208,7 +208,7 @@ void * PerfWakeupThread(void *arg)
* *
* \retval the counter id * \retval the counter id
*/ */
static u_int64_t PerfRegisterQualifiedCounter(char *cname, char *tm_name, static uint16_t PerfRegisterQualifiedCounter(char *cname, char *tm_name,
int type, char *desc, int type, char *desc,
PerfContext *pctx, int type_q) PerfContext *pctx, int type_q)
{ {
@ -307,42 +307,42 @@ static u_int64_t PerfRegisterQualifiedCounter(char *cname, char *tm_name,
return pc->id; return pc->id;
} }
u_int64_t PerfTVRegisterCounter(char *cname, struct ThreadVars_ *tv, int type, uint16_t PerfTVRegisterCounter(char *cname, struct ThreadVars_ *tv, int type,
char *desc) char *desc)
{ {
return PerfRegisterQualifiedCounter(cname, tv->name, type, desc, return PerfRegisterQualifiedCounter(cname, tv->name, type, desc,
&tv->pctx, TYPE_Q_NORMAL); &tv->pctx, TYPE_Q_NORMAL);
} }
u_int64_t PerfTVRegisterAvgCounter(char *cname, struct ThreadVars_ *tv, uint16_t PerfTVRegisterAvgCounter(char *cname, struct ThreadVars_ *tv,
int type, char *desc) int type, char *desc)
{ {
return PerfRegisterQualifiedCounter(cname, tv->name, type, desc, return PerfRegisterQualifiedCounter(cname, tv->name, type, desc,
&tv->pctx, TYPE_Q_AVERAGE); &tv->pctx, TYPE_Q_AVERAGE);
} }
u_int64_t PerfTVRegisterMaxCounter(char *cname, struct ThreadVars_ *tv, uint16_t PerfTVRegisterMaxCounter(char *cname, struct ThreadVars_ *tv,
int type, char *desc) int type, char *desc)
{ {
return PerfRegisterQualifiedCounter(cname, tv->name, type, desc, return PerfRegisterQualifiedCounter(cname, tv->name, type, desc,
&tv->pctx, TYPE_Q_MAXIMUM); &tv->pctx, TYPE_Q_MAXIMUM);
} }
u_int64_t PerfRegisterCounter(char *cname, char *tm_name, int type, char *desc, uint16_t PerfRegisterCounter(char *cname, char *tm_name, int type, char *desc,
PerfContext *pctx) PerfContext *pctx)
{ {
return PerfRegisterQualifiedCounter(cname, tm_name, type, desc, return PerfRegisterQualifiedCounter(cname, tm_name, type, desc,
pctx, TYPE_Q_NORMAL); pctx, TYPE_Q_NORMAL);
} }
u_int64_t PerfRegisterAvgCounter(char *cname, char *tm_name, int type, uint16_t PerfRegisterAvgCounter(char *cname, char *tm_name, int type,
char *desc, PerfContext *pctx) char *desc, PerfContext *pctx)
{ {
return PerfRegisterQualifiedCounter(cname, tm_name, type, desc, return PerfRegisterQualifiedCounter(cname, tm_name, type, desc,
pctx, TYPE_Q_AVERAGE); pctx, TYPE_Q_AVERAGE);
} }
u_int64_t PerfRegisterMaxCounter(char *cname, char *tm_name, int type, uint16_t PerfRegisterMaxCounter(char *cname, char *tm_name, int type,
char *desc, PerfContext *pctx) char *desc, PerfContext *pctx)
{ {
return PerfRegisterQualifiedCounter(cname, tm_name, type, desc, return PerfRegisterQualifiedCounter(cname, tm_name, type, desc,
@ -360,7 +360,7 @@ u_int64_t PerfRegisterMaxCounter(char *cname, char *tm_name, int type,
* *
* \retval 1 on success, 0 on failure * \retval 1 on success, 0 on failure
*/ */
int PerfCounterDisplay(u_int64_t id, PerfContext *pctx, int disp) int PerfCounterDisplay(uint16_t id, PerfContext *pctx, int disp)
{ {
PerfCounter *pc = NULL; PerfCounter *pc = NULL;
@ -393,7 +393,7 @@ int PerfCounterDisplay(u_int64_t id, PerfContext *pctx, int disp)
* \param id Index of the counter in the counter array * \param id Index of the counter in the counter array
* \param pca Counter array that holds the local counters for this TM * \param pca Counter array that holds the local counters for this TM
*/ */
inline void PerfCounterIncr(uint64_t id, PerfCounterArray *pca) inline void PerfCounterIncr(uint16_t id, PerfCounterArray *pca)
{ {
if (!pca) { if (!pca) {
#ifdef DEBUG #ifdef DEBUG
@ -433,7 +433,7 @@ inline void PerfCounterIncr(uint64_t id, PerfCounterArray *pca)
* \param pca Counter array that holds the local counter for this TM * \param pca Counter array that holds the local counter for this TM
* \param x Value to add to this local counter * \param x Value to add to this local counter
*/ */
inline void PerfCounterAddUI64(uint64_t id, PerfCounterArray *pca, uint64_t x) inline void PerfCounterAddUI64(uint16_t id, PerfCounterArray *pca, uint64_t x)
{ {
if (!pca) { if (!pca) {
#ifdef DEBUG #ifdef DEBUG
@ -473,7 +473,7 @@ inline void PerfCounterAddUI64(uint64_t id, PerfCounterArray *pca, uint64_t x)
* \param pca Counter array that holds the local counter for this TM * \param pca Counter array that holds the local counter for this TM
* \param x Value to add to this local counter * \param x Value to add to this local counter
*/ */
inline void PerfCounterAddDouble(uint64_t id, PerfCounterArray *pca, double x) inline void PerfCounterAddDouble(uint16_t id, PerfCounterArray *pca, double x)
{ {
if (!pca) { if (!pca) {
#ifdef DEBUG #ifdef DEBUG
@ -515,7 +515,7 @@ inline void PerfCounterAddDouble(uint64_t id, PerfCounterArray *pca, double x)
* \param pca Pointer to the PerfCounterArray * \param pca Pointer to the PerfCounterArray
* \param x The value to set for the counter * \param x The value to set for the counter
*/ */
inline void PerfCounterSetUI64(uint64_t id, PerfCounterArray *pca, inline void PerfCounterSetUI64(uint16_t id, PerfCounterArray *pca,
uint64_t x) uint64_t x)
{ {
if (!pca) { if (!pca) {
@ -565,7 +565,7 @@ inline void PerfCounterSetUI64(uint64_t id, PerfCounterArray *pca,
* \param pca Pointer to the PerfCounterArray * \param pca Pointer to the PerfCounterArray
* \param x The value to set for the counter * \param x The value to set for the counter
*/ */
inline void PerfCounterSetDouble(uint64_t id, PerfCounterArray *pca, inline void PerfCounterSetDouble(uint16_t id, PerfCounterArray *pca,
double x) double x)
{ {
if (!pca) { if (!pca) {
@ -706,7 +706,7 @@ int PerfAddToClubbedTMTable(char *tm_name, PerfContext *pctx)
* *
* \retval a counter-array in this(s_id-e_id) range for this TM instance * \retval a counter-array in this(s_id-e_id) range for this TM instance
*/ */
PerfCounterArray * PerfGetCounterArrayRange(uint32_t s_id, uint32_t e_id, PerfCounterArray * PerfGetCounterArrayRange(uint16_t s_id, uint16_t e_id,
PerfContext *pctx) PerfContext *pctx)
{ {
PerfCounter *pc = NULL; PerfCounter *pc = NULL;
@ -1331,7 +1331,7 @@ static int PerfTestUpdateCounter09()
{ {
ThreadVars tv; ThreadVars tv;
PerfCounterArray *pca = NULL; PerfCounterArray *pca = NULL;
int id1, id2; uint16_t id1, id2;
int result; int result;
memset(&tv, 0, sizeof(ThreadVars)); memset(&tv, 0, sizeof(ThreadVars));
@ -1361,7 +1361,7 @@ static int PerfTestUpdateGlobalCounter10()
PerfCounterArray *pca = NULL; PerfCounterArray *pca = NULL;
int result = 1; int result = 1;
int id1, id2, id3; uint16_t id1, id2, id3;
uint64_t *p = NULL; uint64_t *p = NULL;
memset(&tv, 0, sizeof(ThreadVars)); memset(&tv, 0, sizeof(ThreadVars));
@ -1400,7 +1400,7 @@ static int PerfTestCounterValues11()
PerfCounterArray *pca = NULL; PerfCounterArray *pca = NULL;
int result = 1; int result = 1;
int id1, id2, id3, id4; uint16_t id1, id2, id3, id4;
uint8_t *u8p; uint8_t *u8p;
memset(&tv, 0, sizeof(ThreadVars)); memset(&tv, 0, sizeof(ThreadVars));
@ -1457,7 +1457,7 @@ static int PerfTestAverageQual12()
double *d_temp = NULL; double *d_temp = NULL;
int result = 1; int result = 1;
int id1, id2; uint16_t id1, id2;
memset(&tv, 0, sizeof(ThreadVars)); memset(&tv, 0, sizeof(ThreadVars));
@ -1506,7 +1506,7 @@ static int PerfTestMaxQual13()
double *p; double *p;
int result = 1; int result = 1;
int id1; uint16_t id1;
memset(&tv, 0, sizeof(ThreadVars)); memset(&tv, 0, sizeof(ThreadVars));

@ -56,7 +56,7 @@ typedef struct PerfCounter_ {
PerfCounterValue *value; PerfCounterValue *value;
/* local id for this counter in this tm */ /* local id for this counter in this tm */
uint64_t id; uint16_t id;
char *desc; char *desc;
@ -79,7 +79,7 @@ typedef struct PerfContext_ {
/* flag set by the wakeup thread, to inform the client threads to sync */ /* flag set by the wakeup thread, to inform the client threads to sync */
uint32_t perf_flag; uint32_t perf_flag;
uint32_t curr_id; uint16_t curr_id;
/* mutex to prevent simultaneous access during update_counter/output_stat */ /* mutex to prevent simultaneous access during update_counter/output_stat */
pthread_mutex_t m; pthread_mutex_t m;
@ -88,7 +88,7 @@ typedef struct PerfContext_ {
/* PerfCounterArray(PCA) Node*/ /* PerfCounterArray(PCA) Node*/
typedef struct PCAElem_ { typedef struct PCAElem_ {
PerfCounter *pc; PerfCounter *pc;
uint64_t id; uint16_t id;
union { union {
uint64_t ui64_cnt; uint64_t ui64_cnt;
double d_cnt; double d_cnt;
@ -145,37 +145,37 @@ void * PerfMgmtThread(void *);
void * PerfWakeupThread(void *); void * PerfWakeupThread(void *);
u_int64_t PerfTVRegisterCounter(char *, struct ThreadVars_ *, int, char *); uint16_t PerfTVRegisterCounter(char *, struct ThreadVars_ *, int, char *);
u_int64_t PerfTVRegisterAvgCounter(char *, struct ThreadVars_ *, int, char *); uint16_t PerfTVRegisterAvgCounter(char *, struct ThreadVars_ *, int, char *);
u_int64_t PerfTVRegisterMaxCounter(char *, struct ThreadVars_ *, int, char *); uint16_t PerfTVRegisterMaxCounter(char *, struct ThreadVars_ *, int, char *);
u_int64_t PerfTVRegisterIntervalCounter(char *, struct ThreadVars_ *, int, char *); uint16_t PerfTVRegisterIntervalCounter(char *, struct ThreadVars_ *, int, char *);
u_int64_t PerfRegisterCounter(char *, char *, int, char *, PerfContext *); uint16_t PerfRegisterCounter(char *, char *, int, char *, PerfContext *);
u_int64_t PerfRegisterAvgCounter(char *, char *, int, char *, PerfContext *); uint16_t PerfRegisterAvgCounter(char *, char *, int, char *, PerfContext *);
u_int64_t PerfRegisterMaxCounter(char *, char *, int, char *, PerfContext *); uint16_t PerfRegisterMaxCounter(char *, char *, int, char *, PerfContext *);
u_int64_t PerfRegisterIntervalCounter(char *, char *, int, char *, PerfContext *); uint16_t PerfRegisterIntervalCounter(char *, char *, int, char *, PerfContext *);
int PerfCounterDisplay(u_int64_t, PerfContext *, int); int PerfCounterDisplay(uint16_t, PerfContext *, int);
inline void PerfCounterIncr(uint64_t, PerfCounterArray *); inline void PerfCounterIncr(uint16_t, PerfCounterArray *);
inline void PerfCounterAddUI64(uint64_t, PerfCounterArray *, uint64_t); inline void PerfCounterAddUI64(uint16_t, PerfCounterArray *, uint64_t);
inline void PerfCounterAddDouble(uint64_t, PerfCounterArray *, double); inline void PerfCounterAddDouble(uint16_t, PerfCounterArray *, double);
inline void PerfCounterSetUI64(uint64_t, PerfCounterArray *, uint64_t); inline void PerfCounterSetUI64(uint16_t, PerfCounterArray *, uint64_t);
inline void PerfCounterSetDouble(uint64_t, PerfCounterArray *, double); inline void PerfCounterSetDouble(uint16_t, PerfCounterArray *, double);
int PerfAddToClubbedTMTable(char *, PerfContext *); int PerfAddToClubbedTMTable(char *, PerfContext *);
PerfCounterArray * PerfGetCounterArrayRange(uint32_t, uint32_t, PerfCounterArray * PerfGetCounterArrayRange(uint16_t, uint16_t,
PerfContext *); PerfContext *);
PerfCounterArray * PerfGetAllCountersArray(PerfContext *); PerfCounterArray * PerfGetAllCountersArray(PerfContext *);

Loading…
Cancel
Save