unistd_h.m4 9.86 KB
Newer Older
Paul Eggert's avatar
Paul Eggert committed
1
# unistd_h.m4 serial 81
Paul Eggert's avatar
Paul Eggert committed
2
dnl Copyright (C) 2006-2020 Free Software Foundation, Inc.
Paul Eggert's avatar
Paul Eggert committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.

dnl Written by Simon Josefsson, Bruno Haible.

AC_DEFUN([gl_UNISTD_H],
[
  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
  dnl once only, before all statements that occur in other macros.
  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])

  gl_CHECK_NEXT_HEADERS([unistd.h])
  if test $ac_cv_header_unistd_h = yes; then
    HAVE_UNISTD_H=1
  else
    HAVE_UNISTD_H=0
  fi
  AC_SUBST([HAVE_UNISTD_H])

23 24 25
  dnl Ensure the type pid_t gets defined.
  AC_REQUIRE([AC_TYPE_PID_T])

Paul Eggert's avatar
Paul Eggert committed
26 27 28
  dnl Determine WINDOWS_64_BIT_OFF_T.
  AC_REQUIRE([gl_TYPE_OFF_T])

Paul Eggert's avatar
Paul Eggert committed
29 30
  dnl Check for declarations of anything we want to poison if the
  dnl corresponding gnulib module is not in use.
31 32 33 34
  gl_WARN_ON_USE_PREPARE([[
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
Paul Eggert's avatar
Paul Eggert committed
35 36 37 38 39
/* Some systems declare various items in the wrong headers.  */
#if !(defined __GLIBC__ && !defined __UCLIBC__)
# include <fcntl.h>
# include <stdio.h>
# include <stdlib.h>
Paul Eggert's avatar
Paul Eggert committed
40
# if defined _WIN32 && ! defined __CYGWIN__
Paul Eggert's avatar
Paul Eggert committed
41 42 43
#  include <io.h>
# endif
#endif
Paul Eggert's avatar
Paul Eggert committed
44 45
    ]], [access chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir
    fchownat fdatasync fsync ftruncate getcwd getdomainname getdtablesize
Paul Eggert's avatar
Paul Eggert committed
46
    getentropy getgroups gethostname getlogin getlogin_r getpagesize getpass
Paul Eggert's avatar
Paul Eggert committed
47 48
    getusershell setusershell endusershell
    group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
Paul Eggert's avatar
Paul Eggert committed
49 50
    readlink readlinkat rmdir sethostname sleep symlink symlinkat
    truncate ttyname_r unlink unlinkat usleep])
Paul Eggert's avatar
Paul Eggert committed
51 52

  AC_REQUIRE([AC_C_RESTRICT])
Paul Eggert's avatar
Paul Eggert committed
53 54 55 56 57 58 59 60 61 62 63 64 65
])

AC_DEFUN([gl_UNISTD_MODULE_INDICATOR],
[
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
  dnl Define it also as a C macro, for the benefit of the unit tests.
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
])

AC_DEFUN([gl_UNISTD_H_DEFAULTS],
[
Paul Eggert's avatar
Paul Eggert committed
66
  GNULIB_ACCESS=0;               AC_SUBST([GNULIB_ACCESS])
67
  GNULIB_CHDIR=0;                AC_SUBST([GNULIB_CHDIR])
Paul Eggert's avatar
Paul Eggert committed
68 69
  GNULIB_CHOWN=0;                AC_SUBST([GNULIB_CHOWN])
  GNULIB_CLOSE=0;                AC_SUBST([GNULIB_CLOSE])
Paul Eggert's avatar
Paul Eggert committed
70
  GNULIB_COPY_FILE_RANGE=0;      AC_SUBST([GNULIB_COPY_FILE_RANGE])
71
  GNULIB_DUP=0;                  AC_SUBST([GNULIB_DUP])
Paul Eggert's avatar
Paul Eggert committed
72 73 74 75 76 77 78
  GNULIB_DUP2=0;                 AC_SUBST([GNULIB_DUP2])
  GNULIB_DUP3=0;                 AC_SUBST([GNULIB_DUP3])
  GNULIB_ENVIRON=0;              AC_SUBST([GNULIB_ENVIRON])
  GNULIB_EUIDACCESS=0;           AC_SUBST([GNULIB_EUIDACCESS])
  GNULIB_FACCESSAT=0;            AC_SUBST([GNULIB_FACCESSAT])
  GNULIB_FCHDIR=0;               AC_SUBST([GNULIB_FCHDIR])
  GNULIB_FCHOWNAT=0;             AC_SUBST([GNULIB_FCHOWNAT])
79
  GNULIB_FDATASYNC=0;            AC_SUBST([GNULIB_FDATASYNC])
Paul Eggert's avatar
Paul Eggert committed
80 81 82 83 84
  GNULIB_FSYNC=0;                AC_SUBST([GNULIB_FSYNC])
  GNULIB_FTRUNCATE=0;            AC_SUBST([GNULIB_FTRUNCATE])
  GNULIB_GETCWD=0;               AC_SUBST([GNULIB_GETCWD])
  GNULIB_GETDOMAINNAME=0;        AC_SUBST([GNULIB_GETDOMAINNAME])
  GNULIB_GETDTABLESIZE=0;        AC_SUBST([GNULIB_GETDTABLESIZE])
Paul Eggert's avatar
Paul Eggert committed
85
  GNULIB_GETENTROPY=0;           AC_SUBST([GNULIB_GETENTROPY])
Paul Eggert's avatar
Paul Eggert committed
86 87 88 89
  GNULIB_GETGROUPS=0;            AC_SUBST([GNULIB_GETGROUPS])
  GNULIB_GETHOSTNAME=0;          AC_SUBST([GNULIB_GETHOSTNAME])
  GNULIB_GETLOGIN=0;             AC_SUBST([GNULIB_GETLOGIN])
  GNULIB_GETLOGIN_R=0;           AC_SUBST([GNULIB_GETLOGIN_R])
Paul Eggert's avatar
Paul Eggert committed
90
  GNULIB_GETOPT_POSIX=0;         AC_SUBST([GNULIB_GETOPT_POSIX])
Paul Eggert's avatar
Paul Eggert committed
91
  GNULIB_GETPAGESIZE=0;          AC_SUBST([GNULIB_GETPAGESIZE])
Paul Eggert's avatar
Paul Eggert committed
92
  GNULIB_GETPASS=0;              AC_SUBST([GNULIB_GETPASS])
Paul Eggert's avatar
Paul Eggert committed
93
  GNULIB_GETUSERSHELL=0;         AC_SUBST([GNULIB_GETUSERSHELL])
Paul Eggert's avatar
Paul Eggert committed
94
  GNULIB_GROUP_MEMBER=0;         AC_SUBST([GNULIB_GROUP_MEMBER])
Paul Eggert's avatar
Paul Eggert committed
95
  GNULIB_ISATTY=0;               AC_SUBST([GNULIB_ISATTY])
Paul Eggert's avatar
Paul Eggert committed
96 97 98 99 100 101 102 103 104 105 106 107
  GNULIB_LCHOWN=0;               AC_SUBST([GNULIB_LCHOWN])
  GNULIB_LINK=0;                 AC_SUBST([GNULIB_LINK])
  GNULIB_LINKAT=0;               AC_SUBST([GNULIB_LINKAT])
  GNULIB_LSEEK=0;                AC_SUBST([GNULIB_LSEEK])
  GNULIB_PIPE=0;                 AC_SUBST([GNULIB_PIPE])
  GNULIB_PIPE2=0;                AC_SUBST([GNULIB_PIPE2])
  GNULIB_PREAD=0;                AC_SUBST([GNULIB_PREAD])
  GNULIB_PWRITE=0;               AC_SUBST([GNULIB_PWRITE])
  GNULIB_READ=0;                 AC_SUBST([GNULIB_READ])
  GNULIB_READLINK=0;             AC_SUBST([GNULIB_READLINK])
  GNULIB_READLINKAT=0;           AC_SUBST([GNULIB_READLINKAT])
  GNULIB_RMDIR=0;                AC_SUBST([GNULIB_RMDIR])
Paul Eggert's avatar
Paul Eggert committed
108
  GNULIB_SETHOSTNAME=0;          AC_SUBST([GNULIB_SETHOSTNAME])
Paul Eggert's avatar
Paul Eggert committed
109 110 111
  GNULIB_SLEEP=0;                AC_SUBST([GNULIB_SLEEP])
  GNULIB_SYMLINK=0;              AC_SUBST([GNULIB_SYMLINK])
  GNULIB_SYMLINKAT=0;            AC_SUBST([GNULIB_SYMLINKAT])
Paul Eggert's avatar
Paul Eggert committed
112
  GNULIB_TRUNCATE=0;             AC_SUBST([GNULIB_TRUNCATE])
Paul Eggert's avatar
Paul Eggert committed
113 114 115 116 117 118 119
  GNULIB_TTYNAME_R=0;            AC_SUBST([GNULIB_TTYNAME_R])
  GNULIB_UNISTD_H_NONBLOCKING=0; AC_SUBST([GNULIB_UNISTD_H_NONBLOCKING])
  GNULIB_UNISTD_H_SIGPIPE=0;     AC_SUBST([GNULIB_UNISTD_H_SIGPIPE])
  GNULIB_UNLINK=0;               AC_SUBST([GNULIB_UNLINK])
  GNULIB_UNLINKAT=0;             AC_SUBST([GNULIB_UNLINKAT])
  GNULIB_USLEEP=0;               AC_SUBST([GNULIB_USLEEP])
  GNULIB_WRITE=0;                AC_SUBST([GNULIB_WRITE])
Paul Eggert's avatar
Paul Eggert committed
120 121
  dnl Assume proper GNU behavior unless another module says otherwise.
  HAVE_CHOWN=1;           AC_SUBST([HAVE_CHOWN])
Paul Eggert's avatar
Paul Eggert committed
122
  HAVE_COPY_FILE_RANGE=1; AC_SUBST([HAVE_COPY_FILE_RANGE])
Paul Eggert's avatar
Paul Eggert committed
123 124 125 126 127
  HAVE_DUP3=1;            AC_SUBST([HAVE_DUP3])
  HAVE_EUIDACCESS=1;      AC_SUBST([HAVE_EUIDACCESS])
  HAVE_FACCESSAT=1;       AC_SUBST([HAVE_FACCESSAT])
  HAVE_FCHDIR=1;          AC_SUBST([HAVE_FCHDIR])
  HAVE_FCHOWNAT=1;        AC_SUBST([HAVE_FCHOWNAT])
128
  HAVE_FDATASYNC=1;       AC_SUBST([HAVE_FDATASYNC])
Paul Eggert's avatar
Paul Eggert committed
129 130 131
  HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
  HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
  HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
Paul Eggert's avatar
Paul Eggert committed
132
  HAVE_GETENTROPY=1;      AC_SUBST([HAVE_GETENTROPY])
Paul Eggert's avatar
Paul Eggert committed
133 134 135 136
  HAVE_GETGROUPS=1;       AC_SUBST([HAVE_GETGROUPS])
  HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
  HAVE_GETLOGIN=1;        AC_SUBST([HAVE_GETLOGIN])
  HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
Paul Eggert's avatar
Paul Eggert committed
137
  HAVE_GETPASS=1;         AC_SUBST([HAVE_GETPASS])
Paul Eggert's avatar
Paul Eggert committed
138
  HAVE_GROUP_MEMBER=1;    AC_SUBST([HAVE_GROUP_MEMBER])
Paul Eggert's avatar
Paul Eggert committed
139 140 141 142 143 144 145 146 147
  HAVE_LCHOWN=1;          AC_SUBST([HAVE_LCHOWN])
  HAVE_LINK=1;            AC_SUBST([HAVE_LINK])
  HAVE_LINKAT=1;          AC_SUBST([HAVE_LINKAT])
  HAVE_PIPE=1;            AC_SUBST([HAVE_PIPE])
  HAVE_PIPE2=1;           AC_SUBST([HAVE_PIPE2])
  HAVE_PREAD=1;           AC_SUBST([HAVE_PREAD])
  HAVE_PWRITE=1;          AC_SUBST([HAVE_PWRITE])
  HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
  HAVE_READLINKAT=1;      AC_SUBST([HAVE_READLINKAT])
Paul Eggert's avatar
Paul Eggert committed
148
  HAVE_SETHOSTNAME=1;     AC_SUBST([HAVE_SETHOSTNAME])
Paul Eggert's avatar
Paul Eggert committed
149 150 151 152 153 154 155
  HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
  HAVE_SYMLINK=1;         AC_SUBST([HAVE_SYMLINK])
  HAVE_SYMLINKAT=1;       AC_SUBST([HAVE_SYMLINKAT])
  HAVE_UNLINKAT=1;        AC_SUBST([HAVE_UNLINKAT])
  HAVE_USLEEP=1;          AC_SUBST([HAVE_USLEEP])
  HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
  HAVE_DECL_FCHDIR=1;     AC_SUBST([HAVE_DECL_FCHDIR])
156
  HAVE_DECL_FDATASYNC=1;  AC_SUBST([HAVE_DECL_FDATASYNC])
Paul Eggert's avatar
Paul Eggert committed
157
  HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
Paul Eggert's avatar
Paul Eggert committed
158
  HAVE_DECL_GETLOGIN=1;   AC_SUBST([HAVE_DECL_GETLOGIN])
Paul Eggert's avatar
Paul Eggert committed
159 160 161
  HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
  HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
  HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
Paul Eggert's avatar
Paul Eggert committed
162
  HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
Paul Eggert's avatar
Paul Eggert committed
163
  HAVE_DECL_TRUNCATE=1;   AC_SUBST([HAVE_DECL_TRUNCATE])
Paul Eggert's avatar
Paul Eggert committed
164 165 166
  HAVE_DECL_TTYNAME_R=1;  AC_SUBST([HAVE_DECL_TTYNAME_R])
  HAVE_OS_H=0;            AC_SUBST([HAVE_OS_H])
  HAVE_SYS_PARAM_H=0;     AC_SUBST([HAVE_SYS_PARAM_H])
Paul Eggert's avatar
Paul Eggert committed
167
  REPLACE_ACCESS=0;       AC_SUBST([REPLACE_ACCESS])
Paul Eggert's avatar
Paul Eggert committed
168 169 170 171
  REPLACE_CHOWN=0;        AC_SUBST([REPLACE_CHOWN])
  REPLACE_CLOSE=0;        AC_SUBST([REPLACE_CLOSE])
  REPLACE_DUP=0;          AC_SUBST([REPLACE_DUP])
  REPLACE_DUP2=0;         AC_SUBST([REPLACE_DUP2])
Paul Eggert's avatar
Paul Eggert committed
172
  REPLACE_FACCESSAT=0;    AC_SUBST([REPLACE_FACCESSAT])
Paul Eggert's avatar
Paul Eggert committed
173
  REPLACE_FCHOWNAT=0;     AC_SUBST([REPLACE_FCHOWNAT])
Paul Eggert's avatar
Paul Eggert committed
174
  REPLACE_FTRUNCATE=0;    AC_SUBST([REPLACE_FTRUNCATE])
Paul Eggert's avatar
Paul Eggert committed
175 176
  REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
  REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
Paul Eggert's avatar
Paul Eggert committed
177
  REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
Paul Eggert's avatar
Paul Eggert committed
178 179 180
  REPLACE_GETLOGIN_R=0;   AC_SUBST([REPLACE_GETLOGIN_R])
  REPLACE_GETGROUPS=0;    AC_SUBST([REPLACE_GETGROUPS])
  REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
Paul Eggert's avatar
Paul Eggert committed
181
  REPLACE_GETPASS=0;      AC_SUBST([REPLACE_GETPASS])
Paul Eggert's avatar
Paul Eggert committed
182
  REPLACE_ISATTY=0;       AC_SUBST([REPLACE_ISATTY])
Paul Eggert's avatar
Paul Eggert committed
183 184 185 186 187 188
  REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
  REPLACE_LINK=0;         AC_SUBST([REPLACE_LINK])
  REPLACE_LINKAT=0;       AC_SUBST([REPLACE_LINKAT])
  REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
  REPLACE_PREAD=0;        AC_SUBST([REPLACE_PREAD])
  REPLACE_PWRITE=0;       AC_SUBST([REPLACE_PWRITE])
Paul Eggert's avatar
Paul Eggert committed
189
  REPLACE_READ=0;         AC_SUBST([REPLACE_READ])
Paul Eggert's avatar
Paul Eggert committed
190
  REPLACE_READLINK=0;     AC_SUBST([REPLACE_READLINK])
Paul Eggert's avatar
Paul Eggert committed
191
  REPLACE_READLINKAT=0;   AC_SUBST([REPLACE_READLINKAT])
Paul Eggert's avatar
Paul Eggert committed
192 193 194
  REPLACE_RMDIR=0;        AC_SUBST([REPLACE_RMDIR])
  REPLACE_SLEEP=0;        AC_SUBST([REPLACE_SLEEP])
  REPLACE_SYMLINK=0;      AC_SUBST([REPLACE_SYMLINK])
Paul Eggert's avatar
Paul Eggert committed
195
  REPLACE_SYMLINKAT=0;    AC_SUBST([REPLACE_SYMLINKAT])
Paul Eggert's avatar
Paul Eggert committed
196
  REPLACE_TRUNCATE=0;     AC_SUBST([REPLACE_TRUNCATE])
Paul Eggert's avatar
Paul Eggert committed
197 198 199 200 201
  REPLACE_TTYNAME_R=0;    AC_SUBST([REPLACE_TTYNAME_R])
  REPLACE_UNLINK=0;       AC_SUBST([REPLACE_UNLINK])
  REPLACE_UNLINKAT=0;     AC_SUBST([REPLACE_UNLINKAT])
  REPLACE_USLEEP=0;       AC_SUBST([REPLACE_USLEEP])
  REPLACE_WRITE=0;        AC_SUBST([REPLACE_WRITE])
Paul Eggert's avatar
Paul Eggert committed
202
  UNISTD_H_HAVE_SYS_RANDOM_H=0; AC_SUBST([UNISTD_H_HAVE_SYS_RANDOM_H])
Paul Eggert's avatar
Paul Eggert committed
203 204 205 206
  UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
  UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
                           AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
])