1 /*
2  * Copyright (c) 1995  Colin Plumb.  All rights reserved.
3  * For licensing and other legal details, see the file legal.c.
4  *
5  * This file includes <unistd.h>, if it's available, and
6  * declares a bunch of functions with "traditional" values if not.
7  * The GNU Libc Manual (node "Version Supported") says this is impossible;
8  * I wonder what they think of this.
9  */
10 
11 #include <limits.h>
12 
13 /*
14  * See if this is a POSIX <limits.h>.  A POSIX system *may* define
15  * a macro for ARG_MAX, but it may instead defined _SC_ARG_MAX
16  * in <unistd.h> and require you yo use sysconf() to get the value.
17  * However, a POSIX system is supposed to defined _POSIX_ARG_MAX
18  * in <limits.h> with the value of 4096, the POSIX-mandated lower
19  * bound on ARG_MAX or sysconf(_SC_ARG_MAX).
20  * A POSIX system is supposed to define most of these, so checking for
21  * them *all* is overkill, but it's easy enough...
22  */
23 #ifndef HAVE_UNISTD_H
24 #ifdef __POSIX__	/* Defined by GCC on POSIX systems */
25 #define HAVE_UNISTD_H 1
26 #elif defined(_POSIX_ARG_MAX) || defined(_POSIX_CHILD_MAX)
27 #define HAVE_UNISTD_H 1
28 #elif defined(_POSIX_LINK_MAX) || defined(_POSIX_MAX_CANON)
29 #define HAVE_UNISTD_H 1
30 #elif defined(_POSIX_MAX_INPUT) || defined(_POSIX_NAME_MAX)
31 #define HAVE_UNISTD_H 1
32 #elif defined(_POSIX_NGROUPS_MAX) || defined(_POSIX_OPEN_MAX)
33 #define HAVE_UNISTD_H 1
34 #elif defined(_POSIX_PATH_MAX) || defined(_POSIX_PIPE_BUF)
35 #define HAVE_UNISTD_H 1
36 #elif defined(_POSIX_RE_DUP_MAX) || defined(_POSIX_SSIZE_MAX)
37 #define HAVE_UNISTD_H 1
38 #elif defined(_POSIX_STREAM_MAX) || defined (_POSIX_TZNAME_MAX)
39 #define HAVE_UNISTD_H 1
40 #endif
41 #endif
42 
43 #if HAVE_UNISTD_H
44 #include <unistd.h>
45 #elif defined(MSDOS)
46 #include <io.h>	/* Where MSDOS keeps such things */
47 #else
48 /* Not POSIX - declare the portions of <unistd.h> we need manually. */
49 int ioctl(int fd, int request, void *arg);
50 int isatty(int fd);
51 int read(int fd, void *buf, int nbytes);
52 unsigned sleep(unsigned seconds);
53 #endif
54