/* * mdsim.h * * Summary: Define the MD_Sim structure. * * Author: David Hardy */ #ifndef MD_SIM_H #define MD_SIM_H #include "mdextend.h" #include "ihash.h" #ifdef __cplusplus extern "C" { #endif #if !defined(MD_STATIC) #if defined(HPUX) #include #elif defined(DARWIN) #include #endif #endif /* * The MD_Sim structure. */ struct MD_Sim_Tag { /* * In order to report version errors, it's important for the version * number and the error table to always be first in MD_Sim structure. */ MD_Int version; /* version number for this implementation of API */ MD_Err *err; /* error info array */ MD_Int errlen; /* number of elements stored in array */ MD_Int errmax; /* maximum number of available array elements */ void * fe_info; /* points to anything that the front end wants to */ /* associate with this sim object */ void * engine; /* all back end engine data accessible here */ MD_Errcode (*create_engine)(MD_Sim *); /* store create routine */ void (*destroy_engine)(MD_Sim *); /* store the linked destroy routine */ char * engine_name; /* store a copy of the engine name */ char errmsg_buf[MD_STRBUF_SIZE]; /* error message buffer */ MD_Int errnum; /* error number */ MD_Int state; /* save which calling state MD_Sim is in */ Ihash nametable; /* hash table of names for fast access ID numbers */ Ihash plentable; /* hash pointers to data lengths (as strings) */ /* this is to resize multiple data arrays */ /* together that should be the same length */ MD_Int iscreated; /* true after create_engine is done */ MD_Int isneedinit; /* true if we need to init before run */ char ** hashkey; /* hash key (string name) for engine data */ MD_Int hashkeylen; /* number of elements stored in array */ MD_Int hashkeymax; /* maximum number of available array elements */ const char **name; /* array of names for engine data */ MD_Int namelen; /* number of elements stored in array */ MD_Int namemax; /* maximum number of available array elements */ MD_Data * data; /* engine data array */ MD_Int datalen; /* number of elements stored in array */ MD_Int datamax; /* maximum number of available array elements */ char ** plenstr; /* hashing strings for plen (ASCII hex-addr) */ MD_Int plenstrlen; /* number of elements stored in array */ MD_Int plenstrmax; /* maximum number of available array elements */ MD_Callback *cb; /* call back registration array */ MD_Int cblen; /* number of elements stored in array */ MD_Int cbmax; /* maximum number of available array elements */ MD_Callback *fcb; /* force call back registration array */ MD_Int fcblen; /* number of elements stored in array */ MD_Int fcbmax; /* maximum number of available array elements */ /* * save state for processing call backs */ MD_Int prev_state; /* preserve state of engine */ MD_Int stepnum; /* current step number of engine */ MD_Int numer; /* numerator */ MD_Int denom; /* denominator */ MD_Int cbcounter; /* count number of callbacks processed */ MD_Int cbtotal; /* total number of callbacks to process */ MD_Int cbnumcalls; /* count number of consecutive calls to callback */ MD_Int cbmaxcalls; /* maximum number of consecutive calls allowed */ MD_Int iscb; /* is a callback being processed? */ MD_Int cbretval; /* return value from callback routine */ MD_Callback *cbptr; /* pointer into an MD_Callback array */ MD_Callback cbsave; /* save the callback passed to processcb */ /* (stepnum, numer, denom are set current) */ /* * function pointers for "virtual" MDAPI routines */ /* 'run' must be provided by engine */ MD_Errcode (*run)( MD_Sim *, MD_Int ); /* default 'init' can be optionally redefined by engine */ MD_Errcode (*init)( MD_Sim * ); /* default 'isdone' and 'wait' can also be redefined */ MD_Int (*isdone)( MD_Sim * ); MD_Errcode (*wait)( MD_Sim * ); /* default routines to process a callback can be redefined */ MD_Errcode (*prcb)( MD_Sim *, MD_Callback * ); MD_Int (*isdoneprcb)( MD_Sim * ); MD_Errcode (*waitprcb)( MD_Sim * ); /* * arrays needed for registering general data types * (all mdtype.h data types are also registered) */ Ihash typetable; /* hash table of type names to access numbers */ MD_Int * typestack; /* stack subtypes for recursive analysis */ MD_Int typestackmax; /* maximum number of available array elements */ /* (no state saved on stack, zero length outside of validate_type()) */ MD_Int * flipqueue; /* queue for flip offsets */ MD_Int flipqueuelen; /* number of elements stored in array */ MD_Int flipqueuemax; /* maximum number of available array elements */ MD_Int flipflags; /* flip info bits to be ORed into typenum */ const char **typename; /* array of type names */ MD_Int typenamelen; /* number of elements stored in array */ MD_Int typenamemax; /* maximum number of available array elements */ MD_Type * type; /* array of type data */ MD_Int typelen; /* number of elements stored in array */ MD_Int typemax; /* maximum number of available array elements */ #if !defined(MD_STATIC) #if defined(HPUX) MD_Int is_engine_loaded; /* flag to indicate successfully loaded engine */ shl_t dlhandle; /* handle for HPUX shared library loading */ #elif defined(DARWIN) NSModule dlhandle; /* handle for Darwin module */ #else void * dlhandle; /* handle to dyanmically linked shared object */ /* for dlopen() just test non-NULL for success */ #endif #endif /* ! MD_STATIC */ }; /* * use macro for errors raised by MDAPI */ #define ERR( sim, errnum, optmsg ) \ MD_raiserr(sim, MD_API_NAME, errnum, optmsg, __FILE__, __LINE__) /* * macro to return index on type constants */ #define INDEX(x) ((x) >> 19) /* * macro to find length of static array */ #define ARRLEN(x) ((MD_Int) (sizeof(x) / sizeof(x[0]))) /* * define state constants for asynchronous calls */ #define STATE_NONE 0 #define STATE_CREATE 1 #define STATE_INIT 2 #define STATE_RUN 3 #define STATE_SETLEN 4 #define STATE_SETDATA 5 #define STATE_GETDATA 6 #define STATE_CALLBACK 7 #define STATE_FCALLBACK 8 #ifdef __cplusplus } #endif #endif /* MD_SIM_H */