unistd_h.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. # unistd_h.m4 serial 90
  2. dnl Copyright (C) 2006-2023 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl Written by Simon Josefsson, Bruno Haible.
  7. AC_DEFUN_ONCE([gl_UNISTD_H],
  8. [
  9. dnl Ensure to expand the default settings once only, before all statements
  10. dnl that occur in other macros.
  11. AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
  12. gl_CHECK_NEXT_HEADERS([unistd.h])
  13. if test $ac_cv_header_unistd_h = yes; then
  14. HAVE_UNISTD_H=1
  15. else
  16. HAVE_UNISTD_H=0
  17. fi
  18. AC_SUBST([HAVE_UNISTD_H])
  19. dnl Ensure the type pid_t gets defined.
  20. AC_REQUIRE([AC_TYPE_PID_T])
  21. dnl Determine WINDOWS_64_BIT_OFF_T.
  22. AC_REQUIRE([gl_TYPE_OFF_T])
  23. dnl Check for declarations of anything we want to poison if the
  24. dnl corresponding gnulib module is not in use.
  25. gl_WARN_ON_USE_PREPARE([[
  26. #if HAVE_UNISTD_H
  27. # include <unistd.h>
  28. #endif
  29. /* Some systems declare various items in the wrong headers. */
  30. #if !(defined __GLIBC__ && !defined __UCLIBC__)
  31. # include <fcntl.h>
  32. # include <stdio.h>
  33. # include <stdlib.h>
  34. # if defined _WIN32 && ! defined __CYGWIN__
  35. # include <io.h>
  36. # endif
  37. #endif
  38. ]], [access chdir chown copy_file_range dup dup2 dup3 environ euidaccess
  39. execl execle execlp execv execve execvp execvpe
  40. faccessat fchdir
  41. fchownat fdatasync fsync ftruncate getcwd getdomainname getdtablesize
  42. getentropy getgroups gethostname getlogin getlogin_r getpagesize getpass
  43. getusershell setusershell endusershell
  44. group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
  45. readlink readlinkat rmdir sethostname sleep symlink symlinkat
  46. truncate ttyname_r unlink unlinkat usleep])
  47. AC_REQUIRE([AC_C_RESTRICT])
  48. AC_CHECK_DECLS_ONCE([execvpe])
  49. if test $ac_cv_have_decl_execvpe = no; then
  50. HAVE_DECL_EXECVPE=0
  51. fi
  52. ])
  53. # gl_UNISTD_MODULE_INDICATOR([modulename])
  54. # sets the shell variable that indicates the presence of the given module
  55. # to a C preprocessor expression that will evaluate to 1.
  56. # This macro invocation must not occur in macros that are AC_REQUIREd.
  57. AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
  58. [
  59. dnl Ensure to expand the default settings once only.
  60. gl_UNISTD_H_REQUIRE_DEFAULTS
  61. gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  62. dnl Define it also as a C macro, for the benefit of the unit tests.
  63. gl_MODULE_INDICATOR_FOR_TESTS([$1])
  64. ])
  65. # Initializes the default values for AC_SUBSTed shell variables.
  66. # This macro must not be AC_REQUIREd. It must only be invoked, and only
  67. # outside of macros or in macros that are not AC_REQUIREd.
  68. AC_DEFUN([gl_UNISTD_H_REQUIRE_DEFAULTS],
  69. [
  70. m4_defun(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS], [
  71. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ACCESS])
  72. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHDIR])
  73. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CHOWN])
  74. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CLOSE])
  75. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_COPY_FILE_RANGE])
  76. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP])
  77. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP2])
  78. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_DUP3])
  79. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ENVIRON])
  80. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EUIDACCESS])
  81. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECL])
  82. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLE])
  83. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECLP])
  84. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECV])
  85. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVE])
  86. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVP])
  87. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_EXECVPE])
  88. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FACCESSAT])
  89. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHDIR])
  90. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FCHOWNAT])
  91. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FDATASYNC])
  92. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FSYNC])
  93. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_FTRUNCATE])
  94. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETCWD])
  95. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDOMAINNAME])
  96. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETDTABLESIZE])
  97. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETENTROPY])
  98. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETGROUPS])
  99. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETHOSTNAME])
  100. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN])
  101. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETLOGIN_R])
  102. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETOPT_POSIX])
  103. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPAGESIZE])
  104. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS])
  105. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETPASS_GNU])
  106. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GETUSERSHELL])
  107. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_GROUP_MEMBER])
  108. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_ISATTY])
  109. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LCHOWN])
  110. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINK])
  111. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LINKAT])
  112. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LSEEK])
  113. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE])
  114. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PIPE2])
  115. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PREAD])
  116. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_PWRITE])
  117. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READ])
  118. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINK])
  119. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_READLINKAT])
  120. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_RMDIR])
  121. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SETHOSTNAME])
  122. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SLEEP])
  123. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINK])
  124. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_SYMLINKAT])
  125. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TRUNCATE])
  126. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TTYNAME_R])
  127. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_GETOPT])
  128. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_NONBLOCKING])
  129. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNISTD_H_SIGPIPE])
  130. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINK])
  131. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_UNLINKAT])
  132. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_USLEEP])
  133. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_WRITE])
  134. dnl Support Microsoft deprecated alias function names by default.
  135. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ACCESS], [1])
  136. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CHDIR], [1])
  137. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_CLOSE], [1])
  138. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP], [1])
  139. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_DUP2], [1])
  140. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECL], [1])
  141. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLE], [1])
  142. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECLP], [1])
  143. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECV], [1])
  144. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVE], [1])
  145. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVP], [1])
  146. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_EXECVPE], [1])
  147. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETCWD], [1])
  148. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_GETPID], [1])
  149. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_ISATTY], [1])
  150. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_LSEEK], [1])
  151. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_READ], [1])
  152. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_RMDIR], [1])
  153. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_SWAB], [1])
  154. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_UNLINK], [1])
  155. gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_WRITE], [1])
  156. ])
  157. m4_require(GL_MODULE_INDICATOR_PREFIX[_UNISTD_H_MODULE_INDICATOR_DEFAULTS])
  158. AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
  159. ])
  160. AC_DEFUN([gl_UNISTD_H_DEFAULTS],
  161. [
  162. dnl Assume proper GNU behavior unless another module says otherwise.
  163. HAVE_CHOWN=1; AC_SUBST([HAVE_CHOWN])
  164. HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE])
  165. HAVE_DUP3=1; AC_SUBST([HAVE_DUP3])
  166. HAVE_EUIDACCESS=1; AC_SUBST([HAVE_EUIDACCESS])
  167. HAVE_EXECVPE=1; AC_SUBST([HAVE_EXECVPE])
  168. HAVE_FACCESSAT=1; AC_SUBST([HAVE_FACCESSAT])
  169. HAVE_FCHDIR=1; AC_SUBST([HAVE_FCHDIR])
  170. HAVE_FCHOWNAT=1; AC_SUBST([HAVE_FCHOWNAT])
  171. HAVE_FDATASYNC=1; AC_SUBST([HAVE_FDATASYNC])
  172. HAVE_FSYNC=1; AC_SUBST([HAVE_FSYNC])
  173. HAVE_FTRUNCATE=1; AC_SUBST([HAVE_FTRUNCATE])
  174. HAVE_GETDTABLESIZE=1; AC_SUBST([HAVE_GETDTABLESIZE])
  175. HAVE_GETENTROPY=1; AC_SUBST([HAVE_GETENTROPY])
  176. HAVE_GETGROUPS=1; AC_SUBST([HAVE_GETGROUPS])
  177. HAVE_GETHOSTNAME=1; AC_SUBST([HAVE_GETHOSTNAME])
  178. HAVE_GETLOGIN=1; AC_SUBST([HAVE_GETLOGIN])
  179. HAVE_GETPAGESIZE=1; AC_SUBST([HAVE_GETPAGESIZE])
  180. HAVE_GETPASS=1; AC_SUBST([HAVE_GETPASS])
  181. HAVE_GROUP_MEMBER=1; AC_SUBST([HAVE_GROUP_MEMBER])
  182. HAVE_LCHOWN=1; AC_SUBST([HAVE_LCHOWN])
  183. HAVE_LINK=1; AC_SUBST([HAVE_LINK])
  184. HAVE_LINKAT=1; AC_SUBST([HAVE_LINKAT])
  185. HAVE_PIPE=1; AC_SUBST([HAVE_PIPE])
  186. HAVE_PIPE2=1; AC_SUBST([HAVE_PIPE2])
  187. HAVE_PREAD=1; AC_SUBST([HAVE_PREAD])
  188. HAVE_PWRITE=1; AC_SUBST([HAVE_PWRITE])
  189. HAVE_READLINK=1; AC_SUBST([HAVE_READLINK])
  190. HAVE_READLINKAT=1; AC_SUBST([HAVE_READLINKAT])
  191. HAVE_SETHOSTNAME=1; AC_SUBST([HAVE_SETHOSTNAME])
  192. HAVE_SLEEP=1; AC_SUBST([HAVE_SLEEP])
  193. HAVE_SYMLINK=1; AC_SUBST([HAVE_SYMLINK])
  194. HAVE_SYMLINKAT=1; AC_SUBST([HAVE_SYMLINKAT])
  195. HAVE_UNLINKAT=1; AC_SUBST([HAVE_UNLINKAT])
  196. HAVE_USLEEP=1; AC_SUBST([HAVE_USLEEP])
  197. HAVE_DECL_ENVIRON=1; AC_SUBST([HAVE_DECL_ENVIRON])
  198. HAVE_DECL_EXECVPE=1; AC_SUBST([HAVE_DECL_EXECVPE])
  199. HAVE_DECL_FCHDIR=1; AC_SUBST([HAVE_DECL_FCHDIR])
  200. HAVE_DECL_FDATASYNC=1; AC_SUBST([HAVE_DECL_FDATASYNC])
  201. HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
  202. HAVE_DECL_GETLOGIN=1; AC_SUBST([HAVE_DECL_GETLOGIN])
  203. HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
  204. HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
  205. HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
  206. HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
  207. HAVE_DECL_TRUNCATE=1; AC_SUBST([HAVE_DECL_TRUNCATE])
  208. HAVE_DECL_TTYNAME_R=1; AC_SUBST([HAVE_DECL_TTYNAME_R])
  209. HAVE_OS_H=0; AC_SUBST([HAVE_OS_H])
  210. HAVE_SYS_PARAM_H=0; AC_SUBST([HAVE_SYS_PARAM_H])
  211. REPLACE_ACCESS=0; AC_SUBST([REPLACE_ACCESS])
  212. REPLACE_CHOWN=0; AC_SUBST([REPLACE_CHOWN])
  213. REPLACE_CLOSE=0; AC_SUBST([REPLACE_CLOSE])
  214. REPLACE_COPY_FILE_RANGE=0; AC_SUBST([REPLACE_COPY_FILE_RANGE])
  215. REPLACE_DUP=0; AC_SUBST([REPLACE_DUP])
  216. REPLACE_DUP2=0; AC_SUBST([REPLACE_DUP2])
  217. REPLACE_EXECL=0; AC_SUBST([REPLACE_EXECL])
  218. REPLACE_EXECLE=0; AC_SUBST([REPLACE_EXECLE])
  219. REPLACE_EXECLP=0; AC_SUBST([REPLACE_EXECLP])
  220. REPLACE_EXECV=0; AC_SUBST([REPLACE_EXECV])
  221. REPLACE_EXECVE=0; AC_SUBST([REPLACE_EXECVE])
  222. REPLACE_EXECVP=0; AC_SUBST([REPLACE_EXECVP])
  223. REPLACE_EXECVPE=0; AC_SUBST([REPLACE_EXECVPE])
  224. REPLACE_FACCESSAT=0; AC_SUBST([REPLACE_FACCESSAT])
  225. REPLACE_FCHOWNAT=0; AC_SUBST([REPLACE_FCHOWNAT])
  226. REPLACE_FTRUNCATE=0; AC_SUBST([REPLACE_FTRUNCATE])
  227. REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD])
  228. REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
  229. REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
  230. REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R])
  231. REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS])
  232. REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE])
  233. REPLACE_GETPASS=0; AC_SUBST([REPLACE_GETPASS])
  234. REPLACE_GETPASS_FOR_GETPASS_GNU=0; AC_SUBST([REPLACE_GETPASS_FOR_GETPASS_GNU])
  235. REPLACE_ISATTY=0; AC_SUBST([REPLACE_ISATTY])
  236. REPLACE_LCHOWN=0; AC_SUBST([REPLACE_LCHOWN])
  237. REPLACE_LINK=0; AC_SUBST([REPLACE_LINK])
  238. REPLACE_LINKAT=0; AC_SUBST([REPLACE_LINKAT])
  239. REPLACE_LSEEK=0; AC_SUBST([REPLACE_LSEEK])
  240. REPLACE_PREAD=0; AC_SUBST([REPLACE_PREAD])
  241. REPLACE_PWRITE=0; AC_SUBST([REPLACE_PWRITE])
  242. REPLACE_READ=0; AC_SUBST([REPLACE_READ])
  243. REPLACE_READLINK=0; AC_SUBST([REPLACE_READLINK])
  244. REPLACE_READLINKAT=0; AC_SUBST([REPLACE_READLINKAT])
  245. REPLACE_RMDIR=0; AC_SUBST([REPLACE_RMDIR])
  246. REPLACE_SLEEP=0; AC_SUBST([REPLACE_SLEEP])
  247. REPLACE_SYMLINK=0; AC_SUBST([REPLACE_SYMLINK])
  248. REPLACE_SYMLINKAT=0; AC_SUBST([REPLACE_SYMLINKAT])
  249. REPLACE_TRUNCATE=0; AC_SUBST([REPLACE_TRUNCATE])
  250. REPLACE_TTYNAME_R=0; AC_SUBST([REPLACE_TTYNAME_R])
  251. REPLACE_UNLINK=0; AC_SUBST([REPLACE_UNLINK])
  252. REPLACE_UNLINKAT=0; AC_SUBST([REPLACE_UNLINKAT])
  253. REPLACE_USLEEP=0; AC_SUBST([REPLACE_USLEEP])
  254. REPLACE_WRITE=0; AC_SUBST([REPLACE_WRITE])
  255. UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H])
  256. UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
  257. UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
  258. AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
  259. ])