Commit | Line | Data |
---|---|---|
9b36a80c | 1 | /* Substitute for and wrapper around <unistd.h>. |
49114fd4 | 2 | Copyright (C) 2003-2011 Free Software Foundation, Inc. |
9b36a80c LC |
3 | |
4 | This program is free software; you can redistribute it and/or modify | |
5 | it under the terms of the GNU Lesser General Public License as published by | |
6 | the Free Software Foundation; either version 2, or (at your option) | |
7 | any later version. | |
8 | ||
9 | This program is distributed in the hope that it will be useful, | |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | GNU Lesser General Public License for more details. | |
13 | ||
14 | You should have received a copy of the GNU Lesser General Public License | |
15 | along with this program; if not, write to the Free Software Foundation, | |
16 | Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
17 | ||
9b36a80c LC |
18 | #if __GNUC__ >= 3 |
19 | @PRAGMA_SYSTEM_HEADER@ | |
20 | #endif | |
0f00f2c3 | 21 | @PRAGMA_COLUMNS@ |
9b36a80c | 22 | |
a927b6c1 LC |
23 | /* Special invocation convention: |
24 | - On mingw, several headers, including <winsock2.h>, include <unistd.h>, | |
25 | but we need to ensure that both the system <unistd.h> and <winsock2.h> | |
26 | are completely included before we replace gethostname. */ | |
27 | #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ | |
28 | && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H | |
29 | /* <unistd.h> is being indirectly included for the first time from | |
30 | <winsock2.h>; avoid declaring any overrides. */ | |
31 | # if @HAVE_UNISTD_H@ | |
32 | # @INCLUDE_NEXT@ @NEXT_UNISTD_H@ | |
33 | # else | |
34 | # error unexpected; report this to bug-gnulib@gnu.org | |
35 | # endif | |
36 | # define _GL_WINSOCK2_H_WITNESS | |
37 | ||
38 | /* Normal invocation. */ | |
39 | #elif !defined _GL_UNISTD_H | |
40 | ||
9b36a80c LC |
41 | /* The include_next requires a split double-inclusion guard. */ |
42 | #if @HAVE_UNISTD_H@ | |
43 | # @INCLUDE_NEXT@ @NEXT_UNISTD_H@ | |
44 | #endif | |
45 | ||
a927b6c1 LC |
46 | /* Get all possible declarations of gethostname(). */ |
47 | #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \ | |
48 | && !defined _GL_INCLUDING_WINSOCK2_H | |
49 | # define _GL_INCLUDING_WINSOCK2_H | |
50 | # include <winsock2.h> | |
51 | # undef _GL_INCLUDING_WINSOCK2_H | |
52 | #endif | |
53 | ||
54 | #if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H | |
9b36a80c LC |
55 | #define _GL_UNISTD_H |
56 | ||
8912421c LC |
57 | /* NetBSD 5.0 mis-defines NULL. Also get size_t. */ |
58 | #include <stddef.h> | |
59 | ||
f240aacb | 60 | /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */ |
61cd9dc9 LC |
61 | /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */ |
62 | /* But avoid namespace pollution on glibc systems. */ | |
63 | #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \ | |
0f00f2c3 LC |
64 | || ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \ |
65 | && defined __CYGWIN__)) \ | |
61cd9dc9 | 66 | && ! defined __GLIBC__ |
9b36a80c LC |
67 | # include <stdio.h> |
68 | #endif | |
69 | ||
61cd9dc9 LC |
70 | /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */ |
71 | /* But avoid namespace pollution on glibc systems. */ | |
0f00f2c3 LC |
72 | #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \ |
73 | && ! defined __GLIBC__ | |
61cd9dc9 LC |
74 | # include <fcntl.h> |
75 | #endif | |
76 | ||
9b36a80c | 77 | /* mingw fails to declare _exit in <unistd.h>. */ |
4a462e35 | 78 | /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */ |
61cd9dc9 LC |
79 | /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */ |
80 | /* But avoid namespace pollution on glibc systems. */ | |
81 | #ifndef __GLIBC__ | |
82 | # include <stdlib.h> | |
83 | #endif | |
9b36a80c | 84 | |
61cd9dc9 LC |
85 | /* mingw declares getcwd in <io.h>, not in <unistd.h>. */ |
86 | #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \ | |
87 | && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)) | |
88 | # include <io.h> | |
89 | #endif | |
90 | ||
49114fd4 LC |
91 | /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>. |
92 | NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */ | |
0f00f2c3 | 93 | /* But avoid namespace pollution on glibc systems. */ |
49114fd4 LC |
94 | #if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \ |
95 | || (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \ | |
0f00f2c3 LC |
96 | && !defined __GLIBC__ |
97 | # include <netdb.h> | |
98 | #endif | |
99 | ||
61cd9dc9 | 100 | #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \ |
a927b6c1 | 101 | || @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK) |
9b36a80c LC |
102 | /* Get ssize_t. */ |
103 | # include <sys/types.h> | |
104 | #endif | |
105 | ||
61cd9dc9 LC |
106 | /* Get getopt(), optarg, optind, opterr, optopt. |
107 | But avoid namespace pollution on glibc systems. */ | |
108 | #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT | |
8912421c LC |
109 | # include <getopt.h> |
110 | #endif | |
111 | ||
a927b6c1 LC |
112 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
113 | ||
114 | /* The definition of _GL_ARG_NONNULL is copied here. */ | |
115 | ||
116 | /* The definition of _GL_WARN_ON_USE is copied here. */ | |
117 | ||
118 | ||
9b36a80c LC |
119 | #if @GNULIB_GETHOSTNAME@ |
120 | /* Get all possible declarations of gethostname(). */ | |
121 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | |
9b36a80c | 122 | # if !defined _GL_SYS_SOCKET_H |
a927b6c1 LC |
123 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
124 | # undef socket | |
125 | # define socket socket_used_without_including_sys_socket_h | |
126 | # undef connect | |
127 | # define connect connect_used_without_including_sys_socket_h | |
128 | # undef accept | |
129 | # define accept accept_used_without_including_sys_socket_h | |
130 | # undef bind | |
131 | # define bind bind_used_without_including_sys_socket_h | |
132 | # undef getpeername | |
133 | # define getpeername getpeername_used_without_including_sys_socket_h | |
134 | # undef getsockname | |
135 | # define getsockname getsockname_used_without_including_sys_socket_h | |
136 | # undef getsockopt | |
137 | # define getsockopt getsockopt_used_without_including_sys_socket_h | |
138 | # undef listen | |
139 | # define listen listen_used_without_including_sys_socket_h | |
140 | # undef recv | |
141 | # define recv recv_used_without_including_sys_socket_h | |
142 | # undef send | |
143 | # define send send_used_without_including_sys_socket_h | |
144 | # undef recvfrom | |
145 | # define recvfrom recvfrom_used_without_including_sys_socket_h | |
146 | # undef sendto | |
147 | # define sendto sendto_used_without_including_sys_socket_h | |
148 | # undef setsockopt | |
149 | # define setsockopt setsockopt_used_without_including_sys_socket_h | |
150 | # undef shutdown | |
151 | # define shutdown shutdown_used_without_including_sys_socket_h | |
152 | # else | |
153 | _GL_WARN_ON_USE (socket, | |
154 | "socket() used without including <sys/socket.h>"); | |
155 | _GL_WARN_ON_USE (connect, | |
156 | "connect() used without including <sys/socket.h>"); | |
157 | _GL_WARN_ON_USE (accept, | |
158 | "accept() used without including <sys/socket.h>"); | |
159 | _GL_WARN_ON_USE (bind, | |
160 | "bind() used without including <sys/socket.h>"); | |
161 | _GL_WARN_ON_USE (getpeername, | |
162 | "getpeername() used without including <sys/socket.h>"); | |
163 | _GL_WARN_ON_USE (getsockname, | |
164 | "getsockname() used without including <sys/socket.h>"); | |
165 | _GL_WARN_ON_USE (getsockopt, | |
166 | "getsockopt() used without including <sys/socket.h>"); | |
167 | _GL_WARN_ON_USE (listen, | |
168 | "listen() used without including <sys/socket.h>"); | |
169 | _GL_WARN_ON_USE (recv, | |
170 | "recv() used without including <sys/socket.h>"); | |
171 | _GL_WARN_ON_USE (send, | |
172 | "send() used without including <sys/socket.h>"); | |
173 | _GL_WARN_ON_USE (recvfrom, | |
174 | "recvfrom() used without including <sys/socket.h>"); | |
175 | _GL_WARN_ON_USE (sendto, | |
176 | "sendto() used without including <sys/socket.h>"); | |
177 | _GL_WARN_ON_USE (setsockopt, | |
178 | "setsockopt() used without including <sys/socket.h>"); | |
179 | _GL_WARN_ON_USE (shutdown, | |
180 | "shutdown() used without including <sys/socket.h>"); | |
181 | # endif | |
9b36a80c LC |
182 | # endif |
183 | # if !defined _GL_SYS_SELECT_H | |
a927b6c1 LC |
184 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
185 | # undef select | |
186 | # define select select_used_without_including_sys_select_h | |
187 | # else | |
188 | _GL_WARN_ON_USE (select, | |
189 | "select() used without including <sys/select.h>"); | |
190 | # endif | |
9b36a80c LC |
191 | # endif |
192 | # endif | |
193 | #endif | |
194 | ||
9b36a80c | 195 | |
f240aacb LC |
196 | /* OS/2 EMX lacks these macros. */ |
197 | #ifndef STDIN_FILENO | |
198 | # define STDIN_FILENO 0 | |
199 | #endif | |
200 | #ifndef STDOUT_FILENO | |
201 | # define STDOUT_FILENO 1 | |
202 | #endif | |
203 | #ifndef STDERR_FILENO | |
204 | # define STDERR_FILENO 2 | |
205 | #endif | |
206 | ||
8912421c LC |
207 | /* Ensure *_OK macros exist. */ |
208 | #ifndef F_OK | |
209 | # define F_OK 0 | |
210 | # define X_OK 1 | |
211 | # define W_OK 2 | |
212 | # define R_OK 4 | |
213 | #endif | |
214 | ||
215 | ||
9b36a80c LC |
216 | /* Declare overridden functions. */ |
217 | ||
f4c79b3c LC |
218 | |
219 | #if defined GNULIB_POSIXCHECK | |
220 | /* The access() function is a security risk. */ | |
221 | _GL_WARN_ON_USE (access, "the access function is a security risk - " | |
222 | "use the gnulib module faccessat instead"); | |
9b36a80c LC |
223 | #endif |
224 | ||
225 | ||
226 | #if @GNULIB_CHOWN@ | |
9b36a80c LC |
227 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE |
228 | to GID (if GID is not -1). Follow symbolic links. | |
229 | Return 0 if successful, otherwise -1 and errno set. | |
230 | See the POSIX:2001 specification | |
231 | <http://www.opengroup.org/susv3xsh/chown.html>. */ | |
f4c79b3c LC |
232 | # if @REPLACE_CHOWN@ |
233 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
234 | # undef chown | |
235 | # define chown rpl_chown | |
236 | # endif | |
237 | _GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid) | |
238 | _GL_ARG_NONNULL ((1))); | |
239 | _GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)); | |
240 | # else | |
241 | # if !@HAVE_CHOWN@ | |
242 | _GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid) | |
243 | _GL_ARG_NONNULL ((1))); | |
244 | # endif | |
245 | _GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)); | |
9b36a80c | 246 | # endif |
f4c79b3c | 247 | _GL_CXXALIASWARN (chown); |
9b36a80c LC |
248 | #elif defined GNULIB_POSIXCHECK |
249 | # undef chown | |
61cd9dc9 LC |
250 | # if HAVE_RAW_DECL_CHOWN |
251 | _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and " | |
252 | "doesn't treat a uid or gid of -1 on some systems - " | |
253 | "use gnulib module chown for portability"); | |
254 | # endif | |
9b36a80c LC |
255 | #endif |
256 | ||
257 | ||
258 | #if @GNULIB_CLOSE@ | |
9b36a80c LC |
259 | # if @REPLACE_CLOSE@ |
260 | /* Automatically included by modules that need a replacement for close. */ | |
f4c79b3c LC |
261 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
262 | # undef close | |
263 | # define close rpl_close | |
264 | # endif | |
265 | _GL_FUNCDECL_RPL (close, int, (int fd)); | |
266 | _GL_CXXALIAS_RPL (close, int, (int fd)); | |
267 | # else | |
268 | _GL_CXXALIAS_SYS (close, int, (int fd)); | |
9b36a80c | 269 | # endif |
f4c79b3c | 270 | _GL_CXXALIASWARN (close); |
8912421c | 271 | #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@ |
9b36a80c LC |
272 | # undef close |
273 | # define close close_used_without_requesting_gnulib_module_close | |
274 | #elif defined GNULIB_POSIXCHECK | |
275 | # undef close | |
61cd9dc9 LC |
276 | /* Assume close is always declared. */ |
277 | _GL_WARN_ON_USE (close, "close does not portably work on sockets - " | |
278 | "use gnulib module close for portability"); | |
9b36a80c LC |
279 | #endif |
280 | ||
281 | ||
8912421c | 282 | #if @REPLACE_DUP@ |
f4c79b3c LC |
283 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
284 | # define dup rpl_dup | |
285 | # endif | |
286 | _GL_FUNCDECL_RPL (dup, int, (int oldfd)); | |
287 | _GL_CXXALIAS_RPL (dup, int, (int oldfd)); | |
288 | #else | |
289 | _GL_CXXALIAS_SYS (dup, int, (int oldfd)); | |
8912421c | 290 | #endif |
f4c79b3c | 291 | _GL_CXXALIASWARN (dup); |
8912421c LC |
292 | |
293 | ||
9b36a80c | 294 | #if @GNULIB_DUP2@ |
9b36a80c LC |
295 | /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if |
296 | NEWFD = OLDFD, otherwise close NEWFD first if it is open. | |
25361e4b | 297 | Return newfd if successful, otherwise -1 and errno set. |
9b36a80c LC |
298 | See the POSIX:2001 specification |
299 | <http://www.opengroup.org/susv3xsh/dup2.html>. */ | |
f4c79b3c LC |
300 | # if @REPLACE_DUP2@ |
301 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
302 | # define dup2 rpl_dup2 | |
303 | # endif | |
304 | _GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd)); | |
305 | _GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd)); | |
306 | # else | |
307 | # if !@HAVE_DUP2@ | |
308 | _GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd)); | |
309 | # endif | |
310 | _GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd)); | |
9b36a80c | 311 | # endif |
f4c79b3c | 312 | _GL_CXXALIASWARN (dup2); |
9b36a80c LC |
313 | #elif defined GNULIB_POSIXCHECK |
314 | # undef dup2 | |
61cd9dc9 LC |
315 | # if HAVE_RAW_DECL_DUP2 |
316 | _GL_WARN_ON_USE (dup2, "dup2 is unportable - " | |
317 | "use gnulib module dup2 for portability"); | |
318 | # endif | |
9b36a80c LC |
319 | #endif |
320 | ||
321 | ||
8912421c LC |
322 | #if @GNULIB_DUP3@ |
323 | /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the | |
324 | specified flags. | |
325 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
326 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
327 | Close NEWFD first if it is open. | |
328 | Return newfd if successful, otherwise -1 and errno set. | |
329 | See the Linux man page at | |
330 | <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */ | |
331 | # if @HAVE_DUP3@ | |
f4c79b3c LC |
332 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
333 | # define dup3 rpl_dup3 | |
334 | # endif | |
335 | _GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags)); | |
336 | _GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags)); | |
337 | # else | |
338 | _GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags)); | |
339 | _GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags)); | |
8912421c | 340 | # endif |
f4c79b3c | 341 | _GL_CXXALIASWARN (dup3); |
8912421c LC |
342 | #elif defined GNULIB_POSIXCHECK |
343 | # undef dup3 | |
61cd9dc9 LC |
344 | # if HAVE_RAW_DECL_DUP3 |
345 | _GL_WARN_ON_USE (dup3, "dup3 is unportable - " | |
346 | "use gnulib module dup3 for portability"); | |
347 | # endif | |
8912421c LC |
348 | #endif |
349 | ||
350 | ||
9b36a80c LC |
351 | #if @GNULIB_ENVIRON@ |
352 | # if !@HAVE_DECL_ENVIRON@ | |
353 | /* Set of environment variables and values. An array of strings of the form | |
354 | "VARIABLE=VALUE", terminated with a NULL. */ | |
355 | # if defined __APPLE__ && defined __MACH__ | |
356 | # include <crt_externs.h> | |
357 | # define environ (*_NSGetEnviron ()) | |
358 | # else | |
f4c79b3c LC |
359 | # ifdef __cplusplus |
360 | extern "C" { | |
361 | # endif | |
9b36a80c | 362 | extern char **environ; |
f4c79b3c LC |
363 | # ifdef __cplusplus |
364 | } | |
365 | # endif | |
9b36a80c LC |
366 | # endif |
367 | # endif | |
368 | #elif defined GNULIB_POSIXCHECK | |
61cd9dc9 LC |
369 | # if HAVE_RAW_DECL_ENVIRON |
370 | static inline char *** | |
371 | rpl_environ (void) | |
372 | { | |
373 | return &environ; | |
374 | } | |
375 | _GL_WARN_ON_USE (rpl_environ, "environ is unportable - " | |
376 | "use gnulib module environ for portability"); | |
377 | # undef environ | |
378 | # define environ (*rpl_environ ()) | |
379 | # endif | |
9b36a80c LC |
380 | #endif |
381 | ||
382 | ||
383 | #if @GNULIB_EUIDACCESS@ | |
8912421c | 384 | /* Like access(), except that it uses the effective user id and group id of |
9b36a80c | 385 | the current process. */ |
f4c79b3c LC |
386 | # if !@HAVE_EUIDACCESS@ |
387 | _GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode) | |
388 | _GL_ARG_NONNULL ((1))); | |
389 | # endif | |
390 | _GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode)); | |
391 | _GL_CXXALIASWARN (euidaccess); | |
392 | # if defined GNULIB_POSIXCHECK | |
393 | /* Like access(), this function is a security risk. */ | |
394 | _GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - " | |
395 | "use the gnulib module faccessat instead"); | |
9b36a80c LC |
396 | # endif |
397 | #elif defined GNULIB_POSIXCHECK | |
398 | # undef euidaccess | |
61cd9dc9 LC |
399 | # if HAVE_RAW_DECL_EUIDACCESS |
400 | _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - " | |
401 | "use gnulib module euidaccess for portability"); | |
402 | # endif | |
9b36a80c LC |
403 | #endif |
404 | ||
405 | ||
8912421c LC |
406 | #if @GNULIB_FACCESSAT@ |
407 | # if !@HAVE_FACCESSAT@ | |
f4c79b3c LC |
408 | _GL_FUNCDECL_SYS (faccessat, int, |
409 | (int fd, char const *file, int mode, int flag) | |
410 | _GL_ARG_NONNULL ((2))); | |
8912421c | 411 | # endif |
f4c79b3c LC |
412 | _GL_CXXALIAS_SYS (faccessat, int, |
413 | (int fd, char const *file, int mode, int flag)); | |
414 | _GL_CXXALIASWARN (faccessat); | |
8912421c LC |
415 | #elif defined GNULIB_POSIXCHECK |
416 | # undef faccessat | |
61cd9dc9 LC |
417 | # if HAVE_RAW_DECL_FACCESSAT |
418 | _GL_WARN_ON_USE (faccessat, "faccessat is not portable - " | |
419 | "use gnulib module faccessat for portability"); | |
420 | # endif | |
8912421c LC |
421 | #endif |
422 | ||
423 | ||
9b36a80c | 424 | #if @GNULIB_FCHDIR@ |
9b36a80c LC |
425 | /* Change the process' current working directory to the directory on which |
426 | the given file descriptor is open. | |
427 | Return 0 if successful, otherwise -1 and errno set. | |
428 | See the POSIX:2001 specification | |
429 | <http://www.opengroup.org/susv3xsh/fchdir.html>. */ | |
a927b6c1 LC |
430 | # if ! @HAVE_FCHDIR@ |
431 | _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); | |
9b36a80c | 432 | |
8912421c | 433 | /* Gnulib internal hooks needed to maintain the fchdir metadata. */ |
f4c79b3c | 434 | _GL_EXTERN_C int _gl_register_fd (int fd, const char *filename) |
1cd4fffc | 435 | _GL_ARG_NONNULL ((2)); |
f4c79b3c LC |
436 | _GL_EXTERN_C void _gl_unregister_fd (int fd); |
437 | _GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd); | |
438 | _GL_EXTERN_C const char *_gl_directory_name (int fd); | |
9b36a80c | 439 | |
ab4d62ad LC |
440 | # else |
441 | # if !@HAVE_DECL_FCHDIR@ | |
442 | _GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/)); | |
443 | # endif | |
9b36a80c | 444 | # endif |
a927b6c1 | 445 | _GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/)); |
f4c79b3c | 446 | _GL_CXXALIASWARN (fchdir); |
9b36a80c LC |
447 | #elif defined GNULIB_POSIXCHECK |
448 | # undef fchdir | |
61cd9dc9 LC |
449 | # if HAVE_RAW_DECL_FCHDIR |
450 | _GL_WARN_ON_USE (fchdir, "fchdir is unportable - " | |
451 | "use gnulib module fchdir for portability"); | |
452 | # endif | |
9b36a80c LC |
453 | #endif |
454 | ||
455 | ||
8912421c LC |
456 | #if @GNULIB_FCHOWNAT@ |
457 | # if @REPLACE_FCHOWNAT@ | |
f4c79b3c LC |
458 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
459 | # undef fchownat | |
460 | # define fchownat rpl_fchownat | |
461 | # endif | |
462 | _GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file, | |
463 | uid_t owner, gid_t group, int flag) | |
464 | _GL_ARG_NONNULL ((2))); | |
465 | _GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file, | |
466 | uid_t owner, gid_t group, int flag)); | |
467 | # else | |
468 | # if !@HAVE_FCHOWNAT@ | |
469 | _GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file, | |
470 | uid_t owner, gid_t group, int flag) | |
471 | _GL_ARG_NONNULL ((2))); | |
472 | # endif | |
473 | _GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file, | |
474 | uid_t owner, gid_t group, int flag)); | |
8912421c | 475 | # endif |
f4c79b3c | 476 | _GL_CXXALIASWARN (fchownat); |
8912421c LC |
477 | #elif defined GNULIB_POSIXCHECK |
478 | # undef fchownat | |
61cd9dc9 LC |
479 | # if HAVE_RAW_DECL_FCHOWNAT |
480 | _GL_WARN_ON_USE (fchownat, "fchownat is not portable - " | |
481 | "use gnulib module openat for portability"); | |
482 | # endif | |
8912421c LC |
483 | #endif |
484 | ||
485 | ||
9b36a80c LC |
486 | #if @GNULIB_FSYNC@ |
487 | /* Synchronize changes to a file. | |
488 | Return 0 if successful, otherwise -1 and errno set. | |
489 | See POSIX:2001 specification | |
490 | <http://www.opengroup.org/susv3xsh/fsync.html>. */ | |
491 | # if !@HAVE_FSYNC@ | |
f4c79b3c | 492 | _GL_FUNCDECL_SYS (fsync, int, (int fd)); |
9b36a80c | 493 | # endif |
f4c79b3c LC |
494 | _GL_CXXALIAS_SYS (fsync, int, (int fd)); |
495 | _GL_CXXALIASWARN (fsync); | |
9b36a80c LC |
496 | #elif defined GNULIB_POSIXCHECK |
497 | # undef fsync | |
61cd9dc9 LC |
498 | # if HAVE_RAW_DECL_FSYNC |
499 | _GL_WARN_ON_USE (fsync, "fsync is unportable - " | |
500 | "use gnulib module fsync for portability"); | |
501 | # endif | |
9b36a80c LC |
502 | #endif |
503 | ||
504 | ||
505 | #if @GNULIB_FTRUNCATE@ | |
9b36a80c LC |
506 | /* Change the size of the file to which FD is opened to become equal to LENGTH. |
507 | Return 0 if successful, otherwise -1 and errno set. | |
508 | See the POSIX:2001 specification | |
509 | <http://www.opengroup.org/susv3xsh/ftruncate.html>. */ | |
f4c79b3c LC |
510 | # if !@HAVE_FTRUNCATE@ |
511 | _GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length)); | |
9b36a80c | 512 | # endif |
f4c79b3c LC |
513 | _GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length)); |
514 | _GL_CXXALIASWARN (ftruncate); | |
9b36a80c LC |
515 | #elif defined GNULIB_POSIXCHECK |
516 | # undef ftruncate | |
61cd9dc9 LC |
517 | # if HAVE_RAW_DECL_FTRUNCATE |
518 | _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - " | |
519 | "use gnulib module ftruncate for portability"); | |
520 | # endif | |
9b36a80c LC |
521 | #endif |
522 | ||
523 | ||
524 | #if @GNULIB_GETCWD@ | |
9b36a80c LC |
525 | /* Get the name of the current working directory, and put it in SIZE bytes |
526 | of BUF. | |
527 | Return BUF if successful, or NULL if the directory couldn't be determined | |
528 | or SIZE was too small. | |
529 | See the POSIX:2001 specification | |
530 | <http://www.opengroup.org/susv3xsh/getcwd.html>. | |
531 | Additionally, the gnulib module 'getcwd' guarantees the following GNU | |
532 | extension: If BUF is NULL, an array is allocated with 'malloc'; the array | |
533 | is SIZE bytes long, unless SIZE == 0, in which case it is as big as | |
534 | necessary. */ | |
f4c79b3c LC |
535 | # if @REPLACE_GETCWD@ |
536 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
537 | # define getcwd rpl_getcwd | |
538 | # endif | |
539 | _GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size)); | |
540 | _GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size)); | |
541 | # else | |
a927b6c1 LC |
542 | /* Need to cast, because on mingw, the second parameter is |
543 | int size. */ | |
544 | _GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size)); | |
9b36a80c | 545 | # endif |
f4c79b3c | 546 | _GL_CXXALIASWARN (getcwd); |
9b36a80c LC |
547 | #elif defined GNULIB_POSIXCHECK |
548 | # undef getcwd | |
61cd9dc9 LC |
549 | # if HAVE_RAW_DECL_GETCWD |
550 | _GL_WARN_ON_USE (getcwd, "getcwd is unportable - " | |
551 | "use gnulib module getcwd for portability"); | |
552 | # endif | |
9b36a80c LC |
553 | #endif |
554 | ||
555 | ||
556 | #if @GNULIB_GETDOMAINNAME@ | |
557 | /* Return the NIS domain name of the machine. | |
558 | WARNING! The NIS domain name is unrelated to the fully qualified host name | |
559 | of the machine. It is also unrelated to email addresses. | |
560 | WARNING! The NIS domain name is usually the empty string or "(none)" when | |
561 | not using NIS. | |
562 | ||
563 | Put up to LEN bytes of the NIS domain name into NAME. | |
564 | Null terminate it if the name is shorter than LEN. | |
565 | If the NIS domain name is longer than LEN, set errno = EINVAL and return -1. | |
566 | Return 0 if successful, otherwise set errno and return -1. */ | |
0f00f2c3 LC |
567 | # if @REPLACE_GETDOMAINNAME@ |
568 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
569 | # undef getdomainname | |
570 | # define getdomainname rpl_getdomainname | |
571 | # endif | |
572 | _GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len) | |
573 | _GL_ARG_NONNULL ((1))); | |
574 | _GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len)); | |
575 | # else | |
576 | # if !@HAVE_DECL_GETDOMAINNAME@ | |
f4c79b3c LC |
577 | _GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len) |
578 | _GL_ARG_NONNULL ((1))); | |
0f00f2c3 LC |
579 | # endif |
580 | _GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len)); | |
9b36a80c | 581 | # endif |
f4c79b3c | 582 | _GL_CXXALIASWARN (getdomainname); |
9b36a80c LC |
583 | #elif defined GNULIB_POSIXCHECK |
584 | # undef getdomainname | |
61cd9dc9 LC |
585 | # if HAVE_RAW_DECL_GETDOMAINNAME |
586 | _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - " | |
587 | "use gnulib module getdomainname for portability"); | |
588 | # endif | |
9b36a80c LC |
589 | #endif |
590 | ||
591 | ||
592 | #if @GNULIB_GETDTABLESIZE@ | |
8912421c LC |
593 | /* Return the maximum number of file descriptors in the current process. |
594 | In POSIX, this is same as sysconf (_SC_OPEN_MAX). */ | |
f4c79b3c LC |
595 | # if !@HAVE_GETDTABLESIZE@ |
596 | _GL_FUNCDECL_SYS (getdtablesize, int, (void)); | |
9b36a80c | 597 | # endif |
f4c79b3c LC |
598 | _GL_CXXALIAS_SYS (getdtablesize, int, (void)); |
599 | _GL_CXXALIASWARN (getdtablesize); | |
9b36a80c LC |
600 | #elif defined GNULIB_POSIXCHECK |
601 | # undef getdtablesize | |
61cd9dc9 LC |
602 | # if HAVE_RAW_DECL_GETDTABLESIZE |
603 | _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " | |
604 | "use gnulib module getdtablesize for portability"); | |
605 | # endif | |
9b36a80c LC |
606 | #endif |
607 | ||
608 | ||
f29ded4b | 609 | #if @GNULIB_GETGROUPS@ |
f29ded4b LC |
610 | /* Return the supplemental groups that the current process belongs to. |
611 | It is unspecified whether the effective group id is in the list. | |
612 | If N is 0, return the group count; otherwise, N describes how many | |
613 | entries are available in GROUPS. Return -1 and set errno if N is | |
614 | not 0 and not large enough. Fails with ENOSYS on some systems. */ | |
f4c79b3c LC |
615 | # if @REPLACE_GETGROUPS@ |
616 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
617 | # undef getgroups | |
618 | # define getgroups rpl_getgroups | |
619 | # endif | |
620 | _GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups)); | |
621 | _GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups)); | |
622 | # else | |
623 | # if !@HAVE_GETGROUPS@ | |
624 | _GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups)); | |
625 | # endif | |
626 | _GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups)); | |
f29ded4b | 627 | # endif |
f4c79b3c | 628 | _GL_CXXALIASWARN (getgroups); |
f29ded4b LC |
629 | #elif defined GNULIB_POSIXCHECK |
630 | # undef getgroups | |
61cd9dc9 LC |
631 | # if HAVE_RAW_DECL_GETGROUPS |
632 | _GL_WARN_ON_USE (getgroups, "getgroups is unportable - " | |
633 | "use gnulib module getgroups for portability"); | |
634 | # endif | |
f29ded4b LC |
635 | #endif |
636 | ||
637 | ||
9b36a80c LC |
638 | #if @GNULIB_GETHOSTNAME@ |
639 | /* Return the standard host name of the machine. | |
640 | WARNING! The host name may or may not be fully qualified. | |
641 | ||
642 | Put up to LEN bytes of the host name into NAME. | |
643 | Null terminate it if the name is shorter than LEN. | |
644 | If the host name is longer than LEN, set errno = EINVAL and return -1. | |
645 | Return 0 if successful, otherwise set errno and return -1. */ | |
646 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | |
f4c79b3c LC |
647 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
648 | # undef gethostname | |
649 | # define gethostname rpl_gethostname | |
650 | # endif | |
651 | _GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len) | |
652 | _GL_ARG_NONNULL ((1))); | |
653 | _GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len)); | |
654 | # else | |
655 | # if !@HAVE_GETHOSTNAME@ | |
656 | _GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len) | |
657 | _GL_ARG_NONNULL ((1))); | |
658 | # endif | |
ab4d62ad LC |
659 | /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second |
660 | parameter is | |
f4c79b3c LC |
661 | int len. */ |
662 | _GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len)); | |
9b36a80c | 663 | # endif |
f4c79b3c | 664 | _GL_CXXALIASWARN (gethostname); |
9b36a80c LC |
665 | #elif @UNISTD_H_HAVE_WINSOCK2_H@ |
666 | # undef gethostname | |
667 | # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname | |
668 | #elif defined GNULIB_POSIXCHECK | |
669 | # undef gethostname | |
61cd9dc9 LC |
670 | # if HAVE_RAW_DECL_GETHOSTNAME |
671 | _GL_WARN_ON_USE (gethostname, "gethostname is unportable - " | |
672 | "use gnulib module gethostname for portability"); | |
673 | # endif | |
674 | #endif | |
675 | ||
676 | ||
677 | #if @GNULIB_GETLOGIN@ | |
678 | /* Returns the user's login name, or NULL if it cannot be found. Upon error, | |
679 | returns NULL with errno set. | |
680 | ||
681 | See <http://www.opengroup.org/susv3xsh/getlogin.html>. | |
682 | ||
683 | Most programs don't need to use this function, because the information is | |
684 | available through environment variables: | |
685 | ${LOGNAME-$USER} on Unix platforms, | |
686 | $USERNAME on native Windows platforms. | |
687 | */ | |
688 | # if !@HAVE_GETLOGIN@ | |
f4c79b3c | 689 | _GL_FUNCDECL_SYS (getlogin, char *, (void)); |
61cd9dc9 | 690 | # endif |
f4c79b3c LC |
691 | _GL_CXXALIAS_SYS (getlogin, char *, (void)); |
692 | _GL_CXXALIASWARN (getlogin); | |
61cd9dc9 LC |
693 | #elif defined GNULIB_POSIXCHECK |
694 | # undef getlogin | |
695 | # if HAVE_RAW_DECL_GETLOGIN | |
696 | _GL_WARN_ON_USE (getlogin, "getlogin is unportable - " | |
697 | "use gnulib module getlogin for portability"); | |
698 | # endif | |
9b36a80c LC |
699 | #endif |
700 | ||
701 | ||
702 | #if @GNULIB_GETLOGIN_R@ | |
703 | /* Copies the user's login name to NAME. | |
704 | The array pointed to by NAME has room for SIZE bytes. | |
705 | ||
706 | Returns 0 if successful. Upon error, an error number is returned, or -1 in | |
707 | the case that the login name cannot be found but no specific error is | |
708 | provided (this case is hopefully rare but is left open by the POSIX spec). | |
709 | ||
710 | See <http://www.opengroup.org/susv3xsh/getlogin.html>. | |
61cd9dc9 LC |
711 | |
712 | Most programs don't need to use this function, because the information is | |
713 | available through environment variables: | |
714 | ${LOGNAME-$USER} on Unix platforms, | |
715 | $USERNAME on native Windows platforms. | |
9b36a80c | 716 | */ |
49114fd4 LC |
717 | # if @REPLACE_GETLOGIN_R@ |
718 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
719 | # define getlogin_r rpl_getlogin_r | |
720 | # endif | |
721 | _GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size) | |
722 | _GL_ARG_NONNULL ((1))); | |
723 | _GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size)); | |
724 | # else | |
725 | # if !@HAVE_DECL_GETLOGIN_R@ | |
f4c79b3c LC |
726 | _GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size) |
727 | _GL_ARG_NONNULL ((1))); | |
49114fd4 | 728 | # endif |
f4c79b3c LC |
729 | /* Need to cast, because on Solaris 10 systems, the second argument is |
730 | int size. */ | |
731 | _GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size)); | |
49114fd4 | 732 | # endif |
f4c79b3c | 733 | _GL_CXXALIASWARN (getlogin_r); |
9b36a80c LC |
734 | #elif defined GNULIB_POSIXCHECK |
735 | # undef getlogin_r | |
61cd9dc9 LC |
736 | # if HAVE_RAW_DECL_GETLOGIN_R |
737 | _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - " | |
738 | "use gnulib module getlogin_r for portability"); | |
739 | # endif | |
9b36a80c LC |
740 | #endif |
741 | ||
742 | ||
743 | #if @GNULIB_GETPAGESIZE@ | |
744 | # if @REPLACE_GETPAGESIZE@ | |
f4c79b3c LC |
745 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
746 | # define getpagesize rpl_getpagesize | |
9b36a80c | 747 | # endif |
f4c79b3c LC |
748 | _GL_FUNCDECL_RPL (getpagesize, int, (void)); |
749 | _GL_CXXALIAS_RPL (getpagesize, int, (void)); | |
750 | # else | |
751 | # if !@HAVE_GETPAGESIZE@ | |
752 | # if !defined getpagesize | |
753 | /* This is for POSIX systems. */ | |
754 | # if !defined _gl_getpagesize && defined _SC_PAGESIZE | |
755 | # if ! (defined __VMS && __VMS_VER < 70000000) | |
756 | # define _gl_getpagesize() sysconf (_SC_PAGESIZE) | |
757 | # endif | |
758 | # endif | |
9b36a80c | 759 | /* This is for older VMS. */ |
f4c79b3c LC |
760 | # if !defined _gl_getpagesize && defined __VMS |
761 | # ifdef __ALPHA | |
762 | # define _gl_getpagesize() 8192 | |
763 | # else | |
764 | # define _gl_getpagesize() 512 | |
765 | # endif | |
766 | # endif | |
9b36a80c | 767 | /* This is for BeOS. */ |
f4c79b3c LC |
768 | # if !defined _gl_getpagesize && @HAVE_OS_H@ |
769 | # include <OS.h> | |
770 | # if defined B_PAGE_SIZE | |
771 | # define _gl_getpagesize() B_PAGE_SIZE | |
772 | # endif | |
773 | # endif | |
9b36a80c | 774 | /* This is for AmigaOS4.0. */ |
f4c79b3c LC |
775 | # if !defined _gl_getpagesize && defined __amigaos4__ |
776 | # define _gl_getpagesize() 2048 | |
777 | # endif | |
9b36a80c | 778 | /* This is for older Unix systems. */ |
f4c79b3c LC |
779 | # if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@ |
780 | # include <sys/param.h> | |
781 | # ifdef EXEC_PAGESIZE | |
782 | # define _gl_getpagesize() EXEC_PAGESIZE | |
783 | # else | |
784 | # ifdef NBPG | |
785 | # ifndef CLSIZE | |
786 | # define CLSIZE 1 | |
787 | # endif | |
788 | # define _gl_getpagesize() (NBPG * CLSIZE) | |
789 | # else | |
790 | # ifdef NBPC | |
791 | # define _gl_getpagesize() NBPC | |
792 | # endif | |
793 | # endif | |
9b36a80c | 794 | # endif |
f4c79b3c LC |
795 | # endif |
796 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
797 | # define getpagesize() _gl_getpagesize () | |
9b36a80c | 798 | # else |
49114fd4 | 799 | # if !GNULIB_defined_getpagesize_function |
f4c79b3c LC |
800 | static inline int |
801 | getpagesize () | |
802 | { | |
803 | return _gl_getpagesize (); | |
804 | } | |
49114fd4 LC |
805 | # define GNULIB_defined_getpagesize_function 1 |
806 | # endif | |
9b36a80c LC |
807 | # endif |
808 | # endif | |
809 | # endif | |
f4c79b3c LC |
810 | /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */ |
811 | _GL_CXXALIAS_SYS_CAST (getpagesize, int, (void)); | |
9b36a80c | 812 | # endif |
a927b6c1 | 813 | # if @HAVE_DECL_GETPAGESIZE@ |
f4c79b3c | 814 | _GL_CXXALIASWARN (getpagesize); |
a927b6c1 | 815 | # endif |
9b36a80c LC |
816 | #elif defined GNULIB_POSIXCHECK |
817 | # undef getpagesize | |
61cd9dc9 LC |
818 | # if HAVE_RAW_DECL_GETPAGESIZE |
819 | _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - " | |
820 | "use gnulib module getpagesize for portability"); | |
821 | # endif | |
9b36a80c LC |
822 | #endif |
823 | ||
824 | ||
825 | #if @GNULIB_GETUSERSHELL@ | |
9b36a80c LC |
826 | /* Return the next valid login shell on the system, or NULL when the end of |
827 | the list has been reached. */ | |
a927b6c1 | 828 | # if !@HAVE_DECL_GETUSERSHELL@ |
f4c79b3c | 829 | _GL_FUNCDECL_SYS (getusershell, char *, (void)); |
9b36a80c | 830 | # endif |
f4c79b3c LC |
831 | _GL_CXXALIAS_SYS (getusershell, char *, (void)); |
832 | _GL_CXXALIASWARN (getusershell); | |
9b36a80c LC |
833 | #elif defined GNULIB_POSIXCHECK |
834 | # undef getusershell | |
61cd9dc9 LC |
835 | # if HAVE_RAW_DECL_GETUSERSHELL |
836 | _GL_WARN_ON_USE (getusershell, "getusershell is unportable - " | |
837 | "use gnulib module getusershell for portability"); | |
838 | # endif | |
f4c79b3c LC |
839 | #endif |
840 | ||
841 | #if @GNULIB_GETUSERSHELL@ | |
842 | /* Rewind to pointer that is advanced at each getusershell() call. */ | |
a927b6c1 | 843 | # if !@HAVE_DECL_GETUSERSHELL@ |
f4c79b3c LC |
844 | _GL_FUNCDECL_SYS (setusershell, void, (void)); |
845 | # endif | |
846 | _GL_CXXALIAS_SYS (setusershell, void, (void)); | |
847 | _GL_CXXALIASWARN (setusershell); | |
848 | #elif defined GNULIB_POSIXCHECK | |
9b36a80c | 849 | # undef setusershell |
61cd9dc9 LC |
850 | # if HAVE_RAW_DECL_SETUSERSHELL |
851 | _GL_WARN_ON_USE (setusershell, "setusershell is unportable - " | |
852 | "use gnulib module getusershell for portability"); | |
853 | # endif | |
f4c79b3c LC |
854 | #endif |
855 | ||
856 | #if @GNULIB_GETUSERSHELL@ | |
857 | /* Free the pointer that is advanced at each getusershell() call and | |
858 | associated resources. */ | |
a927b6c1 | 859 | # if !@HAVE_DECL_GETUSERSHELL@ |
f4c79b3c LC |
860 | _GL_FUNCDECL_SYS (endusershell, void, (void)); |
861 | # endif | |
862 | _GL_CXXALIAS_SYS (endusershell, void, (void)); | |
863 | _GL_CXXALIASWARN (endusershell); | |
864 | #elif defined GNULIB_POSIXCHECK | |
9b36a80c | 865 | # undef endusershell |
61cd9dc9 LC |
866 | # if HAVE_RAW_DECL_ENDUSERSHELL |
867 | _GL_WARN_ON_USE (endusershell, "endusershell is unportable - " | |
868 | "use gnulib module getusershell for portability"); | |
869 | # endif | |
9b36a80c LC |
870 | #endif |
871 | ||
872 | ||
873 | #if @GNULIB_LCHOWN@ | |
9b36a80c LC |
874 | /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE |
875 | to GID (if GID is not -1). Do not follow symbolic links. | |
876 | Return 0 if successful, otherwise -1 and errno set. | |
877 | See the POSIX:2001 specification | |
878 | <http://www.opengroup.org/susv3xsh/lchown.html>. */ | |
f4c79b3c LC |
879 | # if @REPLACE_LCHOWN@ |
880 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
881 | # undef lchown | |
882 | # define lchown rpl_lchown | |
883 | # endif | |
884 | _GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group) | |
885 | _GL_ARG_NONNULL ((1))); | |
886 | _GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)); | |
887 | # else | |
888 | # if !@HAVE_LCHOWN@ | |
889 | _GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group) | |
890 | _GL_ARG_NONNULL ((1))); | |
891 | # endif | |
892 | _GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)); | |
9b36a80c | 893 | # endif |
f4c79b3c | 894 | _GL_CXXALIASWARN (lchown); |
9b36a80c LC |
895 | #elif defined GNULIB_POSIXCHECK |
896 | # undef lchown | |
61cd9dc9 LC |
897 | # if HAVE_RAW_DECL_LCHOWN |
898 | _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - " | |
899 | "use gnulib module lchown for portability"); | |
900 | # endif | |
9b36a80c LC |
901 | #endif |
902 | ||
903 | ||
f240aacb LC |
904 | #if @GNULIB_LINK@ |
905 | /* Create a new hard link for an existing file. | |
906 | Return 0 if successful, otherwise -1 and errno set. | |
907 | See POSIX:2001 specification | |
908 | <http://www.opengroup.org/susv3xsh/link.html>. */ | |
f4c79b3c LC |
909 | # if @REPLACE_LINK@ |
910 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
911 | # define link rpl_link | |
912 | # endif | |
913 | _GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2) | |
914 | _GL_ARG_NONNULL ((1, 2))); | |
915 | _GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2)); | |
916 | # else | |
917 | # if !@HAVE_LINK@ | |
918 | _GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2) | |
919 | _GL_ARG_NONNULL ((1, 2))); | |
920 | # endif | |
921 | _GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2)); | |
f240aacb | 922 | # endif |
f4c79b3c | 923 | _GL_CXXALIASWARN (link); |
f240aacb LC |
924 | #elif defined GNULIB_POSIXCHECK |
925 | # undef link | |
61cd9dc9 LC |
926 | # if HAVE_RAW_DECL_LINK |
927 | _GL_WARN_ON_USE (link, "link is unportable - " | |
928 | "use gnulib module link for portability"); | |
929 | # endif | |
f240aacb LC |
930 | #endif |
931 | ||
f4c79b3c | 932 | |
8912421c | 933 | #if @GNULIB_LINKAT@ |
8912421c LC |
934 | /* Create a new hard link for an existing file, relative to two |
935 | directories. FLAG controls whether symlinks are followed. | |
936 | Return 0 if successful, otherwise -1 and errno set. */ | |
f4c79b3c LC |
937 | # if @REPLACE_LINKAT@ |
938 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
939 | # undef linkat | |
940 | # define linkat rpl_linkat | |
941 | # endif | |
942 | _GL_FUNCDECL_RPL (linkat, int, | |
943 | (int fd1, const char *path1, int fd2, const char *path2, | |
1cd4fffc | 944 | int flag) |
f4c79b3c LC |
945 | _GL_ARG_NONNULL ((2, 4))); |
946 | _GL_CXXALIAS_RPL (linkat, int, | |
947 | (int fd1, const char *path1, int fd2, const char *path2, | |
948 | int flag)); | |
949 | # else | |
950 | # if !@HAVE_LINKAT@ | |
951 | _GL_FUNCDECL_SYS (linkat, int, | |
952 | (int fd1, const char *path1, int fd2, const char *path2, | |
953 | int flag) | |
954 | _GL_ARG_NONNULL ((2, 4))); | |
955 | # endif | |
956 | _GL_CXXALIAS_SYS (linkat, int, | |
957 | (int fd1, const char *path1, int fd2, const char *path2, | |
958 | int flag)); | |
8912421c | 959 | # endif |
f4c79b3c | 960 | _GL_CXXALIASWARN (linkat); |
8912421c LC |
961 | #elif defined GNULIB_POSIXCHECK |
962 | # undef linkat | |
61cd9dc9 LC |
963 | # if HAVE_RAW_DECL_LINKAT |
964 | _GL_WARN_ON_USE (linkat, "linkat is unportable - " | |
965 | "use gnulib module linkat for portability"); | |
966 | # endif | |
8912421c | 967 | #endif |
f240aacb | 968 | |
f4c79b3c | 969 | |
9b36a80c | 970 | #if @GNULIB_LSEEK@ |
9b36a80c LC |
971 | /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END. |
972 | Return the new offset if successful, otherwise -1 and errno set. | |
973 | See the POSIX:2001 specification | |
974 | <http://www.opengroup.org/susv3xsh/lseek.html>. */ | |
f4c79b3c LC |
975 | # if @REPLACE_LSEEK@ |
976 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
977 | # define lseek rpl_lseek | |
978 | # endif | |
979 | _GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence)); | |
980 | _GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence)); | |
981 | # else | |
982 | _GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence)); | |
9b36a80c | 983 | # endif |
f4c79b3c | 984 | _GL_CXXALIASWARN (lseek); |
9b36a80c LC |
985 | #elif defined GNULIB_POSIXCHECK |
986 | # undef lseek | |
61cd9dc9 LC |
987 | # if HAVE_RAW_DECL_LSEEK |
988 | _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some " | |
989 | "systems - use gnulib module lseek for portability"); | |
990 | # endif | |
9b36a80c LC |
991 | #endif |
992 | ||
993 | ||
ab4d62ad LC |
994 | #if @GNULIB_PIPE@ |
995 | /* Create a pipe, defaulting to O_BINARY mode. | |
996 | Store the read-end as fd[0] and the write-end as fd[1]. | |
997 | Return 0 upon success, or -1 with errno set upon failure. */ | |
998 | # if !@HAVE_PIPE@ | |
999 | _GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1))); | |
1000 | # endif | |
1001 | _GL_CXXALIAS_SYS (pipe, int, (int fd[2])); | |
1002 | _GL_CXXALIASWARN (pipe); | |
1003 | #elif defined GNULIB_POSIXCHECK | |
1004 | # undef pipe | |
1005 | # if HAVE_RAW_DECL_PIPE | |
1006 | _GL_WARN_ON_USE (pipe, "pipe is unportable - " | |
1007 | "use gnulib module pipe-posix for portability"); | |
1008 | # endif | |
1009 | #endif | |
1010 | ||
1011 | ||
8912421c LC |
1012 | #if @GNULIB_PIPE2@ |
1013 | /* Create a pipe, applying the given flags when opening the read-end of the | |
1014 | pipe and the write-end of the pipe. | |
1015 | The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>) | |
1016 | and O_TEXT, O_BINARY (defined in "binary-io.h"). | |
1017 | Store the read-end as fd[0] and the write-end as fd[1]. | |
1018 | Return 0 upon success, or -1 with errno set upon failure. | |
1019 | See also the Linux man page at | |
1020 | <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */ | |
1021 | # if @HAVE_PIPE2@ | |
f4c79b3c LC |
1022 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
1023 | # define pipe2 rpl_pipe2 | |
1024 | # endif | |
1025 | _GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); | |
1026 | _GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags)); | |
1027 | # else | |
1028 | _GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1))); | |
1029 | _GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags)); | |
8912421c | 1030 | # endif |
f4c79b3c | 1031 | _GL_CXXALIASWARN (pipe2); |
8912421c LC |
1032 | #elif defined GNULIB_POSIXCHECK |
1033 | # undef pipe2 | |
61cd9dc9 LC |
1034 | # if HAVE_RAW_DECL_PIPE2 |
1035 | _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - " | |
1036 | "use gnulib module pipe2 for portability"); | |
1037 | # endif | |
8912421c LC |
1038 | #endif |
1039 | ||
1040 | ||
1cd4fffc | 1041 | #if @GNULIB_PREAD@ |
1cd4fffc LC |
1042 | /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET. |
1043 | Return the number of bytes placed into BUF if successful, otherwise | |
1044 | set errno and return -1. 0 indicates EOF. See the POSIX:2001 | |
1045 | specification <http://www.opengroup.org/susv3xsh/pread.html>. */ | |
f4c79b3c LC |
1046 | # if @REPLACE_PREAD@ |
1047 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1048 | # define pread rpl_pread | |
1049 | # endif | |
1050 | _GL_FUNCDECL_RPL (pread, ssize_t, | |
1051 | (int fd, void *buf, size_t bufsize, off_t offset) | |
1052 | _GL_ARG_NONNULL ((2))); | |
1053 | _GL_CXXALIAS_RPL (pread, ssize_t, | |
1054 | (int fd, void *buf, size_t bufsize, off_t offset)); | |
1055 | # else | |
1056 | # if !@HAVE_PREAD@ | |
1057 | _GL_FUNCDECL_SYS (pread, ssize_t, | |
1058 | (int fd, void *buf, size_t bufsize, off_t offset) | |
1059 | _GL_ARG_NONNULL ((2))); | |
1060 | # endif | |
1061 | _GL_CXXALIAS_SYS (pread, ssize_t, | |
1062 | (int fd, void *buf, size_t bufsize, off_t offset)); | |
1cd4fffc | 1063 | # endif |
f4c79b3c | 1064 | _GL_CXXALIASWARN (pread); |
1cd4fffc LC |
1065 | #elif defined GNULIB_POSIXCHECK |
1066 | # undef pread | |
61cd9dc9 LC |
1067 | # if HAVE_RAW_DECL_PREAD |
1068 | _GL_WARN_ON_USE (pread, "pread is unportable - " | |
1069 | "use gnulib module pread for portability"); | |
1070 | # endif | |
1cd4fffc LC |
1071 | #endif |
1072 | ||
1073 | ||
a927b6c1 LC |
1074 | #if @GNULIB_PWRITE@ |
1075 | /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET. | |
1076 | Return the number of bytes written if successful, otherwise | |
1077 | set errno and return -1. 0 indicates nothing written. See the | |
1078 | POSIX:2001 specification | |
1079 | <http://www.opengroup.org/susv3xsh/pwrite.html>. */ | |
1080 | # if @REPLACE_PWRITE@ | |
1081 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1082 | # define pwrite rpl_pwrite | |
1083 | # endif | |
1084 | _GL_FUNCDECL_RPL (pwrite, ssize_t, | |
1085 | (int fd, const void *buf, size_t bufsize, off_t offset) | |
1086 | _GL_ARG_NONNULL ((2))); | |
1087 | _GL_CXXALIAS_RPL (pwrite, ssize_t, | |
1088 | (int fd, const void *buf, size_t bufsize, off_t offset)); | |
1089 | # else | |
1090 | # if !@HAVE_PWRITE@ | |
1091 | _GL_FUNCDECL_SYS (pwrite, ssize_t, | |
1092 | (int fd, const void *buf, size_t bufsize, off_t offset) | |
1093 | _GL_ARG_NONNULL ((2))); | |
1094 | # endif | |
1095 | _GL_CXXALIAS_SYS (pwrite, ssize_t, | |
1096 | (int fd, const void *buf, size_t bufsize, off_t offset)); | |
1097 | # endif | |
1098 | _GL_CXXALIASWARN (pwrite); | |
1099 | #elif defined GNULIB_POSIXCHECK | |
1100 | # undef pwrite | |
1101 | # if HAVE_RAW_DECL_PWRITE | |
1102 | _GL_WARN_ON_USE (pwrite, "pwrite is unportable - " | |
1103 | "use gnulib module pwrite for portability"); | |
1104 | # endif | |
1105 | #endif | |
1106 | ||
1107 | ||
9b36a80c LC |
1108 | #if @GNULIB_READLINK@ |
1109 | /* Read the contents of the symbolic link FILE and place the first BUFSIZE | |
1110 | bytes of it into BUF. Return the number of bytes placed into BUF if | |
1111 | successful, otherwise -1 and errno set. | |
1112 | See the POSIX:2001 specification | |
1113 | <http://www.opengroup.org/susv3xsh/readlink.html>. */ | |
f4c79b3c LC |
1114 | # if @REPLACE_READLINK@ |
1115 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1116 | # define readlink rpl_readlink | |
1117 | # endif | |
1118 | _GL_FUNCDECL_RPL (readlink, ssize_t, | |
1119 | (const char *file, char *buf, size_t bufsize) | |
1120 | _GL_ARG_NONNULL ((1, 2))); | |
1121 | _GL_CXXALIAS_RPL (readlink, ssize_t, | |
1122 | (const char *file, char *buf, size_t bufsize)); | |
1123 | # else | |
1124 | # if !@HAVE_READLINK@ | |
1125 | _GL_FUNCDECL_SYS (readlink, ssize_t, | |
1126 | (const char *file, char *buf, size_t bufsize) | |
1127 | _GL_ARG_NONNULL ((1, 2))); | |
1128 | # endif | |
1129 | _GL_CXXALIAS_SYS (readlink, ssize_t, | |
1130 | (const char *file, char *buf, size_t bufsize)); | |
9b36a80c | 1131 | # endif |
f4c79b3c | 1132 | _GL_CXXALIASWARN (readlink); |
9b36a80c LC |
1133 | #elif defined GNULIB_POSIXCHECK |
1134 | # undef readlink | |
61cd9dc9 LC |
1135 | # if HAVE_RAW_DECL_READLINK |
1136 | _GL_WARN_ON_USE (readlink, "readlink is unportable - " | |
1137 | "use gnulib module readlink for portability"); | |
1138 | # endif | |
9b36a80c LC |
1139 | #endif |
1140 | ||
1141 | ||
8912421c LC |
1142 | #if @GNULIB_READLINKAT@ |
1143 | # if !@HAVE_READLINKAT@ | |
f4c79b3c LC |
1144 | _GL_FUNCDECL_SYS (readlinkat, ssize_t, |
1145 | (int fd, char const *file, char *buf, size_t len) | |
1146 | _GL_ARG_NONNULL ((2, 3))); | |
8912421c | 1147 | # endif |
f4c79b3c LC |
1148 | _GL_CXXALIAS_SYS (readlinkat, ssize_t, |
1149 | (int fd, char const *file, char *buf, size_t len)); | |
1150 | _GL_CXXALIASWARN (readlinkat); | |
8912421c LC |
1151 | #elif defined GNULIB_POSIXCHECK |
1152 | # undef readlinkat | |
61cd9dc9 LC |
1153 | # if HAVE_RAW_DECL_READLINKAT |
1154 | _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - " | |
9157d901 | 1155 | "use gnulib module readlinkat for portability"); |
61cd9dc9 | 1156 | # endif |
8912421c LC |
1157 | #endif |
1158 | ||
1159 | ||
1160 | #if @GNULIB_RMDIR@ | |
8912421c | 1161 | /* Remove the directory DIR. */ |
f4c79b3c LC |
1162 | # if @REPLACE_RMDIR@ |
1163 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1164 | # define rmdir rpl_rmdir | |
1165 | # endif | |
1166 | _GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1))); | |
1167 | _GL_CXXALIAS_RPL (rmdir, int, (char const *name)); | |
1168 | # else | |
1169 | _GL_CXXALIAS_SYS (rmdir, int, (char const *name)); | |
8912421c | 1170 | # endif |
f4c79b3c | 1171 | _GL_CXXALIASWARN (rmdir); |
8912421c LC |
1172 | #elif defined GNULIB_POSIXCHECK |
1173 | # undef rmdir | |
61cd9dc9 LC |
1174 | # if HAVE_RAW_DECL_RMDIR |
1175 | _GL_WARN_ON_USE (rmdir, "rmdir is unportable - " | |
1176 | "use gnulib module rmdir for portability"); | |
1177 | # endif | |
8912421c LC |
1178 | #endif |
1179 | ||
1180 | ||
9b36a80c LC |
1181 | #if @GNULIB_SLEEP@ |
1182 | /* Pause the execution of the current thread for N seconds. | |
1183 | Returns the number of seconds left to sleep. | |
1184 | See the POSIX:2001 specification | |
1185 | <http://www.opengroup.org/susv3xsh/sleep.html>. */ | |
f4c79b3c LC |
1186 | # if @REPLACE_SLEEP@ |
1187 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1188 | # undef sleep | |
1189 | # define sleep rpl_sleep | |
1190 | # endif | |
1191 | _GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n)); | |
1192 | _GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n)); | |
1193 | # else | |
1194 | # if !@HAVE_SLEEP@ | |
1195 | _GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n)); | |
1196 | # endif | |
1197 | _GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n)); | |
9b36a80c | 1198 | # endif |
f4c79b3c | 1199 | _GL_CXXALIASWARN (sleep); |
9b36a80c LC |
1200 | #elif defined GNULIB_POSIXCHECK |
1201 | # undef sleep | |
61cd9dc9 LC |
1202 | # if HAVE_RAW_DECL_SLEEP |
1203 | _GL_WARN_ON_USE (sleep, "sleep is unportable - " | |
1204 | "use gnulib module sleep for portability"); | |
1205 | # endif | |
9b36a80c LC |
1206 | #endif |
1207 | ||
1208 | ||
8912421c LC |
1209 | #if @GNULIB_SYMLINK@ |
1210 | # if @REPLACE_SYMLINK@ | |
f4c79b3c LC |
1211 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
1212 | # undef symlink | |
1213 | # define symlink rpl_symlink | |
1214 | # endif | |
1215 | _GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file) | |
1216 | _GL_ARG_NONNULL ((1, 2))); | |
1217 | _GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file)); | |
1218 | # else | |
1219 | # if !@HAVE_SYMLINK@ | |
1220 | _GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file) | |
1221 | _GL_ARG_NONNULL ((1, 2))); | |
1222 | # endif | |
1223 | _GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file)); | |
8912421c | 1224 | # endif |
f4c79b3c | 1225 | _GL_CXXALIASWARN (symlink); |
8912421c LC |
1226 | #elif defined GNULIB_POSIXCHECK |
1227 | # undef symlink | |
61cd9dc9 LC |
1228 | # if HAVE_RAW_DECL_SYMLINK |
1229 | _GL_WARN_ON_USE (symlink, "symlink is not portable - " | |
1230 | "use gnulib module symlink for portability"); | |
1231 | # endif | |
8912421c LC |
1232 | #endif |
1233 | ||
1234 | ||
1235 | #if @GNULIB_SYMLINKAT@ | |
1236 | # if !@HAVE_SYMLINKAT@ | |
f4c79b3c LC |
1237 | _GL_FUNCDECL_SYS (symlinkat, int, |
1238 | (char const *contents, int fd, char const *file) | |
1239 | _GL_ARG_NONNULL ((1, 3))); | |
8912421c | 1240 | # endif |
f4c79b3c LC |
1241 | _GL_CXXALIAS_SYS (symlinkat, int, |
1242 | (char const *contents, int fd, char const *file)); | |
1243 | _GL_CXXALIASWARN (symlinkat); | |
8912421c LC |
1244 | #elif defined GNULIB_POSIXCHECK |
1245 | # undef symlinkat | |
61cd9dc9 LC |
1246 | # if HAVE_RAW_DECL_SYMLINKAT |
1247 | _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - " | |
1248 | "use gnulib module symlinkat for portability"); | |
1249 | # endif | |
8912421c LC |
1250 | #endif |
1251 | ||
1252 | ||
a927b6c1 LC |
1253 | #if @GNULIB_TTYNAME_R@ |
1254 | /* Store at most BUFLEN characters of the pathname of the terminal FD is | |
1255 | open on in BUF. Return 0 on success, otherwise an error number. */ | |
1256 | # if @REPLACE_TTYNAME_R@ | |
1257 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1258 | # undef ttyname_r | |
1259 | # define ttyname_r rpl_ttyname_r | |
1260 | # endif | |
1261 | _GL_FUNCDECL_RPL (ttyname_r, int, | |
1262 | (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); | |
1263 | _GL_CXXALIAS_RPL (ttyname_r, int, | |
1264 | (int fd, char *buf, size_t buflen)); | |
1265 | # else | |
ab4d62ad | 1266 | # if !@HAVE_DECL_TTYNAME_R@ |
a927b6c1 LC |
1267 | _GL_FUNCDECL_SYS (ttyname_r, int, |
1268 | (int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2))); | |
1269 | # endif | |
1270 | _GL_CXXALIAS_SYS (ttyname_r, int, | |
1271 | (int fd, char *buf, size_t buflen)); | |
1272 | # endif | |
1273 | _GL_CXXALIASWARN (ttyname_r); | |
1274 | #elif defined GNULIB_POSIXCHECK | |
1275 | # undef ttyname_r | |
1276 | # if HAVE_RAW_DECL_TTYNAME_R | |
1277 | _GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - " | |
1278 | "use gnulib module ttyname_r for portability"); | |
1279 | # endif | |
1280 | #endif | |
1281 | ||
1282 | ||
8912421c LC |
1283 | #if @GNULIB_UNLINK@ |
1284 | # if @REPLACE_UNLINK@ | |
f4c79b3c LC |
1285 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
1286 | # undef unlink | |
1287 | # define unlink rpl_unlink | |
1288 | # endif | |
1289 | _GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1))); | |
1290 | _GL_CXXALIAS_RPL (unlink, int, (char const *file)); | |
1291 | # else | |
1292 | _GL_CXXALIAS_SYS (unlink, int, (char const *file)); | |
8912421c | 1293 | # endif |
f4c79b3c | 1294 | _GL_CXXALIASWARN (unlink); |
8912421c LC |
1295 | #elif defined GNULIB_POSIXCHECK |
1296 | # undef unlink | |
61cd9dc9 LC |
1297 | # if HAVE_RAW_DECL_UNLINK |
1298 | _GL_WARN_ON_USE (unlink, "unlink is not portable - " | |
1299 | "use gnulib module unlink for portability"); | |
1300 | # endif | |
8912421c LC |
1301 | #endif |
1302 | ||
1303 | ||
1304 | #if @GNULIB_UNLINKAT@ | |
1305 | # if @REPLACE_UNLINKAT@ | |
f4c79b3c LC |
1306 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
1307 | # undef unlinkat | |
1308 | # define unlinkat rpl_unlinkat | |
1309 | # endif | |
1310 | _GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag) | |
1311 | _GL_ARG_NONNULL ((2))); | |
1312 | _GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag)); | |
1313 | # else | |
1314 | # if !@HAVE_UNLINKAT@ | |
1315 | _GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag) | |
1316 | _GL_ARG_NONNULL ((2))); | |
1317 | # endif | |
1318 | _GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag)); | |
8912421c | 1319 | # endif |
f4c79b3c | 1320 | _GL_CXXALIASWARN (unlinkat); |
8912421c LC |
1321 | #elif defined GNULIB_POSIXCHECK |
1322 | # undef unlinkat | |
61cd9dc9 LC |
1323 | # if HAVE_RAW_DECL_UNLINKAT |
1324 | _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - " | |
1325 | "use gnulib module openat for portability"); | |
1326 | # endif | |
8912421c LC |
1327 | #endif |
1328 | ||
1329 | ||
414e4441 | 1330 | #if @GNULIB_USLEEP@ |
414e4441 LC |
1331 | /* Pause the execution of the current thread for N microseconds. |
1332 | Returns 0 on completion, or -1 on range error. | |
1333 | See the POSIX:2001 specification | |
1334 | <http://www.opengroup.org/susv3xsh/sleep.html>. */ | |
f4c79b3c LC |
1335 | # if @REPLACE_USLEEP@ |
1336 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1337 | # undef usleep | |
1338 | # define usleep rpl_usleep | |
1339 | # endif | |
1340 | _GL_FUNCDECL_RPL (usleep, int, (useconds_t n)); | |
1341 | _GL_CXXALIAS_RPL (usleep, int, (useconds_t n)); | |
1342 | # else | |
1343 | # if !@HAVE_USLEEP@ | |
1344 | _GL_FUNCDECL_SYS (usleep, int, (useconds_t n)); | |
1345 | # endif | |
1346 | _GL_CXXALIAS_SYS (usleep, int, (useconds_t n)); | |
414e4441 | 1347 | # endif |
f4c79b3c | 1348 | _GL_CXXALIASWARN (usleep); |
414e4441 LC |
1349 | #elif defined GNULIB_POSIXCHECK |
1350 | # undef usleep | |
61cd9dc9 LC |
1351 | # if HAVE_RAW_DECL_USLEEP |
1352 | _GL_WARN_ON_USE (usleep, "usleep is unportable - " | |
1353 | "use gnulib module usleep for portability"); | |
1354 | # endif | |
414e4441 LC |
1355 | #endif |
1356 | ||
1357 | ||
f4c79b3c | 1358 | #if @GNULIB_WRITE@ |
9b36a80c LC |
1359 | /* Write up to COUNT bytes starting at BUF to file descriptor FD. |
1360 | See the POSIX:2001 specification | |
1361 | <http://www.opengroup.org/susv3xsh/write.html>. */ | |
f4c79b3c LC |
1362 | # if @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@ |
1363 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
1364 | # undef write | |
1365 | # define write rpl_write | |
1366 | # endif | |
1367 | _GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count) | |
1368 | _GL_ARG_NONNULL ((2))); | |
1369 | _GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count)); | |
1370 | # else | |
a927b6c1 LC |
1371 | /* Need to cast, because on mingw, the third parameter is |
1372 | unsigned int count | |
1373 | and the return type is 'int'. */ | |
1374 | _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count)); | |
f4c79b3c LC |
1375 | # endif |
1376 | _GL_CXXALIASWARN (write); | |
9b36a80c LC |
1377 | #endif |
1378 | ||
1379 | ||
1380 | #endif /* _GL_UNISTD_H */ | |
1381 | #endif /* _GL_UNISTD_H */ |