1 /*------------------------------------------------------------\ 2 | | 3 | This file is part of the Alliance CAD System Copyright | 4 | (C) Laboratoire LIP6 - D�partement ASIM Universite P&M Curie| 5 | | 6 | Home page : http://www-asim.lip6.fr/alliance/ | 7 | E-mail : mailto:alliance-users@asim.lip6.fr | 8 | | 9 | This progam is free software; you can redistribute it | 10 | and/or modify it under the terms of the GNU Library General| 11 | Public License as published by the Free Software Foundation | 12 | either version 2 of the License, or (at your option) any | 13 | later version. | 14 | | 15 | Alliance VLSI CAD System is distributed in the hope that | 16 | it will be useful, but WITHOUT ANY WARRANTY; | 17 | without even the implied warranty of MERCHANTABILITY or | 18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | 19 | Public License for more details. | 20 | | 21 | You should have received a copy of the GNU General Public | 22 | License along with the GNU C Library; see the file COPYING. | 23 | If not, write to the Free Software Foundation, Inc., | 24 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 25 | | 26 \------------------------------------------------------------*/ 27 /*------------------------------------------------------\ 28 | | 29 | Title : Structures and fonctions for AUT | 30 | | 31 | Date : 03.12.96 | 32 | | 33 | Author : Jacomme Ludovic | 34 | | 35 \------------------------------------------------------*/ 36 37 # ifndef AUT_103_H 38 # define AUT_103_H 39 40 /*------------------------------------------------------\ 41 | | 42 | Constants | 43 | | 44 \------------------------------------------------------*/ 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif /* __cplusplus */ 49 50 # ifndef __P 51 # if defined(__STDC__) || defined(__GNUC__) || defined(__cplusplus) 52 # define __P(x) x 53 # else 54 # define __P(x) () 55 # endif 56 # endif 57 58 /*------------------------------------------------------\ 59 | | 60 | Hash Key | 61 | | 62 \------------------------------------------------------*/ 63 64 # define AUT_HASH_KEY_EMPTY (char *)0 65 # define AUT_HASH_KEY_DELETED (char *)1 66 67 /*------------------------------------------------------\ 68 | | 69 | Prime Number | 70 | | 71 \------------------------------------------------------*/ 72 73 # define AUT_MAX_PRIME_NUMBER 58 74 75 /*------------------------------------------------------\ 76 | | 77 | Alloc | 78 | | 79 \------------------------------------------------------*/ 80 81 # define AUT_ALLOC_BLOCK 0 82 # define AUT_ALLOC_HEAP 1 83 84 /*------------------------------------------------------\ 85 | | 86 | Macros | 87 | | 88 \------------------------------------------------------*/ 89 /*------------------------------------------------------\ 90 | | 91 | Allocation Macros | 92 | | 93 \------------------------------------------------------*/ 94 95 # define autallocblock( S ) ( autalloc( (unsigned int)( S ), AUT_ALLOC_BLOCK ) ) 96 # define autallocheap( S ) ( autalloc( (unsigned int)( S ), AUT_ALLOC_HEAP ) ) 97 # define autfreeblock( P ) ( autfree( (char *)( P ), 0 ) ) 98 # define autfreeheap( P, S ) ( autfree( (char *)( P ), (unsigned int)( S ) ) ) 99 100 /*------------------------------------------------------\ 101 | | 102 | Resize Macros | 103 | | 104 \------------------------------------------------------*/ 105 106 # define autresizeblock( P, O, N ) ( autresize( ( P ), ( O ), ( N ) ) ) 107 108 /*------------------------------------------------------\ 109 | | 110 | Debug Macros | 111 | | 112 \------------------------------------------------------*/ 113 114 # define autbegin() do { \ 115 \ 116 if ( AUT_DEBUG_ON ) addautdebug(__LINE__,autbasename(__FILE__,NULL)); } while (0) 117 118 # define autend() do { \ 119 \ 120 if ( AUT_DEBUG_ON ) delautdebug(); } while (0) 121 122 /*------------------------------------------------------\ 123 | | 124 | Type | 125 | | 126 \------------------------------------------------------*/ 127 /*------------------------------------------------------\ 128 | | 129 | Aut Debug List | 130 | | 131 \------------------------------------------------------*/ 132 133 typedef struct autdebug_list 134 { 135 struct autdebug_list *NEXT; 136 int LINE; 137 char *NAME; 138 139 } autdebug_list; 140 141 /*------------------------------------------------------\ 142 | | 143 | Aut Hash Table | 144 | | 145 \------------------------------------------------------*/ 146 147 typedef struct authelem 148 { 149 char *KEY; 150 long VALUE; 151 152 } authelem; 153 154 typedef struct authtable 155 { 156 authelem *TABLE; 157 long TABLE_SIZE; 158 long NUMBER_ELEM; 159 long NUMBER_ADD; 160 long NUMBER_SCAN; 161 long NUMBER_DEL; 162 long NUMBER_STRETCH; 163 long (*FUNC_SIZE)(); 164 long (*FUNC_INDEX)(); 165 long (*FUNC_KEY)(); 166 167 } authtable; 168 169 /*------------------------------------------------------\ 170 | | 171 | Aut Hash Table 2 | 172 | | 173 \------------------------------------------------------*/ 174 175 typedef struct auth2elem 176 { 177 char *KEY1; 178 char *KEY2; 179 long VALUE; 180 181 } auth2elem; 182 183 typedef struct auth2table 184 { 185 auth2elem *TABLE; 186 long TABLE_SIZE; 187 long NUMBER_ELEM; 188 long NUMBER_ADD; 189 long NUMBER_SCAN; 190 long NUMBER_DEL; 191 long NUMBER_STRETCH; 192 long (*FUNC_SIZE)(); 193 long (*FUNC_INDEX)(); 194 long (*FUNC_KEY)(); 195 196 } auth2table; 197 198 /*------------------------------------------------------\ 199 | | 200 | Aut Graph | 201 | | 202 \------------------------------------------------------*/ 203 204 typedef struct autnode_list 205 { 206 struct autnode_list *NEXT; 207 struct autnode_list **PREV; 208 char *NAME; 209 chain_list *ARC_FROM; 210 chain_list *ARC_TO; 211 long FLAGS; 212 void *USER; 213 214 } autnode_list; 215 216 typedef struct autarc_list 217 { 218 struct autarc_list *NEXT; 219 struct autarc_list **PREV; 220 autnode_list *NODE_FROM; 221 autnode_list *NODE_TO; 222 long FLAGS; 223 void *USER; 224 225 } autarc_list; 226 227 typedef struct autgraph 228 { 229 autnode_list *NODE; 230 autarc_list *ARC; 231 authtable *HASH_NODE; 232 auth2table *HASH_ARC; 233 long NUMBER_NODE; 234 long NUMBER_ARC; 235 long FLAGS; 236 void *USER; 237 238 } autgraph; 239 240 /*------------------------------------------------------\ 241 | | 242 | Global Variables | 243 | | 244 \------------------------------------------------------*/ 245 246 extern autdebug_list *HEAD_AUTDEBUG; 247 extern char AUT_DEBUG_ON; 248 extern long AUT_HASH_PRIME_NUMBER[ AUT_MAX_PRIME_NUMBER ]; 249 extern long AUT_HASH_MAX_SCAN; 250 extern long AUT_HASH_STRETCH_FACTOR; 251 252 /*------------------------------------------------------\ 253 | | 254 | Functions | 255 | | 256 \------------------------------------------------------*/ 257 /*------------------------------------------------------\ 258 | | 259 | Env Functions | 260 | | 261 \------------------------------------------------------*/ 262 263 extern void autenv __P(()); 264 265 /*------------------------------------------------------\ 266 | | 267 | Exit Functions | 268 | | 269 \------------------------------------------------------*/ 270 271 extern void autexit __P((long Value)); 272 273 /*------------------------------------------------------\ 274 | | 275 | Alloc Functions | 276 | | 277 \------------------------------------------------------*/ 278 279 extern char * autalloc __P((unsigned int Size, char Heap)); 280 extern authelem * allocauthelem __P((unsigned int Number)); 281 extern authtable * allocauthtable __P(()); 282 extern auth2elem * allocauth2elem __P((unsigned int Number)); 283 extern auth2table * allocauth2table __P(()); 284 extern autdebug_list * allocautdebug __P(()); 285 286 /*------------------------------------------------------\ 287 | | 288 | Resize Functions | 289 | | 290 \------------------------------------------------------*/ 291 292 extern char * autresize __P((char *Source, unsigned int OldSize, unsigned int NewSize)); 293 294 /*------------------------------------------------------\ 295 | | 296 | Free Functions | 297 | | 298 \------------------------------------------------------*/ 299 300 extern void autfree __P((char *Pointer, unsigned int Size)); 301 extern void freeauthelem __P((authelem *Element)); 302 extern void freeauthtable __P((authtable *HashTable)); 303 extern void freeauth2elem __P((auth2elem *Element)); 304 extern void freeauth2table __P((auth2table *HashTable)); 305 extern void freeautdebug __P((autdebug_list *Debug)); 306 307 /*------------------------------------------------------\ 308 | | 309 | Debug Functions | 310 | | 311 \------------------------------------------------------*/ 312 313 extern void autdebug __P(()); 314 extern void addautdebug __P((int Line, char *File)); 315 extern void delautdebug __P(()); 316 317 /*------------------------------------------------------\ 318 | | 319 | Get Hash Functions | 320 | | 321 \------------------------------------------------------*/ 322 323 extern long getauthsize __P((long Size)); 324 extern long getauthkey __P((authtable *Table, char *Key)); 325 extern long getauthindex __P((authtable *Table, char *Key, long Index)); 326 327 extern long getauth2size __P((long Size)); 328 extern long getauth2key __P((auth2table *Table, char *Key1, char *Key2)); 329 extern long getauth2index __P((auth2table *Table, char *Key1, char *Key2, long Index)); 330 331 /*------------------------------------------------------\ 332 | | 333 | Check Hash Functions | 334 | | 335 \------------------------------------------------------*/ 336 337 extern int checkauthkey __P((char *Key, int Severity)); 338 extern int checkauth2key __P((char *Key1, char *Key2, int Severity)); 339 340 /*------------------------------------------------------\ 341 | | 342 | Set Hash Functions | 343 | | 344 \------------------------------------------------------*/ 345 346 extern void setauthfunc __P((authtable *HashTable, long (*FuncSize)(), \ 347 long (*FuncKey)() , long (*FuncIndex)())); 348 349 extern void setauth2func __P((auth2table *HashTable, long (*FuncSize)(), \ 350 long (*FuncKey)(), long (*FuncIndex)())); 351 352 /*------------------------------------------------------\ 353 | | 354 | Hash Table Functions | 355 | | 356 \------------------------------------------------------*/ 357 358 extern authtable *createauthtable __P((long Length)); 359 extern void stretchauthtable __P((authtable *HashTable)); 360 extern void destroyauthtable __P((authtable *HashTable)); 361 extern void resetauthtable __P((authtable *HashTable)); 362 extern void viewauthtable __P((authtable *HashTable, void (*FuncView)())); 363 extern void viewauthelem __P((authelem *Element)); 364 365 extern auth2table *createauth2table __P((long Length)); 366 extern void stretchauth2table __P((auth2table *HashTable)); 367 extern void destroyauth2table __P((auth2table *HashTable)); 368 extern void resetauth2table __P((auth2table *HashTable)); 369 extern void viewauth2table __P((auth2table *HashTable, void (*FuncView)())); 370 extern void viewauth2elem __P((auth2elem *Element)); 371 372 /*------------------------------------------------------\ 373 | | 374 | Hash Element Functions | 375 | | 376 \------------------------------------------------------*/ 377 378 extern authelem *addauthelem __P((authtable *HashTable, char *Key, long Value)); 379 extern authelem *searchauthelem __P((authtable *HashTable, char *Key)); 380 extern int delauthelem __P((authtable *HashTable, char *Key)); 381 382 extern auth2elem *addauth2elem __P((auth2table *HashTable, char *Key1, \ 383 char *Key2, long Value)); 384 extern auth2elem *searchauth2elem __P((auth2table *HashTable, char *Key1, char *Key2)); 385 extern int delauth2elem __P((auth2table *HashTable, char *Key1, char *Key2)); 386 387 /*------------------------------------------------------\ 388 | | 389 | Hash Test Functions | 390 | | 391 \------------------------------------------------------*/ 392 393 extern int testauthtable __P((authtable *HashTable)); 394 extern int testauth2table __P((auth2table *HashTable)); 395 396 /*------------------------------------------------------\ 397 | | 398 | Sort Compare Function | 399 | | 400 \------------------------------------------------------*/ 401 402 extern long sortautcompare __P((long *ValueArray, long Index1, long Index2)); 403 404 /*------------------------------------------------------\ 405 | | 406 | Sort Function | 407 | | 408 \------------------------------------------------------*/ 409 410 extern void sortautarray __P((void *ValueArray, long *IndexArray, \ 411 long ArraySize, long (*FuncCompare)())); 412 413 /*------------------------------------------------------\ 414 | | 415 | File Function | 416 | | 417 \------------------------------------------------------*/ 418 419 extern char *autbasename __P((char *Name, char *Extension)); 420 421 /*------------------------------------------------------\ 422 | | 423 | Name Functions | 424 | | 425 \------------------------------------------------------*/ 426 427 extern char *autnamealloc __P((char *Name)); 428 429 /*------------------------------------------------------\ 430 | | 431 | Graph Functions | 432 | | 433 \------------------------------------------------------*/ 434 435 extern autnode_list * searchautgraphnode __P((autgraph *Graph, char *Name)); 436 extern autarc_list * searchautgrapharc __P((autgraph *Graph, autnode_list *NodeFrom, \ 437 autnode_list *NodeTo)); 438 439 extern autnode_list * addautgraphnode __P((autgraph *Graph, char *Name)); 440 extern autarc_list * addautgrapharc __P((autgraph *Graph, autnode_list *NodeFrom, \ 441 autnode_list *NodeTo)); 442 443 extern void delautgraphnode __P((autgraph *Graph, autnode_list *Node)); 444 extern void delautgrapharc __P((autgraph *Graph, autarc_list *Arc)); 445 446 extern autgraph * createautgraph __P(()); 447 extern void destroyautgraph __P((autgraph *Graph)); 448 449 extern void viewautgraph __P((autgraph *Graph, void (*FuncViewNode)(), \ 450 void (*FuncViewArc)())); 451 extern autgraph * loadautgraph __P((char *FileName)); 452 extern void driveautgraph __P((autgraph *Graph, char *FileName)); 453 454 #ifdef __cplusplus 455 } 456 #endif /* __cplusplus */ 457 458 # endif 459