00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00039 #ifndef __NUSMV_CORE_DAG_DAG_H__
00040 #define __NUSMV_CORE_DAG_DAG_H__
00041
00042 #if HAVE_CONFIG_H
00043 # include "nusmv-config.h"
00044 #endif
00045
00046
00047
00048 #if NUSMV_HAVE_MALLOC_H
00049 # if NUSMV_HAVE_SYS_TYPES_H
00050 # include <sys/types.h>
00051 # endif
00052 # include <malloc.h>
00053 #elif defined(NUSMV_HAVE_SYS_MALLOC_H) && NUSMV_HAVE_SYS_MALLOC_H
00054 # if NUSMV_HAVE_SYS_TYPES_H
00055 # include <sys/types.h>
00056 # endif
00057 # include <sys/malloc.h>
00058 #elif NUSMV_HAVE_STDLIB_H
00059 # include <stdlib.h>
00060 #endif
00061
00062 #if NUSMV_HAVE_UNISTD_H
00063 #include <unistd.h>
00064 #endif
00065
00066
00067 #include "nusmv/core/utils/utils.h"
00068 #include "cudd/util.h"
00069 #include "cudd/st.h"
00070 #include "nusmv/core/utils/list.h"
00071
00072
00073
00074
00075
00076
00077
00083 #define DAG_DEFAULT_VERTICES_NO 65537
00084
00090 #define DAG_DEFAULT_DENSITY 20
00091
00097 #define DAG_DEFAULT_GROWTH 1.5
00098
00099
00100
00101
00102 #if !defined(NUSMV_SIZEOF_VOID_P) || !defined(NUSMV_SIZEOF_LONG)
00103 #error Constants NUSMV_SIZEOF_VOID_P and NUSMV_SIZEOF_LONG must be defined
00104 #endif
00105
00106 #if (NUSMV_SIZEOF_VOID_P == NUSMV_SIZEOF_LONG)
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 # define DAG_ANNOTATION_BIT ((nusmv_ptrint) 1)
00128 #else
00129
00130
00131 # define DAG_ANNOTATION_BIT ((nusmv_ptrint) 1)
00132 #endif
00133
00134
00135
00136
00142 #define DAG_NODE_NO (int) 0
00143
00149 #define DAG_GC_NO (int) 1
00150
00156 #define DAG_MAX_STAT (int) 2
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 typedef struct DagManager Dag_Manager_t;
00168 typedef struct Dag_Vertex Dag_Vertex_t;
00169 typedef struct Dag_DfsFunctions Dag_DfsFunctions_t;
00170
00176 typedef void (*PF_VPVPCPI)(void*, char*, nusmv_ptrint);
00177
00183 typedef int (*PF_IVPCPI)(void*, char*, nusmv_ptrint);
00184 typedef void (*PF_VPCP)(char*);
00185
00186
00187
00188
00189
00219 struct Dag_Vertex {
00220 int symbol;
00221 char * data;
00222
00223 Dag_Vertex_t* * outList;
00224 unsigned numSons;
00225
00226 Dag_Manager_t * dag;
00227 int mark;
00228 int visit;
00229 lsHandle vHandle;
00230
00231 char * gRef;
00232 int iRef;
00233 };
00234
00235
00259
00260
00261
00262
00263
00264
00265
00266 struct Dag_DfsFunctions {
00267 PF_IVPCPI Set;
00268 PF_VPVPCPI FirstVisit;
00269 PF_VPVPCPI BackVisit;
00270 PF_VPVPCPI LastVisit;
00271 };
00272
00273
00274
00275
00276
00277
00278
00279
00280
00289 #define Dag_VertexGetRef(p)\
00290 ((Dag_Vertex_t*)((nusmv_ptrint)p & (~ DAG_ANNOTATION_BIT)))
00291
00300 #define Dag_VertexSet(p)\
00301 (p = (Dag_Vertex_t*)((nusmv_ptrint)p | DAG_ANNOTATION_BIT))
00302
00311 #define Dag_VertexClear(p)\
00312 (p = (Dag_Vertex_t*)((nusmv_ptrint)p & (~ DAG_ANNOTATION_BIT)))
00313
00323 #define Dag_VertexIsSet(p)\
00324 ((nusmv_ptrint)p & DAG_ANNOTATION_BIT)
00325
00337 #define DagId(r,s) \
00338 (Dag_Vertex_t*)((nusmv_ptrint)s ^ (nusmv_ptrint)r)
00339
00342
00343
00344
00345
00351 void
00352 Dag_Dfs(Dag_Vertex_t* dfsRoot, Dag_DfsFunctions_t* dfsFun, char* dfsData);
00353
00365 Dag_Manager_t* Dag_ManagerAlloc(void);
00366
00372 Dag_Manager_t*
00373 Dag_ManagerAllocWithParams(int dagInitVerticesNo, int maxDensity,
00374 int growthFactor);
00375
00389 void
00390 Dag_ManagerFree(Dag_Manager_t* dagManager, PF_VPCP freeData,
00391 PF_VPCP freeGen);
00392
00411 void
00412 Dag_ManagerGC(Dag_Manager_t* dagManager, PF_VPCP freeData,
00413 PF_VPCP freeGen);
00414
00415 Dag_DfsFunctions_t* Dag_ManagerGetDfsCleanFun(Dag_Manager_t* dagManager);
00416
00434 void Dag_PrintStats(Dag_Manager_t* dagManager, int clustSz,
00435 FILE* outFile);
00436
00452 Dag_Vertex_t*
00453 Dag_VertexLookup(Dag_Manager_t* dagManager,
00454 int vSymb,
00455 char* vData,
00456 Dag_Vertex_t** vSons,
00457 unsigned numSons);
00458
00474 Dag_Vertex_t*
00475 Dag_VertexInsert(Dag_Manager_t* dagManager,
00476 int vSymb,
00477 char* vData,
00478 Dag_Vertex_t** vSons,
00479 unsigned numSons);
00480
00489 void Dag_VertexMark(Dag_Vertex_t* v);
00490
00499 void Dag_VertexUnmark(Dag_Vertex_t* v);
00500
00508 void PrintStat(Dag_Vertex_t* dfsRoot, FILE* statFile, char* prefix);
00509
00515 #endif