"I am a person who works hard and plays hard."

Yuan Wei
Second Year Graduate Student Department of Computer Science
University of Virginia Charlottesville, VA 22903
Email: yw3f@cs.virginia.edu


Source Code Analysis

Main Page   Compound List   File List   Compound Members   File Members  

stats.h File Reference

#include <stdio.h>
#include "host.h"
#include "machine.h"
#include "eval.h"

Include dependency graph for stats.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Compounds

Defines

Typedefs

Enumerations

Functions


Define Documentation

#define HTAB_HASH      ((((I) >> 8) ^ (I)) & (HTAB_SZ - 1))
 

Definition at line 112 of file stats.h.

Referenced by stat_add_samples().

#define HTAB_SZ   1024
 

Definition at line 111 of file stats.h.

Referenced by print_sdist(), stat_add_samples(), and stat_delete().

#define PF_ALL   (PF_COUNT|PF_PDF|PF_CDF)
 

Definition at line 128 of file stats.h.

#define PF_CDF   0x0004
 

Definition at line 127 of file stats.h.

Referenced by print_dist(), and print_sdist().

#define PF_COUNT   0x0001
 

Definition at line 125 of file stats.h.

Referenced by print_dist(), print_sdist(), and sim_reg_stats().

#define PF_PDF   0x0002
 

Definition at line 126 of file stats.h.

Referenced by print_dist(), print_sdist(), and sim_reg_stats().


Typedef Documentation

typedef void(* print_fn_t)(struct stat_stat_t *stat, md_addr_t index, int count, double sum, double total)
 

Definition at line 134 of file stats.h.


Enumeration Type Documentation

enum stat_class_t
 

Enumeration values:
sc_int 
sc_uint 
sc_float 
sc_double 
sc_dist 
sc_sdist 
sc_formula 
sc_NUM 

Definition at line 95 of file stats.h.

00095                   {
00096   sc_int = 0,                   /* integer stat */
00097   sc_uint,                      /* unsigned integer stat */
00098 #ifdef HOST_HAS_QWORD
00099   sc_qword,                     /* qword integer stat */
00100   sc_sqword,                    /* signed qword integer stat */
00101 #endif /* HOST_HAS_QWORD */
00102   sc_float,                     /* single-precision FP stat */
00103   sc_double,                    /* double-precision FP stat */
00104   sc_dist,                      /* array distribution stat */
00105   sc_sdist,                     /* sparse array distribution stat */
00106   sc_formula,                   /* stat expression formula */
00107   sc_NUM
00108 };


Function Documentation

void stat_add_sample struct stat_stat_t   stat,
md_addr_t    index
 

Definition at line 614 of file stats.c.

References stat_add_samples().

Referenced by sim_main().

00616 {
00617   stat_add_samples(stat, index, 1);
00618 }

void stat_add_samples struct stat_stat_t   stat,
md_addr_t    index,
int    nsamples
 

Definition at line 557 of file stats.c.

References stat_stat_t::stat_variant_t::stat_for_dist_t::arr, stat_stat_t::stat_variant_t::stat_for_dist_t::arr_sz, stat_stat_t::stat_variant_t::stat_for_dist_t::bucket_sz, bucket_t::count, fatal(), stat_stat_t::stat_variant_t::for_dist, stat_stat_t::stat_variant_t::for_sdist, HTAB_HASH, HTAB_SZ, bucket_t::index, stat_stat_t::stat_variant_t::stat_for_sdist_t::init_val, bucket_t::next, stat_stat_t::stat_variant_t::stat_for_dist_t::overflows, panic(), stat_stat_t::stat_variant_t::stat_for_sdist_t::sarr, stat_stat_t::sc, sc_dist, sc_sdist, and stat_stat_t::variant.

Referenced by ruu_dispatch(), sim_main(), and stat_add_sample().

00560 {
00561   switch (stat->sc)
00562     {
00563     case sc_dist:
00564       {
00565         unsigned int i;
00566 
00567         /* compute array index */
00568         i = index / stat->variant.for_dist.bucket_sz;
00569 
00570         /* check for overflow */
00571         if (i >= stat->variant.for_dist.arr_sz)
00572           stat->variant.for_dist.overflows += nsamples;
00573         else
00574           stat->variant.for_dist.arr[i] += nsamples;
00575       }
00576       break;
00577     case sc_sdist:
00578       {
00579         struct bucket_t *bucket;
00580         int hash = HTAB_HASH(index);
00581 
00582         if (hash < 0 || hash >= HTAB_SZ)
00583           panic("hash table index overflow");
00584 
00585         /* find bucket */
00586         for (bucket = stat->variant.for_sdist.sarr[hash];
00587              bucket != NULL;
00588              bucket = bucket->next)
00589           {
00590             if (bucket->index == index)
00591               break;
00592           }
00593         if (!bucket)
00594           {
00595             /* add a new sample bucket */
00596             bucket = (struct bucket_t *)calloc(1, sizeof(struct bucket_t));
00597             if (!bucket)
00598               fatal("out of virtual memory");
00599             bucket->next = stat->variant.for_sdist.sarr[hash];
00600             stat->variant.for_sdist.sarr[hash] = bucket;
00601             bucket->index = index;
00602             bucket->count = stat->variant.for_sdist.init_val;
00603           }
00604         bucket->count += nsamples;
00605       }
00606       break;
00607     default:
00608       panic("stat variable is not an array distribution");
00609     }
00610 }

void stat_delete struct stat_sdb_t   sdb
 

Definition at line 191 of file stats.c.

References stat_stat_t::stat_variant_t::stat_for_dist_t::arr, eval_delete(), stat_sdb_t::evaluator, stat_stat_t::stat_variant_t::for_dist, stat_stat_t::stat_variant_t::for_sdist, HTAB_SZ, bucket_t::next, stat_stat_t::next, panic(), stat_stat_t::stat_variant_t::stat_for_sdist_t::sarr, stat_stat_t::sc, sc_dist, sc_double, sc_float, sc_formula, sc_int, sc_sdist, sc_uint, stat_sdb_t::stats, and stat_stat_t::variant.

00192 {
00193   int i;
00194   struct stat_stat_t *stat, *stat_next;
00195   struct bucket_t *bucket, *bucket_next;
00196 
00197   /* free all individual stat variables */
00198   for (stat = sdb->stats; stat != NULL; stat = stat_next)
00199     {
00200       stat_next = stat->next;
00201       stat->next = NULL;
00202 
00203       /* free stat */
00204       switch (stat->sc)
00205         {
00206         case sc_int:
00207         case sc_uint:
00208 #ifdef HOST_HAS_QWORD
00209         case sc_qword:
00210         case sc_sqword:
00211 #endif /* HOST_HAS_QWORD */
00212         case sc_float:
00213         case sc_double:
00214         case sc_formula:
00215           /* no other storage to deallocate */
00216           break;
00217         case sc_dist:
00218           /* free distribution array */
00219           free(stat->variant.for_dist.arr);
00220           stat->variant.for_dist.arr = NULL;
00221           break;
00222         case sc_sdist:
00223           /* free all hash table buckets */
00224           for (i=0; i<HTAB_SZ; i++)
00225             {
00226               for (bucket = stat->variant.for_sdist.sarr[i];
00227                    bucket != NULL;
00228                    bucket = bucket_next)
00229                 {
00230                   bucket_next = bucket->next;
00231                   bucket->next = NULL;
00232                   free(bucket);
00233                 }
00234               stat->variant.for_sdist.sarr[i] = NULL;
00235             }
00236           /* free hash table array */
00237           free(stat->variant.for_sdist.sarr);
00238           stat->variant.for_sdist.sarr = NULL;
00239           break;
00240         default:
00241           panic("bogus stat class");
00242         }
00243       /* free stat variable record */
00244       free(stat);
00245     }
00246   sdb->stats = NULL;
00247   eval_delete(sdb->evaluator);
00248   sdb->evaluator = NULL;
00249   free(sdb);
00250 }

struct eval_value_t stat_eval_ident struct eval_state_t   es
 

Definition at line 87 of file stats.c.

References ERR_NOERR, ERR_UNDEFVAR, et_double, et_float, et_int, et_uint, eval_delete(), eval_expr(), eval_new(), fatal(), stat_stat_t::stat_variant_t::for_double, stat_stat_t::stat_variant_t::for_float, stat_stat_t::stat_variant_t::for_formula, stat_stat_t::stat_variant_t::for_int, stat_stat_t::stat_variant_t::for_uint, stat_stat_t::stat_variant_t::stat_for_formula_t::formula, stat_stat_t::name, stat_stat_t::next, panic(), stat_stat_t::sc, sc_dist, sc_double, sc_float, sc_formula, sc_int, sc_sdist, sc_uint, stat_sdb_t::stats, eval_value_t::type, eval_value_t::value, stat_stat_t::stat_variant_t::stat_for_double_t::var, stat_stat_t::stat_variant_t::stat_for_float_t::var, stat_stat_t::stat_variant_t::stat_for_uint_t::var, stat_stat_t::stat_variant_t::stat_for_int_t::var, and stat_stat_t::variant.

00088 {
00089   struct stat_sdb_t *sdb = es->user_ptr;
00090   struct stat_stat_t *stat;
00091   static struct eval_value_t err_value = { et_int, { 0 } };
00092   struct eval_value_t val;
00093 
00094   /* locate the stat variable */
00095   for (stat = sdb->stats; stat != NULL; stat = stat->next)
00096     {
00097       if (!strcmp(stat->name, es->tok_buf))
00098         {
00099           /* found it! */
00100           break;
00101         }
00102     }
00103   if (!stat)
00104     {
00105       /* could not find stat variable */
00106       eval_error = ERR_UNDEFVAR;
00107       return err_value;
00108     }
00109   /* else, return the value of stat */
00110 
00111   /* convert the stat variable value to a typed expression value */
00112   switch (stat->sc)
00113     {
00114     case sc_int:
00115       val.type = et_int;
00116       val.value.as_int = *stat->variant.for_int.var;
00117       break;
00118     case sc_uint:
00119       val.type = et_uint;
00120       val.value.as_uint = *stat->variant.for_uint.var;
00121       break;
00122 #ifdef HOST_HAS_QWORD
00123     case sc_qword:
00124       /* FIXME: cast to double, eval package doesn't support long long's */
00125       val.type = et_double;
00126 #ifdef _MSC_VER /* FIXME: MSC does not implement qword_t to dbl conversion */
00127       val.value.as_double = (double)(sqword_t)*stat->variant.for_qword.var;
00128 #else /* !_MSC_VER */
00129       val.value.as_double = (double)*stat->variant.for_qword.var;
00130 #endif /* _MSC_VER */
00131       break;
00132     case sc_sqword:
00133       /* FIXME: cast to double, eval package doesn't support long long's */
00134       val.type = et_double;
00135       val.value.as_double = (double)*stat->variant.for_sqword.var;
00136       break;
00137 #endif /* HOST_HAS_QWORD */
00138     case sc_float:
00139       val.type = et_float;
00140       val.value.as_float = *stat->variant.for_float.var;
00141       break;
00142     case sc_double:
00143       val.type = et_double;
00144       val.value.as_double = *stat->variant.for_double.var;
00145       break;
00146     case sc_dist:
00147     case sc_sdist:
00148       fatal("stat distributions not allowed in formula expressions");
00149       break;
00150     case sc_formula:
00151       {
00152         /* instantiate a new evaluator to avoid recursion problems */
00153         struct eval_state_t *es = eval_new(stat_eval_ident, sdb);
00154         char *endp;
00155 
00156         val = eval_expr(es, stat->variant.for_formula.formula, &endp);
00157         if (eval_error != ERR_NOERR || *endp != '\0')
00158           {
00159             /* pass through eval_error */
00160             val = err_value;
00161           }
00162         /* else, use value returned */
00163         eval_delete(es);
00164       }
00165       break;
00166     default:
00167       panic("bogus stat class");
00168     }
00169 
00170   return val;
00171 }

struct stat_stat_t* stat_find_stat struct stat_sdb_t   sdb,
char *    stat_name
 

Definition at line 1038 of file stats.c.

References stat_stat_t::name, and stat_stat_t::next.

Referenced by dlite_stat(), ident_evaluator(), and sim_reg_stats().

01040 {
01041   struct stat_stat_t *stat;
01042 
01043   for (stat = sdb->stats; stat != NULL; stat = stat->next)
01044     {
01045       if (!strcmp(stat->name, stat_name))
01046         break;
01047     }
01048   return stat;
01049 }

struct stat_sdb_t* stat_new void   
 

Definition at line 175 of file stats.c.

References eval_new(), stat_sdb_t::evaluator, fatal(), and stat_sdb_t::stats.

Referenced by main().

00176 {
00177   struct stat_sdb_t *sdb;
00178 
00179   sdb = (struct stat_sdb_t *)calloc(1, sizeof(struct stat_sdb_t));
00180   if (!sdb)
00181     fatal("out of virtual memory");
00182 
00183   sdb->stats = NULL;
00184   sdb->evaluator = eval_new(stat_eval_ident, sdb);
00185 
00186   return sdb;
00187 }

void stat_print_stat struct stat_sdb_t   sdb,
struct stat_stat_t   stat,
FILE *    fd
 

Definition at line 941 of file stats.c.

References stat_stat_t::desc, ERR_NOERR, eval_delete(), eval_expr(), eval_new(), stat_stat_t::stat_variant_t::for_double, stat_stat_t::stat_variant_t::for_float, stat_stat_t::stat_variant_t::for_formula, stat_stat_t::stat_variant_t::for_int, stat_stat_t::stat_variant_t::for_uint, stat_stat_t::format, stat_stat_t::stat_variant_t::stat_for_formula_t::formula, myfprintf(), mysprintf(), stat_stat_t::name, panic(), print_dist(), print_sdist(), stat_stat_t::sc, sc_dist, sc_double, sc_float, sc_formula, sc_int, sc_sdist, sc_uint, stat_stat_t::stat_variant_t::stat_for_double_t::var, stat_stat_t::stat_variant_t::stat_for_float_t::var, stat_stat_t::stat_variant_t::stat_for_uint_t::var, stat_stat_t::stat_variant_t::stat_for_int_t::var, and stat_stat_t::variant.

Referenced by dlite_stat(), and stat_print_stats().

00944 {
00945   struct eval_value_t val;
00946 
00947   switch (stat->sc)
00948     {
00949     case sc_int:
00950       fprintf(fd, "%-22s ", stat->name);
00951       myfprintf(fd, stat->format, *stat->variant.for_int.var);
00952       fprintf(fd, " # %s", stat->desc);
00953       break;
00954     case sc_uint:
00955       fprintf(fd, "%-22s ", stat->name);
00956       myfprintf(fd, stat->format, *stat->variant.for_uint.var);
00957       fprintf(fd, " # %s", stat->desc);
00958       break;
00959 #ifdef HOST_HAS_QWORD
00960     case sc_qword:
00961       {
00962         char buf[128];
00963 
00964         fprintf(fd, "%-22s ", stat->name);
00965         mysprintf(buf, stat->format, *stat->variant.for_qword.var);
00966         fprintf(fd, "%s # %s", buf, stat->desc);
00967       }
00968       break;
00969     case sc_sqword:
00970       {
00971         char buf[128];
00972 
00973         fprintf(fd, "%-22s ", stat->name);
00974         mysprintf(buf, stat->format, *stat->variant.for_sqword.var);
00975         fprintf(fd, "%s # %s", buf, stat->desc);
00976       }
00977       break;
00978 #endif /* HOST_HAS_QWORD */
00979     case sc_float:
00980       fprintf(fd, "%-22s ", stat->name);
00981       myfprintf(fd, stat->format, (double)*stat->variant.for_float.var);
00982       fprintf(fd, " # %s", stat->desc);
00983       break;
00984     case sc_double:
00985       fprintf(fd, "%-22s ", stat->name);
00986       myfprintf(fd, stat->format, *stat->variant.for_double.var);
00987       fprintf(fd, " # %s", stat->desc);
00988       break;
00989     case sc_dist:
00990       print_dist(stat, fd);
00991       break;
00992     case sc_sdist:
00993       print_sdist(stat, fd);
00994       break;
00995     case sc_formula:
00996       {
00997         /* instantiate a new evaluator to avoid recursion problems */
00998         struct eval_state_t *es = eval_new(stat_eval_ident, sdb);
00999         char *endp;
01000 
01001         fprintf(fd, "%-22s ", stat->name);
01002         val = eval_expr(es, stat->variant.for_formula.formula, &endp);
01003         if (eval_error != ERR_NOERR || *endp != '\0')
01004           fprintf(fd, "<error: %s>", eval_err_str[eval_error]);
01005         else
01006           myfprintf(fd, stat->format, eval_as_double(val));
01007         fprintf(fd, " # %s", stat->desc);
01008 
01009         /* done with the evaluator */
01010         eval_delete(es);
01011       }
01012       break;
01013     default:
01014       panic("bogus stat class");
01015     }
01016   fprintf(fd, "\n");
01017 }

void stat_print_stats struct stat_sdb_t   sdb,
FILE *    fd
 

Definition at line 1021 of file stats.c.

References stat_stat_t::next, stat_print_stat(), and stat_sdb_t::stats.

Referenced by cheetah_mstate_obj(), dlite_stats(), and sim_print_stats().

01023 {
01024   struct stat_stat_t *stat;
01025 
01026   if (!sdb)
01027     {
01028       /* no stats */
01029       return;
01030     }
01031 
01032   for (stat=sdb->stats; stat != NULL; stat=stat->next)
01033     stat_print_stat(sdb, stat, fd);
01034 }

struct stat_stat_t* stat_reg_dist struct stat_sdb_t   sdb,
char *    name,
char *    desc,
unsigned int    init_val,
unsigned int    arr_sz,
unsigned int    bucket_sz,
int    pf,
char *    format,
char **    imap,
print_fn_t    print_fn
 

Definition at line 466 of file stats.c.

References add_stat(), stat_stat_t::stat_variant_t::stat_for_dist_t::arr, stat_stat_t::stat_variant_t::stat_for_dist_t::arr_sz, stat_stat_t::stat_variant_t::stat_for_dist_t::bucket_sz, stat_stat_t::desc, fatal(), stat_stat_t::stat_variant_t::for_dist, stat_stat_t::format, stat_stat_t::stat_variant_t::stat_for_dist_t::imap, stat_stat_t::stat_variant_t::stat_for_dist_t::init_val, mystrdup(), stat_stat_t::name, stat_stat_t::stat_variant_t::stat_for_dist_t::overflows, stat_stat_t::stat_variant_t::stat_for_dist_t::pf, stat_stat_t::stat_variant_t::stat_for_dist_t::print_fn, stat_stat_t::sc, sc_dist, and stat_stat_t::variant.

Referenced by sim_reg_stats().

00476 {
00477   unsigned int i;
00478   struct stat_stat_t *stat;
00479   unsigned int *arr;
00480 
00481   stat = (struct stat_stat_t *)calloc(1, sizeof(struct stat_stat_t));
00482   if (!stat)
00483     fatal("out of virtual memory");
00484 
00485   stat->name = mystrdup(name);
00486   stat->desc = mystrdup(desc);
00487   stat->format = format ? format : NULL;
00488   stat->sc = sc_dist;
00489   stat->variant.for_dist.init_val = init_val;
00490   stat->variant.for_dist.arr_sz = arr_sz;
00491   stat->variant.for_dist.bucket_sz = bucket_sz;
00492   stat->variant.for_dist.pf = pf;
00493   stat->variant.for_dist.imap = imap;
00494   stat->variant.for_dist.print_fn = print_fn;
00495   stat->variant.for_dist.overflows = 0;
00496 
00497   arr = (unsigned int *)calloc(arr_sz, sizeof(unsigned int));
00498   if (!arr)
00499     fatal("out of virtual memory");
00500   stat->variant.for_dist.arr = arr;
00501 
00502   /* link onto SDB chain */
00503   add_stat(sdb, stat);
00504 
00505   /* initialize stat */
00506   for (i=0; i < arr_sz; i++)
00507     arr[i] = init_val;
00508 
00509   return stat;
00510 }

struct stat_stat_t* stat_reg_double struct stat_sdb_t   sdb,
char *    name,
char *    desc,
double *    var,
double    init_val,
char *    format
 

Definition at line 430 of file stats.c.

References add_stat(), stat_stat_t::desc, fatal(), stat_stat_t::stat_variant_t::for_double, stat_stat_t::format, stat_stat_t::stat_variant_t::stat_for_double_t::init_val, mystrdup(), stat_stat_t::name, stat_stat_t::sc, sc_double, stat_stat_t::stat_variant_t::stat_for_double_t::var, and stat_stat_t::variant.

00436 {
00437   struct stat_stat_t *stat;
00438 
00439   stat = (struct stat_stat_t *)calloc(1, sizeof(struct stat_stat_t));
00440   if (!stat)
00441     fatal("out of virtual memory");
00442 
00443   stat->name = mystrdup(name);
00444   stat->desc = mystrdup(desc);
00445   stat->format = format ? format : "%12.4f";
00446   stat->sc = sc_double;
00447   stat->variant.for_double.var = var;
00448   stat->variant.for_double.init_val = init_val;
00449 
00450   /* link onto SDB chain */
00451   add_stat(sdb, stat);
00452 
00453   /* initialize stat */
00454   *var = init_val;
00455 
00456   return stat;
00457 }

struct stat_stat_t* stat_reg_float struct stat_sdb_t   sdb,
char *    name,
char *    desc,
float *    var,
float    init_val,
char *    format
 

Definition at line 399 of file stats.c.

References add_stat(), stat_stat_t::desc, fatal(), stat_stat_t::stat_variant_t::for_float, stat_stat_t::format, stat_stat_t::stat_variant_t::stat_for_float_t::init_val, mystrdup(), stat_stat_t::name, stat_stat_t::sc, sc_float, stat_stat_t::stat_variant_t::stat_for_float_t::var, and stat_stat_t::variant.

00405 {
00406   struct stat_stat_t *stat;
00407 
00408   stat = (struct stat_stat_t *)calloc(1, sizeof(struct stat_stat_t));
00409   if (!stat)
00410     fatal("out of virtual memory");
00411 
00412   stat->name = mystrdup(name);
00413   stat->desc = mystrdup(desc);
00414   stat->format = format ? format : "%12.4f";
00415   stat->sc = sc_float;
00416   stat->variant.for_float.var = var;
00417   stat->variant.for_float.init_val = init_val;
00418 
00419   /* link onto SDB chain */
00420   add_stat(sdb, stat);
00421 
00422   /* initialize stat */
00423   *var = init_val;
00424 
00425   return stat;
00426 }

struct stat_stat_t* stat_reg_formula struct stat_sdb_t   sdb,
char *    name,
char *    desc,
char *    formula,
char *    format
 

Definition at line 628 of file stats.c.

References add_stat(), stat_stat_t::desc, fatal(), stat_stat_t::stat_variant_t::for_formula, stat_stat_t::format, stat_stat_t::stat_variant_t::stat_for_formula_t::formula, mystrdup(), stat_stat_t::name, stat_stat_t::sc, sc_formula, and stat_stat_t::variant.

Referenced by bpred_reg_stats(), cache_reg_stats(), mem_reg_stats(), and sim_reg_stats().

00633 {
00634   struct stat_stat_t *stat;
00635 
00636   stat = (struct stat_stat_t *)calloc(1, sizeof(struct stat_stat_t));
00637   if (!stat)
00638     fatal("out of virtual memory");
00639 
00640   stat->name = mystrdup(name);
00641   stat->desc = mystrdup(desc);
00642   stat->format = format ? format : "%12.4f";
00643   stat->sc = sc_formula;
00644   stat->variant.for_formula.formula = mystrdup(formula);
00645 
00646   /* link onto SDB chain */
00647   add_stat(sdb, stat);
00648 
00649   return stat;
00650 }

struct stat_stat_t* stat_reg_int struct stat_sdb_t   sdb,
char *    name,
char *    desc,
int *    var,
int    init_val,
char *    format
 

Definition at line 273 of file stats.c.

References add_stat(), stat_stat_t::desc, fatal(), stat_stat_t::stat_variant_t::for_int, stat_stat_t::format, stat_stat_t::stat_variant_t::stat_for_int_t::init_val, mystrdup(), stat_stat_t::name, stat_stat_t::sc, sc_int, stat_stat_t::stat_variant_t::stat_for_int_t::var, and stat_stat_t::variant.

Referenced by ld_reg_stats(), and sim_reg_stats().

00279 {
00280   struct stat_stat_t *stat;
00281 
00282   stat = (struct stat_stat_t *)calloc(1, sizeof(struct stat_stat_t));
00283   if (!stat)
00284     fatal("out of virtual memory");
00285 
00286   stat->name = mystrdup(name);
00287   stat->desc = mystrdup(desc);
00288   stat->format = format ? format : "%12d";
00289   stat->sc = sc_int;
00290   stat->variant.for_int.var = var;
00291   stat->variant.for_int.init_val = init_val;
00292 
00293   /* link onto SDB chain */
00294   add_stat(sdb, stat);
00295 
00296   /* initialize stat */
00297   *var = init_val;
00298 
00299   return stat;
00300 }

struct stat_stat_t* stat_reg_sdist struct stat_sdb_t   sdb,
char *    name,
char *    desc,
unsigned int    init_val,
int    pf,
char *    format,
print_fn_t    print_fn
 

Definition at line 520 of file stats.c.

References add_stat(), stat_stat_t::desc, fatal(), stat_stat_t::stat_variant_t::for_sdist, stat_stat_t::format, stat_stat_t::stat_variant_t::stat_for_sdist_t::init_val, mystrdup(), stat_stat_t::name, stat_stat_t::stat_variant_t::stat_for_sdist_t::pf, stat_stat_t::stat_variant_t::stat_for_sdist_t::print_fn, stat_stat_t::stat_variant_t::stat_for_sdist_t::sarr, stat_stat_t::sc, sc_sdist, and stat_stat_t::variant.

Referenced by sim_reg_stats().

00527 {
00528   struct stat_stat_t *stat;
00529   struct bucket_t **sarr;
00530 
00531   stat = (struct stat_stat_t *)calloc(1, sizeof(struct stat_stat_t));
00532   if (!stat)
00533     fatal("out of virtual memory");
00534 
00535   stat->name = mystrdup(name);
00536   stat->desc = mystrdup(desc);
00537   stat->format = format ? format : NULL;
00538   stat->sc = sc_sdist;
00539   stat->variant.for_sdist.init_val = init_val;
00540   stat->variant.for_sdist.pf = pf;
00541   stat->variant.for_sdist.print_fn = print_fn;
00542 
00543   /* allocate hash table */
00544   sarr = (struct bucket_t **)calloc(HTAB_SZ, sizeof(struct bucket_t *));
00545   if (!sarr)
00546     fatal("out of virtual memory");
00547   stat->variant.for_sdist.sarr = sarr;
00548 
00549   /* link onto SDB chain */
00550   add_stat(sdb, stat);
00551 
00552   return stat;
00553 }

struct stat_stat_t* stat_reg_uint struct stat_sdb_t   sdb,
char *    name,
char *    desc,
unsigned int *    var,
unsigned int    init_val,
char *    format
 

Definition at line 304 of file stats.c.

References add_stat(), stat_stat_t::desc, fatal(), stat_stat_t::stat_variant_t::for_uint, stat_stat_t::format, stat_stat_t::stat_variant_t::stat_for_uint_t::init_val, mystrdup(), stat_stat_t::name, stat_stat_t::sc, sc_uint, stat_stat_t::stat_variant_t::stat_for_uint_t::var, and stat_stat_t::variant.

Referenced by ld_reg_stats(), and main().

00310 {
00311   struct stat_stat_t *stat;
00312 
00313   stat = (struct stat_stat_t *)calloc(1, sizeof(struct stat_stat_t));
00314   if (!stat)
00315     fatal("out of virtual memory");
00316 
00317   stat->name = mystrdup(name);
00318   stat->desc = mystrdup(desc);
00319   stat->format = format ? format : "%12u";
00320   stat->sc = sc_uint;
00321   stat->variant.for_uint.var = var;
00322   stat->variant.for_uint.init_val = init_val;
00323 
00324   /* link onto SDB chain */
00325   add_stat(sdb, stat);
00326 
00327   /* initialize stat */
00328   *var = init_val;
00329 
00330   return stat;
00331 }



UVa CS Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214