Update to Gnulib v0.0-3448-g6078aa4 for its <netdb.h> fix.
[bpt/guile.git] / lib / unistd.in.h
1 /* Substitute for and wrapper around <unistd.h>.
2 Copyright (C) 2003-2010 Free Software Foundation, Inc.
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
18 #ifndef _GL_UNISTD_H
19
20 #if __GNUC__ >= 3
21 @PRAGMA_SYSTEM_HEADER@
22 #endif
23
24 /* The include_next requires a split double-inclusion guard. */
25 #if @HAVE_UNISTD_H@
26 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
27 #endif
28
29 #ifndef _GL_UNISTD_H
30 #define _GL_UNISTD_H
31
32 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
33 #include <stddef.h>
34
35 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
36 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
37 /* But avoid namespace pollution on glibc systems. */
38 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
39 || (@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK)) \
40 && ! defined __GLIBC__
41 # include <stdio.h>
42 #endif
43
44 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
45 /* But avoid namespace pollution on glibc systems. */
46 #if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && ! defined __GLIBC__
47 # include <fcntl.h>
48 #endif
49
50 /* mingw fails to declare _exit in <unistd.h>. */
51 /* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
52 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
53 /* But avoid namespace pollution on glibc systems. */
54 #ifndef __GLIBC__
55 # include <stdlib.h>
56 #endif
57
58 /* mingw declares getcwd in <io.h>, not in <unistd.h>. */
59 #if ((@GNULIB_GETCWD@ || defined GNULIB_POSIXCHECK) \
60 && ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
61 # include <io.h>
62 #endif
63
64 #if (@GNULIB_WRITE@ || @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
65 || @GNULIB_PREAD@ || defined GNULIB_POSIXCHECK)
66 /* Get ssize_t. */
67 # include <sys/types.h>
68 #endif
69
70 /* Get getopt(), optarg, optind, opterr, optopt.
71 But avoid namespace pollution on glibc systems. */
72 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
73 # include <getopt.h>
74 #endif
75
76 #if @GNULIB_GETHOSTNAME@
77 /* Get all possible declarations of gethostname(). */
78 # if @UNISTD_H_HAVE_WINSOCK2_H@
79 # include <winsock2.h>
80 # if !defined _GL_SYS_SOCKET_H
81 # undef socket
82 # define socket socket_used_without_including_sys_socket_h
83 # undef connect
84 # define connect connect_used_without_including_sys_socket_h
85 # undef accept
86 # define accept accept_used_without_including_sys_socket_h
87 # undef bind
88 # define bind bind_used_without_including_sys_socket_h
89 # undef getpeername
90 # define getpeername getpeername_used_without_including_sys_socket_h
91 # undef getsockname
92 # define getsockname getsockname_used_without_including_sys_socket_h
93 # undef getsockopt
94 # define getsockopt getsockopt_used_without_including_sys_socket_h
95 # undef listen
96 # define listen listen_used_without_including_sys_socket_h
97 # undef recv
98 # define recv recv_used_without_including_sys_socket_h
99 # undef send
100 # define send send_used_without_including_sys_socket_h
101 # undef recvfrom
102 # define recvfrom recvfrom_used_without_including_sys_socket_h
103 # undef sendto
104 # define sendto sendto_used_without_including_sys_socket_h
105 # undef setsockopt
106 # define setsockopt setsockopt_used_without_including_sys_socket_h
107 # undef shutdown
108 # define shutdown shutdown_used_without_including_sys_socket_h
109 # endif
110 # if !defined _GL_SYS_SELECT_H
111 # undef select
112 # define select select_used_without_including_sys_select_h
113 # endif
114 # endif
115 #endif
116
117 /* The definition of _GL_ARG_NONNULL is copied here. */
118
119 /* The definition of _GL_WARN_ON_USE is copied here. */
120
121
122 /* OS/2 EMX lacks these macros. */
123 #ifndef STDIN_FILENO
124 # define STDIN_FILENO 0
125 #endif
126 #ifndef STDOUT_FILENO
127 # define STDOUT_FILENO 1
128 #endif
129 #ifndef STDERR_FILENO
130 # define STDERR_FILENO 2
131 #endif
132
133 /* Ensure *_OK macros exist. */
134 #ifndef F_OK
135 # define F_OK 0
136 # define X_OK 1
137 # define W_OK 2
138 # define R_OK 4
139 #endif
140
141
142 /* Declare overridden functions. */
143
144 #ifdef __cplusplus
145 extern "C" {
146 #endif
147
148
149 #if @GNULIB_CHOWN@
150 # if @REPLACE_CHOWN@
151 # undef chown
152 # define chown rpl_chown
153 # endif
154 # if !@HAVE_CHOWN@ || @REPLACE_CHOWN@
155 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
156 to GID (if GID is not -1). Follow symbolic links.
157 Return 0 if successful, otherwise -1 and errno set.
158 See the POSIX:2001 specification
159 <http://www.opengroup.org/susv3xsh/chown.html>. */
160 extern int chown (const char *file, uid_t uid, gid_t gid)
161 _GL_ARG_NONNULL ((1));
162 # endif
163 #elif defined GNULIB_POSIXCHECK
164 # undef chown
165 # if HAVE_RAW_DECL_CHOWN
166 _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
167 "doesn't treat a uid or gid of -1 on some systems - "
168 "use gnulib module chown for portability");
169 # endif
170 #endif
171
172
173 #if @GNULIB_CLOSE@
174 # if @REPLACE_CLOSE@
175 /* Automatically included by modules that need a replacement for close. */
176 # undef close
177 # define close rpl_close
178 extern int close (int);
179 # endif
180 #elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
181 # undef close
182 # define close close_used_without_requesting_gnulib_module_close
183 #elif defined GNULIB_POSIXCHECK
184 # undef close
185 /* Assume close is always declared. */
186 _GL_WARN_ON_USE (close, "close does not portably work on sockets - "
187 "use gnulib module close for portability");
188 #endif
189
190
191 #if @REPLACE_DUP@
192 # define dup rpl_dup
193 extern int dup (int);
194 #endif
195
196
197 #if @GNULIB_DUP2@
198 # if @REPLACE_DUP2@
199 # define dup2 rpl_dup2
200 # endif
201 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
202 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
203 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
204 Return newfd if successful, otherwise -1 and errno set.
205 See the POSIX:2001 specification
206 <http://www.opengroup.org/susv3xsh/dup2.html>. */
207 extern int dup2 (int oldfd, int newfd);
208 # endif
209 #elif defined GNULIB_POSIXCHECK
210 # undef dup2
211 # if HAVE_RAW_DECL_DUP2
212 _GL_WARN_ON_USE (dup2, "dup2 is unportable - "
213 "use gnulib module dup2 for portability");
214 # endif
215 #endif
216
217
218 #if @GNULIB_DUP3@
219 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
220 specified flags.
221 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
222 and O_TEXT, O_BINARY (defined in "binary-io.h").
223 Close NEWFD first if it is open.
224 Return newfd if successful, otherwise -1 and errno set.
225 See the Linux man page at
226 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
227 # if @HAVE_DUP3@
228 # define dup3 rpl_dup3
229 # endif
230 extern int dup3 (int oldfd, int newfd, int flags);
231 #elif defined GNULIB_POSIXCHECK
232 # undef dup3
233 # if HAVE_RAW_DECL_DUP3
234 _GL_WARN_ON_USE (dup3, "dup3 is unportable - "
235 "use gnulib module dup3 for portability");
236 # endif
237 #endif
238
239
240 #if @GNULIB_ENVIRON@
241 # if !@HAVE_DECL_ENVIRON@
242 /* Set of environment variables and values. An array of strings of the form
243 "VARIABLE=VALUE", terminated with a NULL. */
244 # if defined __APPLE__ && defined __MACH__
245 # include <crt_externs.h>
246 # define environ (*_NSGetEnviron ())
247 # else
248 extern char **environ;
249 # endif
250 # endif
251 #elif defined GNULIB_POSIXCHECK
252 # if HAVE_RAW_DECL_ENVIRON
253 static inline char ***
254 rpl_environ (void)
255 {
256 return &environ;
257 }
258 _GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
259 "use gnulib module environ for portability");
260 # undef environ
261 # define environ (*rpl_environ ())
262 # endif
263 #endif
264
265
266 #if @GNULIB_EUIDACCESS@
267 # if !@HAVE_EUIDACCESS@
268 /* Like access(), except that it uses the effective user id and group id of
269 the current process. */
270 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
271 # endif
272 #elif defined GNULIB_POSIXCHECK
273 # undef euidaccess
274 # if HAVE_RAW_DECL_EUIDACCESS
275 _GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
276 "use gnulib module euidaccess for portability");
277 # endif
278 #endif
279
280
281 #if @GNULIB_FACCESSAT@
282 # if !@HAVE_FACCESSAT@
283 extern int faccessat (int fd, char const *file, int mode, int flag)
284 _GL_ARG_NONNULL ((2));
285 # endif
286 #elif defined GNULIB_POSIXCHECK
287 # undef faccessat
288 # if HAVE_RAW_DECL_FACCESSAT
289 _GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
290 "use gnulib module faccessat for portability");
291 # endif
292 #endif
293
294
295 #if @GNULIB_FCHDIR@
296 # if @REPLACE_FCHDIR@
297 /* Change the process' current working directory to the directory on which
298 the given file descriptor is open.
299 Return 0 if successful, otherwise -1 and errno set.
300 See the POSIX:2001 specification
301 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
302 extern int fchdir (int /*fd*/);
303
304 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
305 extern int _gl_register_fd (int fd, const char *filename)
306 _GL_ARG_NONNULL ((2));
307 extern void _gl_unregister_fd (int fd);
308 extern int _gl_register_dup (int oldfd, int newfd);
309 extern const char *_gl_directory_name (int fd);
310
311 # endif
312 #elif defined GNULIB_POSIXCHECK
313 # undef fchdir
314 # if HAVE_RAW_DECL_FCHDIR
315 _GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
316 "use gnulib module fchdir for portability");
317 # endif
318 #endif
319
320
321 #if @GNULIB_FCHOWNAT@
322 # if @REPLACE_FCHOWNAT@
323 # undef fchownat
324 # define fchownat rpl_fchownat
325 # endif
326 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
327 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
328 _GL_ARG_NONNULL ((2));
329 # endif
330 #elif defined GNULIB_POSIXCHECK
331 # undef fchownat
332 # if HAVE_RAW_DECL_FCHOWNAT
333 _GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
334 "use gnulib module openat for portability");
335 # endif
336 #endif
337
338
339 #if @GNULIB_FSYNC@
340 /* Synchronize changes to a file.
341 Return 0 if successful, otherwise -1 and errno set.
342 See POSIX:2001 specification
343 <http://www.opengroup.org/susv3xsh/fsync.html>. */
344 # if !@HAVE_FSYNC@
345 extern int fsync (int fd);
346 # endif
347 #elif defined GNULIB_POSIXCHECK
348 # undef fsync
349 # if HAVE_RAW_DECL_FSYNC
350 _GL_WARN_ON_USE (fsync, "fsync is unportable - "
351 "use gnulib module fsync for portability");
352 # endif
353 #endif
354
355
356 #if @GNULIB_FTRUNCATE@
357 # if !@HAVE_FTRUNCATE@
358 /* Change the size of the file to which FD is opened to become equal to LENGTH.
359 Return 0 if successful, otherwise -1 and errno set.
360 See the POSIX:2001 specification
361 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
362 extern int ftruncate (int fd, off_t length);
363 # endif
364 #elif defined GNULIB_POSIXCHECK
365 # undef ftruncate
366 # if HAVE_RAW_DECL_FTRUNCATE
367 _GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
368 "use gnulib module ftruncate for portability");
369 # endif
370 #endif
371
372
373 #if @GNULIB_GETCWD@
374 # if @REPLACE_GETCWD@
375 /* Get the name of the current working directory, and put it in SIZE bytes
376 of BUF.
377 Return BUF if successful, or NULL if the directory couldn't be determined
378 or SIZE was too small.
379 See the POSIX:2001 specification
380 <http://www.opengroup.org/susv3xsh/getcwd.html>.
381 Additionally, the gnulib module 'getcwd' guarantees the following GNU
382 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
383 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
384 necessary. */
385 # define getcwd rpl_getcwd
386 extern char * getcwd (char *buf, size_t size);
387 # endif
388 #elif defined GNULIB_POSIXCHECK
389 # undef getcwd
390 # if HAVE_RAW_DECL_GETCWD
391 _GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
392 "use gnulib module getcwd for portability");
393 # endif
394 #endif
395
396
397 #if @GNULIB_GETDOMAINNAME@
398 /* Return the NIS domain name of the machine.
399 WARNING! The NIS domain name is unrelated to the fully qualified host name
400 of the machine. It is also unrelated to email addresses.
401 WARNING! The NIS domain name is usually the empty string or "(none)" when
402 not using NIS.
403
404 Put up to LEN bytes of the NIS domain name into NAME.
405 Null terminate it if the name is shorter than LEN.
406 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
407 Return 0 if successful, otherwise set errno and return -1. */
408 # if !@HAVE_GETDOMAINNAME@
409 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
410 # endif
411 #elif defined GNULIB_POSIXCHECK
412 # undef getdomainname
413 # if HAVE_RAW_DECL_GETDOMAINNAME
414 _GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
415 "use gnulib module getdomainname for portability");
416 # endif
417 #endif
418
419
420 #if @GNULIB_GETDTABLESIZE@
421 # if !@HAVE_GETDTABLESIZE@
422 /* Return the maximum number of file descriptors in the current process.
423 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
424 extern int getdtablesize (void);
425 # endif
426 #elif defined GNULIB_POSIXCHECK
427 # undef getdtablesize
428 # if HAVE_RAW_DECL_GETDTABLESIZE
429 _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
430 "use gnulib module getdtablesize for portability");
431 # endif
432 #endif
433
434
435 #if @GNULIB_GETGROUPS@
436 # if @REPLACE_GETGROUPS@
437 # undef getgroups
438 # define getgroups rpl_getgroups
439 # endif
440 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
441 /* Return the supplemental groups that the current process belongs to.
442 It is unspecified whether the effective group id is in the list.
443 If N is 0, return the group count; otherwise, N describes how many
444 entries are available in GROUPS. Return -1 and set errno if N is
445 not 0 and not large enough. Fails with ENOSYS on some systems. */
446 int getgroups (int n, gid_t *groups);
447 # endif
448 #elif defined GNULIB_POSIXCHECK
449 # undef getgroups
450 # if HAVE_RAW_DECL_GETGROUPS
451 _GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
452 "use gnulib module getgroups for portability");
453 # endif
454 #endif
455
456
457 #if @GNULIB_GETHOSTNAME@
458 /* Return the standard host name of the machine.
459 WARNING! The host name may or may not be fully qualified.
460
461 Put up to LEN bytes of the host name into NAME.
462 Null terminate it if the name is shorter than LEN.
463 If the host name is longer than LEN, set errno = EINVAL and return -1.
464 Return 0 if successful, otherwise set errno and return -1. */
465 # if @UNISTD_H_HAVE_WINSOCK2_H@
466 # undef gethostname
467 # define gethostname rpl_gethostname
468 # endif
469 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
470 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
471 # endif
472 #elif @UNISTD_H_HAVE_WINSOCK2_H@
473 # undef gethostname
474 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
475 #elif defined GNULIB_POSIXCHECK
476 # undef gethostname
477 # if HAVE_RAW_DECL_GETHOSTNAME
478 _GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
479 "use gnulib module gethostname for portability");
480 # endif
481 #endif
482
483
484 #if @GNULIB_GETLOGIN@
485 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
486 returns NULL with errno set.
487
488 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
489
490 Most programs don't need to use this function, because the information is
491 available through environment variables:
492 ${LOGNAME-$USER} on Unix platforms,
493 $USERNAME on native Windows platforms.
494 */
495 # if !@HAVE_GETLOGIN@
496 extern char *getlogin (void);
497 # endif
498 #elif defined GNULIB_POSIXCHECK
499 # undef getlogin
500 # if HAVE_RAW_DECL_GETLOGIN
501 _GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
502 "use gnulib module getlogin for portability");
503 # endif
504 #endif
505
506
507 #if @GNULIB_GETLOGIN_R@
508 /* Copies the user's login name to NAME.
509 The array pointed to by NAME has room for SIZE bytes.
510
511 Returns 0 if successful. Upon error, an error number is returned, or -1 in
512 the case that the login name cannot be found but no specific error is
513 provided (this case is hopefully rare but is left open by the POSIX spec).
514
515 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
516
517 Most programs don't need to use this function, because the information is
518 available through environment variables:
519 ${LOGNAME-$USER} on Unix platforms,
520 $USERNAME on native Windows platforms.
521 */
522 # if !@HAVE_DECL_GETLOGIN_R@
523 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
524 # endif
525 #elif defined GNULIB_POSIXCHECK
526 # undef getlogin_r
527 # if HAVE_RAW_DECL_GETLOGIN_R
528 _GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
529 "use gnulib module getlogin_r for portability");
530 # endif
531 #endif
532
533
534 #if @GNULIB_GETPAGESIZE@
535 # if @REPLACE_GETPAGESIZE@
536 # define getpagesize rpl_getpagesize
537 extern int getpagesize (void);
538 # elif !@HAVE_GETPAGESIZE@
539 /* This is for POSIX systems. */
540 # if !defined getpagesize && defined _SC_PAGESIZE
541 # if ! (defined __VMS && __VMS_VER < 70000000)
542 # define getpagesize() sysconf (_SC_PAGESIZE)
543 # endif
544 # endif
545 /* This is for older VMS. */
546 # if !defined getpagesize && defined __VMS
547 # ifdef __ALPHA
548 # define getpagesize() 8192
549 # else
550 # define getpagesize() 512
551 # endif
552 # endif
553 /* This is for BeOS. */
554 # if !defined getpagesize && @HAVE_OS_H@
555 # include <OS.h>
556 # if defined B_PAGE_SIZE
557 # define getpagesize() B_PAGE_SIZE
558 # endif
559 # endif
560 /* This is for AmigaOS4.0. */
561 # if !defined getpagesize && defined __amigaos4__
562 # define getpagesize() 2048
563 # endif
564 /* This is for older Unix systems. */
565 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
566 # include <sys/param.h>
567 # ifdef EXEC_PAGESIZE
568 # define getpagesize() EXEC_PAGESIZE
569 # else
570 # ifdef NBPG
571 # ifndef CLSIZE
572 # define CLSIZE 1
573 # endif
574 # define getpagesize() (NBPG * CLSIZE)
575 # else
576 # ifdef NBPC
577 # define getpagesize() NBPC
578 # endif
579 # endif
580 # endif
581 # endif
582 # endif
583 #elif defined GNULIB_POSIXCHECK
584 # undef getpagesize
585 # if HAVE_RAW_DECL_GETPAGESIZE
586 _GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
587 "use gnulib module getpagesize for portability");
588 # endif
589 #endif
590
591
592 #if @GNULIB_GETUSERSHELL@
593 # if !@HAVE_GETUSERSHELL@
594 /* Return the next valid login shell on the system, or NULL when the end of
595 the list has been reached. */
596 extern char *getusershell (void);
597 /* Rewind to pointer that is advanced at each getusershell() call. */
598 extern void setusershell (void);
599 /* Free the pointer that is advanced at each getusershell() call and
600 associated resources. */
601 extern void endusershell (void);
602 # endif
603 #elif defined GNULIB_POSIXCHECK
604 # undef getusershell
605 # if HAVE_RAW_DECL_GETUSERSHELL
606 _GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
607 "use gnulib module getusershell for portability");
608 # endif
609 # undef setusershell
610 # if HAVE_RAW_DECL_SETUSERSHELL
611 _GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
612 "use gnulib module getusershell for portability");
613 # endif
614 # undef endusershell
615 # if HAVE_RAW_DECL_ENDUSERSHELL
616 _GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
617 "use gnulib module getusershell for portability");
618 # endif
619 #endif
620
621
622 #if @GNULIB_LCHOWN@
623 # if @REPLACE_LCHOWN@
624 # undef lchown
625 # define lchown rpl_lchown
626 # endif
627 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
628 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
629 to GID (if GID is not -1). Do not follow symbolic links.
630 Return 0 if successful, otherwise -1 and errno set.
631 See the POSIX:2001 specification
632 <http://www.opengroup.org/susv3xsh/lchown.html>. */
633 extern int lchown (char const *file, uid_t owner, gid_t group)
634 _GL_ARG_NONNULL ((1));
635 # endif
636 #elif defined GNULIB_POSIXCHECK
637 # undef lchown
638 # if HAVE_RAW_DECL_LCHOWN
639 _GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
640 "use gnulib module lchown for portability");
641 # endif
642 #endif
643
644
645 #if @GNULIB_LINK@
646 # if @REPLACE_LINK@
647 # define link rpl_link
648 # endif
649 /* Create a new hard link for an existing file.
650 Return 0 if successful, otherwise -1 and errno set.
651 See POSIX:2001 specification
652 <http://www.opengroup.org/susv3xsh/link.html>. */
653 # if !@HAVE_LINK@ || @REPLACE_LINK@
654 extern int link (const char *path1, const char *path2)
655 _GL_ARG_NONNULL ((1, 2));
656 # endif
657 #elif defined GNULIB_POSIXCHECK
658 # undef link
659 # if HAVE_RAW_DECL_LINK
660 _GL_WARN_ON_USE (link, "link is unportable - "
661 "use gnulib module link for portability");
662 # endif
663 #endif
664
665 #if @GNULIB_LINKAT@
666 # if @REPLACE_LINKAT@
667 # undef linkat
668 # define linkat rpl_linkat
669 # endif
670 /* Create a new hard link for an existing file, relative to two
671 directories. FLAG controls whether symlinks are followed.
672 Return 0 if successful, otherwise -1 and errno set. */
673 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
674 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
675 int flag)
676 _GL_ARG_NONNULL ((2, 4));
677 # endif
678 #elif defined GNULIB_POSIXCHECK
679 # undef linkat
680 # if HAVE_RAW_DECL_LINKAT
681 _GL_WARN_ON_USE (linkat, "linkat is unportable - "
682 "use gnulib module linkat for portability");
683 # endif
684 #endif
685
686 #if @GNULIB_LSEEK@
687 # if @REPLACE_LSEEK@
688 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
689 Return the new offset if successful, otherwise -1 and errno set.
690 See the POSIX:2001 specification
691 <http://www.opengroup.org/susv3xsh/lseek.html>. */
692 # define lseek rpl_lseek
693 extern off_t lseek (int fd, off_t offset, int whence);
694 # endif
695 #elif defined GNULIB_POSIXCHECK
696 # undef lseek
697 # if HAVE_RAW_DECL_LSEEK
698 _GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
699 "systems - use gnulib module lseek for portability");
700 # endif
701 #endif
702
703
704 #if @GNULIB_PIPE2@
705 /* Create a pipe, applying the given flags when opening the read-end of the
706 pipe and the write-end of the pipe.
707 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
708 and O_TEXT, O_BINARY (defined in "binary-io.h").
709 Store the read-end as fd[0] and the write-end as fd[1].
710 Return 0 upon success, or -1 with errno set upon failure.
711 See also the Linux man page at
712 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
713 # if @HAVE_PIPE2@
714 # define pipe2 rpl_pipe2
715 # endif
716 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
717 #elif defined GNULIB_POSIXCHECK
718 # undef pipe2
719 # if HAVE_RAW_DECL_PIPE2
720 _GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
721 "use gnulib module pipe2 for portability");
722 # endif
723 #endif
724
725
726 #if @GNULIB_PREAD@
727 # if @REPLACE_PREAD@
728 # define pread rpl_pread
729 # endif
730 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
731 Return the number of bytes placed into BUF if successful, otherwise
732 set errno and return -1. 0 indicates EOF. See the POSIX:2001
733 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
734 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
735 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
736 _GL_ARG_NONNULL ((2));
737 # endif
738 #elif defined GNULIB_POSIXCHECK
739 # undef pread
740 # if HAVE_RAW_DECL_PREAD
741 _GL_WARN_ON_USE (pread, "pread is unportable - "
742 "use gnulib module pread for portability");
743 # endif
744 #endif
745
746
747 #if @GNULIB_READLINK@
748 # if @REPLACE_READLINK@
749 # define readlink rpl_readlink
750 # endif
751 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
752 bytes of it into BUF. Return the number of bytes placed into BUF if
753 successful, otherwise -1 and errno set.
754 See the POSIX:2001 specification
755 <http://www.opengroup.org/susv3xsh/readlink.html>. */
756 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
757 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
758 _GL_ARG_NONNULL ((1, 2));
759 # endif
760 #elif defined GNULIB_POSIXCHECK
761 # undef readlink
762 # if HAVE_RAW_DECL_READLINK
763 _GL_WARN_ON_USE (readlink, "readlink is unportable - "
764 "use gnulib module readlink for portability");
765 # endif
766 #endif
767
768
769 #if @GNULIB_READLINKAT@
770 # if !@HAVE_READLINKAT@
771 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
772 _GL_ARG_NONNULL ((2, 3));
773 # endif
774 #elif defined GNULIB_POSIXCHECK
775 # undef readlinkat
776 # if HAVE_RAW_DECL_READLINKAT
777 _GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
778 "use gnulib module symlinkat for portability");
779 # endif
780 #endif
781
782
783 #if @GNULIB_RMDIR@
784 # if @REPLACE_RMDIR@
785 # define rmdir rpl_rmdir
786 /* Remove the directory DIR. */
787 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
788 # endif
789 #elif defined GNULIB_POSIXCHECK
790 # undef rmdir
791 # if HAVE_RAW_DECL_RMDIR
792 _GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
793 "use gnulib module rmdir for portability");
794 # endif
795 #endif
796
797
798 #if @GNULIB_SLEEP@
799 # if @REPLACE_SLEEP@
800 # undef sleep
801 # define sleep rpl_sleep
802 # endif
803 /* Pause the execution of the current thread for N seconds.
804 Returns the number of seconds left to sleep.
805 See the POSIX:2001 specification
806 <http://www.opengroup.org/susv3xsh/sleep.html>. */
807 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
808 extern unsigned int sleep (unsigned int n);
809 # endif
810 #elif defined GNULIB_POSIXCHECK
811 # undef sleep
812 # if HAVE_RAW_DECL_SLEEP
813 _GL_WARN_ON_USE (sleep, "sleep is unportable - "
814 "use gnulib module sleep for portability");
815 # endif
816 #endif
817
818
819 #if @GNULIB_SYMLINK@
820 # if @REPLACE_SYMLINK@
821 # undef symlink
822 # define symlink rpl_symlink
823 # endif
824 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
825 extern int symlink (char const *contents, char const *file)
826 _GL_ARG_NONNULL ((1, 2));
827 # endif
828 #elif defined GNULIB_POSIXCHECK
829 # undef symlink
830 # if HAVE_RAW_DECL_SYMLINK
831 _GL_WARN_ON_USE (symlink, "symlink is not portable - "
832 "use gnulib module symlink for portability");
833 # endif
834 #endif
835
836
837 #if @GNULIB_SYMLINKAT@
838 # if !@HAVE_SYMLINKAT@
839 extern int symlinkat (char const *contents, int fd, char const *file)
840 _GL_ARG_NONNULL ((1, 3));
841 # endif
842 #elif defined GNULIB_POSIXCHECK
843 # undef symlinkat
844 # if HAVE_RAW_DECL_SYMLINKAT
845 _GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
846 "use gnulib module symlinkat for portability");
847 # endif
848 #endif
849
850
851 #if @GNULIB_UNLINK@
852 # if @REPLACE_UNLINK@
853 # undef unlink
854 # define unlink rpl_unlink
855 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
856 # endif
857 #elif defined GNULIB_POSIXCHECK
858 # undef unlink
859 # if HAVE_RAW_DECL_UNLINK
860 _GL_WARN_ON_USE (unlink, "unlink is not portable - "
861 "use gnulib module unlink for portability");
862 # endif
863 #endif
864
865
866 #if @GNULIB_UNLINKAT@
867 # if @REPLACE_UNLINKAT@
868 # undef unlinkat
869 # define unlinkat rpl_unlinkat
870 # endif
871 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
872 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
873 # endif
874 #elif defined GNULIB_POSIXCHECK
875 # undef unlinkat
876 # if HAVE_RAW_DECL_UNLINKAT
877 _GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
878 "use gnulib module openat for portability");
879 # endif
880 #endif
881
882
883 #if @GNULIB_USLEEP@
884 # if @REPLACE_USLEEP@
885 # undef usleep
886 # define usleep rpl_usleep
887 # endif
888 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
889 /* Pause the execution of the current thread for N microseconds.
890 Returns 0 on completion, or -1 on range error.
891 See the POSIX:2001 specification
892 <http://www.opengroup.org/susv3xsh/sleep.html>. */
893 extern int usleep (useconds_t n);
894 # endif
895 #elif defined GNULIB_POSIXCHECK
896 # undef usleep
897 # if HAVE_RAW_DECL_USLEEP
898 _GL_WARN_ON_USE (usleep, "usleep is unportable - "
899 "use gnulib module usleep for portability");
900 # endif
901 #endif
902
903
904 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
905 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
906 See the POSIX:2001 specification
907 <http://www.opengroup.org/susv3xsh/write.html>. */
908 # undef write
909 # define write rpl_write
910 extern ssize_t write (int fd, const void *buf, size_t count)
911 _GL_ARG_NONNULL ((2));
912 #endif
913
914
915 #ifdef __cplusplus
916 }
917 #endif
918
919
920 #endif /* _GL_UNISTD_H */
921 #endif /* _GL_UNISTD_H */