~ubuntu-branches/debian/experimental/liblouis/experimental

« back to all changes in this revision

Viewing changes to gnulib/unistd.in.h

  • Committer: Package Import Robot
  • Author(s): Samuel Thibault
  • Date: 2012-12-18 23:52:16 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20121218235216-nxoqw6pmfcdf02gh
Tags: 2.5.2-1
* New upstream release
  - Update copyright
  - Remove patches/format, merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Substitute for and wrapper around <unistd.h>.
2
 
   Copyright (C) 2003-2009 Free Software Foundation, Inc.
 
2
   Copyright (C) 2003-2012 Free Software Foundation, Inc.
3
3
 
4
4
   This program is free software; you can redistribute it and/or modify
5
5
   it under the terms of the GNU General Public License as published by
12
12
   GNU General Public License for more details.
13
13
 
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.  */
17
 
 
18
 
#ifndef _GL_UNISTD_H
 
15
   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
19
16
 
20
17
#if __GNUC__ >= 3
21
18
@PRAGMA_SYSTEM_HEADER@
22
19
#endif
 
20
@PRAGMA_COLUMNS@
 
21
 
 
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.  */
 
30
# if @HAVE_UNISTD_H@
 
31
#  @INCLUDE_NEXT@ @NEXT_UNISTD_H@
 
32
# else
 
33
#  error unexpected; report this to bug-gnulib@gnu.org
 
34
# endif
 
35
# define _GL_WINSOCK2_H_WITNESS
 
36
 
 
37
/* Normal invocation.  */
 
38
#elif !defined _@GUARD_PREFIX@_UNISTD_H
23
39
 
24
40
/* The include_next requires a split double-inclusion guard.  */
25
41
#if @HAVE_UNISTD_H@
26
42
# @INCLUDE_NEXT@ @NEXT_UNISTD_H@
27
43
#endif
28
44
 
29
 
#ifndef _GL_UNISTD_H
30
 
#define _GL_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
 
51
#endif
 
52
 
 
53
#if !defined _@GUARD_PREFIX@_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
 
54
#define _@GUARD_PREFIX@_UNISTD_H
31
55
 
32
56
/* NetBSD 5.0 mis-defines NULL.  Also get size_t.  */
33
57
#include <stddef.h>
34
58
 
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>
38
67
#endif
39
68
 
 
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__
 
73
# include <fcntl.h>
 
74
#endif
 
75
 
40
76
/* mingw fails to declare _exit in <unistd.h>.  */
41
 
/* mingw, BeOS, Haiku declare environ in <stdlib.h>, not in <unistd.h>.  */
42
 
#include <stdlib.h>
43
 
 
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
 
78
   <unistd.h>.  */
 
79
/* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
 
80
/* But avoid namespace pollution on glibc systems.  */
 
81
#ifndef __GLIBC__
 
82
# include <stdlib.h>
 
83
#endif
 
84
 
 
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__)
 
98
# include <io.h>
 
99
#endif
 
100
 
 
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__
 
107
# include <netdb.h>
 
108
#endif
 
109
 
 
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@
 
113
/* Get off_t.  */
 
114
# include <sys/types.h>
 
115
#endif
 
116
 
 
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>
49
122
#endif
50
123
 
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>
54
128
#endif
55
129
 
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.  */
 
131
 
 
132
/* The definition of _GL_ARG_NONNULL is copied here.  */
 
133
 
 
134
/* The definition of _GL_WARN_ON_USE is copied here.  */
 
135
 
 
136
 
 
137
/* Hide some function declarations from <winsock2.h>.  */
 
138
 
 
139
#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@
 
140
# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
 
141
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
61
142
#   undef socket
62
 
#   define socket               socket_used_without_including_sys_socket_h
 
143
#   define socket              socket_used_without_including_sys_socket_h
63
144
#   undef connect
64
 
#   define connect              connect_used_without_including_sys_socket_h
 
145
#   define connect             connect_used_without_including_sys_socket_h
65
146
#   undef accept
66
 
#   define accept               accept_used_without_including_sys_socket_h
 
147
#   define accept              accept_used_without_including_sys_socket_h
67
148
#   undef bind
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
75
156
#   undef listen
76
 
#   define listen               listen_used_without_including_sys_socket_h
 
157
#   define listen              listen_used_without_including_sys_socket_h
77
158
#   undef recv
78
 
#   define recv                 recv_used_without_including_sys_socket_h
 
159
#   define recv                recv_used_without_including_sys_socket_h
79
160
#   undef send
80
 
#   define send                 send_used_without_including_sys_socket_h
 
161
#   define send                send_used_without_including_sys_socket_h
81
162
#   undef recvfrom
82
 
#   define recvfrom             recvfrom_used_without_including_sys_socket_h
 
163
#   define recvfrom            recvfrom_used_without_including_sys_socket_h
83
164
#   undef sendto
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
87
168
#   undef shutdown
88
 
#   define shutdown             shutdown_used_without_including_sys_socket_h
 
169
#   define shutdown            shutdown_used_without_including_sys_socket_h
 
170
#  else
 
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>");
89
199
#  endif
90
 
#  if !defined _GL_SYS_SELECT_H
 
200
# endif
 
201
# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
 
202
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
91
203
#   undef select
92
 
#   define select               select_used_without_including_sys_select_h
 
204
#   define select              select_used_without_including_sys_select_h
 
205
#  else
 
206
    _GL_WARN_ON_USE (select,
 
207
                     "select() used without including <sys/select.h>");
93
208
#  endif
94
209
# endif
95
210
#endif
96
211
 
97
 
/* The definition of GL_LINK_WARNING is copied here.  */
98
 
 
99
212
 
100
213
/* OS/2 EMX lacks these macros.  */
101
214
#ifndef STDIN_FILENO
119
232
 
120
233
/* Declare overridden functions.  */
121
234
 
122
 
#ifdef __cplusplus
123
 
extern "C" {
 
235
 
 
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");
 
240
#endif
 
241
 
 
242
 
 
243
#if @GNULIB_CHDIR@
 
244
_GL_CXXALIAS_SYS (chdir, int, (const char *file) _GL_ARG_NONNULL ((1)));
 
245
_GL_CXXALIASWARN (chdir);
 
246
#elif defined GNULIB_POSIXCHECK
 
247
# undef chdir
 
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");
 
251
# endif
124
252
#endif
125
253
 
126
254
 
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
131
 
#  endif
132
 
#  if REPLACE_CHOWN
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)
 
263
#   undef chown
138
264
#   define chown rpl_chown
139
 
extern int chown (const char *file, uid_t uid, gid_t gid);
140
 
#  endif
 
265
#  endif
 
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));
 
269
# else
 
270
#  if !@HAVE_CHOWN@
 
271
_GL_FUNCDECL_SYS (chown, int, (const char *file, uid_t uid, gid_t gid)
 
272
                              _GL_ARG_NONNULL ((1)));
 
273
#  endif
 
274
_GL_CXXALIAS_SYS (chown, int, (const char *file, uid_t uid, gid_t gid));
141
275
# endif
 
276
_GL_CXXALIASWARN (chown);
142
277
#elif defined GNULIB_POSIXCHECK
143
278
# undef chown
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"), \
148
 
     chown (f, u, g))
 
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");
 
283
# endif
149
284
#endif
150
285
 
151
286
 
152
287
#if @GNULIB_CLOSE@
153
288
# if @REPLACE_CLOSE@
154
289
/* Automatically included by modules that need a replacement for close.  */
155
 
#  undef close
156
 
#  define close rpl_close
157
 
extern int close (int);
 
290
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
291
#   undef close
 
292
#   define close rpl_close
 
293
#  endif
 
294
_GL_FUNCDECL_RPL (close, int, (int fd));
 
295
_GL_CXXALIAS_RPL (close, int, (int fd));
 
296
# else
 
297
_GL_CXXALIAS_SYS (close, int, (int fd));
158
298
# endif
 
299
_GL_CXXALIASWARN (close);
159
300
#elif @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
160
301
# undef close
161
302
# define close close_used_without_requesting_gnulib_module_close
162
303
#elif defined GNULIB_POSIXCHECK
163
304
# undef close
164
 
# define close(f) \
165
 
    (GL_LINK_WARNING ("close does not portably work on sockets - " \
166
 
                      "use gnulib module close for portability"), \
167
 
     close (f))
 
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");
168
308
#endif
169
309
 
170
310
 
171
 
#if @REPLACE_DUP@
172
 
# define dup rpl_dup
173
 
extern int dup (int);
 
311
#if @GNULIB_DUP@
 
312
# if @REPLACE_DUP@
 
313
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
314
#   define dup rpl_dup
 
315
#  endif
 
316
_GL_FUNCDECL_RPL (dup, int, (int oldfd));
 
317
_GL_CXXALIAS_RPL (dup, int, (int oldfd));
 
318
# else
 
319
_GL_CXXALIAS_SYS (dup, int, (int oldfd));
 
320
# endif
 
321
_GL_CXXALIASWARN (dup);
 
322
#elif defined GNULIB_POSIXCHECK
 
323
# undef dup
 
324
# if HAVE_RAW_DECL_DUP
 
325
_GL_WARN_ON_USE (dup, "dup is unportable - "
 
326
                 "use gnulib module dup for portability");
 
327
# endif
174
328
#endif
175
329
 
176
330
 
177
331
#if @GNULIB_DUP2@
178
 
# if @REPLACE_DUP2@
179
 
#  define dup2 rpl_dup2
180
 
# endif
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>.  */
 
337
# if @REPLACE_DUP2@
 
338
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
339
#   define dup2 rpl_dup2
 
340
#  endif
 
341
_GL_FUNCDECL_RPL (dup2, int, (int oldfd, int newfd));
 
342
_GL_CXXALIAS_RPL (dup2, int, (int oldfd, int newfd));
 
343
# else
 
344
#  if !@HAVE_DUP2@
 
345
_GL_FUNCDECL_SYS (dup2, int, (int oldfd, int newfd));
 
346
#  endif
 
347
_GL_CXXALIAS_SYS (dup2, int, (int oldfd, int newfd));
188
348
# endif
 
349
_GL_CXXALIASWARN (dup2);
189
350
#elif defined GNULIB_POSIXCHECK
190
351
# undef dup2
191
 
# define dup2(o,n) \
192
 
    (GL_LINK_WARNING ("dup2 is unportable - " \
193
 
                      "use gnulib module dup2 for portability"), \
194
 
     dup2 (o, n))
 
352
# if HAVE_RAW_DECL_DUP2
 
353
_GL_WARN_ON_USE (dup2, "dup2 is unportable - "
 
354
                 "use gnulib module dup2 for portability");
 
355
# endif
195
356
#endif
196
357
 
197
358
 
205
366
   See the Linux man page at
206
367
   <http://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>.  */
207
368
# if @HAVE_DUP3@
208
 
#  define dup3 rpl_dup3
 
369
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
370
#   define dup3 rpl_dup3
 
371
#  endif
 
372
_GL_FUNCDECL_RPL (dup3, int, (int oldfd, int newfd, int flags));
 
373
_GL_CXXALIAS_RPL (dup3, int, (int oldfd, int newfd, int flags));
 
374
# else
 
375
_GL_FUNCDECL_SYS (dup3, int, (int oldfd, int newfd, int flags));
 
376
_GL_CXXALIAS_SYS (dup3, int, (int oldfd, int newfd, int flags));
209
377
# endif
210
 
extern int dup3 (int oldfd, int newfd, int flags);
 
378
_GL_CXXALIASWARN (dup3);
211
379
#elif defined GNULIB_POSIXCHECK
212
380
# undef dup3
213
 
# define dup3(o,n,f) \
214
 
    (GL_LINK_WARNING ("dup3 is unportable - " \
215
 
                      "use gnulib module dup3 for portability"), \
216
 
     dup3 (o, n, f))
 
381
# if HAVE_RAW_DECL_DUP3
 
382
_GL_WARN_ON_USE (dup3, "dup3 is unportable - "
 
383
                 "use gnulib module dup3 for portability");
 
384
# endif
217
385
#endif
218
386
 
219
387
 
225
393
#   include <crt_externs.h>
226
394
#   define environ (*_NSGetEnviron ())
227
395
#  else
 
396
#   ifdef __cplusplus
 
397
extern "C" {
 
398
#   endif
228
399
extern char **environ;
 
400
#   ifdef __cplusplus
 
401
}
 
402
#   endif
229
403
#  endif
230
404
# endif
231
405
#elif defined GNULIB_POSIXCHECK
232
 
# undef environ
233
 
# define environ \
234
 
    (GL_LINK_WARNING ("environ is unportable - " \
235
 
                      "use gnulib module environ for portability"), \
236
 
     environ)
 
406
# if HAVE_RAW_DECL_ENVIRON
 
407
static inline char ***
 
408
rpl_environ (void)
 
409
{
 
410
  return &environ;
 
411
}
 
412
_GL_WARN_ON_USE (rpl_environ, "environ is unportable - "
 
413
                 "use gnulib module environ for portability");
 
414
#  undef environ
 
415
#  define environ (*rpl_environ ())
 
416
# endif
237
417
#endif
238
418
 
239
419
 
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)));
 
426
# endif
 
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");
245
433
# endif
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"), \
251
 
     euidaccess (f, m))
 
436
# if HAVE_RAW_DECL_EUIDACCESS
 
437
_GL_WARN_ON_USE (euidaccess, "euidaccess is unportable - "
 
438
                 "use gnulib module euidaccess for portability");
 
439
# endif
252
440
#endif
253
441
 
254
442
 
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)));
258
448
# endif
 
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");
 
457
# endif
265
458
#endif
266
459
 
267
460
 
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>.  */
 
467
# if ! @HAVE_FCHDIR@
 
468
_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
276
469
 
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);
282
476
 
 
477
# else
 
478
#  if !@HAVE_DECL_FCHDIR@
 
479
_GL_FUNCDECL_SYS (fchdir, int, (int /*fd*/));
 
480
#  endif
283
481
# endif
 
482
_GL_CXXALIAS_SYS (fchdir, int, (int /*fd*/));
 
483
_GL_CXXALIASWARN (fchdir);
284
484
#elif defined GNULIB_POSIXCHECK
285
485
# undef fchdir
286
 
# define fchdir(f) \
287
 
    (GL_LINK_WARNING ("fchdir is unportable - " \
288
 
                      "use gnulib module fchdir for portability"), \
289
 
     fchdir (f))
 
486
# if HAVE_RAW_DECL_FCHDIR
 
487
_GL_WARN_ON_USE (fchdir, "fchdir is unportable - "
 
488
                 "use gnulib module fchdir for portability");
 
489
# endif
290
490
#endif
291
491
 
292
492
 
293
493
#if @GNULIB_FCHOWNAT@
294
494
# if @REPLACE_FCHOWNAT@
295
 
#  undef fchownat
296
 
#  define fchownat rpl_fchownat
297
 
# endif
298
 
# if !@HAVE_FCHOWNAT@ || @REPLACE_FCHOWNAT@
299
 
extern int fchownat (int fd, char const *file, uid_t owner, gid_t group, int flag);
300
 
# endif
 
495
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
496
#   undef fchownat
 
497
#   define fchownat rpl_fchownat
 
498
#  endif
 
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));
 
504
# else
 
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)));
 
509
#  endif
 
510
_GL_CXXALIAS_SYS (fchownat, int, (int fd, char const *file,
 
511
                                  uid_t owner, gid_t group, int flag));
 
512
# endif
 
513
_GL_CXXALIASWARN (fchownat);
301
514
#elif defined GNULIB_POSIXCHECK
302
515
# undef fchownat
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");
 
519
# endif
 
520
#endif
 
521
 
 
522
 
 
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));
 
530
# endif
 
531
_GL_CXXALIAS_SYS (fdatasync, int, (int fd));
 
532
_GL_CXXALIASWARN (fdatasync);
 
533
#elif defined GNULIB_POSIXCHECK
 
534
# undef fdatasync
 
535
# if HAVE_RAW_DECL_FDATASYNC
 
536
_GL_WARN_ON_USE (fdatasync, "fdatasync is unportable - "
 
537
                 "use gnulib module fdatasync for portability");
 
538
# endif
307
539
#endif
308
540
 
309
541
 
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));
317
549
# endif
 
550
_GL_CXXALIAS_SYS (fsync, int, (int fd));
 
551
_GL_CXXALIASWARN (fsync);
318
552
#elif defined GNULIB_POSIXCHECK
319
553
# undef fsync
320
 
# define fsync(fd) \
321
 
    (GL_LINK_WARNING ("fsync is unportable - " \
322
 
                      "use gnulib module fsync for portability"), \
323
 
     fsync (fd))
 
554
# if HAVE_RAW_DECL_FSYNC
 
555
_GL_WARN_ON_USE (fsync, "fsync is unportable - "
 
556
                 "use gnulib module fsync for portability");
 
557
# endif
324
558
#endif
325
559
 
326
560
 
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)
 
568
#   undef ftruncate
 
569
#   define ftruncate rpl_ftruncate
 
570
#  endif
 
571
_GL_FUNCDECL_RPL (ftruncate, int, (int fd, off_t length));
 
572
_GL_CXXALIAS_RPL (ftruncate, int, (int fd, off_t length));
 
573
# else
 
574
#  if !@HAVE_FTRUNCATE@
 
575
_GL_FUNCDECL_SYS (ftruncate, int, (int fd, off_t length));
 
576
#  endif
 
577
_GL_CXXALIAS_SYS (ftruncate, int, (int fd, off_t length));
334
578
# endif
 
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"), \
340
 
     ftruncate (f, l))
 
582
# if HAVE_RAW_DECL_FTRUNCATE
 
583
_GL_WARN_ON_USE (ftruncate, "ftruncate is unportable - "
 
584
                 "use gnulib module ftruncate for portability");
 
585
# endif
341
586
#endif
342
587
 
343
588
 
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.  */
347
 
# include <stdlib.h>
348
 
# if @REPLACE_GETCWD@
349
590
/* Get the name of the current working directory, and put it in SIZE bytes
350
591
   of BUF.
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
358
599
   necessary.  */
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
 
603
#  endif
 
604
_GL_FUNCDECL_RPL (getcwd, char *, (char *buf, size_t size));
 
605
_GL_CXXALIAS_RPL (getcwd, char *, (char *buf, size_t size));
 
606
# else
 
607
/* Need to cast, because on mingw, the second parameter is
 
608
                                                   int size.  */
 
609
_GL_CXXALIAS_SYS_CAST (getcwd, char *, (char *buf, size_t size));
361
610
# endif
 
611
_GL_CXXALIASWARN (getcwd);
362
612
#elif defined GNULIB_POSIXCHECK
363
613
# undef getcwd
364
 
# define getcwd(b,s) \
365
 
    (GL_LINK_WARNING ("getcwd is unportable - " \
366
 
                      "use gnulib module getcwd for portability"), \
367
 
     getcwd (b, s))
 
614
# if HAVE_RAW_DECL_GETCWD
 
615
_GL_WARN_ON_USE (getcwd, "getcwd is unportable - "
 
616
                 "use gnulib module getcwd for portability");
 
617
# endif
368
618
#endif
369
619
 
370
620
 
379
629
   Null terminate it if the name is shorter than LEN.
380
630
   If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
381
631
   Return 0 if successful, otherwise set errno and return -1.  */
382
 
# if !@HAVE_GETDOMAINNAME@
383
 
extern int getdomainname(char *name, size_t len);
 
632
# if @REPLACE_GETDOMAINNAME@
 
633
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
634
#   undef getdomainname
 
635
#   define getdomainname rpl_getdomainname
 
636
#  endif
 
637
_GL_FUNCDECL_RPL (getdomainname, int, (char *name, size_t len)
 
638
                                      _GL_ARG_NONNULL ((1)));
 
639
_GL_CXXALIAS_RPL (getdomainname, int, (char *name, size_t len));
 
640
# else
 
641
#  if !@HAVE_DECL_GETDOMAINNAME@
 
642
_GL_FUNCDECL_SYS (getdomainname, int, (char *name, size_t len)
 
643
                                      _GL_ARG_NONNULL ((1)));
 
644
#  endif
 
645
_GL_CXXALIAS_SYS (getdomainname, int, (char *name, size_t len));
384
646
# endif
 
647
_GL_CXXALIASWARN (getdomainname);
385
648
#elif defined GNULIB_POSIXCHECK
386
649
# undef getdomainname
387
 
# define getdomainname(n,l) \
388
 
    (GL_LINK_WARNING ("getdomainname is unportable - " \
389
 
                      "use gnulib module getdomainname for portability"), \
390
 
     getdomainname (n, l))
 
650
# if HAVE_RAW_DECL_GETDOMAINNAME
 
651
_GL_WARN_ON_USE (getdomainname, "getdomainname is unportable - "
 
652
                 "use gnulib module getdomainname for portability");
 
653
# endif
391
654
#endif
392
655
 
393
656
 
394
657
#if @GNULIB_GETDTABLESIZE@
395
 
# if !@HAVE_GETDTABLESIZE@
396
658
/* Return the maximum number of file descriptors in the current process.
397
659
   In POSIX, this is same as sysconf (_SC_OPEN_MAX).  */
398
 
extern int getdtablesize (void);
 
660
# if !@HAVE_GETDTABLESIZE@
 
661
_GL_FUNCDECL_SYS (getdtablesize, int, (void));
399
662
# endif
 
663
_GL_CXXALIAS_SYS (getdtablesize, int, (void));
 
664
_GL_CXXALIASWARN (getdtablesize);
400
665
#elif defined GNULIB_POSIXCHECK
401
666
# undef getdtablesize
402
 
# define getdtablesize() \
403
 
    (GL_LINK_WARNING ("getdtablesize is unportable - " \
404
 
                      "use gnulib module getdtablesize for portability"), \
405
 
     getdtablesize ())
 
667
# if HAVE_RAW_DECL_GETDTABLESIZE
 
668
_GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
 
669
                 "use gnulib module getdtablesize for portability");
 
670
# endif
 
671
#endif
 
672
 
 
673
 
 
674
#if @GNULIB_GETGROUPS@
 
675
/* Return the supplemental groups that the current process belongs to.
 
676
   It is unspecified whether the effective group id is in the list.
 
677
   If N is 0, return the group count; otherwise, N describes how many
 
678
   entries are available in GROUPS.  Return -1 and set errno if N is
 
679
   not 0 and not large enough.  Fails with ENOSYS on some systems.  */
 
680
# if @REPLACE_GETGROUPS@
 
681
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
682
#   undef getgroups
 
683
#   define getgroups rpl_getgroups
 
684
#  endif
 
685
_GL_FUNCDECL_RPL (getgroups, int, (int n, gid_t *groups));
 
686
_GL_CXXALIAS_RPL (getgroups, int, (int n, gid_t *groups));
 
687
# else
 
688
#  if !@HAVE_GETGROUPS@
 
689
_GL_FUNCDECL_SYS (getgroups, int, (int n, gid_t *groups));
 
690
#  endif
 
691
_GL_CXXALIAS_SYS (getgroups, int, (int n, gid_t *groups));
 
692
# endif
 
693
_GL_CXXALIASWARN (getgroups);
 
694
#elif defined GNULIB_POSIXCHECK
 
695
# undef getgroups
 
696
# if HAVE_RAW_DECL_GETGROUPS
 
697
_GL_WARN_ON_USE (getgroups, "getgroups is unportable - "
 
698
                 "use gnulib module getgroups for portability");
 
699
# endif
406
700
#endif
407
701
 
408
702
 
415
709
   If the host name is longer than LEN, set errno = EINVAL and return -1.
416
710
   Return 0 if successful, otherwise set errno and return -1.  */
417
711
# if @UNISTD_H_HAVE_WINSOCK2_H@
418
 
#  undef gethostname
419
 
#  define gethostname rpl_gethostname
420
 
# endif
421
 
# if @UNISTD_H_HAVE_WINSOCK2_H@ || !@HAVE_GETHOSTNAME@
422
 
extern int gethostname(char *name, size_t len);
423
 
# endif
 
712
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
713
#   undef gethostname
 
714
#   define gethostname rpl_gethostname
 
715
#  endif
 
716
_GL_FUNCDECL_RPL (gethostname, int, (char *name, size_t len)
 
717
                                    _GL_ARG_NONNULL ((1)));
 
718
_GL_CXXALIAS_RPL (gethostname, int, (char *name, size_t len));
 
719
# else
 
720
#  if !@HAVE_GETHOSTNAME@
 
721
_GL_FUNCDECL_SYS (gethostname, int, (char *name, size_t len)
 
722
                                    _GL_ARG_NONNULL ((1)));
 
723
#  endif
 
724
/* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
 
725
   parameter is
 
726
                                                      int len.  */
 
727
_GL_CXXALIAS_SYS_CAST (gethostname, int, (char *name, size_t len));
 
728
# endif
 
729
_GL_CXXALIASWARN (gethostname);
424
730
#elif @UNISTD_H_HAVE_WINSOCK2_H@
425
731
# undef gethostname
426
732
# define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
427
733
#elif defined GNULIB_POSIXCHECK
428
734
# undef gethostname
429
 
# define gethostname(n,l) \
430
 
    (GL_LINK_WARNING ("gethostname is unportable - " \
431
 
                      "use gnulib module gethostname for portability"), \
432
 
     gethostname (n, l))
 
735
# if HAVE_RAW_DECL_GETHOSTNAME
 
736
_GL_WARN_ON_USE (gethostname, "gethostname is unportable - "
 
737
                 "use gnulib module gethostname for portability");
 
738
# endif
 
739
#endif
 
740
 
 
741
 
 
742
#if @GNULIB_GETLOGIN@
 
743
/* Returns the user's login name, or NULL if it cannot be found.  Upon error,
 
744
   returns NULL with errno set.
 
745
 
 
746
   See <http://www.opengroup.org/susv3xsh/getlogin.html>.
 
747
 
 
748
   Most programs don't need to use this function, because the information is
 
749
   available through environment variables:
 
750
     ${LOGNAME-$USER}        on Unix platforms,
 
751
     $USERNAME               on native Windows platforms.
 
752
 */
 
753
# if !@HAVE_GETLOGIN@
 
754
_GL_FUNCDECL_SYS (getlogin, char *, (void));
 
755
# endif
 
756
_GL_CXXALIAS_SYS (getlogin, char *, (void));
 
757
_GL_CXXALIASWARN (getlogin);
 
758
#elif defined GNULIB_POSIXCHECK
 
759
# undef getlogin
 
760
# if HAVE_RAW_DECL_GETLOGIN
 
761
_GL_WARN_ON_USE (getlogin, "getlogin is unportable - "
 
762
                 "use gnulib module getlogin for portability");
 
763
# endif
433
764
#endif
434
765
 
435
766
 
442
773
   provided (this case is hopefully rare but is left open by the POSIX spec).
443
774
 
444
775
   See <http://www.opengroup.org/susv3xsh/getlogin.html>.
 
776
 
 
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.
445
781
 */
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
 
785
#  endif
 
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));
 
789
# else
 
790
#  if !@HAVE_DECL_GETLOGIN_R@
 
791
_GL_FUNCDECL_SYS (getlogin_r, int, (char *name, size_t size)
 
792
                                   _GL_ARG_NONNULL ((1)));
 
793
#  endif
 
794
/* Need to cast, because on Solaris 10 systems, the second argument is
 
795
                                                     int size.  */
 
796
_GL_CXXALIAS_SYS_CAST (getlogin_r, int, (char *name, size_t size));
448
797
# endif
 
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"), \
454
 
     getlogin_r (n, s))
 
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");
 
804
# endif
455
805
#endif
456
806
 
457
807
 
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
 
812
#  endif
 
813
_GL_FUNCDECL_RPL (getpagesize, int, (void));
 
814
_GL_CXXALIAS_RPL (getpagesize, int, (void));
 
815
# else
 
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)
467
 
#   endif
468
 
#  endif
 
819
#    if !defined _gl_getpagesize && defined _SC_PAGESIZE
 
820
#     if ! (defined __VMS && __VMS_VER < 70000000)
 
821
#      define _gl_getpagesize() sysconf (_SC_PAGESIZE)
 
822
#     endif
 
823
#    endif
469
824
/* This is for older VMS.  */
470
 
#  if !defined getpagesize && defined __VMS
471
 
#   ifdef __ALPHA
472
 
#    define getpagesize() 8192
473
 
#   else
474
 
#    define getpagesize() 512
475
 
#   endif
476
 
#  endif
 
825
#    if !defined _gl_getpagesize && defined __VMS
 
826
#     ifdef __ALPHA
 
827
#      define _gl_getpagesize() 8192
 
828
#     else
 
829
#      define _gl_getpagesize() 512
 
830
#     endif
 
831
#    endif
477
832
/* This is for BeOS.  */
478
 
#  if !defined getpagesize && @HAVE_OS_H@
479
 
#   include <OS.h>
480
 
#   if defined B_PAGE_SIZE
481
 
#    define getpagesize() B_PAGE_SIZE
482
 
#   endif
483
 
#  endif
 
833
#    if !defined _gl_getpagesize && @HAVE_OS_H@
 
834
#     include <OS.h>
 
835
#     if defined B_PAGE_SIZE
 
836
#      define _gl_getpagesize() B_PAGE_SIZE
 
837
#     endif
 
838
#    endif
484
839
/* This is for AmigaOS4.0.  */
485
 
#  if !defined getpagesize && defined __amigaos4__
486
 
#   define getpagesize() 2048
487
 
#  endif
 
840
#    if !defined _gl_getpagesize && defined __amigaos4__
 
841
#     define _gl_getpagesize() 2048
 
842
#    endif
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
493
 
#   else
494
 
#    ifdef NBPG
495
 
#     ifndef CLSIZE
496
 
#      define CLSIZE 1
 
844
#    if !defined _gl_getpagesize && @HAVE_SYS_PARAM_H@
 
845
#     include <sys/param.h>
 
846
#     ifdef EXEC_PAGESIZE
 
847
#      define _gl_getpagesize() EXEC_PAGESIZE
 
848
#     else
 
849
#      ifdef NBPG
 
850
#       ifndef CLSIZE
 
851
#        define CLSIZE 1
 
852
#       endif
 
853
#       define _gl_getpagesize() (NBPG * CLSIZE)
 
854
#      else
 
855
#       ifdef NBPC
 
856
#        define _gl_getpagesize() NBPC
 
857
#       endif
 
858
#      endif
497
859
#     endif
498
 
#     define getpagesize() (NBPG * CLSIZE)
 
860
#    endif
 
861
#    if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
862
#     define getpagesize() _gl_getpagesize ()
499
863
#    else
500
 
#     ifdef NBPC
501
 
#      define getpagesize() NBPC
 
864
#     if !GNULIB_defined_getpagesize_function
 
865
static inline int
 
866
getpagesize ()
 
867
{
 
868
  return _gl_getpagesize ();
 
869
}
 
870
#      define GNULIB_defined_getpagesize_function 1
502
871
#     endif
503
872
#    endif
504
873
#   endif
505
874
#  endif
 
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));
 
877
# endif
 
878
# if @HAVE_DECL_GETPAGESIZE@
 
879
_GL_CXXALIASWARN (getpagesize);
506
880
# endif
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"), \
512
 
     getpagesize ())
 
883
# if HAVE_RAW_DECL_GETPAGESIZE
 
884
_GL_WARN_ON_USE (getpagesize, "getpagesize is unportable - "
 
885
                 "use gnulib module getpagesize for portability");
 
886
# endif
513
887
#endif
514
888
 
515
889
 
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));
 
895
# endif
 
896
_GL_CXXALIAS_SYS (getusershell, char *, (void));
 
897
_GL_CXXALIASWARN (getusershell);
 
898
#elif defined GNULIB_POSIXCHECK
 
899
# undef getusershell
 
900
# if HAVE_RAW_DECL_GETUSERSHELL
 
901
_GL_WARN_ON_USE (getusershell, "getusershell is unportable - "
 
902
                 "use gnulib module getusershell for portability");
 
903
# endif
 
904
#endif
 
905
 
 
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));
 
910
# endif
 
911
_GL_CXXALIAS_SYS (setusershell, void, (void));
 
912
_GL_CXXALIASWARN (setusershell);
 
913
#elif defined GNULIB_POSIXCHECK
 
914
# undef setusershell
 
915
# if HAVE_RAW_DECL_SETUSERSHELL
 
916
_GL_WARN_ON_USE (setusershell, "setusershell is unportable - "
 
917
                 "use gnulib module getusershell for portability");
 
918
# endif
 
919
#endif
 
920
 
 
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));
526
926
# endif
 
927
_GL_CXXALIAS_SYS (endusershell, void, (void));
 
928
_GL_CXXALIASWARN (endusershell);
527
929
#elif defined GNULIB_POSIXCHECK
528
 
# undef getusershell
529
 
# define getusershell() \
530
 
    (GL_LINK_WARNING ("getusershell is unportable - " \
531
 
                      "use gnulib module getusershell for portability"), \
532
 
     getusershell ())
533
 
# undef setusershell
534
 
# define setusershell() \
535
 
    (GL_LINK_WARNING ("setusershell is unportable - " \
536
 
                      "use gnulib module getusershell for portability"), \
537
 
     setusershell ())
538
930
# undef endusershell
539
 
# define endusershell() \
540
 
    (GL_LINK_WARNING ("endusershell is unportable - " \
541
 
                      "use gnulib module getusershell for portability"), \
542
 
     endusershell ())
 
931
# if HAVE_RAW_DECL_ENDUSERSHELL
 
932
_GL_WARN_ON_USE (endusershell, "endusershell is unportable - "
 
933
                 "use gnulib module getusershell for portability");
 
934
# endif
 
935
#endif
 
936
 
 
937
 
 
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));
 
942
# endif
 
943
_GL_CXXALIAS_SYS (group_member, int, (gid_t gid));
 
944
_GL_CXXALIASWARN (group_member);
 
945
#elif defined GNULIB_POSIXCHECK
 
946
# undef group_member
 
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");
 
950
# endif
 
951
#endif
 
952
 
 
953
 
 
954
#if @GNULIB_ISATTY@
 
955
# if @REPLACE_ISATTY@
 
956
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
957
#   undef isatty
 
958
#   define isatty rpl_isatty
 
959
#  endif
 
960
_GL_FUNCDECL_RPL (isatty, int, (int fd));
 
961
_GL_CXXALIAS_RPL (isatty, int, (int fd));
 
962
# else
 
963
_GL_CXXALIAS_SYS (isatty, int, (int fd));
 
964
# endif
 
965
_GL_CXXALIASWARN (isatty);
 
966
#elif defined GNULIB_POSIXCHECK
 
967
# undef isatty
 
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");
 
971
# endif
543
972
#endif
544
973
 
545
974
 
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)
 
983
#   undef lchown
 
984
#   define lchown rpl_lchown
 
985
#  endif
 
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));
 
989
# else
 
990
#  if !@HAVE_LCHOWN@
 
991
_GL_FUNCDECL_SYS (lchown, int, (char const *file, uid_t owner, gid_t group)
 
992
                               _GL_ARG_NONNULL ((1)));
 
993
#  endif
 
994
_GL_CXXALIAS_SYS (lchown, int, (char const *file, uid_t owner, gid_t group));
555
995
# endif
 
996
_GL_CXXALIASWARN (lchown);
556
997
#elif defined GNULIB_POSIXCHECK
557
998
# undef lchown
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"), \
561
 
     lchown (f, u, g))
 
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");
 
1002
# endif
562
1003
#endif
563
1004
 
564
1005
 
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
568
 
# endif
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);
575
 
# endif
 
1012
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
1013
#   define link rpl_link
 
1014
#  endif
 
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));
 
1018
# else
 
1019
#  if !@HAVE_LINK@
 
1020
_GL_FUNCDECL_SYS (link, int, (const char *path1, const char *path2)
 
1021
                             _GL_ARG_NONNULL ((1, 2)));
 
1022
#  endif
 
1023
_GL_CXXALIAS_SYS (link, int, (const char *path1, const char *path2));
 
1024
# endif
 
1025
_GL_CXXALIASWARN (link);
576
1026
#elif defined GNULIB_POSIXCHECK
577
1027
# undef link
578
 
# define link(path1,path2) \
579
 
    (GL_LINK_WARNING ("link is unportable - " \
580
 
                      "use gnulib module link for portability"), \
581
 
     link (path1, path2))
 
1028
# if HAVE_RAW_DECL_LINK
 
1029
_GL_WARN_ON_USE (link, "link is unportable - "
 
1030
                 "use gnulib module link for portability");
 
1031
# endif
582
1032
#endif
583
1033
 
 
1034
 
584
1035
#if @GNULIB_LINKAT@
585
 
# if @REPLACE_LINKAT@
586
 
#  undef linkat
587
 
#  define linkat rpl_linkat
588
 
# endif
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,
594
 
                   int flag);
 
1039
# if @REPLACE_LINKAT@
 
1040
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
1041
#   undef linkat
 
1042
#   define linkat rpl_linkat
 
1043
#  endif
 
1044
_GL_FUNCDECL_RPL (linkat, int,
 
1045
                  (int fd1, const char *path1, int fd2, const char *path2,
 
1046
                   int flag)
 
1047
                  _GL_ARG_NONNULL ((2, 4)));
 
1048
_GL_CXXALIAS_RPL (linkat, int,
 
1049
                  (int fd1, const char *path1, int fd2, const char *path2,
 
1050
                   int flag));
 
1051
# else
 
1052
#  if !@HAVE_LINKAT@
 
1053
_GL_FUNCDECL_SYS (linkat, int,
 
1054
                  (int fd1, const char *path1, int fd2, const char *path2,
 
1055
                   int flag)
 
1056
                  _GL_ARG_NONNULL ((2, 4)));
 
1057
#  endif
 
1058
_GL_CXXALIAS_SYS (linkat, int,
 
1059
                  (int fd1, const char *path1, int fd2, const char *path2,
 
1060
                   int flag));
595
1061
# endif
 
1062
_GL_CXXALIASWARN (linkat);
596
1063
#elif defined GNULIB_POSIXCHECK
597
1064
# undef linkat
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");
 
1068
# endif
602
1069
#endif
603
1070
 
 
1071
 
604
1072
#if @GNULIB_LSEEK@
605
 
# if @REPLACE_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
 
1080
#  endif
 
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));
 
1083
# else
 
1084
_GL_CXXALIAS_SYS (lseek, off_t, (int fd, off_t offset, int whence));
612
1085
# endif
 
1086
_GL_CXXALIASWARN (lseek);
613
1087
#elif defined GNULIB_POSIXCHECK
614
1088
# undef lseek
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"), \
618
 
     lseek (f, o, w))
 
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");
 
1092
# endif
 
1093
#endif
 
1094
 
 
1095
 
 
1096
#if @GNULIB_PIPE@
 
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.  */
 
1100
# if !@HAVE_PIPE@
 
1101
_GL_FUNCDECL_SYS (pipe, int, (int fd[2]) _GL_ARG_NONNULL ((1)));
 
1102
# endif
 
1103
_GL_CXXALIAS_SYS (pipe, int, (int fd[2]));
 
1104
_GL_CXXALIASWARN (pipe);
 
1105
#elif defined GNULIB_POSIXCHECK
 
1106
# undef pipe
 
1107
# if HAVE_RAW_DECL_PIPE
 
1108
_GL_WARN_ON_USE (pipe, "pipe is unportable - "
 
1109
                 "use gnulib module pipe-posix for portability");
 
1110
# endif
619
1111
#endif
620
1112
 
621
1113
 
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
 
1126
#  endif
 
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));
 
1129
# else
 
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));
633
1132
# endif
634
 
extern int pipe2 (int fd[2], int flags);
 
1133
_GL_CXXALIASWARN (pipe2);
635
1134
#elif defined GNULIB_POSIXCHECK
636
1135
# undef pipe2
637
 
# define pipe2(f,o) \
638
 
    (GL_LINK_WARNING ("pipe2 is unportable - " \
639
 
                      "use gnulib module pipe2 for portability"), \
640
 
     pipe2 (f, o))
 
1136
# if HAVE_RAW_DECL_PIPE2
 
1137
_GL_WARN_ON_USE (pipe2, "pipe2 is unportable - "
 
1138
                 "use gnulib module pipe2 for portability");
 
1139
# endif
 
1140
#endif
 
1141
 
 
1142
 
 
1143
#if @GNULIB_PREAD@
 
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)
 
1151
#   undef pread
 
1152
#   define pread rpl_pread
 
1153
#  endif
 
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));
 
1159
# else
 
1160
#  if !@HAVE_PREAD@
 
1161
_GL_FUNCDECL_SYS (pread, ssize_t,
 
1162
                  (int fd, void *buf, size_t bufsize, off_t offset)
 
1163
                  _GL_ARG_NONNULL ((2)));
 
1164
#  endif
 
1165
_GL_CXXALIAS_SYS (pread, ssize_t,
 
1166
                  (int fd, void *buf, size_t bufsize, off_t offset));
 
1167
# endif
 
1168
_GL_CXXALIASWARN (pread);
 
1169
#elif defined GNULIB_POSIXCHECK
 
1170
# undef pread
 
1171
# if HAVE_RAW_DECL_PREAD
 
1172
_GL_WARN_ON_USE (pread, "pread is unportable - "
 
1173
                 "use gnulib module pread for portability");
 
1174
# endif
 
1175
#endif
 
1176
 
 
1177
 
 
1178
#if @GNULIB_PWRITE@
 
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)
 
1186
#   undef pwrite
 
1187
#   define pwrite rpl_pwrite
 
1188
#  endif
 
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));
 
1194
# else
 
1195
#  if !@HAVE_PWRITE@
 
1196
_GL_FUNCDECL_SYS (pwrite, ssize_t,
 
1197
                  (int fd, const void *buf, size_t bufsize, off_t offset)
 
1198
                  _GL_ARG_NONNULL ((2)));
 
1199
#  endif
 
1200
_GL_CXXALIAS_SYS (pwrite, ssize_t,
 
1201
                  (int fd, const void *buf, size_t bufsize, off_t offset));
 
1202
# endif
 
1203
_GL_CXXALIASWARN (pwrite);
 
1204
#elif defined GNULIB_POSIXCHECK
 
1205
# undef pwrite
 
1206
# if HAVE_RAW_DECL_PWRITE
 
1207
_GL_WARN_ON_USE (pwrite, "pwrite is unportable - "
 
1208
                 "use gnulib module pwrite for portability");
 
1209
# endif
 
1210
#endif
 
1211
 
 
1212
 
 
1213
#if @GNULIB_READ@
 
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>.  */
 
1217
# if @REPLACE_READ@
 
1218
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
1219
#   undef read
 
1220
#   define read rpl_read
 
1221
#  endif
 
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));
 
1225
# else
 
1226
/* Need to cast, because on mingw, the third parameter is
 
1227
                                                          unsigned int count
 
1228
   and the return type is 'int'.  */
 
1229
_GL_CXXALIAS_SYS_CAST (read, ssize_t, (int fd, void *buf, size_t count));
 
1230
# endif
 
1231
_GL_CXXALIASWARN (read);
641
1232
#endif
642
1233
 
643
1234
 
644
1235
#if @GNULIB_READLINK@
645
 
# if @REPLACE_READLINK@
646
 
#  define readlink rpl_readlink
647
 
# endif
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
 
1244
#  endif
 
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));
 
1250
# else
 
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)));
 
1255
#  endif
 
1256
_GL_CXXALIAS_SYS (readlink, ssize_t,
 
1257
                  (const char *file, char *buf, size_t bufsize));
655
1258
# endif
 
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"), \
661
 
     readlink (f, b, s))
 
1262
# if HAVE_RAW_DECL_READLINK
 
1263
_GL_WARN_ON_USE (readlink, "readlink is unportable - "
 
1264
                 "use gnulib module readlink for portability");
 
1265
# endif
662
1266
#endif
663
1267
 
664
1268
 
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)));
668
1274
# endif
 
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");
 
1283
# endif
675
1284
#endif
676
1285
 
677
1286
 
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
 
1292
#  endif
 
1293
_GL_FUNCDECL_RPL (rmdir, int, (char const *name) _GL_ARG_NONNULL ((1)));
 
1294
_GL_CXXALIAS_RPL (rmdir, int, (char const *name));
 
1295
# else
 
1296
_GL_CXXALIAS_SYS (rmdir, int, (char const *name));
683
1297
# endif
 
1298
_GL_CXXALIASWARN (rmdir);
684
1299
#elif defined GNULIB_POSIXCHECK
685
1300
# undef rmdir
686
 
# define rmdir(n) \
687
 
    (GL_LINK_WARNING ("rmdir is unportable - " \
688
 
                      "use gnulib module rmdir for portability"), \
689
 
     rmdir (n))
 
1301
# if HAVE_RAW_DECL_RMDIR
 
1302
_GL_WARN_ON_USE (rmdir, "rmdir is unportable - "
 
1303
                 "use gnulib module rmdir for portability");
 
1304
# endif
 
1305
#endif
 
1306
 
 
1307
 
 
1308
#if @GNULIB_SETHOSTNAME@
 
1309
/* Set the host name of the machine.
 
1310
   The host name may or may not be fully qualified.
 
1311
 
 
1312
   Put LEN bytes of NAME into the host name.
 
1313
   Return 0 if successful, otherwise, set errno and return -1.
 
1314
 
 
1315
   Platforms with no ability to set the hostname return -1 and set
 
1316
   errno = ENOSYS.  */
 
1317
# if !@HAVE_SETHOSTNAME@ || !@HAVE_DECL_SETHOSTNAME@
 
1318
_GL_FUNCDECL_SYS (sethostname, int, (const char *name, size_t len)
 
1319
                                    _GL_ARG_NONNULL ((1)));
 
1320
# endif
 
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
 
1327
# undef sethostname
 
1328
# if HAVE_RAW_DECL_SETHOSTNAME
 
1329
_GL_WARN_ON_USE (sethostname, "sethostname is unportable - "
 
1330
                 "use gnulib module sethostname for portability");
 
1331
# endif
690
1332
#endif
691
1333
 
692
1334
 
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>.  */
698
 
# if !@HAVE_SLEEP@
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)
 
1342
#   undef sleep
 
1343
#   define sleep rpl_sleep
 
1344
#  endif
 
1345
_GL_FUNCDECL_RPL (sleep, unsigned int, (unsigned int n));
 
1346
_GL_CXXALIAS_RPL (sleep, unsigned int, (unsigned int n));
 
1347
# else
 
1348
#  if !@HAVE_SLEEP@
 
1349
_GL_FUNCDECL_SYS (sleep, unsigned int, (unsigned int n));
 
1350
#  endif
 
1351
_GL_CXXALIAS_SYS (sleep, unsigned int, (unsigned int n));
700
1352
# endif
 
1353
_GL_CXXALIASWARN (sleep);
701
1354
#elif defined GNULIB_POSIXCHECK
702
1355
# undef sleep
703
 
# define sleep(n) \
704
 
    (GL_LINK_WARNING ("sleep is unportable - " \
705
 
                      "use gnulib module sleep for portability"), \
706
 
     sleep (n))
 
1356
# if HAVE_RAW_DECL_SLEEP
 
1357
_GL_WARN_ON_USE (sleep, "sleep is unportable - "
 
1358
                 "use gnulib module sleep for portability");
 
1359
# endif
707
1360
#endif
708
1361
 
709
1362
 
710
1363
#if @GNULIB_SYMLINK@
711
1364
# if @REPLACE_SYMLINK@
712
 
#  undef symlink
713
 
#  define symlink rpl_symlink
714
 
# endif
715
 
# if !@HAVE_SYMLINK@ || @REPLACE_SYMLINK@
716
 
int symlink (char const *contents, char const *file);
717
 
# endif
 
1365
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
1366
#   undef symlink
 
1367
#   define symlink rpl_symlink
 
1368
#  endif
 
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));
 
1372
# else
 
1373
#  if !@HAVE_SYMLINK@
 
1374
_GL_FUNCDECL_SYS (symlink, int, (char const *contents, char const *file)
 
1375
                                _GL_ARG_NONNULL ((1, 2)));
 
1376
#  endif
 
1377
_GL_CXXALIAS_SYS (symlink, int, (char const *contents, char const *file));
 
1378
# endif
 
1379
_GL_CXXALIASWARN (symlink);
718
1380
#elif defined GNULIB_POSIXCHECK
719
1381
# undef symlink
720
 
# define symlink(c,n)                        \
721
 
    (GL_LINK_WARNING ("symlink is not portable - " \
722
 
                      "use gnulib module symlink for portability"), \
723
 
     symlink (c, n))
 
1382
# if HAVE_RAW_DECL_SYMLINK
 
1383
_GL_WARN_ON_USE (symlink, "symlink is not portable - "
 
1384
                 "use gnulib module symlink for portability");
 
1385
# endif
724
1386
#endif
725
1387
 
726
1388
 
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)));
730
1394
# endif
 
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"), \
736
 
     symlinkat (c, d, n))
 
1400
# if HAVE_RAW_DECL_SYMLINKAT
 
1401
_GL_WARN_ON_USE (symlinkat, "symlinkat is not portable - "
 
1402
                 "use gnulib module symlinkat for portability");
 
1403
# endif
 
1404
#endif
 
1405
 
 
1406
 
 
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)
 
1412
#   undef ttyname_r
 
1413
#   define ttyname_r rpl_ttyname_r
 
1414
#  endif
 
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));
 
1419
# else
 
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)));
 
1423
#  endif
 
1424
_GL_CXXALIAS_SYS (ttyname_r, int,
 
1425
                  (int fd, char *buf, size_t buflen));
 
1426
# endif
 
1427
_GL_CXXALIASWARN (ttyname_r);
 
1428
#elif defined GNULIB_POSIXCHECK
 
1429
# undef ttyname_r
 
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");
 
1433
# endif
737
1434
#endif
738
1435
 
739
1436
 
740
1437
#if @GNULIB_UNLINK@
741
1438
# if @REPLACE_UNLINK@
742
 
#  undef unlink
743
 
#  define unlink rpl_unlink
744
 
extern int unlink (char const *file);
 
1439
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
1440
#   undef unlink
 
1441
#   define unlink rpl_unlink
 
1442
#  endif
 
1443
_GL_FUNCDECL_RPL (unlink, int, (char const *file) _GL_ARG_NONNULL ((1)));
 
1444
_GL_CXXALIAS_RPL (unlink, int, (char const *file));
 
1445
# else
 
1446
_GL_CXXALIAS_SYS (unlink, int, (char const *file));
745
1447
# endif
 
1448
_GL_CXXALIASWARN (unlink);
746
1449
#elif defined GNULIB_POSIXCHECK
747
1450
# undef unlink
748
 
# define unlink(n)                         \
749
 
    (GL_LINK_WARNING ("unlink is not portable - " \
750
 
                      "use gnulib module unlink for portability"), \
751
 
     unlink (n))
 
1451
# if HAVE_RAW_DECL_UNLINK
 
1452
_GL_WARN_ON_USE (unlink, "unlink is not portable - "
 
1453
                 "use gnulib module unlink for portability");
 
1454
# endif
752
1455
#endif
753
1456
 
754
1457
 
755
1458
#if @GNULIB_UNLINKAT@
756
1459
# if @REPLACE_UNLINKAT@
757
 
#  undef unlinkat
758
 
#  define unlinkat rpl_unlinkat
759
 
# endif
760
 
# if !@HAVE_UNLINKAT@ || @REPLACE_UNLINKAT@
761
 
extern int unlinkat (int fd, char const *file, int flag);
762
 
# endif
 
1460
#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 
1461
#   undef unlinkat
 
1462
#   define unlinkat rpl_unlinkat
 
1463
#  endif
 
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));
 
1467
# else
 
1468
#  if !@HAVE_UNLINKAT@
 
1469
_GL_FUNCDECL_SYS (unlinkat, int, (int fd, char const *file, int flag)
 
1470
                                 _GL_ARG_NONNULL ((2)));
 
1471
#  endif
 
1472
_GL_CXXALIAS_SYS (unlinkat, int, (int fd, char const *file, int flag));
 
1473
# endif
 
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"), \
768
 
     unlinkat (d, n, f))
769
 
#endif
770
 
 
771
 
 
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");
 
1480
# endif
 
1481
#endif
 
1482
 
 
1483
 
 
1484
#if @GNULIB_USLEEP@
 
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)
 
1491
#   undef usleep
 
1492
#   define usleep rpl_usleep
 
1493
#  endif
 
1494
_GL_FUNCDECL_RPL (usleep, int, (useconds_t n));
 
1495
_GL_CXXALIAS_RPL (usleep, int, (useconds_t n));
 
1496
# else
 
1497
#  if !@HAVE_USLEEP@
 
1498
_GL_FUNCDECL_SYS (usleep, int, (useconds_t n));
 
1499
#  endif
 
1500
_GL_CXXALIAS_SYS (usleep, int, (useconds_t n));
 
1501
# endif
 
1502
_GL_CXXALIASWARN (usleep);
 
1503
#elif defined GNULIB_POSIXCHECK
 
1504
# undef usleep
 
1505
# if HAVE_RAW_DECL_USLEEP
 
1506
_GL_WARN_ON_USE (usleep, "usleep is unportable - "
 
1507
                 "use gnulib module usleep for portability");
 
1508
# endif
 
1509
#endif
 
1510
 
 
1511
 
 
1512
#if @GNULIB_WRITE@
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>.  */
776
 
# undef write
777
 
# define write rpl_write
778
 
extern ssize_t write (int fd, const void *buf, size_t count);
779
 
#endif
780
 
 
781
 
 
782
 
#ifdef __cplusplus
783
 
}
784
 
#endif
785
 
 
786
 
 
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)
 
1518
#   undef write
 
1519
#   define write rpl_write
 
1520
#  endif
 
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));
 
1524
# else
 
1525
/* Need to cast, because on mingw, the third parameter is
 
1526
                                                             unsigned int count
 
1527
   and the return type is 'int'.  */
 
1528
_GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const void *buf, size_t count));
 
1529
# endif
 
1530
_GL_CXXALIASWARN (write);
 
1531
#endif
 
1532
 
 
1533
 
 
1534
#endif /* _@GUARD_PREFIX@_UNISTD_H */
 
1535
#endif /* _@GUARD_PREFIX@_UNISTD_H */