a.out.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef __A_OUT_H__
#define __A_OUT_H__

/*
 * COFF excerpted from Intel 386 Architecture BCS Supplement, draft 3/3/90
 */

struct	filehdr {
	unsigned short	f_magic;	/* I386MAGIC */
	unsigned short	f_nscns;		/* unused by system */
	long	f_timdat;			/* unused by system */
	long	f_symptr;			/* unused by system */
	long	f_nsyms;			/* unused by system */
	unsigned short	f_opthdr;	/* sizeof(opthdr) */
	unsigned short	f_flags;		/* unused by system */
};

#define	I286MAGIC	0x152
#define	I386MAGIC	0x14C

#define	F_RELFLG	00001
#define	F_EXEC		00002
#define	F_LNNO		00004
#define	F_LSYMS		00008
#define	F_SWABD		00100
#define	F_AR16WR	00200
#define	F_AR12WR	00400

struct aouthdr {
	short	magic;			/* [ONZ]_MAGIC */
	short	vstamp;				/* unused by system */
	long	tsize;				/* unused by system */
	long	dsize;				/* unused by system */
	long	bsize;				/* unused by system */
	long	entry;			/* address to start execution */
	long	tstart;				/* unused by system */
	long	dstart;				/* unused by system */
};

#define	O_MAGIC		0407
#define	N_MAGIC		0410
#define	I_MAGIC		0411
#define	Z_MAGIC		0413

struct scnhdr {
	char	s_name[8];			/* unused by system */
	long	s_paddr;			/* unused by system */
	long	s_vaddr;		/* offset of section - memory(bytes)*/
	long	s_size;			/* section size (bytes) */
	long	s_scnptr;		/* offset of section - file (bytes) */
					/* if zero -> BSS segment */
	long	s_relptr;			/* unused by system */
	long	s_lnnoptr;			/* unused by system */
	unsigned short s_nreloc;		/* unused by system */
	unsigned short s_lnno;			/* unused by system */
	long	s_flags;		/* see below */
};

#define	STYP_REG	0x000
#define	STYP_DSECT	0x001
#define	STYP_NOLOAD	0x002
#define	STYP_GROUP	0x004
#define	STYP_PAD	0x008
#define	STYP_COPY	0x010
#define	STYP_TEXT	0x020
#define	STYP_DATA	0x040
#define	STYP_BSS	0x080
#define	STYP_INFO	0x200
#define	STYP_OVER	0x400			/* not supported */
#define	STYP_LIB	0x800			/* not supported */

#if	NUSEG
/*
 * It is not at all clear who uses this stuff below, or why the magic user-
 * namespace symbol NUSEG is needed. NUSEG is actually part of the deep
 * kernel internal stuff...
 */
	/*
	 * xechdr corresponds to the least commmon denominator
	 * of the COFF format and the <l.out> format 286 Coherent used
	 */ 

struct	xecseg {
	unsigned	mbase;
	unsigned	size;
	unsigned	fbase;
};

struct	xechdr {
	unsigned	magic;
	unsigned	entry;
	unsigned	initsp;
	struct	xecseg segs[NUSEG+1];		/* text, data, bss, stack */ 
};

struct	xecnode {
	int	segtype;			/* 0..NUSEG */
	struct	xecseg xseg;
	struct	xecnode *xn;
};

#endif	/* NUSEG */

#define	XMAGIC(a, b)	((a<< 16) | b)

#endif

acct.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	 __ACCT_H__
#define	 __ACCT_H__

/*
 * Accounting structure.
 */

#include <common/__time.h>
#include <common/_uid.h>

typedef	unsigned short	comp_t;

struct acct {
	char		ac_comm [10];	/* Command name */
	comp_t		ac_utime;	/* User time */
	comp_t		ac_stime;	/* System time */
	comp_t		ac_etime;	/* Elapsed time */
	__time_t	ac_btime;	/* Beginning time of process */
	o_uid_t		ac_uid;		/* User id */
	o_gid_t		ac_gid;		/* Group id */
	short		ac_mem;		/* Average memory usage */
	comp_t		ac_io;		/* Number of disk I/O blocks */
	o_dev_t		ac_tty;		/* Control typewriter */
	char		ac_flag;	/* Accounting flag */
};


/*
 * Flags (ac_flag).
 */
#define AFORK	01			/* Execute fork, but not exec */
#define ASU	02			/* Used super user privileges */

#endif	/* ! defined (__ACCT_H__) */

sys/acct.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	 __SYS_ACCT_H__
#define	 __SYS_ACCT_H__

#include <common/__time.h>
#include <common/_uid.h>

typedef	unsigned short	comp_t;


struct acct {
	char		ac_comm [10];	/* Command name */
	comp_t		ac_utime;	/* User time */
	comp_t		ac_stime;	/* System time */
	comp_t		ac_etime;	/* Elapsed time */
	__time_t	ac_btime;	/* Beginning time of process */
	o_uid_t		ac_uid;		/* User id */
	o_gid_t		ac_gid;		/* Group id */
	short		ac_mem;		/* Average memory usage */
	comp_t		ac_io;		/* Number of disk I/O blocks */
	o_dev_t		ac_tty;		/* Control typewriter */
	char		ac_flag;	/* Accounting flag */
};

/*
 * Flags (ac_flag).
 */
#define AFORK	01			/* Execute fork, but not exec */
#define ASU	02			/* Used super user privileges */

#endif

sys/errno.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__SYS_ERRNO_H__
#define	__SYS_ERRNO_H__

#include <common/feature.h>

/*
 * Error numbers for DDI/DKI drivers, as described in errnos (D5DK) in the
 * System V, Release 4 Multiprocessor "Device Driver Interface/Driver-Kernel
 * Interface Reference Manual".
 *
 * Actual numeric values of error constants are derived from the System V ABI
 * "Intel 386 Processor Supplement".
 *
 * If these definitions are to be imported by <errno.h>, they *must* be macros
 * rather than enumerations or other kinds of constant, as required by the ISO
 * C standard (ISO/IEC 9989-1990).
 *
 * User-level programs should not use this file directly.
 */

#define	EPERM		1	/* Permission denied. */
#define	ENOENT		2	/* No such file or directory. */
#define	ESRCH		3	/* No such process. */
#define	EINTR		4	/* Interrupted system call. */
#define	EIO		5	/* I/O error. */
#define	ENXIO		6	/* No such device or address. */
#define	E2BIG		7	/* Argument list too long. */
#define	ENOEXEC		8	/* Exec format error. */
#define	EBADF		9	/* Bad file number. */
#define	ECHILD		10	/* No child processes. */
#define	EAGAIN		11	/* No more processes. */
#define	ENOMEM		12	/* Not enough space. */
#define	EACCES		13	/* Permission denied. */
#define	EFAULT		14	/* Bad address. */
#define	ENOTBLK		15	/* Block device required. */
#define	EBUSY		16	/* Device busy. */
#define EEXIST		17	/* File exists. */
#define	EXDEV		18	/* Cross-device link. */
#define	ENODEV		19	/* No such device. */
#define ENOTDIR		20	/* Not a directory. */
#define	EISDIR		21	/* Is a directory. */
#define	EINVAL		22	/* Invalid argument. */
#define	ENFILE		23	/* File-table overflow. */
#define	EMFILE		24	/* Too many open files. */
#define	ENOTTY		25	/* Not a teletypewriter (tty) */
#define	ETXTBSY		26	/* Text file busy. */
#define	EFBIG		27	/* File too large. */
#define	ENOSPC		28	/* No space left on device. */
#define	ESPIPE		29	/* Tried to seek on a pipe */
#define	EROFS		30	/* Read-only file system. */
#define	EMLINK		31	/* Too many links. */
#define	EPIPE		32	/* Broken pipe. */
#define	EDOM		33	/* Math argument out of domain of function. */
#define	ERANGE		34	/* Math result not representable. */
#define	ENOMSG		35	/* No message of desired type. */
#define	EIDRM		36	/* Identifier removed. */
#define	EDEADLK		45	/* Deadlock condition. */
#define	ENOLCK		46	/* No record locks available. */
#define	ENOSTR		60	/* Device not a stream. */
#define	ENODATA		61	/* No data available. */
#define	ETIME		62	/* Timer expired. */
#define	ENOSR		63	/* Out of STREAMS resources. */
#define	ENOPKG		65	/* Package not installed. */
#define	EPROTO		71	/* Protocol error. */
#define EBADMSG		77	/* Not a data message. */
#define	ENAMETOOLONG	78	/* File name too long. */
#define	EOVERFLOW	79	/* Value too large for defined data type. */
#define	ENOTUNIQ	80	/* Name not unique on network. */
#define	EBADFD		81	/* File descriptor in bad state. */
#define	EREMCHG		82	/* Remote address changed. */
#define	ELIBACC		83	/* Cannot access a needed shared library. */
#define	ELIBBAD		84	/* Accessing a corrupted shared library. */
#define	ELIBSCN		85	/* ".lib" section in "a.out" corrupted. */
#define	ELIBMAX		86	/* Attempting to link in more shared libraries
				   than system limit. */
#define	ELIBEXEC	87	/* Cannot exec () a shared library directly. */
#define	EILSEQ		88	/* Illegal byte sequence. */
#define	ENOSYS		89	/* Operation not applicable. */
#define	ELOOP		90	/* Number of symbolic links encountered during
				   path name traversal exceeds MAXSYMLINKS. */
#define	EUSERS		94	/* Too many users. */
#define	ENOTSOCK	95	/* Socket operation on non-socket. */
#define	EDESTADDRREQ	96	/* Destination address required. */
#define	EMSGSIZE	97	/* Message too long. */
#define	EPROTOTYPE	98	/* Protocol wrong type for socket. */
#define	ENOPROTOOPT	99	/* Protocol not available. */
#define	EPROTONOSUPPORT	120	/* Protocol not supported. */
#define	ESOCKTNOSUPPORT	121	/* Socket type not supported. */
#define	EOPNOTSUPP	122	/* Operation not supported on transport
				   endpoint. */
#define	EPFNOSUPPORT	123	/* Protocol family not supported. */
#define	EAFNOSUPPORT	124	/* Address family not supported by protocol
				   family. */
#define	EADDRINUSE	125	/* Address already in use. */
#define	EADDRNOTAVAIL	126	/* Cannot assign requested address. */
#define	ENETDOWN	127	/* Network is down. */
#define	ENETUNREACH	128	/* Network is unreachable. */
#define	ENETRESET	129	/* Network dropped connection because of
				   reset. */
#define	ECONNABORTED	130	/* Software-caused connection abort. */
#define	ECONNRESET	131	/* Connection reset by peer. */
#define	ENOBUFS		132	/* No buffer space available. */
#define	EISCONN		133	/* Transport endpoint is already connected. */
#define	ENOTCONN	134	/* Transport endpoint is not connected. */
#define	ESHUTDOWN	143	/* Cannot send after transport endpoint
				   shutdown. */
#define	ETIMEDOUT	145	/* Connection timed out. */
#define	ECONNREFUSED	146	/* Connection refused. */
#define	EHOSTDOWN	147	/* Host is down. */
#define	EHOSTUNREACH	148	/* No route to host. */
#define	EALREADY	149	/* Operation already in progress. */
#define	EINPROGRESS	150	/* Operation now in progress. */
#define	ESTALE		151	/* Stale NFS file handle. */

/*
 * Alias for compatibility with socket-based network sources; not for use in
 * new code or driver code.
 */

#define	EWOULDBLOCK	EAGAIN

#if	_KERNEL || _DDI_DKI_IMPL

/*
 * Driver code can use the following instead of touching the U area. Note that
 * these functions are not part of the DDI/DKI, but the DDI/DKI implementation
 * wants them.
 */

#include <common/ccompat.h>

__EXTERN_C_BEGIN__

int		get_user_error	__PROTO ((void));
void		set_user_error	__PROTO ((int));

__EXTERN_C_END__

#endif

#endif	/* ! defined (__SYS_ERRNO_H__) */

sys/signal.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */
#ifndef	__SYS_SIGNAL_H__
#define	__SYS_SIGNAL_H__

#include <common/feature.h>
#include <common/_signal.h>

/*
 * Signal numbers, to be used by DDI/DKI device drivers, as described in
 * signals(D5DK). The numeric values are taken from the System V, Release 4
 * "Programmer's Reference Manual".
 *
 * If the values in this header are to be imported from <signal.h>, then the
 * signal-number constants are required to be macros expanding to positive
 * integral constants as per the ISO C standard (ISO/IEC 9989:1990).
 *
 * This header file should not be directly used by user-level code.
 */

#define	SIGHUP		1	/*
				 * Hangup: the device has been disconnected
				 * (DDI/DKI).
				 * Default action: terminate.
				 */
#define	SIGINT		2	/*
				 * Interrupt: the interrupt character has been
				 * received (DDI/DKI).
				 * Default action: terminate.
				 */
#define	SIGQUIT		3	/*
				 * Quit: the quit character has been received
				 * (DDI/DKI).
				 * Default action: terminate with core image.
				 */
#define	SIGILL		4	/*
				 * Illegal instruction.
				 * Default action: terminate with core image.
				 */
#define	SIGTRAP		5	/*
				 * Trace/Breakpoint trap.
				 * Default action: terminate with core image.
				 */
#define	SIGABRT		6	/*
				 * Abort.
				 * Default action: terminate with core image.
				 */
#define	SIGIOT		SIGABRT	/* Obsolete */
#define	SIGEMT		7	/*
				 * Emulation trap.
				 * Default action: terminate with core image.
				 */
#define	SIGFPE		8	/*
				 * Arithmetic exception.
				 * Default action: terminate with core image.
				 */
#define	SIGKILL		9	/*
				 * Kill. It is an error to request a non-
				 * default disposition for this signal. This
				 * signal cannot be blocked.
				 * Default action: terminate.
				 */
#define	SIGBUS		10	/*
				 * Bus error.
				 * Default action: terminate with core image.
				 */
#define	SIGSEGV		11	/*
				 * Segmentation violation.
				 * Default action: terminate with core image.
				 */
#define	SIGSYS		12	/*
				 * Bad system call.
				 * Default action: terminate with core image.
				 */
#define	SIGPIPE		13	/*
				 * Broken pipe. A write was attempted to a
				 * pipe with no readers.
				 * Default action: terminate.
				 */
#define	SIGALRM		14	/*
				 * Alarm timer expired.
				 * Default action: terminate.
				 */
#define	SIGTERM		15	/*
				 * Terminate.
				 * Default action: terminate.
				 */
#define	SIGUSR1		16	/*
				 * User signal 1.
				 * Default action: terminate.
				 */
#define	SIGUSR2		17	/*
				 * User signal 2.
				 * Default action: terminate.
				 */
#define	SIGCHLD		18	/*
				 * Child status changed.
				 * Default action: ignore.
				 */
#define	SIGCLD		SIGCHLD	/*
				 * Obsolete alias for SIGCHLD.
				 */
#define	SIGPWR		19	/*
				 * Power-failure/restart.
				 * Default action: ignore.
				 */
#define	SIGWINCH	20	/*
				 * Window size changed (DDI/DKI).
				 * Default action: ignore.
				 */
#define	SIGURG		21	/*
				 * Urgent data are available (DDI/DKI).
				 * Default action: ignore.
				 */
#define	SIGPOLL		22	/*
				 * Pollable event. A process must specifically
				 * register to receive this signal (DDI/DKI).
				 * Default action: terminate.
				 */
#define	SIGIO		SIGPOLL	/* Obsolete BSD definition */
#define	SIGSTOP		23	/*
				 * Stop. Discards pending SIGCONT.
				 * Default action: stop.
				 */
#define	SIGTSTP		24	/*
				 * Interactive stop. Discards pending SIGCONT.
				 * DDI/DKI character drivers must not send
				 * this signal.
				 * Default action: stop.
				 */
#define	SIGCONT		25	/*
				 * Continue. Dicards pending SIGSTOP, SIGTSTP,
				 * SIGTTIN, and SIGTTOU signals, and continues
				 * the process if it was stopped.
				 * Default action: ignore.
				 */
#define	SIGTTIN		26	/*
				 * Job control on input. Discards pending
				 * SIGCONT.
				 * Default action: stop.
				 */
#define	SIGTTOU		27	/*
				 * Job control on output. Discards pending
				 * SIGCONT.
				 * Default action: stop.
				 */
#define	SIGVTALRM	28	/*
				 * Virtual timer expired.
				 * Default action: terminate.
				 */
#define	SIGPROF		29	/*
				 * Profiling timer expired.
				 * Default action: terminate.
				 */
#define	SIGXCPU		30	/*
				 * CPU time limit exceeded.
				 * Default action: terminate with core image.
				 */
#define	SIGXFSZ		31	/*
				 * File size limit exceeded.
				 * Default action: terminate with core image.
				 */

#if	! _STDC_SOURCE && ! _POSIX_C_SOURCE
#define NSIG		(_SIGNAL_MAX + 1)	/* Number of signals */
#endif

/*
 * Special arguments to signal.
 */

#define SIG_DFL		((__sighand_t *) 0)	/* Default */
#define SIG_IGN		((__sighand_t *) 1)	/* Ignore */

#if	! _STDC_SOURCE

#define SIG_ERR		((__sighand_t *) -1)	/* Error */
#define SIG_HOLD	((__sighand_t *) 2)	/* Hold */

#if	_SYSV4 && ! _SYSV3

typedef	n_sigset_t	sigset_t;

struct sigaction {
	int		sa_flags;
	__sighand_t   *	sa_handler;
	sigset_t	sa_mask;
	int		__NON_POSIX (sa_resv) [2];
};

#define	SA_NOCLDSTOP	((long) __SF_NOCLDSTOP) << 16)

#if	! _POSIX_C_SOURCE

#define	SA_ONSTACK	__SA_ONSTACK
#define	SA_RESETHAND	__SA_RESETHAND
#define	SA_RESTART	__SA_RESTART
#define	SA_SIGINFO	__SA_SIGINFO
#define	SA_NODEFER	__SA_NODEFER
#define	SA_NOCLDWAIT	((long) __SF_NOCLDWAIT << 16)

#endif

#else	/* ! _SYSV4 */

typedef	o_sigset_t	sigset_t;

struct sigaction {
	__sighand_t   *	sa_handler;
	sigset_t	sa_mask;
	int		sa_flags;
};

#define	SA_NOCLDSTOP		1

#endif	/* ! _SYSV4 */

/*
 * "how" flags for sigprocmask ()
 */

#define	SIG_SETMASK		0
#define	SIG_BLOCK		1
#define	SIG_UNBLOCK		2

#endif	/* ! _STDC_SOURCE */

#endif	/* ! defined (__SYS_SIGNAL_H__) */

sys/stat.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__SYS_STAT_H__
#define	__SYS_STAT_H__

#include <common/feature.h>
#include <common/ccompat.h>
#include <common/__time.h>
#include <common/__off.h>
#include <common/_fsize.h>
#include <common/_uid.h>
#include <common/__stat.h>
#include <common/_imode.h>
#include <common/_timestr.h>

/*
 * Structure returned by stat () and fstat () system calls.
 *
 * Some configuration systems do some ill-advised things such as using 'grep'
 * to determine whether a system is capable of supporting the R4 version of
 * the "stat" structure, so we must hide the definition by default.
 */

#ifdef	__R4STAT_TAG

struct __R4STAT_TAG {
	n_dev_t		st_dev;		/* device */
	long		__pad1 [3];
	n_ino_t		st_ino;		/* inode number */
	n_mode_t	st_mode;	/* permission bits */
	n_nlink_t	st_nlink;	/* link count */
	n_uid_t		st_uid;		/* owner */
	n_gid_t		st_gid;		/* group */
	n_dev_t		__NON_POSIX (st_rdev);
					/* directory device */
	long		__pad2 [2];
	__off_t		st_size;	/* current size */
	long		__pad3;
	__timestruc_t	st_atim;	/* time of last access */
	__timestruc_t	st_mtim;	/* time of last modification */
	__timestruc_t	st_ctim;	/* time of creation */
	long		__NON_POSIX (st_blksize);
					/* preferred operation size */
	long		__NON_POSIX (st_blocks);
					/* total size in allocated blocks */
	char		__NON_POSIX (st_fstype) [_ST_FSTYPSZ];
					/* file-system type name */
	long		__pad4 [8];
};

#endif	/* ! defined (__R4STAT_TAG) */


struct __R3STAT_TAG {
	o_dev_t		st_dev;		/* Device */
	o_ino_t		st_ino;		/* Inode number	*/
	o_mode_t	st_mode;	/* Mode	*/
	o_nlink_t	st_nlink;	/* Link count */
	o_uid_t		st_uid;		/* User id */
	o_gid_t		st_gid;		/* Group id */
	o_dev_t	 	__NON_POSIX (st_rdev);
					/* Real device */
	__off_t		st_size;	/* Size */
	__time_t	st_atime;	/* Access time */
	__time_t	st_mtime;	/* Modify time */
	__time_t	st_ctime;	/* Change time */
};


#if	_SYSV4 && ! _DDI_DKI

#define	st_atime	st_atim.tv_sec
#define	st_mtime	st_mtim.tv_sec
#define	st_ctime	st_ctim.tv_sec

#endif


/*
 * Mode macros. Note that the following definitions are required to be
 * macros. Several packages also use them in #if-expressions, so we
 * cannot base them on the underlying versions in <common/_imode.h>.
 */

#define	S_IFMT		0xF000		/* Type	mask */
#define	S_IFDIR		0x4000		/* Directory */
#define	S_IFCHR		0x2000		/* Character special */
#define	S_IFPIP		0x1000		/* Pipe	*/
#define	S_IFIFO		0x1000		/* Pipe	*/
#define	S_IFBLK		0x6000		/* Block special */
#define	S_IFREG		0x8000		/* Regular */
#define	S_IFSOCK	0x1000		/* Socket */


#define	S_ISUID		0x0800		/* Set user id on execution	*/
#define	S_ISGID		0x0400		/* Set group id on execution	*/
#define	S_ISVTX		0x0200		/* Save swapped text even after use */

#define	S_IREAD		0x0100		/* Read permission, owner	*/
#define	S_IWRITE	0x0080		/* Write permission, owner	*/
#define	S_IEXEC		0x0040		/* Execute/search permission, owner */
#define	S_IRWXU		0x01C0		/* RWX permission, owner	*/
#define	S_IRUSR		0x0100		/* Read permission, owner	*/
#define	S_IWUSR		0x0080		/* Write permission, owner	*/
#define	S_IXUSR		0x0040		/* Execute/search permission, owner */
#define	S_IRWXG		0x0038		/* RWX permission, group	*/
#define	S_IRGRP		0x0020		/* Read permission, group	*/
#define	S_IWGRP		0x0010		/* Write permission, group	*/
#define	S_IXGRP		0x0008		/* Execute/search permission, group */
#define	S_IRWXO		0x0007		/* RWX permission, other	*/
#define	S_IROTH		0x0004		/* Read permission, other	*/
#define	S_IWOTH		0x0002		/* Write permission, other	*/
#define	S_IXOTH		0x0001		/* Execute/search permission, other */

/* Mode test macros. */

#define	S_ISFIFO(mode)	(((mode) & S_IFMT) == S_IFIFO)
#define	S_ISSOCK(mode)	(((mode) & S_IFMT) == S_IFSOCK)
#define	S_ISCHR(mode)	(((mode) & S_IFMT) == S_IFCHR)
#define	S_ISDIR(mode)	(((mode) & S_IFMT) == S_IFDIR)
#define	S_ISBLK(mode)	(((mode) & S_IFMT) == S_IFBLK)
#define	S_ISREG(mode)	(((mode) & S_IFMT) == S_IFREG)


#if	! (_DDI_DKI || _KERNEL)

__EXTERN_C_BEGIN__

int		chmod		__PROTO ((__CONST__ char * _path,
					  __mode_t _mode));
int		fstat		__PROTO ((int _fildes, struct stat * _buf));
int		mkdir		__PROTO ((__CONST__ char * _path,
					  __mode_t _mode));
int		mkfifo		__PROTO ((__CONST__ char * _path,
					  __mode_t _mode));
int		mknod		__PROTO ((__CONST__ char * _path,
					  __mode_t _mode, __dev_t _dev));
int		stat		__PROTO ((__CONST__ char * _path,
					  struct stat * _buf));
__mode_t	umask		__PROTO ((__mode_t _mask));

__EXTERN_C_END__

#endif	/* ! (_DDI_DKI || _KERNEL) */

#if	! _DDI_DKI

/*
 * Nonexistent device.
 * Must compare correctly with dev_t, which is an unsigned short in the
 * internal COHERENT device-driver system.
 */

#ifndef	NODEV
# define NODEV		((__dev_t) -1)
#endif


/*
 * Functions.
 */
#define	major(dev)	(((dev) >> 8) & 0xFF)
#define minor(dev)	((dev) & 0xFF)
#define makedev(m1, m2)	((__dev_t) (((m1) << 8) | (m2)))

#endif	/* ! _DDI_DKI */

#endif	/* ! defined (__SYS_STAT_H__) */

sys/fdioctl.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef __SYS_FDIOCTL_H__
#define __SYS_FDIOCTL_H__

/*
 * Floppy I/O control commands.
 */

#define FDIOC		('F'<<8)
#define FDFORMAT	(FDIOC|1)	/* Format diskette track */

/*
 * Formatting information is largely supplied
 * by the low nibble of the minor device number opened for formatting
 * which will specify the number of heads and the track density.
 *	0	1 head, 40 tracks, 8 sectors per track
 *	1	2 heads, 40 tracks, 8 sectors per track
 *	2	2 heads, 80 tracks, 8 sectors per track
 *	3	1 head, 40 tracks, 9 sectors per track
 *	4	2 heads, 40 tracks, 9 sectors per track
 *	5	2 heads, 80 tracks, 9 sectors per track
 * Each FDFORMAT command will format a single track.
 * The parameter block consists of an array of fform structures
 * one for each sector being formatted specifying the cylinder,
 * head, sector number, and size of the sector.
 */

struct fform {
	char	ff_cylin;	/* 0 .. number of tracks - 1 */
	char	ff_head;	/* 0 or 1 */
	char	ff_sect;	/* 1 .. number of sectors */
	char	ff_size;	/* 1, 2, or 3 for 256, 512, or 1024 */
};

#endif	/* ! defined (__SYS_FDIOCTL_H__) */

sys/haiioctl.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */
/***********************************************************************
 *  Module: haiioctl.h
 *  
 *  Definitions and declarations needed to implement and use the haiioctl
 *  call.
 *  
 *  Copyright (c) 1993 Christopher Sean Hilton All rights reserved.
 */

#ifndef __HAIIOCTL_H__
#define __HAIIOCTL_H__

#include <sys/haiscsi.h>
 
#define HAI_IOC		0x49414800	/* "\0HAI"  on intel machines */
#define HAIINQUIRY	(HAI_IOC | 1)	/* Inquiry Command */
#define HAIMDSNS0	(HAI_IOC | 2)	/* Group 0 Mode Sense */
#define HAIMDSLCT0	(HAI_IOC | 3)	/* Group 0 Mode Select */
#define HAIMDSNS2	(HAI_IOC | 4)	/* Group 2 Mode Sense */
#define HAIMDSLCT2	(HAI_IOC | 5)	/* Group 2 Mode Select */
#define HAIUSERCDB	(HAI_IOC | 6)	/* User Selected command (be careful) */

/***********************************************************************
 *  haiusercdb  --  Use this layout to get I/O Control info to or from
 *                  a particular device on the scsi bus.  Note well
 *                  that you will need to be the super user in order
 *                  to use the HAIUSERCDB I/O Control.
 */

typedef struct haiusercdb_s *haiusercdb_p;

typedef struct haiusercdb_s {
	cdb_t		cdb;		/* CDB you want to run */
	char		sensebuf[HAI_SENSELEN]; /* Sensebuf for returned errors */
	unsigned short	status;		/* Device Status after command */
	unsigned short	hastat;		/* Host Adapter Status after command */
	unsigned short	timeout;	/* Time to live */
	unsigned short	xferdir;	/* Transfer direction */
	size_t		buflen;		/* Buffer length */
	char		buf[0];		/* Start of buffer (C++ okay!?) */
} haiusercdb_t;

#endif	/* ! defined (__HAIIOCTL_H__) */

sys/hdioctl.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef __SYS_HDIOCTL_H__
#define	__SYS_HDIOCTL_H__

#include <common/feature.h>

/*
 * Ioctl support for hard disk devices.
 */

#define	HDIOC	('H' << 8)
#define	HDGETA	(HDIOC|1)	/* get drive attributes */
#define	HDSETA	(HDIOC|2)	/* set drive attributes */
#define HDGETIDEINFO (HDIOC|4)	/* get result of IDE info command */

/*
 * Configuration word (ii_config) meanings by bit number
 * 0:  ?
 * 1:  Hard sectored
 * 2:  Soft sectored
 * 3:  Not MFM encoded
 * 4:  Head Switch Time > 15 usec
 * 5:  Spindled Motor Control Option Implemented
 * 6:  Fixed Drive
 * 7:  ?
 * 8:  Disk Transfer Rate <= 5Mbs
 * 9:  Disk Transfer Rate > 5Mbs but <= 10 Mbs
 * 10: Disk Transfer Rate > 10Mbs
 * 11: Rotational Speed Tolerance > 0.5%
 * 12: Data Strobe Offset Option Available
 * 13: Track Offset Option Available
 * 14: Format Speed Tolerance Gap Required
 * 15: ?
 */

typedef struct ide_info {
  unsigned short ii_config;	/* Configuration */
  unsigned short ii_cyl;	/* Cylinders (default xlat mode) */
  unsigned short ii_reserved;	/* reserved */
  unsigned short ii_heads;	/* heads (default xlat mode */
  unsigned short ii_bpt;	/* bytes per track (unformatted) */
  unsigned short ii_bps;	/* bytes per sector (unformatted) */
  unsigned short ii_spt;	/* sectors per track (default xlat mode) */
  unsigned short ii_vendor1[3];	/* vendor unique data */
  unsigned short ii_serialnum[10]; /* serial number in ASCII */
  unsigned short ii_buffertype;	/* buffer type */
  unsigned short ii_buffersize;	/* buffer size in 512 byte sectors */
  unsigned short ii_eccbyteslong; /* ecc bytes for r/w long */
  unsigned short ii_firmrev[4];	/* firmware revision in ascii */
  unsigned short ii_modelnum[20]; /* model number in ascii */
  unsigned short ii_doublewordio; /* double word transfer flag */
  unsigned short ii_capabilities; /* capabilities */
  unsigned short ii_reserved2;	/* reserved */
  unsigned short ii_piomode;	/* PIO data xfer timing mode */
  unsigned short ii_dmamode;	/* DMA data xfer timing mode */
  unsigned short ii_reserved3[75]; /* reserved */
  unsigned short ii_vendor2[32]; /* vendor unique data */
  unsigned short ii_reserved4[96]; /* reserved */
} ide_info_t;


/*
 * Drive attributes
 * Note: all fields defined as bytes to prevent compiler arith probs.
 *	All multi-byte fields are stored low-byte first.
 * This struct is configured for binary compatibility with ROM data!
 */

typedef struct hdparm_s {
	unsigned char	ncyl[2];	/* number of cylinders */
	unsigned char	nhead;		/* number heads */
	unsigned char	rwccp[2];	/* reduced write curr cyl */
	unsigned char	wpcc[2];	/* write pre-compensation cyl */
	unsigned char	eccl;		/* max ecc data length */
	unsigned char	ctrl;		/* control byte */
	unsigned char	fill2[3];
	unsigned char	landc[2];	/* landing zone cylinder */
	unsigned char	nspt;		/* number of sectors per track */
	unsigned char	hdfill3;
} hdparm_t;


/* Macro for initializing drive parameter tables. */

#define _HDPARMS(cyl,hd,spt,ctl,pcomp)	{ \
	{ (cyl) & 0xFF, (cyl) >> 8 }, hd, { 0, 0 }, \
	{ (pcomp) & 0xFF, (pcomp) >> 8 }, 0, ctl, \
	{ 0, 0, 0 }, { 0 , 0 }, spt, 0 }


/* Convert from a 2-element unsigned char array to unsigned short. */
/* Copy number into a 2-element unsigned char array. */

#if	_I386

#define _CHAR2_TO_USHORT(c_array)	(* (unsigned short *) (c_array))
#define	_NUM_TO_CHAR2(c_array, num)	(* (unsigned short *) (c_array) = (num))

#else

#define _CHAR2_TO_USHORT(c_array)	\
	((unsigned short) ((c_array)[1] << 8) | (c_array)[0])
/#define _NUM_TO_CHAR2(c_array, num) \
	(((c_array)[0] = (num) & 0xFF), ((c_array)[1] = (num) >> 8))

#endif


#if	_KERNEL
#define N_ATDRV	2U			/* only two drives supported */
#endif

#endif /* ! defined (__SYS_HDIOCTL_H__) */

sys/ioctl.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__SYS_IOCTL_H__
#define	__SYS_IOCTL_H__

/*
 * This header is not defined by iBCS2, the System V ABI, POSIX.1, or POSIX.2,
 * but many applications include it.  This stub permits such programs to
 * compile; the real ioctl information is in the respective driver's header.
 */

#endif	/* ! defined (__SYS_IOCTL_H__) */

sys/lpioctl.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__SYS_LPIOCTL_H__
#define	__SYS_LPIOCTL_H__

#define	LPRAW	0		/* Set raw (no special characters) mode */
#define	LPPLEN	1		/* Set lp page length (non-raw)--def. 66 */
#define	LPLLEN	2		/* Set lp line length (non-raw)--def. 132 */

#endif

sys/mtioctl.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	 __SYS_MTIOCTL_H__
#define	 __SYS_MTIOCTL_H__

/*
 * Magnetic tape ioctl commands.
 */

#define MTIOC		('M'<<8)
#define MTREWIND 	(MTIOC|1)	/* Rewind */
#define	MTWEOF	 	(MTIOC|2)	/* Write end of file mark */
#define MTRSKIP	 	(MTIOC|3)	/* Record skip */
#define MTFSKIP	 	(MTIOC|4)	/* File skip */
#define MTDEC	 	(MTIOC|5)	/* DEC mode */
#define MTIBM	 	(MTIOC|6)	/* IBM mode */
#define MT800	 	(MTIOC|7)	/* 800 bpi */
#define MT1600	 	(MTIOC|8)	/* 1600 bpi */
#define	MT6250	 	(MTIOC|9)	/* 6250 bpi */

#define MTTENSE	 	(MTIOC|10)	/* Tension tape */
#define	MTERASE	 	(MTIOC|11)	/* Erase tape */

#endif	/* ! defined (__SYS_MTIOCTL_H__) */

sys/sdioctl.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef __SYS_SDIOCTL_H__
#define __SYS_SDIOCTL_H__

/*
 * ioctl constants for SCSI devices.
 */

#define	SDIOC		('S'<<8)
#define	SCSI_HA_CMD	(SDIOC|0)
#define	SCSI_CMD	(SDIOC|1)
#define	SCSI_CMD_IN	(SDIOC|2)
#define	SCSI_CMD_OUT	(SDIOC|3)

/*
 * Temporary additions for haiscsi from C. Hilton
 */
#define SDGTINQ     (SDIOC | 0)     /* Get inquiry info */

#endif	/* ! defined (__SYS_SDIOCTL_H__) */

sys/tnioctl.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__SYS_TNIOCTL_H__
#define	__SYS_TNIOCTL_H__

#define	TNIOC	('N' << 8)
#define	TNGETA	(TNIOC|1)	/* Get node attributes */
#define	TNGETAF	(TNIOC|2)	/* Get node attributes, clear node stats */

#define	NTNST	8		/* Number of network statistics */

/*
 * Network node attributes.
 * Maintained on a per node id basis.
 * NOTE: Node id 0 is used for totals.
 */

typedef struct tnattr {
	unsigned char	host[6];	/* host id - node id in host[5] */
	unsigned char	bad;		/* non-zero if node is down */
	unsigned char	fill;		/* reserved, also for alignment */
	unsigned long	recons;		/* network reconfigurations */
	unsigned long	stats[NTNST];	/* statistics */
} tnattr_t ;


/*
 * Statistics maintained per node.
 */

#define	TnRxBYTES	0	/* # bytes received from node */
#define	TnTxBYTES	1	/* # bytes transmitted to node */
#define	TnRxPACKS	2	/* # packets received from node */
#define	TnTxPACKS	3	/* # packets transmitted to node */
#define	TnDISCARD	4	/* # packets discarded [to node] */
#define	TnSTATMOD	5	/* # status transitions on node */
#define	TnWRTDLYS	6	/* # delayed writes */
#define	TnELAPSED	7	/* elapsed time for stats in ticks */

#endif	/* ! defined (__SYS_TNIOCTL_H__) */

sys/ftioctl.h

#ifndef __FTIOCTL_H__
#define __FTIOCTL_H__

/* Get up to 29 KBytes of QIC-40/QIC-80 tape header information. */

struct FtHdrBuf {
	unsigned int	bufLen;
	unsigned char *	buffer;
};

#define	FT_IOC		(('F' << 16) | ('t' << 8))

#define FT_GET_HEADER	(FT_IOC | 1)
#define FT_SET_HEADER	(FT_IOC | 2)
#define FT_GET_OFFSET	(FT_IOC | 3)
#define FT_SET_OFFSET	(FT_IOC | 4)

/* Test area. */

#define FT_FIND_SEG	50	/* test ioctl command */
#define FT_PRINT_STAT	51	/* test ioctl command */
#define FT_SKIP_TAPE	52	/* test ioctl command */
#define FT_PRINT_STAT2	53	/* test ioctl command */
#define FT_READ_POS	54	/* test ioctl command */
#define FT_STOP_TAPE	55	/* test ioctl command */
#define FT_SPECIFY	56	/* test ioctl command */
#define FT_READ_BLOCKS	57	/* test ioctl command */
#define FT_READ_SEGMENTS	58	/* test ioctl command */

#define FT_FAKE_BBT_MAP	60
#define FT_FAKE_BBT_SEG	61
#define FT_FAKE_IOERR	62

#endif /* __FTIOCTL_H__ */

sys/ipc.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef __SYS_IPC_H__
#define	__SYS_IPC_H__

#include <common/feature.h>
#include <common/_ipcperm.h>

/*
 * IPC Mode bits.
 */

#define	__IPC_ALLOC	0x8000		/* entry currently allocated */
#define	IPC_CREAT	0x0200		/* create entry if key doesn't exist */
#define	IPC_EXCL	0x0400		/* fail if key exists */
#define	IPC_NOWAIT	0x0800		/* error if request must wait */


/*
 * IPC Keys.
 */

#define IPC_PRIVATE	((key_t) 0)

/*
 * IPC Control Commands.
 */

#define	IPC_RMID	0		/* remove identifier */
#define	IPC_SET		1		/* set options */
#define	IPC_STAT	2		/* get options */

#if	_KERNEL

#include <common/ccompat.h>

/*
 * Common framework for IPC permissions-checking.
 */

__EXTERN_C_BEGIN__

int		ipc_cred_match	__PROTO ((struct ipc_perm * _ipcp));
int		ipc_lack_perm	__PROTO ((struct ipc_perm * _ipcp,
					  __mode_t _mode));
void		ipc_perm_init	__PROTO ((struct ipc_perm * _ipcp,
					  __mode_t _mpde));

__EXTERN_C_END__

#endif	/* _KERNEL */

#endif	/* ! defined (__SYS_IPC_H__) */

sys/deftty.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef __SYS_DEFTTY_H__
#define __SYS_DEFTTY_H__

/*
 * Coherent - default tty settings.
 *	used by sys/drv/tty.c, src/cmd0/getty.c, and src/cmd0/login.c
 *	to initialize terminal characteristics.
 */

#if	'A' != 65 || '@' != 64
# error	Your native character set should be ASCII
#else
# define	__CTRL(c)	((c) - '@')
#endif

#define DEF_SG_ISPEED	B9600
#define DEF_SG_OSPEED	B9600
#define	DEF_SG_ERASE	'\b'
#define	DEF_SG_KILL	__CTRL ('U')
#define	DEF_SG_FLAGS	(CRMOD | ECHO | XTABS | CRT)
#define	DEF_T_INTRC	__CTRL ('C')
#define	DEF_T_QUITC	__CTRL ('\\')
#define	DEF_T_STARTC	__CTRL ('Q')
#define	DEF_T_STOPC	__CTRL ('S')
#define	DEF_T_EOFC	__CTRL ('D')
#define	DEF_T_BRKC	-1

#endif	/* ! defined (__SYS_DEFTTY_H__) */

sys/ktty.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	 __SYS_KTTY_H__
#define	 __SYS_KTTY_H__

/*
 * Kernel portion of typewriter structure.
 */

#include <common/feature.h>
#include <kernel/timeout.h>
#include <sys/poll.h>
#include <sys/clist.h>
#include <sgtty.h>
#include <termio.h>

#define	NCIB	256		/* Input buffer */
#define	OHILIM	500		/* Output buffer hi water mark */
#define	OLOLIM	40		/* Output buffer lo water mark */
#define	IHILIM	512		/* Input buffer hi water mark */
#define	ILOLIM	40		/* Input buffer lo water mark */
#define	ITSLIM	(IHILIM-(IHILIM/4))	/* Input buffer tandem stop mark */
#define	ESC	'\\'		/* Some characters */

typedef struct tty {
	CQUEUE	t_oq;		/* Output queue */
	CQUEUE	t_iq;		/* Input queue */
	char	*t_ddp;		/* Device specific */
	int	(*t_start)();	/* Start function */
	int	(*t_param)();	/* Load parameters function */
	char	t_dispeed;	/* Default input speed */
	char	t_dospeed;	/* Default output speed */
	int	t_open;		/* Open count */
	int	t_flags;	/* Flags */
	char	t_nfill;	/* Number of fill characters */
	char	t_fillb;	/* The fill character */
	int	t_ibx;		/* Input buffer index */
	char	t_ib[NCIB];	/* Input buffer */
	int	t_hpos;		/* Horizontal position */
	int	t_opos;		/* Original horizontal position */
	struct	sgttyb t_sgttyb;/* Stty/gtty information */
	struct	tchars t_tchars;/* Tchars information */
	struct	termio t_termio;
	int	t_group;	/* Process group */
	int	t_escape;	/* Pending escape count */
	event_t t_ipolls;	/* List of input polls enabled on device */
	event_t t_opolls;	/* List of output polls enabled on device */
	TIM	t_rawtim;	/* Raw timing struct */
	int	t_cs_sel;	/* ... obsolete ... */
	TIM	t_vtime;	/* VTIME timing struct */
	TIM	t_sbrk;		/* TCSBRK timing struct */
} TTY;

/*
 * Test macros for various conditions related to the terminal settings; the
 * tests are related to conditions at the granularity of the System V modes,
 * so for COHERENT-286 the conditions are synthesized from the old V7 modes.
 */

#define	_IS_BREAK_CHAR(tp,c)	((tp)->t_tchars.t_brkc == (c))

/*
 * The following are not part of S5 sgtty.
 */

#define	_IS_RAW_INPUT_MODE(tp)	(((tp)->t_sgttyb.sg_flags & RAWIN) != 0)
#define	_IS_CRT_MODE(tp)	(((tp)->t_sgttyb.sg_flags & CRT) != 0)

#define	_IS_EOF_CHAR(tp,c)	((tp)->t_termio.c_cc [VEOF] == (c))
#define	_IS_ERASE_CHAR(tp,c)	((tp)->t_termio.c_cc [VERASE] == (c))
#define	_IS_INTERRUPT_CHAR(tp,c) \
				((tp)->t_termio.c_cc [VINTR] == (c))
#define	_IS_KILL_CHAR(tp,c)	((tp)->t_termio.c_cc [VKILL] == (c))
#define	_IS_QUIT_CHAR(tp,c)	((tp)->t_termio.c_cc [VQUIT] == (c))
#define	_IS_START_CHAR(tp,c)	(CSTART == (c))
#define	_IS_STOP_CHAR(tp,c)	(CSTOP == (c))

#define	_IS_CANON_MODE(tp)	(((tp)->t_termio.c_lflag & ICANON) != 0)
#define	_IS_ECHO_MODE(tp)	(((tp)->t_termio.c_lflag & ECHO) != 0)
#define _IS_ICRNL_MODE(tp)	(((tp)->t_termio.c_iflag & ICRNL) != 0)
#define _IS_IGNCR_MODE(tp)	(((tp)->t_termio.c_iflag & IGNCR) != 0)
#define	_IS_ISIG_MODE(tp)	(((tp)->t_termio.c_lflag & ISIG) != 0)
#define	_IS_ISTRIP_MODE(tp)	(((tp)->t_termio.c_iflag & ISTRIP) != 0)
#define _IS_IXON_MODE(tp)	(((tp)->t_termio.c_iflag & IXON) != 0)
#define _IS_IXANY_MODE(tp)	(((tp)->t_termio.c_iflag & IXANY) != 0)
#define _IS_OCRNL_MODE(tp)	(((tp)->t_termio.c_oflag & OCRNL) != 0)
#define _IS_ONLCR_MODE(tp)	(((tp)->t_termio.c_oflag & ONLCR) != 0)
#define	_IS_RAW_OUT_MODE(tp)	(((tp)->t_termio.c_oflag & OPOST) == 0)
#define	_IS_TANDEM_MODE(tp)	(((tp)->t_termio.c_iflag & IXOFF) != 0)
#define	_IS_XTABS_MODE(tp)	(((tp)->t_termio.c_oflag & TABDLY) == TAB3)

#endif	/* ! defined (__SYS_KTTY_H__) */

sys/tty.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__SYS_TTY_H__
#define	__SYS_TTY_H__

#include <common/feature.h>

#define	T_HILIM	0x0001		/* Hi water mark wait */
#define	T_DRAIN	0x0002		/* Drain wait */
#define	T_INPUT	0x0004		/* Input wait */
#define T_IFULL	0x0008		/* Input buffer full */
#define	T_INL	0x0010		/* Insert newline */
#define	T_STOP	0x0020		/* Stopped */
#define	T_HPCL	0x0040		/* Hang up dataset on last close */
#define	T_EXCL	0x0080		/* Exclusive use */
#define	T_TSTOP	0x0100		/* Tandem input stop */
#define	T_ISTOP	0x0200		/* Input overflow stop */
#define T_MODC	0x0400		/* Modem control */
#define T_CARR	0x0800		/* Carrier detect status */
#define	T_HOPEN	0x2000		/* Hanging in open (for modem control) */
#define	T_HCLOS	0x4000		/* Hanging in close (for modem control) */
#define	T_CFLOW	0x8000		/* Use RTS/CTS flow control */
#define	T_XSTOP	0x10000		/* Stopped by receiving a Ctrl-S */

#define NMODC	0x80		/* Minor device modem control bit */
				/* Set for NO modem control       */
#define CPOLL	0x40		/* Minor device polled driver bit */
				/* Set for polled operation       */
				/* Clear for IRQ operation        */
#define CFLOW	0x20		/* Minor device flow control bit  */
				/* Set for RTS/CTS flow control   */
				/* Clear for none                 */

#if	_KERNEL
#include <sys/ktty.h>
#endif

#endif	/* ! defined (__SYS_TTY_H__) */

arcoff.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */
/*		COMMON ARCHIVE FORMAT
*
*	ARCHIVE File Organization:
*	_______________________________________________
*	|__________ARCHIVE_MAGIC_STRING_______________|
*	|__________ARCHIVE_FILE_MEMBER_1______________|
*	|					      |
*	|	Archive File Header "ar_hdr"          |
*	|.............................................|
*	|	Member Contents			      |
*	|		1. External symbol directory  |
*	|		2. Text file		      |
*	|_____________________________________________|
*	|________ARCHIVE_FILE_MEMBER_2________________|
*	|		"ar_hdr"		      |
*	|.............................................|
*	|	Member Contents (.o or text file)     |
*	|_____________________________________________|
*	|	.		.		.     |
*	|	.		.		.     |
*	|	.		.		.     |
*	|_____________________________________________|
*	|________ARCHIVE_FILE_MEMBER_n________________|
*	|		"ar_hdr"		      |
*	|.............................................|
*	|		Member Contents 	      |
*	|_____________________________________________|
*
*/
#ifndef __ARCOFF_H__
#define __ARCOFF_H__

#define ARMAG	"!<arch>\n"
#define SARMAG	8
#define ARFMAG	"`\n"

struct ar_hdr		/* archive file member header - printable ascii */
{
	char	ar_name[16];	/* file member name - `/' terminated */
	char	ar_date[12];	/* file member date - decimal */
	char	ar_uid[6];	/* file member user id - decimal */
	char	ar_gid[6];	/* file member group id - decimal */
	char	ar_mode[8];	/* file member mode - octal */
	char	ar_size[10];	/* file member size - decimal */
	char	ar_fmag[2];	/* ARFMAG - string to end header */
};

#endif

coff.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef __COFF_H__
#define __COFF_H__

#include <common/ccompat.h>

/*
 * Common Object File Format (COFF) header for COHERENT.
 */

/* File header. */
typedef	struct	filehdr	{
	unsigned short	f_magic;		/* Magic number		*/
	unsigned short	f_nscns;		/* Number of sections	*/
	long		f_timdat;		/* Time and date	*/
	long		f_symptr;		/* Seek to symbol table	*/
	long		f_nsyms;		/* Number of symbols	*/
	unsigned short	f_opthdr;		/* Optional header size	*/
	unsigned short	f_flags;		/* Flags		*/
}	FILHDR;
#define	FILHSZ	(sizeof (FILHDR))

/* Magic number. */
#define	C_386_MAGIC	0x14C			/* Intel iAPX 80386	*/
#define ISCOFF(x)	((x) == C_386_MAGIC)

/* Flags for f_flags field. */
#define	F_RELFLG	0x0001			/* No relocation info	*/
#define	F_EXEC		0x0002			/* Executable		*/
#define	F_LNNO		0x0004			/* No line numbers	*/
#define	F_LSYMS		0x0008			/* No local symbols	*/
#define F_MINMAL	0x0010			/* Product of strip	*/
#define	F_AR32WR	0x0100			/* i80x86 byte order	*/
#define F_KER		0x0800			/* Loadable driver	*/

/* Optional header. */
typedef struct aouthdr	{
	short		magic;			/* AOUT_MAGIC		*/
	short		vstamp;			/* Version stamp	*/
	long		tsize;			/* .text size in bytes	*/
	long		dsize;			/* .data size in bytes	*/
	long		bsize;			/* .bss  size in bytes	*/
	long		entry;			/* Entry point		*/
	long		text_start;		/* Base of .text data	*/
	long		data_start;		/* Base of .data data	*/
} AOUTHDR;

/* Magic numbers for aouthdr.magic;  COHERENT only supports Z_MAGIC. */
#define O_MAGIC	0x107	/* .text and .data are contiguous, .text not shared */
#define N_MAGIC 0x108	/* .data starts at seg after .text .text is protected */
#define I_MAGIC 0x109	/* sep id */
#define Z_MAGIC 0x10B	/* .text and .data aligned for direct page */

/* Section header. */
typedef	struct	scnhdr	{
	char		s_name[8];		/* Section name		*/
	long		s_paddr;		/* Physical address	*/
	long		s_vaddr;		/* Virtual address	*/
	long		s_size;			/* Size			*/
	long		s_scnptr;		/* Data pointer		*/
	long		s_relptr;		/* Reloc pointer	*/
	long		s_lnnoptr;		/* Line number pointer	*/
	unsigned short	s_nreloc;		/* Reloc entries	*/
	unsigned short	s_nlnno;		/* Line number entries	*/
	long		s_flags;		/* Flags		*/
}	SCNHDR;

/* Names of special sections */
#define _TEXT	".text"
#define _DATA	".data"
#define _BSS	".bss"
#define	_COMMENT ".comment"
#define _TV	".tv"
#define _INIT	".init"
#define _FINI	".fini"
#define _RODATA ".rodata"

/* Flags for s_flags field. */
#define STYP_GROUP	0x004L			/* Grouped section	*/
#define STYP_PAD	0x008L			/* Padding section	*/
#define STYP_COPY	0x010L			/* Copy section		*/
#define	STYP_TEXT	0x020L			/* Code segment		*/
#define	STYP_DATA	0x040L			/* Data segment		*/
#define	STYP_BSS	0x080L			/* BSS segment		*/
#define STYP_INFO	0x200L			/* Comment section	*/
#define STYP_OVER	0x400L			/* Overlay section	*/
#define STYP_LIB	0x800L			/* Shared library	*/

/*
 * Shared Library Section.
 * Followed by implementation dependent data
 * and a path name aligned on a dword boundary.
 */
typedef	struct	shrlib	{
	long		entsz;			/* Entry size in longs	*/
	long		pathndx;		/* Path offset in longs	*/
}	SHRLIB;


/* Relocation items. */
typedef	struct	reloc	{
	long		r_vaddr __ALIGN (2);	/* Address (where)	*/
	long		r_symndx __ALIGN (2);	/* Symbol index (what)	*/
	unsigned short	r_type;			/* Type (how)		*/
#pragma	align 2
}	RELOC;
#pragma	align	/* control structure padding with Coherent 'cc' */

#define RELSZ	(sizeof (RELOC))

/* Relocation types. */
#define	R_DIR8		0x07			/* 8-bit direct		*/
#define	R_DIR16		0x01			/* 16-bit direct	*/
#define	R_DIR32		0x06			/* 32-bit direct	*/
#define R_RELBYTE	0x0f			/* 8 bit direct		*/
#define R_RELWORD	0x10			/* 16 bit direct	*/
#define R_RELLONG	0x11			/* 32 bit direct	*/
#define	R_PCRBYTE	0x12			/* 8-bit PC-relative	*/
#define	R_PCRWORD	0x13			/* 16-bit PC-relative	*/
#define	R_PCRLONG	0x14			/* 32-bit PC-relative	*/
#define R_NONREL	0x00			/* Fake item for ld -r	*/

/* Line number. */
typedef struct lineno {
	union	{
		long	l_symndx;		/* Fn name symbol index	*/
		long	l_paddr;		/* Physical address	*/
	} l_addr __ALIGN (2);
	unsigned short l_lnno;			/* Line num., 0 for fn	*/
#pragma	align 2
}	LINENO;
#pragma	align	/* control structure padding with Coherent 'cc' */

#define	LINESZ	(sizeof (LINENO))

/* Symbol table. */
#define	SYMNMLEN	8			/* Symbol name length	*/
#define FILNMLEN	14			/* Chars in file name	*/
#define DIMNUM		4			/* Dims in aux entry	*/

typedef	struct	syment	{
	union	{
		char	_n_name [SYMNMLEN];	/* Name			*/
		struct	{
			long	_n_zeroes;	/* If name[0-3] zero,	*/
			long	_n_offset;	/* string table offset	*/
		} _n_n;
		char	* _n_nptr [2];
	} _n __ALIGN (2);
	long		n_value __ALIGN (2);	/* Value		*/
	short		n_scnum;		/* Section number	*/
	unsigned short	n_type;			/* Type			*/
	char		n_sclass;		/* Storage class	*/
	char		n_numaux;		/* Auxilliary entries	*/
#pragma	align 2
}	SYMENT;
#pragma	align	/* control structure padding with Coherent 'cc' */

#define SYMESZ	(sizeof (SYMENT))
#define	n_name		_n._n_name
#define	n_zeroes	_n._n_n._n_zeroes
#define	n_offset	_n._n_n._n_offset

/* Special section numbers */
#define N_UNDEF	 0				/* Undefined		*/
#define N_ABS	-1				/* Absolute		*/
#define N_DEBUG	-2				/* Debug		*/
#define N_TV	-3		/* Needs preload transfer vector	*/
#define P_TV	-4		/* Needs postload transfer vector	*/

/* Storage classes. */
#define C_EFCN		-1			/* End of function	*/
#define C_NULL		0			/* None			*/
#define C_AUTO		1			/* Automatic		*/
#define	C_EXT		2			/* External		*/
#define	C_STAT		3			/* Static		*/
#define C_REG		4			/* Register		*/
#define C_EXTDEF	5			/* External definition  */
#define C_LABEL		6			/* Label		*/
#define C_ULABEL	7			/* Undefined label	*/
#define C_MOS		8			/* Member of structure	*/
#define C_ARG		9			/* Function argument	*/
#define C_STRTAG	10			/* Structure tag	*/
#define	C_MOU		11			/* Member of union	*/
#define C_UNTAG		12			/* Union tag		*/
#define C_TPDEF		13			/* Typedef		*/
#define C_USTATIC	14			/* Undefined static	*/
#define C_ENTAG		15			/* Enum tag		*/
#define C_MOE		16			/* Member of enum	*/
#define C_REGPARM	17			/* Register parameter	*/
#define C_FIELD		18			/* Bit field		*/
#define C_BLOCK		100			/* Block (.bb or .eb)	*/
#define	C_FCN		101			/* Function (.bf or .ef) */
#define C_EOS		102			/* End of structure	*/
#define C_FILE		103			/* File name		*/

#define ISTAG(x)	(C_STRTAG==(x) || C_UNTAG==(x) || C_ENTAG==(x))

/* Fundimental types. */
#define T_NULL		0
#define T_VOID		1
#define T_CHAR		2
#define T_SHORT		3
#define T_INT		4
#define T_LONG		5
#define T_FLOAT		6
#define T_DOUBLE	7
#define T_STRUCT	8
#define T_UNION		9
#define T_ENUM		10
#define T_MOE		11			/* Member of enumeration */
#define T_UCHAR		12
#define T_USHORT	13
#define T_UINT		14
#define T_ULONG		15

/* Derived types in n_type. */
#define DT_NON	0				/* Non-derived type	*/
#define DT_PTR	1				/* Pointer		*/
#define DT_FCN	2				/* Function		*/
#define DT_ARY	3				/* Array		*/

/* Type packing constants. */
#define N_BTMASK	0x0F			/* Mask for basic type	*/
#define N_TMASK 	0x30			/* Derived type mask	*/
#define N_TSHIFT	2			/* Shift for more derived bits */
#define	N_BTSHFT	4			/* Shift for derived type */
 
/* Type processing macros. */
#define BTYPE(x)  ((x) & N_BTMASK)		/* Base type		*/
#define ISPTR(x)  ((DT_PTR<<N_BTSHFT)==((x)&N_TMASK))	/* Pointer?	*/
#define ISFCN(x)  ((DT_FCN<<N_BTSHFT)==((x)&N_TMASK))	/* Function?	*/
#define ISARY(x)  ((DT_ARY<<N_BTSHFT)==((x)&N_TMASK))	/* Array?	*/
#define INCREF(x) ((((x)&~N_BTMASK)<<N_TSHIFT)|(DT_PTR<<N_BTSHFT)|((x)&N_BTMASK))
#define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))

/* Symbol aux entries. */
typedef union auxent	{
	struct	{
		long	x_tagndx;	/* struct/union/enum tag index	*/
		union	{
			struct	{
				unsigned short	x_lnno;	/* Decl. line	*/
				unsigned short	x_size;	/* Size		*/
			} x_lnsz;
			long	x_fsize;	/* Function size	*/
		} x_misc;
		union	{
			struct	{		/* Functions		*/
				long	x_lnnoptr;	/* line # ptr	*/
				long	x_endndx;	/* index of .eb	*/
			} x_fcn;
			struct	{		/* Arrays		*/
				unsigned short x_dimen [DIMNUM];/* Dims	*/
			} x_ary;
		} x_fcnary;
		unsigned short	x_tvndx;	/* TV index		*/
#pragma	align 2
	} x_sym;
#pragma	align	/* control structure padding with Coherent 'cc' */

	struct {				/* File names		*/
		char x_fname [FILNMLEN];	/* File name		*/
	} x_file;

	struct	{				/* Sections		*/
		long	x_scnlen;		/* Section length	*/
		unsigned short	x_nreloc;	/* Reloc entrys		*/
		unsigned short	x_nlinno;	/* Line number entries	*/
	} x_scn;

#pragma	align	2
}	AUXENT;
#pragma	align	/* control structure padding with Coherent 'cc' */

#define	ae_tagndx	x_sym.x_tagndx
#define	ae_lnno		x_sym.x_misc.x_lnsz.x_lnno
#define	ae_size		x_sym.x_misc.x_lnsz.x_size
#define	ae_fsize	x_sym.x_misc.x_fsize
#define	ae_lnnoptr	x_sym.x_fcnary.x_fcn.x_lnnoptr
#define	ae_endndx	x_sym.x_fcnary.x_fcn.x_endndx
#define	ae_dimen	x_sym.x_fcnary.x_ary.x_dimen
#define	ae_tvndx	x_sym.x_tvndx
#define	ae_fname	x_file.x_fname
#define	ae_scnlen	x_scn.x_scnlen
#define	ae_nreloc	x_scn.x_nreloc
#define	ae_nlinno	x_scn.x_nlinno
#define AUXESZ	(sizeof (AUXENT))

int	coffnlist	__PROTO ((char *fn, SYMENT *nlp, char *names,
			  int count));

#endif	/* ! defined (__COFF_H__) */

common/__off.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__COMMON___OFF_H__
#define	__COMMON___OFF_H__

/*
 * This internal header file defines the internal data type "__off_t".
 * It is equivalent to the POSIX.1 data type "off_t" but is given an internal
 * name so that header files may refer to it without exporting the user-level
 * type.
 */

typedef	long		__off_t;

#endif	/* ! defined (__COMMON___OFF_H__) */

common/_off.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__COMMON__OFF_H__
#define	__COMMON__OFF_H__

/*
 * This internal header file is intended as the sole point of definition for
 * the POSIX.1 data type "off_t". 
 */

#include <common/__off.h>

typedef	__off_t		off_t;

#endif	/* ! defined (__COMMON__OFF_H__) */

common/_signal.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__COMMON__SIGNAL_H__
#define	__COMMON__SIGNAL_H__

#include <common/ccompat.h>
#include <common/_limits.h>
#include <common/_tricks.h>

/*
 * This header file contains a number of definitions for signal-related data
 * types used by kernel and user-level mechanisms to support the variety of
 * existing binary interfaces.
 */

/*
 * The following constant gives the number of signals for which kernel storage
 * is made available; this number is traditionally made available to user code
 * though the NSIG constant, although neither Standard C nor POSIX.1
 * applications can use it.
 */

#define	_SIGNAL_MAX		31


/*
 * Be aware that while ISO C and POSIX.1 specify the signature of a signal-
 * catching function as "void (*) (int sig)", extra parameters to the signal
 * functions are supported.
 */

typedef	void	__sighand_t	__PROTO ((__ANY_ARGS__));


/*
 * The following deals with signal actions. For maximum efficiency, we use
 * signals as collections of bit-vectors; various user-level binary
 * compatibility standards specify the lengths of the vectors, whereas the
 * kernel internally allocates exactly as much as is really needed.
 */

typedef	unsigned long		__sigmask_t;

#define	__SIGMASK_BIT		__LONG_BIT

typedef	struct {
	__sigmask_t	_sigbits [4];
} n_sigset_t;

#define	__N_SIGSET_SET(ss, value) \
		((ss)._sigbits [3] = (ss)._sigbits [2] = \
		 (ss)._sigbits [1] = (ss)._sigbits [0] = (value))

typedef	struct {
	__sigmask_t	_sigbits [1];
} o_sigset_t;

#define	__O_SIGSET_SET(ss, value)	(* (ss)._sigbits = (value))

#define	___SIGSET_LEN	__DIVIDE_ROUNDUP_CONST (_SIGNAL_MAX, __SIGMASK_BIT)
typedef struct {
	__sigmask_t	_sigbits [___SIGSET_LEN];
} __sigset_t;

#if	___SIGSET_LEN == 1
#define	___SIGSET_SET(ss, value)	(* (ss)._sigbits = (value))
#elif	___SIGSET_LEN == 2
#define	___SIGSET_SET(ss, value) \
		((ss)._sigbits [1] = (ss)._sigbits [0] = (value))
#else
#error	_SIGNAL_MAX is larger than we expect
#endif


/*
 * Signal-action flags that are relevant for all signals.
 */

enum {
	__SA_ONSTACK	= 1,
	__SA_RESETHAND	= 2,
	__SA_RESTART	= 4,
	__SA_SIGINFO	= 8,
	__SA_NODEFER	= 16
};
typedef	unsigned short	__sigactfl_t;


/*
 * Signal-action flags that are only relevant for particular signals.
 */

enum {
	__SF_NOCLDWAIT	= 1,
	__SF_NOCLDSTOP	= 2
};

typedef	unsigned short	__sigmiscfl_t;


/*
 * Some simple macros for dealing with the bit-set operations on sigset_t's.
 */

#define	__SIGSET_UNIT(ss,n)	\
	(sizeof ((ss)._sigbits) == sizeof (__sigmask_t) ? 0 : \
	 (unsigned) ((n) - 1) / (sizeof (__sigmask_t) * __CHAR_BIT))

#define	__SIGSET_MASK(n)	(1UL << ((unsigned) ((n) - 1) & \
				  (sizeof (__sigmask_t) * __CHAR_BIT - 1)))

#define	__SIGSET_ADDBIT(ss,n)	\
		((ss)._sigbits [__SIGSET_UNIT (ss, n)] |= __SIGSET_MASK (n))
#define	__SIGSET_CLRBIT(ss,n)	\
		((ss)._sigbits [__SIGSET_UNIT (ss, n)] &= ~ __SIGSET_MASK (n))
#define	__SIGSET_TSTBIT(ss,n)	\
		(((ss)._sigbits [__SIGSET_UNIT (ss, n)] & \
		 __SIGSET_MASK (n)) != 0)
#define	__SIGSET_ADDMASK(ss,n,m)	\
		((ss)._sigbits [__SIGSET_UNIT (ss, n)] |= (m))
#define	__SIGSET_CLRMASK(ss,n,m)	\
		((ss)._sigbits [__SIGSET_UNIT (ss, n)] &= ~ (m))
#define	__SIGSET_TSTMASK(ss,n,m)	\
		(((ss)._sigbits [__SIGSET_UNIT (ss, n)] & (m)) != 0)
#define	__SIGSET_FIRSTBIT(mask)		(__LEAST_BIT_ULONG (mask) + 1)


#endif	/* ! defined (__COMMON__SIGNAL_H__) */

common/__stat.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__COMMON___STAT_H__
#define	__COMMON___STAT_H__

/*
 * This internal header file assigns the structure tags used for the various
 * forms of the POSIX.1 file-statistics structure "stat". This structure comes
 * in various incompatible forms as defined in such documents as the System V,
 * release 4 ABI, and the iBCS2 specification; however some code needs to
 * access both forms in a uniform way.
 *
 * Here, we create incomplete type declarations for types that can be used to
 * access either structure uniformly, and assign the structure tags based on
 * the features that are set in the system.
 */

#include <common/feature.h>

#if	_DDI_DKI

#define	__R4STAT_TAG	__r4stat
#define	__R3STAT_TAG	__r3stat

#elif	_SYSV4

#define	__R4STAT_TAG	stat
#define	__R4STAT_TAG	__r3stat

#else

/*
 * Suppress the R4 stat structure to avoid causing problems with auto-config
 * scripts that use 'grep' to determine what members the stat structure has.
 */
/* #define	__R4STAT_TAG	__r4stat */
#define	__R3STAT_TAG	stat

#endif

typedef	struct __R4STAT_TAG	__stat_t;
 
#define	_ST_FSTYPSZ	16

#endif	/* ! defined (__COMMON___STAT_H__) */

ctype.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */
/*
 * C character handling library header.
 * Draft Proposed ANSI C Standard, Section 4.3, 5/13/88 draft.
 * Implemented by table lookup.
 */

#ifndef	__CTYPE_H__
#define	__CTYPE_H__

#include <common/feature.h>
#include <common/ccompat.h>

__EXTERN_C_BEGIN__

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

#if	! _STDC_SOURCE && ! _POSIX_C_SOURCE

int		isascii		__PROTO ((int _c));
int		toascii		__PROTO ((int _c));
int		_tolower	__PROTO ((int _c));
int		_toupper	__PROTO ((int _c));

#endif	/* ! _STDC_SOURCE && ! _POSIX_C_SOURCE */

__EXTERN_C_END__

/*
 * Type table and bit classifications.
 * Table indices: 0==EOF, 1==NUL, ..., 128==DEL, 129==0x80, ..., 256==0xFF.
 * Indices 0 and 129 to 256 are nonASCII characters.
 */
#define	_CTYPEN	257			/* Table size			*/
extern	unsigned char _ctype[_CTYPEN];	/* Type table			*/
#define	_U	0x01			/* Upper case alphabetic	*/
#define	_L	0x02			/* Lower case alphabetic	*/
#define	_A	(_U|_L)			/* Alphabetic			*/
#define	_N	0x04			/* Numeric			*/
#define	_S	0x08			/* White space character	*/
#define	_P	0x10			/* Punctuation character	*/
#define	_C	0x20			/* Control character		*/
#define	_B	0x40			/* Printable but nothing else	*/
#define	_X	0x80			/* Hexadecimal digit		*/

/* Macros covering ANSI Standard functions. */
#define isalnum(c)      ((_ctype [(c) + 1] & (_A|_N)) != 0)
#define isalpha(c)      ((_ctype [(c) + 1] & _A) != 0)
#define iscntrl(c)      ((_ctype [(c) + 1] & _C) != 0)
#define isdigit(c)      ((_ctype [(c) + 1] & _N) != 0)
#define isgraph(c)      ((_ctype [(c) + 1] & (_P | _A | _N)) != 0)
#define islower(c)      ((_ctype [(c) + 1] & _L) != 0)
#define isprint(c)      ((_ctype [(c) + 1] & (_P | _B | _A | _N)) != 0)
#define ispunct(c)      ((_ctype [(c) + 1] & _P) != 0)
#define isspace(c)      ((_ctype [(c) + 1] & _S) != 0)
#define isupper(c)      ((_ctype [(c) + 1] & _U) != 0)
#define isxdigit(c)     ((_ctype [(c) + 1] & _X) != 0)

#if	! _STDC_SOURCE && ! _POSIX_C_SOURCE

#if	'a' - 'A' != 0x20
# error	Your native environment characater set is not ASCII
#endif

#define	isascii(c)	(((c) & ~ 0x7F) == 0)
#define	toascii(c)	((c) & 0x7F)
#define	_tolower(c)	((c) | ('a' - 'A'))
#define	_toupper(c)	((c) & ~ ('a' - 'A'))

#endif	/* ! _STDC_SOURCE && ! _POSIX_C_SOURCE */

#endif	/* ! defined (__CTYPE_H__) */

errno.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	__ERRNO_H__
#define	__ERRNO_H__

#include <common/feature.h>
#include <sys/errno.h>

extern	int		errno;

#if	! _STDC_SOURCE && ! _POSIX_C_SOURCE

extern	int		sys_nerr;
extern	char	      *	sys_errlist [];

#endif

#endif	/* ! defined (__ERRNO_H__) */

signal.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef	 __SIGNAL_H__
#define	 __SIGNAL_H__

#include <common/feature.h>
#include <common/ccompat.h>
#include <common/__pid.h>
#include <sys/signal.h>

typedef	long	sig_atomic_t;


__EXTERN_C_BEGIN__

__sighand_t   *	signal		__PROTO ((int _sig, __sighand_t * _func));
int		raise		__PROTO ((int _sig));

__sighand_t   *	sigset		__PROTO ((int _sig, __sighand_t * _func));
int		sighold		__PROTO ((int _sig));
int		sigignore	__PROTO ((int _sig));
int		sigrelse	__PROTO ((int _sig));
int		sigpause	__PROTO ((int _sig));

#if	! _STDC_SOURCE

int		kill		__PROTO ((__pid_t _pid, int _sig));
int		sigaction	__PROTO ((int _sig,
					  __CONST__ struct sigaction * _act,
					  struct sigaction * _oact));
int		sigaddset	__PROTO ((sigset_t * _set, int _signo));
int		sigdelset	__PROTO ((sigset_t * _set, int _signo));
int		sigemptyset	__PROTO ((sigset_t * _set));
int		sigfillset	__PROTO ((sigset_t * _set));
int		sigismember	__PROTO ((__CONST__ sigset_t * _set,
					  int _signo));
int		sigpending	__PROTO ((sigset_t * _set));
int		sigprocmask	__PROTO ((int _how,
					  __CONST__ sigset_t * _set,
					  sigset_t * _oset));
int		sigsuspend	__PROTO ((__CONST__ sigset_t * _sigmask));

#if	! _SYSV4

/*
 * Pre-SVR4 systems make these available as inlines. For us, this is optional
 * but still legal. For SVR4 systems, we require proper error checking. For
 * this to work, we depend on __SIGSET_UNIT (ss, n) not evaluating "n".
 */

#define	sigfillset(set)		((set)->_sigbits [0] = -1UL, 0)
#define	sigemptyset(set)	((set)->_sigbits [0] = 0)
#define	sigismember(set, signo)	((set)->_sigbits [0] & __SIGSET_MASK (signo))
#define sigaddset(set, signo)	((set)->_sigbits [0] |= \
					__SIGSET_MASK (signo), 0)
#define	sigdelset(set, signo)	((set)->_sigbits [0] &= \
					~ __SIGSET_MASK (signo), 0)

#endif	/* ! _SYSV4 */

#endif	/* ! _STDC_SOURCE */

__EXTERN_C_END__

#endif	/* ! defined (__SIGNAL_H__) */

ustat.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */

#ifndef __USTAT_H__
#define __USTAT_H__

#include <common/__daddr.h>
#include <common/_uid.h>

struct ustat {
	__daddr_t	f_tfree;	/* Total free blocks */
	__ino_t		f_tinode;	/* Number of free inodes */
	char		f_fname[6];	/* File system name (label) */
	char		f_fpack[6];	/* File system pack name */
};

#endif	/* ! defined (__USTAT_H__) */

sgtty.h

/* (-lgl
 *	Coherent 386 release 4.2
 *	Copyright (c) 1982, 1993 by Mark Williams Company.
 *	All rights reserved. May not be copied without permission.
 *	For copying permission and licensing info, write licensing@mwc.com
 -lgl) */
/*
 * Terminal ioctl.
 * This is an IBM-PC special-case file.  Many of these ioctls apply
 * only to the PC console and PC asynchronous ports.
 */

#ifndef	 __SGTTY_H__
#define	 __SGTTY_H__

/*
 * Ioctl functions.
 */

#define	__TIOC		('t' << 8)

#define	TIOCHPCL	(__TIOC | 2)	/* Hang up on last close */
#define	TIOCGETP	(__TIOC | 8)	/* Terminal get modes (old gtty) */
#define	TIOCSETP	(__TIOC | 9)	/* Terminal set modes (old stty) */
#define	TIOCSETN	(__TIOC | 10)	/* Set modes w/o delay or out flush */
#define	TIOCEXCL	(__TIOC | 13)	/* Set exclusive use */
#define	TIOCNXCL	(__TIOC | 14)	/* Set non-exclusive use */
#define TIOCFLUSH	(__TIOC | 16)	/* Flush characters in I/O queues */
#define	TIOCSETC	(__TIOC | 17)	/* Set characters */
#define	TIOCGETC	(__TIOC | 18)	/* Get characters */


/*
 * Structure for TIOVGETB/TIOVPUTB
 */

struct vidctl {
	short	v_position;		/* Position in video memory */
	short	v_count;		/* Number of characters to transfer */
	short	v_buffer;		/* Character buffer to read/write */
};


/*
 * stty/gtty modes.
 */

#define	XTABS	0x0002		/* Expand tabs to spaces */
#define	LCASE	0x0004		/* Lowercase mapping on input */
#define	ECHO	0x0008		/* Echo input characters */
#define CRMOD	0x0010		/* Map '\r' to '\n' */
#define	RAW	0x0020
#define	ODDP	0x0040		/* Allow odd parity */
#define	EVENP	0x0080		/* Allow even parity */
#define	ANYP	0x00C0		/* Allow any parity */


/*
 * The following are not part of S5 sgtty.
 * They are here to allow compilation of old V7 sources.
 */

#define	CBREAK	0x010000	/* Each input character causes wakeup */
#define	TANDEM	0x020000	/* flow control protocol */
#define	CRT	0x040000	/* CRT character erase */
#define RAWIN	0x080000
#define RAWOUT	0x100000


/*
 * Names for terminal speeds.
 */

#define	B0	0		/* Hangup if modem control enabled */
#define	B50	1		/* 50 bps */
#define	B75	2		/* 75 bps */
#define	B110	3		/* 110 bps */
#define	B134	4		/* 134.5 bps (IBM 2741) */
#define	B150	5		/* 150 bps */
#define	B200	6		/* 200 bps */
#define	B300	7		/* 300 bps */
#define	B600	8		/* 600 bps */
#define	B1200	9		/* 1200 bps */
#define	B1800	10		/* 1800 bps */
#define	B2400	11		/* 2400 bps */
#define	B4800	12		/* 4800 bps */
#define	B9600	13		/* 9600 bps */
#define	B19200	14		/* 19200 bps */
#define	B38400	15
#define	EXTA	14
#define	EXTB	15


/*
 * Common definitions for 286/386 versions
 */

#define TIOCCHPCL	0111		/* Don't hang up on last close */
#define TIOCGETTF	0112		/* Get tty flag word */
#define TIOCBREAD	0113		/* Blocking read in CBREAK/RAW mode */
#define TIOCCBREAD	0114		/* Turn off TIOCBREAD */
#define TIOCSHIFT	0115		/* Switch console left-SHIFT & "\" */
#define TIOCCSHIFT	0116		/* Normal console left-SHIFT & "\" */

#define	TIOCQUERY	0120		/* No. of chars waiting for read */

#define	TIOCSETG	0130		/* Set tty process group */

#define	TIOCGETF	0200		/* Get function keys  (dev. dep.) */
#define	TIOCSETF	0201		/* Set function keys  (dev. dep.) */
#define	TIOCGETKBT	0202		/* Get keyboard table (dev. dep.) */
#define	TIOCSETKBT	0203		/* Set keyboard table (dev. dep.) */

/* misc. functions */

#define TIOCSDTR	0301		/* Set DTR */
#define TIOCCDTR	0302		/* Clear DTR */
#define TIOCSRTS	0303		/* Set RTS */
#define TIOCCRTS	0304		/* Clear RTS */
#define TIOCSBRK	0305		/* Set BREAK */
#define TIOCCBRK	0306		/* Clear BREAK */

#define TIOCRSPEED	0320		/* Set "raw" line I/O speed divisor */
#define TIOCWORDL	0321		/* Set line word length and stop bits */

#define TIOCRMSR	0400		/* Get CTS/DSR/RI/RLSD (MSR) */

#define TIOVGETB	0500		/* Read video memory */
#define TIOVPUTB	0501		/* Write video memory */


/*
 * Bits for TIOCRMSR.
 */

#define MSRCTS		1		/* Clear to Send */
#define MSRDSR		2		/* Data Set Ready */
#define MSRRI		4		/* Ring Indicator */
#define MSRRLSD		8		/* Received Line Signal Detect */


/*
 * Attribute masks for TIOVPUTB - attributes occupy odd addresses
 * in video memory.
 */

#define	VNORM	0x07			/* Ordinary Video */
#define	VINTE	0x08			/* Intense video */
#define	VBLIN	0x80			/* Blinking video */
#define	VREVE	0x70			/* Reverse video */
#define	VUNDE	0x01			/* Underline video (mono board) */


/*
 * Structure for TIOCSETP/TIOCGETP
 */

struct sgttyb {
	char	sg_ispeed;		/* Input speed */
	char	sg_ospeed;		/* Output speed */
	char	sg_erase;		/* Character erase */
	char	sg_kill;		/* Line kill character */
	int	sg_flags;		/* Flags */
};


/*
 * Structure for TIOCSETC/TIOCGETC
 */

struct tchars {
	char	t_intrc;		/* Interrupt */
	char	t_quitc;		/* Quit */
	char	t_startc;		/* Start output */
	char	t_stopc;		/* Stop output */
	char	t_eofc;			/* End of file */
	char	t_brkc;			/* Input delimiter */
};

#endif	/* ! defined (__SGTTY_H__) */