• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/genericProc/ssBackEnd/ssb_options.h

00001 /*
00002  * options.h - options package interfaces
00003  *
00004  * This file is a part of the SimpleScalar tool suite written by
00005  * Todd M. Austin as a part of the Multiscalar Research Project.
00006  *  
00007  * The tool suite is currently maintained by Doug Burger and Todd M. Austin.
00008  * 
00009  * Copyright (C) 1994, 1995, 1996, 1997, 1998 by Todd M. Austin
00010  *
00011  * This source file is distributed "as is" in the hope that it will be
00012  * useful.  The tool set comes with no warranty, and no author or
00013  * distributor accepts any responsibility for the consequences of its
00014  * use. 
00015  * 
00016  * Everyone is granted permission to copy, modify and redistribute
00017  * this tool set under the following conditions:
00018  * 
00019  *    This source code is distributed for non-commercial use only. 
00020  *    Please contact the maintainer for restrictions applying to 
00021  *    commercial use.
00022  *
00023  *    Permission is granted to anyone to make or distribute copies
00024  *    of this source code, either as received or modified, in any
00025  *    medium, provided that all copyright notices, permission and
00026  *    nonwarranty notices are preserved, and that the distributor
00027  *    grants the recipient permission for further redistribution as
00028  *    permitted by this document.
00029  *
00030  *    Permission is granted to distribute this file in compiled
00031  *    or executable form under the same conditions that apply for
00032  *    source code, provided that either:
00033  *
00034  *    A. it is accompanied by the corresponding machine-readable
00035  *       source code,
00036  *    B. it is accompanied by a written offer, with no time limit,
00037  *       to give anyone a machine-readable copy of the corresponding
00038  *       source code in return for reimbursement of the cost of
00039  *       distribution.  This written offer must permit verbatim
00040  *       duplication by anyone, or
00041  *    C. it is distributed by someone who received only the
00042  *       executable form, and is accompanied by a copy of the
00043  *       written offer of source code that they received concurrently.
00044  *
00045  * In other words, you are welcome to use, share and improve this
00046  * source file.  You are forbidden to forbid anyone else to use, share
00047  * and improve what you give them.
00048  *
00049  * INTERNET: dburger@cs.wisc.edu
00050  * US Mail:  1210 W. Dayton Street, Madison, WI 53706
00051  *
00052  * $Id: ssb_options.h,v 1.1.1.1 2006-01-31 16:35:50 afrodri Exp $
00053  *
00054  * $Log: not supported by cvs2svn $
00055  * Revision 1.5  2005/08/16 21:12:55  arodrig6
00056  * changes for docs
00057  *
00058  * Revision 1.4  2004/11/16 04:17:46  arodrig6
00059  * added more documentation
00060  *
00061  * Revision 1.3  2004/08/17 23:39:04  arodrig6
00062  * added main and NIC processors
00063  *
00064  * Revision 1.2  2004/08/10 22:55:35  arodrig6
00065  * works, except for the speculative stuff, caches, and multiple procs
00066  *
00067  * Revision 1.1  2004/08/05 23:51:44  arodrig6
00068  * grabed files from SS and broke up some of them
00069  *
00070  * Revision 1.1.1.1  2000/03/07 05:15:17  karu
00071  * this is the repository created for my own maintanence.
00072  * created when spec95 (lisp and compress worked).
00073  * compress still had the scanf("%i") problem
00074  * DIFF from the repository I am using alongwith ramdass on /projects
00075  * need to merge the two sometime :-)
00076  *
00077  * Revision 1.1.1.1  2000/02/25 21:02:51  karu
00078  * creating cvs repository for ss3-ppc
00079  *
00080  * Revision 1.2  1998/08/27 15:48:03  taustin
00081  * implemented host interface description in host.h
00082  *
00083  * Revision 1.1  1997/03/11  01:31:53  taustin
00084  * Initial revision
00085  *
00086  *
00087  */
00088 
00089 #ifndef OPTIONS_H
00090 #define OPTIONS_H
00091 
00092 /*
00093  * This options package allows the user to specify the name, description,
00094  * location, and default values of program option variables.  In addition,
00095  * two builtin options are supported:
00096  *
00097  *   -config <filename>         # load options from <filename>
00098  *   -dumpconfig <filename>     # save current option into <filename>
00099  *
00100  * NOTE: all user-installed option names must begin with a `-', e.g., `-debug'
00101  */
00102 
00103 /* option variable classes */
00104 enum opt_class_t {
00105   oc_int = 0,           /* integer option */
00106   oc_uint,              /* unsigned integer option */
00107   oc_float,             /* float option */
00108   oc_double,            /* double option */
00109   oc_enum,              /* enumeration option */
00110   oc_flag,              /* boolean option */
00111   oc_string,            /* string option */
00112   oc_NUM
00113 };
00114 
00115 //: user-specified option definition 
00116 //!SEC:ssBack
00117 struct opt_opt_t {
00118   opt_opt_t *next;      /* next option */
00119   const char *name;                     /* option name, e.g., "-foo:bar" */
00120   const char *desc;                     /* option description */
00121   int nvars;                    /* > 1 if var for list options */
00122   int *nelt;                    /* number of elements parsed */
00123   char *format;                 /* option value print format */
00124   int print;                    /* print option during `-dumpconfig'? */
00125   int accrue;                   /* accrue list across uses */
00126   enum opt_class_t oc;          /* class of this option */
00127   union opt_variant_t {
00128     /* oc == oc_int */
00129     struct opt_for_int_t {
00130       int *var;                 /* pointer to integer option */
00131     } for_int;
00132     /* oc == oc_uint */
00133     struct opt_for_uint_t {
00134       unsigned int *var;        /* pointer to unsigned integer option */
00135     } for_uint;
00136     /* oc == oc_float */
00137     struct opt_for_float_t {
00138       float *var;               /* pointer to float option */
00139     } for_float;
00140     /* oc == oc_double */
00141     struct opt_for_double_t {
00142       double *var;              /* pointer to double option */
00143     } for_double;
00144     /* oc == oc_enum, oc_flag */
00145     struct opt_for_enum_t {
00146       int *var;                 /* ptr to *int* enum option, NOTE: AN INT */
00147       const char **emap;                /* array of enum strings */
00148       int *eval;                /* optional array of enum values */
00149       int emap_sz;              /* number of enum's in arrays */
00150     } for_enum;
00151     /* oc == oc_string */
00152     struct opt_for_string_t {
00153       char **var;               /* pointer to string pointer option */
00154     } for_string;
00155   } variant;
00156 };
00157 
00158 /* user-specified argument orphan parser, called when an argument is
00159    encountered that is not claimed by a user-installed option */
00160 typedef int
00161 (*orphan_fn_t)(int i,           /* index of the orphan'ed argument */
00162                int argc,        /* number of program arguments */
00163                char **argv);    /* program arguments */
00164 
00165 //: option node
00166 //
00167 // an option note, these trail the option list when help or option
00168 // state is printed
00169 //
00170 //!SEC:ssBack
00171 struct opt_note_t {
00172    opt_note_t *next;    /* next option note */
00173   char *note;                   /* option note */
00174 };
00175 
00176 //: option database definition 
00177 //!SEC:ssBack
00178 struct opt_odb_t {
00179   opt_opt_t *options;   /* user-installed options in option database */
00180   orphan_fn_t orphan_fn;        /* user-specified orphan parser */
00181   char *header;                 /* options header */
00182   opt_note_t *notes;    /* option notes */
00183 };
00184 
00185 /* create a new option database */
00186 struct opt_odb_t *
00187 opt_new(orphan_fn_t orphan_fn);         /* user-specified orphan parser */
00188 
00189 /* free an option database */
00190 void
00191 opt_delete( opt_odb_t *odb);    /* option database */
00192 
00193 /* register an integer option variable */
00194 void
00195 opt_reg_int( opt_odb_t *odb,    /* option database */
00196             const char *name,                   /* option name */
00197             const char *desc,                   /* option description */
00198             int *var,                   /* pointer to option variable */
00199             int def_val,                /* default value of option variable */
00200             int print,                  /* print during `-dumpconfig' */
00201             const char *format);                /* optional user print format */
00202 
00203 /* register an integer option list */
00204 void
00205 opt_reg_int_list( opt_odb_t *odb,       /* option database */
00206                  const char *name,              /* option name */
00207                  const char *desc,              /* option description */
00208                  int *vars,             /* pointer to option array */
00209                  int nvars,             /* total entries in option array */
00210                  int *nelt,             /* number of entries parsed */
00211                  int *def_val,          /* default value of option array */
00212                  int print,             /* print during `-dumpconfig'? */
00213                  const char *format,            /* optional user print format */
00214                  int accrue);           /* accrue list across uses */
00215 
00216 /* register an unsigned integer option variable */
00217 void
00218 opt_reg_uint( opt_odb_t *odb,   /* option database */
00219              const char *name,          /* option name */
00220              const char *desc,          /* option description */
00221              unsigned int *var,         /* pointer to option variable */
00222              unsigned int def_val,      /* default value of option variable */
00223              int print,                 /* print during `-dumpconfig'? */
00224              const char *format);               /* optional user print format */
00225 
00226 /* register an unsigned integer option list */
00227 void
00228 opt_reg_uint_list( opt_odb_t *odb,/* option database */
00229                   const char *name,             /* option name */
00230                   const char *desc,             /* option description */
00231                   unsigned int *vars,   /* pointer to option array */
00232                   int nvars,            /* total entries in option array */
00233                   int *nelt,            /* number of elements parsed */
00234                   unsigned int *def_val,/* default value of option array */
00235                   int print,            /* print during `-dumpconfig'? */
00236                   const char *format,           /* optional user print format */
00237                   int accrue);          /* accrue list across uses */
00238 
00239 /* register a single-precision floating point option variable */
00240 void
00241 opt_reg_float( opt_odb_t *odb,  /* option data base */
00242               const char *name,         /* option name */
00243               const char *desc,         /* option description */
00244               float *var,               /* target option variable */
00245               float def_val,            /* default variable value */
00246               int print,                /* print during `-dumpconfig'? */
00247               const char *format);              /* optional value print format */
00248 
00249 /* register a single-precision floating point option array */
00250 void
00251 opt_reg_float_list( opt_odb_t *odb,/* option data base */
00252                    char *name,          /* option name */
00253                    char *desc,          /* option description */
00254                    float *vars,         /* target array */
00255                    int nvars,           /* target array size */
00256                    int *nelt,           /* number of args parsed goes here */
00257                    float *def_val,      /* default variable value */
00258                    int print,           /* print during `-dumpconfig'? */
00259                    char *format,        /* optional value print format */
00260                    int accrue);         /* accrue list across uses */
00261 
00262 /* register a double-precision floating point option variable */
00263 void
00264 opt_reg_double( opt_odb_t *odb, /* option data base */
00265                char *name,              /* option name */
00266                char *desc,              /* option description */
00267                double *var,             /* target variable */
00268                double def_val,          /* default variable value */
00269                int print,               /* print during `-dumpconfig'? */
00270                char *format);           /* optional value print format */
00271 
00272 /* register a double-precision floating point option array */
00273 void
00274 opt_reg_double_list( opt_odb_t *odb,/* option data base */
00275                     char *name,         /* option name */
00276                     char *desc,         /* option description */
00277                     double *vars,       /* target array */
00278                     int nvars,          /* target array size */
00279                     int *nelt,          /* number of args parsed goes here */
00280                     double *def_val,    /* default variable value */
00281                     int print,          /* print during `-dumpconfig'? */
00282                     char *format,       /* optional value print format */
00283                     int accrue);        /* accrue list across uses */
00284 
00285 /* register an enumeration option variable, NOTE: all enumeration option
00286    variables must be of type `int', since true enum variables may be allocated
00287    with variable sizes by some compilers */
00288 void
00289 opt_reg_enum( opt_odb_t *odb,   /* option data base */
00290              char *name,                /* option name */
00291              char *desc,                /* option description */
00292              int *var,                  /* target variable */
00293              char *def_val,             /* default variable value */
00294              char **emap,               /* enumeration string map */
00295              int *eval,                 /* enumeration value map, optional */
00296              int emap_sz,               /* size of maps */
00297              int print,                 /* print during `-dumpconfig'? */
00298              char *format);             /* optional value print format */
00299 
00300 /* register an enumeration option array, NOTE: all enumeration option variables
00301    must be of type `int', since true enum variables may be allocated with
00302    variable sizes by some compilers */
00303 void
00304 opt_reg_enum_list( opt_odb_t *odb,/* option data base */
00305                   char *name,           /* option name */
00306                   char *desc,           /* option description */
00307                   int *vars,            /* target array */
00308                   int nvars,            /* target array size */
00309                   int *nelt,            /* number of args parsed goes here */
00310                   char *def_val,        /* default variable value */
00311                   char **emap,          /* enumeration string map */
00312                   int *eval,            /* enumeration value map, optional */
00313                   int emap_sz,          /* size of maps */
00314                   int print,            /* print during `-dumpconfig'? */
00315                   char *format,         /* optional value print format */
00316                   int accrue);          /* accrue list across uses */
00317 
00318 /* register a boolean flag option variable */
00319 void
00320 opt_reg_flag( opt_odb_t *odb,   /* option data base */
00321              const char *name,          /* option name */
00322              const char *desc,          /* option description */
00323              int *var,                  /* target variable */
00324              int def_val,               /* default variable value */
00325              int print,                 /* print during `-dumpconfig'? */
00326              const char *format);               /* optional value print format */
00327 
00328 /* register a boolean flag option array */
00329 void
00330 opt_reg_flag_list( opt_odb_t *odb,/* option database */
00331                   const char *name,             /* option name */
00332                   const char *desc,             /* option description */
00333                   int *vars,            /* pointer to option array */
00334                   int nvars,            /* total entries in option array */
00335                   int *nelt,            /* number of elements parsed */
00336                   int *def_val,         /* default array value */
00337                   int print,            /* print during `-dumpconfig'? */
00338                   const char *format,           /* optional value print format */
00339                   int accrue);          /* accrue list across uses */
00340 
00341 /* register a string option variable */
00342 void
00343 opt_reg_string( opt_odb_t *odb, /* option data base */
00344                const char *name,                /* option name */
00345                const char *desc,                /* option description */
00346                char **var,              /* pointer to string option variable */
00347                const char *def_val,             /* default variable value */
00348                int print,               /* print during `-dumpconfig'? */
00349                const char *format);             /* optional value print format */
00350 
00351 /* register a string option array */
00352 void
00353 opt_reg_string_list( opt_odb_t *odb,/* option data base */
00354                     const char *name,           /* option name */
00355                     const char *desc,           /* option description */
00356                     char **vars,        /* pointer to option string array */
00357                     int nvars,          /* target array size */
00358                     int *nelt,          /* number of args parsed goes here */
00359                     char **def_val,     /* default variable value */
00360                     int print,          /* print during `-dumpconfig'? */
00361                     const char *format, /* optional value print format */
00362                     int accrue);        /* accrue list across uses */
00363 
00364 /* process command line arguments */
00365 void
00366 opt_process_options( opt_odb_t *odb, const char*);
00367 
00368 /* print the value of an option */
00369 void
00370 opt_print_option( opt_opt_t *opt,       /* option variable */
00371                  FILE *fd);             /* output stream */
00372 
00373 /* print all options and current values */
00374 void
00375 opt_print_options( opt_odb_t *odb,/* option data base */
00376                   FILE *fd,             /* output stream */
00377                   int terse,            /* print terse options? */
00378                   int notes);           /* include notes? */
00379 
00380 /* print option help page with default values */
00381 void
00382 opt_print_help( opt_odb_t *odb, /* option data base */
00383                FILE *fd);               /* output stream */
00384 
00385 /* find an option by name in the option database, returns NULL if not found */
00386  opt_opt_t *
00387 opt_find_option( opt_odb_t *odb,        /* option database */
00388                 char *opt_name);        /* option name */
00389 
00390 /* register an options header, the header is printed before the option list */
00391 void
00392 opt_reg_header( opt_odb_t *odb, /* option database */
00393                const char *header);             /* options header string */
00394 
00395 /* register an option note, notes are printed after the list of options */
00396 void
00397 opt_reg_note( opt_odb_t *odb,   /* option database */
00398              const char *note);         /* option note */
00399 
00400 #endif /* OPTIONS_H */

Generated on Fri Oct 22 2010 11:02:24 for SST by  doxygen 1.7.1