tc.os.h revision 59243
159243Sobrien/* $Header: /src/pub/tcsh/tc.os.h,v 3.82 1999/02/06 15:19:03 christos Exp $ */
259243Sobrien/*
359243Sobrien * tc.os.h: Shell os dependent defines
459243Sobrien */
559243Sobrien/*-
659243Sobrien * Copyright (c) 1980, 1991 The Regents of the University of California.
759243Sobrien * All rights reserved.
859243Sobrien *
959243Sobrien * Redistribution and use in source and binary forms, with or without
1059243Sobrien * modification, are permitted provided that the following conditions
1159243Sobrien * are met:
1259243Sobrien * 1. Redistributions of source code must retain the above copyright
1359243Sobrien *    notice, this list of conditions and the following disclaimer.
1459243Sobrien * 2. Redistributions in binary form must reproduce the above copyright
1559243Sobrien *    notice, this list of conditions and the following disclaimer in the
1659243Sobrien *    documentation and/or other materials provided with the distribution.
1759243Sobrien * 3. All advertising materials mentioning features or use of this software
1859243Sobrien *    must display the following acknowledgement:
1959243Sobrien *	This product includes software developed by the University of
2059243Sobrien *	California, Berkeley and its contributors.
2159243Sobrien * 4. Neither the name of the University nor the names of its contributors
2259243Sobrien *    may be used to endorse or promote products derived from this software
2359243Sobrien *    without specific prior written permission.
2459243Sobrien *
2559243Sobrien * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2659243Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2759243Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2859243Sobrien * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2959243Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3059243Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3159243Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3259243Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3359243Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3459243Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3559243Sobrien * SUCH DAMAGE.
3659243Sobrien */
3759243Sobrien#ifndef _h_tc_os
3859243Sobrien#define _h_tc_os
3959243Sobrien
4059243Sobrien#ifndef WINNT
4159243Sobrien#define NEEDstrerror		/* Too hard to find which systems have it */
4259243Sobrien#endif /* WINNT */
4359243Sobrien
4459243Sobrien
4559243Sobrien#ifdef notdef
4659243Sobrien/*
4759243Sobrien * for SVR4 and linux we used to fork pipelines backwards.
4859243Sobrien * This should not be needed any more.
4959243Sobrien * more info in sh.sem.c
5059243Sobrien */
5159243Sobrien# define BACKPIPE
5259243Sobrien#endif /* notdef */
5359243Sobrien
5459243Sobrien#ifdef   _VMS_POSIX
5559243Sobrien# ifndef  NOFILE
5659243Sobrien#  define  NOFILE 64
5759243Sobrien# endif /* NOFILE */
5859243Sobrien# define  nice(a)       setprio((getpid()),a)
5959243Sobrien# undef   NEEDstrerror    /* won't get sensible error messages otherwise */
6059243Sobrien# define  NEEDgethostname
6159243Sobrien# include <sys/time.h>    /* for time stuff in tc.prompt.c */
6259243Sobrien# include <limits.h>
6359243Sobrien#endif /* atp vmsposix */
6459243Sobrien
6559243Sobrien#if defined(DECOSF1) || defined(HPUXVERSION)
6659243Sobrien# include <sys/signal.h>
6759243Sobrien#endif /* DECOSF1 || HPUXVERSION */
6859243Sobrien
6959243Sobrien#ifdef DECOSF1
7059243Sobrien# include <sys/ioctl.h>
7159243Sobrien#endif /* DECOSF1 */
7259243Sobrien
7359243Sobrien#if defined(OPEN_MAX) && !defined(NOFILE)
7459243Sobrien# define NOFILE OPEN_MAX
7559243Sobrien#endif /* OPEN_MAX && !NOFILE */
7659243Sobrien
7759243Sobrien#if defined(USR_NFDS) && !defined(NOFILE)
7859243Sobrien# define NOFILE USR_NFDS
7959243Sobrien#endif /* USR_NFDS && !NOFILE */
8059243Sobrien
8159243Sobrien#ifndef NOFILE
8259243Sobrien# define NOFILE 256
8359243Sobrien#endif /* NOFILE */
8459243Sobrien
8559243Sobrien#if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || SYSVREL >= 4
8659243Sobrien# undef NEEDstrerror
8759243Sobrien#endif /* linux || __NetBSD__ || __FreeBSD__ || SYSVREL >= 4 */
8859243Sobrien
8959243Sobrien#if !defined(pyr) && !defined(sinix)
9059243Sobrien/* Pyramid's cpp complains about the next line */
9159243Sobrien# if defined(BSD) && BSD >= 199306
9259243Sobrien#  undef NEEDstrerror
9359243Sobrien# endif /* BSD && BSD >= 199306 */
9459243Sobrien#endif /* pyr */
9559243Sobrien
9659243Sobrien#ifdef OREO
9759243Sobrien# include <sys/time.h>
9859243Sobrien# ifdef notdef
9959243Sobrien  /* Don't include it, because it defines things we don't really have */
10059243Sobrien#  include <sys/resource.h>
10159243Sobrien# endif /* notdef */
10259243Sobrien# ifdef POSIX
10359243Sobrien#  include <sys/tty.h>
10459243Sobrien#  include <termios.h>
10559243Sobrien# endif /* POSIX */
10659243Sobrien#endif /* OREO */
10759243Sobrien
10859243Sobrien#ifndef NCARGS
10959243Sobrien# ifdef _SC_ARG_MAX
11059243Sobrien#  define NCARGS sysconf(_SC_ARG_MAX)
11159243Sobrien# else /* !_SC_ARG_MAX */
11259243Sobrien#  ifdef ARG_MAX
11359243Sobrien#   define NCARGS ARG_MAX
11459243Sobrien#  else /* !ARG_MAX */
11559243Sobrien#   ifdef _MINIX
11659243Sobrien#    define NCARGS 80
11759243Sobrien#   else /* !_MINIX */
11859243Sobrien#    define NCARGS 1024
11959243Sobrien#   endif /* _MINIX */
12059243Sobrien#  endif /* ARG_MAX */
12159243Sobrien# endif /* _SC_ARG_MAX */
12259243Sobrien#endif /* NCARGS */
12359243Sobrien
12459243Sobrien#ifdef convex
12559243Sobrien# include <sys/dmon.h>
12659243Sobrien#endif /* convex */
12759243Sobrien
12859243Sobrien#ifdef titan
12959243Sobrienextern int end;
13059243Sobrien#endif /* titan */
13159243Sobrien
13259243Sobrien#ifdef hpux
13359243Sobrien# ifdef lint
13459243Sobrien/*
13559243Sobrien * Hpux defines struct ucred, in <sys/user.h>, but if I include that
13659243Sobrien * then I need to include the *world*
13759243Sobrien * [all this to pass lint cleanly!!!]
13859243Sobrien * so I define struct ucred here...
13959243Sobrien */
14059243Sobrienstruct ucred {
14159243Sobrien    int     foo;
14259243Sobrien};
14359243Sobrien# endif /* lint */
14459243Sobrien
14559243Sobrien/*
14659243Sobrien * hpux 7.0 does not define it
14759243Sobrien */
14859243Sobrien# ifndef CSUSP
14959243Sobrien#  define CSUSP 032
15059243Sobrien# endif	/* CSUSP */
15159243Sobrien
15259243Sobrien# include <signal.h>
15359243Sobrien# if !defined(hp9000s500) && !(defined(SIGRTMAX) || defined(SIGRTMIN))
15459243Sobrien/*
15559243Sobrien * hpux < 7
15659243Sobrien */
15759243Sobrien#  include <sys/bsdtty.h>
15859243Sobrien# endif /* !hp9000s500 && !(SIGRTMAX || SIGRTMIN) */
15959243Sobrien
16059243Sobrien# ifndef POSIX
16159243Sobrien#  ifdef BSDJOBS
16259243Sobrien#   define getpgrp(a) getpgrp2(a)
16359243Sobrien#   define setpgrp(a, b) setpgrp2(a, b)
16459243Sobrien#  endif /* BSDJOBS */
16559243Sobrien# endif	/* POSIX */
16659243Sobrien#endif /* hpux */
16759243Sobrien
16859243Sobrien/*
16959243Sobrien * ISC does not define CSUSP
17059243Sobrien */
17159243Sobrien#ifdef ISC
17259243Sobrien# ifndef CSUSP
17359243Sobrien#  define CSUSP 032
17459243Sobrien# endif	/* CSUSP */
17559243Sobrien# if defined(POSIX) && !defined(TIOCGWINSZ)
17659243Sobrien/*
17759243Sobrien * ISC defines this only in termio.h. If we are using POSIX and include
17859243Sobrien * termios.h, then we define it ourselves so that window resizing works.
17959243Sobrien */
18059243Sobrien#  define TIOCGWINSZ      (('T'<<8)|104)
18159243Sobrien# endif /* POSIX && !TIOCGWINSZ */
18259243Sobrien#endif /* ISC */
18359243Sobrien
18459243Sobrien#ifdef ISC202
18559243Sobrien# undef TIOCGWINSZ
18659243Sobrien#endif /* ISC202 */
18759243Sobrien
18859243Sobrien/*
18959243Sobrien * XXX: This will be changed soon to
19059243Sobrien * #if (SYSVREL > 0) && defined(TIOCGWINSZ)
19159243Sobrien * If that breaks on your machine, let me know.
19259243Sobrien *
19359243Sobrien * It would break on linux, where all this is
19459243Sobrien * defined in <termios.h>. Wrapper added.
19559243Sobrien */
19659243Sobrien#if !defined(linux) && !defined(_VMS_POSIX)
19759243Sobrien# if defined(INTEL) || defined(u3b2) || defined (u3b5) || defined(ub15) || defined(u3b20d) || defined(ISC) || defined(SCO) || defined(tower32)
19859243Sobrien#  ifdef TIOCGWINSZ
19959243Sobrien/*
20059243Sobrien * for struct winsiz
20159243Sobrien */
20259243Sobrien#   include <sys/stream.h>
20359243Sobrien#   include <sys/ptem.h>
20459243Sobrien#  endif /* TIOCGWINSZ */
20559243Sobrien#  ifndef ODT
20659243Sobrien#   define NEEDgethostname
20759243Sobrien#  endif /* ODT */
20859243Sobrien# endif /* INTEL || u3b2 || u3b5 || ub15 || u3b20d || ISC || SCO || tower32 */
20959243Sobrien#endif /* !linux && !_VMS_POSIX */
21059243Sobrien
21159243Sobrien#if defined(UNIXPC) || defined(COHERENT)
21259243Sobrien# define NEEDgethostname
21359243Sobrien#endif /* UNIXPC || COHERENT */
21459243Sobrien
21559243Sobrien#ifdef IRIS4D
21659243Sobrien# include <sys/time.h>
21759243Sobrien# include <sys/resource.h>
21859243Sobrien# ifndef POSIX
21959243Sobrien/*
22059243Sobrien * BSDsetpgrp() and BSDgetpgrp() are BSD versions of setpgrp, etc.
22159243Sobrien */
22259243Sobrien#  define setpgrp BSDsetpgrp
22359243Sobrien#  define getpgrp BSDgetpgrp
22459243Sobrien# endif /* POSIX */
22559243Sobrien#endif /* IRIS4D */
22659243Sobrien
22759243Sobrien/*
22859243Sobrien * For some versions of system V software, specially ones that use the
22959243Sobrien * Wollongong Software TCP/IP, the FIOCLEX, FIONCLEX, FIONBIO calls
23059243Sobrien * might not work correctly for file descriptors [they work only for
23159243Sobrien * sockets]. So we try to use first the fcntl() and we only use the
23259243Sobrien * ioctl() form, only if we don't have the fcntl() one.
23359243Sobrien *
23459243Sobrien * From: scott@craycos.com (Scott Bolte)
23559243Sobrien */
23659243Sobrien#ifndef WINNT
23759243Sobrien# ifdef F_SETFD
23859243Sobrien#  define close_on_exec(fd, v) fcntl((fd), F_SETFD, v)
23959243Sobrien# else /* !F_SETFD */
24059243Sobrien#  ifdef FIOCLEX
24159243Sobrien#   define close_on_exec(fd, v) ioctl((fd), ((v) ? FIOCLEX : FIONCLEX), NULL)
24259243Sobrien#  else /* !FIOCLEX */
24359243Sobrien#   define close_on_exec(fd, v)	/* Nothing */
24459243Sobrien#  endif /* FIOCLEX */
24559243Sobrien# endif /* F_SETFD */
24659243Sobrien#else /* WINNT */
24759243Sobrien# define close_on_exec(fd, v) nt_close_on_exec((fd),(v))
24859243Sobrien#endif /* !WINNT */
24959243Sobrien
25059243Sobrien/*
25159243Sobrien * Stat
25259243Sobrien */
25359243Sobrien#ifdef ISC
25459243Sobrien/* these are not defined for _POSIX_SOURCE under ISC 2.2 */
25559243Sobrien# ifndef S_IFMT
25659243Sobrien#  define S_IFMT	0170000		/* type of file */
25759243Sobrien#  define S_IFDIR	0040000		/* directory */
25859243Sobrien#  define S_IFCHR	0020000		/* character special */
25959243Sobrien#  define S_IFBLK	0060000		/* block special */
26059243Sobrien#  define S_IFREG	0100000		/* regular */
26159243Sobrien#  define S_IFIFO	0010000		/* fifo */
26259243Sobrien#  define S_IFNAM	0050000		/* special named file */
26359243Sobrien#  ifndef ISC202
26459243Sobrien#   define S_IFLNK	0120000		/* symbolic link */
26559243Sobrien#  endif /* ISC202 */
26659243Sobrien# endif /* S_IFMT */
26759243Sobrien#endif /* ISC */
26859243Sobrien
26959243Sobrien#if defined(uts) || defined(UTekV) || defined(sysV88)
27059243Sobrien/*
27159243Sobrien * The uts 2.1.2 macros (Amdahl) are busted!
27259243Sobrien * You should fix <sys/stat.h>, cause other programs will break too!
27359243Sobrien *
27459243Sobrien * From: creiman@ncsa.uiuc.edu (Charlie Reiman)
27559243Sobrien */
27659243Sobrien
27759243Sobrien/*
27859243Sobrien * The same applies to Motorola MPC (System V/88 R32V2, UTekV 3.2e)
27959243Sobrien * workstations, the stat macros are broken.
28059243Sobrien * Kaveh Ghazi (ghazi@caip.rutgers.edu)
28159243Sobrien */
28259243Sobrien# undef S_ISDIR
28359243Sobrien# undef S_ISCHR
28459243Sobrien# undef S_ISBLK
28559243Sobrien# undef S_ISREG
28659243Sobrien# undef S_ISFIFO
28759243Sobrien# undef S_ISNAM
28859243Sobrien# undef S_ISLNK
28959243Sobrien# undef S_ISSOCK
29059243Sobrien#endif /* uts || UTekV || sysV88 */
29159243Sobrien
29259243Sobrien#ifdef S_IFMT
29359243Sobrien# if !defined(S_ISDIR) && defined(S_IFDIR)
29459243Sobrien#  define S_ISDIR(a)	(((a) & S_IFMT) == S_IFDIR)
29559243Sobrien# endif	/* ! S_ISDIR && S_IFDIR */
29659243Sobrien# if !defined(S_ISCHR) && defined(S_IFCHR)
29759243Sobrien#  define S_ISCHR(a)	(((a) & S_IFMT) == S_IFCHR)
29859243Sobrien# endif /* ! S_ISCHR && S_IFCHR */
29959243Sobrien# if !defined(S_ISBLK) && defined(S_IFBLK)
30059243Sobrien#  define S_ISBLK(a)	(((a) & S_IFMT) == S_IFBLK)
30159243Sobrien# endif	/* ! S_ISBLK && S_IFBLK */
30259243Sobrien# if !defined(S_ISREG) && defined(S_IFREG)
30359243Sobrien#  define S_ISREG(a)	(((a) & S_IFMT) == S_IFREG)
30459243Sobrien# endif	/* ! S_ISREG && S_IFREG */
30559243Sobrien# if !defined(S_ISFIFO) && defined(S_IFIFO)
30659243Sobrien#  define S_ISFIFO(a)	(((a) & S_IFMT) == S_IFIFO)
30759243Sobrien# endif	/* ! S_ISFIFO && S_IFIFO */
30859243Sobrien# if !defined(S_ISNAM) && defined(S_IFNAM)
30959243Sobrien#  define S_ISNAM(a)	(((a) & S_IFMT) == S_IFNAM)
31059243Sobrien# endif	/* ! S_ISNAM && S_IFNAM */
31159243Sobrien# if !defined(S_ISLNK) && defined(S_IFLNK)
31259243Sobrien#  define S_ISLNK(a)	(((a) & S_IFMT) == S_IFLNK)
31359243Sobrien# endif	/* ! S_ISLNK && S_IFLNK */
31459243Sobrien# if !defined(S_ISSOCK) && defined(S_IFSOCK)
31559243Sobrien#  define S_ISSOCK(a)	(((a) & S_IFMT) == S_IFSOCK)
31659243Sobrien# endif	/* ! S_ISSOCK && S_IFSOCK */
31759243Sobrien#endif /* S_IFMT */
31859243Sobrien
31959243Sobrien#ifdef tower32
32059243Sobrien/* The header files lie; we really don't have symlinks */
32159243Sobrien# undef S_ISLNK
32259243Sobrien# undef S_IFLNK
32359243Sobrien#endif /* tower32 */
32459243Sobrien
32559243Sobrien#ifndef S_IREAD
32659243Sobrien# define S_IREAD 0000400
32759243Sobrien#endif /* S_IREAD */
32859243Sobrien#ifndef S_IROTH
32959243Sobrien# define S_IROTH (S_IREAD >> 6)
33059243Sobrien#endif /* S_IROTH */
33159243Sobrien#ifndef S_IRGRP
33259243Sobrien# define S_IRGRP (S_IREAD >> 3)
33359243Sobrien#endif /* S_IRGRP */
33459243Sobrien#ifndef S_IRUSR
33559243Sobrien# define S_IRUSR S_IREAD
33659243Sobrien#endif /* S_IRUSR */
33759243Sobrien
33859243Sobrien#ifndef S_IWRITE
33959243Sobrien# define S_IWRITE 0000200
34059243Sobrien#endif /* S_IWRITE */
34159243Sobrien#ifndef S_IWOTH
34259243Sobrien# define S_IWOTH (S_IWRITE >> 6)
34359243Sobrien#endif /* S_IWOTH */
34459243Sobrien#ifndef S_IWGRP
34559243Sobrien# define S_IWGRP (S_IWRITE >> 3)
34659243Sobrien#endif /* S_IWGRP */
34759243Sobrien#ifndef S_IWUSR
34859243Sobrien# define S_IWUSR S_IWRITE
34959243Sobrien#endif /* S_IWUSR */
35059243Sobrien
35159243Sobrien#ifndef S_IEXEC
35259243Sobrien# define S_IEXEC 0000100
35359243Sobrien#endif /* S_IEXEC */
35459243Sobrien#ifndef S_IXOTH
35559243Sobrien# define S_IXOTH (S_IEXEC >> 6)
35659243Sobrien#endif /* S_IXOTH */
35759243Sobrien#ifndef S_IXGRP
35859243Sobrien# define S_IXGRP (S_IEXEC >> 3)
35959243Sobrien#endif /* S_IXGRP */
36059243Sobrien#ifndef S_IXUSR
36159243Sobrien# define S_IXUSR S_IEXEC
36259243Sobrien#endif /* S_IXUSR */
36359243Sobrien
36459243Sobrien#ifndef S_ISUID
36559243Sobrien# define S_ISUID 0004000 	/* setuid */
36659243Sobrien#endif /* S_ISUID */
36759243Sobrien#ifndef S_ISGID
36859243Sobrien# define S_ISGID 0002000	/* setgid */
36959243Sobrien#endif /* S_ISGID */
37059243Sobrien#ifndef S_ISVTX
37159243Sobrien# define S_ISVTX 0001000	/* sticky */
37259243Sobrien#endif /* S_ISVTX */
37359243Sobrien#ifndef S_ENFMT
37459243Sobrien# define S_ENFMT S_ISGID	/* record locking enforcement flag */
37559243Sobrien#endif /* S_ENFMT */
37659243Sobrien
37759243Sobrien/* the following macros are for POSIX conformance */
37859243Sobrien#ifndef S_IRWXU
37959243Sobrien# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
38059243Sobrien#endif /* S_IRWXU */
38159243Sobrien#ifndef S_IRWXG
38259243Sobrien# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
38359243Sobrien#endif /* S_IRWXG */
38459243Sobrien#ifndef S_IRWXO
38559243Sobrien# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
38659243Sobrien#endif /* S_IRWXO */
38759243Sobrien
38859243Sobrien/*
38959243Sobrien * Access()
39059243Sobrien */
39159243Sobrien#ifndef F_OK
39259243Sobrien# define F_OK 0
39359243Sobrien#endif /* F_OK */
39459243Sobrien#ifndef X_OK
39559243Sobrien# define X_OK 1
39659243Sobrien#endif /* X_OK */
39759243Sobrien#ifndef W_OK
39859243Sobrien# define W_OK 2
39959243Sobrien#endif /* W_OK */
40059243Sobrien#ifndef R_OK
40159243Sobrien# define R_OK 4
40259243Sobrien#endif /* R_OK */
40359243Sobrien
40459243Sobrien/*
40559243Sobrien * Open()
40659243Sobrien */
40759243Sobrien#ifndef O_RDONLY
40859243Sobrien# define O_RDONLY	0
40959243Sobrien#endif /* O_RDONLY */
41059243Sobrien#ifndef O_WRONLY
41159243Sobrien# define O_WRONLY	1
41259243Sobrien#endif /* O_WRONLY */
41359243Sobrien#ifndef O_RDWR
41459243Sobrien# define O_RDWR		2
41559243Sobrien#endif /* O_RDWR */
41659243Sobrien
41759243Sobrien/*
41859243Sobrien * Lseek()
41959243Sobrien */
42059243Sobrien#ifndef L_SET
42159243Sobrien# ifdef SEEK_SET
42259243Sobrien#  define L_SET		SEEK_SET
42359243Sobrien# else /* !SEEK_SET */
42459243Sobrien#  define L_SET		0
42559243Sobrien# endif	/* SEEK_SET */
42659243Sobrien#endif /* L_SET */
42759243Sobrien#ifndef L_INCR
42859243Sobrien# ifdef SEEK_CUR
42959243Sobrien#  define L_INCR	SEEK_CUR
43059243Sobrien# else /* !SEEK_CUR */
43159243Sobrien#  define L_INCR	1
43259243Sobrien# endif	/* SEEK_CUR */
43359243Sobrien#endif /* L_INCR */
43459243Sobrien#ifndef L_XTND
43559243Sobrien# ifdef SEEK_END
43659243Sobrien#  define L_XTND	SEEK_END
43759243Sobrien# else /* !SEEK_END */
43859243Sobrien#  define L_XTND	2
43959243Sobrien# endif /* SEEK_END */
44059243Sobrien#endif /* L_XTND */
44159243Sobrien
44259243Sobrien#ifdef _SEQUENT_
44359243Sobrien# define NEEDgethostname
44459243Sobrien#endif /* _SEQUENT_ */
44559243Sobrien
44659243Sobrien#if defined(BSD) && defined(POSIXJOBS) && !defined(BSD4_4) && !defined(__hp_osf)
44759243Sobrien# define setpgid(pid, pgrp)	setpgrp(pid, pgrp)
44859243Sobrien#endif /* BSD && POSIXJOBS && && !BSD4_4 && !__hp_osf */
44959243Sobrien
45059243Sobrien#if defined(BSDJOBS) && !(defined(POSIX) && defined(POSIXJOBS))
45159243Sobrien# if !defined(_AIX370) && !defined(_AIXPS2)
45259243Sobrien#  define setpgid(pid, pgrp)	setpgrp(pid, pgrp)
45359243Sobrien# endif /* !_AIX370 && !_AIXPS2 */
45459243Sobrien# define NEEDtcgetpgrp
45559243Sobrien#endif /* BSDJOBS && !(POSIX && POSIXJOBS) */
45659243Sobrien
45759243Sobrien#ifdef RENO
45859243Sobrien/*
45959243Sobrien * RENO has this broken. It is fixed on 4.4BSD
46059243Sobrien */
46159243Sobrien# define NEEDtcgetpgrp
46259243Sobrien#endif /* RENO */
46359243Sobrien
46459243Sobrien#ifdef DGUX
46559243Sobrien# define setpgrp(a, b) setpgrp2(a, b)
46659243Sobrien# define getpgrp(a) getpgrp2(a)
46759243Sobrien#endif /* DGUX */
46859243Sobrien
46959243Sobrien#ifdef SXA
47059243Sobrien# ifndef _BSDX_
47159243Sobrien/*
47259243Sobrien * Only needed in the system V environment.
47359243Sobrien */
47459243Sobrien#  define setrlimit 	bsd_setrlimit
47559243Sobrien#  define getrlimit	bsd_getrlimit
47659243Sobrien# endif	/* _BSDX_ */
47759243Sobrien#endif /* SXA */
47859243Sobrien
47959243Sobrien#if defined(_MINIX) || defined(__EMX__)
48059243Sobrien# define NEEDgethostname
48159243Sobrien# define NEEDnice
48259243Sobrien# define HAVENOLIMIT
48359243Sobrien/*
48459243Sobrien * Minix does not have these, so...
48559243Sobrien */
48659243Sobrien# define getpgrp		getpid
48759243Sobrien#endif /* _MINIX || __EMX__ */
48859243Sobrien
48959243Sobrien#ifdef __EMX__
49059243Sobrien/* XXX: How can we get the tty name in emx? */
49159243Sobrien# define ttyname(fd) (isatty(fd) ? "/dev/tty" : NULL)
49259243Sobrien#endif /* __EMX__ */
49359243Sobrien
49459243Sobrien#ifndef POSIX
49559243Sobrien# define mygetpgrp()    getpgrp(0)
49659243Sobrien#else /* POSIX */
49759243Sobrien# if (defined(BSD) && !defined(BSD4_4)) || defined(SUNOS4) || defined(IRIS4D) || defined(DGUX) || defined(HPRT)
49859243Sobrien#  define mygetpgrp()    getpgrp(0)
49959243Sobrien# else /* !((BSD && !BSD4_4) || SUNOS4 || IRIS4D || DGUX || HPRT) */
50059243Sobrien#  define mygetpgrp()    getpgrp()
50159243Sobrien# endif	/* (BSD && BSD4_4) || SUNOS4 || IRISD || DGUX  || HPRT */
50259243Sobrien#endif /* POSIX */
50359243Sobrien
50459243Sobrien
50559243Sobrien#if !defined(SOLARIS2) && !defined(sinix) && !defined(BSD4_4) && !defined(WINNT)
50659243Sobrien# if (SYSVREL > 0 && !defined(OREO) && !defined(sgi) && !defined(linux) && !defined(sinix) && !defined(_AIX) &&!defined(_UWIN)) || defined(NeXT)
50759243Sobrien#  define NEEDgetcwd
50859243Sobrien# endif /* (SYSVREL > 0 && !OREO && !sgi && !linux && !sinix && !_AIX && !_UWIN) || NeXT */
50959243Sobrien#endif
51059243Sobrien
51159243Sobrien#ifndef S_IFLNK
51259243Sobrien# define lstat stat
51359243Sobrien#endif /* S_IFLNK */
51459243Sobrien
51559243Sobrien
51659243Sobrien#if defined(BSDTIMES) && !defined(_SEQUENT_)
51759243Sobrientypedef struct timeval timeval_t;
51859243Sobrien#endif /* BSDTIMES && ! _SEQUENT_ */
51959243Sobrien
52059243Sobrien#ifdef NeXT
52159243Sobrien/*
52259243Sobrien * From Tony_Mason@transarc.com, override NeXT's malloc stuff.
52359243Sobrien */
52459243Sobrien# define malloc tcsh_malloc
52559243Sobrien# define calloc tcsh_calloc
52659243Sobrien# define realloc tcsh_realloc
52759243Sobrien# define free tcsh_free
52859243Sobrien#endif /* NeXT */
52959243Sobrien
53059243Sobrien#if !defined(BSD4_4) && !defined(__linux__) && !defined(__hpux) && !defined(sgi)
53159243Sobrien#ifndef NEEDgethostname
53259243Sobrienextern int gethostname __P((char *, int));
53359243Sobrien#endif /* NEEDgethostname */
53459243Sobrien#endif /* !BDS4_4 && !__linux__ && !__hpux && !sgi */
53559243Sobrien
53659243Sobrien#if !defined(POSIX) || defined(SUNOS4) || defined(UTekV) || defined(sysV88)
53759243Sobrienextern time_t time();
53859243Sobrienextern char *getenv();
53959243Sobrienextern int atoi();
54059243Sobrien# ifndef __EMX__
54159243Sobrienextern char *ttyname();
54259243Sobrien# endif /* __EMX__ */
54359243Sobrien
54459243Sobrien# if defined(SUNOS4)
54559243Sobrien#  ifndef toupper
54659243Sobrienextern int toupper __P((int));
54759243Sobrien#  endif /* toupper */
54859243Sobrien#  ifndef tolower
54959243Sobrienextern int tolower __P((int));
55059243Sobrien#  endif /* tolower */
55159243Sobrienextern caddr_t sbrk __P((int));
55259243Sobrien#  if SYSVREL == 0 && !defined(__lucid)
55359243Sobrienextern int qsort();
55459243Sobrien#  endif /* SYSVREL == 0 && !__lucid */
55559243Sobrien# else /* !SUNOS4 */
55659243Sobrien#  ifndef WINNT
55759243Sobrien#   ifndef hpux
55859243Sobrien#    if __GNUC__ != 2
55959243Sobrienextern int abort();
56059243Sobrien#    endif /* __GNUC__ != 2 */
56159243Sobrien#    ifndef fps500
56259243Sobrienextern int qsort();
56359243Sobrien#    endif /* !fps500 */
56459243Sobrien#   else /* !hpux */
56559243Sobrienextern void abort();
56659243Sobrienextern void qsort();
56759243Sobrien#   endif /* hpux */
56859243Sobrien#  endif /* !WINNT */
56959243Sobrien# endif	/* SUNOS4 */
57059243Sobrien#ifndef _CX_UX
57159243Sobrienextern void perror();
57259243Sobrien#endif
57359243Sobrien
57459243Sobrien# ifdef BSDSIGS
57559243Sobrien#  if defined(_AIX370) || defined(MACH) || defined(NeXT) || defined(_AIXPS2) || defined(ardent) || defined(SUNOS4) || defined(HPBSD) || defined(__MACHTEN__)
57659243Sobrienextern int sigvec();
57759243Sobrienextern int sigpause();
57859243Sobrien#  else	/* !(_AIX370 || MACH || NeXT || _AIXPS2 || ardent || SUNOS4 || HPBSD) */
57959243Sobrien#   if (!defined(apollo) || !defined(__STDC__)) && !defined(__DGUX__) && !defined(fps500)
58059243Sobrienextern sigret_t sigvec();
58159243Sobrien#ifndef _CX_UX
58259243Sobrienextern void sigpause();
58359243Sobrien#endif /* _CX_UX */
58459243Sobrien#   endif /* (!apollo || !__STDC__) && !__DGUX__ && !fps500 */
58559243Sobrien#  endif /* _AIX370 || MACH || NeXT || _AIXPS2 || ardent || SUNOS4 || HPBSD */
58659243Sobrienextern sigmask_t sigblock();
58759243Sobrienextern sigmask_t sigsetmask();
58859243Sobrien# endif	/* BSDSIGS */
58959243Sobrien
59059243Sobrien# ifndef killpg
59159243Sobrienextern int killpg();
59259243Sobrien# endif	/* killpg */
59359243Sobrien
59459243Sobrien# ifndef lstat
59559243Sobrienextern int lstat();
59659243Sobrien# endif	/* lstat */
59759243Sobrien
59859243Sobrien# ifdef BSD
59959243Sobrienextern uid_t getuid(), geteuid();
60059243Sobrienextern gid_t getgid(), getegid();
60159243Sobrien# endif /* BSD */
60259243Sobrien
60359243Sobrien# ifdef SYSMALLOC
60459243Sobrienextern memalign_t malloc();
60559243Sobrienextern memalign_t realloc();
60659243Sobrienextern memalign_t calloc();
60759243Sobrienextern void free();
60859243Sobrien# endif	/* SYSMALLOC */
60959243Sobrien
61059243Sobrien# ifdef BSDTIMES
61159243Sobrienextern int getrlimit();
61259243Sobrienextern int setrlimit();
61359243Sobrienextern int getrusage();
61459243Sobrienextern int gettimeofday();
61559243Sobrien# endif	/* BSDTIMES */
61659243Sobrien
61759243Sobrien# if defined(NLS) && !defined(NOSTRCOLL) && !defined(NeXT)
61859243Sobrienextern int strcoll();
61959243Sobrien# endif /* NLS && !NOSTRCOLL && !NeXT */
62059243Sobrien
62159243Sobrien# ifdef BSDJOBS
62259243Sobrien#  ifdef BSDTIMES
62359243Sobrien#   ifdef __MACHTEN__
62459243Sobrienextern pid_t wait3();
62559243Sobrien#   else
62659243Sobrien#   ifndef HPBSD
62759243Sobrienextern int wait3();
62859243Sobrien#   endif /* HPBSD */
62959243Sobrien#   endif /* __MACHTEN__ */
63059243Sobrien#  else	/* !BSDTIMES */
63159243Sobrien#   if !defined(POSIXJOBS) && !defined(_SEQUENT_)
63259243Sobrienextern int wait3();
63359243Sobrien#   else /* POSIXJOBS || _SEQUENT_ */
63459243Sobrienextern int waitpid();
63559243Sobrien#   endif /* POSIXJOBS || _SEQUENT_ */
63659243Sobrien#  endif /* BSDTIMES */
63759243Sobrien# else /* !BSDJOBS */
63859243Sobrien#  if SYSVREL < 3
63959243Sobrienextern int ourwait();
64059243Sobrien#  else	/* SYSVREL >= 3 */
64159243Sobrienextern int wait();
64259243Sobrien#  endif /* SYSVREL < 3 */
64359243Sobrien# endif	/* BSDJOBS */
64459243Sobrien
64559243Sobrien# ifdef BSDNICE
64659243Sobrienextern int setpriority();
64759243Sobrien# else /* !BSDNICE */
64859243Sobrienextern int nice();
64959243Sobrien# endif	/* BSDNICE */
65059243Sobrien
65159243Sobrien# if (!defined(fps500) && !defined(apollo) && !defined(__lucid) && !defined(HPBSD) && !defined(DECOSF1))
65259243Sobrienextern void setpwent();
65359243Sobrienextern void endpwent();
65459243Sobrien# endif /* !fps500 && !apollo && !__lucid && !HPBSD && !DECOSF1 */
65559243Sobrien
65659243Sobrien# ifndef __STDC__
65759243Sobrienextern struct passwd *getpwuid(), *getpwnam(), *getpwent();
65859243Sobrien#  ifdef PW_SHADOW
65959243Sobrienextern struct spwd *getspnam(), *getspent();
66059243Sobrien#  endif /* PW_SHADOW */
66159243Sobrien#  ifdef PW_AUTH
66259243Sobrienextern struct authorization *getauthuid();
66359243Sobrien#  endif /* PW_AUTH */
66459243Sobrien# endif /* __STDC__ */
66559243Sobrien
66659243Sobrien# ifndef getcwd
66759243Sobrienextern char *getcwd();
66859243Sobrien# endif	/* getcwd */
66959243Sobrien
67059243Sobrien#else /* POSIX || !SUNOS4 || !UTekV || !sysV88 */
67159243Sobrien
67259243Sobrien# if (defined(SUNOS4) && !defined(__GNUC__)) || defined(_IBMR2) || defined(_IBMESA)
67359243Sobrienextern char *getvwd();
67459243Sobrien# endif	/* (SUNOS4 && ! __GNUC__) || _IBMR2 || _IBMESA */
67559243Sobrien
67659243Sobrien# ifdef SCO
67759243Sobrienextern char *ttyname();
67859243Sobrien# endif /* SCO */
67959243Sobrien
68059243Sobrien# ifdef __clipper__
68159243Sobrienextern char *ttyname();
68259243Sobrien# endif /* __clipper__ */
68359243Sobrien
68459243Sobrien#endif /* !POSIX || SUNOS4 || UTekV || sysV88 */
68559243Sobrien
68659243Sobrien#if defined(SUNOS4) && __GNUC__ == 2
68759243Sobrien/*
68859243Sobrien * Somehow these are missing
68959243Sobrien */
69059243Sobrienextern int ioctl __P((int, int, ...));
69159243Sobrienextern int readlink __P((const char *, char *, size_t));
69259243Sobrienextern void setgrent __P((void));
69359243Sobrienextern void endgrent __P((void));
69459243Sobrien# ifdef REMOTEHOST
69559243Sobrien#  ifndef _SOCKLEN_T	/* Avoid Solaris 2.7 bogosity. */
69659243Sobrienstruct sockaddr;
69759243Sobrienextern int getpeername __P((int, struct sockaddr *, int *));
69859243Sobrien#  endif /* _SOCKLEN_T */
69959243Sobrien# endif /* REMOTEHOST */
70059243Sobrien#endif /* SUNOS4 && __GNUC__ == 2 */
70159243Sobrien
70259243Sobrien#if (defined(BSD) && !defined(BSD4_4)) || defined(SUNOS4)
70359243Sobrien# if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
70459243Sobrienextern void bcopy	__P((const void *, void *, size_t));
70559243Sobrien#  define memmove(a, b, c) (bcopy((char *) (b), (char *) (a), (int) (c)), a)
70659243Sobrien# endif /* __alpha && __osf__ && DECOSF1 < 200 */
70759243Sobrien#endif /* (BSD && !BSD4_4) || SUNOS4 */
70859243Sobrien
70959243Sobrien#if !defined(hpux) && !defined(COHERENT) && ((SYSVREL < 4) || defined(_SEQUENT_)) && !defined(BSD4_4) && !defined(memmove)
71059243Sobrien# define NEEDmemmove
71159243Sobrien#endif /* !hpux && !COHERENT && (SYSVREL < 4 || _SEQUENT_) && !BSD4_4 && !memmove */
71259243Sobrien
71359243Sobrien#if defined(UTek) || defined(pyr)
71459243Sobrien# define NEEDmemset
71559243Sobrien#else /* !UTek && !pyr */
71659243Sobrien# ifdef SUNOS4
71759243Sobrien#  include <memory.h>	/* memset should be declared in <string.h> but isn't */
71859243Sobrien# endif /* SUNOS4 */
71959243Sobrien#endif /* UTek || pyr */
72059243Sobrien
72159243Sobrien#if SYSVREL == 4
72259243Sobrien# ifdef REMOTEHOST
72359243Sobrien/* Irix6 defines getpeername(int, void *, int *) which conflicts with
72459243Sobrien   the definition below. */
72559243Sobrien#  if !defined(__sgi) && !defined(_OSD_POSIX)
72659243Sobrien#   ifndef _SOCKLEN_T	/* Avoid Solaris 2.7 bogosity. */
72759243Sobrienstruct sockaddr;
72859243Sobrienextern int getpeername __P((int, struct sockaddr *, int *));
72959243Sobrien#   endif /* _SOCKLEN_T */
73059243Sobrien#  endif /* !__sgi && !_OSD_POSIX */
73159243Sobrien# endif /* REMOTEHOST */
73259243Sobrien# ifndef BSDTIMES
73359243Sobrienextern int getrlimit __P((int, struct rlimit *));
73459243Sobrienextern int setrlimit __P((int, const struct rlimit *));
73559243Sobrien# endif /* !BSDTIMES */
73659243Sobrien# if !defined(IRIS4D) && !defined(SOLARIS2)
73759243Sobrienextern int wait3();	/* I think some bizarre systems still need this */
73859243Sobrien# endif /* !IRIS4D && !SOLARIS2 */
73959243Sobrien# if defined(SOLARIS2)
74059243Sobrien#  undef NEEDstrerror
74159243Sobrienextern char *strerror __P((int));
74259243Sobrien# endif /* SOLARIS2 */
74359243Sobrien#endif /* SYSVREL == 4 */
74459243Sobrien
74559243Sobrien#if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
74659243Sobrien/* These are ok for 1.3, but conflict with the header files for 2.0 */
74759243Sobrienextern int gethostname __P((char *, int));
74859243Sobrienextern char *sbrk __P((ssize_t));
74959243Sobrienextern int ioctl __P((int, unsigned long, char *));
75059243Sobrienextern pid_t vfork __P((void));
75159243Sobrienextern int killpg __P((pid_t, int));
75259243Sobrien#endif /* __osf__ && __alpha && DECOSF1 < 200 */
75359243Sobrien
75459243Sobrien#endif /* _h_tc_os */
755