port.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* Portability declarations. Requires sys/types.h.
  2. Copyright (C) 1988, 1992 Free Software Foundation
  3. This file is part of GNU Tar.
  4. GNU Tar is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Tar is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Tar; see the file COPYING. If not, write to
  14. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  15. /* AIX requires this to be the first thing in the file. */
  16. #ifdef __GNUC__
  17. #define alloca __builtin_alloca
  18. #else /* not __GNUC__ */
  19. #if HAVE_ALLOCA_H
  20. #include <alloca.h>
  21. #else /* not HAVE_ALLOCA_H */
  22. #ifdef _AIX
  23. #pragma alloca
  24. #else /* not _AIX */
  25. char *alloca ();
  26. #endif /* not _AIX */
  27. #endif /* not HAVE_ALLOCA_H */
  28. #endif /* not __GNUC__ */
  29. #include "pathmax.h"
  30. #ifdef _POSIX_VERSION
  31. #include <sys/wait.h>
  32. #else /* !_POSIX_VERSION */
  33. #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f)
  34. #define WIFSIGNALED(w) (((w) & 0xff) != 0x7f && ((w) & 0xff) != 0)
  35. #define WIFEXITED(w) (((w) & 0xff) == 0)
  36. #define WSTOPSIG(w) (((w) >> 8) & 0xff)
  37. #define WTERMSIG(w) ((w) & 0x7f)
  38. #define WEXITSTATUS(w) (((w) >> 8) & 0xff)
  39. #endif /* _POSIX_VERSION */
  40. /* nonstandard */
  41. #ifndef WIFCOREDUMPED
  42. #define WIFCOREDUMPED(w) (((w) & 0x80) != 0)
  43. #endif
  44. #ifdef __MSDOS__
  45. /* missing things from sys/stat.h */
  46. #define S_ISUID 0
  47. #define S_ISGID 0
  48. #define S_ISVTX 0
  49. /* device stuff */
  50. #define makedev(ma, mi) ((ma << 8) | mi)
  51. #define major(dev) (dev)
  52. #define minor(dev) (dev)
  53. typedef long off_t;
  54. #endif /* __MSDOS__ */
  55. #if defined(__STDC__) || defined(__TURBOC__)
  56. #define PTR void *
  57. #else
  58. #define PTR char *
  59. #define const
  60. #endif
  61. /* Since major is a function on SVR4, we can't just use `ifndef major'. */
  62. #ifdef major /* Might be defined in sys/types.h. */
  63. #define HAVE_MAJOR
  64. #endif
  65. #if !defined(HAVE_MAJOR) && defined(MAJOR_IN_MKDEV)
  66. #include <sys/mkdev.h>
  67. #define HAVE_MAJOR
  68. #endif
  69. #if !defined(HAVE_MAJOR) && defined(MAJOR_IN_SYSMACROS)
  70. #include <sys/sysmacros.h>
  71. #define HAVE_MAJOR
  72. #endif
  73. #ifndef HAVE_MAJOR
  74. #define major(dev) (((dev) >> 8) & 0xff)
  75. #define minor(dev) ((dev) & 0xff)
  76. #define makedev(maj, min) (((maj) << 8) | (min))
  77. #endif
  78. #undef HAVE_MAJOR
  79. #if defined(STDC_HEADERS) || defined(USG)
  80. #include <string.h>
  81. #if !defined(__MSDOS__) && !defined(STDC_HEADERS)
  82. #include <memory.h>
  83. #endif
  84. #define index strchr
  85. #define rindex strrchr
  86. #define bcopy(s, d, n) memcpy(d, s, n)
  87. #define bzero(s, n) memset(s, 0, n)
  88. #define bcmp memcmp
  89. #else
  90. #include <strings.h>
  91. #endif
  92. #if defined(STDC_HEADERS)
  93. #include <stdlib.h>
  94. #else
  95. char *malloc(), *realloc();
  96. char *getenv();
  97. #endif
  98. #ifndef _POSIX_VERSION
  99. #ifdef __MSDOS__
  100. #include <io.h>
  101. #else /* !__MSDOS__ */
  102. off_t lseek();
  103. #endif /* !__MSDOS__ */
  104. char *getcwd();
  105. #endif /* !_POSIX_VERSION */
  106. #ifndef NULL
  107. #define NULL 0
  108. #endif
  109. #ifndef O_BINARY
  110. #define O_BINARY 0
  111. #endif
  112. #ifndef O_CREAT
  113. #define O_CREAT 0
  114. #endif
  115. #ifndef O_NDELAY
  116. #define O_NDELAY 0
  117. #endif
  118. #ifndef O_RDONLY
  119. #define O_RDONLY 0
  120. #endif
  121. #ifndef O_RDWR
  122. #define O_RDWR 2
  123. #endif
  124. #include <sys/stat.h>
  125. #ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */
  126. #define mode_t unsigned short
  127. #endif
  128. #if !defined(S_ISBLK) && defined(S_IFBLK)
  129. #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
  130. #endif
  131. #if !defined(S_ISCHR) && defined(S_IFCHR)
  132. #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
  133. #endif
  134. #if !defined(S_ISDIR) && defined(S_IFDIR)
  135. #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  136. #endif
  137. #if !defined(S_ISREG) && defined(S_IFREG)
  138. #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  139. #endif
  140. #if !defined(S_ISFIFO) && defined(S_IFIFO)
  141. #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
  142. #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0))
  143. #endif
  144. #if !defined(S_ISLNK) && defined(S_IFLNK)
  145. #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
  146. #endif
  147. #if !defined(S_ISSOCK) && defined(S_IFSOCK)
  148. #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
  149. #endif
  150. #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
  151. #define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
  152. #define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
  153. #endif
  154. #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
  155. #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
  156. #endif
  157. #if !defined(S_ISCTG) && defined(S_IFCTG) /* contiguous file */
  158. #define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
  159. #endif
  160. #if !defined(S_ISVTX)
  161. #define S_ISVTX 0001000
  162. #endif