2 * This file is part of the Alliance CAD System
3 * Copyright (C) Laboratoire LIP6 - Département ASIM
4 * Universite Pierre et Marie Curie
6 * Home page : http://www-asim.lip6.fr/alliance/
7 * E-mail support : mailto:alliance-support@asim.lip6.fr
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Library General Public License as published
11 * by the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
14 * Alliance VLSI CAD System is distributed in the hope that it will be
15 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with the GNU C Library; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 /*******************************************************************************
27 * Tool : Spice parser / driver v 7.00 *
28 * Author(s) : Gregoire AVOT *
29 * Updates : March, 18th 1998 *
31 *******************************************************************************/
34 #include <sys/types.h>
40 tableint
* creattableint()
45 new = (tableint
*) mbkalloc( sizeof( tableint
) * SPI_TABLEINTMAX
);
47 for( i
= 0 ; i
< SPI_TABLEINTMAX
; i
++ )
57 int settableint( table
, value
, data
)
69 p
= ( value
>> ( niveau
* 8 ) ) & ( SPI_TABLEINTMASK
);
71 if( table
[ p
].index
== value
)
73 /* L'element existe déjà : on le remplace */
74 table
[ p
].data
= data
;
78 if( table
[ p
].index
== 0 )
81 table
[ p
].index
= value
;
82 table
[ p
].data
= data
;
86 if( table
[ p
].down
== NULL
)
87 table
[ p
].down
= creattableint();
91 table
= table
[p
].down
;
95 void removetableint( table
, value
)
106 p
= ( value
>> ( niveau
* 8 ) ) & ( SPI_TABLEINTMASK
);
108 if( table
[ p
].index
== value
)
110 /* L'element existe déjà : on le vire */
111 table
[ p
].index
= 0;
112 table
[ p
].data
= NULL
;
116 if( table
[ p
].down
!= NULL
)
117 table
= table
[ p
].down
;
124 void* tsttableint( table
, value
)
135 p
= ( value
>> ( niveau
* 8 ) ) & (SPI_TABLEINTMASK
);
137 if( table
[ p
].index
== value
)
138 return( table
[ p
].data
);
140 if( table
[ p
].down
== NULL
)
145 table
= table
[ p
].down
;
149 void freetableint( table
)
154 for( i
= 0 ; i
< SPI_TABLEINTMAX
; i
++ )
156 if( table
[ i
].down
)
157 freetableint( table
[ i
].down
);
162 int scanint( table
, n
)
168 tableint
*t
=NULL
, *t3
, *t2
, *t1
, *t0
;
172 for( i
= 0 ; i
< SPI_TABLEINTMAX
; i
++ )
175 return( table
[i
].index
);
180 n0
= n
& SPI_TABLEINTMASK
;
181 n1
= ( n
>> 8 ) & SPI_TABLEINTMASK
;
182 n2
= ( n
>> 16 ) & SPI_TABLEINTMASK
;
183 n3
= ( n
>> 24 ) & SPI_TABLEINTMASK
;
185 /* recherche de l'element n */
192 if( table
[ n3
].index
== n
)
199 if( table
[ n3
].down
[ n2
].index
== n
)
201 t
= table
[ n3
].down
;
207 if( table
[ n3
].down
[ n2
].down
[ n1
].index
== n
)
209 t
= table
[ n3
].down
[ n2
].down
;
212 t2
= table
[ n3
].down
;
216 if( table
[ n3
].down
[ n2
].down
[ n1
].down
[ n0
].index
== n
)
218 t
= table
[ n3
].down
[ n2
].down
[ n1
].down
;
221 t2
= table
[ n3
].down
;
222 t1
= table
[ n3
].down
[ n2
].down
;
226 /* Descent d'un niveau */
232 for( i
= 0 ; i
< SPI_TABLEINTMAX
; i
++ )
235 return( t
[ i
].index
);
242 /* Parcour un niveau horizontalement */
244 for( i
= l
+ 1 ; i
< SPI_TABLEINTMAX
; i
++ )
247 return( t
[ i
].index
);
250 /* Remonte les niveaux */
273 /* Cette boucle se finie en interne par un return */