12
12
GNU General Public License for more details.
14
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. */
15
along with this program; if not, see <http://www.gnu.org/licenses/>. */
21
18
@PRAGMA_SYSTEM_HEADER@
22
/* Special invocation convention:
23
- On mingw, several headers, including <winsock2.h>, include <unistd.h>,
24
but we need to ensure that both the system <unistd.h> and <winsock2.h>
25
are completely included before we replace gethostname. */
26
#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
27
&& !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
28
/* <unistd.h> is being indirectly included for the first time from
29
<winsock2.h>; avoid declaring any overrides. */
31
# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
33
# error unexpected; report this to bug-gnulib@gnu.org
35
# define _GL_WINSOCK2_H_WITNESS
37
/* Normal invocation. */
38
#elif !defined _@GUARD_PREFIX@_UNISTD_H
24
40
/* The include_next requires a split double-inclusion guard. */
25
41
#if @HAVE_UNISTD_H@
26
42
# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
45
/* Get all possible declarations of gethostname(). */
46
#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
47
&& !defined _GL_INCLUDING_WINSOCK2_H
48
# define _GL_INCLUDING_WINSOCK2_H
49
# include <winsock2.h>
50
# undef _GL_INCLUDING_WINSOCK2_H
53
#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
54
#define _@GUARD_PREFIX@_UNISTD_H
32
56
/* NetBSD 5.0 mis-defines NULL. Also get size_t. */
33
57
#include <stddef.h>
35
59
/* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
36
#if !(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET)
60
/* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
61
/* But avoid namespace pollution on glibc systems. */
62
#if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
63
|| ((@GNULIB_SYMLINKAT@ || defined GNULIB_POSIXCHECK) \
64
&& defined __CYGWIN__)) \
65
&& ! defined __GLIBC__
37
66
# include <stdio.h>
69
/* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
70
/* But avoid namespace pollution on glibc systems. */
71
#if (@GNULIB_UNLINKAT@ || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
72
&& ! defined __GLIBC__
40
76
/* mingw fails to declare _exit in <unistd.h>. */
41
/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>. */
44
#if ((@GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@) \
45
|| (@GNULIB_READLINK@ && (!@HAVE_READLINK@ || @REPLACE_READLINK@)) \
46
|| (@GNULIB_READLINKAT@ && !@HAVE_READLINKAT@))
77
/* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
79
/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
80
/* But avoid namespace pollution on glibc systems. */
85
/* Native Windows platforms declare chdir, getcwd, rmdir in
86
<io.h> and/or <direct.h>, not in <unistd.h>.
87
They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
88
lseek(), read(), unlink(), write() in <io.h>. */
89
#if ((@GNULIB_CHDIR@ || @GNULIB_GETCWD@ || @GNULIB_RMDIR@ \
90
|| defined GNULIB_POSIXCHECK) \
91
&& ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__))
92
# include <io.h> /* mingw32, mingw64 */
93
# include <direct.h> /* mingw64, MSVC 9 */
94
#elif (@GNULIB_CLOSE@ || @GNULIB_DUP@ || @GNULIB_DUP2@ || @GNULIB_ISATTY@ \
95
|| @GNULIB_LSEEK@ || @GNULIB_READ@ || @GNULIB_UNLINK@ || @GNULIB_WRITE@ \
96
|| defined GNULIB_POSIXCHECK) \
97
&& ((defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__)
101
/* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
102
NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
103
/* But avoid namespace pollution on glibc systems. */
104
#if ((@GNULIB_GETDOMAINNAME@ && (defined _AIX || defined __osf__)) \
105
|| (@GNULIB_GETHOSTNAME@ && defined __TANDEM)) \
106
&& !defined __GLIBC__
110
/* MSVC defines off_t in <sys/types.h>.
111
May also define off_t to a 64-bit type on native Windows. */
112
#if !@HAVE_UNISTD_H@ || @WINDOWS_64_BIT_OFF_T@
114
# include <sys/types.h>
117
#if (@GNULIB_READ@ || @GNULIB_WRITE@ \
118
|| @GNULIB_READLINK@ || @GNULIB_READLINKAT@ \
119
|| @GNULIB_PREAD@ || @GNULIB_PWRITE@ || defined GNULIB_POSIXCHECK)
47
120
/* Get ssize_t. */
48
121
# include <sys/types.h>
51
/* Get getopt(), optarg, optind, opterr, optopt. */
52
#if @GNULIB_UNISTD_H_GETOPT@ && !defined _GL_SYSTEM_GETOPT
124
/* Get getopt(), optarg, optind, opterr, optopt.
125
But avoid namespace pollution on glibc systems. */
126
#if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined _GL_SYSTEM_GETOPT
53
127
# include <getopt.h>
56
#if @GNULIB_GETHOSTNAME@
57
/* Get all possible declarations of gethostname(). */
58
# if @UNISTD_H_HAVE_WINSOCK2_H@
59
# include <winsock2.h>
60
# if !defined _GL_SYS_SOCKET_H
130
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
132
/* The definition of _GL_ARG_NONNULL is copied here. */
134
/* The definition of _GL_WARN_ON_USE is copied here. */
137
/* Hide some function declarations from <winsock2.h>. */
139
#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
140
# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
141
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
62
# define socket socket_used_without_including_sys_socket_h
143
# define socket socket_used_without_including_sys_socket_h
64
# define connect connect_used_without_including_sys_socket_h
145
# define connect connect_used_without_including_sys_socket_h
66
# define accept accept_used_without_including_sys_socket_h
147
# define accept accept_used_without_including_sys_socket_h
68
# define bind bind_used_without_including_sys_socket_h
149
# define bind bind_used_without_including_sys_socket_h
69
150
# undef getpeername
70
# define getpeername getpeername_used_without_including_sys_socket_h
151
# define getpeername getpeername_used_without_including_sys_socket_h
71
152
# undef getsockname
72
# define getsockname getsockname_used_without_including_sys_socket_h
153
# define getsockname getsockname_used_without_including_sys_socket_h
73
154
# undef getsockopt
74
# define getsockopt getsockopt_used_without_including_sys_socket_h
155
# define getsockopt getsockopt_used_without_including_sys_socket_h
76
# define listen listen_used_without_including_sys_socket_h
157
# define listen listen_used_without_including_sys_socket_h
78
# define recv recv_used_without_including_sys_socket_h
159
# define recv recv_used_without_including_sys_socket_h
80
# define send send_used_without_including_sys_socket_h
161
# define send send_used_without_including_sys_socket_h
82
# define recvfrom recvfrom_used_without_including_sys_socket_h
163
# define recvfrom recvfrom_used_without_including_sys_socket_h
84
# define sendto sendto_used_without_including_sys_socket_h
165
# define sendto sendto_used_without_including_sys_socket_h
85
166
# undef setsockopt
86
# define setsockopt setsockopt_used_without_including_sys_socket_h
167
# define setsockopt setsockopt_used_without_including_sys_socket_h
88
# define shutdown shutdown_used_without_including_sys_socket_h
169
# define shutdown shutdown_used_without_including_sys_socket_h
171
_GL_WARN_ON_USE (socket,
172
"socket() used without including <sys/socket.h>");
173
_GL_WARN_ON_USE (connect,
174
"connect() used without including <sys/socket.h>");
175
_GL_WARN_ON_USE (accept,
176
"accept() used without including <sys/socket.h>");
177
_GL_WARN_ON_USE (bind,
178
"bind() used without including <sys/socket.h>");
179
_GL_WARN_ON_USE (getpeername,
180
"getpeername() used without including <sys/socket.h>");
181
_GL_WARN_ON_USE (getsockname,
182
"getsockname() used without including <sys/socket.h>");
183
_GL_WARN_ON_USE (getsockopt,
184
"getsockopt() used without including <sys/socket.h>");
185
_GL_WARN_ON_USE (listen,
186
"listen() used without including <sys/socket.h>");
187
_GL_WARN_ON_USE (recv,
188
"recv() used without including <sys/socket.h>");
189
_GL_WARN_ON_USE (send,
190
"send() used without including <sys/socket.h>");
191
_GL_WARN_ON_USE (recvfrom,
192
"recvfrom() used without including <sys/socket.h>");
193
_GL_WARN_ON_USE (sendto,
194
"sendto() used without including <sys/socket.h>");
195
_GL_WARN_ON_USE (setsockopt,
196
"setsockopt() used without including <sys/socket.h>");
197
_GL_WARN_ON_USE (shutdown,
198
"shutdown() used without including <sys/socket.h>");
90
# if !defined _GL_SYS_SELECT_H
201
# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
202
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
92
# define select select_used_without_including_sys_select_h
204
# define select select_used_without_including_sys_select_h
206
_GL_WARN_ON_USE (select,
207
"select() used without including <sys/select.h>");
97
/* The definition of GL_LINK_WARNING is copied here. */
100
213
/* OS/2 EMX lacks these macros. */
101
214
#ifndef STDIN_FILENO
120
233
/* Declare overridden functions. */
236
#if defined GNULIB_POSIXCHECK
237
/* The access() function is a security risk. */
238
_GL_WARN_ON_USE (access, "the access function is a security risk - "
239
"use the gnulib module faccessat instead");
244
_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
245
_GL_CXXALIASWARN (chdir);
246
#elif defined GNULIB_POSIXCHECK
248
# if HAVE_RAW_DECL_CHDIR
249
_GL_WARN_ON_USE (chown, "chdir is not always in <unistd.h> - "
250
"use gnulib module chdir for portability");
127
255
#if @GNULIB_CHOWN@
256
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
257
to GID (if GID is not -1). Follow symbolic links.
258
Return 0 if successful, otherwise -1 and errno set.
259
See the POSIX:2008 specification
260
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
128
261
# if @REPLACE_CHOWN@
129
# ifndef REPLACE_CHOWN
130
# define REPLACE_CHOWN 1
133
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
134
to GID (if GID is not -1). Follow symbolic links.
135
Return 0 if successful, otherwise -1 and errno set.
136
See the POSIX:2001 specification
137
<http://www.opengroup.org/susv3xsh/chown.html>. */
262
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
138
264
# define chown rpl_chown
139
extern int chown (const char *file, uid_t uid, gid_t gid);
266
_GL_FUNCDECL_RPL (chown, int, (const char *file, uid_t uid, gid_t gid)
267
_GL_ARG_NONNULL ((1)));
268
_GL_CXXALIAS_RPL (chown, int, (const char *file, uid_t uid, gid_t gid));
271
_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
272
_GL_ARG_NONNULL ((1)));
274
_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
276
_GL_CXXALIASWARN (chown);
142
277
#elif defined GNULIB_POSIXCHECK
144
# define chown(f,u,g) \
145
(GL_LINK_WARNING ("chown fails to follow symlinks on some systems and " \
146
"doesn't treat a uid or gid of -1 on some systems - " \
147
"use gnulib module chown for portability"), \
279
# if HAVE_RAW_DECL_CHOWN
280
_GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
281
"doesn't treat a uid or gid of -1 on some systems - "
282
"use gnulib module chown for portability");
152
287
#if @GNULIB_CLOSE@
153
288
# if @REPLACE_CLOSE@
154
289
/* Automatically included by modules that need a replacement for close. */
156
# define close rpl_close
157
extern int close (int);
290
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
292
# define close rpl_close
294
_GL_FUNCDECL_RPL (close, int, (int fd));
295
_GL_CXXALIAS_RPL (close, int, (int fd));
297
_GL_CXXALIAS_SYS (close, int, (int fd));
299
_GL_CXXALIASWARN (close);
159
300
#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
161
302
# define close close_used_without_requesting_gnulib_module_close
162
303
#elif defined GNULIB_POSIXCHECK
165
(GL_LINK_WARNING ("close does not portably work on sockets - " \
166
"use gnulib module close for portability"), \
305
/* Assume close is always declared. */
306
_GL_WARN_ON_USE (close, "close does not portably work on sockets - "
307
"use gnulib module close for portability");
173
extern int dup (int);
313
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
316
_GL_FUNCDECL_RPL (dup, int, (int oldfd));
317
_GL_CXXALIAS_RPL (dup, int, (int oldfd));
319
_GL_CXXALIAS_SYS (dup, int, (int oldfd));
321
_GL_CXXALIASWARN (dup);
322
#elif defined GNULIB_POSIXCHECK
324
# if HAVE_RAW_DECL_DUP
325
_GL_WARN_ON_USE (dup, "dup is unportable - "
326
"use gnulib module dup for portability");
177
331
#if @GNULIB_DUP2@
179
# define dup2 rpl_dup2
181
# if !@HAVE_DUP2@ || @REPLACE_DUP2@
182
332
/* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
183
333
NEWFD = OLDFD, otherwise close NEWFD first if it is open.
184
334
Return newfd if successful, otherwise -1 and errno set.
185
See the POSIX:2001 specification
186
<http://www.opengroup.org/susv3xsh/dup2.html>. */
187
extern int dup2 (int oldfd, int newfd);
335
See the POSIX:2008 specification
336
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
338
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
339
# define dup2 rpl_dup2
341
_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
342
_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
345
_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
347
_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
349
_GL_CXXALIASWARN (dup2);
189
350
#elif defined GNULIB_POSIXCHECK
192
(GL_LINK_WARNING ("dup2 is unportable - " \
193
"use gnulib module dup2 for portability"), \
352
# if HAVE_RAW_DECL_DUP2
353
_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
354
"use gnulib module dup2 for portability");
225
393
# include <crt_externs.h>
226
394
# define environ (*_NSGetEnviron ())
228
399
extern char **environ;
231
405
#elif defined GNULIB_POSIXCHECK
234
(GL_LINK_WARNING ("environ is unportable - " \
235
"use gnulib module environ for portability"), \
406
# if HAVE_RAW_DECL_ENVIRON
407
static inline char ***
412
_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
413
"use gnulib module environ for portability");
415
# define environ (*rpl_environ ())
240
420
#if @GNULIB_EUIDACCESS@
241
# if !@HAVE_EUIDACCESS@
242
421
/* Like access(), except that it uses the effective user id and group id of
243
422
the current process. */
244
extern int euidaccess (const char *filename, int mode);
423
# if !@HAVE_EUIDACCESS@
424
_GL_FUNCDECL_SYS (euidaccess, int, (const char *filename, int mode)
425
_GL_ARG_NONNULL ((1)));
427
_GL_CXXALIAS_SYS (euidaccess, int, (const char *filename, int mode));
428
_GL_CXXALIASWARN (euidaccess);
429
# if defined GNULIB_POSIXCHECK
430
/* Like access(), this function is a security risk. */
431
_GL_WARN_ON_USE (euidaccess, "the euidaccess function is a security risk - "
432
"use the gnulib module faccessat instead");
246
434
#elif defined GNULIB_POSIXCHECK
247
435
# undef euidaccess
248
# define euidaccess(f,m) \
249
(GL_LINK_WARNING ("euidaccess is unportable - " \
250
"use gnulib module euidaccess for portability"), \
436
# if HAVE_RAW_DECL_EUIDACCESS
437
_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
438
"use gnulib module euidaccess for portability");
255
443
#if @GNULIB_FACCESSAT@
256
444
# if !@HAVE_FACCESSAT@
257
int faccessat (int fd, char const *file, int mode, int flag);
445
_GL_FUNCDECL_SYS (faccessat, int,
446
(int fd, char const *file, int mode, int flag)
447
_GL_ARG_NONNULL ((2)));
449
_GL_CXXALIAS_SYS (faccessat, int,
450
(int fd, char const *file, int mode, int flag));
451
_GL_CXXALIASWARN (faccessat);
259
452
#elif defined GNULIB_POSIXCHECK
260
453
# undef faccessat
261
# define faccessat(d,n,m,f) \
262
(GL_LINK_WARNING ("faccessat is not portable - " \
263
"use gnulib module faccessat for portability"), \
264
faccessat (d, n, m, f))
454
# if HAVE_RAW_DECL_FACCESSAT
455
_GL_WARN_ON_USE (faccessat, "faccessat is not portable - "
456
"use gnulib module faccessat for portability");
268
461
#if @GNULIB_FCHDIR@
269
# if @REPLACE_FCHDIR@
270
462
/* Change the process' current working directory to the directory on which
271
463
the given file descriptor is open.
272
464
Return 0 if successful, otherwise -1 and errno set.
273
See the POSIX:2001 specification
274
<http://www.opengroup.org/susv3xsh/fchdir.html>. */
275
extern int fchdir (int /*fd*/);
465
See the POSIX:2008 specification
466
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
468
_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
277
470
/* Gnulib internal hooks needed to maintain the fchdir metadata. */
278
extern int _gl_register_fd (int fd, const char *filename);
279
extern void _gl_unregister_fd (int fd);
280
extern int _gl_register_dup (int oldfd, int newfd);
281
extern const char *_gl_directory_name (int fd);
471
_GL_EXTERN_C int _gl_register_fd (int fd, const char *filename)
472
_GL_ARG_NONNULL ((2));
473
_GL_EXTERN_C void _gl_unregister_fd (int fd);
474
_GL_EXTERN_C int _gl_register_dup (int oldfd, int newfd);
475
_GL_EXTERN_C const char *_gl_directory_name (int fd);
478
# if !@HAVE_DECL_FCHDIR@
479
_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
482
_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
483
_GL_CXXALIASWARN (fchdir);
284
484
#elif defined GNULIB_POSIXCHECK
287
(GL_LINK_WARNING ("fchdir is unportable - " \
288
"use gnulib module fchdir for portability"), \
486
# if HAVE_RAW_DECL_FCHDIR
487
_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
488
"use gnulib module fchdir for portability");
293
493
#if @GNULIB_FCHOWNAT@
294
494
# if @REPLACE_FCHOWNAT@
296
# define fchownat rpl_fchownat
298
# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
299
extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);
495
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
497
# define fchownat rpl_fchownat
499
_GL_FUNCDECL_RPL (fchownat, int, (int fd, char const *file,
500
uid_t owner, gid_t group, int flag)
501
_GL_ARG_NONNULL ((2)));
502
_GL_CXXALIAS_RPL (fchownat, int, (int fd, char const *file,
503
uid_t owner, gid_t group, int flag));
505
# if !@HAVE_FCHOWNAT@
506
_GL_FUNCDECL_SYS (fchownat, int, (int fd, char const *file,
507
uid_t owner, gid_t group, int flag)
508
_GL_ARG_NONNULL ((2)));
510
_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
511
uid_t owner, gid_t group, int flag));
513
_GL_CXXALIASWARN (fchownat);
301
514
#elif defined GNULIB_POSIXCHECK
303
# define fchownat(d,n,o,g,f) \
304
(GL_LINK_WARNING ("fchownat is not portable - " \
305
"use gnulib module openat for portability"), \
306
fchownat (d, n, o, g, f))
516
# if HAVE_RAW_DECL_FCHOWNAT
517
_GL_WARN_ON_USE (fchownat, "fchownat is not portable - "
518
"use gnulib module openat for portability");
523
#if @GNULIB_FDATASYNC@
524
/* Synchronize changes to a file.
525
Return 0 if successful, otherwise -1 and errno set.
526
See POSIX:2008 specification
527
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
528
# if !@HAVE_FDATASYNC@ || !@HAVE_DECL_FDATASYNC@
529
_GL_FUNCDECL_SYS (fdatasync, int, (int fd));
531
_GL_CXXALIAS_SYS (fdatasync, int, (int fd));
532
_GL_CXXALIASWARN (fdatasync);
533
#elif defined GNULIB_POSIXCHECK
535
# if HAVE_RAW_DECL_FDATASYNC
536
_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
537
"use gnulib module fdatasync for portability");
310
542
#if @GNULIB_FSYNC@
311
/* Synchronize changes to a file.
543
/* Synchronize changes, including metadata, to a file.
312
544
Return 0 if successful, otherwise -1 and errno set.
313
See POSIX:2001 specification
314
<http://www.opengroup.org/susv3xsh/fsync.html>. */
545
See POSIX:2008 specification
546
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
315
547
# if !@HAVE_FSYNC@
316
extern int fsync (int fd);
548
_GL_FUNCDECL_SYS (fsync, int, (int fd));
550
_GL_CXXALIAS_SYS (fsync, int, (int fd));
551
_GL_CXXALIASWARN (fsync);
318
552
#elif defined GNULIB_POSIXCHECK
321
(GL_LINK_WARNING ("fsync is unportable - " \
322
"use gnulib module fsync for portability"), \
554
# if HAVE_RAW_DECL_FSYNC
555
_GL_WARN_ON_USE (fsync, "fsync is unportable - "
556
"use gnulib module fsync for portability");
327
561
#if @GNULIB_FTRUNCATE@
328
# if !@HAVE_FTRUNCATE@
329
562
/* Change the size of the file to which FD is opened to become equal to LENGTH.
330
563
Return 0 if successful, otherwise -1 and errno set.
331
See the POSIX:2001 specification
332
<http://www.opengroup.org/susv3xsh/ftruncate.html>. */
333
extern int ftruncate (int fd, off_t length);
564
See the POSIX:2008 specification
565
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
566
# if @REPLACE_FTRUNCATE@
567
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
569
# define ftruncate rpl_ftruncate
571
_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
572
_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
574
# if !@HAVE_FTRUNCATE@
575
_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
577
_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
579
_GL_CXXALIASWARN (ftruncate);
335
580
#elif defined GNULIB_POSIXCHECK
336
581
# undef ftruncate
337
# define ftruncate(f,l) \
338
(GL_LINK_WARNING ("ftruncate is unportable - " \
339
"use gnulib module ftruncate for portability"), \
582
# if HAVE_RAW_DECL_FTRUNCATE
583
_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
584
"use gnulib module ftruncate for portability");
344
589
#if @GNULIB_GETCWD@
345
/* Include the headers that might declare getcwd so that they will not
346
cause confusion if included after this file. */
348
# if @REPLACE_GETCWD@
349
590
/* Get the name of the current working directory, and put it in SIZE bytes
351
592
Return BUF if successful, or NULL if the directory couldn't be determined
352
593
or SIZE was too small.
353
See the POSIX:2001 specification
354
<http://www.opengroup.org/susv3xsh/getcwd.html>.
594
See the POSIX:2008 specification
595
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
355
596
Additionally, the gnulib module 'getcwd' guarantees the following GNU
356
597
extension: If BUF is NULL, an array is allocated with 'malloc'; the array
357
598
is SIZE bytes long, unless SIZE == 0, in which case it is as big as
359
# define getcwd rpl_getcwd
360
extern char * getcwd (char *buf, size_t size);
600
# if @REPLACE_GETCWD@
601
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
602
# define getcwd rpl_getcwd
604
_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
605
_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
607
/* Need to cast, because on mingw, the second parameter is
609
_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
611
_GL_CXXALIASWARN (getcwd);
362
612
#elif defined GNULIB_POSIXCHECK
364
# define getcwd(b,s) \
365
(GL_LINK_WARNING ("getcwd is unportable - " \
366
"use gnulib module getcwd for portability"), \
614
# if HAVE_RAW_DECL_GETCWD
615
_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
616
"use gnulib module getcwd for portability");
442
773
provided (this case is hopefully rare but is left open by the POSIX spec).
444
775
See <http://www.opengroup.org/susv3xsh/getlogin.html>.
777
Most programs don't need to use this function, because the information is
778
available through environment variables:
779
${LOGNAME-$USER} on Unix platforms,
780
$USERNAME on native Windows platforms.
446
# if !@HAVE_DECL_GETLOGIN_R@
447
extern int getlogin_r (char *name, size_t size);
782
# if @REPLACE_GETLOGIN_R@
783
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
784
# define getlogin_r rpl_getlogin_r
786
_GL_FUNCDECL_RPL (getlogin_r, int, (char *name, size_t size)
787
_GL_ARG_NONNULL ((1)));
788
_GL_CXXALIAS_RPL (getlogin_r, int, (char *name, size_t size));
790
# if !@HAVE_DECL_GETLOGIN_R@
791
_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
792
_GL_ARG_NONNULL ((1)));
794
/* Need to cast, because on Solaris 10 systems, the second argument is
796
_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
798
_GL_CXXALIASWARN (getlogin_r);
449
799
#elif defined GNULIB_POSIXCHECK
450
800
# undef getlogin_r
451
# define getlogin_r(n,s) \
452
(GL_LINK_WARNING ("getlogin_r is unportable - " \
453
"use gnulib module getlogin_r for portability"), \
801
# if HAVE_RAW_DECL_GETLOGIN_R
802
_GL_WARN_ON_USE (getlogin_r, "getlogin_r is unportable - "
803
"use gnulib module getlogin_r for portability");
458
808
#if @GNULIB_GETPAGESIZE@
459
809
# if @REPLACE_GETPAGESIZE@
460
# define getpagesize rpl_getpagesize
461
extern int getpagesize (void);
462
# elif !@HAVE_GETPAGESIZE@
810
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
811
# define getpagesize rpl_getpagesize
813
_GL_FUNCDECL_RPL (getpagesize, int, (void));
814
_GL_CXXALIAS_RPL (getpagesize, int, (void));
816
# if !@HAVE_GETPAGESIZE@
817
# if !defined getpagesize
463
818
/* This is for POSIX systems. */
464
# if !defined getpagesize && defined _SC_PAGESIZE
465
# if ! (defined __VMS && __VMS_VER < 70000000)
466
# define getpagesize() sysconf (_SC_PAGESIZE)
819
# if !defined _gl_getpagesize && defined _SC_PAGESIZE
820
# if ! (defined __VMS && __VMS_VER < 70000000)
821
# define _gl_getpagesize() sysconf (_SC_PAGESIZE)
469
824
/* This is for older VMS. */
470
# if !defined getpagesize && defined __VMS
472
# define getpagesize() 8192
474
# define getpagesize() 512
825
# if !defined _gl_getpagesize && defined __VMS
827
# define _gl_getpagesize() 8192
829
# define _gl_getpagesize() 512
477
832
/* This is for BeOS. */
478
# if !defined getpagesize && @HAVE_OS_H@
480
# if defined B_PAGE_SIZE
481
# define getpagesize() B_PAGE_SIZE
833
# if !defined _gl_getpagesize && @HAVE_OS_H@
835
# if defined B_PAGE_SIZE
836
# define _gl_getpagesize() B_PAGE_SIZE
484
839
/* This is for AmigaOS4.0. */
485
# if !defined getpagesize && defined __amigaos4__
486
# define getpagesize() 2048
840
# if !defined _gl_getpagesize && defined __amigaos4__
841
# define _gl_getpagesize() 2048
488
843
/* This is for older Unix systems. */
489
# if !defined getpagesize && @HAVE_SYS_PARAM_H@
490
# include <sys/param.h>
491
# ifdef EXEC_PAGESIZE
492
# define getpagesize() EXEC_PAGESIZE
844
# if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
845
# include <sys/param.h>
846
# ifdef EXEC_PAGESIZE
847
# define _gl_getpagesize() EXEC_PAGESIZE
853
# define _gl_getpagesize() (NBPG * CLSIZE)
856
# define _gl_getpagesize() NBPC
498
# define getpagesize() (NBPG * CLSIZE)
861
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
862
# define getpagesize() _gl_getpagesize ()
501
# define getpagesize() NBPC
864
# if !GNULIB_defined_getpagesize_function
868
return _gl_getpagesize ();
870
# define GNULIB_defined_getpagesize_function 1
875
/* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
876
_GL_CXXALIAS_SYS_CAST (getpagesize, int, (void));
878
# if @HAVE_DECL_GETPAGESIZE@
879
_GL_CXXALIASWARN (getpagesize);
507
881
#elif defined GNULIB_POSIXCHECK
508
882
# undef getpagesize
509
# define getpagesize() \
510
(GL_LINK_WARNING ("getpagesize is unportable - " \
511
"use gnulib module getpagesize for portability"), \
883
# if HAVE_RAW_DECL_GETPAGESIZE
884
_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
885
"use gnulib module getpagesize for portability");
516
890
#if @GNULIB_GETUSERSHELL@
517
# if !@HAVE_GETUSERSHELL@
518
891
/* Return the next valid login shell on the system, or NULL when the end of
519
892
the list has been reached. */
520
extern char *getusershell (void);
893
# if !@HAVE_DECL_GETUSERSHELL@
894
_GL_FUNCDECL_SYS (getusershell, char *, (void));
896
_GL_CXXALIAS_SYS (getusershell, char *, (void));
897
_GL_CXXALIASWARN (getusershell);
898
#elif defined GNULIB_POSIXCHECK
900
# if HAVE_RAW_DECL_GETUSERSHELL
901
_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
902
"use gnulib module getusershell for portability");
906
#if @GNULIB_GETUSERSHELL@
521
907
/* Rewind to pointer that is advanced at each getusershell() call. */
522
extern void setusershell (void);
908
# if !@HAVE_DECL_GETUSERSHELL@
909
_GL_FUNCDECL_SYS (setusershell, void, (void));
911
_GL_CXXALIAS_SYS (setusershell, void, (void));
912
_GL_CXXALIASWARN (setusershell);
913
#elif defined GNULIB_POSIXCHECK
915
# if HAVE_RAW_DECL_SETUSERSHELL
916
_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
917
"use gnulib module getusershell for portability");
921
#if @GNULIB_GETUSERSHELL@
523
922
/* Free the pointer that is advanced at each getusershell() call and
524
923
associated resources. */
525
extern void endusershell (void);
924
# if !@HAVE_DECL_GETUSERSHELL@
925
_GL_FUNCDECL_SYS (endusershell, void, (void));
927
_GL_CXXALIAS_SYS (endusershell, void, (void));
928
_GL_CXXALIASWARN (endusershell);
527
929
#elif defined GNULIB_POSIXCHECK
529
# define getusershell() \
530
(GL_LINK_WARNING ("getusershell is unportable - " \
531
"use gnulib module getusershell for portability"), \
534
# define setusershell() \
535
(GL_LINK_WARNING ("setusershell is unportable - " \
536
"use gnulib module getusershell for portability"), \
538
930
# undef endusershell
539
# define endusershell() \
540
(GL_LINK_WARNING ("endusershell is unportable - " \
541
"use gnulib module getusershell for portability"), \
931
# if HAVE_RAW_DECL_ENDUSERSHELL
932
_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
933
"use gnulib module getusershell for portability");
938
#if @GNULIB_GROUP_MEMBER@
939
/* Determine whether group id is in calling user's group list. */
940
# if !@HAVE_GROUP_MEMBER@
941
_GL_FUNCDECL_SYS (group_member, int, (gid_t gid));
943
_GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
944
_GL_CXXALIASWARN (group_member);
945
#elif defined GNULIB_POSIXCHECK
947
# if HAVE_RAW_DECL_GROUP_MEMBER
948
_GL_WARN_ON_USE (group_member, "group_member is unportable - "
949
"use gnulib module group-member for portability");
955
# if @REPLACE_ISATTY@
956
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
958
# define isatty rpl_isatty
960
_GL_FUNCDECL_RPL (isatty, int, (int fd));
961
_GL_CXXALIAS_RPL (isatty, int, (int fd));
963
_GL_CXXALIAS_SYS (isatty, int, (int fd));
965
_GL_CXXALIASWARN (isatty);
966
#elif defined GNULIB_POSIXCHECK
968
# if HAVE_RAW_DECL_ISATTY
969
_GL_WARN_ON_USE (isatty, "isatty has portability problems on native Windows - "
970
"use gnulib module isatty for portability");
546
975
#if @GNULIB_LCHOWN@
976
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
977
to GID (if GID is not -1). Do not follow symbolic links.
978
Return 0 if successful, otherwise -1 and errno set.
979
See the POSIX:2008 specification
980
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
547
981
# if @REPLACE_LCHOWN@
548
/* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
549
to GID (if GID is not -1). Do not follow symbolic links.
550
Return 0 if successful, otherwise -1 and errno set.
551
See the POSIX:2001 specification
552
<http://www.opengroup.org/susv3xsh/lchown.html>. */
553
# define lchown rpl_lchown
554
extern int lchown (char const *file, uid_t owner, gid_t group);
982
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
984
# define lchown rpl_lchown
986
_GL_FUNCDECL_RPL (lchown, int, (char const *file, uid_t owner, gid_t group)
987
_GL_ARG_NONNULL ((1)));
988
_GL_CXXALIAS_RPL (lchown, int, (char const *file, uid_t owner, gid_t group));
991
_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
992
_GL_ARG_NONNULL ((1)));
994
_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
996
_GL_CXXALIASWARN (lchown);
556
997
#elif defined GNULIB_POSIXCHECK
558
# define lchown(f,u,g) \
559
(GL_LINK_WARNING ("lchown is unportable to pre-POSIX.1-2001 " \
560
"systems - use gnulib module lchown for portability"), \
999
# if HAVE_RAW_DECL_LCHOWN
1000
_GL_WARN_ON_USE (lchown, "lchown is unportable to pre-POSIX.1-2001 systems - "
1001
"use gnulib module lchown for portability");
565
1006
#if @GNULIB_LINK@
1007
/* Create a new hard link for an existing file.
1008
Return 0 if successful, otherwise -1 and errno set.
1009
See POSIX:2008 specification
1010
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
566
1011
# if @REPLACE_LINK@
567
# define link rpl_link
569
/* Create a new hard link for an existing file.
570
Return 0 if successful, otherwise -1 and errno set.
571
See POSIX:2001 specification
572
<http://www.opengroup.org/susv3xsh/link.html>. */
573
# if !@HAVE_LINK@ || @REPLACE_LINK@
574
extern int link (const char *path1, const char *path2);
1012
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1013
# define link rpl_link
1015
_GL_FUNCDECL_RPL (link, int, (const char *path1, const char *path2)
1016
_GL_ARG_NONNULL ((1, 2)));
1017
_GL_CXXALIAS_RPL (link, int, (const char *path1, const char *path2));
1020
_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
1021
_GL_ARG_NONNULL ((1, 2)));
1023
_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
1025
_GL_CXXALIASWARN (link);
576
1026
#elif defined GNULIB_POSIXCHECK
578
# define link(path1,path2) \
579
(GL_LINK_WARNING ("link is unportable - " \
580
"use gnulib module link for portability"), \
1028
# if HAVE_RAW_DECL_LINK
1029
_GL_WARN_ON_USE (link, "link is unportable - "
1030
"use gnulib module link for portability");
584
1035
#if @GNULIB_LINKAT@
585
# if @REPLACE_LINKAT@
587
# define linkat rpl_linkat
589
1036
/* Create a new hard link for an existing file, relative to two
590
1037
directories. FLAG controls whether symlinks are followed.
591
1038
Return 0 if successful, otherwise -1 and errno set. */
592
# if !@HAVE_LINKAT@ || @REPLACE_LINKAT@
593
extern int linkat (int fd1, const char *path1, int fd2, const char *path2,
1039
# if @REPLACE_LINKAT@
1040
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1042
# define linkat rpl_linkat
1044
_GL_FUNCDECL_RPL (linkat, int,
1045
(int fd1, const char *path1, int fd2, const char *path2,
1047
_GL_ARG_NONNULL ((2, 4)));
1048
_GL_CXXALIAS_RPL (linkat, int,
1049
(int fd1, const char *path1, int fd2, const char *path2,
1053
_GL_FUNCDECL_SYS (linkat, int,
1054
(int fd1, const char *path1, int fd2, const char *path2,
1056
_GL_ARG_NONNULL ((2, 4)));
1058
_GL_CXXALIAS_SYS (linkat, int,
1059
(int fd1, const char *path1, int fd2, const char *path2,
1062
_GL_CXXALIASWARN (linkat);
596
1063
#elif defined GNULIB_POSIXCHECK
598
# define link(f1,path1,f2,path2,f) \
599
(GL_LINK_WARNING ("linkat is unportable - " \
600
"use gnulib module linkat for portability"), \
601
linkat (f1, path1, f2, path2,f))
1065
# if HAVE_RAW_DECL_LINKAT
1066
_GL_WARN_ON_USE (linkat, "linkat is unportable - "
1067
"use gnulib module linkat for portability");
604
1072
#if @GNULIB_LSEEK@
606
1073
/* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
607
1074
Return the new offset if successful, otherwise -1 and errno set.
608
See the POSIX:2001 specification
609
<http://www.opengroup.org/susv3xsh/lseek.html>. */
610
# define lseek rpl_lseek
611
extern off_t lseek (int fd, off_t offset, int whence);
1075
See the POSIX:2008 specification
1076
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1077
# if @REPLACE_LSEEK@
1078
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1079
# define lseek rpl_lseek
1081
_GL_FUNCDECL_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1082
_GL_CXXALIAS_RPL (lseek, off_t, (int fd, off_t offset, int whence));
1084
_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
1086
_GL_CXXALIASWARN (lseek);
613
1087
#elif defined GNULIB_POSIXCHECK
615
# define lseek(f,o,w) \
616
(GL_LINK_WARNING ("lseek does not fail with ESPIPE on pipes on some " \
617
"systems - use gnulib module lseek for portability"), \
1089
# if HAVE_RAW_DECL_LSEEK
1090
_GL_WARN_ON_USE (lseek, "lseek does not fail with ESPIPE on pipes on some "
1091
"systems - use gnulib module lseek for portability");
1097
/* Create a pipe, defaulting to O_BINARY mode.
1098
Store the read-end as fd[0] and the write-end as fd[1].
1099
Return 0 upon success, or -1 with errno set upon failure. */
1101
_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
1103
_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
1104
_GL_CXXALIASWARN (pipe);
1105
#elif defined GNULIB_POSIXCHECK
1107
# if HAVE_RAW_DECL_PIPE
1108
_GL_WARN_ON_USE (pipe, "pipe is unportable - "
1109
"use gnulib module pipe-posix for portability");
629
1121
See also the Linux man page at
630
1122
<http://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
631
1123
# if @HAVE_PIPE2@
632
# define pipe2 rpl_pipe2
1124
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1125
# define pipe2 rpl_pipe2
1127
_GL_FUNCDECL_RPL (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1128
_GL_CXXALIAS_RPL (pipe2, int, (int fd[2], int flags));
1130
_GL_FUNCDECL_SYS (pipe2, int, (int fd[2], int flags) _GL_ARG_NONNULL ((1)));
1131
_GL_CXXALIAS_SYS (pipe2, int, (int fd[2], int flags));
634
extern int pipe2 (int fd[2], int flags);
1133
_GL_CXXALIASWARN (pipe2);
635
1134
#elif defined GNULIB_POSIXCHECK
637
# define pipe2(f,o) \
638
(GL_LINK_WARNING ("pipe2 is unportable - " \
639
"use gnulib module pipe2 for portability"), \
1136
# if HAVE_RAW_DECL_PIPE2
1137
_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
1138
"use gnulib module pipe2 for portability");
1144
/* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1145
Return the number of bytes placed into BUF if successful, otherwise
1146
set errno and return -1. 0 indicates EOF.
1147
See the POSIX:2008 specification
1148
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1149
# if @REPLACE_PREAD@
1150
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1152
# define pread rpl_pread
1154
_GL_FUNCDECL_RPL (pread, ssize_t,
1155
(int fd, void *buf, size_t bufsize, off_t offset)
1156
_GL_ARG_NONNULL ((2)));
1157
_GL_CXXALIAS_RPL (pread, ssize_t,
1158
(int fd, void *buf, size_t bufsize, off_t offset));
1161
_GL_FUNCDECL_SYS (pread, ssize_t,
1162
(int fd, void *buf, size_t bufsize, off_t offset)
1163
_GL_ARG_NONNULL ((2)));
1165
_GL_CXXALIAS_SYS (pread, ssize_t,
1166
(int fd, void *buf, size_t bufsize, off_t offset));
1168
_GL_CXXALIASWARN (pread);
1169
#elif defined GNULIB_POSIXCHECK
1171
# if HAVE_RAW_DECL_PREAD
1172
_GL_WARN_ON_USE (pread, "pread is unportable - "
1173
"use gnulib module pread for portability");
1179
/* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1180
Return the number of bytes written if successful, otherwise
1181
set errno and return -1. 0 indicates nothing written. See the
1182
POSIX:2008 specification
1183
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1184
# if @REPLACE_PWRITE@
1185
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1187
# define pwrite rpl_pwrite
1189
_GL_FUNCDECL_RPL (pwrite, ssize_t,
1190
(int fd, const void *buf, size_t bufsize, off_t offset)
1191
_GL_ARG_NONNULL ((2)));
1192
_GL_CXXALIAS_RPL (pwrite, ssize_t,
1193
(int fd, const void *buf, size_t bufsize, off_t offset));
1196
_GL_FUNCDECL_SYS (pwrite, ssize_t,
1197
(int fd, const void *buf, size_t bufsize, off_t offset)
1198
_GL_ARG_NONNULL ((2)));
1200
_GL_CXXALIAS_SYS (pwrite, ssize_t,
1201
(int fd, const void *buf, size_t bufsize, off_t offset));
1203
_GL_CXXALIASWARN (pwrite);
1204
#elif defined GNULIB_POSIXCHECK
1206
# if HAVE_RAW_DECL_PWRITE
1207
_GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
1208
"use gnulib module pwrite for portability");
1214
/* Read up to COUNT bytes from file descriptor FD into the buffer starting
1215
at BUF. See the POSIX:2008 specification
1216
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1218
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1220
# define read rpl_read
1222
_GL_FUNCDECL_RPL (read, ssize_t, (int fd, void *buf, size_t count)
1223
_GL_ARG_NONNULL ((2)));
1224
_GL_CXXALIAS_RPL (read, ssize_t, (int fd, void *buf, size_t count));
1226
/* Need to cast, because on mingw, the third parameter is
1228
and the return type is 'int'. */
1229
_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
1231
_GL_CXXALIASWARN (read);
644
1235
#if @GNULIB_READLINK@
645
# if @REPLACE_READLINK@
646
# define readlink rpl_readlink
648
1236
/* Read the contents of the symbolic link FILE and place the first BUFSIZE
649
1237
bytes of it into BUF. Return the number of bytes placed into BUF if
650
1238
successful, otherwise -1 and errno set.
651
See the POSIX:2001 specification
652
<http://www.opengroup.org/susv3xsh/readlink.html>. */
653
# if !@HAVE_READLINK@ || @REPLACE_READLINK@
654
extern ssize_t readlink (const char *file, char *buf, size_t bufsize);
1239
See the POSIX:2008 specification
1240
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1241
# if @REPLACE_READLINK@
1242
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1243
# define readlink rpl_readlink
1245
_GL_FUNCDECL_RPL (readlink, ssize_t,
1246
(const char *file, char *buf, size_t bufsize)
1247
_GL_ARG_NONNULL ((1, 2)));
1248
_GL_CXXALIAS_RPL (readlink, ssize_t,
1249
(const char *file, char *buf, size_t bufsize));
1251
# if !@HAVE_READLINK@
1252
_GL_FUNCDECL_SYS (readlink, ssize_t,
1253
(const char *file, char *buf, size_t bufsize)
1254
_GL_ARG_NONNULL ((1, 2)));
1256
_GL_CXXALIAS_SYS (readlink, ssize_t,
1257
(const char *file, char *buf, size_t bufsize));
1259
_GL_CXXALIASWARN (readlink);
656
1260
#elif defined GNULIB_POSIXCHECK
657
1261
# undef readlink
658
# define readlink(f,b,s) \
659
(GL_LINK_WARNING ("readlink is unportable - " \
660
"use gnulib module readlink for portability"), \
1262
# if HAVE_RAW_DECL_READLINK
1263
_GL_WARN_ON_USE (readlink, "readlink is unportable - "
1264
"use gnulib module readlink for portability");
665
1269
#if @GNULIB_READLINKAT@
666
1270
# if !@HAVE_READLINKAT@
667
ssize_t readlinkat (int fd, char const *file, char *buf, size_t len);
1271
_GL_FUNCDECL_SYS (readlinkat, ssize_t,
1272
(int fd, char const *file, char *buf, size_t len)
1273
_GL_ARG_NONNULL ((2, 3)));
1275
_GL_CXXALIAS_SYS (readlinkat, ssize_t,
1276
(int fd, char const *file, char *buf, size_t len));
1277
_GL_CXXALIASWARN (readlinkat);
669
1278
#elif defined GNULIB_POSIXCHECK
670
1279
# undef readlinkat
671
# define readlinkat(d,n,b,l) \
672
(GL_LINK_WARNING ("readlinkat is not portable - " \
673
"use gnulib module symlinkat for portability"), \
674
readlinkat (d, n, b, l))
1280
# if HAVE_RAW_DECL_READLINKAT
1281
_GL_WARN_ON_USE (readlinkat, "readlinkat is not portable - "
1282
"use gnulib module readlinkat for portability");
678
1287
#if @GNULIB_RMDIR@
1288
/* Remove the directory DIR. */
679
1289
# if @REPLACE_RMDIR@
680
# define rmdir rpl_rmdir
681
/* Remove the directory DIR. */
682
extern int rmdir (char const *name);
1290
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1291
# define rmdir rpl_rmdir
1293
_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
1294
_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
1296
_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
1298
_GL_CXXALIASWARN (rmdir);
684
1299
#elif defined GNULIB_POSIXCHECK
687
(GL_LINK_WARNING ("rmdir is unportable - " \
688
"use gnulib module rmdir for portability"), \
1301
# if HAVE_RAW_DECL_RMDIR
1302
_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
1303
"use gnulib module rmdir for portability");
1308
#if @GNULIB_SETHOSTNAME@
1309
/* Set the host name of the machine.
1310
The host name may or may not be fully qualified.
1312
Put LEN bytes of NAME into the host name.
1313
Return 0 if successful, otherwise, set errno and return -1.
1315
Platforms with no ability to set the hostname return -1 and set
1317
# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
1318
_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
1319
_GL_ARG_NONNULL ((1)));
1321
/* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1322
and FreeBSD 6.4 the second parameter is int. On Solaris 11
1323
2011-10, the first parameter is not const. */
1324
_GL_CXXALIAS_SYS_CAST (sethostname, int, (const char *name, size_t len));
1325
_GL_CXXALIASWARN (sethostname);
1326
#elif defined GNULIB_POSIXCHECK
1328
# if HAVE_RAW_DECL_SETHOSTNAME
1329
_GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
1330
"use gnulib module sethostname for portability");
693
1335
#if @GNULIB_SLEEP@
694
1336
/* Pause the execution of the current thread for N seconds.
695
1337
Returns the number of seconds left to sleep.
696
See the POSIX:2001 specification
697
<http://www.opengroup.org/susv3xsh/sleep.html>. */
699
extern unsigned int sleep (unsigned int n);
1338
See the POSIX:2008 specification
1339
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1340
# if @REPLACE_SLEEP@
1341
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1343
# define sleep rpl_sleep
1345
_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
1346
_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
1349
_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
1351
_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
1353
_GL_CXXALIASWARN (sleep);
701
1354
#elif defined GNULIB_POSIXCHECK
704
(GL_LINK_WARNING ("sleep is unportable - " \
705
"use gnulib module sleep for portability"), \
1356
# if HAVE_RAW_DECL_SLEEP
1357
_GL_WARN_ON_USE (sleep, "sleep is unportable - "
1358
"use gnulib module sleep for portability");
710
1363
#if @GNULIB_SYMLINK@
711
1364
# if @REPLACE_SYMLINK@
713
# define symlink rpl_symlink
715
# if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
716
int symlink (char const *contents, char const *file);
1365
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1367
# define symlink rpl_symlink
1369
_GL_FUNCDECL_RPL (symlink, int, (char const *contents, char const *file)
1370
_GL_ARG_NONNULL ((1, 2)));
1371
_GL_CXXALIAS_RPL (symlink, int, (char const *contents, char const *file));
1373
# if !@HAVE_SYMLINK@
1374
_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
1375
_GL_ARG_NONNULL ((1, 2)));
1377
_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
1379
_GL_CXXALIASWARN (symlink);
718
1380
#elif defined GNULIB_POSIXCHECK
720
# define symlink(c,n) \
721
(GL_LINK_WARNING ("symlink is not portable - " \
722
"use gnulib module symlink for portability"), \
1382
# if HAVE_RAW_DECL_SYMLINK
1383
_GL_WARN_ON_USE (symlink, "symlink is not portable - "
1384
"use gnulib module symlink for portability");
727
1389
#if @GNULIB_SYMLINKAT@
728
1390
# if !@HAVE_SYMLINKAT@
729
int symlinkat (char const *contents, int fd, char const *file);
1391
_GL_FUNCDECL_SYS (symlinkat, int,
1392
(char const *contents, int fd, char const *file)
1393
_GL_ARG_NONNULL ((1, 3)));
1395
_GL_CXXALIAS_SYS (symlinkat, int,
1396
(char const *contents, int fd, char const *file));
1397
_GL_CXXALIASWARN (symlinkat);
731
1398
#elif defined GNULIB_POSIXCHECK
732
1399
# undef symlinkat
733
# define symlinkat(c,d,n) \
734
(GL_LINK_WARNING ("symlinkat is not portable - " \
735
"use gnulib module symlinkat for portability"), \
1400
# if HAVE_RAW_DECL_SYMLINKAT
1401
_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
1402
"use gnulib module symlinkat for portability");
1407
#if @GNULIB_TTYNAME_R@
1408
/* Store at most BUFLEN characters of the pathname of the terminal FD is
1409
open on in BUF. Return 0 on success, otherwise an error number. */
1410
# if @REPLACE_TTYNAME_R@
1411
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1413
# define ttyname_r rpl_ttyname_r
1415
_GL_FUNCDECL_RPL (ttyname_r, int,
1416
(int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1417
_GL_CXXALIAS_RPL (ttyname_r, int,
1418
(int fd, char *buf, size_t buflen));
1420
# if !@HAVE_DECL_TTYNAME_R@
1421
_GL_FUNCDECL_SYS (ttyname_r, int,
1422
(int fd, char *buf, size_t buflen) _GL_ARG_NONNULL ((2)));
1424
_GL_CXXALIAS_SYS (ttyname_r, int,
1425
(int fd, char *buf, size_t buflen));
1427
_GL_CXXALIASWARN (ttyname_r);
1428
#elif defined GNULIB_POSIXCHECK
1430
# if HAVE_RAW_DECL_TTYNAME_R
1431
_GL_WARN_ON_USE (ttyname_r, "ttyname_r is not portable - "
1432
"use gnulib module ttyname_r for portability");
740
1437
#if @GNULIB_UNLINK@
741
1438
# if @REPLACE_UNLINK@
743
# define unlink rpl_unlink
744
extern int unlink (char const *file);
1439
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1441
# define unlink rpl_unlink
1443
_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
1444
_GL_CXXALIAS_RPL (unlink, int, (char const *file));
1446
_GL_CXXALIAS_SYS (unlink, int, (char const *file));
1448
_GL_CXXALIASWARN (unlink);
746
1449
#elif defined GNULIB_POSIXCHECK
749
(GL_LINK_WARNING ("unlink is not portable - " \
750
"use gnulib module unlink for portability"), \
1451
# if HAVE_RAW_DECL_UNLINK
1452
_GL_WARN_ON_USE (unlink, "unlink is not portable - "
1453
"use gnulib module unlink for portability");
755
1458
#if @GNULIB_UNLINKAT@
756
1459
# if @REPLACE_UNLINKAT@
758
# define unlinkat rpl_unlinkat
760
# if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
761
extern int unlinkat (int fd, char const *file, int flag);
1460
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1462
# define unlinkat rpl_unlinkat
1464
_GL_FUNCDECL_RPL (unlinkat, int, (int fd, char const *file, int flag)
1465
_GL_ARG_NONNULL ((2)));
1466
_GL_CXXALIAS_RPL (unlinkat, int, (int fd, char const *file, int flag));
1468
# if !@HAVE_UNLINKAT@
1469
_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
1470
_GL_ARG_NONNULL ((2)));
1472
_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
1474
_GL_CXXALIASWARN (unlinkat);
763
1475
#elif defined GNULIB_POSIXCHECK
764
1476
# undef unlinkat
765
# define unlinkat(d,n,f) \
766
(GL_LINK_WARNING ("unlinkat is not portable - " \
767
"use gnulib module openat for portability"), \
772
#if @GNULIB_WRITE@ && @REPLACE_WRITE@ && @GNULIB_UNISTD_H_SIGPIPE@
1477
# if HAVE_RAW_DECL_UNLINKAT
1478
_GL_WARN_ON_USE (unlinkat, "unlinkat is not portable - "
1479
"use gnulib module openat for portability");
1485
/* Pause the execution of the current thread for N microseconds.
1486
Returns 0 on completion, or -1 on range error.
1487
See the POSIX:2001 specification
1488
<http://www.opengroup.org/susv3xsh/usleep.html>. */
1489
# if @REPLACE_USLEEP@
1490
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1492
# define usleep rpl_usleep
1494
_GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
1495
_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
1498
_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
1500
_GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
1502
_GL_CXXALIASWARN (usleep);
1503
#elif defined GNULIB_POSIXCHECK
1505
# if HAVE_RAW_DECL_USLEEP
1506
_GL_WARN_ON_USE (usleep, "usleep is unportable - "
1507
"use gnulib module usleep for portability");
773
1513
/* Write up to COUNT bytes starting at BUF to file descriptor FD.
774
See the POSIX:2001 specification
775
<http://www.opengroup.org/susv3xsh/write.html>. */
777
# define write rpl_write
778
extern ssize_t write (int fd, const void *buf, size_t count);
787
#endif /* _GL_UNISTD_H */
788
#endif /* _GL_UNISTD_H */
1514
See the POSIX:2008 specification
1515
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
1516
# if @REPLACE_WRITE@
1517
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1519
# define write rpl_write
1521
_GL_FUNCDECL_RPL (write, ssize_t, (int fd, const void *buf, size_t count)
1522
_GL_ARG_NONNULL ((2)));
1523
_GL_CXXALIAS_RPL (write, ssize_t, (int fd, const void *buf, size_t count));
1525
/* Need to cast, because on mingw, the third parameter is
1527
and the return type is 'int'. */
1528
_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
1530
_GL_CXXALIASWARN (write);
1534
#endif /* _@GUARD_PREFIX@_UNISTD_H */
1535
#endif /* _@GUARD_PREFIX@_UNISTD_H */