1 /****************************************************************************/
3 /* Chaine de CAO & VLSI Alliance */
5 /* Produit : FCL v1.02 */
6 /* Fichier : fcl_util.c */
8 /* (c) copyright 1996 Laboratoire MASI equipe CAO & VLSI */
9 /* Tous droits reserves */
10 /* Support : e-mail alliance-support@asim.lip6.fr */
13 /****************************************************************************/
15 #include "fcl_headers.h"
22 fcl_label
CountChain(pthead
)
28 for(pt
=pthead
;pt
;pt
=pt
->NEXT
,i
++);
30 return ((fcl_label
) i
);
33 fcl_label
getlabellocon(ptlocon
)
36 if (ptlocon
== NULL
) return (fcl_label
)0;
37 if (ptlocon
->TYPE
== 'T') {
38 if (ptlocon
->NAME
== MBK_GRID_NAME
) return (fcl_label
)POID_GRID
;
39 if (ptlocon
->NAME
== MBK_SOURCE_NAME
) return (fcl_label
)POID_SOURCE
;
40 if (ptlocon
->NAME
== MBK_DRAIN_NAME
) return (fcl_label
)POID_DRAIN
;
41 if (ptlocon
->NAME
== MBK_BULK_NAME
) return (fcl_label
)POID_BULK
;
43 if (ptlocon
->TYPE
!= INTERNAL
) return (fcl_label
)POID_PAD
;
44 if (ptlocon
->FLAGS
!= 0) return (fcl_label
)ptlocon
->FLAGS
;
46 return (fcl_label
)POID_INS
;
49 fcl_label
getlabeltrs(ptlotrs
)
54 ptype
= getptype(ptlotrs
->USER
,(long)FCL_LABEL_PTYPE
);
56 if (ptype
== (ptype_list
*) NULL
)
57 return ((fcl_label
) 1);
59 return ((fcl_label
) (long)ptype
->DATA
);
62 fcl_label
getlabelsig(ptlosig
)
67 ptype
= getptype(ptlosig
->USER
,(long)FCL_LABEL_PTYPE
);
69 if (ptype
== (ptype_list
*) NULL
)
70 return ((fcl_label
) 0);
72 return ((fcl_label
) (long)ptype
->DATA
);
76 fclCorruptLotrs(ptlotrs
)
81 if ((ptuser
= getptype(ptlotrs
->USER
, FCL_LABEL_PTYPE
)) != NULL
) {
82 ptuser
->DATA
= (void *)FCL_CORRUPT
;
85 ptlotrs
->USER
= addptype(ptlotrs
->USER
, FCL_LABEL_PTYPE
, (void *)FCL_CORRUPT
);
90 fclCorruptLosig(ptlosig
)
95 if ((ptuser
= getptype(ptlosig
->USER
, FCL_LABEL_PTYPE
)) != NULL
) {
96 ptuser
->DATA
= (void *)FCL_CORRUPT
;
99 ptlosig
->USER
= addptype(ptlosig
->USER
, FCL_LABEL_PTYPE
, (void *)FCL_CORRUPT
);
103 fcl_label
getlabelsigtrs(ptlotrs
,ptlosig
)
107 if (ptlotrs
->DRAIN
->SIG
== ptlosig
)
108 return getlabellocon(ptlotrs
->DRAIN
);
110 if (ptlotrs
->GRID
->SIG
== ptlosig
)
111 return getlabellocon(ptlotrs
->GRID
);
113 if (ptlotrs
->SOURCE
->SIG
== ptlosig
)
114 return getlabellocon(ptlotrs
->SOURCE
);
117 if (ptlotrs
->BULK
->SIG
== ptlosig
)
118 return getlabellocon(ptlotrs
->BULK
);
124 lotrs_list
*whichtrs(ptlofig
,ptlocon
)
130 for(ptr
=ptlofig
->LOTRS
;ptr
;ptr
=ptr
->NEXT
)
132 if (ptr
->DRAIN
== ptlocon
) return ptr
;
133 if (ptr
->SOURCE
== ptlocon
) return ptr
;
134 if (ptr
->GRID
== ptlocon
) return ptr
;
135 if (ptr
->BULK
== ptlocon
) return ptr
;
138 return (lotrs_list
*) NULL
;
142 fclMarkTrans(transchain
)
143 chain_list
*transchain
;
149 for (ptchain
= transchain
; ptchain
; ptchain
= ptchain
->NEXT
) {
150 pttrans
= (lotrs_list
*)ptchain
->DATA
;
151 if ((ptuser
= getptype(pttrans
->USER
, FCL_MARK_PTYPE
)) != NULL
) {
152 ptuser
->DATA
= (void *)((long)ptuser
->DATA
| FCL_USED
);
154 else pttrans
->USER
= addptype(pttrans
->USER
, FCL_MARK_PTYPE
, (void *)FCL_USED
);
159 fclUnmarkTrans(transchain
)
160 chain_list
*transchain
;
166 for (ptchain
= transchain
; ptchain
; ptchain
= ptchain
->NEXT
) {
167 pttrans
= (lotrs_list
*)ptchain
->DATA
;
168 mark
= (long)getptype(pttrans
->USER
, FCL_MARK_PTYPE
)->DATA
;
170 if (mark
== 0) pttrans
->USER
= delptype(pttrans
->USER
, FCL_MARK_PTYPE
);
175 fclCleanShareMarks(ptlofig
)
181 for (ptlotrs
= ptlofig
->LOTRS
; ptlotrs
; ptlotrs
= ptlotrs
->NEXT
) {
182 if (getptype(ptlotrs
->USER
, FCL_MARK_PTYPE
) != NULL
) {
183 ptlotrs
->USER
= delptype(ptlotrs
->USER
, FCL_MARK_PTYPE
);
186 for (ptloins
= ptlofig
->LOINS
; ptloins
; ptloins
= ptloins
->NEXT
) {
187 if (getptype(ptloins
->USER
, FCL_MARK_PTYPE
) != NULL
) {
188 ptloins
->USER
= delptype(ptloins
->USER
, FCL_MARK_PTYPE
);
194 fclCleanTransferMarks(ptlofig
)
202 for (ptlotrs
= ptlofig
->LOTRS
; ptlotrs
; ptlotrs
= ptlotrs
->NEXT
) {
203 if (getptype(ptlotrs
->USER
, FCL_TRANSFER_PTYPE
) != NULL
) {
204 ptlotrs
->USER
= delptype(ptlotrs
->USER
, FCL_TRANSFER_PTYPE
);
207 for (ptloins
= ptlofig
->LOINS
; ptloins
; ptloins
= ptloins
->NEXT
) {
208 if (getptype(ptloins
->USER
, FCL_TRANSFER_PTYPE
) != NULL
) {
209 ptloins
->USER
= delptype(ptloins
->USER
, FCL_TRANSFER_PTYPE
);
212 for (ptlosig
= ptlofig
->LOSIG
; ptlosig
; ptlosig
= ptlosig
->NEXT
) {
213 if (getptype(ptlosig
->USER
, FCL_TRANSFER_PTYPE
) != NULL
) {
214 ptlosig
->USER
= delptype(ptlosig
->USER
, FCL_TRANSFER_PTYPE
);
217 if ((ptuser
= getptype(ptlofig
->USER
, FCL_LOCON_PTYPE
)) != NULL
) {
218 freechain((chain_list
*)ptuser
->DATA
);
219 ptlofig
->USER
= delptype(ptlofig
->USER
, FCL_LOCON_PTYPE
);
224 fclCleanCouplingMarks(ptlofig
)
230 for (ptlosig
= ptlofig
->LOSIG
; ptlosig
; ptlosig
= ptlosig
->NEXT
) {
231 if ((ptuser
= getptype(ptlosig
->USER
, FCL_COUP_LIST_PTYPE
)) != NULL
) {
232 freenum((num_list
*)ptuser
->DATA
);
233 ptlosig
->USER
= delptype(ptlosig
->USER
, FCL_COUP_LIST_PTYPE
);
238 void fclCleanTransList(ptloins
)
243 if ((ptuser
= getptype(ptloins
->USER
, FCL_TRANSLIST_PTYPE
)) != NULL
) {
244 freechain((chain_list
*)ptuser
->DATA
);
245 ptloins
->USER
= delptype(ptloins
->USER
, FCL_TRANSLIST_PTYPE
);
247 if ((ptuser
= getptype(ptloins
->USER
, FCL_INSLIST_PTYPE
)) != NULL
) {
248 freechain((chain_list
*)ptuser
->DATA
);
249 ptloins
->USER
= delptype(ptloins
->USER
, FCL_INSLIST_PTYPE
);
255 fclDeleteInstance(ptloins
)
259 locon_list
*ptlocon
, *ptnextlocon
;
261 if ((ptuser
= getptype(ptloins
->USER
, FCL_TRANSLIST_PTYPE
)) != NULL
) {
262 freechain((chain_list
*)ptuser
->DATA
);
263 ptloins
->USER
= delptype(ptloins
->USER
, FCL_TRANSLIST_PTYPE
);
265 if ((ptuser
= getptype(ptloins
->USER
, FCL_INSLIST_PTYPE
)) != NULL
) {
266 freechain((chain_list
*)ptuser
->DATA
);
267 ptloins
->USER
= delptype(ptloins
->USER
, FCL_INSLIST_PTYPE
);
269 for (ptlocon
= ptloins
->LOCON
; ptlocon
; ptlocon
= ptnextlocon
) {
270 ptnextlocon
= ptlocon
->NEXT
;
277 fclFreeCorrespList(ptlist
)
278 fclcorresp_list
*ptlist
;
280 fclcorresp_list
*ptcorresp
;
281 fclcorresp_list
*ptnext
;
283 for (ptcorresp
= ptlist
; ptcorresp
; ptcorresp
= ptnext
) {
284 ptnext
= ptcorresp
->NEXT
;
289 /* display system and user time */
290 extern long NUM_PTYPE
;
293 fclPrintTime(start
, end
, rstart
, rend
)
294 struct rusage
*start
, *end
;
299 unsigned long user
, syst
;
300 unsigned long userM
, userS
, userD
;
301 unsigned long systM
, systS
, systD
;
304 temps
= rend
- rstart
;
305 user
= (100 * end
->ru_utime
.tv_sec
+ (end
->ru_utime
.tv_usec
/ 10000))
306 - (100 * start
->ru_utime
.tv_sec
+ (start
->ru_utime
.tv_usec
/ 10000));
307 syst
= (100 * end
->ru_stime
.tv_sec
+ (end
->ru_stime
.tv_usec
/ 10000))
308 - (100 * start
->ru_stime
.tv_sec
+ (start
->ru_stime
.tv_usec
/ 10000));
311 userS
= (user
% 6000) / 100;
312 userD
= (user
% 100) / 10;
315 systS
= (syst
% 6000) / 100;
316 systD
= (syst
% 100) / 10;
318 fprintf(stdout
, " %02ldm%02lds", (long) (temps
/ 60), (long) (temps
% 60));
319 fprintf(stdout
, " u:%02ldm%02ld.%ld", userM
, userS
, userD
);
320 bytes
= mbkprocessmemoryusage();
321 fprintf(stdout
, " M:%ldKb\n", bytes
/ 1024);
330 getrusage(RUSAGE_SELF
, t
);