comparison lib/unistd.in.h @ 434:b8bf63962a99 3.0

Added various generated files for release
author lost@l-w.ca
date Fri, 29 Oct 2010 19:20:39 -0600
parents
children
comparison
equal deleted inserted replaced
433:b142b473f0ee 434:b8bf63962a99
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 General Public License as published by
6 the Free Software Foundation; either version 3, 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 General Public License for more details.
13
14 You should have received a copy of the GNU 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_LINK_WARNING is copied here. */
118
119 /* The definition of _GL_ARG_NONNULL 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 # define chown(f,u,g) \
166 (GL_LINK_WARNING ("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 chown (f, u, g))
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 # define close(f) \
186 (GL_LINK_WARNING ("close does not portably work on sockets - " \
187 "use gnulib module close for portability"), \
188 close (f))
189 #endif
190
191
192 #if @REPLACE_DUP@
193 # define dup rpl_dup
194 extern int dup (int);
195 #endif
196
197
198 #if @GNULIB_DUP2@
199 # if @REPLACE_DUP2@
200 # define dup2 rpl_dup2
201 # endif
202 # if !@HAVE_DUP2@ || @REPLACE_DUP2@
203 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
204 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
205 Return newfd if successful, otherwise -1 and errno set.
206 See the POSIX:2001 specification
207 <http://www.opengroup.org/susv3xsh/dup2.html>. */
208 extern int dup2 (int oldfd, int newfd);
209 # endif
210 #elif defined GNULIB_POSIXCHECK
211 # undef dup2
212 # define dup2(o,n) \
213 (GL_LINK_WARNING ("dup2 is unportable - " \
214 "use gnulib module dup2 for portability"), \
215 dup2 (o, n))
216 #endif
217
218
219 #if @GNULIB_DUP3@
220 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
221 specified flags.
222 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
223 and O_TEXT, O_BINARY (defined in "binary-io.h").
224 Close NEWFD first if it is open.
225 Return newfd if successful, otherwise -1 and errno set.
226 See the Linux man page at
227 <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
228 # if @HAVE_DUP3@
229 # define dup3 rpl_dup3
230 # endif
231 extern int dup3 (int oldfd, int newfd, int flags);
232 #elif defined GNULIB_POSIXCHECK
233 # undef dup3
234 # define dup3(o,n,f) \
235 (GL_LINK_WARNING ("dup3 is unportable - " \
236 "use gnulib module dup3 for portability"), \
237 dup3 (o, n, f))
238 #endif
239
240
241 #if @GNULIB_ENVIRON@
242 # if !@HAVE_DECL_ENVIRON@
243 /* Set of environment variables and values. An array of strings of the form
244 "VARIABLE=VALUE", terminated with a NULL. */
245 # if defined __APPLE__ && defined __MACH__
246 # include <crt_externs.h>
247 # define environ (*_NSGetEnviron ())
248 # else
249 extern char **environ;
250 # endif
251 # endif
252 #elif defined GNULIB_POSIXCHECK
253 # undef environ
254 # define environ \
255 (GL_LINK_WARNING ("environ is unportable - " \
256 "use gnulib module environ for portability"), \
257 environ)
258 #endif
259
260
261 #if @GNULIB_EUIDACCESS@
262 # if !@HAVE_EUIDACCESS@
263 /* Like access(), except that it uses the effective user id and group id of
264 the current process. */
265 extern int euidaccess (const char *filename, int mode) _GL_ARG_NONNULL ((1));
266 # endif
267 #elif defined GNULIB_POSIXCHECK
268 # undef euidaccess
269 # define euidaccess(f,m) \
270 (GL_LINK_WARNING ("euidaccess is unportable - " \
271 "use gnulib module euidaccess for portability"), \
272 euidaccess (f, m))
273 #endif
274
275
276 #if @GNULIB_FACCESSAT@
277 # if !@HAVE_FACCESSAT@
278 extern int faccessat (int fd, char const *file, int mode, int flag)
279 _GL_ARG_NONNULL ((2));
280 # endif
281 #elif defined GNULIB_POSIXCHECK
282 # undef faccessat
283 # define faccessat(d,n,m,f) \
284 (GL_LINK_WARNING ("faccessat is not portable - " \
285 "use gnulib module faccessat for portability"), \
286 faccessat (d, n, m, f))
287 #endif
288
289
290 #if @GNULIB_FCHDIR@
291 # if @REPLACE_FCHDIR@
292 /* Change the process' current working directory to the directory on which
293 the given file descriptor is open.
294 Return 0 if successful, otherwise -1 and errno set.
295 See the POSIX:2001 specification
296 <http://www.opengroup.org/susv3xsh/fchdir.html>. */
297 extern int fchdir (int /*fd*/);
298
299 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
300 extern int _gl_register_fd (int fd, const char *filename)
301 _GL_ARG_NONNULL ((2));
302 extern void _gl_unregister_fd (int fd);
303 extern int _gl_register_dup (int oldfd, int newfd);
304 extern const char *_gl_directory_name (int fd);
305
306 # endif
307 #elif defined GNULIB_POSIXCHECK
308 # undef fchdir
309 # define fchdir(f) \
310 (GL_LINK_WARNING ("fchdir is unportable - " \
311 "use gnulib module fchdir for portability"), \
312 fchdir (f))
313 #endif
314
315
316 #if @GNULIB_FCHOWNAT@
317 # if @REPLACE_FCHOWNAT@
318 # undef fchownat
319 # define fchownat rpl_fchownat
320 # endif
321 # if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
322 extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag)
323 _GL_ARG_NONNULL ((2));
324 # endif
325 #elif defined GNULIB_POSIXCHECK
326 # undef fchownat
327 # define fchownat(d,n,o,g,f) \
328 (GL_LINK_WARNING ("fchownat is not portable - " \
329 "use gnulib module openat for portability"), \
330 fchownat (d, n, o, g, f))
331 #endif
332
333
334 #if @GNULIB_FSYNC@
335 /* Synchronize changes to a file.
336 Return 0 if successful, otherwise -1 and errno set.
337 See POSIX:2001 specification
338 <http://www.opengroup.org/susv3xsh/fsync.html>. */
339 # if !@HAVE_FSYNC@
340 extern int fsync (int fd);
341 # endif
342 #elif defined GNULIB_POSIXCHECK
343 # undef fsync
344 # define fsync(fd) \
345 (GL_LINK_WARNING ("fsync is unportable - " \
346 "use gnulib module fsync for portability"), \
347 fsync (fd))
348 #endif
349
350
351 #if @GNULIB_FTRUNCATE@
352 # if !@HAVE_FTRUNCATE@
353 /* Change the size of the file to which FD is opened to become equal to LENGTH.
354 Return 0 if successful, otherwise -1 and errno set.
355 See the POSIX:2001 specification
356 <http://www.opengroup.org/susv3xsh/ftruncate.html>. */
357 extern int ftruncate (int fd, off_t length);
358 # endif
359 #elif defined GNULIB_POSIXCHECK
360 # undef ftruncate
361 # define ftruncate(f,l) \
362 (GL_LINK_WARNING ("ftruncate is unportable - " \
363 "use gnulib module ftruncate for portability"), \
364 ftruncate (f, l))
365 #endif
366
367
368 #if @GNULIB_GETCWD@
369 # if @REPLACE_GETCWD@
370 /* Get the name of the current working directory, and put it in SIZE bytes
371 of BUF.
372 Return BUF if successful, or NULL if the directory couldn't be determined
373 or SIZE was too small.
374 See the POSIX:2001 specification
375 <http://www.opengroup.org/susv3xsh/getcwd.html>.
376 Additionally, the gnulib module 'getcwd' guarantees the following GNU
377 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
378 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
379 necessary. */
380 # define getcwd rpl_getcwd
381 extern char * getcwd (char *buf, size_t size);
382 # endif
383 #elif defined GNULIB_POSIXCHECK
384 # undef getcwd
385 # define getcwd(b,s) \
386 (GL_LINK_WARNING ("getcwd is unportable - " \
387 "use gnulib module getcwd for portability"), \
388 getcwd (b, s))
389 #endif
390
391
392 #if @GNULIB_GETDOMAINNAME@
393 /* Return the NIS domain name of the machine.
394 WARNING! The NIS domain name is unrelated to the fully qualified host name
395 of the machine. It is also unrelated to email addresses.
396 WARNING! The NIS domain name is usually the empty string or "(none)" when
397 not using NIS.
398
399 Put up to LEN bytes of the NIS domain name into NAME.
400 Null terminate it if the name is shorter than LEN.
401 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
402 Return 0 if successful, otherwise set errno and return -1. */
403 # if !@HAVE_GETDOMAINNAME@
404 extern int getdomainname(char *name, size_t len) _GL_ARG_NONNULL ((1));
405 # endif
406 #elif defined GNULIB_POSIXCHECK
407 # undef getdomainname
408 # define getdomainname(n,l) \
409 (GL_LINK_WARNING ("getdomainname is unportable - " \
410 "use gnulib module getdomainname for portability"), \
411 getdomainname (n, l))
412 #endif
413
414
415 #if @GNULIB_GETDTABLESIZE@
416 # if !@HAVE_GETDTABLESIZE@
417 /* Return the maximum number of file descriptors in the current process.
418 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
419 extern int getdtablesize (void);
420 # endif
421 #elif defined GNULIB_POSIXCHECK
422 # undef getdtablesize
423 # define getdtablesize() \
424 (GL_LINK_WARNING ("getdtablesize is unportable - " \
425 "use gnulib module getdtablesize for portability"), \
426 getdtablesize ())
427 #endif
428
429
430 #if @GNULIB_GETGROUPS@
431 # if @REPLACE_GETGROUPS@
432 # undef getgroups
433 # define getgroups rpl_getgroups
434 # endif
435 # if !@HAVE_GETGROUPS@ || @REPLACE_GETGROUPS@
436 /* Return the supplemental groups that the current process belongs to.
437 It is unspecified whether the effective group id is in the list.
438 If N is 0, return the group count; otherwise, N describes how many
439 entries are available in GROUPS. Return -1 and set errno if N is
440 not 0 and not large enough. Fails with ENOSYS on some systems. */
441 int getgroups (int n, gid_t *groups);
442 # endif
443 #elif defined GNULIB_POSIXCHECK
444 # undef getgroups
445 # define getgroups(n,g) \
446 (GL_LINK_WARNING ("getgroups is unportable - " \
447 "use gnulib module getgroups for portability"), \
448 getgroups (n, g))
449 #endif
450
451
452 #if @GNULIB_GETHOSTNAME@
453 /* Return the standard host name of the machine.
454 WARNING! The host name may or may not be fully qualified.
455
456 Put up to LEN bytes of the host name into NAME.
457 Null terminate it if the name is shorter than LEN.
458 If the host name is longer than LEN, set errno = EINVAL and return -1.
459 Return 0 if successful, otherwise set errno and return -1. */
460 # if @UNISTD_H_HAVE_WINSOCK2_H@
461 # undef gethostname
462 # define gethostname rpl_gethostname
463 # endif
464 # if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
465 extern int gethostname(char *name, size_t len) _GL_ARG_NONNULL ((1));
466 # endif
467 #elif @UNISTD_H_HAVE_WINSOCK2_H@
468 # undef gethostname
469 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
470 #elif defined GNULIB_POSIXCHECK
471 # undef gethostname
472 # define gethostname(n,l) \
473 (GL_LINK_WARNING ("gethostname is unportable - " \
474 "use gnulib module gethostname for portability"), \
475 gethostname (n, l))
476 #endif
477
478
479 #if @GNULIB_GETLOGIN_R@
480 /* Copies the user's login name to NAME.
481 The array pointed to by NAME has room for SIZE bytes.
482
483 Returns 0 if successful. Upon error, an error number is returned, or -1 in
484 the case that the login name cannot be found but no specific error is
485 provided (this case is hopefully rare but is left open by the POSIX spec).
486
487 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
488
489 Most programs don't need to use this function, because the information is
490 available through environment variables:
491 ${LOGNAME-$USER} on Unix platforms,
492 $USERNAME on native Windows platforms.
493 */
494 # if !@HAVE_DECL_GETLOGIN_R@
495 extern int getlogin_r (char *name, size_t size) _GL_ARG_NONNULL ((1));
496 # endif
497 #elif defined GNULIB_POSIXCHECK
498 # undef getlogin_r
499 # define getlogin_r(n,s) \
500 (GL_LINK_WARNING ("getlogin_r is unportable - " \
501 "use gnulib module getlogin_r for portability"), \
502 getlogin_r (n, s))
503 #endif
504
505
506 #if @GNULIB_GETPAGESIZE@
507 # if @REPLACE_GETPAGESIZE@
508 # define getpagesize rpl_getpagesize
509 extern int getpagesize (void);
510 # elif !@HAVE_GETPAGESIZE@
511 /* This is for POSIX systems. */
512 # if !defined getpagesize && defined _SC_PAGESIZE
513 # if ! (defined __VMS && __VMS_VER < 70000000)
514 # define getpagesize() sysconf (_SC_PAGESIZE)
515 # endif
516 # endif
517 /* This is for older VMS. */
518 # if !defined getpagesize && defined __VMS
519 # ifdef __ALPHA
520 # define getpagesize() 8192
521 # else
522 # define getpagesize() 512
523 # endif
524 # endif
525 /* This is for BeOS. */
526 # if !defined getpagesize && @HAVE_OS_H@
527 # include <OS.h>
528 # if defined B_PAGE_SIZE
529 # define getpagesize() B_PAGE_SIZE
530 # endif
531 # endif
532 /* This is for AmigaOS4.0. */
533 # if !defined getpagesize && defined __amigaos4__
534 # define getpagesize() 2048
535 # endif
536 /* This is for older Unix systems. */
537 # if !defined getpagesize && @HAVE_SYS_PARAM_H@
538 # include <sys/param.h>
539 # ifdef EXEC_PAGESIZE
540 # define getpagesize() EXEC_PAGESIZE
541 # else
542 # ifdef NBPG
543 # ifndef CLSIZE
544 # define CLSIZE 1
545 # endif
546 # define getpagesize() (NBPG * CLSIZE)
547 # else
548 # ifdef NBPC
549 # define getpagesize() NBPC
550 # endif
551 # endif
552 # endif
553 # endif
554 # endif
555 #elif defined GNULIB_POSIXCHECK
556 # undef getpagesize
557 # define getpagesize() \
558 (GL_LINK_WARNING ("getpagesize is unportable - " \
559 "use gnulib module getpagesize for portability"), \
560 getpagesize ())
561 #endif
562
563
564 #if @GNULIB_GETUSERSHELL@
565 # if !@HAVE_GETUSERSHELL@
566 /* Return the next valid login shell on the system, or NULL when the end of
567 the list has been reached. */
568 extern char *getusershell (void);
569 /* Rewind to pointer that is advanced at each getusershell() call. */
570 extern void setusershell (void);
571 /* Free the pointer that is advanced at each getusershell() call and
572 associated resources. */
573 extern void endusershell (void);
574 # endif
575 #elif defined GNULIB_POSIXCHECK
576 # undef getusershell
577 # define getusershell() \
578 (GL_LINK_WARNING ("getusershell is unportable - " \
579 "use gnulib module getusershell for portability"), \
580 getusershell ())
581 # undef setusershell
582 # define setusershell() \
583 (GL_LINK_WARNING ("setusershell is unportable - " \
584 "use gnulib module getusershell for portability"), \
585 setusershell ())
586 # undef endusershell
587 # define endusershell() \
588 (GL_LINK_WARNING ("endusershell is unportable - " \
589 "use gnulib module getusershell for portability"), \
590 endusershell ())
591 #endif
592
593
594 #if @GNULIB_LCHOWN@
595 # if @REPLACE_LCHOWN@
596 # undef lchown
597 # define lchown rpl_lchown
598 # endif
599 # if !@HAVE_LCHOWN@ || @REPLACE_LCHOWN@
600 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
601 to GID (if GID is not -1). Do not follow symbolic links.
602 Return 0 if successful, otherwise -1 and errno set.
603 See the POSIX:2001 specification
604 <http://www.opengroup.org/susv3xsh/lchown.html>. */
605 extern int lchown (char const *file, uid_t owner, gid_t group)
606 _GL_ARG_NONNULL ((1));
607 # endif
608 #elif defined GNULIB_POSIXCHECK
609 # undef lchown
610 # define lchown(f,u,g) \
611 (GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
612 "systems - use gnulib module lchown for portability"), \
613 lchown (f, u, g))
614 #endif
615
616
617 #if @GNULIB_LINK@
618 # if @REPLACE_LINK@
619 # define link rpl_link
620 # endif
621 /* Create a new hard link for an existing file.
622 Return 0 if successful, otherwise -1 and errno set.
623 See POSIX:2001 specification
624 <http://www.opengroup.org/susv3xsh/link.html>. */
625 # if !@HAVE_LINK@ || @REPLACE_LINK@
626 extern int link (const char *path1, const char *path2)
627 _GL_ARG_NONNULL ((1, 2));
628 # endif
629 #elif defined GNULIB_POSIXCHECK
630 # undef link
631 # define link(path1,path2) \
632 (GL_LINK_WARNING ("link is unportable - " \
633 "use gnulib module link for portability"), \
634 link (path1, path2))
635 #endif
636
637 #if @GNULIB_LINKAT@
638 # if @REPLACE_LINKAT@
639 # undef linkat
640 # define linkat rpl_linkat
641 # endif
642 /* Create a new hard link for an existing file, relative to two
643 directories. FLAG controls whether symlinks are followed.
644 Return 0 if successful, otherwise -1 and errno set. */
645 # if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
646 extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
647 int flag)
648 _GL_ARG_NONNULL ((2, 4));
649 # endif
650 #elif defined GNULIB_POSIXCHECK
651 # undef linkat
652 # define linkat(f1,path1,f2,path2,f) \
653 (GL_LINK_WARNING ("linkat is unportable - " \
654 "use gnulib module linkat for portability"), \
655 linkat (f1, path1, f2, path2,f))
656 #endif
657
658 #if @GNULIB_LSEEK@
659 # if @REPLACE_LSEEK@
660 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
661 Return the new offset if successful, otherwise -1 and errno set.
662 See the POSIX:2001 specification
663 <http://www.opengroup.org/susv3xsh/lseek.html>. */
664 # define lseek rpl_lseek
665 extern off_t lseek (int fd, off_t offset, int whence);
666 # endif
667 #elif defined GNULIB_POSIXCHECK
668 # undef lseek
669 # define lseek(f,o,w) \
670 (GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
671 "systems - use gnulib module lseek for portability"), \
672 lseek (f, o, w))
673 #endif
674
675
676 #if @GNULIB_PIPE2@
677 /* Create a pipe, applying the given flags when opening the read-end of the
678 pipe and the write-end of the pipe.
679 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
680 and O_TEXT, O_BINARY (defined in "binary-io.h").
681 Store the read-end as fd[0] and the write-end as fd[1].
682 Return 0 upon success, or -1 with errno set upon failure.
683 See also the Linux man page at
684 <http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
685 # if @HAVE_PIPE2@
686 # define pipe2 rpl_pipe2
687 # endif
688 extern int pipe2 (int fd[2], int flags) _GL_ARG_NONNULL ((1));
689 #elif defined GNULIB_POSIXCHECK
690 # undef pipe2
691 # define pipe2(f,o) \
692 (GL_LINK_WARNING ("pipe2 is unportable - " \
693 "use gnulib module pipe2 for portability"), \
694 pipe2 (f, o))
695 #endif
696
697
698 #if @GNULIB_PREAD@
699 # if @REPLACE_PREAD@
700 # define pread rpl_pread
701 # endif
702 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
703 Return the number of bytes placed into BUF if successful, otherwise
704 set errno and return -1. 0 indicates EOF. See the POSIX:2001
705 specification <http://www.opengroup.org/susv3xsh/pread.html>. */
706 # if !@HAVE_PREAD@ || @REPLACE_PREAD@
707 extern ssize_t pread (int fd, void *buf, size_t bufsize, off_t offset)
708 _GL_ARG_NONNULL ((2));
709 # endif
710 #elif defined GNULIB_POSIXCHECK
711 # undef pread
712 # define pread(f,b,s,o) \
713 (GL_LINK_WARNING ("pread is unportable - " \
714 "use gnulib module pread for portability"), \
715 pread (f, b, s, o))
716 #endif
717
718
719 #if @GNULIB_READLINK@
720 # if @REPLACE_READLINK@
721 # define readlink rpl_readlink
722 # endif
723 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
724 bytes of it into BUF. Return the number of bytes placed into BUF if
725 successful, otherwise -1 and errno set.
726 See the POSIX:2001 specification
727 <http://www.opengroup.org/susv3xsh/readlink.html>. */
728 # if !@HAVE_READLINK@ || @REPLACE_READLINK@
729 extern ssize_t readlink (const char *file, char *buf, size_t bufsize)
730 _GL_ARG_NONNULL ((1, 2));
731 # endif
732 #elif defined GNULIB_POSIXCHECK
733 # undef readlink
734 # define readlink(f,b,s) \
735 (GL_LINK_WARNING ("readlink is unportable - " \
736 "use gnulib module readlink for portability"), \
737 readlink (f, b, s))
738 #endif
739
740
741 #if @GNULIB_READLINKAT@
742 # if !@HAVE_READLINKAT@
743 extern ssize_t readlinkat (int fd, char const *file, char *buf, size_t len)
744 _GL_ARG_NONNULL ((2, 3));
745 # endif
746 #elif defined GNULIB_POSIXCHECK
747 # undef readlinkat
748 # define readlinkat(d,n,b,l) \
749 (GL_LINK_WARNING ("readlinkat is not portable - " \
750 "use gnulib module symlinkat for portability"), \
751 readlinkat (d, n, b, l))
752 #endif
753
754
755 #if @GNULIB_RMDIR@
756 # if @REPLACE_RMDIR@
757 # define rmdir rpl_rmdir
758 /* Remove the directory DIR. */
759 extern int rmdir (char const *name) _GL_ARG_NONNULL ((1));
760 # endif
761 #elif defined GNULIB_POSIXCHECK
762 # undef rmdir
763 # define rmdir(n) \
764 (GL_LINK_WARNING ("rmdir is unportable - " \
765 "use gnulib module rmdir for portability"), \
766 rmdir (n))
767 #endif
768
769
770 #if @GNULIB_SLEEP@
771 # if @REPLACE_SLEEP@
772 # undef sleep
773 # define sleep rpl_sleep
774 # endif
775 /* Pause the execution of the current thread for N seconds.
776 Returns the number of seconds left to sleep.
777 See the POSIX:2001 specification
778 <http://www.opengroup.org/susv3xsh/sleep.html>. */
779 # if !@HAVE_SLEEP@ || @REPLACE_SLEEP@
780 extern unsigned int sleep (unsigned int n);
781 # endif
782 #elif defined GNULIB_POSIXCHECK
783 # undef sleep
784 # define sleep(n) \
785 (GL_LINK_WARNING ("sleep is unportable - " \
786 "use gnulib module sleep for portability"), \
787 sleep (n))
788 #endif
789
790
791 #if @GNULIB_SYMLINK@
792 # if @REPLACE_SYMLINK@
793 # undef symlink
794 # define symlink rpl_symlink
795 # endif
796 # if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
797 extern int symlink (char const *contents, char const *file)
798 _GL_ARG_NONNULL ((1, 2));
799 # endif
800 #elif defined GNULIB_POSIXCHECK
801 # undef symlink
802 # define symlink(c,n) \
803 (GL_LINK_WARNING ("symlink is not portable - " \
804 "use gnulib module symlink for portability"), \
805 symlink (c, n))
806 #endif
807
808
809 #if @GNULIB_SYMLINKAT@
810 # if !@HAVE_SYMLINKAT@
811 extern int symlinkat (char const *contents, int fd, char const *file)
812 _GL_ARG_NONNULL ((1, 3));
813 # endif
814 #elif defined GNULIB_POSIXCHECK
815 # undef symlinkat
816 # define symlinkat(c,d,n) \
817 (GL_LINK_WARNING ("symlinkat is not portable - " \
818 "use gnulib module symlinkat for portability"), \
819 symlinkat (c, d, n))
820 #endif
821
822
823 #if @GNULIB_UNLINK@
824 # if @REPLACE_UNLINK@
825 # undef unlink
826 # define unlink rpl_unlink
827 extern int unlink (char const *file) _GL_ARG_NONNULL ((1));
828 # endif
829 #elif defined GNULIB_POSIXCHECK
830 # undef unlink
831 # define unlink(n) \
832 (GL_LINK_WARNING ("unlink is not portable - " \
833 "use gnulib module unlink for portability"), \
834 unlink (n))
835 #endif
836
837
838 #if @GNULIB_UNLINKAT@
839 # if @REPLACE_UNLINKAT@
840 # undef unlinkat
841 # define unlinkat rpl_unlinkat
842 # endif
843 # if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
844 extern int unlinkat (int fd, char const *file, int flag) _GL_ARG_NONNULL ((2));
845 # endif
846 #elif defined GNULIB_POSIXCHECK
847 # undef unlinkat
848 # define unlinkat(d,n,f) \
849 (GL_LINK_WARNING ("unlinkat is not portable - " \
850 "use gnulib module openat for portability"), \
851 unlinkat (d, n, f))
852 #endif
853
854
855 #if @GNULIB_USLEEP@
856 # if @REPLACE_USLEEP@
857 # undef usleep
858 # define usleep rpl_usleep
859 # endif
860 # if !@HAVE_USLEEP@ || @REPLACE_USLEEP@
861 /* Pause the execution of the current thread for N microseconds.
862 Returns 0 on completion, or -1 on range error.
863 See the POSIX:2001 specification
864 <http://www.opengroup.org/susv3xsh/sleep.html>. */
865 extern int usleep (useconds_t n);
866 # endif
867 #elif defined GNULIB_POSIXCHECK
868 # undef usleep
869 # define usleep(n) \
870 (GL_LINK_WARNING ("usleep is unportable - " \
871 "use gnulib module usleep for portability"), \
872 usleep (n))
873 #endif
874
875
876 #if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
877 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
878 See the POSIX:2001 specification
879 <http://www.opengroup.org/susv3xsh/write.html>. */
880 # undef write
881 # define write rpl_write
882 extern ssize_t write (int fd, const void *buf, size_t count)
883 _GL_ARG_NONNULL ((2));
884 #endif
885
886
887 #ifdef __cplusplus
888 }
889 #endif
890
891
892 #endif /* _GL_UNISTD_H */
893 #endif /* _GL_UNISTD_H */