#ifndef _h_tc_os
#define _h_tc_os
#ifdef notdef
# define BACKPIPE
#endif
#ifdef __CYGWIN__
# undef NOFILE
# define NOFILE sysconf(_SC_OPEN_MAX)
#endif
#ifdef _VMS_POSIX
# ifndef NOFILE
# define NOFILE 64
# endif
# define nice(a) setprio((getpid()),a)
# include <sys/time.h>
# include <limits.h>
#endif
#if defined(DECOSF1) || defined(HPUXVERSION)
# include <sys/signal.h>
#endif
#ifdef DECOSF1
# include <sys/ioctl.h>
#endif
#if defined(OPEN_MAX) && !defined(NOFILE)
# define NOFILE OPEN_MAX
#endif
#if defined(USR_NFDS) && !defined(NOFILE)
# define NOFILE USR_NFDS
#endif
#ifndef NOFILE
# define NOFILE 256
#endif
#ifdef OREO
# include <sys/time.h>
# ifdef notdef
# include <sys/resource.h>
# endif
# ifdef POSIX
# include <sys/tty.h>
# include <termios.h>
# endif
#endif
#ifdef __QNXNTO__
#include <sys/resource.h>
#include <fcntl.h>
#undef O_TEXT
#undef O_BINARY
#endif
#ifdef convex
# include <sys/dmon.h>
#endif
#ifdef titan
extern int end;
#endif
#ifdef hpux
# ifdef lint
struct ucred {
int foo;
};
# endif
# ifndef CSUSP
# define CSUSP 032
# endif
# include <signal.h>
# if !defined(hp9000s500) && !(defined(SIGRTMAX) || defined(SIGRTMIN))
# include <sys/bsdtty.h>
# endif
# ifndef TIOCSTI
# include <sys/strtio.h>
# endif
#endif
#ifdef ISC
# ifndef CSUSP
# define CSUSP 032
# endif
# if defined(POSIX) && !defined(TIOCGWINSZ)
# define TIOCGWINSZ (('T'<<8)|104)
# endif
#endif
#ifdef ISC202
# undef TIOCGWINSZ
#endif
#if !defined(linux) && !defined(__GNU__) && !defined(__GLIBC__) && !defined(_VMS_POSIX)
# if defined(INTEL) || defined(u3b2) || defined (u3b5) || defined(ub15) || defined(u3b20d) || defined(ISC) || defined(SCO) || defined(tower32)
# ifdef TIOCGWINSZ
# include <sys/stream.h>
# include <sys/ptem.h>
# endif
# endif
#endif
#ifdef IRIS4D
# include <sys/time.h>
# include <sys/resource.h>
#endif
#ifndef WINNT_NATIVE
# ifdef F_SETFD
# ifndef FD_CLOEXEC
# define FD_CLOEXEC 1
# endif
# define close_on_exec(fd, v) fcntl((fd), F_SETFD, ((v) ? FD_CLOEXEC : 0))
# else
# ifdef FIOCLEX
# define close_on_exec(fd, v) ioctl((fd), ((v) ? FIOCLEX : FIONCLEX), NULL)
# else
# define close_on_exec(fd, v)
# endif
# endif
#else
# define close_on_exec(fd, v) nt_close_on_exec((fd),(v))
#endif
#ifdef ISC
# ifndef S_IFMT
# define S_IFMT 0170000
# define S_IFDIR 0040000
# define S_IFCHR 0020000
# define S_IFBLK 0060000
# define S_IFREG 0100000
# define S_IFIFO 0010000
# define S_IFNAM 0050000
# ifndef ISC202
# define S_IFLNK 0120000
# endif
# endif
#endif
#ifdef STAT_MACROS_BROKEN
# undef S_ISDIR
# undef S_ISCHR
# undef S_ISBLK
# undef S_ISREG
# undef S_ISFIFO
# undef S_ISNAM
# undef S_ISLNK
# undef S_ISSOCK
#endif
#ifdef S_IFMT
# if !defined(S_ISDIR) && defined(S_IFDIR)
# define S_ISDIR(a) (((a) & S_IFMT) == S_IFDIR)
# endif
# if !defined(S_ISCHR) && defined(S_IFCHR)
# define S_ISCHR(a) (((a) & S_IFMT) == S_IFCHR)
# endif
# if !defined(S_ISBLK) && defined(S_IFBLK)
# define S_ISBLK(a) (((a) & S_IFMT) == S_IFBLK)
# endif
# if !defined(S_ISREG) && defined(S_IFREG)
# define S_ISREG(a) (((a) & S_IFMT) == S_IFREG)
# endif
# if !defined(S_ISFIFO) && defined(S_IFIFO)
# define S_ISFIFO(a) (((a) & S_IFMT) == S_IFIFO)
# endif
# if !defined(S_ISNAM) && defined(S_IFNAM)
# define S_ISNAM(a) (((a) & S_IFMT) == S_IFNAM)
# endif
# if !defined(S_ISLNK) && defined(S_IFLNK)
# define S_ISLNK(a) (((a) & S_IFMT) == S_IFLNK)
# endif
# if !defined(S_ISSOCK) && defined(S_IFSOCK)
# define S_ISSOCK(a) (((a) & S_IFMT) == S_IFSOCK)
# endif
#endif
#ifdef tower32
# undef S_ISLNK
# undef S_IFLNK
#endif
#ifndef S_IREAD
# define S_IREAD 0000400
#endif
#ifndef S_IROTH
# define S_IROTH (S_IREAD >> 6)
#endif
#ifndef S_IRGRP
# define S_IRGRP (S_IREAD >> 3)
#endif
#ifndef S_IRUSR
# define S_IRUSR S_IREAD
#endif
#ifndef S_IWRITE
# define S_IWRITE 0000200
#endif
#ifndef S_IWOTH
# define S_IWOTH (S_IWRITE >> 6)
#endif
#ifndef S_IWGRP
# define S_IWGRP (S_IWRITE >> 3)
#endif
#ifndef S_IWUSR
# define S_IWUSR S_IWRITE
#endif
#ifndef S_IEXEC
# define S_IEXEC 0000100
#endif
#ifndef S_IXOTH
# define S_IXOTH (S_IEXEC >> 6)
#endif
#ifndef S_IXGRP
# define S_IXGRP (S_IEXEC >> 3)
#endif
#ifndef S_IXUSR
# define S_IXUSR S_IEXEC
#endif
#ifndef S_ISUID
# define S_ISUID 0004000
#endif
#ifndef S_ISGID
# define S_ISGID 0002000
#endif
#ifndef S_ISVTX
# define S_ISVTX 0001000
#endif
#ifndef S_ENFMT
# define S_ENFMT S_ISGID
#endif
#ifndef S_IRWXU
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
#endif
#ifndef S_IRWXG
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
#endif
#ifndef S_IRWXO
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
#endif
#ifndef F_OK
# define F_OK 0
#endif
#ifndef X_OK
# define X_OK 1
#endif
#ifndef W_OK
# define W_OK 2
#endif
#ifndef R_OK
# define R_OK 4
#endif
#ifndef O_RDONLY
# define O_RDONLY 0
#endif
#ifndef O_WRONLY
# define O_WRONLY 1
#endif
#ifndef O_RDWR
# define O_RDWR 2
#endif
#ifndef L_SET
# ifdef SEEK_SET
# define L_SET SEEK_SET
# else
# define L_SET 0
# endif
#endif
#ifndef L_INCR
# ifdef SEEK_CUR
# define L_INCR SEEK_CUR
# else
# define L_INCR 1
# endif
#endif
#ifndef L_XTND
# ifdef SEEK_END
# define L_XTND SEEK_END
# else
# define L_XTND 2
# endif
#endif
#if !defined (HAVE_SETPGID) && !defined (SETPGRP_VOID)
# define setpgid(pid, pgrp) setpgrp(pid, pgrp)
#endif
#if defined(BSDJOBS) && !(defined(POSIX) && defined(POSIXJOBS))
# define NEEDtcgetpgrp
#endif
#ifdef RENO
# define NEEDtcgetpgrp
#endif
#ifdef SXA
# ifndef _BSDX_
# define setrlimit bsd_setrlimit
# define getrlimit bsd_getrlimit
# endif
#endif
#if defined(_MINIX) || defined(__EMX__)
# define HAVENOLIMIT
# define getpgrp getpid
#endif
#ifdef __EMX__
# define ttyname(fd) (isatty(fd) ? "/dev/tty" : NULL)
#endif
#ifndef S_IFLNK
# define lstat stat
#endif
#if defined(BSDTIMES) && !defined(_SEQUENT_)
typedef struct timeval timeval_t;
#endif
#ifdef NeXT
# define malloc tcsh_malloc
# define calloc tcsh_calloc
# define realloc tcsh_realloc
# define free tcsh_free
#endif
#if defined(HAVE_GETHOSTNAME) && !HAVE_DECL_GETHOSTNAME
extern int gethostname (char *, int);
#endif
#ifndef GETPGRP_VOID
# define mygetpgrp() getpgrp(0)
#else
# define mygetpgrp() getpgrp()
#endif
#if !defined(POSIX) || defined(SUNOS4) || defined(UTekV) || defined(sysV88)
extern time_t time();
extern char *getenv();
extern int atoi();
# ifndef __EMX__
extern char *ttyname();
# endif
# if defined(SUNOS4)
# ifndef toupper
extern int toupper (int);
# endif
# ifndef tolower
extern int tolower (int);
# endif
extern caddr_t sbrk (int);
# else
# ifndef WINNT_NATIVE
# ifdef hpux
extern void abort();
extern void qsort();
# endif
# endif
# endif
#ifndef _CX_UX
extern void perror();
#endif
# ifdef BSD
extern uid_t getuid(), geteuid();
extern gid_t getgid(), getegid();
# endif
# ifdef SYSMALLOC
extern memalign_t malloc();
extern memalign_t realloc();
extern memalign_t calloc();
extern void free();
# endif
# ifdef BSDJOBS
# ifdef BSDTIMES
# ifdef __MACHTEN__
extern pid_t wait3();
# endif
# endif
# endif
# if (!defined(fps500) && !defined(apollo) && !defined(__lucid) && !defined(HPBSD) && !defined(DECOSF1))
extern void setpwent();
extern void endpwent();
# endif
# ifndef __STDC__
extern struct passwd *getpwuid(), *getpwnam(), *getpwent();
# ifdef HAVE_SHADOW_H
extern struct spwd *getspnam(), *getspent();
# endif
# if defined(HAVE_AUTH_H) && defined(HAVE_GETAUTHUID)
extern struct authorization *getauthuid();
# endif
# endif
# ifndef getcwd
extern char *getcwd();
# endif
#else
# if (defined(SUNOS4) && !defined(__GNUC__)) || defined(_IBMR2) || defined(_IBMESA)
extern char *getvwd();
# endif
# ifdef SCO
extern char *ttyname();
# endif
# ifdef __clipper__
extern char *ttyname();
# endif
#endif
#if defined(SUNOS4) && __GNUC__ == 2
extern int ioctl (int, int, ...);
extern int readlink (const char *, char *, size_t);
extern void setgrent (void);
extern void endgrent (void);
# ifdef REMOTEHOST
# ifndef _SOCKLEN_T
struct sockaddr;
extern int getpeername (int, struct sockaddr *, int *);
# endif
# endif
#endif
#if (defined(BSD) && !defined(BSD4_4)) || defined(SUNOS4)
# if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
extern void bcopy (const void *, void *, size_t);
# define memmove(a, b, c) (bcopy((char *) (b), (char *) (a), (int) (c)), a)
# endif
#endif
#ifdef SUNOS4
# include <memory.h>
#endif
#if SYSVREL == 4
# ifdef REMOTEHOST
# if !defined(__sgi) && !defined(_OSD_POSIX) && !defined(__MVS__)
# ifndef _SOCKLEN_T
struct sockaddr;
extern int getpeername (int, struct sockaddr *, int *);
# endif
# endif
# endif
# ifndef BSDTIMES
extern int getrlimit (int, struct rlimit *);
extern int setrlimit (int, const struct rlimit *);
# endif
# if defined(SOLARIS2)
extern char *strerror (int);
# endif
#endif
#if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
extern char *sbrk (ssize_t);
extern int ioctl (int, unsigned long, char *);
extern pid_t vfork (void);
extern int killpg (pid_t, int);
#endif
#ifndef va_copy
# ifdef __va_copy
# define va_copy(DEST, SRC) __va_copy(DEST, SRC)
# else
# define va_copy(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof(va_list))
# endif
#endif
#endif