From: schmidt@net1.ics.uci.edu (Douglas C. Schmidt)
Newsgroups: gnu.g++.bug
Subject: internal compiler error
Date: 25 Jan 1993 21:29:24 -0500
Organization: GNUs Not Usenet
Distribution: gnu

Hi,

	The following file causes gcc 2.3.3 to fail on both Solaris
2.1 and Sun OS 4.1.2.

	Doug

----------------------------------------
% gcc -v x.C
Reading specs from /opt/gnu/lib/gcc-lib/sparc-sun-solaris2/2.3.3/specs
gcc version 2.3.3
 /opt/gnu/lib/gcc-lib/sparc-sun-solaris2/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsun -Dsparc -Dunix -D__svr4__ -D__sun__ -D__sparc__ -D__unix__ -D__svr4__ -D__sun -D__sparc -D__unix -D__svr4__ -Asystem(unix) -Acpu(sparc) -Amachine(sparc) x.C /i0/da/ud/schmidt/.trash/cca001nS.i
GNU CPP version 2.3.3 (sparc)
 /opt/gnu/lib/gcc-lib/sparc-sun-solaris2/2.3.3/cc1plus /i0/da/ud/schmidt/.trash/cca001nS.i -quiet -dumpbase x.cc -version -fdelayed-branch -fstrength-reduce -finline-functions -o /i0/da/ud/schmidt/.trash/cca001nS.s
GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
x.C:0: warning: destructor `Local_IPC_SAP_Listener::~Local_IPC_SAP_Listener ()' non-virtual
x.C:1913: warning: in inheritance relationship `Handle_L_Stream: Local_IPC_SAP_Listener'
x.C:0: warning: destructor `Local_IPC_SAP_Dgram::~Local_IPC_SAP_Dgram ()' non-virtual
x.C:1943: warning: in inheritance relationship `Handle_L_Dgram: Local_IPC_SAP_Dgram'
x.C:0: warning: destructor `Local_IPC_SAP_CODgram::~Local_IPC_SAP_CODgram ()' non-virtual
x.C:1968: warning: in inheritance relationship `Handle_L_CODgram: Local_IPC_SAP_CODgram'
x.C:0: warning: destructor `Local_IPC_SAP_Listener::~Local_IPC_SAP_Listener ()' non-virtual
x.C:1979: warning: in inheritance relationship `Handle_L_Pipe: Local_IPC_SAP_Listener'
x.C:0: warning: destructor `IPC_SAP_Listener::~IPC_SAP_Listener ()' non-virtual
x.C:2076: warning: in inheritance relationship `Handle_R_Stream: IPC_SAP_Listener'
x.C:0: warning: destructor `IPC_SAP_Dgram::~IPC_SAP_Dgram ()' non-virtual
x.C:2087: warning: in inheritance relationship `Handle_R_Dgram: IPC_SAP_Dgram'
x.C:0: warning: destructor `IPC_SAP_Dgram::~IPC_SAP_Dgram ()' non-virtual
x.C:2096: warning: in inheritance relationship `Handle_Broadcast: IPC_SAP_Dgram'
x.C: In function `void  _GLOBAL_.I.local_stream ()':
x.C:2161: Internal compiler error.
x.C:2161: Please report this to `bug-g++@prep.ai.mit.edu'.
----------------------------------------

extern "C" {
typedef struct  _physadr { int r[1]; } *physadr;
typedef	struct	_label_t { int	val[2]; } label_t;
typedef	unsigned char	lock_t;
}
extern "C" {
typedef	unsigned char	uchar_t;
typedef	unsigned short	ushort_t;
typedef	unsigned int	uint_t;
typedef	unsigned long	ulong_t;
typedef	char *		caddr_t;
typedef	long		daddr_t;
typedef	long		off_t;
typedef	short		cnt_t;
typedef	ulong_t		paddr_t;
typedef	uchar_t		use_t;
typedef	short		sysid_t;
typedef	short		index_t;
typedef enum boolean { B_FALSE, B_TRUE } boolean_t;
typedef	union {
	long	l[2];
	double	d;
} longlong_t;
typedef	union {
	unsigned long	l[2];
	double		d;
} u_longlong_t;
typedef	longlong_t	offset_t;
typedef	longlong_t	diskaddr_t;
typedef union lloff {
	offset_t	_f;
	struct {
		long _u;
		off_t _l;
	} _p;
} lloff_t;
typedef union lldaddr {
	diskaddr_t	_f;
	struct {
		long _u;
		daddr_t _l;
	} _p;
} lldaddr_t;
typedef ulong_t k_fltset_t;
typedef long		id_t;
typedef ulong_t	major_t;
typedef ulong_t	minor_t;
typedef short	pri_t;
typedef	ushort_t o_mode_t;
typedef short	o_dev_t;
typedef	ushort_t o_uid_t;
typedef	o_uid_t	o_gid_t;
typedef	short	o_nlink_t;
typedef short	o_pid_t;
typedef ushort_t o_ino_t;
typedef	int	key_t;
typedef	ulong_t	mode_t;
typedef	long	uid_t;
typedef	uid_t	gid_t;
typedef	ulong_t nlink_t;
typedef ulong_t	dev_t;
typedef ulong_t	ino_t;
typedef long	pid_t;
typedef	uint_t	size_t;
typedef int	ssize_t;
typedef	long		time_t;
typedef	long		clock_t;
typedef	unsigned char	unchar;
typedef	unsigned short	ushort;
typedef	unsigned int	uint;
typedef	unsigned long	ulong;
typedef	long	hostid_t;
typedef unsigned char	u_char;
typedef unsigned short	u_short;
typedef unsigned int	u_int;
typedef unsigned long	u_long;
typedef struct _quad { long val[2]; } quad;
extern "C" {
struct timeval {
	long	tv_sec;
	long	tv_usec;
};
struct timezone {
	int	tz_minuteswest;
	int	tz_dsttime;
};
}
extern "C" {
struct	itimerval {
	struct	timeval it_interval;
	struct	timeval it_value;
};
typedef struct	timestruc {
	time_t 		tv_sec;
	long		tv_nsec;
} timestruc_t;
typedef	longlong_t	hrtime_t;
int adjtime(struct timeval *, struct timeval *);
int getitimer(int, struct itimerval *);
int setitimer(int, struct itimerval *, struct itimerval *);
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;
};
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 "C" {
typedef	long	fd_mask;
typedef	struct fd_set {
	fd_mask	fds_bits[(((1024 )+(( (sizeof (fd_mask) * 8 )	)-1))/( (sizeof (fd_mask) * 8 )	)) ];
} fd_set;
extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
}
}
extern "C" {
struct  netconfig {
	char		*nc_netid;
	unsigned long	nc_semantics;
	unsigned long	nc_flag;
	char		*nc_protofmly;
	char		*nc_proto;
	char		*nc_device;
	unsigned long	nc_nlookups;
	char		**nc_lookups;
	unsigned long	nc_unused[8];
};
typedef struct {
	struct netconfig **nc_head;
	struct netconfig **nc_curr;
} NCONF_HANDLE;
extern void		*setnetconfig(void);
extern int		endnetconfig(void *);
extern struct netconfig	*getnetconfig(void *);
extern struct netconfig	*getnetconfigent(char *);
extern void		freenetconfigent(struct netconfig *);
extern void		*setnetpath(void);
extern int		endnetpath(void *);
extern struct netconfig *getnetpath(void *);
}
extern "C" {
struct	linger {
	int	l_onoff;
	int	l_linger;
};
struct sockaddr {
	u_short	sa_family;
	char	sa_data[14];
};
struct sockproto {
	u_short	sp_family;
	u_short	sp_protocol;
};
struct msghdr {
	caddr_t	msg_name;
	int	msg_namelen;
	struct	iovec *msg_iov;
	int	msg_iovlen;
	caddr_t	msg_accrights;
	int	msg_accrightslen;
};
struct opthdr {
	long	level;
	long	name;
	long	len;
};
struct optdefault {
	int	optname;
	char	*val;
	int	len;
};
struct opproc {
	int	level;
	int	(*func)();
};
struct socksysreq {
	int	args[7];
};
struct socknewproto {
	int	family;
	int	type;
	int	proto;
	dev_t	dev;
	int	flags;
};
extern int accept(int, struct sockaddr *, int *);
extern int bind(int, struct sockaddr *, int);
extern int connect(int, struct sockaddr *, int);
extern int getpeername(int, struct sockaddr *, int *);
extern int getsockname(int, struct sockaddr *, int *);
extern int getsockopt(int, int, int, char *, int *);
extern int listen(int, int);
extern int recv(int, char *, int, int);
extern int recvfrom(int, char *, int, int, struct sockaddr *, int *);
extern int send(int, const char *, int, int);
extern int sendto(int, const char *, int, int, struct sockaddr *, int);
extern int setsockopt(int, int, int, const char *, int);
extern int socket(int, int, int);
extern int recvmsg(int, struct msghdr *, int);
extern int sendmsg(int, struct msghdr *, int);
extern int shutdown(int, int);
extern int socketpair(int, int, int, int *);
}
extern "C" {
extern void	lock_set(lock_t *lp);
extern int	lock_try(lock_t *lp);
extern void	lock_clear(lock_t *lp);
extern int	lock_set_spl(lock_t *lp, int pl);
extern void	lock_clear_splx(lock_t *lp, int s);
}
extern "C" {
typedef	struct dl {
	long	dl_hop;
	ulong_t	dl_lop;
} dl_t;
extern dl_t	ladd(dl_t, dl_t);
extern dl_t	lsub(dl_t, dl_t);
extern dl_t	lmul(dl_t, dl_t);
extern dl_t	ldivide(dl_t, dl_t);
extern dl_t	lshiftl(dl_t, int);
extern dl_t	llog10(dl_t);
extern dl_t	lexp10(dl_t);
extern dl_t	lzero;
extern dl_t	lone;
extern dl_t	lten;
}
extern "C" {
typedef struct lkinfo {
	char	*lk_name;
	int	lk_flags;
	long	lk_pad[2];
} lkinfo_t;
typedef struct _lkstat_t {
	lkinfo_t	*ls_infop;
	ulong_t		ls_wrcnt;
	ulong_t		ls_rdcnt;
	ulong_t		ls_solordcnt;
	ulong_t		ls_fail;
	union {
		dl_t lsu_time;
		struct _lkstat_t *lsu_next;
	} un;
	dl_t		ls_wtime;
	dl_t		ls_htime;
} lkstat_t;
typedef struct lkstat_sum {
	lkstat_t	*sp;
	struct lkstat_sum *next;
} lkstat_sum_t;
typedef struct lksblk {
	struct lksblk *lsb_prev, *lsb_next;
	int lsb_nfree;
	lkstat_t *lsb_free;
	lkstat_t lsb_bufs[91 ];
} lksblk_t;
extern lkstat_t *lkstat_alloc(lkinfo_t *, int);
extern void	lkstat_free(lkstat_t *, int);
extern void *	startup_alloc(size_t, void **);
extern void	startup_free(void *, size_t, void **);
}
extern "C" {
typedef enum syncobj
{
	SOBJ_NONE = 0,
	SOBJ_MTX  = 1,
	SOBJ_RDR  = 2,
	SOBJ_WRT  = 3,
	SOBJ_CV   = 4,
	SOBJ_SEM  = 5
} syncobj_t;
typedef struct sleepq
{
	struct _kthread * sq_first;
} sleepq_t;
extern struct sleepq sleepq[];
}
extern "C" {
}
extern "C" {
}
extern "C" {
typedef struct pirec
{
	struct pirec	*pi_forw;
	struct pirec	*pi_back;
	struct _kthread *pi_owner;
	int		pi_epri_hi;
} pirec_t;
}
extern "C" {
typedef enum
{
	QOBJ_DEF = 0,
	QOBJ_RDR = 0,
	QOBJ_WRT = 1,
	QOBJ_CV  = 0,
	QOBJ_MTX = 0,
	QOBJ_SEM = 0
} qobj_t;
typedef struct turnstile	turnstile_t;
typedef ushort_t		turnstile_id_t;
struct turnstile
{
	union tstile_un
	{
		turnstile_t	*ts_forw;
		pirec_t		ts_prioinv;
	} tsun;
	turnstile_id_t	ts_id;
	short		ts_pad;
	int		ts_refcnt;
	sleepq_t	ts_sleepq[2	];
};
}
extern "C" {
typedef enum {
	MUTEX_ADAPTIVE = 0,
	MUTEX_SPIN,
	MUTEX_ADAPTIVE_STAT,
	MUTEX_SPIN_STAT,
	MUTEX_DRIVER_NOSTAT = 4,
	MUTEX_DRIVER_STAT = 5,
	MUTEX_ADAPTIVE_DEF
} kmutex_type_t;
typedef union mutex {
	struct generic_mutex {
		char	_filler1[3];
		lock_t	m_lock;
		uchar_t	m_type;
		char	_filler2[3];
	} m_generic;
	struct adaptive_mutex {
		uint_t	m_owner : 24;
		lock_t	m_lock;
		uchar_t	m_type;
		char	_filler;
		turnstile_id_t	m_waiters;
	} m_adaptive;
	struct adaptive_mutex2 {
		uint_t	m_owner_lock;
		uchar_t	m_type;
		char	_filler;
		turnstile_id_t	m_waiters;
	} m_adaptive2;
	struct spin_mutex {
		ushort_t m_oldspl;
		lock_t	m_spinlock;
		lock_t	m_dummylock;
		uchar_t	m_type;
		char	_filler;
		ushort_t m_minspl;
	} m_spin;
	struct stat_mutex {
		uint_t	m_stats_lock;
		uchar_t	m_type;
		uchar_t	_filler[3];
	} m_stats;
} kmutex_t;
struct mutex_stats {
	kmutex_t	m_real;
	lkinfo_t	lkinfo;
	lkstat_t	*lkstat;
	char		name[18	];
	uchar_t		flag;
};
}
extern "C" {
extern int ncpus;
typedef enum {
	SEMA_DEFAULT,
	SEMA_DRIVER
} ksema_type_t;
typedef struct _ksema {
	unsigned char	type;
	char		pad;
	turnstile_id_t	waiters;
	int		count;
} ksema_t;
typedef enum {
	RW_SLEEP,
	RW_SLEEP_STAT,
	RW_DRIVER_NOSTAT = 2,
	RW_DRIVER_STAT = 3,
	RW_DEFAULT
} krw_type_t;
typedef enum {
	RW_WRITER,
	RW_READER
} krw_t;
typedef struct _krwlock {
	unsigned char 	type;
	turnstile_id_t	waiters;
	union {
		struct rwlock_stats *sp;
		struct {
			short	writewanted;
			short	holdcnt;
		} rw;
	} un;
	struct _kthread *owner;
} krwlock_t;
struct rwlock_stats {
	krwlock_t	real;
	lkinfo_t	lkinfo;
	lkstat_t	*lkstat;
	char		name[18	+1];
	char		flag;
};
typedef struct {
	turnstile_id_t	waiters;
} kcondvar_t;
typedef	enum {
	CV_DEFAULT,
	CV_DRIVER
} kcv_type_t;
typedef struct lockinfo {
	struct _kthread *owner;
	int 	pc;
	int	sp;
	int	id;
	char	type;
	int	hashbucket;
	struct lockinfo *next;
} lockinfo_t;
extern int locktrace;
}
extern "C" {
typedef struct file {
	struct file	*f_next;
	struct file	*f_prev;
	ushort_t	f_flag;
	cnt_t		f_count;
	struct vnode	*f_vnode;
	offset_t	f_offset;
	struct cred	*f_cred;
	caddr_t		f_audit_data;
	kmutex_t	f_tlock;
	kcondvar_t	f_done;
	int		f_refcnt;
} file_t;
}
extern "C" {
}
extern "C" {
struct bsd_compat_ioctltab {
	int	cmd;
	int	flag;
	unsigned int	size;
};
}
extern "C" {
}
extern "C" {
struct	stat {
	dev_t	st_dev;
	long	st_pad1[3];
	ino_t	st_ino;
	mode_t	st_mode;
	nlink_t st_nlink;
	uid_t 	st_uid;
	gid_t 	st_gid;
	dev_t	st_rdev;
	long	st_pad2[2];
	off_t	st_size;
	long	st_pad3;
	timestruc_t st_atim;
	timestruc_t st_mtim;
	timestruc_t st_ctim;
	long	st_blksize;
	long	st_blocks;
	char	st_fstype[16		];
	long	st_pad4[8];
};
extern int fstat(int, struct stat *);
extern int stat(const char *, struct stat *);
extern int lstat(const char *, struct stat *);
extern int mknod(const char *, mode_t, dev_t);
extern int fchmod(int, mode_t);
extern int chmod(const char *, mode_t);
extern int mkdir(const char *, mode_t);
extern int mkfifo(const char *, mode_t);
extern mode_t umask(mode_t);
}
extern "C" {
typedef struct iovec {
	caddr_t	iov_base;
	int	iov_len;
} iovec_t;
typedef enum uio_seg { UIO_USERSPACE, UIO_SYSSPACE, UIO_USERISPACE } uio_seg_t;
typedef struct uio {
	iovec_t	*uio_iov;
	int	uio_iovcnt;
	lloff_t	_uio_offset;
	uio_seg_t uio_segflg;
	short	uio_fmode;
	lldaddr_t _uio_limit;
	int	uio_resid;
} uio_t;
typedef enum uio_rw { UIO_READ, UIO_WRITE } uio_rw_t;
extern ssize_t readv(int, struct iovec *, int);
extern ssize_t writev(int, const struct iovec *, int);
}
extern "C" {
extern caddr_t mmap(caddr_t, size_t, int, int, int, off_t);
extern int munmap(caddr_t, size_t);
extern int mprotect(caddr_t, size_t, int);
extern int mincore(caddr_t, size_t, char *);
extern int memcntl(caddr_t, size_t, int, caddr_t, int, int);
extern int msync(caddr_t, size_t, int);
extern int madvise(caddr_t, size_t, int);
extern int mlock(caddr_t, size_t);
extern int mlockall(int);
extern int munlock(caddr_t, size_t);
extern int munlockall(void);
}
extern "C" {
struct	sockaddr_un {
	short	sun_family;
	char	sun_path[108];
};
}
extern "C" {
typedef unsigned long rlim_t;
struct rlimit {
	rlim_t	rlim_cur;
	rlim_t	rlim_max;
};
extern int setrlimit(int, const struct rlimit *);
extern int getrlimit(int, struct rlimit *);
}
extern "C" {
struct ipc_perm {
	uid_t	uid;
	gid_t	gid;
	uid_t	cuid;
	gid_t	cgid;
	mode_t	mode;
	ulong	seq;
	key_t	key;
	long	pad[4];
};
key_t ftok(const char *, int);
}
extern "C" {
struct semid_ds {
	struct ipc_perm sem_perm;
	struct sem	*sem_base;
	ushort		sem_nsems;
	time_t		sem_otime;
	long		sem_pad1;
	time_t		sem_ctime;
	long		sem_pad2;
	long		sem_pad3[4];
};
struct sem {
	ushort	semval;
	pid_t	sempid;
	ushort	semncnt;
	ushort	semzcnt;
	ushort	semncnt_cv;
	ushort	semzcnt_cv;
};
struct sem_undo {
	struct sem_undo	*un_np;
	short		un_cnt;
	struct undo {
		short	un_aoe;
		ushort	un_num;
		int	un_id;
	}	un_ent[1];
};
struct	seminfo	{
	int	semmap;
	int	semmni;
	int	semmns;
	int	semmnu;
	int	semmsl;
	int	semopm;
	int	semume;
	int	semusz;
	int	semvmx;
	int	semaem;
};
struct sembuf {
	ushort	sem_num;
	short	sem_op;
	short	sem_flg;
};
int semctl(int, int, int, ...);
int semget(key_t, int, int);
int semop(int, struct sembuf *, unsigned);
}
extern "C" {
struct msqid_ds {
	struct ipc_perm	msg_perm;
	struct msg	*msg_first;
	struct msg	*msg_last;
	ulong		msg_cbytes;
	ulong		msg_qnum;
	ulong		msg_qbytes;
	pid_t		msg_lspid;
	pid_t		msg_lrpid;
	time_t		msg_stime;
	long		msg_pad1;
	time_t		msg_rtime;
	long		msg_pad2;
	time_t		msg_ctime;
	long		msg_pad3;
	short		msg_cv;
	short		msg_qnum_cv;
	long		msg_pad4[3];
};
struct msg {
	struct msg	*msg_next;
	long		msg_type;
	ushort		msg_ts;
	short		msg_spot;
};
struct msgbuf {
	long	mtype;
	char	mtext[1];
};
struct msginfo {
	int	msgmap;
	int	msgmax;
	int	msgmnb;
	int	msgmni;
	int	msgssz;
	int	msgtql;
	ushort	msgseg;
};
int msgctl(int, int, ...);
int msgget(key_t, int);
int msgrcv(int, void *, size_t, long, int);
int msgsnd(int, const void *, size_t, int);
}
extern "C" {
extern "C" {
}
typedef struct siginfo {
	int	si_signo;
	int 	si_code;
	int	si_errno;
	union {
		int	_pad[	((128  / sizeof (int)) - 3) ];
		struct {
			pid_t	_pid;
			union {
				struct {
					uid_t	_uid;
				} _kill;
				struct {
					clock_t _utime;
					int	_status;
					clock_t _stime;
				} _cld;
			} _pdata;
		} _proc;
		struct {
			caddr_t	_addr;
			int	_trapno;
		} _fault;
		struct {
			int	_fd;
			long	_band;
		} _file;
		struct {
			caddr_t	_faddr;
			timestruc_t _tstamp;
			short	_syscall;
			char	_nsysarg;
			char	_fault;
			long	_sysarg[8];
			long	_mstate[17];
		} _prof;
	} _data;
} siginfo_t;
typedef struct k_siginfo {
	int	si_signo;
	int 	si_code;
	int	si_errno;
	union {
		struct {
			pid_t	_pid;
			union {
				struct {
					uid_t	_uid;
				} _kill;
				struct {
					clock_t _utime;
					int	_status;
					clock_t _stime;
				} _cld;
			} _pdata;
		} _proc;
		struct {
			caddr_t	_addr;
			int	_trapno;
		} _fault;
		struct {
			int	_fd;
			long	_band;
		} _file;
		struct {
			caddr_t	_faddr;
			timestruc_t _tstamp;
			short	_syscall;
			char	_nsysarg;
			char	_fault;
		} _prof;
	} _data;
} k_siginfo_t;
typedef struct sigqueue {
	struct sigqueue		*sq_next;
	struct k_siginfo	sq_info;
} sigqueue_t;
}
extern "C" {
typedef enum idtype {
	P_PID,
	P_PPID,
	P_PGID,
	P_SID,
	P_CID,
	P_UID,
	P_GID,
	P_ALL,
	P_LWPID
} idtype_t;
typedef enum idop {
	POP_DIFF,
	POP_AND,
	POP_OR,
	POP_XOR
} idop_t;
typedef struct procset {
	idop_t		p_op;
	idtype_t	p_lidtype;
	id_t		p_lid;
	idtype_t	p_ridtype;
	id_t		p_rid;
} procset_t;
}
extern "C" {
extern pid_t wait(int *);
extern pid_t waitpid(pid_t, int *, int);
extern int waitid(idtype_t, id_t, siginfo_t *, int);
}
extern "C" {
struct shmid_ds {
	struct ipc_perm	shm_perm;
	int		shm_segsz;
	struct anon_map	*shm_amp;
	ushort		shm_lkcnt;
	pid_t		shm_lpid;
	pid_t		shm_cpid;
	ulong		shm_nattch;
	ulong		shm_cnattch;
	time_t		shm_atime;
	long		shm_pad1;
	time_t		shm_dtime;
	long		shm_pad2;
	time_t		shm_ctime;
	long		shm_pad3;
	long		shm_pad4[4];
};
struct	shminfo {
	int	shmmax,
		shmmin,
		shmmni,
		shmseg;
};
int shmctl(int, int, ...);
int shmget(key_t, int, int);
void *shmat(int, void *, int);
int shmdt(void *);
typedef struct segacct {
	struct segacct	*sa_next;
	caddr_t		 sa_addr;
	size_t		 sa_len;
	struct anon_map *sa_amp;
} segacct_t;
}
extern "C" {
struct ifnet {
	char	*if_name;
	short	if_unit;
	short	if_mtu;
	short	if_flags;
	short	if_timer;
	u_short	if_promisc;
	int	if_metric;
	struct	ifaddr *if_addrlist;
	struct	ifqueue {
		struct	mbuf *ifq_head;
		struct	mbuf *ifq_tail;
		int	ifq_len;
		int	ifq_maxlen;
		int	ifq_drops;
	} if_snd;
	int	(*if_init)();
	int	(*if_output)();
	int	(*if_ioctl)();
	int	(*if_reset)();
	int	(*if_watchdog)();
	int	if_ipackets;
	int	if_ierrors;
	int	if_opackets;
	int	if_oerrors;
	int	if_collisions;
	struct	ifnet *if_next;
	struct	ifnet *if_upper;
	struct	ifnet *if_lower;
	int	(*if_input)();
	int	(*if_ctlin)();
	int	(*if_ctlout)();
	struct map *if_memmap;
};
struct ifaddr {
	struct	sockaddr ifa_addr;
	union {
		struct	sockaddr ifu_broadaddr;
		struct	sockaddr ifu_dstaddr;
	} ifa_ifu;
	struct	ifnet *ifa_ifp;
	struct	ifaddr *ifa_next;
};
struct	ifreq {
	char	ifr_name[16 ];
	union {
		struct	sockaddr ifru_addr;
		struct	sockaddr ifru_dstaddr;
		char	ifru_oname[16 ];
		struct	sockaddr ifru_broadaddr;
		short	ifru_flags;
		int	ifru_metric;
		char	ifru_data[1];
		char	ifru_enaddr[6];
		struct ifr_dnld_reqs {
			caddr_t	v_addr;
			caddr_t	m_addr;
			caddr_t	ex_addr;
			u_int	size;
		} ifru_dnld_req;
		struct ifr_fddi_stats {
			u_int	stat_size;
			caddr_t	fddi_stats;
		} ifru_fddi_stat;
		struct ifr_netmapents {
			u_int	map_ent_size,
				entry_number;
			caddr_t	fddi_map_ent;
		} ifru_netmapent;
		struct ifr_fddi_gen_struct {
			int	ifru_fddi_gioctl;
			caddr_t ifru_fddi_gaddr;
		} ifru_fddi_gstruct;
	} ifr_ifru;
};
struct	ifconf {
	int	ifc_len;
	union {
		caddr_t	ifcu_buf;
		struct	ifreq *ifcu_req;
	} ifc_ifcu;
};
}
extern "C" {
extern "C" {
typedef struct cred {
	ushort	cr_ref;
	ushort	cr_ngroups;
	uid_t	cr_uid;
	gid_t	cr_gid;
	uid_t	cr_ruid;
	gid_t	cr_rgid;
	uid_t	cr_suid;
	gid_t	cr_sgid;
	gid_t	cr_groups[1];
} cred_t;
}
extern "C" {
typedef enum vtype {
	VNON	= 0,
	VREG	= 1,
	VDIR	= 2,
	VBLK	= 3,
	VCHR	= 4,
	VLNK	= 5,
	VFIFO	= 6,
	VXNAM	= 7,
	VBAD	= 8
} vtype_t;
typedef struct vnode {
	kmutex_t	v_lock;
	u_short		v_flag;
	u_long		v_count;
	struct vfs	*v_vfsmountedhere;
	struct vnodeops	*v_op;
	struct vfs	*v_vfsp;
	struct stdata	*v_stream;
	struct page	*v_pages;
	enum vtype	v_type;
	dev_t		v_rdev;
	caddr_t		v_data;
	struct filock	*v_filocks;
	kcondvar_t	v_cv;
} vnode_t;
typedef struct vnodeops {
	int	(*vop_open)();
	int	(*vop_close)();
	int	(*vop_read)();
	int	(*vop_write)();
	int	(*vop_ioctl)();
	int	(*vop_setfl)();
	int	(*vop_getattr)();
	int	(*vop_setattr)();
	int	(*vop_access)();
	int	(*vop_lookup)();
	int	(*vop_create)();
	int	(*vop_remove)();
	int	(*vop_link)();
	int	(*vop_rename)();
	int	(*vop_mkdir)();
	int	(*vop_rmdir)();
	int	(*vop_readdir)();
	int	(*vop_symlink)();
	int	(*vop_readlink)();
	int	(*vop_fsync)();
	void	(*vop_inactive)();
	int	(*vop_fid)();
	void	(*vop_rwlock)();
	void	(*vop_rwunlock)();
	int	(*vop_seek)();
	int	(*vop_cmp)();
	int	(*vop_frlock)();
	int	(*vop_space)();
	int	(*vop_realvp)();
	int	(*vop_getpage)();
	int	(*vop_putpage)();
	int	(*vop_map)();
	int	(*vop_addmap)();
	int	(*vop_delmap)();
	int	(*vop_poll)();
	int	(*vop_dump)();
	int	(*vop_pathconf)();
} vnodeops_t;
extern	int setswappingon();
extern	int setswappingoff();
typedef struct vattr {
	long		va_mask;
	vtype_t		va_type;
	mode_t		va_mode;
	uid_t		va_uid;
	gid_t		va_gid;
	dev_t		va_fsid;
	ino_t		va_nodeid;
	nlink_t		va_nlink;
	u_long		va_size0;
	u_long		va_size;
	timestruc_t	va_atime;
	timestruc_t	va_mtime;
	timestruc_t	va_ctime;
	dev_t		va_rdev;
	u_long		va_blksize;
	u_long		va_nblocks;
	u_long		va_vcode;
} vattr_t;
enum rm		{ RMFILE, RMDIRECTORY };
enum symfollow	{ NO_FOLLOW, FOLLOW };
enum vcexcl	{ NONEXCL, EXCL };
enum create	{ CRCREAT, CRMKNOD, CRMKDIR, CRCORE };
typedef enum rm		rm_t;
typedef enum symfollow	symfollow_t;
typedef enum vcexcl	vcexcl_t;
typedef enum create	create_t;
extern int vn_open(char *, enum uio_seg, int, int, struct vnode **,
    enum create);
extern int vn_create(char *, enum uio_seg, struct vattr *, enum vcexcl, int,
    struct vnode **, enum create);
extern int vn_rdwr(enum uio_rw, struct vnode *, caddr_t, int, off_t,
    enum uio_seg, int, long, cred_t *, int *);
extern int vn_close(struct vnode *, int, int, int, struct cred *);
extern void vn_rele(struct vnode *);
extern int vn_link(char *, char *, enum uio_seg);
extern int vn_rename(char *, char *, int);
extern int vn_remove(char *, enum uio_seg, enum rm);
extern vnode_t *specvp(struct vnode *, dev_t, vtype_t, struct cred *);
extern vnode_t *makespecvp(dev_t, vtype_t);
}
extern "C" {
struct pollfd {
	int fd;
	short events;
	short revents;
};
struct pollhead {
	struct polldat	*ph_list;
	struct polldat	*ph_dummy;
	short		ph_events;
};
struct polldat {
	struct polldat *pd_next;
	struct polldat *pd_prev;
	struct polldat *pd_chain;
	short		pd_events;
	struct pollhead *pd_headp;
	void		(*pd_fn)();
	long		pd_arg;
};
int poll(struct pollfd *, unsigned long, int);
}
extern "C" {
}
extern "C" {
struct	queue {
	struct	qinit	*q_qinfo;
	struct	msgb	*q_first;
	struct	msgb	*q_last;
	struct	queue	*q_next;
	struct	queue	*q_link;
	void 		*q_ptr;
	ulong		q_count;
	ulong		q_flag;
	long		q_minpsz;
	long		q_maxpsz;
	ulong		q_hiwat;
	ulong		q_lowat;
	struct qband	*q_bandp;
	kmutex_t	q_lock;
	struct stdata 	*q_stream;
	struct	syncq	*q_syncq;
	long		q_pad2[2];
	unsigned char	q_nband;
	kcondvar_t	q_wait;
	kcondvar_t	q_sync;
};
typedef struct queue queue_t;
struct qband {
	struct qband	*qb_next;
	ulong		qb_count;
	struct msgb	*qb_first;
	struct msgb	*qb_last;
	ulong		qb_hiwat;
	ulong		qb_lowat;
	ulong		qb_flag;
};
typedef struct qband qband_t;
typedef enum qfields {
	QHIWAT	= 0,
	QLOWAT	= 1,
	QMAXPSZ	= 2,
	QMINPSZ	= 3,
	QCOUNT	= 4,
	QFIRST	= 5,
	QLAST	= 6,
	QFLAG	= 7,
	QBAD	= 8
} qfields_t;
struct module_info {
	ushort	mi_idnum;
	char 	*mi_idname;
	long	mi_minpsz;
	long	mi_maxpsz;
	ulong	mi_hiwat;
	ulong 	mi_lowat;
};
struct	qinit {
	int	(*qi_putp)();
	int	(*qi_srvp)();
	int	(*qi_qopen)();
	int	(*qi_qclose)();
	int	(*qi_qadmin)();
	struct module_info *qi_minfo;
	struct module_stat *qi_mstat;
};
struct streamtab {
	struct qinit *st_rdinit;
	struct qinit *st_wrinit;
	struct qinit *st_muxrinit;
	struct qinit *st_muxwinit;
};
struct linkblk {
	queue_t *l_qtop;
	queue_t *l_qbot;
	int	l_index;
};
struct free_rtn {
	void (*free_func)();
	char *free_arg;
	struct	free_rtn	*free_next;
	int free_unsafe;
};
struct datab {
	struct	free_rtn	*db_frtnp;
	unsigned char	*db_base;
	unsigned char	*db_lim;
	unsigned char	db_ref;
	unsigned char	db_type;
	unsigned char	db_refmin;
	unsigned int	db_size;
	char		filler[8];
	long		db_reserved;
};
struct	msgb {
	struct	msgb	*b_next;
	struct  msgb	*b_prev;
	struct	msgb	*b_cont;
	unsigned char	*b_rptr;
	unsigned char	*b_wptr;
	struct datab 	*b_datap;
	unsigned char	b_band;
	unsigned short	b_flag;
	queue_t		*b_queue;
};
typedef struct msgb mblk_t;
typedef struct datab dblk_t;
typedef struct free_rtn frtn_t;
struct iocblk {
	int 	ioc_cmd;
	cred_t	*ioc_cr;
	uint	ioc_id;
	uint	ioc_count;
	int	ioc_error;
	int	ioc_rval;
	long	ioc_filler[4];
};
struct copyreq {
	int	cq_cmd;
	cred_t	*cq_cr;
	uint	cq_id;
	caddr_t	cq_addr;
	uint	cq_size;
	int	cq_flag;
	mblk_t *cq_private;
	long	cq_filler[4];
};
struct copyresp {
	int	cp_cmd;
	cred_t	*cp_cr;
	uint	cp_id;
	caddr_t	cp_rval;
	uint	cp_pad1;
	int	cp_pad2;
	mblk_t *cp_private;
	long	cp_filler[4];
};
struct stroptions {
	ulong	so_flags;
	short	so_readopt;
	ushort	so_wroff;
	long	so_minpsz;
	long	so_maxpsz;
	ulong	so_hiwat;
	ulong	so_lowat;
	unsigned char so_band;
};
struct str_evmsg {
	long		 sv_event;
	vnode_t		*sv_vp;
	long		 sv_eid;
	long		 sv_evpri;
	long		 sv_flags;
	uid_t		 sv_uid;
	pid_t		 sv_pid;
	hostid_t	 sv_hostid;
	long		 sv_pad[4];
};
extern mblk_t *allocb(int, ...);
extern mblk_t *esballoc(unsigned char *, int, int, frtn_t *);
extern int testb(int, uint);
extern int bufcall(uint, int, void (*)(), long);
extern int esbbcall(int, void (*)(), long);
extern void freeb(struct msgb *);
extern void freemsg(mblk_t *);
extern mblk_t *dupb(mblk_t *);
extern mblk_t *dupmsg(mblk_t *);
extern mblk_t *copyb(mblk_t *);
extern mblk_t *copymsg(mblk_t *);
extern void linkb(mblk_t *, mblk_t *);
extern mblk_t *unlinkb(mblk_t *);
extern mblk_t *rmvb(mblk_t *, mblk_t *);
extern int pullupmsg(struct msgb *, int);
extern mblk_t *msgpullup(struct msgb *, int);
extern int adjmsg(struct msgb *, int);
extern int msgdsize(struct msgb *);
extern mblk_t *getq(queue_t *);
extern void rmvq(queue_t *, mblk_t *);
extern void flushq(queue_t *, int);
extern void flushband(queue_t *, unsigned char, int);
extern int canput(queue_t *);
extern int bcanput(queue_t *, unsigned char);
extern int canputnext(queue_t *);
extern int bcanputnext(queue_t *, unsigned char);
extern int putq(queue_t *, mblk_t *);
extern int putbq(queue_t *, mblk_t *);
extern int insq(queue_t *, mblk_t *, mblk_t *);
extern int putctl(queue_t *, int);
extern int putctl1(queue_t *, int, int);
extern int putnextctl(queue_t *, int);
extern int putnextctl1(queue_t *, int, int);
extern queue_t *backq(queue_t *);
extern void qreply(queue_t *, mblk_t *);
extern void qenable(queue_t *);
extern int qsize(queue_t *);
extern void noenable(queue_t *);
extern void enableok(queue_t *);
extern int strqset(queue_t *, qfields_t, unsigned char, long);
extern int strqget(queue_t *, qfields_t, unsigned char, long *);
extern void unbufcall(int);
extern void qprocson(queue_t *);
extern void qprocsoff(queue_t *);
extern void freezestr(queue_t *);
extern void unfreezestr(queue_t *);
extern int nstrpush;
}
extern "C" {
}
struct in_addr {
	union {
		struct { u_char s_b1, s_b2, s_b3, s_b4; } S_un_b;
		struct { u_short s_w1, s_w2; } S_un_w;
		u_long S_addr;
	} S_un;
};
struct sockaddr_in {
	short	sin_family;
	u_short	sin_port;
	struct	in_addr sin_addr;
	char	sin_zero[8];
};
struct ip_mreq {
	struct in_addr	imr_multiaddr;
	struct in_addr	imr_interface;
};
}
extern "C" {
typedef long	fpos_t;
typedef struct
{
	int		_cnt;
	unsigned char	*_ptr;
	unsigned char	*_base;
	unsigned char	_flag;
	unsigned char	_file;
} FILE;
extern FILE		__iob[20	];
extern FILE		*_lastbuf;
extern unsigned char	*_bufendtab[];
extern unsigned char	 _sibuf[], _sobuf[];
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 *, ...);
extern int	vfprintf(FILE *, const char *, void *);
extern int	vprintf(const char *, void *);
extern int	vsprintf(char *, const char *, void *);
extern int	fgetc(FILE *);
extern char	*fgets(char *, int, FILE *);
extern int	fputc(int, FILE *);
extern int	fputs(const char *, FILE *);
extern int	getc(FILE *);
extern int	getchar(void);
extern char	*gets(char *);
extern int	putc(int, FILE *);
extern int	putchar(int);
extern int	puts(const char *);
extern int	ungetc(int, FILE *);
extern size_t	fread(void *, size_t, size_t, FILE *);
	#pragma int_to_unsigned fread
extern size_t	fwrite(const void *, size_t, size_t, FILE *);
	#pragma int_to_unsigned fwrite
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	clearerr(FILE *);
extern int	feof(FILE *);
extern int	ferror(FILE *);
extern void	perror(const char *);
extern int	__filbuf(FILE *);
extern int	__flsbuf(int, FILE *);
}
extern "C" {
typedef	void SIG_FUNC_TYP(int);
typedef	SIG_FUNC_TYP *SIG_TYP;
}
extern "C" {
typedef int	sig_atomic_t;
extern const char *_sys_siglist[];
extern const int _sys_nsig;
extern "C" SIG_TYP  signal (int, SIG_TYP );
extern int raise(int);
}
extern "C" {
extern void *memcpy(void *, const void *, size_t);
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 void *memchr(const void *, int, size_t);
extern char *strchr(const char *, int);
extern size_t strcspn(const char *, const char *);
	#pragma int_to_unsigned strcspn
extern char *strpbrk(const char *, const char *);
extern char *strrchr(const char *, int);
extern size_t strspn(const char *, const char *);
	#pragma int_to_unsigned strspn
extern char *strstr(const char *, const char *);
extern char *strtok(char *, const char *);
extern void *memset(void *, int, size_t);
extern char *strerror(int);
extern char *strsignal(int);
extern size_t strlen(const char *);
	#pragma int_to_unsigned strlen
}
typedef int ptrdiff_t;
typedef __wchar_t wchar_t;
extern "C" {
extern void __eprintf (const char *, const char *, unsigned, const char *);
}
extern "C" {
extern void *memccpy(void *, const void *, int, size_t);
extern void *memchr(const void *, int, size_t);
extern void *memcpy(void *, const void *, size_t);
extern void *memset(void *, int, size_t);
extern int memcmp(const void *, const void *, size_t);
}
typedef void * __gnuc_va_list;
void va_end (__gnuc_va_list);
typedef __gnuc_va_list va_list;
extern "C" {
struct mallinfo  {
	int arena;
	int ordblks;
	int smblks;
	int hblks;
	int hblkhd;
	int usmblks;
	int fsmblks;
	int uordblks;
	int fordblks;
	int keepcost;
};
void *malloc(size_t);
void free(void *);
void *realloc(void *, size_t);
int mallopt(int, int);
struct mallinfo mallinfo(void);
void *calloc(size_t, size_t);
}
extern "C" {
extern int isalnum(int);
extern int isalpha(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 tolower(int);
extern int toupper(int);
extern unsigned char	__ctype[];
}
extern "C" {
typedef struct flock {
	short	l_type;
	short	l_whence;
	off_t	l_start;
	off_t	l_len;
	long	l_sysid;
	pid_t	l_pid;
	long	pad[4];
} flock_t;
}
extern "C" {
extern int fcntl(int, int, ...);
extern int open(const char *, int, ...);
extern int creat(const char *, mode_t);
}
extern "C" {
}
extern "C" {
extern int errno;
}
extern "C" {
struct passwd {
	char	*pw_name;
	char	*pw_passwd;
	uid_t	pw_uid;
	gid_t	pw_gid;
	char	*pw_age;
	char	*pw_comment;
	char	*pw_gecos;
	char	*pw_dir;
	char	*pw_shell;
};
struct comment {
	char	*c_dept;
	char	*c_name;
	char	*c_acct;
	char	*c_bin;
};
extern struct passwd *getpwent(void);
extern struct passwd *getpwuid(uid_t);
extern struct passwd *getpwnam(const char *);
extern void setpwent(void);
extern void endpwent(void);
extern struct passwd *fgetpwent(FILE *);
extern int putpwent(const struct passwd *, FILE *);
}
extern "C" {
}
typedef void (*SignalHandler)(...);
extern "C" {
extern int access(const char *, int);
extern int acct(const char *);
extern unsigned alarm(unsigned);
extern int brk(void *);
extern int chdir(const char *);
extern int chown(const char *, uid_t, gid_t);
extern int chroot(const char *);
extern int close(int);
extern char *ctermid(char *);
extern char *cuserid(char *);
extern int dup(int);
extern int dup2(int, int);
extern int execl(const char *, const char *, ...);
extern int execle(const char *, const char *, ...);
extern int execlp(const char *, const char *, ...);
extern int execv(const char *, char *const *);
extern int execve(const char *, char *const *, char *const *);
extern int execvp(const char *, char *const *);
extern void exit(int);
extern void _exit(int);
extern int fattach(int, const char *);
extern int fchdir(int);
extern int fchown(int, uid_t, gid_t);
extern int fchroot(int);
extern int fdetach(const char *);
extern pid_t fork(void);
extern long fpathconf(int, int);
extern int fsync(int);
extern int ftruncate(int, off_t);
extern char *getcwd(char *, size_t);
extern gid_t getegid(void);
extern uid_t geteuid(void);
extern gid_t getgid(void);
extern int getgroups(int, gid_t *);
extern char *getlogin(void);
extern pid_t getpgid(pid_t);
extern pid_t getpid(void);
extern pid_t getppid(void);
extern pid_t getpgrp(void);
char *gettxt(const char *, const char *);
extern pid_t getsid(pid_t);
extern uid_t getuid(void);
extern int ioctl(int, int, ...);
extern int isatty(int);
extern int link(const char *, const char *);
extern int lchown(const char *, uid_t, gid_t);
extern int lockf(int, int, long);
extern off_t lseek(int, off_t, int);
extern int mincore(caddr_t, size_t, char *);
extern int nice(int);
extern long pathconf(const char *, int);
extern int pause(void);
extern int pipe(int *);
extern void profil(unsigned short *, unsigned int, unsigned int, unsigned int);
extern int ptrace(int, pid_t, int, int);
extern ssize_t read(int, void *, unsigned);
extern int readlink(const char *, void *, int);
extern int rename(const char *, const char *);
extern int rmdir(const char *);
extern void *sbrk(int);
extern int setgid(gid_t);
extern int setegid(gid_t);
extern int setgroups(int, const gid_t *);
extern int setpgid(pid_t, pid_t);
extern pid_t setpgrp(void);
extern pid_t setsid(void);
extern int setuid(uid_t);
extern int seteuid(uid_t);
extern unsigned sleep(unsigned);
extern int stime(const time_t *);
extern int symlink(const char *, const char *);
extern void sync(void);
extern long sysconf(int);
extern pid_t tcgetpgrp(int);
extern int tcsetpgrp(int, pid_t);
extern int truncate(const char *, off_t);
extern char *ttyname(int);
extern int unlink(const char *);
extern pid_t vfork(void);
extern void vhangup(void);
extern ssize_t write(int, const void *, unsigned);
}
extern "C"
{
extern "C" {
extern unsigned long inet_addr(const char *);
extern char *inet_ntoa(struct in_addr);
extern struct in_addr inet_makeaddr(int, int);
extern unsigned long inet_network(const char *);
extern unsigned long inet_lnaof(struct in_addr);
extern unsigned long inet_netof(struct in_addr);
}
extern "C" {
struct	hostent {
	char	*h_name;
	char	**h_aliases;
	int	h_addrtype;
	int	h_length;
	char	**h_addr_list;
};
struct	netent {
	char		*n_name;
	char		**n_aliases;
	int		n_addrtype;
	unsigned long	n_net;
};
struct	servent {
	char	*s_name;
	char	**s_aliases;
	int	s_port;
	char	*s_proto;
};
struct	protoent {
	char	*p_name;
	char	**p_aliases;
	int	p_proto;
};
struct hostent	*gethostbyname(const char *);
struct hostent	*gethostbyaddr(const char *, int, int);
struct hostent	*gethostent(void);
struct netent	*getnetbyname(char *);
struct netent	*getnetbyaddr(long, int);
struct netent	*getnetent(void);
struct servent	*getservbyname(char *, char *);
struct servent	*getservbyport(int, char *);
struct servent	*getservent(void);
struct protoent	*getprotobyname(char *);
struct protoent	*getprotobynumber(int);
struct protoent	*getprotoent(void);
int sethostent(int);
int endhostent(void);
int setnetent(int);
int endnetent(void);
int setservent(int);
int endservent(void);
int setprotoent(int);
int endprotoent(void);
int rcmd(char **, unsigned short, char *, char *, char *, int *);
int rexec(char **, unsigned short, char *, char *, char *, int *);
int rresvport(int *);
int ruserok(char *, int, char *, char *);
extern  int h_errno;
}
}
class Time_Value
{
public:
  Time_Value (long sec = 0, long usec = 0);
  Time_Value (timeval &t);
  void set (timeval &t);
  long get_sec (void) const;
  void set_sec (long sec);
  long get_usec (void) const;
  void set_usec (long usec);
  operator timeval () const;
  friend Time_Value operator + (Time_Value tv1, Time_Value tv2);
  friend Time_Value operator - (Time_Value tv1, Time_Value tv2);
  friend int	    operator < (Time_Value tv1, Time_Value tv2);
  friend int	    operator > (Time_Value tv1, Time_Value tv2);
  friend int	    operator <= (Time_Value tv1, Time_Value tv2);
  friend int	    operator >= (Time_Value tv1, Time_Value tv2);
  friend int	    operator == (Time_Value tv1, Time_Value tv2);
  friend int	    operator != (Time_Value tv1, Time_Value tv2);
private:
  static void normalize_pos (Time_Value &num);
  static void normalize_neg (Time_Value &num);
  long tv_sec;
  long tv_usec;
  enum { ONE_SECOND = 1000000L };
};
class Event_Handler
{
protected:
  Event_Handler (void);
public:
  virtual ~Event_Handler (void);
  virtual int  get_fd (void) const = 0;
  virtual int  handle_close (void);
  virtual int  make_async (void);
  virtual int  handle_input (int);
  virtual int  handle_output (int);
  virtual int  handle_exception (int);
  virtual int  handle_sigio (int);
  virtual int  handle_timeout (const Time_Value &tv);
};
inline int  BIT_ENABLED (unsigned long word, int bit = 1) { return (word & bit) != 0; }
inline int  BIT_DISABLED (unsigned long word, int bit = 1) { return (word & bit) == 0; }
inline void SET_BIT (unsigned long &word, int bit) { word |= bit; }
inline void CLR_BIT (unsigned long &word, int bit) { word &= ~bit; }
class FD_Set
{
friend class FD_Set_Iter;
public:
  FD_Set (void);
  void zero (void);
  int  is_set (int) const;
  void set_bit (int);
  void clr_bit (int);
  int  num_set (void) const;
  int  max_set (void) const;
  int  pr_mask (void);
  void sync (int max = 	20	);
  operator fd_set *();
private:
  int	 size;
  int	 max_fd;
  fd_set mask;
  enum
    {
      MAX_SIZE  = 	20	,
      WORD_SIZE = (sizeof (fd_mask) * 8			)	,
      NUM_WORDS = (((	20	)+(( (sizeof (fd_mask) * 8			)	)-1))/( (sizeof (fd_mask) * 8			)	)) ,
      MSB_MASK	= ~(1 << ((sizeof (fd_mask) * 8			)	 - 1))
    };
  int  count_bits (unsigned long n) const;
  void set_max (int max);
  static const char nbits[256];
};
class FD_Set_Iter
{
public:
  FD_Set_Iter (FD_Set &);
  int operator ()(void);
  void operator++ (void);
private:
  FD_Set  &fds;
  int	  index;
  int	  num;
  fd_mask val;
};
class Timer_Queue
{
public:
  static const Time_Value zero;
public:
  Timer_Queue (void);
  virtual ~Timer_Queue (void);
  int 			  is_empty (void) const;
  const Time_Value        &earliest_time (void) const;
  static const Time_Value &current_time (void);
  void schedule (const Event_Handler *, const Time_Value &, const Time_Value & = Timer_Queue::zero);
  void cancel (const Event_Handler *);
  void expire (const Time_Value &);
private:
  struct Timer
    {
      Timer (const Event_Handler *h, const Time_Value &t, const Time_Value &i, Timer *n);
      Event_Handler const *handler;
      Time_Value timer_value;
      Time_Value interval;
      Timer	 *next;
    };
  Timer *head;
};
typedef int (Event_Handler::*PTMF) (int);
class Reactor
{
public:
  enum Reactor_Mask
  {
    READ_MASK   = 01,
    WRITE_MASK  = 02,
    EXCEPT_MASK = 04,
    SIGIO_MASK  = 010,
    RWE_MASK    = 01 | 02 | 04
  };
  virtual ~Reactor (void);
  virtual int	     register_handler (const Event_Handler *, Reactor_Mask = READ_MASK);
  virtual int	     register_handler (int fd, const Event_Handler *, Reactor_Mask = READ_MASK);
  virtual int	     remove_handler (const Event_Handler *, Reactor_Mask = READ_MASK);
  virtual int	     remove_handler (int fd, Reactor_Mask = READ_MASK);
  virtual int	     set_ready (const Event_Handler *, Reactor_Mask = READ_MASK);
  virtual int	     set_ready (int fd, Reactor_Mask = READ_MASK);
  virtual void	     schedule_timer (const Event_Handler *, const Time_Value &delta, const Time_Value &interval = Timer_Queue::zero);
  virtual void	     cancel_timer (const Event_Handler *);
  virtual void	     handle_events (void);
  virtual int	     handle_events (Time_Value &tv);
public:
  static int enable_signal_handler (int signum);
  static Reactor *open (int size = 	20	, Reactor *new_Reactor = 0);
  static void close (Reactor *Reactor = 0);
protected:
  Reactor (int size = 	20	);
  static void        handle_sigurg (void);
  static void	     handle_sigio (void);
  static void	     handle_sigpipe (void);
  virtual int	     attach (const Event_Handler *, Reactor_Mask, int fd);
  virtual int	     detach (Reactor_Mask, int fd);
  virtual int	     handle_events (Time_Value *);
  virtual int	     any_ready (void) const;
  virtual int	     fill_in_ready (FD_Set &, FD_Set &, FD_Set &, FD_Set&);
  virtual int	     wait_for (FD_Set &, FD_Set &, FD_Set &, Time_Value *);
  virtual Time_Value *calculate_timeout (Time_Value *) const;
  virtual void	     notify_fds (int, FD_Set &, FD_Set &, FD_Set &, FD_Set &);
  virtual void	     notify_fd (int, Reactor_Mask, FD_Set &, const Event_Handler *, PTMF);
  virtual int	     handle_error (void);
  virtual int	     check_connections (void);
protected:
  Event_Handler   const **readfd_table;
  Event_Handler   const **writefd_table;
  Event_Handler   const **exceptfd_table;
  Event_Handler   const **sigiofd_table;
  Timer_Queue  timer_queue;
  int	       max_fd;
  int	       max_size;
  FD_Set       readfd_mask;
  FD_Set       writefd_mask;
  FD_Set       exceptfd_mask;
  FD_Set       sigiofd_mask;
  FD_Set       readfd_mask_ready;
  FD_Set       writefd_mask_ready;
  FD_Set       exceptfd_mask_ready;
  FD_Set       sigiofd_mask_ready;
private:
  static Reactor *instance;
  int max (int i, int j, int k, int l);
  Reactor (const Reactor &);
  Reactor &operator = (const Reactor &);
};
class SAP_Addr
{
public:
  SAP_Addr (void);
  SAP_Addr (int type, int size);
  void set (int type, int size);
  int	  get_size (void) const;
  void	  set_size (int size);
  int	  get_type (void) const;
  void	  set_type (int type);
  virtual void *get_addr (void) const;
  virtual int operator == (const SAP_Addr &sap) const;
  virtual int operator != (const SAP_Addr &sap) const;
protected:
  int addr_type;
  int addr_size;
};
extern const SAP_Addr sap_any;
class SAP_UNIX_Addr : public SAP_Addr
{
public:
  SAP_UNIX_Addr (void);
  SAP_UNIX_Addr (const SAP_UNIX_Addr &sa);
  SAP_UNIX_Addr (const char rendezvous_point[]);
  virtual void *get_addr (void) const;
  virtual int  operator == (const SAP_Addr &SAP) const;
  virtual int  operator != (const SAP_Addr &SAP) const;
  const char *get_path_name (void) const;
private:
  sockaddr_un unix_addr;
};
class IPC_SAP
{
public:
  int  open (int type, int async, int protocol_family, int protocol = 0);
  int  close (void);
  int  set_option (int level, int option, void *optval, int optlen) const;
  int  get_option (int level, int option, void *optval, int &optlen) const;
  int  enable (int signum) const;
  int  disable (int signum) const;
  int get_host_info (SAP_Addr &) const;
  int  get_fd (void) const;
  void set_fd (int fd);
protected:
  IPC_SAP (void);
  IPC_SAP (int type, int async, int protocol_family, int protocol = 0);
  ~IPC_SAP (void);
private:
  int sok_fd;
};
class IPC_SAP_Connect : public IPC_SAP
{
public:
  int get_peer_info (SAP_Addr &) const;
  int send (const void *buf, int n, int flags = 0) const;
  int recv (void *buf, int n, int flags = 0) const;
  int send (const iovec iov[], int n) const;
  int recv (iovec iov[], int n) const;
  int send (int n, ...);
  int recv (int n, ...);
protected:
  IPC_SAP_Connect (void);
  IPC_SAP_Connect (int type, int async, int protocol_family, int protocol = 0);
};
class IPC_SAP_Stream : public IPC_SAP_Connect
{
friend class IPC_SAP_Listener;
public:
  IPC_SAP_Stream (void);
  IPC_SAP_Stream (const SAP_Addr &remote_sap, int async = 0, int protcol_family = 		2		 , int protocol = 0);
  int open (const SAP_Addr &remote_sap, int async = 0, int protcol_family = 		2		 , int protocol = 0);
  int  close_reader (void);
  int  close_writer (void);
  int  send_n (const void *buf, int n, int flags = 0) const;
  int  recv_n (void *buf, int n, int flags = 0) const;
  int  send_urg (void *ptr, int len = sizeof (char));
  int  recv_urg (void *ptr, int len = sizeof (char));
};
class IPC_SAP_Listener : public IPC_SAP
{
public:
  IPC_SAP_Listener (void);
  IPC_SAP_Listener (const SAP_Addr &remote_sap, int async = 0, int micro_sec_delay = -1, int protocol_family = 		2		 , int backlog = 5, int protocol = 0);
  int open (const SAP_Addr &remote_sap, int async = 0, int micro_sec_delay = -1, int protocol_family = 		2		 , int backlog = 5, int protocol = 0);
  int accept (IPC_SAP_Stream &new_ipc_sap, SAP_Addr *remote_addr = 0, int restart = 1) const;
  int operator () (IPC_SAP_Stream &new_ipc_sap, SAP_Addr *remote_addr = 0, int restart = 1) const;
protected:
  int micro_second_delay;
protected:
  int shared_open (const SAP_Addr &remote_sap, int backlog);
  int shared_accept (SAP_Addr *remote_addr, int restart) const;
};
class Local_IPC_SAP
{
public:
  int send_fd (const int fds) const;
  int recv_fd (int &fds) const;
protected:
  Local_IPC_SAP (void);
  Local_IPC_SAP (int fd);
  void set_fd (int fd);
private:
  int sok_fd;
};
class Local_IPC_SAP_Stream : public IPC_SAP_Stream, public Local_IPC_SAP
{
friend class Local_IPC_SAP_Listener;
public:
  Local_IPC_SAP_Stream (void);
  Local_IPC_SAP_Stream (const SAP_Addr &remote_sap, int async = 0, int protocol_family = 		1		 , int protocol = 0);
  int open (const SAP_Addr &remote_sap, int async = 0, int protcol_family = 		1		 , int protocol = 0);
  void set_fd (int fd);
  int send_msg (const iovec iov[], int n, int fd);
  int recv_msg (iovec iov[], int n, int &fd);
private:
  int  get_peer_info (SAP_Addr &) const;
  int  get_host_info (SAP_Addr &) const;
};
class Local_IPC_SAP_Listener : public IPC_SAP_Listener
{
public:
  Local_IPC_SAP_Listener (void);
  Local_IPC_SAP_Listener (const SAP_Addr &remote_sap, int async = 0, int micro_sec_delay = -1, int protocol_family = 		1		 , int backlog = 5, int protocol = 0);
  int  open (const SAP_Addr &remote_sap, int async = 0, int micro_sec_delay= -1, int protocol_family = 		1		 , int backlog = 5, int protocol = 0);
  int  accept (Local_IPC_SAP_Stream &new_ipc_sap, SAP_Addr * = 0, int restart = 1) const;
  int  operator () (Local_IPC_SAP_Stream &new_ipc_sap, SAP_Addr * = 0, int restart = 1) const;
};
class Handle_L_Stream : public Event_Handler, public Local_IPC_SAP_Listener
{
public:
  Handle_L_Stream (void);
  Handle_L_Stream (const SAP_UNIX_Addr &suas, int async = 0);
  int open (const SAP_UNIX_Addr &suas, int async = 0);
  virtual int get_fd (void) const;
  virtual int handle_input (int ready_fd);
  virtual int handle_sigio (int ready_fd);
  virtual int make_async (void);
private:
  static char *login_name;
  static Handle_L_Stream dummy;
};
class IPC_SAP_Dgram : public IPC_SAP
{
public:
  IPC_SAP_Dgram (void);
  IPC_SAP_Dgram (const SAP_Addr &local, int async = 0, int protocol_family = 		2		 , int protocol = 0);
  int open (const SAP_Addr &local, int async = 0, int protocol_family = 		2		 , int protocol = 0);
  int send (const void *buf, int n, const SAP_Addr &addr, int flags = 0) const;
  int send (const iovec iov[], int n, const SAP_Addr &addr, int flags = 0) const;
  int recv (void *buf, int n, SAP_Addr &addr, int flags = 0) const;
  int recv (iovec iov[], int n, SAP_Addr &addr, int flags = 0) const;
private:
  int shared_open (const SAP_Addr &local, int protocol_family);
};
class Local_IPC_SAP_Dgram : public IPC_SAP_Dgram, public Local_IPC_SAP
{
public:
  Local_IPC_SAP_Dgram (void);
  Local_IPC_SAP_Dgram (const SAP_Addr &local, int async = 0, int protocol_family = 		1		 , int protocol = 0);
  int open (const SAP_Addr &local, int async = 0, int protocol_family = 		1		 , int protocol = 0);
private:
};
class Handle_L_Dgram : public Event_Handler, public Local_IPC_SAP_Dgram
{
public:
  Handle_L_Dgram (void);
  Handle_L_Dgram (const SAP_UNIX_Addr &suad, int async = 0);
  int open (const SAP_UNIX_Addr &suad, int async = 0);
  virtual int get_fd (void) const;
  virtual int handle_input (int ready_fd);
};
class IPC_SAP_CODgram : public IPC_SAP_Connect
{
public:
  IPC_SAP_CODgram (void);
  IPC_SAP_CODgram (const SAP_Addr &remote_sap, const SAP_Addr &local_sap = sap_any, int async = 0, int protocol_family = 		2		 , int protocol = 0);
  int open (const SAP_Addr &remote_sap, const SAP_Addr &local_sap = sap_any, int async = 0, int protocol_family = 		2		 , int protocol = 0);
private:
  int shared_open (const SAP_Addr &remote_sap, const SAP_Addr &local_sap, int protocol_family);
};
class Local_IPC_SAP_CODgram : public IPC_SAP_CODgram, public Local_IPC_SAP
{
public:
  Local_IPC_SAP_CODgram (void);
  Local_IPC_SAP_CODgram (const SAP_Addr &remote_sap, const SAP_Addr &local_sap = sap_any, int async = 0, int protocol_family = 		1		 , int protocol = 0);
  int open (const SAP_Addr &remote_sap, const SAP_Addr &local_sap = sap_any, int async = 0, int protocol_family = 		1		 , int protocol = 0);
};
class Handle_L_CODgram : public Event_Handler, public Local_IPC_SAP_CODgram
{
public:
  Handle_L_CODgram (void);
  Handle_L_CODgram (const SAP_UNIX_Addr &suad, int async = 0);
  int open (const SAP_UNIX_Addr &suad, int async = 0);
  virtual int get_fd (void) const;
  virtual int handle_input (int ready_fd);
};
class Handle_L_Pipe : public Event_Handler, public Local_IPC_SAP_Listener
{
public:
  Handle_L_Pipe (void);
  Handle_L_Pipe (const SAP_UNIX_Addr &suap, int async = 0);
  int open (const SAP_UNIX_Addr &suap, int async = 0);
  virtual int get_fd (void) const;
  virtual int handle_input (int ready_fd);
  virtual int handle_sigio (int ready_fd);
  virtual int make_async ();
};
class IPC_SAP_FIFO_Msg
{
public:
  IPC_SAP_FIFO_Msg (int length = 0, void *message = 0);
  long len;
  void *mesg;
};
class IPC_SAP_FIFO
{
public:
  IPC_SAP_FIFO (void);
  IPC_SAP_FIFO (const char *rendezvous, int flags, int perms);
  int open (const char *rendezvous, int flags, int perms);
  int close (void);
  int enable (int num) const;
  int disable (int num) const;
  void set_fd (int fd);
  int get_fd (void) const;
protected:
  int fifo_fd;
};
class IPC_SAP_FIFO_Send : public IPC_SAP_FIFO
{
public:
  IPC_SAP_FIFO_Send (void);
  IPC_SAP_FIFO_Send (const char *rendezvous, int flags = 1 , int perms = 0666);
  int open (const char *rendezvous, int flags = 1 , int perms = 0666);
  int send (void *buf, int len);
};
class IPC_SAP_FIFO_Send_Msg : public IPC_SAP_FIFO_Send
{
public:
  IPC_SAP_FIFO_Send_Msg (void);
  IPC_SAP_FIFO_Send_Msg (const char *rendezvous, int flags = 1 , int perms = 0666);
  int open (const char *rendezvous, int flags = 1 , int perms = 0666);
  int send (IPC_SAP_FIFO_Msg &msg);
};
class IPC_SAP_FIFO_Recv : public IPC_SAP_FIFO
{
public:
  IPC_SAP_FIFO_Recv (void);
  IPC_SAP_FIFO_Recv (const char *rendezvous, int flags = 0 , int perms = 0666, int persistent = 1);
  int open (const char *rendezvous, int flags = 0 , int perms = 0666, int persistent = 1);
  int recv (void *buf, int len);
};
class IPC_SAP_FIFO_Recv_Msg : public IPC_SAP_FIFO_Recv
{
public:
  IPC_SAP_FIFO_Recv_Msg (void);
  IPC_SAP_FIFO_Recv_Msg (const char *rendezvous, int flags = 0 , int perms = 0666, int persistent = 1);
  int open (const char *rendezvous, int flags = 0 , int perms = 0666, int persistent = 1);
  int recv (IPC_SAP_FIFO_Msg &msg);
};
class Handle_L_FIFO_Msg : public Event_Handler, public IPC_SAP_FIFO_Recv_Msg
{
public:
  Handle_L_FIFO_Msg (void);
  Handle_L_FIFO_Msg (char *rendezvous_fifo);
  int open (char *rendezvous_fifo);
  virtual int get_fd (void) const;
  virtual int handle_input (int ready_fd);
  virtual int make_async (void);
  virtual int handle_sigio (int ready_fd);
};
class SAP_INET_Addr : public SAP_Addr
{
public:
  SAP_INET_Addr (void);
  SAP_INET_Addr (const SAP_INET_Addr &);
  SAP_INET_Addr (unsigned short port_number, const char host_name[]);
  SAP_INET_Addr (unsigned short port_number, long ip_addr = 	(u_long)0x00000000 );
  void set (unsigned short port_number, const char host_name[]);
  void set (unsigned short port_number, long ip_addr = 	(u_long)0x00000000 );
  virtual void   *get_addr (void) const;
  virtual int    operator == (const SAP_Addr &SAP) const;
  virtual int    operator != (const SAP_Addr &SAP) const;
  const char     *get_host_name (void) const;
  const	char     *get_host_addr (void) const;
  unsigned long  get_ip_address (void) const;
  unsigned short get_port_number (void) const;
private:
  sockaddr_in inet_addr;
};
class Handle_R_Stream : public Event_Handler, public IPC_SAP_Listener
{
public:
  Handle_R_Stream (void);
  Handle_R_Stream (const SAP_INET_Addr &sia, int async = 0);
  virtual int get_fd (void) const;
  virtual int exception_raised (int ready_fd);
  virtual int handle_input (int ready_fd);
  virtual int handle_sigio(int ready_fd);
private:
  static Handle_R_Stream dummy;
  static char		 *login_name;
  IPC_SAP_Stream	 new_remote_stream;
};
class Handle_R_Dgram : public Event_Handler, public IPC_SAP_Dgram
{
public:
  Handle_R_Dgram (void);
  Handle_R_Dgram (const SAP_INET_Addr &r, int async = 0);
  int open (const SAP_INET_Addr &r, int async = 0);
  virtual int get_fd (void) const;
  virtual int handle_input (int ready_fd);
  virtual int handle_sigio(int ready_fd);
  virtual int make_async (void);
};
class Handle_Broadcast : public Event_Handler, public IPC_SAP_Dgram
{
public:
  Handle_Broadcast (void);
  Handle_Broadcast (const SAP_INET_Addr &r, int async = 0);
  int open (const SAP_INET_Addr &r, int async = 0);
  virtual int get_fd (void) const;
  virtual int handle_input (int ready_fd);
};
class Handle_Timeout : public Event_Handler
{
public:
  Handle_Timeout (void);
  int get_fd (void) const;
  int handle_timeout (const Time_Value &tv);
};
class IO_Handlers
{
public:
  enum IO_Handler_Type
  {
    LOCAL_STREAM = 1,
    LOCAL_DGRAM,
    LOCAL_CODGRAM,
    LOCAL_PIPE,
    LOCAL_FIFO,
    REMOTE_STREAM,
    REMOTE_DGRAM,
    BROADCAST,
  };
  IO_Handler_Type type;
  const Event_Handler *handler;
};
class Timer_Handlers
{
public:
  enum Timer_Handler_Type
  {
    TIMER_ZERO = 0,
    TIMER_ONE  = 1
  };
  Timer_Handlers (Timer_Handler_Type t, Event_Handler *h, Time_Value v1, Time_Value v2)
                 : type (t), handler (h), t1 (v1), t2 (v2) {}
  Timer_Handler_Type type;
  const Event_Handler *handler;
  Time_Value t1;
  Time_Value t2;
};
extern IO_Handlers IO_handlers[];
extern Timer_Handlers timer_handlers[];
Handle_L_Stream   local_stream;
Handle_L_Dgram    local_dgram;
Handle_L_CODgram  local_codgram;
Handle_L_Pipe	  local_pipe;
Handle_L_FIFO_Msg local_fifo;
Handle_R_Stream   remote_stream;
Handle_R_Dgram    remote_dgram;
Handle_Broadcast  broadcast;
IO_Handlers IO_handlers[] =
{
  { IO_Handlers::LOCAL_STREAM,  &local_stream },
  { IO_Handlers::LOCAL_DGRAM,   &local_dgram },
  { IO_Handlers::LOCAL_CODGRAM, &local_codgram },
  { IO_Handlers::LOCAL_PIPE,	&local_pipe },
  { IO_Handlers::LOCAL_FIFO,    &local_fifo },
  { IO_Handlers::REMOTE_STREAM, &remote_stream },
  { IO_Handlers::REMOTE_DGRAM,  &remote_dgram },
  { IO_Handlers::BROADCAST,	&broadcast },
  { 0, 0 }
};
Handle_Timeout handle_timeout;
Timer_Handlers th1 (Timer_Handlers::TIMER_ONE, &handle_timeout, Timer_Queue::zero, Timer_Queue::zero);
Timer_Handlers th2 (Timer_Handlers::TIMER_ZERO, 0, Timer_Queue::zero, Timer_Queue::zero);
Timer_Handlers timer_handlers[2] =
{
  th1, th2
};