[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::c_plus_plus

Title:C++
Notice:Read 1.* and use keywords (e.g. SHOW KEY/FULL KIT_CXX_VAX_VMS)
Moderator:DECCXX::AMARTIN
Created:Fri Nov 06 1987
Last Modified:Thu Jun 05 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:3604
Total number of notes:18242

3519.0. "CXX Memory Access Violation" by ASIC::SNYDER () Mon Mar 31 1997 14:05

Hi,
    
    My name is Ryan Snyder and I work in the ASIC Center Internal Layout
    group with Mike Kirkpatrick (Mike wrote to you about a week ago with a
    similar compiler problem).
    
    We are running on the DEC Alpha platform utilizing:
    
    Digital UNIX V4.0B (Rev. 564)
    V5.5-004 on Digital UNIX (Alpha)
    
    Previously, we were using, without problems:
    
    Digital UNIX V3.2B (Rev. 148)
    V5.1-1 on Digital UNIX (Alpha)
     
    I am getting:
    
    cxx: Fatal: A memory access violation (bus error or segmentation fault)
    has occurred. Please submit a problem report.
    
    I have traced the problem to the include of 'partition.h' in my
    'clock.cc' source file.  Specifically, in class 'BufferPlacement', the
    compiler doesn't seem to like the 'SLList <Block *>Block' argument in
    the 'GetBlockInfo' function header.
    
    I have recomplied the source using the '-P' flag, and included the
    clock.ixx file below.  Please, take a look at it, and see if you can
    shed some light on the problem.  If you need any more information,
    please feel free to contact me.
    
    Thanks,
    
    Ryan
    
    * Ryan Snyder                    email: snyder@mro.dec.com
    * ASIC Center, Internal Layout   phone: 508-467-8224, DTN-297-8224
    * Digital Equipment Corporation  fax:   508-467-1747
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
static char RCSID[] = "$Id: clock.cc,v 1.18 1997/03/13 16:00:35 snyder Exp $";

 
 
 
 
 




 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
 
 
 
 















 







 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 





 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



 
 
 
 
 
 








 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



 
 
 
 
 






 
 
 
 














































































































 
 
 
 
 

 
 
 
 
 
 
 









 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 







 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 







 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 








 





 
 
 
 
 


#   pragma __environment save
#   pragma __environment header_defaults


















 
 
 
 
 

 









 
 
 













 
 







 
 
 
 
 

 































 
 
 
 
 

 




typedef long __cxxl_register_t;


class __cxxl_packages_t

 
 
 
 
 
 
 
 
 
 
 
 
 

{
public:





    static const char *file_name;
    static const char *file_location;
    static int set_cxxl;
    static int set_complex;
    static int set_generic;
    static int set_iostream;
    static int set_objection;
    static int set_stopwatch;
    static int set_string;
    static int set_task;
    static int set_vector;
    static int set_messages;
};

class __cxxl_init_t

 
 
 
 
 
 
 
 
 
 
 
 

{
private:





    static int initcount;

public:





    __cxxl_init_t();
    ~__cxxl_init_t();

    static void initialize();
};




#   pragma __environment restore









 





 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



 
 
 
 
 



extern "C"
{






















 


 


  



 


 










                                                                    

























 


 


  



 


 












 














                                                                    









 














  








 

 







 













 










 










 






 






 


 

 











 
















 




 




























 












 
 






 
 

























 






 



typedef long             ptrdiff_t;




typedef unsigned long   size_t;





 












    typedef unsigned int  wchar_t;




































 


 


  



 


 










                                                                    













 






 












typedef long    fpos_t;





 








 











 































 


 


 



 


 




 













typedef struct {
	int	_cnt;
	unsigned int	_flag2;
	unsigned char	*_ptr;
	unsigned char	*_base;
	int	_bufsiz;
	short	_flag;
	short	_file;




	char	*__newbase;
	void	*_lock;			 
	unsigned char	*_bufendp;
} FILE;

extern FILE	_iob[];












extern "C" {
extern size_t	fread (void *, size_t, size_t, FILE *);
extern size_t	fwrite (const void *, size_t, size_t, FILE *);
}


extern "C" {
extern int	_flsbuf (int, FILE *);
extern int	_filbuf (FILE *);
extern int 	ferror (FILE *);
extern int 	feof (FILE *);
extern void 	clearerr (FILE *);
extern int 	putchar (int);
extern int 	getchar (void);
extern int 	putc (int, FILE *);
extern int 	getc (FILE *);
extern int	remove (const char *);
extern int	rename (const char *, const char *);
extern FILE 	*tmpfile (void);
extern char 	*tmpnam (char *);
extern int 	fclose (FILE *);
extern int 	fflush (FILE *);
extern FILE	*fopen (const char *, const char *);
extern FILE 	*freopen (const char *, const char *, FILE *);
extern void 	setbuf (FILE *, char *);
extern int 	setvbuf (FILE *, char *, int, size_t);
extern int	fprintf (FILE *, const char *, ...);
extern int	fscanf (FILE *, const char *, ...);
extern int	printf (const char *, ...);
extern int	scanf (const char *, ...);
extern int	sprintf (char *, const char *, ...);
extern int	sscanf (const char *, const char *, ...);






























 


 


 



 


 











 
 















 



typedef struct {
	char	**_a0;		 
	int	_offset;		 
} va_list;














extern int  vfprintf (FILE *, const char *, va_list);
extern int  vprintf (const char *, va_list);
extern int  vsprintf (char *, const char *, va_list);











extern int 	fgetc (FILE *);
extern char 	*fgets (char *, int, FILE *);
extern int 	fputc (int, FILE *);
extern int 	fputs (const char *, FILE *);
extern char 	*gets (char *);
extern int 	puts (const char *);
extern int	ungetc (int, FILE *);
extern int	fgetpos (FILE *, fpos_t *);
extern int 	fseek (FILE *, long, int);
extern int	fsetpos (FILE *, const fpos_t *);
extern long	ftell (FILE *);
extern void	rewind (FILE *);
extern void 	perror (const char *);











 












}



















































































































 
























 


 


  

 



 


 













 














 






 










 

























typedef unsigned int wctype_t;









typedef int            time_t;




typedef int             clock_t;













typedef long                    ssize_t;  




 
typedef	unsigned char	uchar_t;
typedef	unsigned short	ushort_t;
typedef	unsigned int	uint_t;
typedef unsigned long	ulong_t;
typedef	volatile unsigned char	vuchar_t;
typedef	volatile unsigned short	vushort_t;
typedef	volatile unsigned int	vuint_t;
typedef volatile unsigned long	vulong_t;




typedef	struct	{ long r[1]; } *physadr_t;



 
typedef	struct	label_t	{
	long	val[10];
} label_t;











































typedef int		level_t;
typedef	int		daddr_t;	 
typedef	char *		caddr_t;	 
typedef long *		qaddr_t;         
typedef char *          addr_t;
typedef	uint_t		ino_t;		 
typedef short		cnt_t;
typedef int		dev_t;		 
typedef	int		chan_t;		 




typedef long    off_t;			 


typedef unsigned long	rlim_t;		 
typedef	int		paddr_t;
typedef	ushort_t	nlink_t;



typedef int    		key_t;		 




typedef	uint_t		mode_t;		 







typedef uint_t		uid_t;		 





typedef uint_t		gid_t;		 




typedef	void *		mid_t;		 




typedef	int		pid_t;		 


typedef char		slab_t[12];	 

typedef ulong_t		shmatt_t;	 
typedef ulong_t		msgqnum_t;	 
typedef ulong_t		msglen_t;	 



        typedef unsigned int wint_t;          


 


typedef unsigned long	sigset_t;


 












typedef struct __pthread_attr_t {
    long		__valid;
    char*		__name;
    unsigned long	__arg;
    unsigned long	__reserved[19];
    } pthread_attr_t;

typedef struct __pthread_mutexattr_t {
    long		__valid;
    unsigned long	__reserved[15];
    } pthread_mutexattr_t;

typedef struct __pthread_condattr_t {
    long		__valid;
    unsigned long	__reserved[13];
    } pthread_condattr_t;

typedef struct __pthread_t {
    void*		__reserved1;
    void*		__reserved2;
    unsigned short	__size;
    unsigned char	__reserved3[2];
    unsigned char	__reserved4[4];
    unsigned long	__sequence;
    unsigned long	__reserved5[2];
    void*		__per_kt_area;
    void*		__stack_base;
    void*		__stack_reserve;
    void*		__stack_yellow;
    void*		__stack_guard;
    unsigned long	__stack_size;
    void**		__tsd_values;
    unsigned long	__tsd_count;
    unsigned int	__reserved6;
    unsigned int	__reserved7;
    unsigned int	__thread_flags;
    } *pthread_t;

typedef volatile struct __pthread_mutex_t {
    unsigned int	__lock;
    unsigned int	__valid;
    char*		__name;
    unsigned int	__arg;
    unsigned int	__depth;
    unsigned long	__sequence;
    unsigned long	__owner;
    void*		__block;
    } pthread_mutex_t;

typedef volatile struct __pthread_cond_t {
    unsigned int	__state;
    unsigned int	__valid;
    char*		__name;
    unsigned int	__arg;
    unsigned long	__sequence;
    void*		__block;
    } pthread_cond_t;

typedef unsigned int	pthread_key_t;

typedef volatile struct __pthread_once_t {
    long	__state;
    long	__reserved[10];
    } pthread_once_t;








 
typedef long            timer_t;         



















typedef void (*sig_t) (int,void (*)(int));











 
typedef pid_t		id_t;		 
					 
					 
					 
					 
typedef unsigned int	useconds_t;	 







 
typedef uint_t	major_t;       
typedef uint_t	minor_t;       
typedef uint_t	devs_t;        
typedef uint_t	unit_t;        



 






 






























 


 


  





















 



 


 






 

 






typedef	unsigned long	vm_offset_t;
typedef	unsigned long	vm_size_t;







 
typedef	uchar_t		uchar;
typedef	ushort_t	ushort;
typedef	uint_t		uint;
typedef ulong_t		ulong;

typedef	physadr_t	physadr;


 
typedef	uchar_t		u_char;
typedef	ushort_t 	u_short;
typedef	uint_t		u_int;
typedef	ulong_t		u_long;
typedef	vuchar_t	vu_char;
typedef	vushort_t 	vu_short;
typedef	vuint_t		vu_int;
typedef	vulong_t	vu_long;





typedef struct  _quad { int val[2]; } quad;


typedef	long	swblk_t;
typedef u_long	fixpt_t;























 


 


  

 



 




 


 




extern "C" {
















































































 

















typedef int	fd_mask;



 



















typedef	struct fd_set {
	fd_mask	fds_bits[(((4096)+(((sizeof(fd_mask) * 8))-1))/((sizeof(fd_mask) * 8)))];
} fd_set;











































 






extern void bzero (char *, int);






struct timeval;
int select (int, fd_set *, fd_set *, fd_set *, struct timeval *);





}






 
typedef unsigned char sa_family_t;

 
typedef	unsigned int	in_addr_t;
 
typedef	unsigned short	in_port_t;











extern "C" {
extern int 	fileno (FILE *);
extern FILE 	*fdopen (int, const char *);




extern char *cuserid (char *);
}













 






















 


 


 



  


 







extern "C"
{

extern int getopt (int, char * const [], const char *);

}


extern char *optarg;
extern int optind;
extern int optopt;
extern int opterr;



 



extern "C" {
extern char	*ctermid (char *);
extern int 	getw (FILE *);
extern int 	pclose (FILE *);
extern int 	putw (int, FILE*);
extern FILE 	*popen (const char *, const char *);
extern char 	*tempnam (const char*, const char*);
}




























 


 


  



 


 















 











                                                                    













 
























 


 


  



 


 


 

















 
















					 



					 







 














 




 















 










 















 























 


 


  

 



 


 

















 





































 








 





					 
 



















































































 


 


  





















 



 


 


 



 





















 
























 


 


 



 


















































 















 






 


















extern "C" {
extern void 	setbuffer (FILE *, char*, int);
extern void 	setlinebuf (FILE *);
}








































































 


 


  



 


 















 











                                                                    









































































































































































































}


#   pragma __environment save
#   pragma __environment header_defaults








 
 
 
 
 











 
 
 
 
 

extern int cxxl_messages_print_cerr(const char *msg_arg);
extern int cxxl_messages_print_cerr_clog(const char *msg_arg);

class Messages

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

{
private:





    char *cxxl_filename;		 
    int cxxl_set;			 
    char *cxxl_default_file_location;	 
    char *cxxl_buffer;			 
    int cxxl_buffer_len;		 





public:
    Messages(const char *filename_arg, int set_arg = 0,
	const char *default_file_location_arg = (const char *)(0L));
    ~Messages();

    const char *text(int msg_arg, const char *fallback_text_arg,
	int set_arg = 0);
};


#   pragma __environment restore










 


extern "C"
{
 


































 


 


  

 



 


 













 






 







 























 


 


  

 



 


 









 




extern "C" {











 






 


















extern void	*memchr (const void *, int , size_t );
extern void	*memcpy (void *, const void *, size_t );
extern void	*memset (void *, int , size_t );
extern size_t 	strcspn (const char *, const char *);
extern size_t	strlen (const char *);
extern size_t	strspn (const char *, const char *);



extern void 	*memmove (void *, const void *, size_t );
extern char 	*strcpy (char *, const char *);
extern char 	*strncpy (char *, const char *, size_t );
extern char 	*strcat (char *, const char *);
extern char	*strncat (char *, const char *, size_t );
extern int 	memcmp (const void *, const void *,size_t );
extern int	strcmp (const char *, const char *);
extern int	strcoll (const char *, const char *);
extern int	strncmp (const char *,const char *,size_t );
extern size_t 	strxfrm (char *, const char *, size_t );
extern char	*strchr (const char *, int );
extern char	*strpbrk (const char *, const char *);
extern char	*strrchr (const char *, int );
extern char	*strstr (const char *, const char *);
extern char 	*strtok (char *, const char *);
extern char 	*strerror (int);
















extern void	*memccpy (void *, const void *, int , size_t );








extern void swab (const void *, void *, ssize_t);





extern char *strdup (const char *);




 
 






















 


 


  

 



 





  














 


 





extern "C" {

















extern int  bcmp (const char *, const char *, int);
extern void bcopy (const char *, char *, int);
extern void  bzero (char *, int);






extern int  ffs (int);
extern char *index (const char*, int);
extern char *rindex (const char*, int);
extern int  strcasecmp (const char *, const char *);
extern int  strncasecmp (const char *, const char *, size_t );


























 


 


  

 



 


 









 
















































































































































}




 








extern char    * basename (char *);
extern char    * dirname (char *);



















}







}


#   pragma __environment save
#   pragma __environment header_defaults








 
 
 











 
 
 

typedef long streamoff, streampos;









class streambuf;
class ostream;
class Mutex;

class ios

 
 
 
 
 
 
 
 
 
 

{
public:





    enum io_state	{ goodbit = 0, eofbit = 01, failbit = 02,
			  badbit = 04 };
    enum open_mode      { in = 01, out = 02, ate = 04, app = 010, trunc = 020,
                          nocreate = 040, noreplace = 0100 };
    enum seek_dir       { beg = 0, cur = 01, end = 02 };

     
    enum                { skipws = 01,
                             
                          left = 02, right = 04, internal = 010,
                             
                          dec = 020, oct = 040, hex = 0100, 
                             
                          showbase = 0200, showpoint = 0400, uppercase = 01000,
                          showpos = 02000,
                             
                          scientific = 04000, fixed = 010000,
                             
                          unitbuf = 020000, stdio = 040000 };
                             




                        ios(streambuf *);
    virtual             ~ios();

    inline int		bad() const;
    static long         bitalloc();
    inline void		clear(int state = 0);
    inline int		eof() const;
    inline int		fail() const;
    inline char		fill() const;
    char		fill(char);
    inline long		flags() const;
    long                flags(long);
    inline int		good() const;
    long		&iword(int);
    inline int		operator!();
    inline		operator void *();
    inline int		precision() const;
    int                 precision(int);
    void		*&pword(int);
    inline streambuf	*rdbuf();
    inline int		rdstate() const;
    long                setf(long setbits, long field);
    long                setf(long);
    static void         sync_with_stdio();
    inline ostream	*tie() const;
    ostream		*tie(ostream *);
    long                unsetf(long);
    inline int		width() const;
    int			width(int);
    static int          xalloc();

    inline Mutex 	*__get_mutex_info() { return m_mutex_info; }



protected:
                        ios();
    void                init(streambuf *);

    void		setstate(int state);
    inline void		__setstate(int state);
    inline int		__width(int);
private:		
                        ios(ios &);
    void                operator=(ios &);

 





















private:
    long		  m_nXalloc;
    long *		  m_pXalloc;
protected:
    streambuf* volatile	  m_psb;
    volatile int	  state;
    int			  ispecial;
    int			  ospecial;
    int			  __fill3;
    int			  osfx_special;
    int			  __fill4;
    ostream* volatile 	  m_posTie;
    volatile long	  m_lFlags;
    volatile short	  m_iPrecision;
    volatile char	  m_chFill;
    char		  __fill5;
    volatile short	  m_cchField;
    short		  __fill6;
    Mutex *		  m_mutex_info;


 




public:
    static const long   basefield;
                             
    static const long   adjustfield;
                             
    static const long   floatfield;
                             
private:
    static long		cxxl_bitalloc;
    static int		cxxl_xalloc;






protected:
    static int		xalloc_count() {return cxxl_xalloc;}
public:
    int                 skip(int);      

    friend class	Iostream_init;
    friend class	istream_withassign;
    friend class	ostream_withassign;
    friend class	iostream_withassign;
};





class streambuf

 
 
 
 
 
 
 

{
public:
                        streambuf();
                        streambuf(char *p, int len);

    void                dbp();

    inline void		__set_mutex_info(int);
    inline int		__get_mutex_info() { return m_mutex_info; }


private:
                        streambuf(streambuf &);
    void                operator=(streambuf &);
    int			snextcUnderflow();
    int			__gets(char *ptr, int n, int flag);
    int			__getl(long &l, int skipws, int base);
    int			__getul(unsigned long &l, int skipws, int base);
    int			__getd(double &d, int skipws);

protected:
    int			allocate();
    inline char		*base();
    inline int		blen();
    inline char		*eback();
    char		*ebuf();
    inline char		*egptr();
    inline char		*epptr();
    void		gbump(int n);
    inline char		*gptr();
    inline char		*pbase();
    void		pbump(int n);
    inline char		*pptr();
    void		setb(char *b, char *eb, int a = 0);
    void		setg(char *eb, char *g, char *eg);
    void		setp(char *p, char *ep);
    inline int		unbuffered();
    void		unbuffered(int n);




    char         	*GetDataMaxPtr();
    void         	SetDataMaxPtr(char *b);

    int			__allocate();
    inline void		__gbump(int n);
    inline void		__pbump(int n);
    void		__setb(char *b, char *eb, int a = 0);
    void		__setg(char *eb, char *g, char *eg);
    void		__setp(char *p, char *ep);
    inline char         *__GetDataMaxPtr();
    inline void         __SetDataMaxPtr(char *b);

public:
    int		        in_avail();
    int			out_waiting();
    int			sbumpc();
    streambuf		*setbuf(char *ptr, int len, int i);
    int			sgetc();
    int			sgetn(char *ptr, int n);
    int			snextc();
    int			sputbackc(char c);
    int			sputc(int c = (-1));
    int			sputn(const char *s, int n);
    void		stossc();
    inline int		__in_avail();
    inline int		__out_waiting();
    inline int		__sbumpc();
    inline int		__sgetc();
    inline int		__sgetn(char *ptr, int n);
    inline int		__snextc();
    inline int		__sputbackc(char c);
    int			__sputc(int c = (-1));
    inline int		__sputn(const char *s, int n);
    inline void		__stossc();
    inline  int         __FastFill(const char, int);
    inline  int         __FastSputn(const char*, int);

 

















protected:
    virtual int         doallocate();
public:
    virtual int         overflow(int c = (-1));
    virtual int         underflow();
    virtual int         pbackfail(int c);
    virtual int         sync();
    virtual streampos   seekoff(streamoff, ios::seek_dir,
				int = ios::in | ios::out);
    virtual streampos   seekpos(streampos, int = ios::in | ios::out);
    virtual int		xsputn(const char *, int);
    virtual int		xsgetn(char *, int);
    virtual streambuf	*setbuf(char *ptr, int len);
    virtual             ~streambuf();


 















private:
 
    int			x_snextc();
public:
    streambuf*		setbuf(unsigned char *, int);


 
































private:
    short	        m_bDoAutoDelete;
    volatile short      m_bIsOkToAllocate;
    int  		m_mutex_info;		 
    char * volatile	m_pchBase;
    char * volatile	m_pchPbase;
    char * volatile	m_pchPptr;
    char * volatile	m_pchEpptr;
    char * volatile	m_pchGptr;
    char * volatile	m_pchEgptr;
    char * volatile	m_pchEback;
    volatile int        m_cchBuffer;
    volatile int        m_cchDataMax;


    friend class	istream;
    friend void 	ios::sync_with_stdio();
};



class istream : virtual public ios

 
 
 
 
 
 

{
public:
                        istream(streambuf *);
    virtual             ~istream();

    istream		&get(char *ptr, int len, char delim = '\n');
    istream		&get(unsigned char *ptr, int len, char delim = '\n');
    istream		&get(char &);
    inline istream	&get(unsigned char &);
    istream		&get(streambuf &sb, char delim = '\n');
    int			get();
    istream		&getline(char *ptr, int len, char delim = '\n');
    istream		&getline(unsigned char *ptr, int len,
						     char delim = '\n');
    istream             &ignore(int len = 1, int delim = (-1));
    int			ipfx(int need = 0);
    void		isfx();
    int			peek();
    istream		&putback(char);
    istream             &read(char *s, int n);
    inline istream	&read(unsigned char *s, int n);
    istream		&seekg(streampos);
    istream		&seekg(streamoff, ios::seek_dir);
    void                skipwhite();
    int			sync();
    streampos           tellg();
    istream		&operator>>(char *);
    istream		&operator>>(char &);
    istream		&operator>>(short &);
    istream		&operator>>(int &);
    istream		&operator>>(long &);



    inline int		gcount();





    istream		&operator>>(float &);
    istream		&operator>>(double &);





    istream		&operator>>(unsigned char *);
    istream		&operator>>(unsigned char &);
    istream		&operator>>(unsigned short &);
    istream		&operator>>(unsigned int &);
    istream		&operator>>(unsigned long &);



    istream		&operator>>(streambuf *);
    inline istream	&operator>>(istream &(*f)(istream &));
    istream		&operator>>(ios &(*f)(ios &));

protected:
			istream();

private:
    volatile int        m_cchGet;
    int			__ipfx(int need = 0);


 
 
    int			do_ipfx(int need = 0);
    void		xget(char *);
 
 
 
public:
     	istream(streambuf *, int, ostream * = 0);
     	istream(int, int, ostream * = 0);
     	istream(int, char *, int);

    friend class	istream_withassign;
    friend class	iostream_withassign;
};

class ostream : virtual public ios

 
 
 
 
 
 

{
public:





			ostream(streambuf *);
    virtual		~ostream();

    ostream             &flush();
    inline ostream	&__flush_tie();
    int			opfx();
    void		osfx();
    ostream		&put(char);
    ostream             &seekp(streampos);
    ostream             &seekp(streamoff, ios::seek_dir);
    streampos           tellp();                   
    ostream		&write(const char *ptr, int n);
    inline ostream	&write(const unsigned char *ptr, int n);
    ostream             &operator<<(const char *);
    ostream		&operator<<(char);
    inline ostream	&operator<<(short);
    ostream             &operator<<(int);
    ostream             &operator<<(long);



    inline ostream	&operator<<(unsigned char);
    inline ostream	&operator<<(unsigned short);
    ostream		&operator<<(unsigned int); 
    ostream             &operator<<(unsigned long);



    ostream             &operator<<(const void *);
    ostream             &operator<<(streambuf *);
    inline ostream	&operator<<(ostream &(*f)(ostream &));
    ostream             &operator<<(ios &(*f)(ios &));





    ostream             &operator<<(float);
    ostream             &operator<<(double);
    inline ostream      &operator<<(long double);










protected:
                        ostream();

private:
    void		__WriteJustifiedString(const char *,  const char *);
    int			__opfx();
    ostream             &__flush();


 
 
public:
    			ostream(int);
			ostream(int, char*);








};

class iostream : public istream, public ostream

 
 
 
 
 
 

{
public:
			iostream(streambuf *);
    virtual		~iostream();

protected:
			iostream();
};

class istream_withassign : public istream

 
 
 
 
 
 

{
public:
			istream_withassign();
    virtual		~istream_withassign();

    istream_withassign	&operator=(istream &);
    istream_withassign	&operator=(streambuf *);
};

class ostream_withassign : public ostream

 
 
 
 
 
 

{
public:
			ostream_withassign();
    virtual		~ostream_withassign();

    ostream_withassign	&operator=(ostream &);
    ostream_withassign	&operator=(streambuf *);
};

class iostream_withassign : public iostream

 
 
 
 
 
 

{
public:
			iostream_withassign();
    virtual		~iostream_withassign();

    iostream_withassign	&operator=(iostream &);
    iostream_withassign	&operator=(streambuf *);
};

class Iostream_init

 
 
 
 
 
 
 
 
 
 
 
 

{
public:
			Iostream_init();
			~Iostream_init();

    void		initialize();

private:





    static int		initcount;

    friend class	ios;
};

 
 
 


 
 
 
 
 
 
 





extern istream_withassign cin;
extern ostream_withassign cout;
extern ostream_withassign cerr;
extern ostream_withassign clog;


 
 
 
 





ios	&dec(ios &);
ios	&hex(ios &);
ios	&oct(ios &);
ostream	&endl(ostream &i);
ostream	&ends(ostream &i);
ostream	&flush(ostream &);
istream	&ws(istream &);
ios	&lock(ios &);
ios	&unlock(ios &);


inline int ios::bad(
    ) const

 
 
 
 
 
 
 
 
 
 
 
 

{
    return state & badbit;
}

inline void ios::clear(
    int __state   
    )

 
 
 
 
 
 
 
 
 
 
 

{
    state = __state & (eofbit | failbit | badbit);
}

inline int ios::eof(
    ) const

 
 
 
 
 
 
 
 
 
 
 

{
    return state & eofbit;
}

inline int ios::fail(
    ) const

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

{
    return state & (failbit | badbit);
}

inline char ios::fill(
    ) const

 
 
 
 
 
 
 
 
 

{
    return m_chFill;
}

inline long ios::flags(
    ) const

 
 
 
 
 
 
 
 
 

{
    return m_lFlags;
}

inline int ios::good(
    ) const

 
 
 
 
 
 
 
 
 
 
 

{
    return state == goodbit;
}

inline int ios::operator!(
    )

 
 
 
 
 
 
 
 
 
 

{
    return state & (failbit | badbit);
}

inline ios::operator void *(
    )

 
 
 
 
 
 
 
 
 
 
 
 
 

{
    return (state & (failbit | badbit)) ? 0 : this;
}

inline int ios::precision(
    ) const

 
 
 
 
 
 
 
 
 
 

{
    return m_iPrecision;
}

inline streambuf *ios::rdbuf(
    )

 
 
 
 
 
 
 
 
 
 

{
    return m_psb;
}

inline int ios::rdstate(
    ) const

 
 
 
 
 
 
 
 
 

{
    return state;
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline void ios::__setstate(
    int __state)   
{
    state |= __state & (eofbit | failbit | badbit);
}

inline ostream *ios::tie(
    ) const

 
 
 
 
 
 
 
 
 
 
 

{
    return m_posTie;
}

inline int ios::width(
    ) const

 
 
 
 
 
 
 
 
 

{
    return m_cchField;
}

inline char *streambuf::base(
    )

 
 
 
 
 
 
 
 
 
 
 

{
    return m_pchBase;
}

inline int streambuf::blen(
    )

 
 
 
 
 
 
 
 
 
 

{
    return m_cchBuffer;
}

inline char *streambuf::eback(
    )

 
 
 
 
 
 
 
 
 
 

{
    return m_pchEback;
}

inline char *streambuf::egptr(
    )

 
 
 
 
 
 
 
 
 
 

{
    return m_pchEgptr;
}

inline char *streambuf::epptr(
    )

 
 
 
 
 
 
 
 
 
 

{
    return m_pchEpptr;
}

inline void streambuf::__gbump(
    int n   
    )

 
 
 
 
 
 
 
 
 
 

{
    m_pchGptr += n;
}

inline char *streambuf::gptr(
    )

 
 
 
 
 
 
 
 
 
 
 
 

{
    return m_pchGptr;
}

inline char *streambuf::pbase(
    )

 
 
 
 
 
 
 
 
 
 
 

{
    return m_pchPbase;
}

inline void streambuf::__pbump(
    int n   
    )

 
 
 
 
 
 
 
 
 
 

{
    m_pchPptr += n;
}

inline char *streambuf::pptr(
    )

 
 
 
 
 
 
 
 
 
 

{
    return m_pchPptr;
}

inline int streambuf::unbuffered(
    )

 
 
 
 
 
 
 
 
 
 
 
 
 

{
    return m_bIsOkToAllocate;
}








































inline int streambuf::__in_avail(
    )

 
 
 
 
 
 
 
 
 
 
 

{
    return m_pchGptr < m_pchEgptr ? m_pchEgptr - m_pchGptr : 0;
}

inline int streambuf::__out_waiting(
    )

 
 
 
 
 
 
 
 
 
 

{
    return (m_pchPbase && m_pchPptr) ? m_pchPptr - m_pchPbase : 0;
}

inline int streambuf::__sbumpc(
    )

 
 
 
 
 
 
 
 
 
 
 

{
    if (m_pchGptr >= m_pchEgptr)
        if (underflow() == (-1))
	    return (-1);
    return ((*m_pchGptr++)&0377);
}

inline int streambuf::__sgetc(
    )

 
 
 
 
 
 
 
 
 
 
 

{
    if (m_pchGptr >= m_pchEgptr)
        if (underflow() == (-1))
	    return (-1);
    return ((*m_pchGptr)&0377);
}

inline int streambuf::__snextc(
    )

 
 
 
 
 
 
 
 
 
 
 
 

{
    if (++m_pchGptr >= m_pchEgptr)
        return snextcUnderflow();
    else
        return ((*m_pchGptr)&0377);
}

inline char *streambuf::__GetDataMaxPtr(
    )

 
 
 
 
 
 
 
 
 

{



    return m_pchBase + m_cchDataMax;

}




















inline void streambuf::__SetDataMaxPtr(
    char *b	 
    )

 
 
 
 
 
 
 
 
 

{



    m_cchDataMax = b - m_pchBase;

}





















inline int istream::gcount(
    )

 
 
 
 
 
 
 
 
 
 
 

{
    return m_cchGet;
}

inline istream &istream::get(
    unsigned char &c   
    )

 
 
 
 
 
 
 
 
 
 

{
    return get((char &)c);
}

inline istream &istream::read(
    unsigned char *s,   
    int           n     
    )

 
 
 
 
 
 
 
 
 
 

{
    return read((char *) s, n);
}

inline istream &istream::operator>>(
    istream &(*f)(istream &)   
    )

 
 
 
 
 
 
 
 
 
 

{
    return (*f)(*this);
}

inline ostream &ostream::write(
    const unsigned char *ptr,   
    int                 n       
    )

 
 
 
 
 
 
 
 
 
 

{
    return write((const char *)ptr, n);
}

inline ostream &ostream::operator<<(
    short i   
    )

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

{
    return *this << (long)i;
}

inline ostream &ostream::operator<<(
    unsigned char c   
    )

 
 
 
 
 
 
 
 
 
 

{
    return *this << (char)c;
}

inline ostream &ostream::operator<<(
    unsigned short i   
    )

 
 
 
 
 
 
 
 
 
 

{
    return *this << (unsigned long)i;
}

inline ostream &ostream::operator<<(
    ostream &(*f)(ostream &)   
    )

 
 
 
 
 
 
 
 
 
 
 
 
 

{
    return (*f)(*this);
}

inline ostream &ostream::operator<<(
    long double d   
    )

 
 
 
 

 
 
 
 
 

{
    return *this << (double)d;
}


#   pragma __environment restore










 







 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



 
 
 
 
 
 
 
 
 
 
class BString {
  public:
     
    BString();
    BString(const char *);
    BString(const BString &);
  
     
    ~BString();

     
    const BString &operator=(const BString &);
    const BString &operator=(int);

     
    operator const char *() const;

     
    friend ostream &operator<<(ostream &, const BString &);
    friend istream &operator>>(istream &, BString &);

     
    friend int operator==(const BString &, const BString &);
    friend int operator!=(const BString &, const BString &);
    friend int operator<(const BString &, const BString &);
    friend int operator>(const BString &, const BString &);
    friend int operator<=(const BString &, const BString &);
    friend int operator>=(const BString &, const BString &);

    friend int operator==(const BString &, const char *);
    friend int operator!=(const BString &, const char *);
    friend int operator<(const BString &, const char *);
    friend int operator>(const BString &, const char *);
    friend int operator<=(const BString &, const char *);
    friend int operator>=(const BString &, const char *);
    
    friend int operator==(const char *, const BString &);
    friend int operator!=(const char *, const BString &);
    friend int operator<(const char *, const BString &);
    friend int operator>(const char *, const BString &);
    friend int operator<=(const char *, const BString &);
    friend int operator>=(const char *, const BString &);
    

     
    friend BString operator+(const BString &,const BString &);
    friend BString operator+(const BString &, const char *);
    friend BString operator+(const char *, const BString &);
    friend BString operator+(const BString &, const char);
    friend BString operator+(const char, const BString &);


     
    BString &operator+=(const BString &);
    BString &operator+=(const char *);
    BString &operator+=(const char);


     
    unsigned int length() const;

    int BString::index(const BString &) const;
    int BString::index(const char *) const;

    BString substr(int start, int end) const;

    const BString &BString::remove(int start, int end);
    
    const BString &BString::insert(int start, const BString &repl);
    const BString &BString::insert(int start, const char *);

    const BString &BString::replace(int start, int end, const BString &repl);
    const BString &BString::replace(int start, int end, const char *);

   protected:
     
    BString(int);

    char *str;
    int len;
};


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline unsigned int BString::length() const
{ return len;
}



 
 
 
 
 
class Distance_Node
{
  public:
   
  Distance_Node();
  Distance_Node(long X, long Y, const BString &netname);
  Distance_Node(const Distance_Node &dNode);
  ~Distance_Node();
  
  const Distance_Node &operator=(const Distance_Node &dNode);

  BString GetNetName() const;
  long Ret_X() const;
  long Ret_Y() const;

  private:
    long x;
    long y;
    BString NetName;
};

















 
 
 
 
 
 
 
 
 
 
 


 
 
 
 
 



 















 








typedef void* Pix;



typedef void (*ErrorHandlerType) (const int, const char*);

void defLibErrorHandler(const int number, const char* msg);





template<class T>
struct SLListNode
{
  SLListNode<T>*         tl;
  T                      hd;
                         SLListNode() { }
                         SLListNode(const T& h, SLListNode<T>* t = 0);
                         ~SLListNode() { }
};

template<class T>
inline SLListNode<T>::SLListNode(const T& h, SLListNode<T>* t)
:hd(h), tl(t) {}




template<class T>
class SLList
{
protected:
  static ErrorHandlerType libErrorHandler;

  SLListNode<T>*        last;

public:
			enum { NULL_PIX, INVARIANT_FAILURE, EMPTY_LIST,
				DEL_AFTER_LAST };
  static T		SLLIST_ERROR;

                        SLList();
                        SLList(const SLList<T>& a);
                        ~SLList();

  SLList<T>&            operator = (const SLList<T>& a);

  int                   empty() const;
  int                   length() const;

  void                  clear();

  Pix                   prepend(const T& item);
  Pix                   append(const T& item);

  void                  join(SLList<T>&);

  Pix                   prepend(SLListNode<T>*);
  Pix                   append(SLListNode<T>*);

  T&                    operator () (Pix p) const;
  Pix                   first() const;
  void                  next(Pix& p) const;
  int                   owns(Pix p) const;
  Pix                   ins_after(Pix p, const T& item);
  void                  del_after(Pix p);

  T&                    front() const;
  T&                    rear() const;
  T                     remove_front();
  int                   remove_front(T& x);
  void                  del_front();

  ErrorHandlerType      setErrorHandler(ErrorHandlerType f);
  void                  error(const int errorNum, const char* msg) const;
  int                   OK();
};

template<class T>
inline SLList<T>::~SLList()
{
  clear();
}

template<class T>
inline SLList<T>::SLList()
{
  last = 0;
  if (!libErrorHandler) {
    libErrorHandler = &defLibErrorHandler;
  }
}

template<class T>
inline int SLList<T>::empty() const
{
  return last == 0;
  if (!libErrorHandler) {
    libErrorHandler = &defLibErrorHandler;
  }
}


template<class T>
inline Pix SLList<T>::first() const
{
  return (last == 0)? 0 : Pix(last->tl);
}

template<class T>
inline void SLList<T>::next(Pix& p) const
{
  p = (p == 0 || p == last)? 0 : Pix(((SLListNode<T>*)(p))->tl);
}

template<class T>
inline T& SLList<T>::operator () (Pix p) const
{
  if (p == 0) {
    error(NULL_PIX, "SLList: null Pix");
    return SLLIST_ERROR;
  }
  return ((SLListNode<T>*)(p))->hd;
}

template<class T>
inline T& SLList<T>::front() const
{
  if (last == 0) {
    error(EMPTY_LIST, "SLList: empty list");
    return SLLIST_ERROR;
  }
  return last->tl->hd;
}

template<class T>
inline T& SLList<T>::rear() const
{
  if (last == 0) {
    error(EMPTY_LIST, "SLList: empty list");
    return SLLIST_ERROR;
  }
  return last->hd;
}




 















 




template<class T>
T SLList<T>::SLLIST_ERROR;

template<class T>
ErrorHandlerType SLList<T>::libErrorHandler;

template<class T>
ErrorHandlerType SLList<T>::setErrorHandler(ErrorHandlerType f)
{
  ErrorHandlerType old = libErrorHandler;
  libErrorHandler = f;
  return old;
}

template<class T>
void SLList<T>::error(const int errorNum, const char* msg) const
{
  (*libErrorHandler)(errorNum, msg);
}

template<class T>
int SLList<T>::length() const
{
  int l = 0;
  SLListNode<T>* t = last;
  if (t != 0) do { ++l; t = t->tl; } while (t != last);
  return l;
}

template<class T>
SLList<T>::SLList(const SLList<T>& a)
{
  if (a.last == 0)
    last = 0;
  else
  {
    SLListNode<T>* p = a.last->tl;
    SLListNode<T>* h = new SLListNode<T>(p->hd);
    last = h;
    for (;;)
    {
      if (p == a.last)
      {
        last->tl = h;
        return;
      }
      p = p->tl;
      SLListNode<T>* n = new SLListNode<T>(p->hd);
      last->tl = n;
      last = n;
    }
  }
}

template<class T>
SLList<T>& SLList<T>::operator = (const SLList<T>& a)
{
  if (last != a.last)
  {
    clear();
    if (a.last != 0)
    {
      SLListNode<T>* p = a.last->tl;
      SLListNode<T>* h = new SLListNode<T>(p->hd);
      last = h;
      for (;;)
      {
        if (p == a.last)
        {
          last->tl = h;
          break;
        }
        p = p->tl;
        SLListNode<T>* n = new SLListNode<T>(p->hd);
        last->tl = n;
        last = n;
      }
    }
  }
  return *this;
}

template<class T>
void SLList<T>::clear()
{
  if (last == 0)
    return;

  SLListNode<T>* p = last->tl;
  last->tl = 0;
  last = 0;

  while (p != 0)
  {
    SLListNode<T>* nxt = p->tl;
    delete(p);
    p = nxt;
  }
}


template<class T>
Pix SLList<T>::prepend(const T& item)
{
  SLListNode<T>* t = new SLListNode<T>(item);
  if (last == 0)
    t->tl = last = t;
  else
  {
    t->tl = last->tl;
    last->tl = t;
  }
  return Pix(t);
}


template<class T>
Pix SLList<T>::prepend(SLListNode<T>* t)
{
  if (t == 0) return 0;
  if (last == 0)
    t->tl = last = t;
  else
  {
    t->tl = last->tl;
    last->tl = t;
  }
  return Pix(t);
}


template<class T>
Pix SLList<T>::append(const T& item)
{
  SLListNode<T>* t = new SLListNode<T>(item);
  if (last == 0)
    t->tl = last = t;
  else
  {
    t->tl = last->tl;
    last->tl = t;
    last = t;
  }
  return Pix(t);
}

template<class T>
Pix SLList<T>::append(SLListNode<T>* t)
{
  if (t == 0) return 0;
  if (last == 0)
    t->tl = last = t;
  else
  {
    t->tl = last->tl;
    last->tl = t;
    last = t;
  }
  return Pix(t);
}

template<class T>
void SLList<T>::join(SLList<T>& b)
{
  SLListNode<T>* t = b.last;
  b.last = 0;
  if (last == 0)
    last = t;
  else if (t != 0)
  {
    SLListNode<T>* f = last->tl;
    last->tl = t->tl;
    t->tl = f;
    last = t;
  }
}

template<class T>
Pix SLList<T>::ins_after(Pix p, const T& item)
{
  SLListNode<T>* u = (SLListNode<T>*)p;
  SLListNode<T>* t = new SLListNode<T>(item);
  if (last == 0)
    t->tl = last = t;
  else if (u == 0)  
  {
    t->tl = last->tl;
    last->tl = t;
  }
  else
  {
    t->tl = u->tl;
    u->tl = t;
    if (u == last) 
      last = t;
  }
  return Pix(t);
}


template<class T>
void SLList<T>::del_after(Pix p)
{
  SLListNode<T>* u = (SLListNode<T>*)p;
  if (last == 0 || u == last) {
    error(DEL_AFTER_LAST, "SLList: cannot del_after last");
    return;
  }
  if (u == 0) u = last;  
  SLListNode<T>* t = u->tl;
  if (u == t)
    last = 0;
  else
  {
    u->tl = t->tl;
    if (last == t)
      last = u;
  }
  delete t;
}

template<class T>
int SLList<T>::owns(Pix p) const
{
  SLListNode<T>* t = last;
  if (t != 0 && p != 0)
  {
    do
    {
      if (Pix(t) == p) return 1;
      t = t->tl;
    } while (t != last);
  }
  return 0;
}

template<class T>
T SLList<T>::remove_front()
{
  if (last == 0) {
    error(EMPTY_LIST, "SLList: empty list");
    return SLLIST_ERROR;
  }
  SLListNode<T>* t = last->tl;
  T res = t->hd;
  if (t == last)
    last = 0;
  else
    last->tl = t->tl;
  delete t;
  return res;
}

template<class T>
int SLList<T>::remove_front(T& x)
{
  if (last == 0)
    return 0;
  else
  {
    SLListNode<T>* t = last->tl;
    x = t->hd;
    if (t == last)
      last = 0;
    else
      last->tl = t->tl;
    delete t;
    return 1;
  }
}


template<class T>
void SLList<T>::del_front()
{
  if (last == 0) {
    error(EMPTY_LIST, "empty list");
    return;
  }
  SLListNode<T>* t = last->tl;
  if (t == last)
    last = 0;
  else
    last->tl = t->tl;
  delete t;
}

template<class T>
int SLList<T>::OK()
{
  int v = 1;
  if (last != 0)
  {
    SLListNode<T>* t = last;
    unsigned long count = ~0L;       

    do
    {
      count--;
      t = t->tl;
    } while (count > 0 && t != last);
    v &= count > 0;
  }
  if (!v) error(INVARIANT_FAILURE, "SLList: invariant failure");
  return v;
}







 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
 
 
 
 
















 






 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 
 
 




extern "C"
{



















}


#   pragma __environment save
#   pragma __environment header_defaults








 
 
 










class filebuf : public streambuf

 
 
 
 
 
 
 

{
 




public:
    static const int openprot;  

 




			filebuf();
			filebuf(int fd);
			filebuf(int fd, char *p, int len);
			~filebuf();

    filebuf		*attach(int fd);
    filebuf		*close();
    int			fd();



    int			is_open();

    filebuf		*open(const char *name, int mode, int prot = openprot);
    virtual int		overflow(int = (-1));
    virtual streampos	seekoff(streamoff, ios::seek_dir, int mode);
    virtual streampos	seekpos(streampos, int mode);
    virtual streambuf	*setbuf(char *p, int len);
    virtual int		sync();
    virtual int		underflow();
    filebuf		*__attach(int fd);
    filebuf		*__close();
    inline int		__fd();
    inline int		__is_open();
    filebuf		*__open(const char *name, int mode, int prot=openprot);


 








private:
    int			m_fd;
    int			m_cchDeltaFp;
    char                m_bFileIsOpen;
    char                m_bFilebufOwnsFd;
    char                m_bNeedsSync;
    char                __fill1;
    int			__fill2;
    long                m_fpBuffer;
    long		__fill3;
    long                m_lcchFile;













};


 
 
 
 
 

class fstreambase : virtual public ios {
public:
			fstreambase();
			fstreambase(int);
			fstreambase(int, char *, int);
			fstreambase(const char *, int, int);
			~fstreambase();
    void		attach(int);
    void		close() ;
    void		open(const char *, int, int);
    void		setbuf(char *, int) ;
private:
    filebuf		m_filebuf;
};



class ifstream : public fstreambase, public istream




 
 
 
 
 
 
 

{
public:
			ifstream();
			ifstream(const char *name, int mode = ios::in,
				int prot = filebuf::openprot);
			ifstream(int fd);
			ifstream(int fd, char *p, int len);
			~ifstream();

    void		attach(int fd);
    void		close();
    void		open(const char *name, int mode = ios::in, 
				int prot = filebuf::openprot);
    filebuf		*rdbuf();
    void		setbuf(char *p, int len);
};


class ofstream : public fstreambase, public ostream



 
 
 
 
 
 
 

{
public:
			ofstream();
			ofstream(const char *name, int mode = ios::out,
				int prot = filebuf::openprot);
			ofstream(int fd);
			ofstream(int fd, char *p, int len);
			~ofstream();

    void		attach(int fd);
    void		close();
    void		open(const char *name, int mode = ios::out, 
				int prot = filebuf::openprot);
    filebuf		*rdbuf();
    void		setbuf(char *p, int len);
};


class fstream : public fstreambase, public iostream




 
 
 
 
 
 
 

{
public:
			fstream();
			fstream(const char *name, int mode,
				int prot = filebuf::openprot);
			fstream(int fd);
			fstream(int fd, char *p, int len);
			~fstream();

    void		attach(int fd);
    void		close();
    void		open(const char *name, int mode,
				int prot = filebuf::openprot) ;
    filebuf		*rdbuf();
    void		setbuf(char *p, int len);
};

 
 
 

inline int filebuf::__fd(
    )

 
 
 
 
 
 

{
    if (__is_open())



        return m_fd;

    else
	return (-1);
}

















inline int filebuf::__is_open(
    )

 
 
 
 
 
 

{



    return m_bFileIsOpen;

}


#   pragma __environment restore









 




 
 
 
 
 
class AttachNode
{
  public:
     AttachNode(const BString &netString, const BString &instString,
                const BString &pinString);
     AttachNode(const BString &netString, const BString &instString);
     AttachNode(const BString &netString);            
     AttachNode();                            
     AttachNode(const AttachNode& S);   
     ~AttachNode();              
  
     const AttachNode &operator=(const AttachNode &);

     void SetNetName(BString netString);
     BString GetNetName() const;
     void SetInstName(BString instString);
     BString GetInstName() const;
     void SetPinName(BString pinString);
     BString GetPinName() const;
     void PrintNode(ofstream &os);

  protected:
     BString netName;
     BString instName;
     BString pinName;
};


class ReAttachNode: public AttachNode
{
  public:
    ReAttachNode(const BString &netString, const BString &instString,
                 const BString &pinString);
    ReAttachNode(const BString &netString, const BString &instString);
    ReAttachNode(const BString &netString);            
    ReAttachNode();                            
    ReAttachNode(const ReAttachNode& S);   
    ~ReAttachNode();              

    const ReAttachNode &operator=(const ReAttachNode &);
};


class AddNode: public AttachNode
{
  public:
    AddNode(const BString &netString, const BString &instString,
            const BString &pinString);
    AddNode(const BString &netString, const BString &instString);
    AddNode(const BString &netString);            
    AddNode();                            
    AddNode(const AddNode& S);   
    ~AddNode();              
  
    const AddNode &operator=(const AddNode &);
};















 

 










 



 
struct hash2_structure {
  int hash_node_key;
  int hash_node_value;
  struct hash2_structure *hash_node_next;
};

 
struct hash_structure {
  int hash_size;
  int hash_dupflg;
  int *hash_table_base;
};

 
struct tree_structure {
  struct tree_structure *tree_left;
  struct tree_structure *tree_right;
  short       tree_balance;
  short       tree_extra;
  void        *tree_key;
  void        *tree_data;
};

 
struct list_structure {
  struct list_structure *list_next;
  void        *list_data;
};

 
struct dlist_structure {
  struct dlist_structure *dlist_prev;
  struct dlist_structure *dlist_next;
  void         *dlist_data;
};

 
struct queue_structure {
  struct queue_structure *queue_prev;
  struct queue_structure *queue_next;
  void         *queue_data;
};

 
struct ring_structure {
  struct ring_structure *ring_prev;
  struct ring_structure *ring_next;
  void *ring_data;
};

 



 




 







 




 




 







 


extern "C" {


int mms_list_free(
	struct list_structure *ptr);
struct list_structure *mms_list_append(
	struct list_structure **first,
	struct list_structure **last,
	void *item);
struct list_structure *mms_list_insert_head(
	struct list_structure **first,
	struct list_structure **last,
	void *item);
struct list_structure *mms_list_insert_after(
	struct list_structure **first,
	struct list_structure **last,
	struct list_structure *ptr,
	void *item);
int mms_list_remove(
	struct list_structure **first,
	struct list_structure **last,
	struct list_structure **item,
	int (*fcn)());
struct list_structure *mms_list_find(
	struct list_structure *first,
	void *key,
	int (*compare)());
int mms_list_traverse(
	struct list_structure *first,
	int (*fcn)());
int mms_list_replace(
	struct list_structure *node,
	void *data,
	int (*fcn)());
int mms_dlist_free(
	struct dlist_structure *ptr);
struct dlist_structure *mms_dlist_append(
	struct dlist_structure **first,
	struct dlist_structure **last,
	void *item);
struct dlist_structure *mms_dlist_insert_head(
	struct dlist_structure **first,
	struct dlist_structure **last,
	void *item);
struct dlist_structure *mms_dlist_insert_after(
	struct dlist_structure **first,
	struct dlist_structure **last,
	struct dlist_structure *ptr,
	void *item);
int mms_dlist_remove(
	struct dlist_structure **first,
	struct dlist_structure **last,
	struct dlist_structure **item,
	int (*fcn)());
struct dlist_structure *mms_dlist_find(
	struct dlist_structure *first,
	void *key,
	int (*compare)());
int mms_dlist_traverse(
	struct dlist_structure *first,
	int (*fcn)());
int mms_dlist_backverse(
	struct dlist_structure *last,
	int (*fcn)());
int mms_dlist_replace(
	struct dlist_structure *node,
	void *data,
	int (*fcn)());
int mms_tree_free(
	struct tree_structure *ptr);
struct tree_structure *mms_tree_insert(
	int *inskey,
	struct tree_structure **tree,
	void *key,
	void *data,
	int   (*comp_fcn)(void *, struct tree_structure *),
	void *(*key_fcn)(void *, struct tree_structure *));
int mms_tree_default_compare(
	void  *k,
	struct tree_structure *t);
void *mms_tree_default_key(
	void  *k,
	struct tree_structure *t);
int mms_tree_idefault_compare(
	void *k,
	struct tree_structure *t);
void *mms_tree_idefault_key(
	void *k,
	struct tree_structure *t);
void *mms_i_tree_alloc(
	int key,
	void **ptr);
int mms_tree_traverse(
	struct tree_structure **tree,
	int (*fcn)());
int mms_tree_traverse2(
	struct tree_structure **tree,
	int (*fcn)());
int mms_tree_remove(
	struct tree_structure **tree,
	int   (*fcn1)(void *,struct tree_structure *),
	void *(*fcn2)(void *,struct tree_structure *));
int mms_tree_remove1(
	struct tree_structure *tptr);
int mms_tree_remove_node(
	struct tree_structure **tree,
	struct tree_structure *node,
	int   (*fcn1)(void *, struct tree_structure *),
	void *(*fcn2)(void *, struct tree_structure *));
int mms_internal_traverse(
	struct tree_structure *tree);
int mms_internal_traverse2(
	struct tree_structure *tree);
int mms_tree_breadth_traverse(
	struct tree_structure **tree,
	int (*fcn)());
struct tree_structure *mms_tree_find(
	struct tree_structure **tree,
	void *key,
	int (*comp_fcn)(void *, struct tree_structure *));
int mms_tree_replace(
	struct tree_structure **tptr,
	void *newdata,
	int (*fcn)());
int mms_tree_delete(
	struct tree_structure **root,
	char *key,
	int   (*comp_fcn)(void *,struct tree_structure *),
	void *(*key_fcn)(void *,struct tree_structure *),
	void *(*free_fcn)());
int mms_queue_free(
	struct queue_structure *ptr);
struct queue_structure *mms_queue_insert_front(
	struct queue_structure **head,
	struct queue_structure **rear,
	void *data);
struct queue_structure *mms_queue_insert_rear(
	struct queue_structure **head,
	struct queue_structure **rear,
	void *data);
struct queue_structure *mms_queue_remove_front(
	struct queue_structure **head,
	struct queue_structure **rear,
	void **data);
struct queue_structure *mms_queue_remove_rear(
	struct queue_structure **head,
	struct queue_structure **rear,
	void **data);
int mms_binsrc(
	char *array[],
	int size,
	char *key,
	int (*fcn)());
int mms_strcmp(
	char *str1,
	char *str2);
void *xmms_tree_find(
	struct tree_structure *ptr,
	void *key,
	int (*comp_fcn)());
int xmms_tree_insert(
	struct tree_structure **root,
	int *key,
	int *ins_flag,
	int   (*comp_fcn)(),
	void *(*alloc_fcn)(),
	struct tree_structure **rptr,
	void *data);
int xmms_tree_delete1(
	struct tree_structure **root,
	char *key,
	int *h,
	int   (*comp_fcn)(void *,struct tree_structure *),
	void *(*key_fcn)(void *,struct tree_structure *),
	void *(*free_fcn)());
int xmms_tree_del(
	struct tree_structure **root,
	struct tree_structure **root_r,
	int *h,
	int   (*comp_fcn)(void *,struct tree_structure *),
	void *(*key_fcn)(void *,struct tree_structure *),
	void *(*free_fcn)());
int xmms_tree_balance1(
	struct tree_structure **root,
	int *h);
int xmms_tree_balance2(
	struct tree_structure **root,
	int *h);


}







 



 







 




















 





 




 




 









 







 




 




 
 
 



 





 























 





















struct def_component_info_structure;
struct def_snet_design_rule_structure; 
struct def_group_specification_structure;  
struct def_layer_info_structure;  
struct def_net_info_structure;    
struct def_coordinate_structure;      
struct def_const_operand_info_structure;
struct def_comp_placement_info_structure; 
struct def_comp_foreign_info_structure;
struct def_coordinate_pair_structure;      
struct def_soft_group_parm_structure;    
struct def_via_info_structure;   
struct def_wire_segment_structure;      
struct def_constraint_info_structure;
struct def_pin_info_structure;    
struct def_data_section_structure;        
struct def_database_info_structure;     




 
struct def_coordinate_structure
{ 
  int def_one_pt[2];      
};

struct def_coordinate_pair_structure
{ 
  int def_two_pt1[2];     
  int def_two_pt2[2];     
};





 
struct def_component_info_structure
{ 
  char        *def_comp_name;             
  char        *def_comp_model_name;       
  char        *def_comp_generic_b_name;   
  char        *def_comp_task_parm;        
  int         def_comp_source;           
  int         def_comp_weight;       
  struct def_comp_placement_info_structure *def_comp_placed;       
  struct def_coordinate_pair_structure  *def_comp_region;           
  struct list_structure *def_comp_nets_h;           
  struct list_structure *def_comp_nets_t;           
  struct list_structure *def_comp_foreign_h;   
  struct list_structure *def_comp_foreign_t;   

  

 

  struct list_structure *def_comp_net_ptrs_h;       
  struct list_structure *def_comp_net_ptrs_t;       
  struct list_structure *def_comp_const_h;          
  struct list_structure *def_comp_const_t;          
  struct def_group_specification_structure *def_comp_group_ptr;     
  struct def_component_info_structure *def_comp_comp_ptr_f;     
  struct def_component_info_structure *def_comp_comp_ptr_b;     
  struct def_data_section_structure *def_comp_sect_ptr;            
};

struct def_comp_placement_info_structure
{ 
  int        def_place_class;      
  int        def_place_ori;        
  struct def_coordinate_structure *def_place_coord;     
  struct def_component_info_structure *def_place_comp_ptr;   
};

struct def_comp_foreign_info_structure
{ 
  char       *def_foreign_cellname;      
  int         def_foreign_ori;        
  struct def_coordinate_structure *def_foreign_coord;     
  struct def_component_info_structure *def_foreign_comp_ptr;  
};






 
struct def_group_specification_structure
{ 
  char         *def_grp_name;         
  struct def_coordinate_pair_structure   *def_grp_region;       
  struct def_soft_group_parm_structure *def_grp_soft;         
  struct list_structure  *def_grp_comps_name_h;  
  struct list_structure  *def_grp_comps_name_t;      

  

 

  struct list_structure  *def_grp_comps_h;       
  struct list_structure  *def_grp_comps_t;      
  struct def_data_section_structure     *def_grp_sect_ptr;      
  struct def_group_specification_structure *def_grp_grp_ptr_f;   
  struct def_group_specification_structure *def_grp_grp_ptr_b;   
};

struct def_soft_group_parm_structure
{ 
  int def_soft_maxhalfperimeter;     
  int def_soft_maxx;                 
  int def_soft_maxy;                 
  struct def_group_specification_structure *def_soft_grp_ptr;  
};







 
struct def_net_info_structure
{ 
  char         *def_net_name;           
  char         *def_net_original;       
  int           def_net_source;         
  int           def_net_use;           
 
  int           def_net_pattern;       
 
  int           def_snet_style;         
 
  int           def_net_estcap;         
  int           def_net_weight;         
  struct list_structure  *def_net_pins_h;         
  struct list_structure  *def_net_pins_t;         
  struct dlist_structure *def_net_wiring_h;       
  struct dlist_structure *def_net_wiring_t;       

   

  int           def_snet_voltage;       
  struct list_structure  *def_snet_width_h;       
  struct list_structure  *def_snet_width_t;       
  struct list_structure  *def_snet_layer_h;       
  struct list_structure  *def_snet_layer_t;       
  struct list_structure  *def_snet_spacing_h;     
  struct list_structure  *def_snet_spacing_t;     

  

 

  struct list_structure *def_net_const_h;          
  struct list_structure *def_net_const_t;          
  struct def_net_info_structure *def_net_net_ptr_f;       
  struct def_net_info_structure *def_net_net_ptr_b;       
  struct def_data_section_structure     *def_net_sect_ptr;        
};

struct def_wire_segment_structure
{ 
  int             def_wire_class;      
  char           *def_wire_via;        
  char           *def_wire_layer_name;  
  struct def_coordinate_structure     *def_wire_point;    
  int            def_swire_width;     

 
  struct def_net_info_structure *def_wire_net_ptr;      
};

struct def_snet_design_rule_structure
{  
  char *def_dsn_layer;                  
  int   def_dsn_value;                  
  struct def_net_info_structure *def_dsn_net_ptr;        
};





 
struct def_via_info_structure
{ 
  char        *def_via_name;        
  


 
  int def_via_created_by_defmod;   
  struct list_structure *def_via_lyrptr_h;   
  struct list_structure *def_via_lyrptr_t;   
  struct list_structure *def_via_rect_h;      
  struct list_structure *def_via_rect_t;      
  struct def_data_section_structure *def_via_sect_ptr;       
  struct def_via_info_structure *def_via_via_ptr_f;    
  struct def_via_info_structure *def_via_via_ptr_b;    

};






 
struct def_layer_info_structure 
{ 
  char *def_lyr_name;                 
  int  *def_lyr_type;                 
  struct list_structure *def_lyr_syn_names_h;   
  struct list_structure *def_lyr_syn_names_t;   
};






 
struct def_constraint_info_structure
{
  int  def_const_min_rise_time;         
  int  def_const_max_rise_time;         
  int  def_const_min_fall_time;         
  int  def_const_max_fall_time;         
  int  def_const_wiredlogic;            
  char *def_const_wire_net_name;        
  int  def_const_distance;              
  struct def_const_operand_info_structure *def_const_operand;  
  struct def_data_section_structure *def_const_sect_ptr;         
};

struct def_const_operand_info_structure
{
  int           def_oprnd_type;           

  char         *def_oprnd_net_name;       

  struct def_pin_info_structure *def_oprnd_pin1;            
  struct def_pin_info_structure *def_oprnd_pin2;            

  struct list_structure  *def_oprnd_sum_h;       
  struct list_structure  *def_oprnd_sum_t;       

  struct def_const_operand_info_structure *def_oprnd_diff_op1;   
  struct def_const_operand_info_structure *def_oprnd_diff_op2;   
  struct def_constraint_info_structure *def_oprnd_const_ptr;  
};

  



 
struct def_pin_info_structure
{ char *def_pin_name;               
  char *def_pin_comp_name;          
  char *def_pin_net_name;           
  struct def_component_info_structure *def_pin_comp_ptr;  
  struct def_net_info_structure *def_pin_net_ptr;    
};

struct def_data_section_structure
{ 
  int def_sect_type;       
  int def_sect_data_count;      
  int def_sect_real_count;      
  struct list_structure *def_sect_list_h;     
  struct list_structure *def_sect_list_t;
  struct def_database_info_structure *def_sect_db_ptr;   
};

struct def_database_info_structure
{ 
  char        *def_file_name;              
  char        *def_design_name;            
  char        *def_design_array;           
  char        *def_design_technology;      
  char        *def_design_floorplan;       
  int          def_design_convert_factor;  
  int          def_pin_total;              
  struct list_structure *def_design_history_h;       
  struct list_structure *def_design_history_t;       
  struct list_structure *def_pin_h;                  
  struct list_structure *def_pin_t;                  
  struct list_structure *def_sections_h;     
  struct list_structure *def_sections_t;
  struct tree_structure *def_layers_root;    
  struct tree_structure *def_comp_root;      
  struct tree_structure *def_net_root;       
  struct tree_structure *def_snet_root;      
  struct tree_structure *def_via_root;       
  struct tree_structure *def_grp_root;     
  
};






 
 
 
 
 
class ClockIter;
class Clock;
class ClockInfo;
class CreateClock;
class FormClock;
 
 
 
 
 
class ClockIter
{ 
  public:
     
    ClockIter();
    ClockIter(const ClockIter &cIter);
    const ClockIter &operator=(const ClockIter &cIter);
    ~ClockIter();

    ClockIter(SLList<Clock *> &clockList);
  
    int IsUpperLevel();
    int IsLowerLevel();
    SLList <Clock *> GoDown();
    SLList <Clock *> GoUp(BString &clockname);
    Clock *GetNextClock();
    Clock *Reset();

  private:
    SLList <Clock *> clockList;
    int current_level;  
    Pix node;
};


 
 
 
 
 
class Clock 
{
  public:
     
    Clock();
    Clock(struct def_database_info_structure *, const BString &netName, const BString &driverName, 
          const BString &recievername, int level, 
          const SLList <BString> &modelname, Clock *parent);
    Clock(Clock *tmpclk);
    Clock(const Clock &S);
    ~Clock();
    const Clock &operator=(const Clock &C);

     
    void SetNetName(const BString &);
    BString GetNetName() const;
    Clock *GetParent() const; 
    BString GetModelName() const; 

    SLList<Clock *> RetSubClkPtrs() const;   
    int Getlevel() const;
    

    int Show_ClockFanout(int hiLevel);
    int Show_ClockLoads(int hiLevel);
    int Show_ClockArea();

    void Modify_Clock(SLList<AddNode *>, SLList<ReAttachNode *>, 
                      struct def_database_info_structure *&);

    virtual ClockIter *GetSubClocks(Clock *parnt, 
                                    const SLList<BString> &modelnames);
    virtual int Inst_Is_Net(struct def_component_info_structure *comp);     
    void SetLoadPtrs(SLList<struct def_component_info_structure *>loads);
 
  protected:
    int Attach_Inst_Clk(SLList<Clock *>, AttachNode *, struct def_component_info_structure *);
    void Attach_Inst_SubClkNet(struct def_component_info_structure *, AttachNode *, struct def_database_info_structure *&,
			       struct def_pin_info_structure *pinPtr);
    void Remove_Inst_ClkNet(struct def_component_info_structure *, struct def_database_info_structure *&, AttachNode *,
                            struct def_pin_info_structure *pinPtr);
    void Add_Load(struct def_component_info_structure *);

    SLList<struct def_component_info_structure *> GetLoads();
    BString GetDriverName() const;
    BString GetRecieverName() const;
    SLList<struct def_component_info_structure *> RetLoadPtrs() const;
    int GetloadCntr() const;

   
    void Get_Inst(struct def_component_info_structure *&comp, struct list_structure *lptr,struct def_pin_info_structure *&pin);
    int Get_Net(struct list_structure *&lptr, struct def_net_info_structure *&net);  
    struct def_net_info_structure *FindNet(struct def_database_info_structure *dbptr, const BString &netName);
    struct def_net_info_structure *FindNet(struct def_data_section_structure *netptr, const BString &netName);
    struct def_component_info_structure *FindComp(struct def_database_info_structure *dbptr, const BString &compName);
    struct def_component_info_structure *FindComp(struct def_data_section_structure *cmpptr, const BString &compName);

    BString driverName;
    BString recieverName;
    BString netName;
    Clock *Parent;
    SLList <struct def_component_info_structure *> loadPtrs;
    SLList <struct def_pin_info_structure *> pinPtrs;
    SLList <Clock *> SubClocks;
    struct def_database_info_structure *defdb;
    int level;
    int loadCntr;
    BString modelName;
};


 
 
 
 
 
class FormClock: public Clock
{
  public:
    FormClock(struct def_database_info_structure *, const BString &ClockName, ifstream &infile, 
              const BString &drivername);
    FormClock(struct def_database_info_structure *, const BString &ClockName, 
              const BString &drivername, const BString &, FormClock *parent, 
              const SLList<BString> &allLoads);
    FormClock(const FormClock &);
    ~FormClock();

    virtual ClockIter *GetSubClocks(FormClock *parnt);
    virtual int Inst_Is_Net(struct def_component_info_structure *comp);

    const FormClock &operator=(const FormClock &);

  private:
    int SetLevel();

    SLList<BString> AllLoads;
};

 
 
 
 
 
class ClockInfo
{
  public:
    ClockInfo(const BString &netName, const BString &driverName, 
              const BString &recieverName, int level, 
              const BString &modelname, const BString &par,
              const SLList<BString> &subclknames);
    ClockInfo(const ClockInfo &S);
    ~ClockInfo();
    
    const ClockInfo &operator=(const ClockInfo &);

    int GetLevel() const;
    BString GetNetName() const;
    BString GetDriverName() const;
    BString GetRecieverName() const;
    BString GetModelName() const;
    BString GetParentName() const;
    SLList<BString> GetSubClkNames() const;
    
  private:
    BString netName, driverName, modelName, parentName, recieverName;
    int level;
    SLList<BString> subclkNames;
};

 
 
 
 
 
class CreateClock: public Clock
{
  public:
    CreateClock(struct def_database_info_structure *&,const SLList<BString> &,const BString &, 
                int level, const BString &,const SLList <BString> &modelname,
                int clknums[], const BString &input_pin, 
                const BString &output_pin);
    CreateClock(struct def_database_info_structure *,const BString &netName,const BString &driverName,
                const BString &recname, int level, const BString &modelname, 
                CreateClock *parent, SLList<ClockInfo *> InfoList);
    CreateClock(const CreateClock &);
    ~CreateClock();
  
    const CreateClock &operator=(const CreateClock &);

  private:
    void CreateInfoList(const SLList<BString>&,const BString &,const BString &,
                       const SLList<BString> &modelnames, int clk_nums[]);

    BString mainclockName;
    SLList<ClockInfo *> InfoList;
};




























 
 
 
 
 






















 


 


  



 


 











                                                                    




extern "C" {










 





 













 

















typedef struct div_t  {			 
	int quot;			 
	int rem; } div_t;			 

typedef struct ldiv_t  {		 
	long int quot;			 
	long int rem; } ldiv_t;		 










 





extern int __getmbcurmax (void);



 
extern int	mblen (const char *, size_t);
extern size_t	mbstowcs (wchar_t *, const char *, size_t);
extern int	mbtowc (wchar_t *, const char *, size_t);
extern size_t	wcstombs (char *, const wchar_t *, size_t);
extern int	wctomb (char *, wchar_t);


extern int	rpmatch (const char *);

extern void 	*valloc (size_t );


extern double 	atof (const char *);
extern int 	atoi (const char *);
extern long int atol (const char *);
extern double 	strtod (const char *, char **);
extern long int strtol (const char *, char **, int );
extern unsigned long int strtoul (const char *, char **, int );
extern int 	rand (void);
extern void	srand (unsigned int );
extern void 	*calloc (size_t , size_t );
extern void	free (void *);
extern void	*malloc (size_t );
extern void 	*realloc (void *, size_t );






 









extern long	a64l (const char *);
extern char	* l64a (long);
extern int	ttyslot (void);






extern char	*ptsname (int);














extern void	abort (void);
extern int	atexit (void (*)(void));
extern void	exit (int );
extern char	*getenv (const char *);
extern int 	system (const char *);
extern void 	*bsearch (const void *, const void *, size_t , size_t , int(*)(const void *, const void *));
extern void 	qsort (void *, size_t , size_t ,int(*)(const void *, const void *));
extern int 	abs (int );
extern struct div_t	div (int , int );
extern long int	labs (long int );
extern struct ldiv_t 	ldiv (long int , long int );

















extern int	_Prand_r (unsigned int *);































extern double	drand48 (void);
extern double	erand48 (unsigned short []);
extern long	jrand48 (unsigned short []);
extern void	lcong48 (unsigned short []);
extern long	lrand48 (void);
extern long	mrand48 (void);
extern long	nrand48 (unsigned short []);
extern unsigned short *seed48 (unsigned short []);
extern void	srand48 (long);
extern int 	putenv (const char *);
extern void	setkey (const char *);























 


extern char	*initstate (unsigned int, char *, int);
extern char	*setstate (char *);
extern int	grantpt (int);
extern int	getsubopt (char **, char *const *, char **);




extern int	random (void);
extern int	srandom (unsigned int);

extern char 	*realpath (const char *, char *);
extern int	unlockpt (int);










 


extern int 	clearenv ();
extern char 	*getpass (const char *);




extern char 	*mktemp (char *);
extern int 	mkstemp (char *);








 



char	*ecvt (double, int, int *, int *);
char	*fcvt (double, int, int *, int *);
char	*gcvt (double, int, char *);







}








































 


 


  



 


 














 



extern "C" {





















 


extern int	isalpha (int);
extern int	isalnum (int);
extern int	iscntrl (int);
extern int	isdigit (int);
extern int	isgraph (int);
extern int	islower (int);
extern int	isprint (int);
extern int	ispunct (int);
extern int	isspace (int);
extern int	isupper (int);
extern int	isxdigit (int);
extern int	toupper (int);
extern int	tolower (int);





extern int	isascii (int);
extern int	toascii (int);

extern int	(_toupper) (int);
extern int	(_tolower) (int);































 


 


 



 


 











 



extern "C" {




 





 






 
typedef struct _LC_charmap_t 	_LC_charmap_t;
typedef struct _LC_monetary_t 	_LC_monetary_t;
typedef struct _LC_numeric_t	_LC_numeric_t;
typedef struct _LC_resp_t	_LC_resp_t;
typedef struct _LC_time_t	_LC_time_t;
typedef struct _LC_collate_t	_LC_collate_t;
typedef struct _LC_ctype_t	_LC_ctype_t;
typedef struct _LC_locale_t	_LC_locale_t;























 


 


 



 


 











 



extern "C" {


























 


 


  



 


 












 









struct lconv {
   char *decimal_point;		 
   char *thousands_sep;		 
   char *grouping;		 
   char *int_curr_symbol;	 
   char *currency_symbol;	 
   char *mon_decimal_point;	 
   char *mon_thousands_sep;	 
   char *mon_grouping;		 
   char *positive_sign;		 
   char *negative_sign;		 
   char int_frac_digits;	 
   char frac_digits;		 
   char p_cs_precedes;		 
   char p_sep_by_space;		 
   char n_cs_precedes;		 
   char n_sep_by_space;		 
   char p_sign_posn;		 
   char n_sign_posn;		 

   char *left_parenthesis;	 
   char *right_parenthesis;	 





};



















extern "C" {

struct lconv *localeconv (void);
char   *setlocale (int, const char *);

}





 
 























 


 


  



 


 












 




extern "C" {




typedef int __nl_item;


typedef struct __catalog_descriptor *nl_catd;



typedef __nl_item nl_item;




extern nl_catd catopen (const char *, int );
extern char  *catgets (nl_catd , int , int , const char *);
extern int catclose (nl_catd );



typedef struct __catalog_descriptor CATD;

extern nl_catd NLcatopen (char *, int);
extern char *NLgetamsg (char *, int, int, char *);
extern char *NLcatgets (nl_catd, int, int, const char *);























 


 



 


  

 















 



























 


 


  



 


 












 
















































struct _message {
	unsigned short 	_set,
			_msg;
	char 		*_text;
	unsigned	_old;
};

struct _header {
	int 		_magic;
	unsigned short	_n_sets,
			_setmax;
	char		_filler[20];
};
struct _msgptr {
	unsigned short 	_msgno,
			_msglen;
	unsigned int	_offset;
};

struct _catset {
	unsigned short 	_setno,
			_n_msgs;
	struct _msgptr 	*_mp;
	int		_msgs_expanded;
};


struct __catalog_descriptor {
	char		*_mem;
	char		*_name;
	int 		_fd;		 
	struct _header 	*_hd;
	int		_catlen;	 
	struct _catset 	*_set;
	int		_setmax;	 
	int		_count;
	int		_magic;		 
	char		*_lc_message;
	char		*_nlspath;
	int		_n_sets;	 
	int		_sets_expanded;
};


extern "C" {

extern struct _catset *__cat_get_catset(nl_catd, int);

extern struct _msgptr *__cat_get_msgptr(struct _catset *, int);
}






}

























 


 


 



 


 











 
 















 












































 


 


  




extern "C" {





typedef struct {                 
        size_t  re_nsub;         
        void    *re_comp;        
        int     re_cflags;       
        size_t  re_erroff;       
        size_t  re_len;          
        wchar_t re_ucoll[2];     
        uchar_t **re_lsub;       
        uchar_t **re_esub;       
	void    *re_filler[8];   
        uchar_t re_map[256];     
} regex_t;

typedef off_t regoff_t;


typedef struct {                 
        regoff_t   rm_so;	 
                                 
        regoff_t   rm_eo;	 
                                 
} regmatch_t;


}








 



 
typedef enum __lc_type_id_t {
    _LC_CAR=1,
    _LC_LOCALE=2,
    _LC_CHARMAP=3,
    _LC_CTYPE=4,
    _LC_COLLATE=5,
    _LC_NUMERIC=6,
    _LC_MONETARY=7,
    _LC_TIME=8,
    _LC_RESP=9 } __lc_type_id_t;

 



typedef struct {
    __lc_type_id_t
	type_id;
    unsigned short
	magic;
    unsigned short
	format;
    unsigned long
	version;
    
    unsigned long  size;

} _LC_object_t;


 
struct _LC_charmap_t;
struct _LC_ctype_t;
struct _LC_collate_t;
struct _LC_time_t;
struct _LC_monetary_t;
struct _LC_numeric_t;
struct _LC_resp_t;
struct _LC_locale_t;



 





 



typedef struct {

    _LC_object_t  hdr;

     
    char     *(*nl_langinfo) (__nl_item, struct _LC_charmap_t *);
    
     
    int   (*mbtowc) (wchar_t *, const char *, size_t, struct _LC_charmap_t *);
    size_t   (*mbstowcs) (wchar_t *, const char *, size_t, struct _LC_charmap_t *);
    int      (*wctomb) (char *, wchar_t, struct _LC_charmap_t *);
    size_t   (*wcstombs) (char *, const wchar_t *, size_t, struct _LC_charmap_t *);
    
     
    int      (*mblen) (const char *, size_t, struct _LC_charmap_t *);
    
     
    int   (*wcswidth) (const wchar_t *, size_t, struct _LC_charmap_t *);
    int   (*wcwidth) (const wchar_t, struct _LC_charmap_t *);
    
     
    int      (*__mbtopc) (wchar_t *, char *, size_t, int *, struct _LC_charmap_t *);
    int      (*__mbstopcs) (wchar_t *, size_t, char *, size_t, int, char **, int *, struct _LC_charmap_t *);
    int      (*__pctomb) (char *, wchar_t *, size_t, int *, struct _LC_charmap_t *);
    int      (*__pcstombs) (char *, size_t, wchar_t *, size_t, char **, int *, struct _LC_charmap_t *);
    
     
    struct _LC_charmap_t *(*init) (struct _LC_locale_t *);
    void     *data;
} _LC_core_charmap_t;


typedef struct {
 
    _LC_object_t  hdr; 
    
     
    wint_t  (*towupper) (wint_t, struct _LC_ctype_t *);
    wint_t  (*towlower) (wint_t, struct _LC_ctype_t *);
    
     
    wctype_t    (*wctype) (char *, struct _LC_ctype_t *);
    int      (*iswctype) (wint_t, wctype_t, struct _LC_ctype_t *);
    
     
    struct _LC_ctype_t   *(*init) (struct _LC_locale_t *);
    void     *data;
} _LC_core_ctype_t;






 






typedef struct {

    _LC_object_t  hdr;

     
    int      (*strcoll) (const char *, const char *, struct _LC_collate_t *);
    size_t   (*strxfrm) (char *, const char *, size_t, struct _LC_collate_t *);
    
     
    int      (*wcscoll) (const wchar_t *, const wchar_t *, struct _LC_collate_t *);
    size_t   (*wcsxfrm) (wchar_t *, const wchar_t *, size_t, struct _LC_collate_t *);
    
     
    int      (*fnmatch) (const char *, const char *, const char *, int, struct _LC_collate_t *);
    
     
    int      (*regcomp) (regex_t *, const char *, int, struct _LC_collate_t *);
    size_t   (*regerror) (int, const regex_t *, char *, size_t, struct _LC_collate_t *);
    int      (*regexec) (const regex_t *, const char *, size_t, regmatch_t *, int, struct _LC_collate_t *);
    void     (*regfree) (regex_t *, struct _LC_collate_t *);

     
    struct _LC_collate_t *(*init) (struct _LC_locale_t *);
    void     *data;
} _LC_core_collate_t;


struct tm;
typedef struct {

    _LC_object_t  hdr;
    
     
    char     *(*nl_langinfo) (__nl_item, struct _LC_time_t *);
    
     
    size_t   (*strftime) (char *, size_t, const char *, const struct tm *, struct _LC_time_t *);
    char     *(*strptime) (const char *, const char *, struct tm *, struct _LC_time_t *);
    
     
    size_t   (*wcsftime) (wchar_t *, size_t, const char *, const struct tm *, struct _LC_time_t *);
    
     
    struct _LC_time_t    *(*init) (struct _LC_locale_t *);
    void     *data;
} _LC_core_time_t;


typedef struct {

    _LC_object_t  hdr;

     
    char     *(*nl_langinfo) (__nl_item, struct _LC_monetary_t *);
    
     
    ssize_t   (*strfmon) (char *, size_t, const char *, va_list, struct _LC_monetary_t *);
    
     
    struct _LC_monetary_t        *(*init) (struct _LC_locale_t *);
    void     *data;
} _LC_core_monetary_t;


typedef struct {

    _LC_object_t  hdr;

     
    char     *(*nl_langinfo) (__nl_item, struct _LC_numeric_t *);
    
     
    struct _LC_numeric_t *(*init) (struct _LC_locale_t *);
    void     *data;
} _LC_core_numeric_t;


typedef struct {

    _LC_object_t  hdr;
    
     
    char        *(*nl_langinfo) (__nl_item, struct _LC_resp_t *);
    
     
    int		(*rpmatch) (const char *, struct _LC_resp_t *);
    
     
    struct _LC_resp_t    *(*init) (struct _LC_locale_t *);
    void        *data;
} _LC_core_resp_t;

typedef struct {

    _LC_object_t hdr;

     
    char         *(*nl_langinfo) (__nl_item, struct _LC_locale_t *);
    struct lconv * (*localeconv) (struct _LC_locale_t *);
    
     
    struct _LC_locale_t  *(*init) (struct _LC_locale_t *);
    void         *data;
} _LC_core_locale_t;


}





















 
struct _LC_charmap_t {

    _LC_core_charmap_t core;
    
    char     *cm_csname;	 
    
    unsigned long   cm_mb_cur_max;  
    unsigned long   cm_mb_cur_min;  

    unsigned char
	     cm_max_disp_width;  
				 





};






 
struct _LC_monetary_t {

    _LC_core_monetary_t   core;
    
    char *int_curr_symbol;	    
    char *currency_symbol;	    
    char *mon_decimal_point;	    
    char *mon_thousands_sep;	    
    char *mon_grouping;		    
    char *positive_sign;	    
    char *negative_sign;	    
    signed char int_frac_digits;    
    signed char frac_digits;	    
    signed char p_cs_precedes;	    
    signed char p_sep_by_space;	    
    signed char n_cs_precedes;	    
    signed char n_sep_by_space;	    
    signed char p_sign_posn;	    
    signed char n_sign_posn;	    
    char *debit_sign;		    
    char *credit_sign;		    
    char *left_parenthesis;	    
    char *right_parenthesis;	    
    
};






 
struct _LC_numeric_t {

    _LC_core_numeric_t core;
    
    char     *decimal_point;
    char     *thousands_sep;
    unsigned
	char *grouping;
    
};






 
struct _LC_resp_t  {

    _LC_core_resp_t core;

    char    *yesexpr;	      
    char    *noexpr;	      
    char    *yesstr;	      
    char    *nostr;	      

};






 
struct _LC_time_t {

    _LC_core_time_t core;
    
    char *d_fmt;  
    char *t_fmt;  
    char *d_t_fmt;
    char *t_fmt_ampm;
    char *abday[7];  
    char *day[7];    
    char *abmon[12];  
    char *mon[12];    
    char *am_pm[2];
    char **era;			 
    char *era_year;
    char *era_d_fmt;
    char *alt_digits;
    char *m_d_recent;		 
    char *m_d_old;		 
    char *era_d_t_fmt;
    char *era_t_fmt;
};






 


typedef union {
    unsigned int n[(sizeof(unsigned int *)/sizeof(unsigned int))];
    		        
    		        
             
    const unsigned int       
	  *p;	        
} _LC_weight_t;    
  




 
typedef struct {

    const char         *ce_sym;  
    _LC_weight_t ce_wgt;	 
				 
} _LC_collel_t;






 
typedef struct {
    _LC_weight_t   ct_wgt;     
			       

    const _LC_collel_t   *ct_collel; 
} _LC_coltbl_v1_t;





 

 
typedef char _LC_strpool_t, *_LC_strpool_ptr_t;









 
typedef struct {
	int          strpool_idx;
	unsigned int ce_wgt[1];
} _LC_collel_tbl_v2_t;




 
typedef _LC_collel_tbl_v2_t  _LC_collel_tbl_t;









 
typedef struct {
	unsigned int min;
	unsigned int max;
	unsigned int *tbl;
} _LC_collel_qidx_v2_t;





 
typedef _LC_collel_qidx_v2_t _LC_collel_qidx_t;





 
typedef struct {
        unsigned int         ce_tbl_bsize;     
	unsigned int         ce_tbl_cnt;       
	unsigned int         ce_strpool_cnt;   
	unsigned int         version_mask;     
	_LC_strpool_t        *ce_strpool;      
	_LC_collel_tbl_t     *ce_tbl;          
	_LC_collel_qidx_t    *ce_qidx;         
	unsigned int         *ct_wgt[1];       
} _LC_coltbl_v2_t;




 
typedef struct {
  int (*getcolval) (_LC_collate_t *hdl, unsigned int *colval, unsigned int realwc, const char *str, int order);
} _LC_coll_methods_t;




 





typedef union {
  _LC_coltbl_v1_t  ct_v1;
  _LC_coltbl_v2_t  ct_v2;
} _LC_coltbl_t;





 
typedef struct {

    _LC_weight_t ss_act;	 
				 
    const char *ss_src;	 
    const char *ss_tgt;	 

} _LC_subs_t;






 




struct _LC_collate_t {

    _LC_core_collate_t core;
    
    unsigned			             
	char    co_nord;	             
    
    unsigned			             
	char    version;	             
                                             
    
    unsigned			             
	char    ce_defined;	             
    
    _LC_weight_t co_sort;	             
					     
    
    unsigned int     co_wc_min;		     
    unsigned int     co_wc_max;		     
    unsigned int     co_hbound;		     

    unsigned int     co_col_min;	     
    unsigned int     co_col_max;	     

    const _LC_coltbl_t *co_coltbl; 	     
				             
    unsigned
	char    co_nsubs;		     
    const _LC_subs_t         *co_subs;      
    const _LC_coll_methods_t *methods;      
};



 





  


 


  



 
typedef struct {

    char    *name;
    unsigned
	int mask;

} _LC_classnm_t;






 
struct _LC_ctype_t {

  _LC_core_ctype_t core;

   
  unsigned int      min_wc;
  unsigned int      max_wc;

  unsigned int      max_upper;	 
  unsigned int      max_lower;	 

   
  const unsigned int      *_upper;	 
  const unsigned int      *_lower;	 
  
   
  const unsigned
      int      *_mask;        
  const unsigned
      int      *qmask;	      
  const unsigned
      char     *qidx;	      

  unsigned int	qidx_hbound;	 
   
  unsigned
      char     nclasses;
 const _LC_classnm_t *classnms;
  
  unsigned int	num_rows;    
  unsigned int	num_qmasks;  
};

















 






 






 




 






 

struct lconv;


struct _LC_locale_t {

    _LC_core_locale_t core;
    char           *nl_info[55];     
					       
    struct lconv   *nl_lconv;
    
    _LC_charmap_t  *lc_charmap;
    _LC_collate_t  *lc_collate;
    _LC_ctype_t    *lc_ctype;
    _LC_monetary_t *lc_monetary;
    _LC_numeric_t  *lc_numeric;
    _LC_resp_t     *lc_resp;
    _LC_time_t     *lc_time;
    char	   *nl_info2[61 - 55];
};




extern _LC_charmap_t  *__lc_charmap;
extern _LC_collate_t  *__lc_collate;
extern _LC_ctype_t    *__lc_ctype;
extern _LC_monetary_t *__lc_monetary;
extern _LC_numeric_t  *__lc_numeric;
extern _LC_resp_t     *__lc_resp;
extern _LC_time_t     *__lc_time;
extern _LC_locale_t   *__lc_locale;
































}






























}









 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class HElement : public BString {
  public:
    HElement();
    HElement(const char *); 
    ~HElement();

    void      Insert(HElement *);
    HElement *GetNext();

    void      AddRef();
    void      DelRef();
    int       IsUsed();

    int       HashValue();
    void      printHElement();
  protected:
    int      refcnt;
    HElement *next;
};

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class HBucket { 
  public:
    HBucket();
    ~HBucket();
    HElement *AddString(const char *);
    void RemoveString(HElement *);
    int IsUsed();  
    int printHBucket();
  protected:
    HElement *data; 
};

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class HTable { 
  public: 
    HTable();
    ~HTable();
    HElement *AddString(const char *);
    void RemoveString(HElement *);
    int IsUsed();
    void printHTable();
  protected:
    int isUsed;
    int count;            
    HBucket **buckets;    
};


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class HashMaster {
  public:
    HashMaster();
    ~HashMaster();
    HElement *Insert(const char *);
    void Delete(HElement *);
    void printHashMaster();
    int IsUsed();
  protected:
    int count;          
    int isUsed;
    HTable **tables;    
};


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
class HString {
  public:
     
    HString();
    HString(const char *);
    HString(const HString &);
    HString(const BString &);

     
    ~HString();
 
     
    const HString &operator=(const HString &);
    const HString &operator=(const BString &);
    const HString &operator=(const char *);
 
     
    operator const char *(void) const;
    operator const BString &(void) const;

     
    friend ostream &operator<<(ostream &, const HString &);
    friend istream &operator>>(istream &, HString &);

     
    friend int operator==(const HString &, const HString &);
    friend int operator!=(const HString &, const HString &);
    friend int operator<(const HString &, const HString &);
    friend int operator>(const HString &, const HString &);
    friend int operator<=(const HString &, const HString &);
    friend int operator>=(const HString &, const HString &);
  
    friend int operator==(const HString &, const char *);
    friend int operator!=(const HString &, const char *);
    friend int operator<(const HString &, const char *);
    friend int operator>(const HString &, const char *);
    friend int operator<=(const HString &, const char *);
    friend int operator>=(const HString &, const char *);

    friend int operator==(const char *, const HString &);
    friend int operator!=(const char *, const HString &);
    friend int operator<(const char *, const HString &);
    friend int operator>(const char *, const HString &);
    friend int operator<=(const char *, const HString &);
    friend int operator>=(const char *, const HString &);

    friend int operator==(const HString &, const BString &);
    friend int operator!=(const HString &, const BString &);
    friend int operator<(const HString &, const BString &);
    friend int operator>(const HString &, const BString &);
    friend int operator<=(const HString &, const BString &);
    friend int operator>=(const HString &, const BString &);
  
    friend int operator==(const BString &, const HString &);
    friend int operator!=(const BString &, const HString &);
    friend int operator<(const BString &, const HString &);
    friend int operator>(const BString &, const HString &);
    friend int operator<=(const BString &, const HString &);
    friend int operator>=(const BString &, const HString &);

     
    friend BString operator+(const HString &, const HString &);
    friend BString operator+(const HString &, const BString &);
    friend BString operator+(const BString &, const HString &);
    friend BString operator+(const HString &, const char *);
    friend BString operator+(const char *, const HString &);
    friend BString operator+(const HString &, const char);
    friend BString operator+(const char, const HString &);

     
    HString &operator+=(const HString &);
    HString &operator+=(const BString &);
    HString &operator+=(const char *);
    HString &operator+=(const char);
 
     
    unsigned int length() const;

     
    void printHashStats();
    void print();

  protected:
    HElement *str;
    static HashMaster *hm;
};


 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline HElement::HElement() 
{ 
  refcnt = 0;
  next = 0;
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline HElement::HElement(const char *chp) : BString(chp) 
{ 
  refcnt = 1;
  next = 0;
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline HElement::~HElement()
{ 
   
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline HElement *HElement::GetNext() 
{ 
  return next; 
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline void HElement::AddRef() 
{ 
  refcnt++; 
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline void HElement::DelRef() 
{ 
  refcnt--; 
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline int HElement::IsUsed()
{ 
  return ((refcnt > 0) ? 1 : 0); 
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline void HElement::Insert(HElement *new_elem)
{ 
  next = new_elem;
}


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline HBucket::HBucket()
{
  data = 0;
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline int HBucket::IsUsed()
{ 
  return ((data) ? 1 : 0); 
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline HString::operator const char *() const
{ return *(this->str);
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
inline HString::operator const BString &() const
{ return *(this->str);
}
 

























 


 
 
 






























 


 


 



 


 











 
 















 




































































 


 


  

 



 


 













                                                                    




extern "C" {













 




 




















struct	tm {			 
        int     tm_sec;          
        int     tm_min;          
        int     tm_hour;         
        int     tm_mday;         
        int     tm_mon;          
        int     tm_year;         
        int     tm_wday;         
        int     tm_yday;         
        int     tm_isdst;        

        long    tm_gmtoff;
        char    *tm_zone;




};






extern clock_t 	clock (void);
extern double 	difftime (time_t , time_t );
extern time_t 	mktime (struct tm *);
extern time_t 	time (time_t *);
extern char 	*asctime (const struct tm *);
extern char 	*ctime (const time_t *);
extern struct tm *gmtime (const time_t *);
extern struct tm *localtime (const time_t *);
extern size_t 	strftime (char *, size_t , const char *,const struct tm *);

 












extern char * _Pasctime_r (const struct tm *, char *);
extern char * _Pctime_r (const time_t *, char *);
extern struct tm * _Pgmtime_r (const time_t *, struct tm *);
extern struct tm * _Plocaltime_r (const time_t *, struct tm *);


















 





 














 























 


 


  

 



 


 




extern "C"
{
























 


 


 




extern "C"
{











 

typedef struct  sigaltstack {
        caddr_t ss_sp;                   




        int     ss_flags;		 
        size_t	ss_size;		 
} stack_t;








 
typedef union sigval {
	int 	sival_int;
	void	*sival_ptr;
} sigval_t;

 










typedef struct sigevent_event {
	union sigval	_sigev_value;	 
	int		_sigev_signo;	 
	int		_sigev_notify;	 
} sigevent_event_t;

typedef struct sigevent {
	sigevent_event_t  	_sigev_sigevent;
	union {
		int 		_sigev[(((64)/sizeof(int)) - 4)];


		



 
		void		      (*_sigev_notify_function) (sigval_t);
		pthread_attr_t *_sigev_notify_attribute;

	} _sigev_un;
} sigevent_t;



 











 



 
typedef struct timespec {
        time_t  tv_sec;          
        long    tv_nsec;         
} timespec_t;



 
struct uuprof {			 
	short		*pr_base;	 
	unsigned long	pr_size;	 
	unsigned long	pr_off;		 
	unsigned long	pr_scale;	 
};






}


















































 



typedef int             clockid_t;



 




 

struct	itimerspec {
	struct		timespec it_interval;  
	struct		timespec it_value;  
};



 







 








 

int clock_gettime (clockid_t clock_id, struct timespec *tp);
int clock_settime (clockid_t clock_id, const struct timespec *tp);
int clock_getdrift (int clock_id, int *oppb);
int clock_setdrift (int clock_id, const int ppb, int *oppb);
int timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timer_created)
;
int timer_delete (timer_t timerid);
int timer_gettime (timer_t timerid, struct itimerspec *value);
int timer_settime (timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue)

;
int timer_getoverrun (timer_t timerid);
int nanosleep (const struct timespec *rqtp, struct timespec *rmtp);
int clock_getres (clockid_t clock_id,struct timespec *res);



}












extern char *tzname[];

extern void tzset (void);






extern long timezone;


extern int daylight;

extern char *strptime (const char *, const char *, struct tm *);

















 


extern unsigned char *NLctime (long *);
extern unsigned char *NLasctime (struct tm *);
extern char *NLstrtime (char *, size_t , const char *, const struct tm *);

extern struct tm *getdate (char *);
extern int getdate_err;










}




typedef void (*ErrorHandlerType) (const int, const char*);

void defLibErrorHandler(const int number, const char* msg);


 















 







typedef void (*ErrorHandlerType) (const int, const char*);

void defLibErrorHandler(const int number, const char* msg);





template<class T>
struct DLListNode
{
  DLListNode<T>*         bk;
  DLListNode<T>*         fd;
  T                      hd;
                         DLListNode();
                         DLListNode(const T& h, 
                                       DLListNode<T>* p = 0,
                                       DLListNode<T>* n = 0);
                         ~DLListNode();
};

template<class T>
inline DLListNode<T>::DLListNode() {}

template<class T>
inline DLListNode<T>::DLListNode(const T& h, DLListNode<T>* p,
                                    DLListNode<T>* n)
  :hd(h), bk(p), fd(n) {}

template<class T>
inline DLListNode<T>::~DLListNode() {}



template<class T>
class DLList
{
  DLListNode<T>*        h;

protected:
  static ErrorHandlerType libErrorHandler;

public:
                        enum { NULL_PIX, INVARIANT_FAILURE, EMPTY_LIST };
  static T		DLLIST_ERROR;

                        DLList();
                        DLList(const DLList<T>& a);
                        ~DLList();

  DLList<T>&            operator = (const DLList<T>& a);

  int                   empty() const;
  int                   length() const;

  void                  clear();

  Pix                   prepend(const T& item);
  Pix                   append(const T& item);
  void                  join(DLList<T>&);

  T&                    front() const;
  T                     remove_front();
  void                  del_front();

  T&                    rear() const;
  T                     remove_rear();
  void                  del_rear();

  T&                    operator () (Pix p) const;
  Pix                   first() const;
  Pix                   last() const;
  void                  next(Pix& p) const;
  void                  prev(Pix& p) const;
  int                   owns(Pix p) const;
  Pix                   ins_after(Pix p, const T& item);
  Pix                   ins_before(Pix p, const T& item);
  void                  del(Pix& p, int dir = 1);
  void                  del_after(Pix& p);

  ErrorHandlerType      setErrorHandler(ErrorHandlerType f);
  void                  error(const int errorNum, const char* msg) const;
  int                   OK();
};


template<class T>
inline DLList<T>::~DLList()
{
  clear();
}

template<class T>
inline DLList<T>::DLList()
{
  h = 0;
  if (!libErrorHandler) {
    libErrorHandler = &defLibErrorHandler;
  }
}

template<class T>
inline int DLList<T>::empty() const
{
  return h == 0;
}


template<class T>
inline void DLList<T>::next(Pix& p) const
{
  p = (p == 0 || p == h->bk)? 0 : Pix(((DLListNode<T>*)p)->fd);
}

template<class T>
inline void DLList<T>::prev(Pix& p) const
{
  p = (p == 0 || p == h)? 0 : Pix(((DLListNode<T>*)p)->bk);
}

template<class T>
inline Pix DLList<T>::first() const
{
  return Pix(h);
}

template<class T>
inline Pix DLList<T>::last() const
{
  return (h == 0)? 0 : Pix(h->bk);
}

template<class T>
inline T& DLList<T>::operator () (Pix p) const
{
  if (p == 0) {
    error(NULL_PIX, "DLList: null Pix");
    return DLLIST_ERROR;
  }
  return ((DLListNode<T>*)p)->hd;
}

template<class T>
inline T& DLList<T>::front() const
{
  if (h == 0) {
    error(EMPTY_LIST, "DLList: empty list");
    return DLLIST_ERROR;
  }
  return h->hd;
}

template<class T>
inline T& DLList<T>::rear() const
{
  if (h == 0) {
    error(EMPTY_LIST, "DLList: empty list");
    return DLLIST_ERROR;
  }
  return h->bk->hd;
}




 















 





 
















 



 





typedef void (*two_arg_error_handler_t)(const char*, const char*);

extern void default_two_arg_error_handler(const char*, const char*);

extern two_arg_error_handler_t lib_error_handler;

extern two_arg_error_handler_t 
       set_lib_error_handler(two_arg_error_handler_t f);




template<class T>
T DLList<T>::DLLIST_ERROR;

template<class T>
ErrorHandlerType DLList<T>::libErrorHandler;

template<class T>
ErrorHandlerType DLList<T>::setErrorHandler(ErrorHandlerType f)
{
  ErrorHandlerType old = libErrorHandler;
  libErrorHandler = f;
  return old;
}

template<class T>
void DLList<T>::error(const int errorNum, const char* msg) const
{
  (*libErrorHandler)(errorNum, msg);
}

template<class T>
int DLList<T>::length() const
{
  int l = 0;
  DLListNode<T>* t = h;
  if (t != 0) do { ++l; t = t->fd; } while (t != h);
  return l;
}

template<class T>
DLList<T>::DLList(const DLList<T>& a)
{
  if (a.h == 0)
    h = 0;
  else
  {
    DLListNode<T>* p = a.h;
    DLListNode<T>* t = new DLListNode<T>(p->hd);
    h = t;
    p = p->fd;
    while (p != a.h)
    {
      DLListNode<T>* n = new DLListNode<T>(p->hd);
      t->fd = n;
      n->bk = t;
      t = n;
        p = p->fd;
    }
    t->fd = h;
    h->bk = t;
  }
  if (!libErrorHandler) {
    libErrorHandler = &defLibErrorHandler;
  }
}

template<class T>
DLList<T>& DLList<T>::operator = (const DLList<T>& a)
{
  if (h != a.h)
  {
    clear();
    if (a.h != 0)
    {
      DLListNode<T>* p = a.h;
      DLListNode<T>* t = new DLListNode<T>(p->hd);
      h = t;
      p = p->fd;
      while (p != a.h)
      {
        DLListNode<T>* n = new DLListNode<T>(p->hd);
        t->fd = n;
        n->bk = t;
        t = n;
        p = p->fd;
      }
      t->fd = h;
      h->bk = t;
    }
  }
  return *this;
}

template<class T>
void DLList<T>::clear()
{
  if (h == 0)
    return;

  DLListNode<T>* p = h->fd;
  h->fd = 0;
  h = 0;

  while (p != 0)
  {
    DLListNode<T>* nxt = p->fd;
    delete(p);
    p = nxt;
  }
}


template<class T>
Pix DLList<T>::prepend(const T& item)
{
  DLListNode<T>* t = new DLListNode<T>(item);
  if (h == 0)
    t->fd = t->bk = h = t;
  else
  {
    t->fd = h;
    t->bk = h->bk;
    h->bk->fd = t;
    h->bk = t;
    h = t;
  }
  return Pix(t);
}

template<class T>
Pix DLList<T>::append(const T& item)
{
  DLListNode<T>* t = new DLListNode<T>(item);
  if (h == 0)
    t->fd = t->bk = h = t;
  else
  {
    t->bk = h->bk;
    t->bk->fd = t;
    t->fd = h;
    h->bk = t;
  }
  return Pix(t);
}

template<class T>
Pix DLList<T>::ins_after(Pix p, const T& item)
{
  if (p == 0) return prepend(item);
  DLListNode<T>* u = (DLListNode<T>*) p;
  DLListNode<T>* t = new DLListNode<T>(item, u, u->fd);
  u->fd->bk = t;
  u->fd = t;
  return Pix(t);
}

template<class T>
Pix DLList<T>::ins_before(Pix p, const T& item)
{
  if (p == 0) {
    error(NULL_PIX, "DLList: null Pix");
    return(0);
  }
  DLListNode<T>* u = (DLListNode<T>*) p;
  DLListNode<T>* t = new DLListNode<T>(item, u->bk, u);
  u->bk->fd = t;
  u->bk = t;
  if (u == h) h = t;
  return Pix(t);
}

template<class T>
void DLList<T>::join(DLList<T>& b)
{
  DLListNode<T>* t = b.h;
  b.h = 0;
  if (h == 0)
    h = t;
  else if (t != 0)
  {
    DLListNode<T>* l = t->bk;
    h->bk->fd = t;
    t->bk = h->bk;
    h->bk = l;
    l->fd = h;
  }
}

template<class T>
int DLList<T>::owns(Pix p) const
{
  DLListNode<T>* t = h;
  if (t != 0 && p != 0)
  {
    do
    {
      if (Pix(t) == p) return 1;
      t = t->fd;
    } while (t != h);
  }
  return 0;
}

template<class T>
void DLList<T>::del(Pix& p, int dir)
{
  if (p == 0) {
    error(NULL_PIX, "DLList: null Pix");
    return;
  }
  DLListNode<T>* t = (DLListNode<T>*) p;
  if (t->fd == t)
  {
    h = 0;
    p = 0;
  }
  else
  {
    if (dir < 0)
    {
      if (t == h)
        p = 0;
      else
        p = Pix(t->bk);
    }
    else
    {
      if (t == h->bk)
        p = 0;
      else
        p = Pix(t->fd);
    }
    t->bk->fd = t->fd;
    t->fd->bk = t->bk;
    if (t == h) h = t->fd;
  }
  delete t;
}

template<class T>
void DLList<T>::del_after(Pix& p)
{
  if (p == 0)
  {
    del_front();
    return;
  }

  DLListNode<T>* b = (DLListNode<T>*) p;
  DLListNode<T>* t = b->fd;

  if (b == t)
  {
    h = 0;
    p = 0;
  }
  else
  {
    t->bk->fd = t->fd;
    t->fd->bk = t->bk;
    if (t == h) h = t->fd;
  }
  delete t;
}

template<class T>
T DLList<T>::remove_front()
{
  if (h == 0) {
    error(EMPTY_LIST, "DLList: empty list");
    return DLLIST_ERROR;
  }
  DLListNode<T>* t = h;
  T res = t->hd;
  if (h->fd == h)
    h = 0;
  else
  {
    h->fd->bk = h->bk;
    h->bk->fd = h->fd;
    h = h->fd;
  }
  delete t;
  return res;
}


template<class T>
void DLList<T>::del_front()
{
  if (h == 0) {
    error(EMPTY_LIST, "DLList: empty list");
    return;
  }
  DLListNode<T>* t = h;
  if (h->fd == h)
    h = 0;
  else
  {
    h->fd->bk = h->bk;
    h->bk->fd = h->fd;
    h = h->fd;
  }
  delete t;
}

template<class T>
T DLList<T>::remove_rear()
{
  if (h == 0) {
    error(EMPTY_LIST, "DLList: empty list");
    return DLLIST_ERROR;
  }
  DLListNode<T>* t = h->bk;
  T res = t->hd;
  if (h->fd == h)
    h = 0;
  else
  {
    t->fd->bk = t->bk;
    t->bk->fd = t->fd;
  }
  delete t;
  return res;
}


template<class T>
void DLList<T>::del_rear()
{
  if (h == 0) {
    error(EMPTY_LIST, "DLList: empty list");
    return;
  }
  DLListNode<T>* t = h->bk;
  if (h->fd == h)
    h = 0;
  else
  {
    t->fd->bk = t->bk;
    t->bk->fd = t->fd;
  }
  delete t;
}


template<class T>
int DLList<T>::OK()
{
  int v = 1;
  if (h != 0)
  {
    DLListNode<T>* t = h;
    unsigned long count = ~0L;       
    do
    {
      count--;
      v &= t->bk->fd == t;
      v &= t->fd->bk == t;
      t = t->fd;
    } while (v && count > 0 && t != h);
    v &= count > 0;
  }
  if (!v) error(INVARIANT_FAILURE, "DLList: invariant failure");
  return v;
}






typedef enum {
    NULLACTION	=    0,
    ADDCELL	=    1, 
    ADDNET	=    2,
    ADD		=    3,
    ATTACH	=    4, 
    DETACH	=    8, 
    CHANGECELL	=   16,
    CHANGEPIN	=   32,
    PIN		=   44,
    CHANGE      =   48, 
    DELETECELL  =   64,
    DELETENET   =  128, 
    NET		=  130,
    DELETE      =  192, 
    UNPLACE     =  256, 
    PLACE       =  512, 
    FIXED       = 1024,
    CELL	= 1873,
    ALL		= 2047
} ActionType;					 










 

class Action
{
  protected:
    HString   completeLine;			 
    int	      lineNum;				 

  public:
            Action();						 
            Action(const HString &line, const int &num);	 
           ~Action();						 

	    Action(const Action &);				 
    const   Action &operator =(const Action &);			 

            const HString    getLine() const;			 
            const int	     getLineNum() const;		 
    virtual       ActionType getAction() const = 0;		 
    virtual const HString    getPin() const;			 
    virtual const HString    getCell() const;			 
    virtual const HString    getNet() const;			 
    virtual const HString    getOldNet() const;			 

    virtual void  print() const;				 
};












 

class Add_Action : public Action
{
  public:
            Add_Action();					 
            Add_Action(const HString &line, const int &num);	 
           ~Add_Action();					 

	    Add_Action(const Add_Action &);			 
    const   Add_Action &operator =(const Add_Action &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
  virtual ActionType getAction() const = 0;			 

  void print() const;						 
};












 

class AddCell : public Add_Action
{
  protected:
    HString cell;	 					 

  public:
            AddCell();						 
            AddCell(const HString &line, const int &num);	 
            AddCell(const HString &line, const int &num, 
                    const HString &cellName);			 
           ~AddCell();						 

	    AddCell(const AddCell &);				 
    const   AddCell &operator =(const AddCell &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getCell() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class AddNet : public Add_Action
{
  protected:
    HString net;	 					 

  public:
            AddNet();						 
            AddNet(const HString &line, const int &num);	 
            AddNet(const HString &line, const int &num, 
                   const HString &netName);			 
           ~AddNet();						 

	    AddNet(const AddNet &);				 
    const   AddNet &operator =(const AddNet &);			 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getNet() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class AttachPin : public Action
{
  protected:
    HString pin;						 
    HString net;						 

  public:
            AttachPin();					 
            AttachPin(const HString &line, const int &num);	 
            AttachPin(const HString &line, const int &num, 
                      const HString &pinName, 
		      const HString &netName);	                 
           ~AttachPin();					 

	    AttachPin(const AttachPin &);			 
    const   AttachPin &operator =(const AttachPin &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getPin() const;				 
    const HString    getNet() const;				 
          ActionType getAction() const;                          

    void print() const;						 
};












 

class DetachPin : public Action
{
  protected:
    HString pin;						 
    HString net;						 

  public:
            DetachPin();					 
            DetachPin(const HString &line, const int &num);	 
            DetachPin(const HString &line, const int &num,
                      const HString &pinName, 
                      const HString &netName);			 
           ~DetachPin();					 

	    DetachPin(const DetachPin &);			 
    const   DetachPin &operator =(const DetachPin &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getNet() const;				 
    const HString    getPin() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class Change_Action : public Action
{
  public:
            Change_Action();				         
            Change_Action(const HString &line, const int &num);  
           ~Change_Action();				         

	    Change_Action(const Change_Action &);		 
    const   Change_Action &operator =(const Change_Action &);	 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
  virtual ActionType getAction() const;				 

    void print() const;						 
};












 

class ChangePin : public Change_Action
{
  protected:
    HString pin;						 
    HString net;	 					 
    HString oldNet;						 

  public:
            ChangePin();					 
            ChangePin(const HString &line, const int &num);	 
            ChangePin(const HString &line, const int &num, 
                      const HString &pinName,
                      const HString &netName, 
                      const HString &oldNet);			 
           ~ChangePin();					 

	    ChangePin(const ChangePin &);			 
    const   ChangePin &operator =(const ChangePin &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getPin() const;				 
    const HString    getOldNet() const;				 
    const HString    getNet() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class ChangeCell : public Change_Action
{
  protected:
    HString cell;	 					 

  public:
            ChangeCell();					 
            ChangeCell(const HString &line, const int &num);	 
            ChangeCell(const HString &line, const int &num,
                       const HString &cellName);		 
           ~ChangeCell();					 

	    ChangeCell(const ChangeCell &);			 
    const   ChangeCell &operator =(const ChangeCell &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getCell() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class Delete_Action : public Action
{
  public:
            Delete_Action();				         
            Delete_Action(const HString &line, const int &num);  
           ~Delete_Action();				         

	    Delete_Action(const Delete_Action &);		 
    const   Delete_Action &operator =(const Delete_Action &);	 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
  virtual ActionType getAction() const;				 

    void print() const;						 
};












 

class DeleteNet : public Delete_Action
{
  protected:
    HString net;	 					 

  public:
            DeleteNet();					 
            DeleteNet(const HString &line, const int &num);	 
            DeleteNet(const HString &line, const int &num, 
                      const HString &netName);			 
           ~DeleteNet();					 

	    DeleteNet(const DeleteNet &);			 
    const   DeleteNet &operator =(const DeleteNet &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getNet() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class DeleteCell : public Delete_Action
{
  protected:
    HString cell;				 		 

  public:
            DeleteCell(); 					 
            DeleteCell(const HString &line, const int &num);	 
            DeleteCell(const HString &line, const int &num, 
                       const HString &cellName);		 
           ~DeleteCell(); 					 

	    DeleteCell(const DeleteCell &);			 
    const   DeleteCell &operator =(const DeleteCell &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getCell() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class UnplaceCell : public Action
{
  protected:
    HString cell;	 					 

  public:
            UnplaceCell();					 
            UnplaceCell(const HString &line, const int &num);	 
            UnplaceCell(const HString &line, const int &num, 
                        const HString &cellName);		 
           ~UnplaceCell();					 

	    UnplaceCell(const UnplaceCell &);			 
    const   UnplaceCell &operator =(const UnplaceCell &); 	 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getCell() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class PlaceCell : public Action
{
  protected:
    HString cell;	 					 

  public:
            PlaceCell();					 
            PlaceCell(const HString &line, const int &num);	 
            PlaceCell(const HString &line, const int &num, 
                      const HString &cellName);			 
           ~PlaceCell();					 

	    PlaceCell(const PlaceCell &);			 
    const   PlaceCell &operator =(const PlaceCell &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getCell() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};












 

class FixedCell : public Action
{
  protected:
    HString cell;	 					 

  public:
            FixedCell();					 
            FixedCell(const HString &line, const int &num);	 
            FixedCell(const HString &line, const int &num,
                      const HString &cellName);			 
           ~FixedCell();					 

	    FixedCell(const FixedCell &);			 
    const   FixedCell &operator =(const FixedCell &);		 

    const HString    getLine() const;				 
    const int        getLineNum() const;			 
    const HString    getCell() const;				 
          ActionType getAction() const;				 

    void print() const;						 
};











 

class NullAction : public Action
{
  public:
            NullAction();					 
           ~NullAction();					 

    ActionType getAction() const;				 

    void print() const;						 
};





typedef DLList<Action *> Eco_List;












 

class ActionIter
{
  protected:
    Pix 	listPtr;				 
    Eco_List 	action_list;	                         
    int		begin;					 

  public:
            ActionIter();					 
            ActionIter(const Eco_List &); 			 
           ~ActionIter();					 

	    ActionIter(const ActionIter &);			 
    const   ActionIter &operator =(const ActionIter &);		 

            Action *getNextAction();				 
								 
    void    reset();						 
};




















 

class Eco_File
{
  protected:
    HString  fileName;				 
    Eco_List eco_list;				 

    void 	  readReport();			 

  public:
            Eco_File();						 
            Eco_File(const HString &);				 
           ~Eco_File();						 
 
    	    Eco_File(const Eco_File &);				 
    const   Eco_File &operator =(const Eco_File &); 		 

    void    putFileName(const HString &);			 
    const   HString getFileName() const;			 

            ActionIter *getActions(const int &) const;		 
								 
    void    print_list() const;					 
};












extern char fao1[160];
extern char fao2[160];
extern char fao3[160];



 
 
 

 


struct excrtl_message {
  unsigned char level;
  unsigned char fao_count;
           char *facility;
           char *name;
           char *message;
};













extern struct excrtl_message DEF_SUCCESS;
extern struct excrtl_message DEF_INFO;
extern struct excrtl_message DEF_EXPDATA;
extern struct excrtl_message DEF_EXPKEY;
extern struct excrtl_message DEF_EXPKEYS;
extern struct excrtl_message DEF_EXPGRAMMAR;
extern struct excrtl_message DEF_DATACOUNT;
extern struct excrtl_message DEF_WARNING;
extern struct excrtl_message DEF_ERROR;
extern struct excrtl_message DEF_INTERNALLERR;
extern struct excrtl_message DEF_UNEXPKEY;
extern struct excrtl_message DEF_UNRECTOKEN;
extern struct excrtl_message DEF_EOF;
extern struct excrtl_message DEF_FATAL;





 



 







 




















 





 




 




 









 







 




 




 
 
 



 





 














 
 

extern "C" {

  int def_input_library(void *def_db_ptr, FILE *fptr);
  void *def_input_def(FILE *fptr, 
		     char *fileName, 
		     int input_key, 
		     int name_flags, 
		     char *name_mask, 
		     int default_flags, 
		     char *default_mask);
  int def_syntaxerr(int token);
  int def_input_design_section(void *def_db_ptr);
  int def_input_via_section(void *db_ptr);
  int def_parse_via(void *sect_ptr);
  int def_input_component_section(void *def_db_ptr, int parse_placement);
  int def_parse_component(void *sect_ptr, int parse_placement);
  int def_parse_generate(void *comp_ptr, char *comp_name);
  int def_parse_source(void);
  int def_parse_foreign(void *comp_ptr, char *comp_name);
  int def_parse_weight(void);
  int def_parse_region(int *llx, int *lly, int *urx, int *ury);
  int def_parse_placement(void *comp_ptr, char *comp_name, int place_type);
  int def_parse_point(int *xpt, int *ypt);
  int def_parse_pair(int *llx, int *lly, int *urx, int *ury);
  int def_parse_orientation(void);
  int def_input_snet_section(void *db_ptr, int parse_routing);
  int def_parse_snet(int parse_routing, void *sect_ptr);
  int def_parse_width(int *width, char *layer);
  int def_parse_voltage(void);
  int def_parse_style(void);
  int def_parse_spacing(char *layer, int *spacing);
  int def_input_rnet_section(void *db_ptr, int parse_routing);
  int def_parse_rnet(int parse_routing, void *sect_ptr);
  int def_parse_original(char **orig_name);
  int def_parse_use(void);
  int def_parse_pattern(void);
  int def_parse_estcap(void);
  int def_parse_routing(int net_type, void *net_ptr, char *net_name, int routing_class);
  int def_parse_routing_layer(int net_type, void *net_ptr, char *net_name);
  int def_parse_routing_point(int x1pt, int y1pt, int *x2pt, int *y2pt);
  int def_parse_ignore_routing(void);
  int def_parse_ignore_placement(void);
  int def_input_group_section(void *def_db_ptr);
  int def_parse_group(void *sect_ptr);
  int def_parse_soft(void *grp_ptr, char *grp_name);
  int def_input_constraint_section(void *def_db_ptr);
  int def_parse_constr(void *sect_ptr);
  int def_parse_net_constr(void *const_ptr, void *operand_ptr, int orig_flag);
  int def_parse_path(void *const_ptr, void *operand_ptr, int orig_flag);
  int def_parse_sum(void *const_ptr, void *sum_ptr, int orig_flag);
  int def_parse_diff(void *const_ptr, void *diff_ptr, int orig_flag);
  int def_parse_wired(void *const_ptr);
  int def_parse_delay(void *const_ptr);
  int def_input_skip_vias(void);
  int def_input_skip_comps(void);
  int def_input_skip_rnets(void);
  int def_input_skip_snets(void);
  int def_input_skip_groups(void);
  int def_input_skip_design(void);
  int def_input_skip_consts(void);
  char *def_lib_store(char *ptr);
  void def_lib_message(void *msg_num);
  def_yylex(void);
  def_parse_set_in_mask(char *str);
  def_parse_nopass_comments(void);

void *def_create_def_db(char *def_file_name);
void *def_create_section(void *def_db_identifier, int section_type, int expd_data_count);
void *def_create_component(void *def_section_id, char *comp_name);
void *def_create_rnet(void *def_section_id, char *rnet_name);
void *def_create_snet(void *def_section_id, char *snet_name);
void *def_create_via(void *def_section_id, char *via_name);
void *def_create_group(void *def_section_id, char *group_name);
void *def_create_const(void *def_section_id);
int def_store_real_count(void *def_sect_id, int real_count);
int def_store_design_name(void *def_db_identifier, char *design_name);
int def_store_design_array(void *def_db_identifier, char *array_name);
int def_store_design_tech(void *def_db_identifier, char *tech_name);
int def_store_design_floorplan(void *def_db_identifier, char *floorplan_name);
int def_store_design_convert_factor(void *def_db_identifier, int convert_factor);
int def_store_design_external_pin(void *def_db_identifier, char *pin_name, char *net_name);
int def_store_design_history(void *def_db_identifier, char *history_ptr);
int def_store_comp_model_name(void *def_comp_id, char *comp_name, char *model_name);
int def_store_comp_generic_b_name(void *def_comp_id, char *comp_name, char *block_name);
int def_store_comp_task_parm(void *def_comp_id, char *comp_name, char *task_parm);
int def_store_comp_source(void *def_comp_id, char *comp_name, int source);
int def_store_comp_weight(void *def_comp_id, char *comp_name, int weight);
int def_store_comp_region(void *def_comp_id, char *comp_name, int x1, int y1, int x2, int y2);
int def_store_comp_foreign_cellname(void *def_comp_id, char *comp_name, char *foreign_cellname);
int def_store_comp_foreign_ori(void *def_comp_id, char *comp_name, int foreign_orientation);
int def_store_comp_foreign_coords(void *def_comp_id, char *comp_name, int x, int y);
int def_store_comp_net_connectivity(void *def_comp_id, char *comp_name, char *net_name);
int def_store_comp_placed_class(void *def_comp_id, char *comp_name, int placement_class);
int def_store_comp_placed_ori(void *def_comp_id, char *comp_name, int placed_orientation);
int def_store_comp_placed_coords(void *def_comp_id, char *comp_name, int x, int y);
int def_store_net_original(void *def_net_id, char *net_name, char *original_name);
int def_store_net_source(void *def_net_id, char *net_name, int source);
int def_store_net_use(void *def_net_id, char *net_name, int use);
int def_store_net_pattern(void *def_net_id, char *net_name, int pattern);
int def_store_net_estcap(void *def_net_id, char *net_name, int estcap);
int def_store_net_weight(void *def_net_id, char *net_name, int weight);
int def_store_net_pin_connectivity(void *def_net_id, char *net_name, char *pin_name, char *comp_name);
int def_store_routing_type(void *def_net_id, char *net_name, int wire_class);
int def_store_snet_routing(void *def_net_id, char *net_name, int x, int y, char *via_name, char *layer_name, int width);
int def_store_net_routing(void *def_net_id, char *net_name, int x, int y, char *via_name, char *layer_name);
int def_store_snet_width(void *def_snet_id, char *net_name, int width, char *layer_name);
int def_store_snet_voltage(void *def_snet_id, char *net_name, int volts);
int def_store_snet_style(void *def_snet_id, char *net_name, int style);
int def_store_snet_spacing(void *def_snet_id, char *net_name, int spacing, char *layer_name);
int def_store_via_layer_name(void *def_via_id, char *via_name, char *layer_name);
int def_store_via_layer_name_syn(void *def_via_id, char *via_name, char *layer_name, char *synonym);
int def_store_via_layer_rect(void *def_via_id, char *via_name, int x1, int y1, int x2, int y2);
int def_store_group_comp(void *def_group_id, char *group_name, char *comp_name);
int def_store_group_region(void *def_group_id, char *group_name, int x1, int y1, int x2, int y2);
int def_store_group_maxx(void *def_group_id, char *group_name, int maxx);
int def_store_group_maxy(void *def_group_id, char *group_name, int maxy);
int def_store_group_maxhalfperim(void *def_group_id, char *group_name, int maxhalfperim);
int def_store_const_min_rise(void *def_const_id, int min_rise);
int def_store_const_max_rise(void *def_const_id, int max_rise);
int def_store_const_min_fall(void *def_const_id, int min_fall);
int def_store_const_max_fall(void *def_const_id, int max_fall);
int def_store_const_wired_net_name(void *def_const_id, char *net_name);
int def_store_const_wired_distance(void *def_const_id, int distance);

void *def_store_const_net(void *def_const_id, char *net_name, int orig_flag);

void *def_store_const_path(void *def_const_id, char *comp1_name, 
                           char *pin1, char *comp2_name, 
                           char *pin2, int orig_flag);

void *def_store_const_diff(void *def_const_id, void *def_oprnd_id1, 
                           void *def_oprnd_id2, void *def_diff_id, 
                           int orig_flag);

void *def_store_const_sum(void *def_const_id, void *def_oprnd_id, 
                          void *def_sum_id, int orig_flag);


}















struct CIRCUITGLOBAL
{
  SLList <AddNode *> glb_add_cir;
  SLList <ReAttachNode *> glb_reattach_cir;
};

 
 
 
 
 
extern "C" {
  int ctedit_parse(void);
  int ctedit_lex(void);
  void ctedit_error(char*);
  void ctedit_lex_init(FILE *);
} 



















 
 
 
 
 
 
 
 
 
 
 


 
 
 
 
 





 
 
 
 
 
class Distance_Node;


class AreaInfo
{
  public:
    AreaInfo(const BString &, int loadcntr, SLList <struct def_component_info_structure *> loadPtrs, 
                   SLList <Clock *> SubClocks, struct def_database_info_structure *defdb);
    ~AreaInfo();
    AreaInfo(const AreaInfo &);

    const AreaInfo &operator=(const AreaInfo &);

    double GetArea() const;
    BString GetNetName() const;
    int GetLoadNum() const;
    double GetDensity() const;
  
  private:
    void GetLowBounds(long &, long &, SLList<Distance_Node *>);
    void GetUpperBounds(long &, long &, SLList<Distance_Node *>);
    void Getarea(long X1, long X2, long Y1, long Y2, double &area);

    long X1, Y1, X2, Y2;
    double area, density;
    BString netName;
    int loadNum;
};













int Store_List(SLList <BString> &typeName, char *type);
void set_params(char *, int &, SLList <BString> &);
void Print_Instance(int, int, const BString &, const BString &);
void Print_InstNum(int, int, int);
void Print_Net(const BString &);
extern "C" void output_cmd(int);
extern "C" int def_output_def(FILE *, struct def_database_info_structure *, int keys);
extern "C" void input_cmd(int);
extern "C" def_init_ptr(void *ptr, int key);
extern "C" char *lib_store (char *);
extern "C" void show_cmd(int);
extern "C" int modify_clock(int);
extern "C" int extract_clock(int);
extern "C" int form_clock(int);
extern "C" int create_clock(int);
void PrintAreaInfo(SLList<AreaInfo *>, AreaInfo *, AreaInfo *, double, 
	           double, AreaInfo *, AreaInfo *, float); 
void process_commands(char *prompt);
extern "C" void aw_send_message_cb(char *);













 
 
 
 
 
 
 
 
 
 
 
 
 
 


 
 
 
 
 








class CtEdit 
{
  public:
    CtEdit();
    CtEdit(const CtEdit &S);
    ~CtEdit();

    const CtEdit &operator=(const CtEdit &S);

    void ExtractClock(const BString &netName, 
                      const BString &driverName, int level, 
                      const SLList <BString> &modelname,
                      const BString &rootNodeName);
    void ModifyClock(const BString &clockName);
    void Form_Clock(const BString &clockName, const BString &driverName,
                    const BString &filename);
    void Create_Clock(const BString &clockName, int levels, int clocks[], 
                      const BString &, const SLList<BString> &netnames, 
                      const SLList<BString> &modelNames, const BString &inpin,
                      const BString &outpin);

    void InputDef(const BString &filename);
    void InputEco(const BString &filename);
    void InputMod(const BString &filename);
    void OutputDef(const BString &filename, int with_placement);
    void OutputMod(const BString &filename);

    void ShowClockFanout(const BString &clockName) const;
    void ShowClockArea(const BString &clockName) const;
    void ShowClockLoads(const BString &clockName) const;
    void ShowNet(const BString &net) const;

    void AddCircuitAppend(AddNode *node);
    void ReAttachCircuitAppend(ReAttachNode *node);
    
  private: 
    void ExtractExistingLoadsFromEcoFile(const BString &clockname);
    void ExtractNewLoadsFromEcoFile(Clock *clock);
    int NetIsClock(const BString &, SLList<Clock *>, Clock *&);
    Distance_Node *GetClosestBuffer(SLList<Distance_Node *>, long, long);
    int CompName(struct def_component_info_structure *, const BString &);

    SLList <Clock *> ClockList;
    SLList <AddNode *> add_circuit;
    SLList <ReAttachNode *> reattach_circuit;
    struct def_database_info_structure *defdb;
    Eco_File ecoList;
    
};


















 
 
 
 
 
extern CtEdit *ctglb;
extern ofstream logfile;
extern ofstream create_net;
extern ofstream create_inst;
extern ofstream attach_pins;
extern int command_table;
extern struct CIRCUITGLOBAL cirglb;

 
 
 
 
 



































 


 


 








 
 











 













 




 























































extern "C"
{


extern  double acos(double );
extern  double asin(double );
extern  double atan(double );
extern  double atan2(double ,double );
extern  double ceil(double );
extern  double cos(double );
extern  double cosh(double );
extern  double exp(double );
extern  double fabs(double );
extern  double floor(double );
extern  double fmod(double , double );
extern  double frexp(double , int *);
extern  double ldexp(double , int );
extern  double log(double );
extern  double log10(double );
extern  double modf(double , double *);
extern  double pow(double , double );
extern  double sin(double );
extern  double sinh(double );
extern  double sqrt(double );
extern  double tan(double );
extern  double tanh(double );


 
extern float acosf ( float );
extern float asinf ( float );
extern float atanf ( float );
extern float atan2f ( float, float );
extern float ceilf ( float );
extern float cosf ( float );
extern float coshf ( float );
extern float expf ( float );
extern float fabsf ( float );
extern float floorf ( float );
extern float fmodf ( float, float );
extern float frexpf ( float, int * );
extern float ldexpf ( float, int );
extern float logf ( float );
extern float log10f ( float );
extern float modff ( float, float * );
extern float powf ( float, float );
extern float sinf ( float );
extern float sinhf ( float );
extern float sqrtf ( float );
extern float tanf ( float );
extern float tanhf ( float );


}


































































 



extern int signgam;



































extern "C"
{

extern double   erf(double );
extern double   erfc(double );
extern double   gamma(double );
extern double   hypot(double ,double );
extern int      isnan( double );
extern double   j0(double );
extern double   j1(double );
extern double   jn(int, double );
extern double   lgamma(double );
extern double   y0(double );
extern double   y1(double );
extern double   yn(int , double );



 

extern float erfcf ( float );
extern float erff ( float );
extern float gammaf ( float );
extern float hypotf ( float, float );
extern int   isnanf ( float );
extern float j0f ( float );
extern float j1f ( float );
extern float jnf ( int, float );
extern float lgammaf ( float );
extern float y0f( float );
extern float y1f( float );
extern float ynf( int, float );



}


























































































































































extern "C"
{


 

extern double   acosh(double );
extern double   asinh(double );
extern double   atanh(double );
extern double   cbrt(double );
extern double   expm1(double );
extern double   log1p(double );
extern double   logb( double );
extern double   nextafter(double, double );
extern double   remainder(double, double );
extern double   rint(double );











extern double   cabs( double, double );
extern double   copysign (double , double );
extern double   drem(double , double );


extern double   scalb( double , double );

extern int      finite( double );



 
extern float acoshf ( float );
extern float asinhf ( float );
extern float atanhf ( float );
extern float cabsf ( float, float );
extern float cbrtf ( float );
extern float copysignf ( float, float );
extern float dremf ( float, float );
extern float expm1f ( float );
extern float log1pf ( float );
extern float logbf ( float );
extern float nextafterf ( float, float );
extern float remainderf ( float, float );
extern float rintf ( float );
extern float scalbf ( float, float );
extern int finitef ( float );



 
extern double F_acos ( double );
extern double F_asin ( double );
extern double F_atan ( double );
extern double F_atan2 ( double, double );
extern double F_cos ( double );
extern double F_exp ( double );
extern double F_hypot ( double, double );
extern double F_log ( double );
extern double F_log10 ( double );
extern double F_pow ( double, double );
extern double F_sin ( double );
extern double F_sqrt ( double );
extern double F_tan ( double );


 
extern float F_acosf ( float );
extern float F_asinf ( float );
extern float F_atan2f ( float, float );
extern float F_atanf ( float );
extern float F_cosf ( float );
extern float F_expf ( float );
extern float F_hypotf ( float, float );
extern float F_log10f ( float );
extern float F_logf ( float );
extern float F_powf ( float, float );
extern float F_sinf ( float );
extern float F_sqrtf ( float );
extern float F_tanf ( float );



 
extern double acosd ( double );
extern double asind ( double );
extern double atand ( double );
extern double atand2 ( double, double );
extern double cosd ( double );
extern double cot ( double );
extern double cotd ( double );
extern double log2 ( double );
extern double nint ( double );
extern double powi ( double, int );
extern double sind ( double );
extern double tand ( double );
extern double trunc ( double );

extern float acosdf ( float );
extern float asindf ( float );
extern float atand2f ( float, float );
extern float atandf ( float );
extern float cosdf ( float );
extern float cotdf ( float );
extern float cotf ( float );
extern float log2f ( float );
extern float nintf ( float );
extern float powif ( float, int );
extern float sindf ( float );
extern float tandf ( float );
extern float truncf ( float );

extern int fp_class ( double );
extern int fp_classf ( float );
extern int powii ( int, int );
extern int unordered ( double, double );
extern int unorderedf ( float, float );


}






























struct exception {
	int type;
	char *name;
	double arg1;
	double arg2;
	double retval;
};










































 





















 


 



 


 












 




 
















 



















 































 







 
 
 











 
 
 
 
 
 
 
 
 
 
 
 

 
 
 
 
 



 
 
 
 
 
class SquarePartition;
class Coordinates;
class AdjacentPlacement;
class Block;
class AdjacentInfo;
class Box;
class BoxInfo;
class BufferPlacement;

 
 
 
 
 
 
 
class SquarePartition 
{
  public:
    SquarePartition(const BString &mainclockName, struct def_database_info_structure *, int);
    SquarePartition(const SquarePartition &S);
    ~SquarePartition();
  
    const SquarePartition &operator=(const SquarePartition &S);

    SLList<Coordinates *> GetCoordList() const;
    SLList<BString> GetLoadNames() const;

  private:
    SLList<Coordinates *> CoordList;
    SLList<BString> loads;
};

 
 
 
 
 
 
 
class Coordinates
{
  public:
    Coordinates(long min_x, long min_y, long max_x, long max_y);
    Coordinates(const Coordinates &S);
    ~Coordinates();
  
    const Coordinates &operator=(const Coordinates &S);

    long Get_min_X() const;
    long Get_min_Y() const;
    long Get_max_X() const;
    long Get_max_Y() const;

  private:
    long min_X, min_Y, max_X, max_Y;
};

 
 
 
 
 
 
 
 
 
 
 
 
class AdjacentPlacement
{
  public:
    AdjacentPlacement(SLList<Coordinates *> coordList, struct def_database_info_structure *defdb, 
                      SLList<BString> loadname, 
                      const SLList<BString> &netNames); 
    AdjacentPlacement(const AdjacentPlacement &S);
    ~AdjacentPlacement();

    const AdjacentPlacement &operator=(const AdjacentPlacement &S);
  
    SLList<Block *> GetBlocks() const;

  private:
    Distance_Node *GetClosestLoad(const SLList<Distance_Node *> &, long,long);

    SLList<Block *> Blocks;
};


 
 
 
 
 
 
 
 
class Block
{
  public:
    Block(SLList<struct def_component_info_structure *> loads, const BString &netName);
    Block();                                      
    Block(const Block &S);
    ~Block();

    const Block &operator=(const Block &S);

    BString GetNetName() const;
    SLList<struct def_component_info_structure *> GetLoads() const;
    void AddLoad(struct def_component_info_structure *);
    void DeleteLoads();

  private:
    BString netName;
    SLList<struct def_component_info_structure *> Loads;
};


 
 
 
 
 
 
 
 
class AdjacentInfo
{
  public:
    AdjacentInfo(Coordinates *coord, SLList<Coordinates *>, 
                 SLList<BString> &loadnames, struct def_database_info_structure *defdb, 
                 int netcount);
    AdjacentInfo(const AdjacentInfo &S);
    ~AdjacentInfo();

    const AdjacentInfo &operator=(const AdjacentInfo &S);
  
    int GetDensity() const;
    int GetNumAdjacent() const;
    SLList<struct def_component_info_structure *> GetLoads() const;
    void DecrementPriority();
    int Priority() const;

  private:
    int num_adjacent;
    int density;
    SLList<struct def_component_info_structure *> loads;
    int priority;
};

 
 
 
 
 
 
 
 
 
 
class BufferPlacement
{
  public:
    BufferPlacement();
    BufferPlacement(SLList<Block *> blocks, SLList<ClockInfo *> infolist,
                    struct def_database_info_structure *defdb);
    BufferPlacement(const BufferPlacement &);
    ~BufferPlacement();
  
    const BufferPlacement &operator=(const BufferPlacement &);

    SLList<Box *> GetBoxs() const;

  private:
    int GetSubClkNumber(SLList<ClockInfo *>, int level);
    void GetBlockInfo(SLList<Distance_Node *> &, SLList<Distance_Node *> &,
                      SLList<Block *>Blocks, struct def_database_info_structure *);
    SLList<Coordinates *> GetCoordList(SLList<Distance_Node *>, int);
    SLList<BoxInfo *> GetBoxPriorityList(SLList<Coordinates *>, 
                                         int subclocknumber, 
                                         SLList<Distance_Node *>);
    void AttachBlocks(SLList<Block *>, SLList<ClockInfo *>,
                      SLList<Distance_Node *>,SLList<BoxInfo *>);
    void AttachBoxs(SLList<Box *>, SLList<ClockInfo *>,
                    SLList<Distance_Node *>, SLList<BoxInfo *>);


   
    SLList<Box *> boxs;
};

 
 
 
 
 
 
 
 
class Box
{
  public:
    Box();
    Box(const BString &netname, SLList<Block *> blocks);
    Box(const BString &netname, SLList<Box *> boxs);
    Box(const Box &);
    ~Box();

    const Box &operator=(const Box &);

    BString GetNetName() const;
    SLList<Box *> GetBoxs() const;
    SLList<Block *> GetBlocks() const;
    long GetMid_x() const;
    long GetMid_y() const; 

    void AddBlock(Block *);
    void AddBox(Box *);
  private:
    BString netName;
    SLList<Box *> boxs;
    SLList<Block *> blocks;
    SLList<Distance_Node *> load_coords;
    long mid_x, mid_y;
};

 
 
 
 
 
 
 
class BoxInfo
{
  public:
    BoxInfo();
    BoxInfo(Coordinates *,int,SLList<Coordinates *>,SLList<Distance_Node *> &);
    BoxInfo(const BoxInfo &);
    ~BoxInfo();

    const BoxInfo &operator=(const BoxInfo &);

    int GetPriority() const;
    int GetAdjacentNum() const;
    int GetDensity() const;
    Coordinates *GetCoords();
    BString GetNetName() const;

    void DecrementPriority();

    void SetNetName(const BString &);
    void SetCoords(long x1, long y1, long x2, long y2);

  private:
    BString netName;
    Coordinates *coord;
    int priority, adjacent, density;
};









 
 
 
 
 
#pragma define_template SLList < Clock * >
#pragma define_template SLList < struct def_component_info_structure * >
#pragma define_template SLList < struct def_pin_info_structure * >
#pragma define_template SLList < struct def_net_info_structure * >
#pragma define_template SLList < AttachNode * >
#pragma define_template SLList < ReAttachNode * >
#pragma define_template SLList < AddNode * >
#pragma define_template SLList < AreaInfo * >
#pragma define_template SLList < ClockInfo * >
#pragma define_template SLList < int >
#pragma define_template SLList < Coordinates * >
#pragma define_template SLList < Block * >
#pragma define_template SLList < long >
#pragma define_template SLList < AdjacentInfo * >

Clock::Clock()
{
}
 
 
 
 
 
 
 
 
 
Clock::Clock(Clock *tmpclk)
{
  Parent = tmpclk;
  loadCntr = 0;
}

 
 
 
 
 
 
 
 
 
 
 
Clock::Clock(struct def_database_info_structure *defDB, const BString &netname, 
             const BString &drivername, const BString &recname, int lev, 
             const SLList <BString> &modelnames, Clock *parent)
{
  SubClocks.clear();
  netName = netname;
  recieverName = recname;
  driverName = drivername;
  defdb = defDB;
  level = lev;
  Parent = parent;
  loadCntr = 0;
  Pix node = modelnames.first();

  for(int i = 0; i < level - 1; i++) {
    modelnames.next(node);
  }
  modelName = modelnames(node);

   
  GetLoads();
  ClockIter *clkiter = GetSubClocks(this, modelnames);
  delete clkiter;
}

 
 
 
 
 
 
 
 
 
Clock::Clock(const Clock& S)
{
  recieverName = S.recieverName;
  driverName = S.driverName;
  defdb = S.defdb;
  netName = S.netName;
}

 
 
 
 
 
 
 
 
 
Clock::~Clock()
{
  Pix node;
  for(node = loadPtrs.first(); node; loadPtrs.next(node)) {
    delete loadPtrs(node);
     
  }

  for(node = SubClocks.first(); node; SubClocks.next(node)) {
    delete SubClocks(node);
  }

  for(node = pinPtrs.first(); node; pinPtrs.next(node)) {
    delete pinPtrs(node);
  }

  loadPtrs.clear();
  SubClocks.clear();
  pinPtrs.clear();

}

 
 

 
 
 
 
 
 
 
const Clock &Clock::operator=(const Clock &msg)
{
  driverName = msg.driverName;
  netName = msg.netName;
  defdb = msg.defdb;
  return *this;
}

 
 
 
 
 
 
 
 
 
BString Clock::GetDriverName() const
{
  return driverName;
}

BString Clock::GetRecieverName() const
{
  return recieverName;
}

 
 
 
 
 
 
 
 
 
BString Clock::GetNetName() const
{
  return netName;
}

 
 
 
 
 
 
 
 
 
int Clock::Getlevel() const
{
  return level;
}

 
 
 
 
 
 
 
 
 
void Clock::SetNetName(const BString &netname) 
{
  netName = netname;
}

 
 
 
 
 
 
 
 
 
 
ClockIter *Clock::GetSubClocks(Clock *parnt, 
                               const SLList<BString> &modelnames) 
{
  struct list_structure *lptr;
  struct def_net_info_structure *net;
  struct def_component_info_structure *comp;
  struct def_pin_info_structure *pin;
  char Newnet[100], Newdrv[100]; 
  char tmpdriverName[100], tmprec[100];
  Clock *clk;
  BString rec;

  for (int i = 0; i < 100; i++) {
    tmpdriverName[i] = '\0';
    Newnet[i] = '\0';
    Newdrv[i] = '\0';
  }

  if (driverName != "") {
    strcpy(tmpdriverName, driverName);
    for (i = strlen(tmpdriverName) -1; i >= 0; i--) { 
      if (tmpdriverName[i] != '.') {
	tmpdriverName[i] = '\0';
      }
    }
  } else {
    strcpy(tmpdriverName, "");
  }

  if (Get_Net(lptr, net)) {
    while(lptr) {
      Get_Inst(comp, lptr, pin);
      if (Inst_Is_Net(comp) && 
          !strcmp(comp->def_comp_name,tmpdriverName) == 0) { 
        struct list_structure *lptr1, *lptr2, *lptr3;
        struct def_net_info_structure *netinfo;
         
         
        for (lptr1 = defdb->def_sections_h; lptr1; lptr1 = ((lptr1)->list_next)) {
          struct def_data_section_structure *sect_ptr = (struct def_data_section_structure *)((lptr1)->list_data);
          if (sect_ptr->def_sect_type == 4 ||
              sect_ptr->def_sect_type == 3) {
            for (lptr2=sect_ptr->def_sect_list_h;lptr2;lptr2=((lptr2)->list_next)) {
              struct def_net_info_structure *netinfo = (struct def_net_info_structure *)((lptr2)->list_data);
              if (strstr(netinfo->def_net_name, comp->def_comp_name) != 0L) {
                for(lptr3 = netinfo->def_net_pins_h; lptr3;
                    lptr3=((lptr3)->list_next)) {
                  struct def_pin_info_structure *pininfo = (struct def_pin_info_structure *)((lptr3)->list_data);
                  if(strcmp(pininfo->def_pin_comp_name, 
                            comp->def_comp_name)== 0) {
                    strcpy(Newnet, netinfo->def_net_name);
                    strcpy(Newdrv, comp->def_comp_name);
                    strcat(Newdrv, ".");
                    strcat(Newdrv, pininfo->def_pin_name);
                    break;
                  }
                }
              }
            }
          }
        }
        int tlevel = level - 1;
        strcpy(tmprec,pin->def_pin_comp_name);
        strcat(tmprec, ".");
        strcat(tmprec, pin->def_pin_name);
        rec = tmprec;
        clk = new Clock(defdb, Newnet, Newdrv, rec, tlevel, modelnames, parnt);
        SubClocks.append(clk);
      }
      lptr = ((lptr)->list_next);
    }
  }
  return new ClockIter(SubClocks);
}

 
 
 
 
 
 
 
 
 
Clock *Clock::GetParent() const
{
  return Parent;
}

 
 
 
 
 
 
 
 
 
 
SLList<struct def_component_info_structure *> Clock::GetLoads() 
{
  struct list_structure *pinList = 0L;
  struct def_net_info_structure *net;
  struct def_component_info_structure *comp;
  struct def_pin_info_structure *pin;
  char tmpdriverName[100];


  for (int i = 0; i < 100; i++) {
    tmpdriverName[i] = '\0';
  }

  if (driverName != "") {
    strcpy(tmpdriverName, driverName);
    for (i = strlen(tmpdriverName) -1; i >= 0; i--) { 
      if (tmpdriverName[i] != '.') {
	tmpdriverName[i] = '\0';
      }
    }
  } else {
    strcpy(tmpdriverName, "");
  }

   
  if (Get_Net(pinList, net)) {
    while (pinList) {
      Get_Inst(comp, pinList, pin); 
      if (!Inst_Is_Net(comp) && 
          !(strcmp(comp->def_comp_name, tmpdriverName)==0)) {
        loadCntr++;
        loadPtrs.append(comp);
        pinPtrs.append(pin);
      }
      pinList = ((pinList)->list_next);
    }
  }
  return loadPtrs;
}


BString Clock::GetModelName() const
{
  return modelName;
}

 
 
 
 
 
 
 
 
 
int Clock::Get_Net(struct list_structure *&lptr, struct def_net_info_structure *&net)
{
  net = FindNet(defdb,netName);
  if (net != 0L) {
    lptr = net->def_net_pins_h;
    return 1;
  }
  else return 0;
}


 
 
 
 
 
 
 
 
 
struct def_net_info_structure *Clock::FindNet(struct def_database_info_structure *dbptr, const BString &netName)
{
  struct list_structure *lptr;
  struct def_net_info_structure *netinfo;

  for (lptr = dbptr->def_sections_h; lptr; lptr = ((lptr)->list_next)) {
    struct def_data_section_structure *sect_ptr = (struct def_data_section_structure *)((lptr)->list_data);
    if (sect_ptr->def_sect_type == 4 ||
        sect_ptr->def_sect_type == 3) {
      netinfo = FindNet(sect_ptr, netName);
      if (netinfo != 0L) {
        return netinfo;
      }
    }
  }
  return 0L;
}

 
 
 
 
 
 
 
 
 
struct def_net_info_structure *Clock::FindNet(struct def_data_section_structure *netptr, const BString &netName)
{
  struct list_structure *lptr;

  for (lptr = netptr->def_sect_list_h; lptr; lptr = ((lptr)->list_next)) {
    struct def_net_info_structure *netinfo = (struct def_net_info_structure *)((lptr)->list_data);
    if(strcmp(netinfo->def_net_name,netName) == 0) {
      return netinfo;
    }
  }
  return 0L;
}

 
 
 
 
 
 
 
 
 
 
 
struct def_component_info_structure *Clock::FindComp(struct def_database_info_structure *dbptr, const BString &compName)
{
  struct list_structure *lptr;
  struct def_component_info_structure *compinfo;
  for (lptr = dbptr->def_sections_h; lptr; lptr = ((lptr)->list_next)) 
  {
    struct def_data_section_structure *sect_ptr = (struct def_data_section_structure *)((lptr)->list_data);
    if (sect_ptr->def_sect_type == 2) 
    {
      compinfo = FindComp(sect_ptr, compName);
      if (compinfo != 0L)
      {
        return compinfo;
      }
    }
  }
  return 0L;
}

 
 
 
 
 
 
 
 
 
struct def_component_info_structure *Clock::FindComp(struct def_data_section_structure *cmpptr, const BString &compName)
{
  struct list_structure *lptr;
  for (lptr = cmpptr->def_sect_list_h; lptr; lptr = ((lptr)->list_next)) {
    struct def_component_info_structure *compinfo = (struct def_component_info_structure *)((lptr)->list_data);
    if(strcmp(compinfo->def_comp_name,compName) == 0) {
      return compinfo;
    }
  }
  return 0L;
}

 
 
 
 
 
 
 
 
 
 
void Clock::Get_Inst(struct def_component_info_structure *&comp, struct list_structure *lptr,
                     struct def_pin_info_structure *&pin)
{
  pin = (struct def_pin_info_structure *)((lptr)->list_data);
  comp = FindComp(defdb, pin->def_pin_comp_name);
}


 
 
 
 
 
 
 
 
 
int Clock::Inst_Is_Net(struct def_component_info_structure *comp)
{
  if (strstr(comp->def_comp_model_name, modelName) != 0L) {
    return 1;
  }
  return 0;
}


 
 
 
 
 
 
 
 
int Clock::GetloadCntr() const
{
  return loadCntr;
}

 
 
 
 
 
 
 
 
SLList <struct def_component_info_structure *> Clock::RetLoadPtrs() const
{
  return loadPtrs;
}

 
 
 
 
 
 
 
 
SLList<Clock *> Clock::RetSubClkPtrs() const
{
  return SubClocks;
}

 
 
 
 
 
 
 
 
 
 
int Clock::Show_ClockFanout(int hiLevel)
{
  ClockIter *subclksiter;
  Pix node;
  struct def_component_info_structure *data;
  
  if(Parent != 0L) {    
   
   
   
   
   
   
   
   
   
   
   
   
  }
  Print_Instance(Getlevel(), hiLevel, GetDriverName(), GetModelName());
  Print_Net(GetNetName());
 
   
   

  SLList<struct def_component_info_structure *> loads = RetLoadPtrs();
  for (node = loads.first(); node; loads.next(node))
  {
    data = (struct def_component_info_structure *)loads(node);
    Print_Instance(Getlevel()-1, hiLevel, data->def_comp_name, " ");
    cout << endl;
    logfile << endl;
    
     
     
     
     
  }
  SLList <Clock *> tc = RetSubClkPtrs();
  subclksiter = new ClockIter(tc);
  if(subclksiter)
  {
    Clock *clk = subclksiter->Reset();
    while(clk)
    {
      clk->Show_ClockFanout(hiLevel);
      clk = subclksiter->GetNextClock();    
    }
  }
  delete subclksiter;
  return 1;
}

 
 
 
 
 
 
 
 
 
 
int Clock::Show_ClockLoads(int hiLevel)
{
  ClockIter *subclksiter;
  Pix node;
  struct def_component_info_structure *data;

  if (Getlevel() == 1)
  {
    int loadnum = GetloadCntr();
    Print_InstNum(Getlevel()-1, hiLevel, loadnum);
    Print_Net(GetNetName());
  }
  else
  {
    logfile << "!";
    for(int i=0; i<(hiLevel-Getlevel()); i++)
    {
      cout << "    ";
      logfile << "    ";
    }
    Print_Net(GetNetName());
    SLList <Clock *> tc = RetSubClkPtrs();
    subclksiter = new ClockIter(tc);
    if(subclksiter)
    {
      Clock *clk = subclksiter->Reset();
      while(clk)
      {
        clk->Show_ClockLoads(hiLevel);
        clk = subclksiter->GetNextClock();    
      }
    }
  }
  return 1;
}

 
 
 
 
 
 
 
 
 
 
int Clock::Show_ClockArea()
{
  ClockIter *subclksiter = 0L;
  Pix node;
  struct def_component_info_structure *data;
  long X1, Y1, X2, Y2;
  double area;
  SLList<AreaInfo *> LowLevelAreaInfo;
  BString CurrentClkName;
  int finished = 0;
  double min_area = 3.4e38, max_area = 0, area_mean = 0; 
  double standard_dev =0;
  int min_load_num = 10000, max_load_num = 0;
  float std_load_dev = 0, loads_mean = 0;
  AreaInfo *areaData;

  LowLevelAreaInfo.clear();

   
  SLList <Clock *> tc = RetSubClkPtrs();
  subclksiter = new ClockIter(tc);

  if(subclksiter->Reset())
  {
    while(!finished)
    {
      while(subclksiter->IsLowerLevel())
      {
        tc = subclksiter->GoDown();
        subclksiter = new ClockIter(tc);
      }
      Clock *clk = subclksiter->Reset();
      while(clk)
      {
        areaData = new AreaInfo(clk->GetNetName(), clk->GetloadCntr(), 
                             clk->RetLoadPtrs(), clk->RetSubClkPtrs(), defdb);
        LowLevelAreaInfo.append(areaData);
        clk = subclksiter->GetNextClock();    
      }
      int end_of_list = 1;
      while(end_of_list)
      {
        if(subclksiter->IsUpperLevel())
        {
          tc = subclksiter->GoUp(CurrentClkName);
          subclksiter = new ClockIter(tc);
          clk = subclksiter->Reset();
          while(clk->GetNetName() != CurrentClkName)
          {
            clk = subclksiter->GetNextClock();
          }
          clk = subclksiter->GetNextClock();
          if(clk == 0L)
          {
            end_of_list = 1;
          }
          else
          {
            SLList <Clock *> tc = clk->RetSubClkPtrs();
            subclksiter = new ClockIter(tc);
            end_of_list = 0;
          }
        }
        else
        {
          end_of_list = 0;
          finished = 1;
        }
      }
    }
  }
  else
  {
    areaData = new AreaInfo(GetNetName(), GetloadCntr(), 
                             RetLoadPtrs(), RetSubClkPtrs(), defdb);
    LowLevelAreaInfo.append(areaData);
  }
   
   
   
  int cntr = 0;
  AreaInfo *maxAreaData, *minAreaData, *minLoad, *maxLoad;
  for (node = LowLevelAreaInfo.first(); node; LowLevelAreaInfo.next(node))
  {
    areaData = LowLevelAreaInfo(node);
    area = areaData->GetArea();
    if (area < min_area) 
    {
      min_area = area;
      minAreaData = areaData;
    }
    if (area > max_area)
    {
      max_area = area;
      maxAreaData = areaData;
    }
    cntr++;
    area_mean += area;
    int loads = areaData->GetLoadNum();
    if (loads > max_load_num)
    {
      max_load_num = loads;
      maxLoad = areaData;
    }
    if (loads < min_load_num)
    {
      min_load_num = loads;
      minLoad = areaData;
    }
    loads_mean += loads;
  }
  if (cntr != 0)
  {
    area_mean /= cntr;
    loads_mean /= cntr;
  }
  double area_total = 0;
  float loads_total = 0;
   
  for (node = LowLevelAreaInfo.first(); node; LowLevelAreaInfo.next(node))
  {
     
    areaData = LowLevelAreaInfo(node);
    double tmp = areaData->GetArea();
    tmp -= area_mean;  
    tmp *= tmp;  
    area_total += tmp;  
     
    float tmploads = areaData->GetLoadNum();
    tmploads -= loads_mean;  
    tmploads *= tmploads;  
    loads_total += tmploads;  
  }
   
  if (cntr > 1)
  {
    area_total = area_total / (cntr - 1);  
    loads_total = loads_total / (cntr - 1);
  }
  standard_dev = sqrt(area_total);  
  std_load_dev = sqrt(loads_total);
  PrintAreaInfo(LowLevelAreaInfo, minAreaData, maxAreaData, area_mean, 
                standard_dev, minLoad, maxLoad, std_load_dev);
   
  for (node = LowLevelAreaInfo.first(); node; LowLevelAreaInfo.next(node))
  {
    delete LowLevelAreaInfo(node);
  }
  return 1;
}

 
 
 
 
 
 
 
 
 
void Clock::Modify_Clock(SLList<AddNode *> add_circuit, 
                         SLList<ReAttachNode *> reattach_circuit, 
                         struct def_database_info_structure *&defdb)
{
  Pix node, Nnode, Pnode;
  int found_load = 1;
  AttachNode *inst;
  SLList<AttachNode *> attach_circuit;
  
  attach_circuit.clear();

  for (node = reattach_circuit.first(); node; reattach_circuit.next(node)) {
    ReAttachNode *reattnode = reattach_circuit(node);

    AttachNode *attnode = new AttachNode(reattnode->GetNetName(),
                                         reattnode->GetInstName(),
                                         reattnode->GetPinName());

    cout << "MC " << reattnode->GetNetName() << " " 
         << reattnode->GetInstName() << endl;

    logfile << "!MC " << reattnode->GetNetName() << " " 
            << reattnode->GetInstName() << endl;

    attach_circuit.append(attnode);
  }

  for (node = add_circuit.first(); node; add_circuit.next(node)) {
    AddNode *addnode = add_circuit(node);
    AttachNode *attanode = new AttachNode(addnode->GetNetName(),
                                          addnode->GetInstName(),
                                          addnode->GetPinName());
    attach_circuit.append(attanode);
  }


  
  struct def_pin_info_structure *pin_tmp;
  SLList<struct def_pin_info_structure *> tmppinPtrs = pinPtrs;
  SLList<struct def_component_info_structure *> tmploadPtrs = loadPtrs;

  for (Pnode = tmppinPtrs.first(); Pnode; tmppinPtrs.next(Pnode)) {
    found_load = 0;
    pin_tmp = tmppinPtrs(Pnode);

    struct def_component_info_structure *load;
    for(node = tmploadPtrs.first(); node; tmploadPtrs.next(node)) {
      load = tmploadPtrs(node);

      if (!(strcmp(load->def_comp_name,pin_tmp->def_pin_comp_name))) {
	found_load = 1;
        break;
      } 
    }

    if (found_load) {
      found_load = 0;
      for(Nnode = attach_circuit.first(); Nnode; attach_circuit.next(Nnode)) {
	inst = attach_circuit(Nnode);
	if (!strcmp(inst->GetInstName(), load->def_comp_name) &&
	    !strcmp(inst->GetPinName(), pin_tmp->def_pin_name)) {
	  
	  cout << "I found inst " << inst->GetInstName() << " "
	       << inst->GetNetName() << " " << inst->GetPinName() << endl;
	  found_load = 1;
	  break;
	}
      }
    }

    if (found_load) {
      cout << "Removing data for:" << endl;
      cout << " " << inst->GetInstName() << " " << inst->GetNetName() << " "
           << inst->GetPinName() << endl;
      cout << " " << pin_tmp->def_pin_comp_name << " " 
	   << pin_tmp->def_pin_net_name 
           << " " << pin_tmp->def_pin_name << endl;

       
      Remove_Inst_ClkNet(load, defdb, inst, 0);
      Attach_Inst_SubClkNet(load, inst, defdb, pin_tmp);
    }
  }
}  

 
 
 
 
 
 
 
 
void Clock::Add_Load(struct def_component_info_structure *compData) 
{
  loadCntr++;

  struct def_component_info_structure *newComp = ((struct def_component_info_structure *) malloc (sizeof(struct def_component_info_structure)));
  def_init_ptr((void *)newComp,3);
  newComp->def_comp_name = lib_store(compData->def_comp_name);
  newComp->def_comp_model_name = lib_store(compData->def_comp_model_name);
  loadPtrs.append(newComp);

   
}

 
 
 
 
 
 
 
 
 
int Clock::Attach_Inst_Clk(SLList<Clock *> SubClks, AttachNode *crct,
                                                         struct def_component_info_structure *load)
{
  ClockIter *clockList = new ClockIter(SubClks);
  Clock *tmpclk = clockList->Reset();
  int load_found = 0;

  while (tmpclk) {

    if(tmpclk->GetNetName() == crct->GetNetName()) {

      SLList<struct def_component_info_structure *> loadptrs = tmpclk->RetLoadPtrs(); 
      for(Pix node = loadptrs.first(); node; loadptrs.next(node)) {
        struct def_component_info_structure *cmp = loadptrs(node);
        if (strcmp(cmp->def_comp_name, load->def_comp_name) == 0) {
          load_found = 1;
          break;
        }
      }
      if (!load_found) {
        tmpclk->Add_Load(load);
      }
      delete clockList;
      return 1;  
    } else {
      if (tmpclk->RetSubClkPtrs().first()) {
        tmpclk->Attach_Inst_Clk(tmpclk->RetSubClkPtrs(), crct, load);
        tmpclk = clockList->GetNextClock();
      } else {
        tmpclk = clockList->GetNextClock();
      }
    }
  }

  if (clockList) {
    delete clockList;
  }
}
  
 
 
 
 
 
 
 
 
 
void Clock::Attach_Inst_SubClkNet(struct def_component_info_structure *load, AttachNode *ccircuit,
                                  struct def_database_info_structure *&defdb, struct def_pin_info_structure *oldPin)
{

  Attach_Inst_Clk(SubClocks, ccircuit, load);

  struct list_structure *lptr, *lptr2, *lptr3, **lptr_h, **lptr_t;

  for (lptr2 = defdb->def_sections_h; lptr2; lptr2 = ((lptr2)->list_next)) {
    struct def_data_section_structure *sect_ptr = (struct def_data_section_structure *)((lptr2)->list_data);
    if (sect_ptr->def_sect_type == 4 ||
        sect_ptr->def_sect_type == 3) {
      if (strstr(ccircuit->GetNetName(), netName) != 0L) {
         
        for(lptr=sect_ptr->def_sect_list_h; lptr; lptr = ((lptr)->list_next)) {
          int found_instname = 0;
          struct def_net_info_structure *net = (struct def_net_info_structure *)((lptr)->list_data);
          if (!strcmp(net->def_net_name, ccircuit->GetNetName())) {
            for(lptr3 = net->def_net_pins_h; lptr3; lptr3 = ((lptr3)->list_next)) {
              struct def_pin_info_structure *cmp = (struct def_pin_info_structure *)((lptr3)->list_data);
              if (strstr(ccircuit->GetInstName(),cmp->def_pin_comp_name)!=0L) {
                found_instname = 1;
                break;
              }
            }
            if (!found_instname) {
              lptr_h = &net->def_net_pins_h;
              lptr_t = &net->def_net_pins_t;
               
	      cout << "Add a pin to net " << net->def_net_name << " ";
	      logfile << "!Add a pin to net " << net->def_net_name << " ";
	      if (oldPin) {
		cout << ccircuit->GetInstName() << "." ;
		cout << oldPin->def_pin_name << endl;
		logfile << ccircuit->GetInstName() << "." ;
		logfile << oldPin->def_pin_name << endl;
	      } else {
		cout << ccircuit->GetInstName() << "." << endl;
		cout << "OldPin is null!?" << endl;
		logfile << ccircuit->GetInstName() << "." << endl;
		logfile << "OldPin is null!?" << endl;
	      }

	      struct def_pin_info_structure *pinptr = ((struct def_pin_info_structure *) malloc (sizeof(struct def_pin_info_structure)));
              def_init_ptr((void *)pinptr,15);

	      if (oldPin) {
		pinptr->def_pin_name = lib_store(oldPin->def_pin_name);
		pinptr->def_pin_comp_name = lib_store(oldPin->def_pin_comp_name);
	      }
              pinptr->def_pin_net_name = lib_store(net->def_net_name);
              pinptr->def_pin_net_ptr = net;
	      
              mms_list_append(lptr_h, lptr_t, pinptr);
            }
          }
        }
      }
    }
  }
}



































 

 
 
 
 
 
 
 
 
void Clock::Remove_Inst_ClkNet(struct def_component_info_structure *load, struct def_database_info_structure *&defdb,
                               AttachNode *ccircuit, struct def_pin_info_structure *pinPtr)
{
  struct def_component_info_structure *prevload;

  for (Pix node = loadPtrs.first(); node; loadPtrs.next(node)) {
    struct def_component_info_structure *tmpload = loadPtrs(node);
    if (!strcmp(load->def_comp_name,tmpload->def_comp_name)) {
      if (node == loadPtrs.first()) {
        loadPtrs.del_front();
      } else {
        loadPtrs.del_after(prevload);
      }
      loadCntr--;
      break;
    }
    prevload = tmpload;
  }

  struct list_structure *lptr3, *lptr2, *lptr, **lptr_h, **lptr_t;

  for(lptr3 = defdb->def_sections_h; lptr3; lptr3 = ((lptr3)->list_next)) {
    struct def_data_section_structure *sect_ptr = (struct def_data_section_structure *)((lptr3)->list_data);
    if (sect_ptr->def_sect_type == 4 ||
        sect_ptr->def_sect_type == 3) {

      for(lptr=sect_ptr->def_sect_list_h; lptr; lptr=((lptr)->list_next)) {
        struct def_net_info_structure *net = (struct def_net_info_structure *) ((lptr)->list_data);
        if (!strcmp(net->def_net_name, netName)) {

          for (lptr2 = net->def_net_pins_h; lptr2; lptr2 = ((lptr2)->list_next)) {
            struct def_pin_info_structure *cmp = (struct def_pin_info_structure *)((lptr2)->list_data);
            if (strstr(ccircuit->GetInstName(), cmp->def_pin_comp_name) != 0L) {
              lptr_h = &net->def_net_pins_h;
              lptr_t = &net->def_net_pins_t;
               

	      









 
	      cout << "Removed pin " << cmp->def_pin_comp_name << " " 
                   << cmp->def_pin_name << " from net " 
                   << net->def_net_name << endl;
	      logfile << "!Removed pin " << cmp->def_pin_comp_name << " " 
                      << cmp->def_pin_name << " from net " 
                      << net->def_net_name << endl;

              mms_list_remove(lptr_h, lptr_t, &(lptr2), 0);
              break;
            }
          }
        }
      }
    }
  }
}

void Clock::SetLoadPtrs(SLList<struct def_component_info_structure *>loads)
{
  loadPtrs = loads;
}


 

 
 
 
 
 
 


 
 
 
 
 
 
 
 
ClockIter::ClockIter()
{
  
}

 
 
 
 
 
 
 
 
ClockIter::ClockIter(const ClockIter &cIter)
{
  clockList = cIter.clockList;
  node = cIter.node;
}

 
 
 
 
 
 
 
 
const ClockIter &ClockIter::operator=(const ClockIter &cIter)
{
  clockList = cIter.clockList;
  node = cIter.node;
  return *this;
}

 
 
 
 
 
 
 
 
ClockIter::~ClockIter()
{
}

 
 
 
 
 
 
 
 
ClockIter::ClockIter(SLList<Clock *> &clocklist)
{
  clockList.clear();
  if (clocklist.first() != 0L)
  {
    clockList = clocklist;
  }
}

 
 
 
 
 
 
 
 
 
int ClockIter::IsLowerLevel()
{
  if (clockList.first() != 0L)
  {
    for(Pix nnode = clockList.first(); nnode; clockList.next(nnode))
    {
      Clock *ck = clockList(nnode);
      SLList<Clock *> subclklist = ck->RetSubClkPtrs();
      if(subclklist.first() != 0L)
      {
        return 1;
      }
    }
    return 0;
  }
  else return 0;
}

 
 
 
 
 
 
 
 
 
 
SLList<Clock *> ClockIter::GoDown()
{
  Clock *ck = clockList(clockList.first());
  return ck->RetSubClkPtrs();
}

 
 
 
 
 
 
 
 
 
 
int ClockIter::IsUpperLevel()
{
  if(clockList.first() != 0L)
  {
    Clock *ck = clockList(clockList.first());
    ck = ck->GetParent();
    if(ck->GetParent() == 0L)
    {
      return 0;
    }
    else
    {
      return 1;
    }
  }
  else return 0;
}

 
 
 
 
 
 
 
 
 
 
SLList <Clock *>ClockIter::GoUp(BString &clockname)
{
  Clock *ck = clockList(clockList.first());
  ck = ck->GetParent();
  clockname = ck->GetNetName();
  ck = ck->GetParent();
  return ck->RetSubClkPtrs();
}


 
 
 
 
 
 
 
 
 
Clock *ClockIter::GetNextClock() 
{
  clockList.next(node);
  if(node != 0L)
  {
    return clockList(node);
  }
  else 
  {
    return 0L;
  }
}

 
 
 
 
 
 
 
 
 
Clock *ClockIter::Reset()
{
    node = clockList.first();
    if (node != 0L)
    {
      return clockList(node);
    }
    else
    {
      return 0L;
    }
}


 
 
 
 
 
 
 
 
 

 
 
 
 
 
 
 
 
 
 
 
 
FormClock::FormClock(struct def_database_info_structure *def, const BString &clockname, 
                     ifstream &infile, const BString &drivername)
{
  BString loadName;
  struct def_component_info_structure *loadInfo;


  level = 0;
  Parent = 0L;
  SubClocks.clear();
  AllLoads.clear();
  defdb = def;
  netName = clockname;
  recieverName = "";
  if(drivername == " ")
  {
    char tmpdrivername[100];
    strcpy(tmpdrivername, netName);
    strcat(tmpdrivername, ".Z");
    driverName = tmpdrivername;
  }
  loadCntr = 0;

   
  while(infile)
  {
    infile >> loadName;
    AllLoads.append(loadName);
  }
  GetLoads();
  ClockIter *subclklist = GetSubClocks(this);
  if(subclklist)
  {
    level = SetLevel();
  }
  delete subclklist;
}

 
 
 
 
 
 
 
 
 
 
 
FormClock::FormClock(struct def_database_info_structure *def, const BString &clockname, 
                     const BString &drivername, const BString &rec_name,
                     FormClock *parent, const SLList<BString> &allLoads)
{
  AllLoads = allLoads;
  defdb = def;
  netName = clockname;
  recieverName = rec_name;
  driverName = drivername;
  Parent = parent;
  loadCntr = 0;
  GetLoads();
  ClockIter *subclklist = GetSubClocks(this);
  if(subclklist)
  {
    level = SetLevel();
  }
  delete subclklist;
}

 
FormClock::FormClock(const FormClock &s): Clock(s)
{
  AllLoads = s.AllLoads;
}

 
const FormClock &FormClock::operator=(const FormClock &s)
{
  Clock::operator = (s);
  AllLoads = s.AllLoads;
  return *this;
}

 
FormClock::~FormClock()
{
}

 
 
 
 
 
 
 
 
 
 
int FormClock::SetLevel()
{
  int tmplevel;
  
  if(SubClocks.first() != 0L)
  {
    Clock *clk = SubClocks(SubClocks.first());
    tmplevel = clk->Getlevel() + 1;
  }
  else
  {
    tmplevel = 1;
  }
  return tmplevel;
}

 
 
 
 
 
 
 
 
 
 
ClockIter *FormClock::GetSubClocks(FormClock *parnt) 
{
  struct list_structure *lptr;
  struct def_net_info_structure *net;
  struct def_component_info_structure *comp;
  struct def_pin_info_structure *pin;
  char Newnet[100], Newdrv[100], tmprec[100];
  char tmpdriverName[100];
  Clock *clk;
  int foundnet = 0;
  BString rec;
  
  for (int i = 0; i < 100; i++)
  {
    tmpdriverName[i] = '\0';
    Newnet[i] = '\0';
    Newdrv[i] = '\0';
  }
 if(driverName != " ")
  {
    strcpy(tmpdriverName, driverName);
    i=0;
    while(tmpdriverName[i] != '.')
    {
      i++;
    }
    tmpdriverName[i] = '\0';
  }
  else
  {
    strcpy(tmpdriverName, "");
  }
  if(Get_Net(lptr, net))
  {
    while(lptr)
    {
      Get_Inst(comp, lptr, pin);
      if(Inst_Is_Net(comp) && !(strcmp(comp->def_comp_name,tmpdriverName)==0)) 
      {
        struct list_structure *lptr1, *lptr2, *lptr3;
        struct def_net_info_structure *netinfo;
        foundnet = 0;
         
         
        for (lptr1 = defdb->def_sections_h; lptr1; lptr1 = ((lptr1)->list_next))
        {
          struct def_data_section_structure *sect_ptr = (struct def_data_section_structure *)((lptr1)->list_data);
          if (sect_ptr->def_sect_type == 4 ||
              sect_ptr->def_sect_type == 3) 
          {
            for (lptr2=sect_ptr->def_sect_list_h;lptr2;lptr2=((lptr2)->list_next))
            {
              struct def_net_info_structure *netinfo = (struct def_net_info_structure *)((lptr2)->list_data);
              if(strstr(netinfo->def_net_name, comp->def_comp_name) != 0L)
              {
                for(lptr3=netinfo->def_net_pins_h;lptr3;lptr3=((lptr3)->list_next))
                {
                  struct def_pin_info_structure *pininfo = (struct def_pin_info_structure *)((lptr3)->list_data);
                  if(strcmp(pininfo->def_pin_comp_name, 
                            comp->def_comp_name) == 0)
                  {
                    foundnet = 1;
                    strcpy(Newnet, netinfo->def_net_name);
                    strcpy(Newdrv, comp->def_comp_name);
                    strcat(Newdrv, ".");
                    strcat(Newdrv, pininfo->def_pin_name);
                    break;
                  }
                }
              }
            }
          }
        }
        if(foundnet)
        {
          strcpy(tmprec,pin->def_pin_comp_name);
          strcat(tmprec, ".");
          strcat(tmprec, pin->def_pin_name);
          rec = tmprec;
          clk = new FormClock(defdb, Newnet, Newdrv, rec, parnt, AllLoads);
          SubClocks.append(clk);
        }
      }
      lptr = ((lptr)->list_next);
    }
  }
  return new ClockIter(SubClocks);
}

 
 
 
 
 
 
 
 
 
 
int FormClock::Inst_Is_Net(struct def_component_info_structure *comp)
{
  for(Pix node = AllLoads.first(); node; AllLoads.next(node))
  {
    BString loadname = AllLoads(node);
    if(strcmp(loadname, comp->def_comp_name) == 0)
    {
      return 0;
    }
  }
  return 1;
}

 
 
 
 
 
 
 
 
ClockInfo::ClockInfo(const BString &netname, const BString &drivername, 
                     const BString &recievername, int Level, 
                     const BString &modelname, const BString &par,
                     const SLList<BString> &subclknames)
{
  parentName = par;
  netName = netname;
  driverName = drivername;
  recieverName = recievername;
  level = Level;
  modelName = modelname;
  subclkNames = subclknames;
}

 
ClockInfo::ClockInfo(const ClockInfo &S)
{
  netName = S.netName;
  driverName = S.driverName;
  modelName = S.modelName;
  level = S.level;
  subclkNames = S.subclkNames;
}

 
ClockInfo::~ClockInfo()
{
}

 
const ClockInfo &ClockInfo::operator=(const ClockInfo &S)
{
  netName = S.netName;
  driverName = S.driverName;
  modelName = S.modelName;
  level = S.level;
  subclkNames = S.subclkNames;
  return *this;
}

 
 
 
 
 
 
 
 
 
int ClockInfo::GetLevel() const
{
  return level;
}

 
 
 
 
 
 
 
 
 
BString ClockInfo::GetNetName() const
{
  return netName;
}

 
 
 
 
 
 
 
 
 
BString ClockInfo::GetDriverName() const
{
  return driverName;
}

 
 
 
 
 
 
 
 
 
BString ClockInfo::GetRecieverName() const
{
  return recieverName;
}

 
 
 
 
 
 
 
 
 
BString ClockInfo::GetModelName() const
{
  return modelName;
}
 
 
 
 
 
 
 
 
 
SLList<BString> ClockInfo::GetSubClkNames() const 
{
  return subclkNames;
}
 
 
 
 
 
 
 
 
 
BString ClockInfo::GetParentName() const
{
  return parentName;
}

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CreateClock::CreateClock(struct def_database_info_structure *&defdeb,
                         const SLList<BString> &netnames, 
                         const BString &drivername, int Level, 
                         const BString &netname, 
                         const SLList <BString> &modelnames, int clknums[],
                         const BString &input_pin, const BString &output_pin)
{
  char tmpdriverName[100];
  int i = 0, j = 0;
  defdb = defdeb;
  netName = netname;
  recieverName = "";
  
  if(driverName != " ")
  {
    strcpy(tmpdriverName, drivername);
    strcat(tmpdriverName, ".");
    strcat(tmpdriverName, output_pin);
    driverName = tmpdriverName;
  }
  else
  {
    driverName = drivername;
  }
  level = Level;
  modelName = " ";
  Parent = 0L;
  loadCntr = 0;
  mainclockName = netname;

  CreateInfoList(netnames, input_pin, output_pin, modelnames, clknums);

  ClockInfo *clkinfo;
  Pix nnode, nd;

  for(Pix node = InfoList.first(); node; InfoList.next(node))
  {
    clkinfo = InfoList(node);
    if (clkinfo->GetNetName() == netName)
    {
      break;
    }
  }
  SLList<BString> subclknames = clkinfo->GetSubClkNames();
  for(node = subclknames.first(); node; subclknames.next(node))
  {
    BString subclkname = subclknames(node);
    for(nnode = InfoList.first(); nnode; InfoList.next(nnode))
    {
      ClockInfo *clockinfo = InfoList(nnode);
      if(strstr(clockinfo->GetNetName(), subclkname) != 0L)
      {
        BString Netname = clockinfo->GetNetName();
        BString Modelname = clockinfo->GetModelName();
        int Level = clockinfo->GetLevel();
        BString Drivername = clockinfo->GetDriverName();
        BString Recievername = clockinfo->GetRecieverName();
        CreateClock *createclock = new CreateClock(defdb, Netname, 
                                                   Drivername,Recievername,
                                                   Level,Modelname, this, 
                                                   InfoList);
        SubClocks.append(createclock);
        break;
      }
    }
  }
   
  SLList<Clock *> lowclks;
  SLList<BString> lownames;
  SLList <Clock *> tc = SubClocks;
  ClockIter *subclksiter = new ClockIter(tc);
  int finished = 0;
  BString CurrentClkName;

  lowclks.clear();
  lownames.clear();

  if(subclksiter->Reset())
  {
    while(!finished)
    {
      while(subclksiter->IsLowerLevel())
      {
        tc = subclksiter->GoDown();
        subclksiter = new ClockIter(tc);
      }
      Clock *clk = subclksiter->Reset();
      while(clk)
      {
        lowclks.append(clk);
        lownames.append(clk->GetNetName());
        clk = subclksiter->GetNextClock();    
      }
      int end_of_list = 1;
      while(end_of_list)
      {
        if(subclksiter->IsUpperLevel())
        {
          tc = subclksiter->GoUp(CurrentClkName);
          subclksiter = new ClockIter(tc);
          clk = subclksiter->Reset();
          while(clk->GetNetName() != CurrentClkName)
          {
            clk = subclksiter->GetNextClock();
          }
          clk = subclksiter->GetNextClock();
          if(clk == 0L)
          {
            end_of_list = 1;
          }
          else
          {
            SLList <Clock *> tc = clk->RetSubClkPtrs();
            subclksiter = new ClockIter(tc);
            end_of_list = 0;
          }
        }
        else
        {
          end_of_list = 0;
          finished = 1;
        }
      }
    }
  }
   
  Clock *clock;
  SquarePartition *sqr_part = new SquarePartition(mainclockName, defdb, 
                                                  clknums[1]);
  SLList<BString> loadnames = sqr_part->GetLoadNames();
  if(loadnames.first() == 0L)
  {
    cout << "No Loads found for clock: " << netName << endl;
    logfile << "!No Loads found for clock: " << netName << endl;    
    delete this;
    return;
  }
  SLList<Coordinates *> coordlist = sqr_part->GetCoordList();
  AdjacentPlacement *adj_place = new AdjacentPlacement(coordlist, defdb, 
                                                       loadnames, lownames);
  SLList<Block *>blocks = adj_place->GetBlocks();
  BString clk_name;
  Block *block;
  for(node = lowclks.first(); node; lowclks.next(node))
  {
    clock = lowclks(node);
    clk_name = clock->GetNetName();

    for(nd = blocks.first(); nd; blocks.next(nd))
    {
      block = blocks(nd);
      if(clk_name == block->GetNetName())
      {
        clock->SetLoadPtrs(block->GetLoads());
        break;
      }
    }
  }

   
  struct list_structure *lptr, *lptr2, *lptr3, **lptr_h, **lptr_t;
  struct def_data_section_structure *sect_ptr;
  struct def_net_info_structure *netinfo;
  struct def_component_info_structure *compinfo;
  struct def_pin_info_structure *pininfo;
  SLList <struct def_pin_info_structure *>pinlist;
  char tmpstring[100];
  pinlist.clear();
  int net_found = 0;
   
  
   
  for(lptr = defdb->def_sections_h; lptr; lptr = ((lptr)->list_next))
  {
    sect_ptr = (struct def_data_section_structure *) ((lptr)->list_data);
    if(sect_ptr->def_sect_type == 4 || 
       sect_ptr->def_sect_type == 3)
    {
      for(lptr2 = sect_ptr->def_sect_list_h; lptr2; lptr2 = ((lptr2)->list_next))
      {
        netinfo = (struct def_net_info_structure *) ((lptr2)->list_data);
        if(strcmp(netinfo->def_net_name,mainclockName) == 0)
        { 
          lptr3 = netinfo->def_net_pins_h;
          while(lptr3)
          { 
            pinlist.append((struct def_pin_info_structure *)((lptr3)->list_data));
            lptr_h = &netinfo->def_net_pins_h;
            lptr_t = &netinfo->def_net_pins_t;
            mms_list_remove(lptr_h, lptr_t, &(lptr3), 0);
            lptr3 = netinfo->def_net_pins_h;
          }
        }
      }
    }
  }
   
  for(lptr = defdb->def_sections_h; lptr; lptr = ((lptr)->list_next))
  {
    sect_ptr = (struct def_data_section_structure *) ((lptr)->list_data);
    if(sect_ptr->def_sect_type == 4 || 
       sect_ptr->def_sect_type == 3)
    {
      for(lptr2 = sect_ptr->def_sect_list_h; lptr2; lptr2 = ((lptr2)->list_next))
      {
        netinfo = (struct def_net_info_structure *) ((lptr2)->list_data);
        if(strcmp(netinfo->def_net_name,mainclockName) == 0)
        { 
          lptr_h = &netinfo->def_net_pins_h;
          lptr_t = &netinfo->def_net_pins_t;
          pininfo = ((struct def_pin_info_structure *) malloc (sizeof(struct def_pin_info_structure)));
          def_init_ptr((void *)pininfo,15);
          strcpy(tmpstring, driverName);
          while(tmpstring[i] != '\0' && tmpstring[i] != '.')
          {
            i++;
          }
          tmpstring[i] = '\0';
          pininfo->def_pin_comp_name = lib_store(tmpstring);
          strcpy(tmpstring, output_pin);
          pininfo->def_pin_name = lib_store(tmpstring);
          mms_list_append(lptr_h, lptr_t, pininfo);
          break;
        }
      }
    }
  }  
  SLList<struct def_net_info_structure *>parentinfolist;
  parentinfolist.clear();
  struct def_net_info_structure *parentinfo;
   
  tc = SubClocks;
  subclksiter = new ClockIter(tc);
  clock = subclksiter->Reset();
  for(lptr = defdb->def_sections_h; lptr; lptr = ((lptr)->list_next))
  {
    sect_ptr = (struct def_data_section_structure *) ((lptr)->list_data);
    if(sect_ptr->def_sect_type == 4 || 
       sect_ptr->def_sect_type == 3)
    {
      for(lptr2 = sect_ptr->def_sect_list_h; lptr2; lptr2 = ((lptr2)->list_next))
      {
        netinfo = (struct def_net_info_structure *) ((lptr2)->list_data);
        if(netinfo->def_net_name == mainclockName)
        {  
          parentinfolist.append(netinfo);
        }
      }
    }
  }

  int done_iterating = 0;
  while(clock)
  {   
    while(clock)
    {
      for(lptr = defdb->def_sections_h; lptr; lptr = ((lptr)->list_next))
      {
        sect_ptr = (struct def_data_section_structure *) ((lptr)->list_data);
        if(sect_ptr->def_sect_type == 4 || 
           sect_ptr->def_sect_type == 3)
        {
           
          i = 0, j = 0;
          char tmpcompstring[100];
          lptr_h = &sect_ptr->def_sect_list_h;
          lptr_t = &sect_ptr->def_sect_list_t;
          netinfo = ((struct def_net_info_structure *) malloc (sizeof(struct def_net_info_structure)));
          def_init_ptr((void *)netinfo, 8);
          for(i = 0; i < 100; i++)
          {
            tmpstring[i] = '\0';
            tmpcompstring[i] = '\0';
          }
          i = 0;
          strcpy(tmpstring, clock->GetNetName());
          netinfo->def_net_name = lib_store(tmpstring);
          mms_list_append(lptr_h, lptr_t, netinfo);
           
          while(mainclockName[i] == tmpstring[i])
          {
            i++;
          }
          i++;
          while(tmpstring[i] != '\0')
          {
            tmpcompstring[j++] = tmpstring[i++];
          }
          pininfo = ((struct def_pin_info_structure *) malloc (sizeof(struct def_pin_info_structure)));
          def_init_ptr((void *)pininfo,15);
          pininfo->def_pin_comp_name = lib_store(tmpcompstring);
          for(i = 0; i < 100; i++)
          {
            tmpstring[i] = '\0';
          }
          strcpy(tmpstring, output_pin);
          pininfo->def_pin_name = lib_store(tmpstring);
          lptr_h = &netinfo->def_net_pins_h;
          lptr_t = &netinfo->def_net_pins_t;
          mms_list_append(lptr_h, lptr_t, pininfo);

           
          pininfo = ((struct def_pin_info_structure *) malloc (sizeof(struct def_pin_info_structure)));
          def_init_ptr((void *)pininfo,15);      
          pininfo->def_pin_comp_name = lib_store(tmpcompstring);
          strcpy(tmpstring, input_pin);
          pininfo->def_pin_name = lib_store(tmpstring);
           
          for(node = parentinfolist.first(); node; parentinfolist.next(node))
          {
            parentinfo = parentinfolist(node);
            lptr_h = &parentinfo->def_net_pins_h;
            lptr_t = &parentinfo->def_net_pins_t;
            mms_list_append(lptr_h, lptr_t, pininfo);
          }
                 
           

           
          for(i = 0; i < 100; i++)
          {
            tmpstring[i] = '\0';
          }
          strcpy(tmpstring, clock->GetModelName());   
          compinfo = ((struct def_component_info_structure *) malloc (sizeof(struct def_component_info_structure)));
          def_init_ptr((void *) compinfo, 3);
          compinfo->def_comp_name = lib_store(tmpcompstring);
          compinfo->def_comp_model_name = lib_store(tmpstring);
          for(lptr2 = defdb->def_sections_h; lptr2; lptr2 = ((lptr2)->list_next))
          {
            sect_ptr = (struct def_data_section_structure *) ((lptr2)->list_data);
            if(sect_ptr->def_sect_type == 2)
            { 
               lptr_h = &sect_ptr->def_sect_list_h;
               lptr_t = &sect_ptr->def_sect_list_t;
               mms_list_append(lptr_h, lptr_t, compinfo);
               break;
            }
          }   
          break;
        }
      }
      clock = subclksiter->GetNextClock();
    }
    
    if(!subclksiter->IsLowerLevel())
    {
      do
      {
        if(!subclksiter->IsUpperLevel())
        {
          done_iterating = 1;
          break;
        }
        tc = subclksiter->GoUp(CurrentClkName);
        subclksiter = new ClockIter(tc);
        clock = subclksiter->Reset();
        while(clock->GetNetName() != CurrentClkName)
        {
          clock = subclksiter->GetNextClock();
        }
        clock = subclksiter->GetNextClock();
      } while(!clock);
    }
    else
    {
      clock = subclksiter->Reset();
    }
    if(!done_iterating)
    {
      tc = clock->RetSubClkPtrs();
      subclksiter = new ClockIter(tc);
       
      clock = subclksiter->Reset();
      Clock *parclk = clock->GetParent();
      BString parname = parclk->GetNetName();
      parentinfolist.clear();
      net_found = 0;
      for(lptr = defdb->def_sections_h; lptr; lptr = ((lptr)->list_next))
      {
        sect_ptr = (struct def_data_section_structure *) ((lptr)->list_data);
        if(sect_ptr->def_sect_type == 4 || 
           sect_ptr->def_sect_type == 3)
        {
          for (lptr2=sect_ptr->def_sect_list_h;lptr2;lptr2=((lptr2)->list_next))
          {
            netinfo = (struct def_net_info_structure *)((lptr2)->list_data);
            if(strcmp(netinfo->def_net_name, parname) == 0)
            {
              parentinfolist.append(netinfo);
              net_found = 1;
              break;
            }
          }
        }
        if(net_found)
        {
          break;
        }
      }
    }
  }
   
  for(node = blocks.first(); node; blocks.next(node))
  {
    block = blocks(node);
    clk_name = block->GetNetName();
    for(lptr = defdb->def_sections_h; lptr; lptr = ((lptr)->list_next))
    {
      sect_ptr = (struct def_data_section_structure *) ((lptr)->list_data);
      if(sect_ptr->def_sect_type == 4 || 
         sect_ptr->def_sect_type == 3)
      {
        net_found = 0;
        for(lptr2 = sect_ptr->def_sect_list_h; lptr2; lptr2 = ((lptr2)->list_next))
        {
          netinfo = (struct def_net_info_structure *)((lptr2)->list_data);
          if(strcmp(netinfo->def_net_name, clk_name) == 0)
          {
            SLList<struct def_component_info_structure *> loads = block->GetLoads();
            for(nnode = loads.first(); nnode; loads.next(nnode))
            {
              compinfo = loads(nnode);
              for(nd = pinlist.first(); nd; pinlist.next(nd))
              {
                pininfo = pinlist(nd);
                if(strcmp(pininfo->def_pin_comp_name, 
                          compinfo->def_comp_name) == 0)
                {
                  lptr_h = &netinfo->def_net_pins_h;
                  lptr_t = &netinfo->def_net_pins_t;
                  mms_list_append(lptr_h, lptr_t, pininfo);
                  break;
                }
              }
            }
            net_found = 1;
            break;
          }
          if(net_found)
          {
            net_found = 0;
            break;
          }
        }
      }
    }
  }
}

 
 
 
 
 
 
 
 
 
 
 
 
 
CreateClock::CreateClock(struct def_database_info_structure *defdeb, const BString &netname, 
                         const BString &drivername, const BString &recname,
                         int Level, 
                         const BString &modelname, CreateClock *parent, 
                         SLList<ClockInfo *> InfoList)
{
  defdb = defdeb;
  netName = netname;
  driverName = drivername;
  recieverName = recname;
  level = Level;
  modelName = modelname;
  Parent = parent;
  loadCntr = 0;
  
  ClockInfo *clkinfo;

  for(Pix node = InfoList.first(); node; InfoList.next(node))
  {
    clkinfo = InfoList(node);
    if (clkinfo->GetNetName() == netName)
    {
      break;
    }
  }
  SLList<BString> subclknames = clkinfo->GetSubClkNames();
  for(node = subclknames.first(); node; subclknames.next(node))
  {
    BString subclkname = subclknames(node);
    for(Pix nnode = InfoList.first(); nnode; InfoList.next(nnode))
    {
      ClockInfo *clockinfo = InfoList(nnode);
      if(strstr(clockinfo->GetNetName(), subclkname) != 0L)
      {
        BString Netname = clockinfo->GetNetName();
        BString Modelname = clockinfo->GetModelName();
        int Level = clockinfo->GetLevel();
        BString Drivername = clockinfo->GetDriverName();
        BString Recievername = clockinfo->GetRecieverName();
        CreateClock *createclock = new CreateClock(defdb, Netname, 
                                                   Drivername, Recievername, 
                                                   Level,Modelname, this, 
                                                   InfoList);
        SubClocks.append(createclock);
        break;
      }
    }
  }
}

 
CreateClock::CreateClock(const CreateClock &S): Clock(S)
{
  modelName = S.modelName;
  InfoList = S.InfoList;
}

 
CreateClock::~CreateClock()
{
}

 
const CreateClock &CreateClock::operator=(const CreateClock &S)
{
  Clock::operator = (S);
  modelName = S.modelName;
  InfoList = S.InfoList;
  return *this;
}

 
 
 
 
 
 
 
 
 
 
 
void CreateClock::CreateInfoList(const SLList<BString> &netnames, 
                                 const BString &in_pin, const BString &out_pin,
                                 const SLList<BString> &modelnames,  
                                 int clknums[])
{
  int Level = level;
  BString parent, RootName, modelname, tmp_netName, Drivername, Recievername;
  int subclocknumber = 0;
  ClockInfo *lastclock;
  SLList<BString> subclknames;
  char tmp_clocknum[100], tmp_netname[100];
  Pix netname_node = netnames.first(), subnet_node = netnames.first(); 
  Pix modelname_node = modelnames.first(), node;
  double remander = 0;
 
   
  clknums[Level] = 1;
  InfoList.clear();
  parent = " ";
  RootName = netName;
  modelname = " ";
  subclknames.clear();

   
  subclocknumber = clknums[Level - 1] / clknums[Level];
  int counter = 0;
  while(subclocknumber > counter)
  {
    counter++;
    for (int j = 0; j < 100; j++)
    {
      tmp_netname[j] = '\0';
      tmp_clocknum[j] = '\0';
    }
    tmp_netName = netnames(netname_node);
    strcpy(tmp_netname, tmp_netName);
    gcvt(counter,4,tmp_clocknum);
    strcat(tmp_netname, "-");
    strcat(tmp_netname, tmp_clocknum);
    tmp_netName = tmp_netname;
    subclknames.append(tmp_netName);
  }
  ClockInfo *clkinfo = new ClockInfo(netName, driverName, "", Level, modelname,
                                     parent, subclknames);
  InfoList.append(clkinfo);
  
  int clocksuffix = 1;
  int clockposition = 0;
  int prevLevel = Level - 1;
  subclknames.clear();
  netnames.next(subnet_node);
   
  for(node = InfoList.first(); node; InfoList.next(node))
  {
    ClockInfo *clkInfo = InfoList(node);
    subclknames = clkInfo->GetSubClkNames();
    Level = clkInfo->GetLevel() - 1;
    if(Level != prevLevel)
    {
      netnames.next(netname_node);
      netnames.next(subnet_node);
      modelnames.next(modelname_node);
      prevLevel = Level;
      clockposition = 0;
      clocksuffix = 1;
    }
    for (Pix nnode = subclknames.first(); nnode; subclknames.next(nnode))
    {
      clockposition++;
      subclocknumber = clknums[Level - 1] / clknums[Level];
      remander = fmod(clknums[Level-1], clknums[Level]);
      if(remander >= clockposition)
      {
        subclocknumber = subclocknumber + 1;
      }
       
      char tmpname[100];
      for(int k=0; k < 100; k++)
      {
        tmpname[k] = '\0';
      }
      strcpy(tmpname, subclknames(nnode));
      strcat(tmpname, ".");
      strcat(tmpname, out_pin);
      Drivername = tmpname;
      for(k=0; k < 100; k++)
      {
        tmpname[k] = '\0';
      }
      strcpy(tmpname, subclknames(nnode));
      strcat(tmpname, ".");
      strcat(tmpname, in_pin);
      Recievername = tmpname;
      tmp_netName = subclknames(nnode);
      strcpy(tmp_netname, RootName);
      strcat(tmp_netname, "-");
      strcat(tmp_netname, tmp_netName);
      tmp_netName = tmp_netname;
       
      parent = clkInfo->GetNetName();
       
      modelname = modelnames(modelname_node);
       
      SLList<BString> subsubclknames;
      subsubclknames.clear();
      if(Level > 1)
      {
        counter = 0;
        while(subclocknumber > counter)
        {
          counter++;
          strcpy(tmp_netname, netnames(subnet_node));
          gcvt(clocksuffix, 4, tmp_clocknum);
          strcat(tmp_netname, "-");
          strcat(tmp_netname, tmp_clocknum);
          BString string = tmp_netname;
          subsubclknames.append(string);
          clocksuffix++;
        }
      }
       
      clkinfo = new ClockInfo(tmp_netName, Drivername, Recievername, Level, 
                              modelname, parent, subsubclknames);
      InfoList.append(clkinfo);
    }
  }
}














T.RTitleUserPersonal
Name
DateLines
3519.1Appears to be fixed in development compilersDECC::SULLIVANJeff SullivanTue Apr 01 1997 15:405
I was able to reproduce the compiler crash using DEC C++ V5.5-004 on Digital
UNIX V4.0. It appears to be fixed in a later compiler. If this problem is
holding you up, let us know and perhaps we can offer a solution.

-Jeff
3519.2New compiler and/or helpASIC::SNYDERWed Apr 02 1997 14:4511
    We were under the impression that V5.5-004 was the latest-and-greatest
    compiler version.  We just had our system upgraded.  If this is not the
    most recent version, please give me some details so I can have our
    system administrator perform an update.
    
    If there isn't a more recent official compiler release, I would
    definitely want some suggestions.
    
    Thanks.
    
    -Ryan
3519.3Fixed in DEC C++ T5.6, coming soonDECC::SULLIVANJeff SullivanWed Apr 16 1997 14:5623
This problem is fixed in DEC CXX T5.6-002, which should be announced in this
conference shortly. This is a field test compiler and you are correct that
V5.5-004 is the most recent official compiler release.

Below is my test case:

% cxx -c cpp_3519.cxx
% cxx -V
cxx  (cxx)
DEC CXX T5.6-002 on Digital UNIX (Alpha)

$ cxx -c cpp_3519.cxx
cxx: Fatal: A memory access violation (bus error or segmentation fault)
has occurred.  Please submit a problem report.
$ cxx -V
cxx  (cxx)
DEC C++ V5.5-004 on Digital UNIX (Alpha)

I will add your test to our regression test system, so that we'll know if it
reappears in the future.

Thanks,
-Jeff
3519.4The line that causes crash...DECC::SULLIVANJeff SullivanWed Apr 16 1997 15:4918
Fwiw...
The problem is with this line in the test case:

#ifdef BUG
 void GetBlockInfo(SLList<Distance_Node *> &, SLList<Distance_Node *> &,
                   SLList<Block *>Blocks, struct def_database_info_structure *);
#endif


% cxx -c cpp_3519.cxx
% cxx -c cpp_3519.cxx -DBUG
cxx: Fatal: A memory access violation (bus error or segmentation fault)
has occurred.  Please submit a problem report.


I will add this test as regression test c_plus_plus_3519

-Jeff