tc.os.h revision 100616
1/* $Header: /src/pub/tcsh/tc.os.h,v 3.88 2002/05/16 13:51:26 christos Exp $ */
2/*
3 * tc.os.h: Shell os dependent defines
4 */
5/*-
6 * Copyright (c) 1980, 1991 The Regents of the University of California.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the University nor the names of its contributors
18 *    may be used to endorse or promote products derived from this software
19 *    without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33#ifndef _h_tc_os
34#define _h_tc_os
35
36#ifndef WINNT_NATIVE
37#define NEEDstrerror		/* Too hard to find which systems have it */
38#endif /* WINNT_NATIVE */
39
40
41#ifdef notdef
42/*
43 * for SVR4 and linux we used to fork pipelines backwards.
44 * This should not be needed any more.
45 * more info in sh.sem.c
46 */
47# define BACKPIPE
48#endif /* notdef */
49
50#ifdef __CYGWIN__
51#  undef NEEDstrerror
52#endif
53
54#ifdef   _VMS_POSIX
55# ifndef  NOFILE
56#  define  NOFILE 64
57# endif /* NOFILE */
58# define  nice(a)       setprio((getpid()),a)
59# undef   NEEDstrerror    /* won't get sensible error messages otherwise */
60# define  NEEDgethostname
61# include <sys/time.h>    /* for time stuff in tc.prompt.c */
62# include <limits.h>
63#endif /* atp vmsposix */
64
65#if defined(DECOSF1) || defined(HPUXVERSION)
66# include <sys/signal.h>
67#endif /* DECOSF1 || HPUXVERSION */
68
69#ifdef DECOSF1
70# include <sys/ioctl.h>
71#endif /* DECOSF1 */
72
73#if defined(OPEN_MAX) && !defined(NOFILE)
74# define NOFILE OPEN_MAX
75#endif /* OPEN_MAX && !NOFILE */
76
77#if defined(USR_NFDS) && !defined(NOFILE)
78# define NOFILE USR_NFDS
79#endif /* USR_NFDS && !NOFILE */
80
81#ifndef NOFILE
82# define NOFILE 256
83#endif /* NOFILE */
84
85#if defined(linux) || defined(__NetBSD__) || defined(__FreeBSD__) || SYSVREL >= 4  || defined(_MINIX_VMD)
86# undef NEEDstrerror
87#endif /* linux || __NetBSD__ || __FreeBSD__ || SYSVREL >= 4 || _MINIX_VMD */
88
89#if !defined(pyr) && !defined(sinix)
90/* Pyramid's cpp complains about the next line */
91# if defined(BSD) && BSD >= 199306
92#  undef NEEDstrerror
93# endif /* BSD && BSD >= 199306 */
94#endif /* pyr */
95
96#ifdef OREO
97# include <sys/time.h>
98# ifdef notdef
99  /* Don't include it, because it defines things we don't really have */
100#  include <sys/resource.h>
101# endif /* notdef */
102# ifdef POSIX
103#  include <sys/tty.h>
104#  include <termios.h>
105# endif /* POSIX */
106#endif /* OREO */
107
108#ifndef NCARGS
109# ifdef _SC_ARG_MAX
110#  define NCARGS sysconf(_SC_ARG_MAX)
111# else /* !_SC_ARG_MAX */
112#  ifdef ARG_MAX
113#   define NCARGS ARG_MAX
114#  else /* !ARG_MAX */
115#   ifdef _MINIX
116#    define NCARGS 80
117#   else /* !_MINIX */
118#    define NCARGS 1024
119#   endif /* _MINIX */
120#  endif /* ARG_MAX */
121# endif /* _SC_ARG_MAX */
122#endif /* NCARGS */
123
124#ifdef convex
125# include <sys/dmon.h>
126#endif /* convex */
127
128#ifdef titan
129extern int end;
130#endif /* titan */
131
132#ifdef hpux
133# ifdef lint
134/*
135 * Hpux defines struct ucred, in <sys/user.h>, but if I include that
136 * then I need to include the *world*
137 * [all this to pass lint cleanly!!!]
138 * so I define struct ucred here...
139 */
140struct ucred {
141    int     foo;
142};
143# endif /* lint */
144
145/*
146 * hpux 7.0 does not define it
147 */
148# ifndef CSUSP
149#  define CSUSP 032
150# endif	/* CSUSP */
151
152# include <signal.h>
153# if !defined(hp9000s500) && !(defined(SIGRTMAX) || defined(SIGRTMIN))
154/*
155 * hpux < 7
156 */
157#  include <sys/bsdtty.h>
158# endif /* !hp9000s500 && !(SIGRTMAX || SIGRTMIN) */
159
160# ifndef POSIX
161#  ifdef BSDJOBS
162#   define getpgrp(a) getpgrp2(a)
163#   define setpgrp(a, b) setpgrp2(a, b)
164#  endif /* BSDJOBS */
165# endif	/* POSIX */
166# ifndef TIOCSTI
167#  include <sys/strtio.h>
168# endif
169#endif /* hpux */
170
171/*
172 * ISC does not define CSUSP
173 */
174#ifdef ISC
175# ifndef CSUSP
176#  define CSUSP 032
177# endif	/* CSUSP */
178# if defined(POSIX) && !defined(TIOCGWINSZ)
179/*
180 * ISC defines this only in termio.h. If we are using POSIX and include
181 * termios.h, then we define it ourselves so that window resizing works.
182 */
183#  define TIOCGWINSZ      (('T'<<8)|104)
184# endif /* POSIX && !TIOCGWINSZ */
185#endif /* ISC */
186
187#ifdef ISC202
188# undef TIOCGWINSZ
189#endif /* ISC202 */
190
191/*
192 * XXX: This will be changed soon to
193 * #if (SYSVREL > 0) && defined(TIOCGWINSZ)
194 * If that breaks on your machine, let me know.
195 *
196 * It would break on linux, where all this is
197 * defined in <termios.h>. Wrapper added.
198 */
199#if !defined(linux) && !defined(_VMS_POSIX)
200# if defined(INTEL) || defined(u3b2) || defined (u3b5) || defined(ub15) || defined(u3b20d) || defined(ISC) || defined(SCO) || defined(tower32)
201#  ifdef TIOCGWINSZ
202/*
203 * for struct winsiz
204 */
205#   include <sys/stream.h>
206#   include <sys/ptem.h>
207#  endif /* TIOCGWINSZ */
208#  ifndef ODT
209#   define NEEDgethostname
210#  endif /* ODT */
211# endif /* INTEL || u3b2 || u3b5 || ub15 || u3b20d || ISC || SCO || tower32 */
212#endif /* !linux && !_VMS_POSIX */
213
214#if defined(UNIXPC) || defined(COHERENT)
215# define NEEDgethostname
216#endif /* UNIXPC || COHERENT */
217
218#ifdef IRIS4D
219# include <sys/time.h>
220# include <sys/resource.h>
221# ifndef POSIX
222/*
223 * BSDsetpgrp() and BSDgetpgrp() are BSD versions of setpgrp, etc.
224 */
225#  define setpgrp BSDsetpgrp
226#  define getpgrp BSDgetpgrp
227# endif /* POSIX */
228#endif /* IRIS4D */
229
230/*
231 * For some versions of system V software, specially ones that use the
232 * Wollongong Software TCP/IP, the FIOCLEX, FIONCLEX, FIONBIO calls
233 * might not work correctly for file descriptors [they work only for
234 * sockets]. So we try to use first the fcntl() and we only use the
235 * ioctl() form, only if we don't have the fcntl() one.
236 *
237 * From: scott@craycos.com (Scott Bolte)
238 */
239#ifndef WINNT_NATIVE
240# ifdef F_SETFD
241#  define close_on_exec(fd, v) fcntl((fd), F_SETFD, v)
242# else /* !F_SETFD */
243#  ifdef FIOCLEX
244#   define close_on_exec(fd, v) ioctl((fd), ((v) ? FIOCLEX : FIONCLEX), NULL)
245#  else /* !FIOCLEX */
246#   define close_on_exec(fd, v)	/* Nothing */
247#  endif /* FIOCLEX */
248# endif /* F_SETFD */
249#else /* WINNT_NATIVE */
250# define close_on_exec(fd, v) nt_close_on_exec((fd),(v))
251#endif /* !WINNT_NATIVE */
252
253/*
254 * Stat
255 */
256#ifdef ISC
257/* these are not defined for _POSIX_SOURCE under ISC 2.2 */
258# ifndef S_IFMT
259#  define S_IFMT	0170000		/* type of file */
260#  define S_IFDIR	0040000		/* directory */
261#  define S_IFCHR	0020000		/* character special */
262#  define S_IFBLK	0060000		/* block special */
263#  define S_IFREG	0100000		/* regular */
264#  define S_IFIFO	0010000		/* fifo */
265#  define S_IFNAM	0050000		/* special named file */
266#  ifndef ISC202
267#   define S_IFLNK	0120000		/* symbolic link */
268#  endif /* ISC202 */
269# endif /* S_IFMT */
270#endif /* ISC */
271
272#if defined(uts) || defined(UTekV) || defined(sysV88)
273/*
274 * The uts 2.1.2 macros (Amdahl) are busted!
275 * You should fix <sys/stat.h>, cause other programs will break too!
276 *
277 * From: creiman@ncsa.uiuc.edu (Charlie Reiman)
278 */
279
280/*
281 * The same applies to Motorola MPC (System V/88 R32V2, UTekV 3.2e)
282 * workstations, the stat macros are broken.
283 * Kaveh Ghazi (ghazi@caip.rutgers.edu)
284 */
285# undef S_ISDIR
286# undef S_ISCHR
287# undef S_ISBLK
288# undef S_ISREG
289# undef S_ISFIFO
290# undef S_ISNAM
291# undef S_ISLNK
292# undef S_ISSOCK
293#endif /* uts || UTekV || sysV88 */
294
295#ifdef S_IFMT
296# if !defined(S_ISDIR) && defined(S_IFDIR)
297#  define S_ISDIR(a)	(((a) & S_IFMT) == S_IFDIR)
298# endif	/* ! S_ISDIR && S_IFDIR */
299# if !defined(S_ISCHR) && defined(S_IFCHR)
300#  define S_ISCHR(a)	(((a) & S_IFMT) == S_IFCHR)
301# endif /* ! S_ISCHR && S_IFCHR */
302# if !defined(S_ISBLK) && defined(S_IFBLK)
303#  define S_ISBLK(a)	(((a) & S_IFMT) == S_IFBLK)
304# endif	/* ! S_ISBLK && S_IFBLK */
305# if !defined(S_ISREG) && defined(S_IFREG)
306#  define S_ISREG(a)	(((a) & S_IFMT) == S_IFREG)
307# endif	/* ! S_ISREG && S_IFREG */
308# if !defined(S_ISFIFO) && defined(S_IFIFO)
309#  define S_ISFIFO(a)	(((a) & S_IFMT) == S_IFIFO)
310# endif	/* ! S_ISFIFO && S_IFIFO */
311# if !defined(S_ISNAM) && defined(S_IFNAM)
312#  define S_ISNAM(a)	(((a) & S_IFMT) == S_IFNAM)
313# endif	/* ! S_ISNAM && S_IFNAM */
314# if !defined(S_ISLNK) && defined(S_IFLNK)
315#  define S_ISLNK(a)	(((a) & S_IFMT) == S_IFLNK)
316# endif	/* ! S_ISLNK && S_IFLNK */
317# if !defined(S_ISSOCK) && defined(S_IFSOCK)
318#  define S_ISSOCK(a)	(((a) & S_IFMT) == S_IFSOCK)
319# endif	/* ! S_ISSOCK && S_IFSOCK */
320#endif /* S_IFMT */
321
322#ifdef tower32
323/* The header files lie; we really don't have symlinks */
324# undef S_ISLNK
325# undef S_IFLNK
326#endif /* tower32 */
327
328#ifndef S_IREAD
329# define S_IREAD 0000400
330#endif /* S_IREAD */
331#ifndef S_IROTH
332# define S_IROTH (S_IREAD >> 6)
333#endif /* S_IROTH */
334#ifndef S_IRGRP
335# define S_IRGRP (S_IREAD >> 3)
336#endif /* S_IRGRP */
337#ifndef S_IRUSR
338# define S_IRUSR S_IREAD
339#endif /* S_IRUSR */
340
341#ifndef S_IWRITE
342# define S_IWRITE 0000200
343#endif /* S_IWRITE */
344#ifndef S_IWOTH
345# define S_IWOTH (S_IWRITE >> 6)
346#endif /* S_IWOTH */
347#ifndef S_IWGRP
348# define S_IWGRP (S_IWRITE >> 3)
349#endif /* S_IWGRP */
350#ifndef S_IWUSR
351# define S_IWUSR S_IWRITE
352#endif /* S_IWUSR */
353
354#ifndef S_IEXEC
355# define S_IEXEC 0000100
356#endif /* S_IEXEC */
357#ifndef S_IXOTH
358# define S_IXOTH (S_IEXEC >> 6)
359#endif /* S_IXOTH */
360#ifndef S_IXGRP
361# define S_IXGRP (S_IEXEC >> 3)
362#endif /* S_IXGRP */
363#ifndef S_IXUSR
364# define S_IXUSR S_IEXEC
365#endif /* S_IXUSR */
366
367#ifndef S_ISUID
368# define S_ISUID 0004000 	/* setuid */
369#endif /* S_ISUID */
370#ifndef S_ISGID
371# define S_ISGID 0002000	/* setgid */
372#endif /* S_ISGID */
373#ifndef S_ISVTX
374# define S_ISVTX 0001000	/* sticky */
375#endif /* S_ISVTX */
376#ifndef S_ENFMT
377# define S_ENFMT S_ISGID	/* record locking enforcement flag */
378#endif /* S_ENFMT */
379
380/* the following macros are for POSIX conformance */
381#ifndef S_IRWXU
382# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
383#endif /* S_IRWXU */
384#ifndef S_IRWXG
385# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
386#endif /* S_IRWXG */
387#ifndef S_IRWXO
388# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
389#endif /* S_IRWXO */
390
391/*
392 * Access()
393 */
394#ifndef F_OK
395# define F_OK 0
396#endif /* F_OK */
397#ifndef X_OK
398# define X_OK 1
399#endif /* X_OK */
400#ifndef W_OK
401# define W_OK 2
402#endif /* W_OK */
403#ifndef R_OK
404# define R_OK 4
405#endif /* R_OK */
406
407/*
408 * Open()
409 */
410#ifndef O_RDONLY
411# define O_RDONLY	0
412#endif /* O_RDONLY */
413#ifndef O_WRONLY
414# define O_WRONLY	1
415#endif /* O_WRONLY */
416#ifndef O_RDWR
417# define O_RDWR		2
418#endif /* O_RDWR */
419
420/*
421 * Lseek()
422 */
423#ifndef L_SET
424# ifdef SEEK_SET
425#  define L_SET		SEEK_SET
426# else /* !SEEK_SET */
427#  define L_SET		0
428# endif	/* SEEK_SET */
429#endif /* L_SET */
430#ifndef L_INCR
431# ifdef SEEK_CUR
432#  define L_INCR	SEEK_CUR
433# else /* !SEEK_CUR */
434#  define L_INCR	1
435# endif	/* SEEK_CUR */
436#endif /* L_INCR */
437#ifndef L_XTND
438# ifdef SEEK_END
439#  define L_XTND	SEEK_END
440# else /* !SEEK_END */
441#  define L_XTND	2
442# endif /* SEEK_END */
443#endif /* L_XTND */
444
445#ifdef _SEQUENT_
446# define NEEDgethostname
447#endif /* _SEQUENT_ */
448
449#if defined(BSD) && defined(POSIXJOBS) && !defined(BSD4_4) && !defined(__hp_osf)
450# define setpgid(pid, pgrp)	setpgrp(pid, pgrp)
451#endif /* BSD && POSIXJOBS && && !BSD4_4 && !__hp_osf */
452
453#if defined(BSDJOBS) && !(defined(POSIX) && defined(POSIXJOBS))
454# if !defined(_AIX370) && !defined(_AIXPS2)
455#  define setpgid(pid, pgrp)	setpgrp(pid, pgrp)
456# endif /* !_AIX370 && !_AIXPS2 */
457# define NEEDtcgetpgrp
458#endif /* BSDJOBS && !(POSIX && POSIXJOBS) */
459
460#ifdef RENO
461/*
462 * RENO has this broken. It is fixed on 4.4BSD
463 */
464# define NEEDtcgetpgrp
465#endif /* RENO */
466
467#ifdef DGUX
468# define setpgrp(a, b) setpgrp2(a, b)
469# define getpgrp(a) getpgrp2(a)
470#endif /* DGUX */
471
472#ifdef SXA
473# ifndef _BSDX_
474/*
475 * Only needed in the system V environment.
476 */
477#  define setrlimit 	bsd_setrlimit
478#  define getrlimit	bsd_getrlimit
479# endif	/* _BSDX_ */
480#endif /* SXA */
481
482#if defined(_MINIX) || defined(__EMX__)
483# define NEEDgethostname
484# define NEEDnice
485# define HAVENOLIMIT
486/*
487 * Minix does not have these, so...
488 */
489# define getpgrp		getpid
490#endif /* _MINIX || __EMX__ */
491
492#ifdef __EMX__
493/* XXX: How can we get the tty name in emx? */
494# define ttyname(fd) (isatty(fd) ? "/dev/tty" : NULL)
495#endif /* __EMX__ */
496
497#ifndef POSIX
498# define mygetpgrp()    getpgrp(0)
499#else /* POSIX */
500# if (defined(BSD) && !defined(BSD4_4)) || defined(SUNOS4) || defined(IRIS4D) || defined(DGUX) || defined(HPRT)
501#  define mygetpgrp()    getpgrp(0)
502# else /* !((BSD && !BSD4_4) || SUNOS4 || IRIS4D || DGUX || HPRT) */
503#  define mygetpgrp()    getpgrp()
504# endif	/* (BSD && BSD4_4) || SUNOS4 || IRISD || DGUX  || HPRT */
505#endif /* POSIX */
506
507
508#if !defined(SOLARIS2) && !defined(sinix) && !defined(BSD4_4) && !defined(WINNT_NATIVE)
509# if (SYSVREL > 0 && !defined(OREO) && !defined(sgi) && !defined(linux) && !defined(sinix) && !defined(_AIX) &&!defined(_UWIN)) || defined(NeXT)
510#  define NEEDgetcwd
511# endif /* (SYSVREL > 0 && !OREO && !sgi && !linux && !sinix && !_AIX && !_UWIN) || NeXT */
512#endif
513
514#ifndef S_IFLNK
515# define lstat stat
516#endif /* S_IFLNK */
517
518
519#if defined(BSDTIMES) && !defined(_SEQUENT_)
520typedef struct timeval timeval_t;
521#endif /* BSDTIMES && ! _SEQUENT_ */
522
523#ifdef NeXT
524/*
525 * From Tony_Mason@transarc.com, override NeXT's malloc stuff.
526 */
527# define malloc tcsh_malloc
528# define calloc tcsh_calloc
529# define realloc tcsh_realloc
530# define free tcsh_free
531#endif /* NeXT */
532
533#if !defined(BSD4_4) && !defined(__linux__) && !defined(__hpux) && \
534    !defined(sgi) && !defined(_AIX) && !defined(__CYGWIN__)
535#ifndef NEEDgethostname
536extern int gethostname __P((char *, int));
537#endif /* NEEDgethostname */
538#endif /* !BDS4_4 && !__linux__ && !__hpux && !sgi */
539
540#if !defined(POSIX) || defined(SUNOS4) || defined(UTekV) || defined(sysV88)
541extern time_t time();
542extern char *getenv();
543extern int atoi();
544# ifndef __EMX__
545extern char *ttyname();
546# endif /* __EMX__ */
547
548# if defined(SUNOS4)
549#  ifndef toupper
550extern int toupper __P((int));
551#  endif /* toupper */
552#  ifndef tolower
553extern int tolower __P((int));
554#  endif /* tolower */
555extern caddr_t sbrk __P((int));
556#  if SYSVREL == 0 && !defined(__lucid)
557extern int qsort();
558#  endif /* SYSVREL == 0 && !__lucid */
559# else /* !SUNOS4 */
560#  ifndef WINNT_NATIVE
561#   ifndef hpux
562#    if __GNUC__ != 2
563extern int abort();
564#    endif /* __GNUC__ != 2 */
565#    ifndef fps500
566extern int qsort();
567#    endif /* !fps500 */
568#   else /* !hpux */
569extern void abort();
570extern void qsort();
571#   endif /* hpux */
572#  endif /* !WINNT_NATIVE */
573# endif	/* SUNOS4 */
574#ifndef _CX_UX
575extern void perror();
576#endif
577
578# ifdef BSDSIGS
579#  if defined(_AIX370) || defined(MACH) || defined(NeXT) || defined(_AIXPS2) || defined(ardent) || defined(SUNOS4) || defined(HPBSD) || defined(__MACHTEN__)
580extern int sigvec();
581extern int sigpause();
582#  else	/* !(_AIX370 || MACH || NeXT || _AIXPS2 || ardent || SUNOS4 || HPBSD) */
583#   if (!defined(apollo) || !defined(__STDC__)) && !defined(__DGUX__) && !defined(fps500)
584extern sigret_t sigvec();
585#ifndef _CX_UX
586extern void sigpause();
587#endif /* _CX_UX */
588#   endif /* (!apollo || !__STDC__) && !__DGUX__ && !fps500 */
589#  endif /* _AIX370 || MACH || NeXT || _AIXPS2 || ardent || SUNOS4 || HPBSD */
590extern sigmask_t sigblock();
591extern sigmask_t sigsetmask();
592# endif	/* BSDSIGS */
593
594# ifndef killpg
595extern int killpg();
596# endif	/* killpg */
597
598# ifndef lstat
599extern int lstat();
600# endif	/* lstat */
601
602# ifdef BSD
603extern uid_t getuid(), geteuid();
604extern gid_t getgid(), getegid();
605# endif /* BSD */
606
607# ifdef SYSMALLOC
608extern memalign_t malloc();
609extern memalign_t realloc();
610extern memalign_t calloc();
611extern void free();
612# endif	/* SYSMALLOC */
613
614# ifdef BSDTIMES
615extern int getrlimit();
616extern int setrlimit();
617extern int getrusage();
618extern int gettimeofday();
619# endif	/* BSDTIMES */
620
621# if defined(NLS) && !defined(NOSTRCOLL) && !defined(NeXT)
622extern int strcoll();
623# endif /* NLS && !NOSTRCOLL && !NeXT */
624
625# ifdef BSDJOBS
626#  ifdef BSDTIMES
627#   ifdef __MACHTEN__
628extern pid_t wait3();
629#   else
630#   ifndef HPBSD
631extern int wait3();
632#   endif /* HPBSD */
633#   endif /* __MACHTEN__ */
634#  else	/* !BSDTIMES */
635#   if !defined(POSIXJOBS) && !defined(_SEQUENT_)
636extern int wait3();
637#   else /* POSIXJOBS || _SEQUENT_ */
638extern int waitpid();
639#   endif /* POSIXJOBS || _SEQUENT_ */
640#  endif /* BSDTIMES */
641# else /* !BSDJOBS */
642#  if SYSVREL < 3
643extern int ourwait();
644#  else	/* SYSVREL >= 3 */
645extern int wait();
646#  endif /* SYSVREL < 3 */
647# endif	/* BSDJOBS */
648
649# ifdef BSDNICE
650extern int setpriority();
651# else /* !BSDNICE */
652extern int nice();
653# endif	/* BSDNICE */
654
655# if (!defined(fps500) && !defined(apollo) && !defined(__lucid) && !defined(HPBSD) && !defined(DECOSF1))
656extern void setpwent();
657extern void endpwent();
658# endif /* !fps500 && !apollo && !__lucid && !HPBSD && !DECOSF1 */
659
660# ifndef __STDC__
661extern struct passwd *getpwuid(), *getpwnam(), *getpwent();
662#  ifdef PW_SHADOW
663extern struct spwd *getspnam(), *getspent();
664#  endif /* PW_SHADOW */
665#  ifdef PW_AUTH
666extern struct authorization *getauthuid();
667#  endif /* PW_AUTH */
668# endif /* __STDC__ */
669
670# ifndef getcwd
671extern char *getcwd();
672# endif	/* getcwd */
673
674#else /* POSIX || !SUNOS4 || !UTekV || !sysV88 */
675
676# if (defined(SUNOS4) && !defined(__GNUC__)) || defined(_IBMR2) || defined(_IBMESA)
677extern char *getvwd();
678# endif	/* (SUNOS4 && ! __GNUC__) || _IBMR2 || _IBMESA */
679
680# ifdef SCO
681extern char *ttyname();
682# endif /* SCO */
683
684# ifdef __clipper__
685extern char *ttyname();
686# endif /* __clipper__ */
687
688#endif /* !POSIX || SUNOS4 || UTekV || sysV88 */
689
690#if defined(SUNOS4) && __GNUC__ == 2
691/*
692 * Somehow these are missing
693 */
694extern int ioctl __P((int, int, ...));
695extern int readlink __P((const char *, char *, size_t));
696extern void setgrent __P((void));
697extern void endgrent __P((void));
698# ifdef REMOTEHOST
699#  ifndef _SOCKLEN_T	/* Avoid Solaris 2.7 bogosity. */
700struct sockaddr;
701extern int getpeername __P((int, struct sockaddr *, int *));
702#  endif /* _SOCKLEN_T */
703# endif /* REMOTEHOST */
704#endif /* SUNOS4 && __GNUC__ == 2 */
705
706#if (defined(BSD) && !defined(BSD4_4)) || defined(SUNOS4)
707# if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
708extern void bcopy	__P((const void *, void *, size_t));
709#  define memmove(a, b, c) (bcopy((char *) (b), (char *) (a), (int) (c)), a)
710# endif /* __alpha && __osf__ && DECOSF1 < 200 */
711#endif /* (BSD && !BSD4_4) || SUNOS4 */
712
713#if !defined(hpux) && !defined(COHERENT) && ((SYSVREL < 4) || defined(_SEQUENT_)) && !defined(BSD4_4) && !defined(memmove)
714# define NEEDmemmove
715#endif /* !hpux && !COHERENT && (SYSVREL < 4 || _SEQUENT_) && !BSD4_4 && !memmove */
716
717#if defined(UTek) || defined(pyr)
718# define NEEDmemset
719#else /* !UTek && !pyr */
720# ifdef SUNOS4
721#  include <memory.h>	/* memset should be declared in <string.h> but isn't */
722# endif /* SUNOS4 */
723#endif /* UTek || pyr */
724
725#if SYSVREL == 4
726# ifdef REMOTEHOST
727/* Irix6 defines getpeername(int, void *, int *) which conflicts with
728   the definition below. */
729#  if !defined(__sgi) && !defined(_OSD_POSIX) && !defined(__MVS__)
730#   ifndef _SOCKLEN_T	/* Avoid Solaris 2.7 bogosity. */
731struct sockaddr;
732extern int getpeername __P((int, struct sockaddr *, int *));
733#   endif /* _SOCKLEN_T */
734#  endif /* !__sgi && !_OSD_POSIX && !__MVS__ */
735# endif /* REMOTEHOST */
736# ifndef BSDTIMES
737extern int getrlimit __P((int, struct rlimit *));
738extern int setrlimit __P((int, const struct rlimit *));
739# endif /* !BSDTIMES */
740# if !defined(IRIS4D) && !defined(SOLARIS2)
741extern int wait3();	/* I think some bizarre systems still need this */
742# endif /* !IRIS4D && !SOLARIS2 */
743# if defined(SOLARIS2)
744#  undef NEEDstrerror
745extern char *strerror __P((int));
746# endif /* SOLARIS2 */
747#endif /* SYSVREL == 4 */
748
749#if defined(__alpha) && defined(__osf__) && DECOSF1 < 200
750/* These are ok for 1.3, but conflict with the header files for 2.0 */
751extern int gethostname __P((char *, int));
752extern char *sbrk __P((ssize_t));
753extern int ioctl __P((int, unsigned long, char *));
754extern pid_t vfork __P((void));
755extern int killpg __P((pid_t, int));
756#endif /* __osf__ && __alpha && DECOSF1 < 200 */
757
758#endif /* _h_tc_os */
759