posix.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include <limits.h>
  11. /*
  12. * See if this is a POSIX <limits.h>. A POSIX system *may* define
  13. * a macro for ARG_MAX, but it may instead defined _SC_ARG_MAX
  14. * in <unistd.h> and require you yo use sysconf() to get the value.
  15. * However, a POSIX system is supposed to defined _POSIX_ARG_MAX
  16. * in <limits.h> with the value of 4096, the POSIX-mandated lower
  17. * bound on ARG_MAX or sysconf(_SC_ARG_MAX).
  18. * A POSIX system is supposed to define most of these, so checking for
  19. * them *all* is overkill, but it's easy enough...
  20. */
  21. #ifndef HAVE_UNISTD_H
  22. #ifdef __POSIX__ /* Defined by GCC on POSIX systems */
  23. #define HAVE_UNISTD_H 1
  24. #elif defined(_POSIX_ARG_MAX) || defined(_POSIX_CHILD_MAX)
  25. #define HAVE_UNISTD_H 1
  26. #elif defined(_POSIX_LINK_MAX) || defined(_POSIX_MAX_CANON)
  27. #define HAVE_UNISTD_H 1
  28. #elif defined(_POSIX_MAX_INPUT) || defined(_POSIX_NAME_MAX)
  29. #define HAVE_UNISTD_H 1
  30. #elif defined(_POSIX_NGROUPS_MAX) || defined(_POSIX_OPEN_MAX)
  31. #define HAVE_UNISTD_H 1
  32. #elif defined(_POSIX_PATH_MAX) || defined(_POSIX_PIPE_BUF)
  33. #define HAVE_UNISTD_H 1
  34. #elif defined(_POSIX_RE_DUP_MAX) || defined(_POSIX_SSIZE_MAX)
  35. #define HAVE_UNISTD_H 1
  36. #elif defined(_POSIX_STREAM_MAX) || defined (_POSIX_TZNAME_MAX)
  37. #define HAVE_UNISTD_H 1
  38. #endif
  39. #endif
  40. #if HAVE_UNISTD_H
  41. #include <unistd.h>
  42. #elif defined(MSDOS)
  43. #include <io.h> /* Where MSDOS keeps such things */
  44. #else
  45. /* Not POSIX - declare the portions of <unistd.h> we need manually. */
  46. int ioctl(int fd, int request, void *arg);
  47. int isatty(int fd);
  48. int read(int fd, void *buf, int nbytes);
  49. unsigned sleep(unsigned seconds);
  50. #endif