14ad28ceobrien/*
24ad28ceobrien * tc.os.h: Shell os dependent defines
34ad28ceobrien */
44ad28ceobrien/*-
54ad28ceobrien * Copyright (c) 1980, 1991 The Regents of the University of California.
64ad28ceobrien * All rights reserved.
74ad28ceobrien *
84ad28ceobrien * Redistribution and use in source and binary forms, with or without
94ad28ceobrien * modification, are permitted provided that the following conditions
104ad28ceobrien * are met:
114ad28ceobrien * 1. Redistributions of source code must retain the above copyright
124ad28ceobrien *    notice, this list of conditions and the following disclaimer.
134ad28ceobrien * 2. Redistributions in binary form must reproduce the above copyright
144ad28ceobrien *    notice, this list of conditions and the following disclaimer in the
154ad28ceobrien *    documentation and/or other materials provided with the distribution.
16f2c2aa2mp * 3. Neither the name of the University nor the names of its contributors
174ad28ceobrien *    may be used to endorse or promote products derived from this software
184ad28ceobrien *    without specific prior written permission.
194ad28ceobrien *
204ad28ceobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
214ad28ceobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
224ad28ceobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
234ad28ceobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
244ad28ceobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
254ad28ceobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
264ad28ceobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
274ad28ceobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
284ad28ceobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
294ad28ceobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
304ad28ceobrien * SUCH DAMAGE.
314ad28ceobrien */
324ad28ceobrien#ifndef _h_tc_os
334ad28ceobrien#define _h_tc_os
344ad28ceobrien
354ad28ceobrien#ifdef notdef
364ad28ceobrien/*
374ad28ceobrien * for SVR4 and linux we used to fork pipelines backwards.
384ad28ceobrien * This should not be needed any more.
394ad28ceobrien * more info in sh.sem.c
404ad28ceobrien */
414ad28ceobrien# define BACKPIPE
424ad28ceobrien#endif /* notdef */
434ad28ceobrien
445e7fc01ache#ifdef __CYGWIN__
45bbd1addmp#  undef NOFILE
46bbd1addmp#  define NOFILE sysconf(_SC_OPEN_MAX)
475e7fc01ache#endif
485e7fc01ache
494ad28ceobrien#ifdef   _VMS_POSIX
504ad28ceobrien# ifndef  NOFILE
514ad28ceobrien#  define  NOFILE 64
524ad28ceobrien# endif /* NOFILE */
534ad28ceobrien# define  nice(a)       setprio((getpid()),a)
544ad28ceobrien# include <sys/time.h>    /* for time stuff in tc.prompt.c */
554ad28ceobrien# include <limits.h>
564ad28ceobrien#endif /* atp vmsposix */
574ad28ceobrien
584ad28ceobrien#if defined(DECOSF1) || defined(HPUXVERSION)
594ad28ceobrien# include <sys/signal.h>
604ad28ceobrien#endif /* DECOSF1 || HPUXVERSION */
614ad28ceobrien
624ad28ceobrien#ifdef DECOSF1
634ad28ceobrien# include <sys/ioctl.h>
644ad28ceobrien#endif /* DECOSF1 */
654ad28ceobrien
664ad28ceobrien#if defined(OPEN_MAX) && !defined(NOFILE)
674ad28ceobrien# define NOFILE OPEN_MAX
684ad28ceobrien#endif /* OPEN_MAX && !NOFILE */
694ad28ceobrien
704ad28ceobrien#if defined(USR_NFDS) && !defined(NOFILE)
714ad28ceobrien# define NOFILE USR_NFDS
724ad28ceobrien#endif /* USR_NFDS && !NOFILE */
734ad28ceobrien
744ad28ceobrien#ifndef NOFILE
754ad28ceobrien# define NOFILE 256
764ad28ceobrien#endif /* NOFILE */
774ad28ceobrien
784ad28ceobrien#ifdef OREO
794ad28ceobrien# include <sys/time.h>
804ad28ceobrien# ifdef notdef
814ad28ceobrien  /* Don't include it, because it defines things we don't really have */
824ad28ceobrien#  include <sys/resource.h>
834ad28ceobrien# endif /* notdef */
844ad28ceobrien# ifdef POSIX
854ad28ceobrien#  include <sys/tty.h>
864ad28ceobrien#  include <termios.h>
874ad28ceobrien# endif /* POSIX */
884ad28ceobrien#endif /* OREO */
894ad28ceobrien
9050eaa69mp#ifdef __QNXNTO__
9150eaa69mp#include <sys/resource.h>
9250eaa69mp#include <fcntl.h>
9350eaa69mp#undef O_TEXT
9450eaa69mp#undef O_BINARY
9550eaa69mp#endif
9650eaa69mp
974ad28ceobrien#ifdef convex
984ad28ceobrien# include <sys/dmon.h>
994ad28ceobrien#endif /* convex */
1004ad28ceobrien
1014ad28ceobrien#ifdef titan
1024ad28ceobrienextern int end;
1034ad28ceobrien#endif /* titan */
1044ad28ceobrien
1054ad28ceobrien#ifdef hpux
1064ad28ceobrien# ifdef lint
1074ad28ceobrien/*
1084ad28ceobrien * Hpux defines struct ucred, in <sys/user.h>, but if I include that
1094ad28ceobrien * then I need to include the *world*
1104ad28ceobrien * [all this to pass lint cleanly!!!]
1114ad28ceobrien * so I define struct ucred here...
1124ad28ceobrien */
1134ad28ceobrienstruct ucred {
1144ad28ceobrien    int     foo;
1154ad28ceobrien};
1164ad28ceobrien# endif /* lint */
1174ad28ceobrien
1184ad28ceobrien/*
1194ad28ceobrien * hpux 7.0 does not define it
1204ad28ceobrien */
1214ad28ceobrien# ifndef CSUSP
1224ad28ceobrien#  define CSUSP 032
1234ad28ceobrien# endif	/* CSUSP */
1244ad28ceobrien
1254ad28ceobrien# include <signal.h>
1264ad28ceobrien# if !defined(hp9000s500) && !(defined(SIGRTMAX) || defined(SIGRTMIN))
1274ad28ceobrien/*
1284ad28ceobrien * hpux < 7
1294ad28ceobrien */
1304ad28ceobrien#  include <sys/bsdtty.h>
1314ad28ceobrien# endif /* !hp9000s500 && !(SIGRTMAX || SIGRTMIN) */
1324ad28ceobrien
133f2c2aa2mp# ifndef TIOCSTI
134f2c2aa2mp#  include <sys/strtio.h>
135f2c2aa2mp# endif
1364ad28ceobrien#endif /* hpux */
1374ad28ceobrien
1384ad28ceobrien/*
1394ad28ceobrien * ISC does not define CSUSP
1404ad28ceobrien */
1414ad28ceobrien#ifdef ISC
1424ad28ceobrien# ifndef CSUSP
1434ad28ceobrien#  define CSUSP 032
1444ad28ceobrien# endif	/* CSUSP */
1454ad28ceobrien# if defined(POSIX) && !defined(TIOCGWINSZ)
1464ad28ceobrien/*
1474ad28ceobrien * ISC defines this only in termio.h. If we are using POSIX and include
1484ad28ceobrien * termios.h, then we define it ourselves so that window resizing works.
1494ad28ceobrien */
1504ad28ceobrien#  define TIOCGWINSZ      (('T'<<8)|104)
1514ad28ceobrien# endif /* POSIX && !TIOCGWINSZ */
1524ad28ceobrien#endif /* ISC */
1534ad28ceobrien
1544ad28ceobrien#ifdef ISC202
1554ad28ceobrien# undef TIOCGWINSZ
1564ad28ceobrien#endif /* ISC202 */
1574ad28ceobrien
1584ad28ceobrien/*
1594ad28ceobrien * XXX: This will be changed soon to
1604ad28ceobrien * #if (SYSVREL > 0) && defined(TIOCGWINSZ)
1614ad28ceobrien * If that breaks on your machine, let me know.
1624ad28ceobrien *
16394a109bmp * It would break on glibc, where all this is
1644ad28ceobrien * defined in <termios.h>. Wrapper added.
1654ad28ceobrien */
16654c5644mp#if !defined(__linux__) && !defined(__GNU__) && !defined(__GLIBC__) && !defined(_VMS_POSIX)
1674ad28ceobrien# if defined(INTEL) || defined(u3b2) || defined (u3b5) || defined(ub15) || defined(u3b20d) || defined(ISC) || defined(SCO) || defined(tower32)
1684ad28ceobrien#  ifdef TIOCGWINSZ
1694ad28ceobrien/*
1704ad28ceobrien * for struct winsiz
1714ad28ceobrien */
1724ad28ceobrien#   include <sys/stream.h>
1734ad28ceobrien#   include <sys/ptem.h>
1744ad28ceobrien#  endif /* TIOCGWINSZ */
1754ad28ceobrien# endif /* INTEL || u3b2 || u3b5 || ub15 || u3b20d || ISC || SCO || tower32 */
17694a109bmp#endif /* !glibc && !_VMS_POSIX */
1774ad28ceobrien
1784ad28ceobrien#ifdef IRIS4D
1794ad28ceobrien# include <sys/time.h>
1804ad28ceobrien# include <sys/resource.h>
1814ad28ceobrien#endif /* IRIS4D */
1824ad28ceobrien
1834ad28ceobrien/*
1844ad28ceobrien * For some versions of system V software, specially ones that use the
1854ad28ceobrien * Wollongong Software TCP/IP, the FIOCLEX, FIONCLEX, FIONBIO calls
1864ad28ceobrien * might not work correctly for file descriptors [they work only for
1874ad28ceobrien * sockets]. So we try to use first the fcntl() and we only use the
1884ad28ceobrien * ioctl() form, only if we don't have the fcntl() one.
1894ad28ceobrien *
1904ad28ceobrien * From: scott@craycos.com (Scott Bolte)
1914ad28ceobrien */
1925e7fc01ache#ifndef WINNT_NATIVE
1934ad28ceobrien# ifdef F_SETFD
19494a109bmp#  ifndef FD_CLOEXEC
19594a109bmp#   define FD_CLOEXEC 1
19694a109bmp#  endif
19794a109bmp#  define close_on_exec(fd, v) fcntl((fd), F_SETFD, ((v) ? FD_CLOEXEC : 0))
1984ad28ceobrien# else /* !F_SETFD */
1994ad28ceobrien#  ifdef FIOCLEX
2004ad28ceobrien#   define close_on_exec(fd, v) ioctl((fd), ((v) ? FIOCLEX : FIONCLEX), NULL)
2014ad28ceobrien#  else /* !FIOCLEX */
2024ad28ceobrien#   define close_on_exec(fd, v)	/* Nothing */
2034ad28ceobrien#  endif /* FIOCLEX */
2044ad28ceobrien# endif /* F_SETFD */
2055e7fc01ache#else /* WINNT_NATIVE */
2064ad28ceobrien# define close_on_exec(fd, v) nt_close_on_exec((fd),(v))
2075e7fc01ache#endif /* !WINNT_NATIVE */
2084ad28ceobrien
2094ad28ceobrien/*
2104ad28ceobrien * Stat
2114ad28ceobrien */
2124ad28ceobrien#ifdef ISC
2134ad28ceobrien/* these are not defined for _POSIX_SOURCE under ISC 2.2 */
2144ad28ceobrien# ifndef S_IFMT
2154ad28ceobrien#  define S_IFMT	0170000		/* type of file */
2164ad28ceobrien#  define S_IFDIR	0040000		/* directory */
2174ad28ceobrien#  define S_IFCHR	0020000		/* character special */
2184ad28ceobrien#  define S_IFBLK	0060000		/* block special */
2194ad28ceobrien#  define S_IFREG	0100000		/* regular */
2204ad28ceobrien#  define S_IFIFO	0010000		/* fifo */
2214ad28ceobrien#  define S_IFNAM	0050000		/* special named file */
2224ad28ceobrien#  ifndef ISC202
2234ad28ceobrien#   define S_IFLNK	0120000		/* symbolic link */
2244ad28ceobrien#  endif /* ISC202 */
2254ad28ceobrien# endif /* S_IFMT */
2264ad28ceobrien#endif /* ISC */
2274ad28ceobrien
22894a109bmp#ifdef STAT_MACROS_BROKEN
2294ad28ceobrien# undef S_ISDIR
2304ad28ceobrien# undef S_ISCHR
2314ad28ceobrien# undef S_ISBLK
2324ad28ceobrien# undef S_ISREG
2334ad28ceobrien# undef S_ISFIFO
2344ad28ceobrien# undef S_ISNAM
2354ad28ceobrien# undef S_ISLNK
2364ad28ceobrien# undef S_ISSOCK
23794a109bmp#endif /* STAT_MACROS_BROKEN */
2384ad28ceobrien
2394ad28ceobrien#ifdef S_IFMT
2404ad28ceobrien# if !defined(S_ISDIR) && defined(S_IFDIR)
2414ad28ceobrien#  define S_ISDIR(a)	(((a) & S_IFMT) == S_IFDIR)
2424ad28ceobrien# endif	/* ! S_ISDIR && S_IFDIR */
2434ad28ceobrien# if !defined(S_ISCHR) && defined(S_IFCHR)
2444ad28ceobrien#  define S_ISCHR(a)	(((a) & S_IFMT) == S_IFCHR)
2454ad28ceobrien# endif /* ! S_ISCHR && S_IFCHR */
2464ad28ceobrien# if !defined(S_ISBLK) && defined(S_IFBLK)
2474ad28ceobrien#  define S_ISBLK(a)	(((a) & S_IFMT) == S_IFBLK)
2484ad28ceobrien# endif	/* ! S_ISBLK && S_IFBLK */
2494ad28ceobrien# if !defined(S_ISREG) && defined(S_IFREG)
2504ad28ceobrien#  define S_ISREG(a)	(((a) & S_IFMT) == S_IFREG)
2514ad28ceobrien# endif	/* ! S_ISREG && S_IFREG */
2524ad28ceobrien# if !defined(S_ISFIFO) && defined(S_IFIFO)
2534ad28ceobrien#  define S_ISFIFO(a)	(((a) & S_IFMT) == S_IFIFO)
2544ad28ceobrien# endif	/* ! S_ISFIFO && S_IFIFO */
2554ad28ceobrien# if !defined(S_ISNAM) && defined(S_IFNAM)
2564ad28ceobrien#  define S_ISNAM(a)	(((a) & S_IFMT) == S_IFNAM)
2574ad28ceobrien# endif	/* ! S_ISNAM && S_IFNAM */
2584ad28ceobrien# if !defined(S_ISLNK) && defined(S_IFLNK)
2594ad28ceobrien#  define S_ISLNK(a)	(((a) & S_IFMT) == S_IFLNK)
2604ad28ceobrien# endif	/* ! S_ISLNK && S_IFLNK */
2614ad28ceobrien# if !defined(S_ISSOCK) && defined(S_IFSOCK)
2624ad28ceobrien#  define S_ISSOCK(a)	(((a) & S_IFMT) == S_IFSOCK)
2634ad28ceobrien# endif	/* ! S_ISSOCK && S_IFSOCK */
2644ad28ceobrien#endif /* S_IFMT */
2654ad28ceobrien
2664ad28ceobrien#ifdef tower32
2674ad28ceobrien/* The header files lie; we really don't have symlinks */
2684ad28ceobrien# undef S_ISLNK
2694ad28ceobrien# undef S_IFLNK
2704ad28ceobrien#endif /* tower32 */
2714ad28ceobrien
2724ad28ceobrien#ifndef S_IREAD
2734ad28ceobrien# define S_IREAD 0000400
2744ad28ceobrien#endif /* S_IREAD */
2754ad28ceobrien#ifndef S_IROTH
2764ad28ceobrien# define S_IROTH (S_IREAD >> 6)
2774ad28ceobrien#endif /* S_IROTH */
2784ad28ceobrien#ifndef S_IRGRP
2794ad28ceobrien# define S_IRGRP (S_IREAD >> 3)
2804ad28ceobrien#endif /* S_IRGRP */
2814ad28ceobrien#ifndef S_IRUSR
2824ad28ceobrien# define S_IRUSR S_IREAD
2834ad28ceobrien#endif /* S_IRUSR */
2844ad28ceobrien
2854ad28ceobrien#ifndef S_IWRITE
2864ad28ceobrien# define S_IWRITE 0000200
2874ad28ceobrien#endif /* S_IWRITE */
2884ad28ceobrien#ifndef S_IWOTH
2894ad28ceobrien# define S_IWOTH (S_IWRITE >> 6)
2904ad28ceobrien#endif /* S_IWOTH */
2914ad28ceobrien#ifndef S_IWGRP
2924ad28ceobrien# define S_IWGRP (S_IWRITE >> 3)
2934ad28ceobrien#endif /* S_IWGRP */
2944ad28ceobrien#ifndef S_IWUSR
2954ad28ceobrien# define S_IWUSR S_IWRITE
2964ad28ceobrien#endif /* S_IWUSR */
2974ad28ceobrien
2984ad28ceobrien#ifndef S_IEXEC
2994ad28ceobrien# define S_IEXEC 0000100
3004ad28ceobrien#endif /* S_IEXEC */
3014ad28ceobrien#ifndef S_IXOTH
3024ad28ceobrien# define S_IXOTH (S_IEXEC >> 6)
3034ad28ceobrien#endif /* S_IXOTH */
3044ad28ceobrien#ifndef S_IXGRP
3054ad28ceobrien# define S_IXGRP (S_IEXEC >> 3)
3064ad28ceobrien#endif /* S_IXGRP */
3074ad28ceobrien#ifndef S_IXUSR
3084ad28ceobrien# define S_IXUSR S_IEXEC
3094ad28ceobrien#endif /* S_IXUSR */
3104ad28ceobrien
3114ad28ceobrien#ifndef S_ISUID
3124ad28ceobrien# define S_ISUID 0004000 	/* setuid */
3134ad28ceobrien#endif /* S_ISUID */
3144ad28ceobrien#ifndef S_ISGID
3154ad28ceobrien# define S_ISGID 0002000	/* setgid */
3164ad28ceobrien#endif /* S_ISGID */
3174ad28ceobrien#ifndef S_ISVTX
3184ad28ceobrien# define S_ISVTX 0001000	/* sticky */
3194ad28ceobrien#endif /* S_ISVTX */
3204ad28ceobrien#ifndef S_ENFMT
3214ad28ceobrien# define S_ENFMT S_ISGID	/* record locking enforcement flag */
3224ad28ceobrien#endif /* S_ENFMT */
3234ad28ceobrien
3244ad28ceobrien/* the following macros are for POSIX conformance */
3254ad28ceobrien#ifndef S_IRWXU
3264ad28ceobrien# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
3274ad28ceobrien#endif /* S_IRWXU */
3284ad28ceobrien#ifndef S_IRWXG
3294ad28ceobrien# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
3304ad28ceobrien#endif /* S_IRWXG */
3314ad28ceobrien#ifndef S_IRWXO
3324ad28ceobrien# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
3334ad28ceobrien#endif /* S_IRWXO */
3344ad28ceobrien
3354ad28ceobrien/*
3364ad28ceobrien * Access()
3374ad28ceobrien */
3384ad28ceobrien#ifndef F_OK
3394ad28ceobrien# define F_OK 0
3404ad28ceobrien#endif /* F_OK */
3414ad28ceobrien#ifndef X_OK
3424ad28ceobrien# define X_OK 1
3434ad28ceobrien#endif /* X_OK */
3444ad28ceobrien#ifndef W_OK
3454ad28ceobrien# define W_OK 2
3464ad28ceobrien#endif /* W_OK */
3474ad28ceobrien#ifndef R_OK
3484ad28ceobrien# define R_OK 4
3494ad28ceobrien#endif /* R_OK */
3504ad28ceobrien
3514ad28ceobrien/*
3524ad28ceobrien * Open()
3534ad28ceobrien */
3544ad28ceobrien#ifndef O_RDONLY
3554ad28ceobrien# define O_RDONLY	0
3564ad28ceobrien#endif /* O_RDONLY */
3574ad28ceobrien#ifndef O_WRONLY
3584ad28ceobrien# define O_WRONLY	1
3594ad28ceobrien#endif /* O_WRONLY */
3604ad28ceobrien#ifndef O_RDWR
3614ad28ceobrien# define O_RDWR		2
3624ad28ceobrien#endif /* O_RDWR */
36354c5644mp#ifndef O_TEMPORARY
36454c5644mp# define O_TEMPORARY	0
36554c5644mp#endif /* O_TEMPORARY */
36654c5644mp#ifndef O_EXCL
36754c5644mp# define O_EXCL		0
36854c5644mp#endif /* O_EXCL */
36954c5644mp#ifndef O_LARGEFILE
37054c5644mp# define O_LARGEFILE	0
37154c5644mp#endif /* O_LARGEFILE */
37254c5644mp#ifndef O_CREAT
37354c5644mp# define O_CREAT	0
37454c5644mp#endif /* O_CREAT */
3754ad28ceobrien
3764ad28ceobrien/*
3774ad28ceobrien * Lseek()
3784ad28ceobrien */
3794ad28ceobrien#ifndef L_SET
3804ad28ceobrien# ifdef SEEK_SET
3814ad28ceobrien#  define L_SET		SEEK_SET
3824ad28ceobrien# else /* !SEEK_SET */
3834ad28ceobrien#  define L_SET		0
3844ad28ceobrien# endif	/* SEEK_SET */
3854ad28ceobrien#endif /* L_SET */
3864ad28ceobrien#ifndef L_INCR
3874ad28ceobrien# ifdef SEEK_CUR
3884ad28ceobrien#  define L_INCR	SEEK_CUR
3894ad28ceobrien# else /* !SEEK_CUR */
3904ad28ceobrien#  define L_INCR	1
3914ad28ceobrien# endif	/* SEEK_CUR */
3924ad28ceobrien#endif /* L_INCR */
3934ad28ceobrien#ifndef L_XTND
3944ad28ceobrien# ifdef SEEK_END
3954ad28ceobrien#  define L_XTND	SEEK_END
3964ad28ceobrien# else /* !SEEK_END */
3974ad28ceobrien#  define L_XTND	2
3984ad28ceobrien# endif /* SEEK_END */
3994ad28ceobrien#endif /* L_XTND */
4004ad28ceobrien
40194a109bmp#if !defined (HAVE_SETPGID) && !defined (SETPGRP_VOID)
4024ad28ceobrien# define setpgid(pid, pgrp)	setpgrp(pid, pgrp)
40394a109bmp#endif
4044ad28ceobrien
4054ad28ceobrien#if defined(BSDJOBS) && !(defined(POSIX) && defined(POSIXJOBS))
4064ad28ceobrien# define NEEDtcgetpgrp
4074ad28ceobrien#endif /* BSDJOBS && !(POSIX && POSIXJOBS) */
4084ad28ceobrien
4094ad28ceobrien#ifdef RENO
4104ad28ceobrien/*
4114ad28ceobrien * RENO has this broken. It is fixed on 4.4BSD
4124ad28ceobrien */
4134ad28ceobrien# define NEEDtcgetpgrp
4144ad28ceobrien#endif /* RENO */
4154ad28ceobrien
4164ad28ceobrien#ifdef SXA
4174ad28ceobrien# ifndef _BSDX_
4184ad28ceobrien/*
4194ad28ceobrien * Only needed in the system V environment.
4204ad28ceobrien */
4214ad28ceobrien#  define setrlimit 	bsd_setrlimit
4224ad28ceobrien#  define getrlimit	bsd_getrlimit
4234ad28ceobrien# endif	/* _BSDX_ */
4244ad28ceobrien#endif /* SXA */
4254ad28ceobrien
4264ad28ceobrien#if defined(_MINIX) || defined(__EMX__)
4274ad28ceobrien# define HAVENOLIMIT
4284ad28ceobrien/*
4294ad28ceobrien * Minix does not have these, so...
4304ad28ceobrien */
4314ad28ceobrien# define getpgrp		getpid
4324ad28ceobrien#endif /* _MINIX || __EMX__ */
4334ad28ceobrien
4344ad28ceobrien#ifdef __EMX__
4354ad28ceobrien/* XXX: How can we get the tty name in emx? */
4364ad28ceobrien# define ttyname(fd) (isatty(fd) ? "/dev/tty" : NULL)
4374ad28ceobrien#endif /* __EMX__ */
4384ad28ceobrien
4394ad28ceobrien#ifndef S_IFLNK
4404ad28ceobrien# define lstat stat
4414ad28ceobrien#endif /* S_IFLNK */
4424ad28ceobrien
4434ad28ceobrien
4444ad28ceobrien#if defined(BSDTIMES) && !defined(_SEQUENT_)
4454ad28ceobrientypedef struct timeval timeval_t;
4464ad28ceobrien#endif /* BSDTIMES && ! _SEQUENT_ */
4474ad28ceobrien
4484ad28ceobrien#ifdef NeXT
4494ad28ceobrien/*
4504ad28ceobrien * From Tony_Mason@transarc.com, override NeXT's malloc stuff.
4514ad28ceobrien */
4524ad28ceobrien# define malloc tcsh_malloc
4534ad28ceobrien# define calloc tcsh_calloc
4544ad28ceobrien# define realloc tcsh_realloc
4554ad28ceobrien# define free tcsh_free
4564ad28ceobrien#endif /* NeXT */
4574ad28ceobrien
45894a109bmp#if defined(HAVE_GETHOSTNAME) && !HAVE_DECL_GETHOSTNAME
459a409803mpextern int gethostname (char *, int);
46094a109bmp#endif
46194a109bmp
46294a109bmp#ifndef GETPGRP_VOID
46394a109bmp# define mygetpgrp()    getpgrp(0)
46494a109bmp#else
46594a109bmp# define mygetpgrp()    getpgrp()
46694a109bmp#endif
4674ad28ceobrien
4684ad28ceobrien#if !defined(POSIX) || defined(SUNOS4) || defined(UTekV) || defined(sysV88)
4694ad28ceobrienextern time_t time();
4704ad28ceobrienextern char *getenv();
4714ad28ceobrienextern int atoi();
4724ad28ceobrien# ifndef __EMX__
4734ad28ceobrienextern char *ttyname();
4744ad28ceobrien# endif /* __EMX__ */
4754ad28ceobrien
47694a109bmp
4774ad28ceobrien# if defined(SUNOS4)
4784ad28ceobrien#  ifndef toupper
479a409803mpextern int toupper (int);
4804ad28ceobrien#  endif /* toupper */
4814ad28ceobrien#  ifndef tolower
482a409803mpextern int tolower (int);
4834ad28ceobrien#  endif /* tolower */
484a409803mpextern caddr_t sbrk (int);
4854ad28ceobrien# else /* !SUNOS4 */
4865e7fc01ache#  ifndef WINNT_NATIVE
48794a109bmp#   ifdef hpux
4884ad28ceobrienextern void abort();
4894ad28ceobrienextern void qsort();
4904ad28ceobrien#   endif /* hpux */
4915e7fc01ache#  endif /* !WINNT_NATIVE */
4924ad28ceobrien# endif	/* SUNOS4 */
4934ad28ceobrien#ifndef _CX_UX
4944ad28ceobrienextern void perror();
4954ad28ceobrien#endif
4964ad28ceobrien
4974ad28ceobrien# ifdef BSD
4984ad28ceobrienextern uid_t getuid(), geteuid();
4994ad28ceobrienextern gid_t getgid(), getegid();
5004ad28ceobrien# endif /* BSD */
5014ad28ceobrien
5024ad28ceobrien# ifdef SYSMALLOC
5034ad28ceobrienextern memalign_t malloc();
5044ad28ceobrienextern memalign_t realloc();
5054ad28ceobrienextern memalign_t calloc();
5064ad28ceobrienextern void free();
5074ad28ceobrien# endif	/* SYSMALLOC */
5084ad28ceobrien
5094ad28ceobrien# ifdef BSDJOBS
5104ad28ceobrien#  ifdef BSDTIMES
5114ad28ceobrien#   ifdef __MACHTEN__
5124ad28ceobrienextern pid_t wait3();
5134ad28ceobrien#   endif /* __MACHTEN__ */
5144ad28ceobrien#  endif /* BSDTIMES */
5154ad28ceobrien# endif	/* BSDJOBS */
5164ad28ceobrien
5174ad28ceobrien# if (!defined(fps500) && !defined(apollo) && !defined(__lucid) && !defined(HPBSD) && !defined(DECOSF1))
5184ad28ceobrienextern void setpwent();
5194ad28ceobrienextern void endpwent();
5204ad28ceobrien# endif /* !fps500 && !apollo && !__lucid && !HPBSD && !DECOSF1 */
5214ad28ceobrien
5224ad28ceobrien# ifndef __STDC__
5234ad28ceobrienextern struct passwd *getpwuid(), *getpwnam(), *getpwent();
52494a109bmp#  ifdef HAVE_SHADOW_H
5254ad28ceobrienextern struct spwd *getspnam(), *getspent();
52694a109bmp#  endif /* HAVE_SHADOW_H */
527a409803mp#  if defined(HAVE_AUTH_H) && defined(HAVE_GETAUTHUID)
5284ad28ceobrienextern struct authorization *getauthuid();
529a409803mp#  endif /* HAVE_AUTH_H && HAVE_GETAUTHUID */
5304ad28ceobrien# endif /* __STDC__ */
5314ad28ceobrien
5324ad28ceobrien# ifndef getcwd
5334ad28ceobrienextern char *getcwd();
5344ad28ceobrien# endif	/* getcwd */
5354ad28ceobrien
5364ad28ceobrien#else /* POSIX || !SUNOS4 || !UTekV || !sysV88 */
5374ad28ceobrien
5384ad28ceobrien# if (defined(SUNOS4) && !defined(__GNUC__)) || defined(_IBMR2) || defined(_IBMESA)
5394ad28ceobrienextern char *getvwd();
5404ad28ceobrien# endif	/* (SUNOS4 && ! __GNUC__) || _IBMR2 || _IBMESA */
5414ad28ceobrien
5424ad28ceobrien# ifdef SCO
5434ad28ceobrienextern char *ttyname();
5444ad28ceobrien# endif /* SCO */
5454ad28ceobrien
5464ad28ceobrien# ifdef __clipper__
5474ad28ceobrienextern char *ttyname();
5484ad28ceobrien# endif /* __clipper__ */
5494ad28ceobrien
5504ad28ceobrien#endif /* !POSIX || SUNOS4 || UTekV || sysV88 */
5514ad28ceobrien
5524ad28ceobrien#if defined(SUNOS4) && __GNUC__ == 2
5534ad28ceobrien/*
5544ad28ceobrien * Somehow these are missing
5554ad28ceobrien */
556a409803mpextern int ioctl (int, int, ...);
557a409803mpextern int readlink (const char *, char *, size_t);
558a409803mpextern void setgrent (void);
559a409803mpextern void endgrent (void);
5604ad28ceobrien# ifdef REMOTEHOST
5614ad28ceobrien#  ifndef _SOCKLEN_T	/* Avoid Solaris 2.7 bogosity. */
5624ad28ceobrienstruct sockaddr;
563a409803mpextern int getpeername (int, struct sockaddr *, int *);
5644ad28ceobrien#  endif /* _SOCKLEN_T */
5654ad28ceobrien# endif /* REMOTEHOST */
5664ad28ceobrien#endif /* SUNOS4 && __GNUC__ == 2 */
5674ad28ceobrien
5684ad28ceobrien#if (defined(BSD) && !defined(BSD4_4)) || defined(SUNOS4)
5694ad28ceobrien# if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
570a409803mpextern void bcopy	(const void *, void *, size_t);
5714ad28ceobrien#  define memmove(a, b, c) (bcopy((char *) (b), (char *) (a), (int) (c)), a)
5724ad28ceobrien# endif /* __alpha && __osf__ && DECOSF1 < 200 */
5734ad28ceobrien#endif /* (BSD && !BSD4_4) || SUNOS4 */
5744ad28ceobrien
57594a109bmp#ifdef SUNOS4
57694a109bmp# include <memory.h>	/* memset should be declared in <string.h> but isn't */
57794a109bmp#endif /* SUNOS4 */
5784ad28ceobrien
5794ad28ceobrien#if SYSVREL == 4
5804ad28ceobrien# ifdef REMOTEHOST
5814ad28ceobrien/* Irix6 defines getpeername(int, void *, int *) which conflicts with
5824ad28ceobrien   the definition below. */
5835e7fc01ache#  if !defined(__sgi) && !defined(_OSD_POSIX) && !defined(__MVS__)
5844ad28ceobrien#   ifndef _SOCKLEN_T	/* Avoid Solaris 2.7 bogosity. */
5854ad28ceobrienstruct sockaddr;
586a409803mpextern int getpeername (int, struct sockaddr *, int *);
5874ad28ceobrien#   endif /* _SOCKLEN_T */
5885e7fc01ache#  endif /* !__sgi && !_OSD_POSIX && !__MVS__ */
5894ad28ceobrien# endif /* REMOTEHOST */
5904ad28ceobrien# ifndef BSDTIMES
591a409803mpextern int getrlimit (int, struct rlimit *);
592a409803mpextern int setrlimit (int, const struct rlimit *);
5934ad28ceobrien# endif /* !BSDTIMES */
5944ad28ceobrien# if defined(SOLARIS2)
595a409803mpextern char *strerror (int);
5964ad28ceobrien# endif /* SOLARIS2 */
5974ad28ceobrien#endif /* SYSVREL == 4 */
5984ad28ceobrien
5994ad28ceobrien#if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
6004ad28ceobrien/* These are ok for 1.3, but conflict with the header files for 2.0 */
601a409803mpextern char *sbrk (ssize_t);
602a409803mpextern int ioctl (int, unsigned long, char *);
603a409803mpextern pid_t vfork (void);
604a409803mpextern int killpg (pid_t, int);
6054ad28ceobrien#endif /* __osf__ && __alpha && DECOSF1 < 200 */
6064ad28ceobrien
607a409803mp#ifndef va_copy
608a409803mp# ifdef __va_copy
609a409803mp#  define va_copy(DEST, SRC) __va_copy(DEST, SRC)
610a409803mp# else
611a409803mp#  define va_copy(DEST, SRC) memcpy(&(DEST), &(SRC), sizeof(va_list))
612a409803mp# endif
613a409803mp#endif
614a409803mp
61554c5644mp#if defined(__CYGWIN__) && !defined(NO_CRYPT)
61654c5644mpextern char *cygwin_xcrypt(struct passwd *, const char *, const char *);
61754c5644mp#endif /* __CYGWIN__ && !NO_CRYPT */
61854c5644mp
6194ad28ceobrien#endif /* _h_tc_os */
620