unistd_h.m4 9.21 KB
Newer Older
1
# unistd_h.m4 serial 73
2
dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
3 4 5 6
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.

7
dnl Written by Simon Josefsson, Bruno Haible.
8

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

15
  gl_CHECK_NEXT_HEADERS([unistd.h])
Bruno Haible's avatar
Bruno Haible committed
16
  if test $ac_cv_header_unistd_h = yes; then
17 18 19
    HAVE_UNISTD_H=1
  else
    HAVE_UNISTD_H=0
Bruno Haible's avatar
Bruno Haible committed
20
  fi
21
  AC_SUBST([HAVE_UNISTD_H])
22

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

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

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
35
/* Some systems declare various items in the wrong headers.  */
Bruno Haible's avatar
Bruno Haible committed
36
#if !(defined __GLIBC__ && !defined __UCLIBC__)
37 38
# include <fcntl.h>
# include <stdio.h>
39
# include <stdlib.h>
40
# if defined _WIN32 && ! defined __CYGWIN__
41 42
#  include <io.h>
# endif
43
#endif
Bruno Haible's avatar
Bruno Haible committed
44
    ]], [chdir chown dup dup2 dup3 environ euidaccess faccessat fchdir fchownat
Eric Blake's avatar
Eric Blake committed
45
    fdatasync fsync ftruncate getcwd getdomainname getdtablesize getgroups
Bruno Haible's avatar
Bruno Haible committed
46 47 48
    gethostname getlogin getlogin_r getpagesize
    getusershell setusershell endusershell
    group_member isatty lchown link linkat lseek pipe pipe2 pread pwrite
Bruno Haible's avatar
Bruno Haible committed
49 50
    readlink readlinkat rmdir sethostname sleep symlink symlinkat
    truncate ttyname_r unlink unlinkat usleep])
51
])
52

53 54 55 56
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])
57
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
58
  dnl Define it also as a C macro, for the benefit of the unit tests.
59
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
60 61 62
])

AC_DEFUN([gl_UNISTD_H_DEFAULTS],
63
[
Bruno Haible's avatar
Bruno Haible committed
64
  GNULIB_CHDIR=0;                AC_SUBST([GNULIB_CHDIR])
65 66
  GNULIB_CHOWN=0;                AC_SUBST([GNULIB_CHOWN])
  GNULIB_CLOSE=0;                AC_SUBST([GNULIB_CLOSE])
Bruno Haible's avatar
Bruno Haible committed
67
  GNULIB_DUP=0;                  AC_SUBST([GNULIB_DUP])
68 69 70 71 72 73 74
  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])
Eric Blake's avatar
Eric Blake committed
75
  GNULIB_FDATASYNC=0;            AC_SUBST([GNULIB_FDATASYNC])
76 77 78 79 80 81 82 83 84 85 86
  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])
  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])
  GNULIB_GETPAGESIZE=0;          AC_SUBST([GNULIB_GETPAGESIZE])
  GNULIB_GETUSERSHELL=0;         AC_SUBST([GNULIB_GETUSERSHELL])
87
  GNULIB_GROUP_MEMBER=0;         AC_SUBST([GNULIB_GROUP_MEMBER])
Bruno Haible's avatar
Bruno Haible committed
88
  GNULIB_ISATTY=0;               AC_SUBST([GNULIB_ISATTY])
89 90 91 92 93 94 95 96
  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])
97
  GNULIB_READ=0;                 AC_SUBST([GNULIB_READ])
98 99 100
  GNULIB_READLINK=0;             AC_SUBST([GNULIB_READLINK])
  GNULIB_READLINKAT=0;           AC_SUBST([GNULIB_READLINKAT])
  GNULIB_RMDIR=0;                AC_SUBST([GNULIB_RMDIR])
101
  GNULIB_SETHOSTNAME=0;          AC_SUBST([GNULIB_SETHOSTNAME])
Bruno Haible's avatar
Bruno Haible committed
102
  GNULIB_SLEEP=0;                AC_SUBST([GNULIB_SLEEP])
103 104
  GNULIB_SYMLINK=0;              AC_SUBST([GNULIB_SYMLINK])
  GNULIB_SYMLINKAT=0;            AC_SUBST([GNULIB_SYMLINKAT])
Bruno Haible's avatar
Bruno Haible committed
105
  GNULIB_TRUNCATE=0;             AC_SUBST([GNULIB_TRUNCATE])
106 107 108 109 110 111 112
  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])
113
  dnl Assume proper GNU behavior unless another module says otherwise.
114
  HAVE_CHOWN=1;           AC_SUBST([HAVE_CHOWN])
115
  HAVE_DUP2=1;            AC_SUBST([HAVE_DUP2])
Bruno Haible's avatar
Bruno Haible committed
116
  HAVE_DUP3=1;            AC_SUBST([HAVE_DUP3])
117
  HAVE_EUIDACCESS=1;      AC_SUBST([HAVE_EUIDACCESS])
Eric Blake's avatar
Eric Blake committed
118
  HAVE_FACCESSAT=1;       AC_SUBST([HAVE_FACCESSAT])
119
  HAVE_FCHDIR=1;          AC_SUBST([HAVE_FCHDIR])
120
  HAVE_FCHOWNAT=1;        AC_SUBST([HAVE_FCHOWNAT])
Eric Blake's avatar
Eric Blake committed
121
  HAVE_FDATASYNC=1;       AC_SUBST([HAVE_FDATASYNC])
Richard W.M. Jones's avatar
Richard W.M. Jones committed
122
  HAVE_FSYNC=1;           AC_SUBST([HAVE_FSYNC])
123
  HAVE_FTRUNCATE=1;       AC_SUBST([HAVE_FTRUNCATE])
124
  HAVE_GETDTABLESIZE=1;   AC_SUBST([HAVE_GETDTABLESIZE])
125
  HAVE_GETGROUPS=1;       AC_SUBST([HAVE_GETGROUPS])
126
  HAVE_GETHOSTNAME=1;     AC_SUBST([HAVE_GETHOSTNAME])
Bruno Haible's avatar
Bruno Haible committed
127
  HAVE_GETLOGIN=1;        AC_SUBST([HAVE_GETLOGIN])
128
  HAVE_GETPAGESIZE=1;     AC_SUBST([HAVE_GETPAGESIZE])
129
  HAVE_GROUP_MEMBER=1;    AC_SUBST([HAVE_GROUP_MEMBER])
130
  HAVE_LCHOWN=1;          AC_SUBST([HAVE_LCHOWN])
Martin Lambers's avatar
Martin Lambers committed
131
  HAVE_LINK=1;            AC_SUBST([HAVE_LINK])
Eric Blake's avatar
Eric Blake committed
132
  HAVE_LINKAT=1;          AC_SUBST([HAVE_LINKAT])
133
  HAVE_PIPE=1;            AC_SUBST([HAVE_PIPE])
Bruno Haible's avatar
Bruno Haible committed
134
  HAVE_PIPE2=1;           AC_SUBST([HAVE_PIPE2])
Jim Meyering's avatar
Jim Meyering committed
135
  HAVE_PREAD=1;           AC_SUBST([HAVE_PREAD])
Peter O'Gorman's avatar
Peter O'Gorman committed
136
  HAVE_PWRITE=1;          AC_SUBST([HAVE_PWRITE])
137
  HAVE_READLINK=1;        AC_SUBST([HAVE_READLINK])
Eric Blake's avatar
Eric Blake committed
138
  HAVE_READLINKAT=1;      AC_SUBST([HAVE_READLINKAT])
139
  HAVE_SETHOSTNAME=1;     AC_SUBST([HAVE_SETHOSTNAME])
Bruno Haible's avatar
Bruno Haible committed
140
  HAVE_SLEEP=1;           AC_SUBST([HAVE_SLEEP])
141
  HAVE_SYMLINK=1;         AC_SUBST([HAVE_SYMLINK])
Eric Blake's avatar
Eric Blake committed
142
  HAVE_SYMLINKAT=1;       AC_SUBST([HAVE_SYMLINKAT])
Bruno Haible's avatar
Bruno Haible committed
143 144
  HAVE_UNLINKAT=1;        AC_SUBST([HAVE_UNLINKAT])
  HAVE_USLEEP=1;          AC_SUBST([HAVE_USLEEP])
Bruno Haible's avatar
Bruno Haible committed
145
  HAVE_DECL_ENVIRON=1;    AC_SUBST([HAVE_DECL_ENVIRON])
146
  HAVE_DECL_FCHDIR=1;     AC_SUBST([HAVE_DECL_FCHDIR])
147
  HAVE_DECL_FDATASYNC=1;  AC_SUBST([HAVE_DECL_FDATASYNC])
148
  HAVE_DECL_GETDOMAINNAME=1; AC_SUBST([HAVE_DECL_GETDOMAINNAME])
149
  HAVE_DECL_GETLOGIN=1;   AC_SUBST([HAVE_DECL_GETLOGIN])
150
  HAVE_DECL_GETLOGIN_R=1; AC_SUBST([HAVE_DECL_GETLOGIN_R])
151
  HAVE_DECL_GETPAGESIZE=1; AC_SUBST([HAVE_DECL_GETPAGESIZE])
152
  HAVE_DECL_GETUSERSHELL=1; AC_SUBST([HAVE_DECL_GETUSERSHELL])
153
  HAVE_DECL_SETHOSTNAME=1; AC_SUBST([HAVE_DECL_SETHOSTNAME])
154
  HAVE_DECL_TRUNCATE=1;   AC_SUBST([HAVE_DECL_TRUNCATE])
155
  HAVE_DECL_TTYNAME_R=1;  AC_SUBST([HAVE_DECL_TTYNAME_R])
156 157
  HAVE_OS_H=0;            AC_SUBST([HAVE_OS_H])
  HAVE_SYS_PARAM_H=0;     AC_SUBST([HAVE_SYS_PARAM_H])
158
  REPLACE_CHOWN=0;        AC_SUBST([REPLACE_CHOWN])
Paolo Bonzini's avatar
Paolo Bonzini committed
159
  REPLACE_CLOSE=0;        AC_SUBST([REPLACE_CLOSE])
160
  REPLACE_DUP=0;          AC_SUBST([REPLACE_DUP])
161
  REPLACE_DUP2=0;         AC_SUBST([REPLACE_DUP2])
162
  REPLACE_FACCESSAT=0;    AC_SUBST([REPLACE_FACCESSAT])
163
  REPLACE_FCHOWNAT=0;     AC_SUBST([REPLACE_FCHOWNAT])
164
  REPLACE_FTRUNCATE=0;    AC_SUBST([REPLACE_FTRUNCATE])
165
  REPLACE_GETCWD=0;       AC_SUBST([REPLACE_GETCWD])
166
  REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME])
167
  REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE])
168
  REPLACE_GETLOGIN_R=0;   AC_SUBST([REPLACE_GETLOGIN_R])
169
  REPLACE_GETGROUPS=0;    AC_SUBST([REPLACE_GETGROUPS])
170
  REPLACE_GETPAGESIZE=0;  AC_SUBST([REPLACE_GETPAGESIZE])
Bruno Haible's avatar
Bruno Haible committed
171
  REPLACE_ISATTY=0;       AC_SUBST([REPLACE_ISATTY])
172
  REPLACE_LCHOWN=0;       AC_SUBST([REPLACE_LCHOWN])
Eric Blake's avatar
Eric Blake committed
173
  REPLACE_LINK=0;         AC_SUBST([REPLACE_LINK])
174
  REPLACE_LINKAT=0;       AC_SUBST([REPLACE_LINKAT])
Eric Blake's avatar
Eric Blake committed
175
  REPLACE_LSEEK=0;        AC_SUBST([REPLACE_LSEEK])
Jim Meyering's avatar
Jim Meyering committed
176
  REPLACE_PREAD=0;        AC_SUBST([REPLACE_PREAD])
Peter O'Gorman's avatar
Peter O'Gorman committed
177
  REPLACE_PWRITE=0;       AC_SUBST([REPLACE_PWRITE])
178
  REPLACE_READ=0;         AC_SUBST([REPLACE_READ])
179
  REPLACE_READLINK=0;     AC_SUBST([REPLACE_READLINK])
180
  REPLACE_READLINKAT=0;   AC_SUBST([REPLACE_READLINKAT])
181
  REPLACE_RMDIR=0;        AC_SUBST([REPLACE_RMDIR])
182
  REPLACE_SLEEP=0;        AC_SUBST([REPLACE_SLEEP])
183
  REPLACE_SYMLINK=0;      AC_SUBST([REPLACE_SYMLINK])
Paul Eggert's avatar
Paul Eggert committed
184
  REPLACE_SYMLINKAT=0;    AC_SUBST([REPLACE_SYMLINKAT])
Bruno Haible's avatar
Bruno Haible committed
185
  REPLACE_TRUNCATE=0;     AC_SUBST([REPLACE_TRUNCATE])
186
  REPLACE_TTYNAME_R=0;    AC_SUBST([REPLACE_TTYNAME_R])
187
  REPLACE_UNLINK=0;       AC_SUBST([REPLACE_UNLINK])
188
  REPLACE_UNLINKAT=0;     AC_SUBST([REPLACE_UNLINKAT])
Eric Blake's avatar
Eric Blake committed
189
  REPLACE_USLEEP=0;       AC_SUBST([REPLACE_USLEEP])
Bruno Haible's avatar
Bruno Haible committed
190
  REPLACE_WRITE=0;        AC_SUBST([REPLACE_WRITE])
191
  UNISTD_H_HAVE_WINSOCK2_H=0; AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H])
192 193
  UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS=0;
                           AC_SUBST([UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS])
194
])