1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* Substitute for and wrapper around <unistd.h>.
3 Copyright (C) 2003-2019 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <https://www.gnu.org/licenses/>. */
21 #pragma GCC system_header
25 #ifdef _GL_INCLUDING_UNISTD_H
26 /* Special invocation convention:
27 - On Mac OS X 10.3.9 we have a sequence of nested includes
28 <unistd.h> -> <signal.h> -> <pthread.h> -> <unistd.h>
29 In this situation, the functions are not yet declared, therefore we cannot
30 provide the C++ aliases. */
32 #include_next <unistd.h>
35 /* Normal invocation convention. */
37 /* The include_next requires a split double-inclusion guard. */
39 # define _GL_INCLUDING_UNISTD_H
40 # include_next <unistd.h>
41 # undef _GL_INCLUDING_UNISTD_H
44 /* Get all possible declarations of gethostname(). */
46 && !defined _GL_INCLUDING_WINSOCK2_H
47 # define _GL_INCLUDING_WINSOCK2_H
48 # include <winsock2.h>
49 # undef _GL_INCLUDING_WINSOCK2_H
52 #if !defined _GL_UNISTD_H && !defined _GL_INCLUDING_WINSOCK2_H
55 /* NetBSD 5.0 mis-defines NULL. Also get size_t. */
58 /* mingw doesn't define the SEEK_* or *_FILENO macros in <unistd.h>. */
59 /* MSVC declares 'unlink' in <stdio.h>, not in <unistd.h>. We must include
60 it before we #define unlink rpl_unlink. */
61 /* Cygwin 1.7.1 declares symlinkat in <stdio.h>, not in <unistd.h>. */
62 /* But avoid namespace pollution on glibc systems. */
63 #if (!(defined SEEK_CUR && defined SEEK_END && defined SEEK_SET) \
64 || ((0 || defined GNULIB_POSIXCHECK) \
65 && (defined _WIN32 && ! defined __CYGWIN__)) \
66 || ((0 || defined GNULIB_POSIXCHECK) \
67 && defined __CYGWIN__)) \
68 && ! defined __GLIBC__
72 /* Cygwin 1.7.1 declares unlinkat in <fcntl.h>, not in <unistd.h>. */
73 /* But avoid namespace pollution on glibc systems. */
74 #if (0 || defined GNULIB_POSIXCHECK) && defined __CYGWIN__ \
75 && ! defined __GLIBC__
79 /* mingw fails to declare _exit in <unistd.h>. */
80 /* mingw, MSVC, BeOS, Haiku declare environ in <stdlib.h>, not in
82 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>. */
83 /* OSF Tru64 Unix cannot see gnulib rpl_strtod when system <stdlib.h> is
85 /* But avoid namespace pollution on glibc systems. */
86 #if !defined __GLIBC__ && !defined __osf__
87 # define __need_system_stdlib_h
89 # undef __need_system_stdlib_h
92 /* Native Windows platforms declare chdir, getcwd, rmdir in
93 <io.h> and/or <direct.h>, not in <unistd.h>.
94 They also declare access(), chmod(), close(), dup(), dup2(), isatty(),
95 lseek(), read(), unlink(), write() in <io.h>. */
97 || defined GNULIB_POSIXCHECK) \
98 && (defined _WIN32 && ! defined __CYGWIN__))
99 # include <io.h> /* mingw32, mingw64 */
100 # include <direct.h> /* mingw64, MSVC 9 */
101 #elif (1 || 0 || 1 || 0 \
102 || 1 || 0 || 0 || 0 \
103 || defined GNULIB_POSIXCHECK) \
104 && (defined _WIN32 && ! defined __CYGWIN__)
108 /* AIX and OSF/1 5.1 declare getdomainname in <netdb.h>, not in <unistd.h>.
109 NonStop Kernel declares gethostname in <netdb.h>, not in <unistd.h>. */
110 /* But avoid namespace pollution on glibc systems. */
111 #if ((0 && (defined _AIX || defined __osf__)) \
112 || (0 && defined __TANDEM)) \
113 && !defined __GLIBC__
117 /* MSVC defines off_t in <sys/types.h>.
118 May also define off_t to a 64-bit type on native Windows. */
121 # include <sys/types.h>
126 || 0 || 0 || defined GNULIB_POSIXCHECK)
128 # include <sys/types.h>
131 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
132 /* C++ compatible function declaration macros.
133 Copyright (C) 2010-2019 Free Software Foundation, Inc.
135 This program is free software: you can redistribute it and/or modify it
136 under the terms of the GNU General Public License as published
137 by the Free Software Foundation; either version 3 of the License, or
138 (at your option) any later version.
140 This program is distributed in the hope that it will be useful,
141 but WITHOUT ANY WARRANTY; without even the implied warranty of
142 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
143 General Public License for more details.
145 You should have received a copy of the GNU General Public License
146 along with this program. If not, see <https://www.gnu.org/licenses/>. */
148 #ifndef _GL_CXXDEFS_H
149 #define _GL_CXXDEFS_H
151 /* Begin/end the GNULIB_NAMESPACE namespace. */
152 #if defined __cplusplus && defined GNULIB_NAMESPACE
153 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
154 # define _GL_END_NAMESPACE }
156 # define _GL_BEGIN_NAMESPACE
157 # define _GL_END_NAMESPACE
160 /* The three most frequent use cases of these macros are:
162 * For providing a substitute for a function that is missing on some
163 platforms, but is declared and works fine on the platforms on which
168 _GL_FUNCDECL_SYS (foo, ...);
170 _GL_CXXALIAS_SYS (foo, ...);
171 _GL_CXXALIASWARN (foo);
172 #elif defined GNULIB_POSIXCHECK
176 * For providing a replacement for a function that exists on all platforms,
177 but is broken/insufficient and needs to be replaced on some platforms:
181 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
185 _GL_FUNCDECL_RPL (foo, ...);
186 _GL_CXXALIAS_RPL (foo, ...);
188 _GL_CXXALIAS_SYS (foo, ...);
190 _GL_CXXALIASWARN (foo);
191 #elif defined GNULIB_POSIXCHECK
195 * For providing a replacement for a function that exists on some platforms
196 but is broken/insufficient and needs to be replaced on some of them and
197 is additionally either missing or undeclared on some other platforms:
201 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
205 _GL_FUNCDECL_RPL (foo, ...);
206 _GL_CXXALIAS_RPL (foo, ...);
208 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
209 _GL_FUNCDECL_SYS (foo, ...);
211 _GL_CXXALIAS_SYS (foo, ...);
213 _GL_CXXALIASWARN (foo);
214 #elif defined GNULIB_POSIXCHECK
219 /* _GL_EXTERN_C declaration;
220 performs the declaration with C linkage. */
221 #if defined __cplusplus
222 # define _GL_EXTERN_C extern "C"
224 # define _GL_EXTERN_C extern
227 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
228 declares a replacement function, named rpl_func, with the given prototype,
229 consisting of return type, parameters, and attributes.
231 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
232 _GL_ARG_NONNULL ((1)));
234 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
235 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
236 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
237 _GL_EXTERN_C rettype rpl_func parameters_and_attributes
239 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
240 declares the system function, named func, with the given prototype,
241 consisting of return type, parameters, and attributes.
243 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
244 _GL_ARG_NONNULL ((1)));
246 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
247 _GL_EXTERN_C rettype func parameters_and_attributes
249 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
250 declares a C++ alias called GNULIB_NAMESPACE::func
251 that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
253 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
255 Wrapping rpl_func in an object with an inline conversion operator
256 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
257 actually used in the program. */
258 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
259 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
260 #if defined __cplusplus && defined GNULIB_NAMESPACE
261 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
262 namespace GNULIB_NAMESPACE \
264 static const struct _gl_ ## func ## _wrapper \
266 typedef rettype (*type) parameters; \
268 inline operator type () const \
274 _GL_EXTERN_C int _gl_cxxalias_dummy
276 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
277 _GL_EXTERN_C int _gl_cxxalias_dummy
280 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
281 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
282 except that the C function rpl_func may have a slightly different
283 declaration. A cast is used to silence the "invalid conversion" error
284 that would otherwise occur. */
285 #if defined __cplusplus && defined GNULIB_NAMESPACE
286 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
287 namespace GNULIB_NAMESPACE \
289 static const struct _gl_ ## func ## _wrapper \
291 typedef rettype (*type) parameters; \
293 inline operator type () const \
295 return reinterpret_cast<type>(::rpl_func); \
299 _GL_EXTERN_C int _gl_cxxalias_dummy
301 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
302 _GL_EXTERN_C int _gl_cxxalias_dummy
305 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
306 declares a C++ alias called GNULIB_NAMESPACE::func
307 that redirects to the system provided function func, if GNULIB_NAMESPACE
310 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
312 Wrapping func in an object with an inline conversion operator
313 avoids a reference to func unless GNULIB_NAMESPACE::func is
314 actually used in the program. */
315 #if defined __cplusplus && defined GNULIB_NAMESPACE
316 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
317 namespace GNULIB_NAMESPACE \
319 static const struct _gl_ ## func ## _wrapper \
321 typedef rettype (*type) parameters; \
323 inline operator type () const \
329 _GL_EXTERN_C int _gl_cxxalias_dummy
331 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
332 _GL_EXTERN_C int _gl_cxxalias_dummy
335 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
336 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
337 except that the C function func may have a slightly different declaration.
338 A cast is used to silence the "invalid conversion" error that would
340 #if defined __cplusplus && defined GNULIB_NAMESPACE
341 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
342 namespace GNULIB_NAMESPACE \
344 static const struct _gl_ ## func ## _wrapper \
346 typedef rettype (*type) parameters; \
348 inline operator type () const \
350 return reinterpret_cast<type>(::func); \
354 _GL_EXTERN_C int _gl_cxxalias_dummy
356 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
357 _GL_EXTERN_C int _gl_cxxalias_dummy
360 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
361 is like _GL_CXXALIAS_SYS (func, rettype, parameters);
362 except that the C function is picked among a set of overloaded functions,
363 namely the one with rettype2 and parameters2. Two consecutive casts
364 are used to silence the "cannot find a match" and "invalid conversion"
365 errors that would otherwise occur. */
366 #if defined __cplusplus && defined GNULIB_NAMESPACE
367 /* The outer cast must be a reinterpret_cast.
368 The inner cast: When the function is defined as a set of overloaded
369 functions, it works as a static_cast<>, choosing the designated variant.
370 When the function is defined as a single variant, it works as a
371 reinterpret_cast<>. The parenthesized cast syntax works both ways. */
372 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
373 namespace GNULIB_NAMESPACE \
375 static const struct _gl_ ## func ## _wrapper \
377 typedef rettype (*type) parameters; \
379 inline operator type () const \
381 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
385 _GL_EXTERN_C int _gl_cxxalias_dummy
387 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
388 _GL_EXTERN_C int _gl_cxxalias_dummy
391 /* _GL_CXXALIASWARN (func);
392 causes a warning to be emitted when ::func is used but not when
393 GNULIB_NAMESPACE::func is used. func must be defined without overloaded
395 #if defined __cplusplus && defined GNULIB_NAMESPACE
396 # define _GL_CXXALIASWARN(func) \
397 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
398 # define _GL_CXXALIASWARN_1(func,namespace) \
399 _GL_CXXALIASWARN_2 (func, namespace)
400 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
401 we enable the warning only when not optimizing. */
403 # define _GL_CXXALIASWARN_2(func,namespace) \
404 _GL_WARN_ON_USE (func, \
405 "The symbol ::" #func " refers to the system function. " \
406 "Use " #namespace "::" #func " instead.")
407 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
408 # define _GL_CXXALIASWARN_2(func,namespace) \
409 extern __typeof__ (func) func
411 # define _GL_CXXALIASWARN_2(func,namespace) \
412 _GL_EXTERN_C int _gl_cxxalias_dummy
415 # define _GL_CXXALIASWARN(func) \
416 _GL_EXTERN_C int _gl_cxxalias_dummy
419 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
420 causes a warning to be emitted when the given overloaded variant of ::func
421 is used but not when GNULIB_NAMESPACE::func is used. */
422 #if defined __cplusplus && defined GNULIB_NAMESPACE
423 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
424 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
426 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
427 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
428 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
429 we enable the warning only when not optimizing. */
431 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
432 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
433 "The symbol ::" #func " refers to the system function. " \
434 "Use " #namespace "::" #func " instead.")
435 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
436 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
437 extern __typeof__ (func) func
439 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
440 _GL_EXTERN_C int _gl_cxxalias_dummy
443 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
444 _GL_EXTERN_C int _gl_cxxalias_dummy
447 #endif /* _GL_CXXDEFS_H */
449 /* The definition of _GL_ARG_NONNULL is copied here. */
450 /* A C macro for declaring that specific arguments must not be NULL.
451 Copyright (C) 2009-2019 Free Software Foundation, Inc.
453 This program is free software: you can redistribute it and/or modify it
454 under the terms of the GNU General Public License as published
455 by the Free Software Foundation; either version 3 of the License, or
456 (at your option) any later version.
458 This program is distributed in the hope that it will be useful,
459 but WITHOUT ANY WARRANTY; without even the implied warranty of
460 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
461 General Public License for more details.
463 You should have received a copy of the GNU General Public License
464 along with this program. If not, see <https://www.gnu.org/licenses/>. */
466 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
467 that the values passed as arguments n, ..., m must be non-NULL pointers.
468 n = 1 stands for the first argument, n = 2 for the second argument etc. */
469 #ifndef _GL_ARG_NONNULL
470 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
471 # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
473 # define _GL_ARG_NONNULL(params)
477 /* The definition of _GL_WARN_ON_USE is copied here. */
478 /* A C macro for emitting warnings if a function is used.
479 Copyright (C) 2010-2019 Free Software Foundation, Inc.
481 This program is free software: you can redistribute it and/or modify it
482 under the terms of the GNU General Public License as published
483 by the Free Software Foundation; either version 3 of the License, or
484 (at your option) any later version.
486 This program is distributed in the hope that it will be useful,
487 but WITHOUT ANY WARRANTY; without even the implied warranty of
488 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
489 General Public License for more details.
491 You should have received a copy of the GNU General Public License
492 along with this program. If not, see <https://www.gnu.org/licenses/>. */
494 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
495 for FUNCTION which will then trigger a compiler warning containing
496 the text of "literal string" anywhere that function is called, if
497 supported by the compiler. If the compiler does not support this
498 feature, the macro expands to an unused extern declaration.
500 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
501 attribute used in _GL_WARN_ON_USE. If the compiler does not support
502 this feature, it expands to empty.
504 These macros are useful for marking a function as a potential
505 portability trap, with the intent that "literal string" include
506 instructions on the replacement function that should be used
508 _GL_WARN_ON_USE is for functions with 'extern' linkage.
509 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
512 However, one of the reasons that a function is a portability trap is
513 if it has the wrong signature. Declaring FUNCTION with a different
514 signature in C is a compilation error, so this macro must use the
515 same type as any existing declaration so that programs that avoid
516 the problematic FUNCTION do not fail to compile merely because they
517 included a header that poisoned the function. But this implies that
518 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
519 have a declaration. Use of this macro implies that there must not
520 be any other macro hiding the declaration of FUNCTION; but
521 undefining FUNCTION first is part of the poisoning process anyway
522 (although for symbols that are provided only via a macro, the result
523 is a compilation error rather than a warning containing
524 "literal string"). Also note that in C++, it is only safe to use if
525 FUNCTION has no overloads.
527 For an example, it is possible to poison 'getline' by:
528 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
529 [getline]) in configure.ac, which potentially defines
530 HAVE_RAW_DECL_GETLINE
531 - adding this code to a header that wraps the system <stdio.h>:
533 #if HAVE_RAW_DECL_GETLINE
534 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
535 "not universally present; use the gnulib module getline");
538 It is not possible to directly poison global variables. But it is
539 possible to write a wrapper accessor function, and poison that
540 (less common usage, like &environ, will cause a compilation error
541 rather than issue the nice warning, but the end result of informing
542 the developer about their portability problem is still achieved):
543 #if HAVE_RAW_DECL_ENVIRON
545 rpl_environ (void) { return &environ; }
546 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
548 # define environ (*rpl_environ ())
550 or better (avoiding contradictory use of 'static' and 'extern'):
551 #if HAVE_RAW_DECL_ENVIRON
553 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
554 rpl_environ (void) { return &environ; }
556 # define environ (*rpl_environ ())
559 #ifndef _GL_WARN_ON_USE
561 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
562 /* A compiler attribute is available in gcc versions 4.3.0 and later. */
563 # define _GL_WARN_ON_USE(function, message) \
564 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
565 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
566 __attribute__ ((__warning__ (message)))
567 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
568 /* Verify the existence of the function. */
569 # define _GL_WARN_ON_USE(function, message) \
570 extern __typeof__ (function) function
571 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
572 # else /* Unsupported. */
573 # define _GL_WARN_ON_USE(function, message) \
574 _GL_WARN_EXTERN_C int _gl_warn_on_use
575 # define _GL_WARN_ON_USE_ATTRIBUTE(message)
579 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
580 is like _GL_WARN_ON_USE (function, "string"), except that the function is
581 declared with the given prototype, consisting of return type, parameters,
583 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
584 not work in this case. */
585 #ifndef _GL_WARN_ON_USE_CXX
586 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
587 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
588 extern rettype function parameters_and_attributes \
589 __attribute__ ((__warning__ (msg)))
590 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
591 /* Verify the existence of the function. */
592 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
593 extern rettype function parameters_and_attributes
594 # else /* Unsupported. */
595 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
596 _GL_WARN_EXTERN_C int _gl_warn_on_use
600 /* _GL_WARN_EXTERN_C declaration;
601 performs the declaration with C linkage. */
602 #ifndef _GL_WARN_EXTERN_C
603 # if defined __cplusplus
604 # define _GL_WARN_EXTERN_C extern "C"
606 # define _GL_WARN_EXTERN_C extern
611 /* Get getopt(), optarg, optind, opterr, optopt. */
612 #if 0 && !defined _GL_SYSTEM_GETOPT
613 # include <getopt-cdefs.h>
614 # include <getopt-pfx-core.h>
617 #ifndef _GL_INLINE_HEADER_BEGIN
618 #error "Please include config.h first."
620 _GL_INLINE_HEADER_BEGIN
621 #ifndef _GL_UNISTD_INLINE
622 # define _GL_UNISTD_INLINE _GL_INLINE
625 /* Hide some function declarations from <winsock2.h>. */
628 # if !defined _GL_SYS_SOCKET_H
629 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
631 # define socket socket_used_without_including_sys_socket_h
633 # define connect connect_used_without_including_sys_socket_h
635 # define accept accept_used_without_including_sys_socket_h
637 # define bind bind_used_without_including_sys_socket_h
639 # define getpeername getpeername_used_without_including_sys_socket_h
641 # define getsockname getsockname_used_without_including_sys_socket_h
643 # define getsockopt getsockopt_used_without_including_sys_socket_h
645 # define listen listen_used_without_including_sys_socket_h
647 # define recv recv_used_without_including_sys_socket_h
649 # define send send_used_without_including_sys_socket_h
651 # define recvfrom recvfrom_used_without_including_sys_socket_h
653 # define sendto sendto_used_without_including_sys_socket_h
655 # define setsockopt setsockopt_used_without_including_sys_socket_h
657 # define shutdown shutdown_used_without_including_sys_socket_h
659 _GL_WARN_ON_USE (socket
,
660 "socket() used without including <sys/socket.h>");
661 _GL_WARN_ON_USE (connect
,
662 "connect() used without including <sys/socket.h>");
663 _GL_WARN_ON_USE (accept
,
664 "accept() used without including <sys/socket.h>");
665 _GL_WARN_ON_USE (bind
,
666 "bind() used without including <sys/socket.h>");
667 _GL_WARN_ON_USE (getpeername
,
668 "getpeername() used without including <sys/socket.h>");
669 _GL_WARN_ON_USE (getsockname
,
670 "getsockname() used without including <sys/socket.h>");
671 _GL_WARN_ON_USE (getsockopt
,
672 "getsockopt() used without including <sys/socket.h>");
673 _GL_WARN_ON_USE (listen
,
674 "listen() used without including <sys/socket.h>");
675 _GL_WARN_ON_USE (recv
,
676 "recv() used without including <sys/socket.h>");
677 _GL_WARN_ON_USE (send
,
678 "send() used without including <sys/socket.h>");
679 _GL_WARN_ON_USE (recvfrom
,
680 "recvfrom() used without including <sys/socket.h>");
681 _GL_WARN_ON_USE (sendto
,
682 "sendto() used without including <sys/socket.h>");
683 _GL_WARN_ON_USE (setsockopt
,
684 "setsockopt() used without including <sys/socket.h>");
685 _GL_WARN_ON_USE (shutdown
,
686 "shutdown() used without including <sys/socket.h>");
689 # if !defined _GL_SYS_SELECT_H
690 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
692 # define select select_used_without_including_sys_select_h
694 _GL_WARN_ON_USE (select
,
695 "select() used without including <sys/select.h>");
701 /* OS/2 EMX lacks these macros. */
703 # define STDIN_FILENO 0
705 #ifndef STDOUT_FILENO
706 # define STDOUT_FILENO 1
708 #ifndef STDERR_FILENO
709 # define STDERR_FILENO 2
712 /* Ensure *_OK macros exist. */
721 /* Declare overridden functions. */
724 #if defined GNULIB_POSIXCHECK
725 /* The access() function is a security risk. */
726 _GL_WARN_ON_USE (access
, "the access function is a security risk - "
727 "use the gnulib module faccessat instead");
732 _GL_CXXALIAS_SYS (chdir
, int, (const char *file
) _GL_ARG_NONNULL ((1)));
733 _GL_CXXALIASWARN (chdir
);
734 #elif defined GNULIB_POSIXCHECK
736 # if HAVE_RAW_DECL_CHDIR
737 _GL_WARN_ON_USE (chown
, "chdir is not always in <unistd.h> - "
738 "use gnulib module chdir for portability");
744 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
745 to GID (if GID is not -1). Follow symbolic links.
746 Return 0 if successful, otherwise -1 and errno set.
747 See the POSIX:2008 specification
748 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html. */
750 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
752 # define chown rpl_chown
754 _GL_FUNCDECL_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
755 _GL_ARG_NONNULL ((1)));
756 _GL_CXXALIAS_RPL (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
759 _GL_FUNCDECL_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
)
760 _GL_ARG_NONNULL ((1)));
762 _GL_CXXALIAS_SYS (chown
, int, (const char *file
, uid_t uid
, gid_t gid
));
764 _GL_CXXALIASWARN (chown
);
765 #elif defined GNULIB_POSIXCHECK
767 # if HAVE_RAW_DECL_CHOWN
768 _GL_WARN_ON_USE (chown
, "chown fails to follow symlinks on some systems and "
769 "doesn't treat a uid or gid of -1 on some systems - "
770 "use gnulib module chown for portability");
777 /* Automatically included by modules that need a replacement for close. */
778 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
780 # define close rpl_close
782 _GL_FUNCDECL_RPL (close
, int, (int fd
));
783 _GL_CXXALIAS_RPL (close
, int, (int fd
));
785 _GL_CXXALIAS_SYS (close
, int, (int fd
));
787 _GL_CXXALIASWARN (close
);
790 # define close close_used_without_requesting_gnulib_module_close
791 #elif defined GNULIB_POSIXCHECK
793 /* Assume close is always declared. */
794 _GL_WARN_ON_USE (close
, "close does not portably work on sockets - "
795 "use gnulib module close for portability");
801 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
804 _GL_FUNCDECL_RPL (dup
, int, (int oldfd
));
805 _GL_CXXALIAS_RPL (dup
, int, (int oldfd
));
807 _GL_CXXALIAS_SYS (dup
, int, (int oldfd
));
809 _GL_CXXALIASWARN (dup
);
810 #elif defined GNULIB_POSIXCHECK
812 # if HAVE_RAW_DECL_DUP
813 _GL_WARN_ON_USE (dup
, "dup is unportable - "
814 "use gnulib module dup for portability");
820 /* Copy the file descriptor OLDFD into file descriptor NEWFD. Do nothing if
821 NEWFD = OLDFD, otherwise close NEWFD first if it is open.
822 Return newfd if successful, otherwise -1 and errno set.
823 See the POSIX:2008 specification
824 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>. */
826 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
827 # define dup2 rpl_dup2
829 _GL_FUNCDECL_RPL (dup2
, int, (int oldfd
, int newfd
));
830 _GL_CXXALIAS_RPL (dup2
, int, (int oldfd
, int newfd
));
833 _GL_FUNCDECL_SYS (dup2
, int, (int oldfd
, int newfd
));
835 _GL_CXXALIAS_SYS (dup2
, int, (int oldfd
, int newfd
));
837 _GL_CXXALIASWARN (dup2
);
838 #elif defined GNULIB_POSIXCHECK
840 # if HAVE_RAW_DECL_DUP2
841 _GL_WARN_ON_USE (dup2
, "dup2 is unportable - "
842 "use gnulib module dup2 for portability");
848 /* Copy the file descriptor OLDFD into file descriptor NEWFD, with the
850 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
851 and O_TEXT, O_BINARY (defined in "binary-io.h").
852 Close NEWFD first if it is open.
853 Return newfd if successful, otherwise -1 and errno set.
854 See the Linux man page at
855 <https://www.kernel.org/doc/man-pages/online/pages/man2/dup3.2.html>. */
857 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
858 # define dup3 rpl_dup3
860 _GL_FUNCDECL_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
861 _GL_CXXALIAS_RPL (dup3
, int, (int oldfd
, int newfd
, int flags
));
863 _GL_FUNCDECL_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
864 _GL_CXXALIAS_SYS (dup3
, int, (int oldfd
, int newfd
, int flags
));
866 _GL_CXXALIASWARN (dup3
);
867 #elif defined GNULIB_POSIXCHECK
869 # if HAVE_RAW_DECL_DUP3
870 _GL_WARN_ON_USE (dup3
, "dup3 is unportable - "
871 "use gnulib module dup3 for portability");
877 # if defined __CYGWIN__ && !defined __i386__
878 /* The 'environ' variable is defined in a DLL. Therefore its declaration needs
879 the '__declspec(dllimport)' attribute, but the system's <unistd.h> lacks it.
880 This leads to a link error on 64-bit Cygwin when the option
881 -Wl,--disable-auto-import is in use. */
882 _GL_EXTERN_C
__declspec(dllimport
) char **environ
;
885 /* Set of environment variables and values. An array of strings of the form
886 "VARIABLE=VALUE", terminated with a NULL. */
887 # if defined __APPLE__ && defined __MACH__
888 # include <TargetConditionals.h>
889 # if !TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
890 # define _GL_USE_CRT_EXTERNS
893 # ifdef _GL_USE_CRT_EXTERNS
894 # include <crt_externs.h>
895 # define environ (*_NSGetEnviron ())
900 extern char **environ
;
906 #elif defined GNULIB_POSIXCHECK
907 # if HAVE_RAW_DECL_ENVIRON
908 _GL_UNISTD_INLINE
char ***
909 _GL_WARN_ON_USE_ATTRIBUTE ("environ is unportable - "
910 "use gnulib module environ for portability")
916 # define environ (*rpl_environ ())
922 /* Like access(), except that it uses the effective user id and group id of
923 the current process. */
925 _GL_FUNCDECL_SYS (euidaccess
, int, (const char *filename
, int mode
)
926 _GL_ARG_NONNULL ((1)));
928 _GL_CXXALIAS_SYS (euidaccess
, int, (const char *filename
, int mode
));
929 _GL_CXXALIASWARN (euidaccess
);
930 # if defined GNULIB_POSIXCHECK
931 /* Like access(), this function is a security risk. */
932 _GL_WARN_ON_USE (euidaccess
, "the euidaccess function is a security risk - "
933 "use the gnulib module faccessat instead");
935 #elif defined GNULIB_POSIXCHECK
937 # if HAVE_RAW_DECL_EUIDACCESS
938 _GL_WARN_ON_USE (euidaccess
, "euidaccess is unportable - "
939 "use gnulib module euidaccess for portability");
946 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
948 # define faccessat rpl_faccessat
950 _GL_FUNCDECL_RPL (faccessat
, int,
951 (int fd
, char const *name
, int mode
, int flag
)
952 _GL_ARG_NONNULL ((2)));
953 _GL_CXXALIAS_RPL (faccessat
, int,
954 (int fd
, char const *name
, int mode
, int flag
));
957 _GL_FUNCDECL_SYS (faccessat
, int,
958 (int fd
, char const *file
, int mode
, int flag
)
959 _GL_ARG_NONNULL ((2)));
961 _GL_CXXALIAS_SYS (faccessat
, int,
962 (int fd
, char const *file
, int mode
, int flag
));
964 _GL_CXXALIASWARN (faccessat
);
965 #elif defined GNULIB_POSIXCHECK
967 # if HAVE_RAW_DECL_FACCESSAT
968 _GL_WARN_ON_USE (faccessat
, "faccessat is not portable - "
969 "use gnulib module faccessat for portability");
975 /* Change the process' current working directory to the directory on which
976 the given file descriptor is open.
977 Return 0 if successful, otherwise -1 and errno set.
978 See the POSIX:2008 specification
979 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html>. */
981 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
983 /* Gnulib internal hooks needed to maintain the fchdir metadata. */
984 _GL_EXTERN_C
int _gl_register_fd (int fd
, const char *filename
)
985 _GL_ARG_NONNULL ((2));
986 _GL_EXTERN_C
void _gl_unregister_fd (int fd
);
987 _GL_EXTERN_C
int _gl_register_dup (int oldfd
, int newfd
);
988 _GL_EXTERN_C
const char *_gl_directory_name (int fd
);
992 _GL_FUNCDECL_SYS (fchdir
, int, (int /*fd*/));
995 _GL_CXXALIAS_SYS (fchdir
, int, (int /*fd*/));
996 _GL_CXXALIASWARN (fchdir
);
997 #elif defined GNULIB_POSIXCHECK
999 # if HAVE_RAW_DECL_FCHDIR
1000 _GL_WARN_ON_USE (fchdir
, "fchdir is unportable - "
1001 "use gnulib module fchdir for portability");
1008 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1010 # define fchownat rpl_fchownat
1012 _GL_FUNCDECL_RPL (fchownat
, int, (int fd
, char const *file
,
1013 uid_t owner
, gid_t group
, int flag
)
1014 _GL_ARG_NONNULL ((2)));
1015 _GL_CXXALIAS_RPL (fchownat
, int, (int fd
, char const *file
,
1016 uid_t owner
, gid_t group
, int flag
));
1019 _GL_FUNCDECL_SYS (fchownat
, int, (int fd
, char const *file
,
1020 uid_t owner
, gid_t group
, int flag
)
1021 _GL_ARG_NONNULL ((2)));
1023 _GL_CXXALIAS_SYS (fchownat
, int, (int fd
, char const *file
,
1024 uid_t owner
, gid_t group
, int flag
));
1026 _GL_CXXALIASWARN (fchownat
);
1027 #elif defined GNULIB_POSIXCHECK
1029 # if HAVE_RAW_DECL_FCHOWNAT
1030 _GL_WARN_ON_USE (fchownat
, "fchownat is not portable - "
1031 "use gnulib module openat for portability");
1037 /* Synchronize changes to a file.
1038 Return 0 if successful, otherwise -1 and errno set.
1039 See POSIX:2008 specification
1040 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html>. */
1042 _GL_FUNCDECL_SYS (fdatasync
, int, (int fd
));
1044 _GL_CXXALIAS_SYS (fdatasync
, int, (int fd
));
1045 _GL_CXXALIASWARN (fdatasync
);
1046 #elif defined GNULIB_POSIXCHECK
1048 # if HAVE_RAW_DECL_FDATASYNC
1049 _GL_WARN_ON_USE (fdatasync
, "fdatasync is unportable - "
1050 "use gnulib module fdatasync for portability");
1056 /* Synchronize changes, including metadata, to a file.
1057 Return 0 if successful, otherwise -1 and errno set.
1058 See POSIX:2008 specification
1059 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html>. */
1061 _GL_FUNCDECL_SYS (fsync
, int, (int fd
));
1063 _GL_CXXALIAS_SYS (fsync
, int, (int fd
));
1064 _GL_CXXALIASWARN (fsync
);
1065 #elif defined GNULIB_POSIXCHECK
1067 # if HAVE_RAW_DECL_FSYNC
1068 _GL_WARN_ON_USE (fsync
, "fsync is unportable - "
1069 "use gnulib module fsync for portability");
1075 /* Change the size of the file to which FD is opened to become equal to LENGTH.
1076 Return 0 if successful, otherwise -1 and errno set.
1077 See the POSIX:2008 specification
1078 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html>. */
1080 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1082 # define ftruncate rpl_ftruncate
1084 _GL_FUNCDECL_RPL (ftruncate
, int, (int fd
, off_t length
));
1085 _GL_CXXALIAS_RPL (ftruncate
, int, (int fd
, off_t length
));
1088 _GL_FUNCDECL_SYS (ftruncate
, int, (int fd
, off_t length
));
1090 _GL_CXXALIAS_SYS (ftruncate
, int, (int fd
, off_t length
));
1092 _GL_CXXALIASWARN (ftruncate
);
1093 #elif defined GNULIB_POSIXCHECK
1095 # if HAVE_RAW_DECL_FTRUNCATE
1096 _GL_WARN_ON_USE (ftruncate
, "ftruncate is unportable - "
1097 "use gnulib module ftruncate for portability");
1103 /* Get the name of the current working directory, and put it in SIZE bytes
1105 Return BUF if successful, or NULL if the directory couldn't be determined
1106 or SIZE was too small.
1107 See the POSIX:2008 specification
1108 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html>.
1109 Additionally, the gnulib module 'getcwd' guarantees the following GNU
1110 extension: If BUF is NULL, an array is allocated with 'malloc'; the array
1111 is SIZE bytes long, unless SIZE == 0, in which case it is as big as
1114 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1115 # define getcwd rpl_getcwd
1117 _GL_FUNCDECL_RPL (getcwd
, char *, (char *buf
, size_t size
));
1118 _GL_CXXALIAS_RPL (getcwd
, char *, (char *buf
, size_t size
));
1120 /* Need to cast, because on mingw, the second parameter is
1122 _GL_CXXALIAS_SYS_CAST (getcwd
, char *, (char *buf
, size_t size
));
1124 _GL_CXXALIASWARN (getcwd
);
1125 #elif defined GNULIB_POSIXCHECK
1127 # if HAVE_RAW_DECL_GETCWD
1128 _GL_WARN_ON_USE (getcwd
, "getcwd is unportable - "
1129 "use gnulib module getcwd for portability");
1135 /* Return the NIS domain name of the machine.
1136 WARNING! The NIS domain name is unrelated to the fully qualified host name
1137 of the machine. It is also unrelated to email addresses.
1138 WARNING! The NIS domain name is usually the empty string or "(none)" when
1141 Put up to LEN bytes of the NIS domain name into NAME.
1142 Null terminate it if the name is shorter than LEN.
1143 If the NIS domain name is longer than LEN, set errno = EINVAL and return -1.
1144 Return 0 if successful, otherwise set errno and return -1. */
1146 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1147 # undef getdomainname
1148 # define getdomainname rpl_getdomainname
1150 _GL_FUNCDECL_RPL (getdomainname
, int, (char *name
, size_t len
)
1151 _GL_ARG_NONNULL ((1)));
1152 _GL_CXXALIAS_RPL (getdomainname
, int, (char *name
, size_t len
));
1155 _GL_FUNCDECL_SYS (getdomainname
, int, (char *name
, size_t len
)
1156 _GL_ARG_NONNULL ((1)));
1158 _GL_CXXALIAS_SYS (getdomainname
, int, (char *name
, size_t len
));
1160 _GL_CXXALIASWARN (getdomainname
);
1161 #elif defined GNULIB_POSIXCHECK
1162 # undef getdomainname
1163 # if HAVE_RAW_DECL_GETDOMAINNAME
1164 _GL_WARN_ON_USE (getdomainname
, "getdomainname is unportable - "
1165 "use gnulib module getdomainname for portability");
1171 /* Return the maximum number of file descriptors in the current process.
1172 In POSIX, this is same as sysconf (_SC_OPEN_MAX). */
1174 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1175 # undef getdtablesize
1176 # define getdtablesize rpl_getdtablesize
1178 _GL_FUNCDECL_RPL (getdtablesize
, int, (void));
1179 _GL_CXXALIAS_RPL (getdtablesize
, int, (void));
1182 _GL_FUNCDECL_SYS (getdtablesize
, int, (void));
1184 _GL_CXXALIAS_SYS (getdtablesize
, int, (void));
1186 _GL_CXXALIASWARN (getdtablesize
);
1187 #elif defined GNULIB_POSIXCHECK
1188 # undef getdtablesize
1189 # if HAVE_RAW_DECL_GETDTABLESIZE
1190 _GL_WARN_ON_USE (getdtablesize
, "getdtablesize is unportable - "
1191 "use gnulib module getdtablesize for portability");
1197 /* Return the supplemental groups that the current process belongs to.
1198 It is unspecified whether the effective group id is in the list.
1199 If N is 0, return the group count; otherwise, N describes how many
1200 entries are available in GROUPS. Return -1 and set errno if N is
1201 not 0 and not large enough. Fails with ENOSYS on some systems. */
1203 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1205 # define getgroups rpl_getgroups
1207 _GL_FUNCDECL_RPL (getgroups
, int, (int n
, gid_t
*groups
));
1208 _GL_CXXALIAS_RPL (getgroups
, int, (int n
, gid_t
*groups
));
1211 _GL_FUNCDECL_SYS (getgroups
, int, (int n
, gid_t
*groups
));
1213 _GL_CXXALIAS_SYS (getgroups
, int, (int n
, gid_t
*groups
));
1215 _GL_CXXALIASWARN (getgroups
);
1216 #elif defined GNULIB_POSIXCHECK
1218 # if HAVE_RAW_DECL_GETGROUPS
1219 _GL_WARN_ON_USE (getgroups
, "getgroups is unportable - "
1220 "use gnulib module getgroups for portability");
1226 /* Return the standard host name of the machine.
1227 WARNING! The host name may or may not be fully qualified.
1229 Put up to LEN bytes of the host name into NAME.
1230 Null terminate it if the name is shorter than LEN.
1231 If the host name is longer than LEN, set errno = EINVAL and return -1.
1232 Return 0 if successful, otherwise set errno and return -1. */
1234 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1236 # define gethostname rpl_gethostname
1238 _GL_FUNCDECL_RPL (gethostname
, int, (char *name
, size_t len
)
1239 _GL_ARG_NONNULL ((1)));
1240 _GL_CXXALIAS_RPL (gethostname
, int, (char *name
, size_t len
));
1243 _GL_FUNCDECL_SYS (gethostname
, int, (char *name
, size_t len
)
1244 _GL_ARG_NONNULL ((1)));
1246 /* Need to cast, because on Solaris 10 and OSF/1 5.1 systems, the second
1249 _GL_CXXALIAS_SYS_CAST (gethostname
, int, (char *name
, size_t len
));
1251 _GL_CXXALIASWARN (gethostname
);
1254 # define gethostname gethostname_used_without_requesting_gnulib_module_gethostname
1255 #elif defined GNULIB_POSIXCHECK
1257 # if HAVE_RAW_DECL_GETHOSTNAME
1258 _GL_WARN_ON_USE (gethostname
, "gethostname is unportable - "
1259 "use gnulib module gethostname for portability");
1265 /* Returns the user's login name, or NULL if it cannot be found. Upon error,
1266 returns NULL with errno set.
1268 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
1270 Most programs don't need to use this function, because the information is
1271 available through environment variables:
1272 ${LOGNAME-$USER} on Unix platforms,
1273 $USERNAME on native Windows platforms.
1276 _GL_FUNCDECL_SYS (getlogin
, char *, (void));
1278 _GL_CXXALIAS_SYS (getlogin
, char *, (void));
1279 _GL_CXXALIASWARN (getlogin
);
1280 #elif defined GNULIB_POSIXCHECK
1282 # if HAVE_RAW_DECL_GETLOGIN
1283 _GL_WARN_ON_USE (getlogin
, "getlogin is unportable - "
1284 "use gnulib module getlogin for portability");
1290 /* Copies the user's login name to NAME.
1291 The array pointed to by NAME has room for SIZE bytes.
1293 Returns 0 if successful. Upon error, an error number is returned, or -1 in
1294 the case that the login name cannot be found but no specific error is
1295 provided (this case is hopefully rare but is left open by the POSIX spec).
1297 See <http://www.opengroup.org/susv3xsh/getlogin.html>.
1299 Most programs don't need to use this function, because the information is
1300 available through environment variables:
1301 ${LOGNAME-$USER} on Unix platforms,
1302 $USERNAME on native Windows platforms.
1305 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1306 # define getlogin_r rpl_getlogin_r
1308 _GL_FUNCDECL_RPL (getlogin_r
, int, (char *name
, size_t size
)
1309 _GL_ARG_NONNULL ((1)));
1310 _GL_CXXALIAS_RPL (getlogin_r
, int, (char *name
, size_t size
));
1313 _GL_FUNCDECL_SYS (getlogin_r
, int, (char *name
, size_t size
)
1314 _GL_ARG_NONNULL ((1)));
1316 /* Need to cast, because on Solaris 10 systems, the second argument is
1318 _GL_CXXALIAS_SYS_CAST (getlogin_r
, int, (char *name
, size_t size
));
1320 _GL_CXXALIASWARN (getlogin_r
);
1321 #elif defined GNULIB_POSIXCHECK
1323 # if HAVE_RAW_DECL_GETLOGIN_R
1324 _GL_WARN_ON_USE (getlogin_r
, "getlogin_r is unportable - "
1325 "use gnulib module getlogin_r for portability");
1332 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1333 # define getpagesize rpl_getpagesize
1335 _GL_FUNCDECL_RPL (getpagesize
, int, (void));
1336 _GL_CXXALIAS_RPL (getpagesize
, int, (void));
1339 # if !defined getpagesize
1340 /* This is for POSIX systems. */
1341 # if !defined _gl_getpagesize && defined _SC_PAGESIZE
1342 # if ! (defined __VMS && __VMS_VER < 70000000)
1343 # define _gl_getpagesize() sysconf (_SC_PAGESIZE)
1346 /* This is for older VMS. */
1347 # if !defined _gl_getpagesize && defined __VMS
1349 # define _gl_getpagesize() 8192
1351 # define _gl_getpagesize() 512
1354 /* This is for BeOS. */
1355 # if !defined _gl_getpagesize && 0
1357 # if defined B_PAGE_SIZE
1358 # define _gl_getpagesize() B_PAGE_SIZE
1361 /* This is for AmigaOS4.0. */
1362 # if !defined _gl_getpagesize && defined __amigaos4__
1363 # define _gl_getpagesize() 2048
1365 /* This is for older Unix systems. */
1366 # if !defined _gl_getpagesize && 0
1367 # include <sys/param.h>
1368 # ifdef EXEC_PAGESIZE
1369 # define _gl_getpagesize() EXEC_PAGESIZE
1375 # define _gl_getpagesize() (NBPG * CLSIZE)
1378 # define _gl_getpagesize() NBPC
1383 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1384 # define getpagesize() _gl_getpagesize ()
1386 # if !GNULIB_defined_getpagesize_function
1387 _GL_UNISTD_INLINE
int
1390 return _gl_getpagesize ();
1392 # define GNULIB_defined_getpagesize_function 1
1397 /* Need to cast, because on Cygwin 1.5.x systems, the return type is size_t. */
1398 _GL_CXXALIAS_SYS_CAST (getpagesize
, int, (void));
1401 _GL_CXXALIASWARN (getpagesize
);
1403 #elif defined GNULIB_POSIXCHECK
1405 # if HAVE_RAW_DECL_GETPAGESIZE
1406 _GL_WARN_ON_USE (getpagesize
, "getpagesize is unportable - "
1407 "use gnulib module getpagesize for portability");
1413 /* Function getpass() from module 'getpass':
1414 Read a password from /dev/tty or stdin.
1415 Function getpass() from module 'getpass-gnu':
1416 Read a password of arbitrary length from /dev/tty or stdin. */
1418 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1420 # define getpass rpl_getpass
1422 _GL_FUNCDECL_RPL (getpass
, char *, (const char *prompt
)
1423 _GL_ARG_NONNULL ((1)));
1424 _GL_CXXALIAS_RPL (getpass
, char *, (const char *prompt
));
1427 _GL_FUNCDECL_SYS (getpass
, char *, (const char *prompt
)
1428 _GL_ARG_NONNULL ((1)));
1430 _GL_CXXALIAS_SYS (getpass
, char *, (const char *prompt
));
1432 _GL_CXXALIASWARN (getpass
);
1433 #elif defined GNULIB_POSIXCHECK
1435 # if HAVE_RAW_DECL_GETPASS
1436 _GL_WARN_ON_USE (getpass
, "getpass is unportable - "
1437 "use gnulib module getpass or getpass-gnu for portability");
1443 /* Return the next valid login shell on the system, or NULL when the end of
1444 the list has been reached. */
1446 _GL_FUNCDECL_SYS (getusershell
, char *, (void));
1448 _GL_CXXALIAS_SYS (getusershell
, char *, (void));
1449 _GL_CXXALIASWARN (getusershell
);
1450 #elif defined GNULIB_POSIXCHECK
1451 # undef getusershell
1452 # if HAVE_RAW_DECL_GETUSERSHELL
1453 _GL_WARN_ON_USE (getusershell
, "getusershell is unportable - "
1454 "use gnulib module getusershell for portability");
1459 /* Rewind to pointer that is advanced at each getusershell() call. */
1461 _GL_FUNCDECL_SYS (setusershell
, void, (void));
1463 _GL_CXXALIAS_SYS (setusershell
, void, (void));
1464 _GL_CXXALIASWARN (setusershell
);
1465 #elif defined GNULIB_POSIXCHECK
1466 # undef setusershell
1467 # if HAVE_RAW_DECL_SETUSERSHELL
1468 _GL_WARN_ON_USE (setusershell
, "setusershell is unportable - "
1469 "use gnulib module getusershell for portability");
1474 /* Free the pointer that is advanced at each getusershell() call and
1475 associated resources. */
1477 _GL_FUNCDECL_SYS (endusershell
, void, (void));
1479 _GL_CXXALIAS_SYS (endusershell
, void, (void));
1480 _GL_CXXALIASWARN (endusershell
);
1481 #elif defined GNULIB_POSIXCHECK
1482 # undef endusershell
1483 # if HAVE_RAW_DECL_ENDUSERSHELL
1484 _GL_WARN_ON_USE (endusershell
, "endusershell is unportable - "
1485 "use gnulib module getusershell for portability");
1491 /* Determine whether group id is in calling user's group list. */
1493 _GL_FUNCDECL_SYS (group_member
, int, (gid_t gid
));
1495 _GL_CXXALIAS_SYS (group_member
, int, (gid_t gid
));
1496 _GL_CXXALIASWARN (group_member
);
1497 #elif defined GNULIB_POSIXCHECK
1498 # undef group_member
1499 # if HAVE_RAW_DECL_GROUP_MEMBER
1500 _GL_WARN_ON_USE (group_member
, "group_member is unportable - "
1501 "use gnulib module group-member for portability");
1508 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1510 # define isatty rpl_isatty
1512 _GL_FUNCDECL_RPL (isatty
, int, (int fd
));
1513 _GL_CXXALIAS_RPL (isatty
, int, (int fd
));
1515 _GL_CXXALIAS_SYS (isatty
, int, (int fd
));
1517 _GL_CXXALIASWARN (isatty
);
1518 #elif defined GNULIB_POSIXCHECK
1520 # if HAVE_RAW_DECL_ISATTY
1521 _GL_WARN_ON_USE (isatty
, "isatty has portability problems on native Windows - "
1522 "use gnulib module isatty for portability");
1528 /* Change the owner of FILE to UID (if UID is not -1) and the group of FILE
1529 to GID (if GID is not -1). Do not follow symbolic links.
1530 Return 0 if successful, otherwise -1 and errno set.
1531 See the POSIX:2008 specification
1532 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html>. */
1534 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1536 # define lchown rpl_lchown
1538 _GL_FUNCDECL_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1539 _GL_ARG_NONNULL ((1)));
1540 _GL_CXXALIAS_RPL (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1543 _GL_FUNCDECL_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
)
1544 _GL_ARG_NONNULL ((1)));
1546 _GL_CXXALIAS_SYS (lchown
, int, (char const *file
, uid_t owner
, gid_t group
));
1548 _GL_CXXALIASWARN (lchown
);
1549 #elif defined GNULIB_POSIXCHECK
1551 # if HAVE_RAW_DECL_LCHOWN
1552 _GL_WARN_ON_USE (lchown
, "lchown is unportable to pre-POSIX.1-2001 systems - "
1553 "use gnulib module lchown for portability");
1559 /* Create a new hard link for an existing file.
1560 Return 0 if successful, otherwise -1 and errno set.
1561 See POSIX:2008 specification
1562 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html>. */
1564 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1565 # define link rpl_link
1567 _GL_FUNCDECL_RPL (link
, int, (const char *path1
, const char *path2
)
1568 _GL_ARG_NONNULL ((1, 2)));
1569 _GL_CXXALIAS_RPL (link
, int, (const char *path1
, const char *path2
));
1572 _GL_FUNCDECL_SYS (link
, int, (const char *path1
, const char *path2
)
1573 _GL_ARG_NONNULL ((1, 2)));
1575 _GL_CXXALIAS_SYS (link
, int, (const char *path1
, const char *path2
));
1577 _GL_CXXALIASWARN (link
);
1578 #elif defined GNULIB_POSIXCHECK
1580 # if HAVE_RAW_DECL_LINK
1581 _GL_WARN_ON_USE (link
, "link is unportable - "
1582 "use gnulib module link for portability");
1588 /* Create a new hard link for an existing file, relative to two
1589 directories. FLAG controls whether symlinks are followed.
1590 Return 0 if successful, otherwise -1 and errno set. */
1592 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1594 # define linkat rpl_linkat
1596 _GL_FUNCDECL_RPL (linkat
, int,
1597 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1599 _GL_ARG_NONNULL ((2, 4)));
1600 _GL_CXXALIAS_RPL (linkat
, int,
1601 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1605 _GL_FUNCDECL_SYS (linkat
, int,
1606 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1608 _GL_ARG_NONNULL ((2, 4)));
1610 _GL_CXXALIAS_SYS (linkat
, int,
1611 (int fd1
, const char *path1
, int fd2
, const char *path2
,
1614 _GL_CXXALIASWARN (linkat
);
1615 #elif defined GNULIB_POSIXCHECK
1617 # if HAVE_RAW_DECL_LINKAT
1618 _GL_WARN_ON_USE (linkat
, "linkat is unportable - "
1619 "use gnulib module linkat for portability");
1625 /* Set the offset of FD relative to SEEK_SET, SEEK_CUR, or SEEK_END.
1626 Return the new offset if successful, otherwise -1 and errno set.
1627 See the POSIX:2008 specification
1628 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html>. */
1630 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1631 # define lseek rpl_lseek
1633 _GL_FUNCDECL_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1634 _GL_CXXALIAS_RPL (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1636 _GL_CXXALIAS_SYS (lseek
, off_t
, (int fd
, off_t offset
, int whence
));
1638 _GL_CXXALIASWARN (lseek
);
1639 #elif defined GNULIB_POSIXCHECK
1641 # if HAVE_RAW_DECL_LSEEK
1642 _GL_WARN_ON_USE (lseek
, "lseek does not fail with ESPIPE on pipes on some "
1643 "systems - use gnulib module lseek for portability");
1649 /* Create a pipe, defaulting to O_BINARY mode.
1650 Store the read-end as fd[0] and the write-end as fd[1].
1651 Return 0 upon success, or -1 with errno set upon failure. */
1653 _GL_FUNCDECL_SYS (pipe
, int, (int fd
[2]) _GL_ARG_NONNULL ((1)));
1655 _GL_CXXALIAS_SYS (pipe
, int, (int fd
[2]));
1656 _GL_CXXALIASWARN (pipe
);
1657 #elif defined GNULIB_POSIXCHECK
1659 # if HAVE_RAW_DECL_PIPE
1660 _GL_WARN_ON_USE (pipe
, "pipe is unportable - "
1661 "use gnulib module pipe-posix for portability");
1667 /* Create a pipe, applying the given flags when opening the read-end of the
1668 pipe and the write-end of the pipe.
1669 The flags are a bitmask, possibly including O_CLOEXEC (defined in <fcntl.h>)
1670 and O_TEXT, O_BINARY (defined in "binary-io.h").
1671 Store the read-end as fd[0] and the write-end as fd[1].
1672 Return 0 upon success, or -1 with errno set upon failure.
1673 See also the Linux man page at
1674 <https://www.kernel.org/doc/man-pages/online/pages/man2/pipe2.2.html>. */
1676 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1677 # define pipe2 rpl_pipe2
1679 _GL_FUNCDECL_RPL (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1680 _GL_CXXALIAS_RPL (pipe2
, int, (int fd
[2], int flags
));
1682 _GL_FUNCDECL_SYS (pipe2
, int, (int fd
[2], int flags
) _GL_ARG_NONNULL ((1)));
1683 _GL_CXXALIAS_SYS (pipe2
, int, (int fd
[2], int flags
));
1685 _GL_CXXALIASWARN (pipe2
);
1686 #elif defined GNULIB_POSIXCHECK
1688 # if HAVE_RAW_DECL_PIPE2
1689 _GL_WARN_ON_USE (pipe2
, "pipe2 is unportable - "
1690 "use gnulib module pipe2 for portability");
1696 /* Read at most BUFSIZE bytes from FD into BUF, starting at OFFSET.
1697 Return the number of bytes placed into BUF if successful, otherwise
1698 set errno and return -1. 0 indicates EOF.
1699 See the POSIX:2008 specification
1700 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html>. */
1702 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1704 # define pread rpl_pread
1706 _GL_FUNCDECL_RPL (pread
, ssize_t
,
1707 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1708 _GL_ARG_NONNULL ((2)));
1709 _GL_CXXALIAS_RPL (pread
, ssize_t
,
1710 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1713 _GL_FUNCDECL_SYS (pread
, ssize_t
,
1714 (int fd
, void *buf
, size_t bufsize
, off_t offset
)
1715 _GL_ARG_NONNULL ((2)));
1717 _GL_CXXALIAS_SYS (pread
, ssize_t
,
1718 (int fd
, void *buf
, size_t bufsize
, off_t offset
));
1720 _GL_CXXALIASWARN (pread
);
1721 #elif defined GNULIB_POSIXCHECK
1723 # if HAVE_RAW_DECL_PREAD
1724 _GL_WARN_ON_USE (pread
, "pread is unportable - "
1725 "use gnulib module pread for portability");
1731 /* Write at most BUFSIZE bytes from BUF into FD, starting at OFFSET.
1732 Return the number of bytes written if successful, otherwise
1733 set errno and return -1. 0 indicates nothing written. See the
1734 POSIX:2008 specification
1735 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/pwrite.html>. */
1737 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1739 # define pwrite rpl_pwrite
1741 _GL_FUNCDECL_RPL (pwrite
, ssize_t
,
1742 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1743 _GL_ARG_NONNULL ((2)));
1744 _GL_CXXALIAS_RPL (pwrite
, ssize_t
,
1745 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1748 _GL_FUNCDECL_SYS (pwrite
, ssize_t
,
1749 (int fd
, const void *buf
, size_t bufsize
, off_t offset
)
1750 _GL_ARG_NONNULL ((2)));
1752 _GL_CXXALIAS_SYS (pwrite
, ssize_t
,
1753 (int fd
, const void *buf
, size_t bufsize
, off_t offset
));
1755 _GL_CXXALIASWARN (pwrite
);
1756 #elif defined GNULIB_POSIXCHECK
1758 # if HAVE_RAW_DECL_PWRITE
1759 _GL_WARN_ON_USE (pwrite
, "pwrite is unportable - "
1760 "use gnulib module pwrite for portability");
1766 /* Read up to COUNT bytes from file descriptor FD into the buffer starting
1767 at BUF. See the POSIX:2008 specification
1768 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/read.html>. */
1770 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1772 # define read rpl_read
1774 _GL_FUNCDECL_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
)
1775 _GL_ARG_NONNULL ((2)));
1776 _GL_CXXALIAS_RPL (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1778 /* Need to cast, because on mingw, the third parameter is
1780 and the return type is 'int'. */
1781 _GL_CXXALIAS_SYS_CAST (read
, ssize_t
, (int fd
, void *buf
, size_t count
));
1783 _GL_CXXALIASWARN (read
);
1788 /* Read the contents of the symbolic link FILE and place the first BUFSIZE
1789 bytes of it into BUF. Return the number of bytes placed into BUF if
1790 successful, otherwise -1 and errno set.
1791 See the POSIX:2008 specification
1792 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>. */
1794 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1795 # define readlink rpl_readlink
1797 _GL_FUNCDECL_RPL (readlink
, ssize_t
,
1798 (const char *file
, char *buf
, size_t bufsize
)
1799 _GL_ARG_NONNULL ((1, 2)));
1800 _GL_CXXALIAS_RPL (readlink
, ssize_t
,
1801 (const char *file
, char *buf
, size_t bufsize
));
1804 _GL_FUNCDECL_SYS (readlink
, ssize_t
,
1805 (const char *file
, char *buf
, size_t bufsize
)
1806 _GL_ARG_NONNULL ((1, 2)));
1808 _GL_CXXALIAS_SYS (readlink
, ssize_t
,
1809 (const char *file
, char *buf
, size_t bufsize
));
1811 _GL_CXXALIASWARN (readlink
);
1812 #elif defined GNULIB_POSIXCHECK
1814 # if HAVE_RAW_DECL_READLINK
1815 _GL_WARN_ON_USE (readlink
, "readlink is unportable - "
1816 "use gnulib module readlink for portability");
1823 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1824 # define readlinkat rpl_readlinkat
1826 _GL_FUNCDECL_RPL (readlinkat
, ssize_t
,
1827 (int fd
, char const *file
, char *buf
, size_t len
)
1828 _GL_ARG_NONNULL ((2, 3)));
1829 _GL_CXXALIAS_RPL (readlinkat
, ssize_t
,
1830 (int fd
, char const *file
, char *buf
, size_t len
));
1833 _GL_FUNCDECL_SYS (readlinkat
, ssize_t
,
1834 (int fd
, char const *file
, char *buf
, size_t len
)
1835 _GL_ARG_NONNULL ((2, 3)));
1837 _GL_CXXALIAS_SYS (readlinkat
, ssize_t
,
1838 (int fd
, char const *file
, char *buf
, size_t len
));
1840 _GL_CXXALIASWARN (readlinkat
);
1841 #elif defined GNULIB_POSIXCHECK
1843 # if HAVE_RAW_DECL_READLINKAT
1844 _GL_WARN_ON_USE (readlinkat
, "readlinkat is not portable - "
1845 "use gnulib module readlinkat for portability");
1851 /* Remove the directory DIR. */
1853 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1854 # define rmdir rpl_rmdir
1856 _GL_FUNCDECL_RPL (rmdir
, int, (char const *name
) _GL_ARG_NONNULL ((1)));
1857 _GL_CXXALIAS_RPL (rmdir
, int, (char const *name
));
1859 _GL_CXXALIAS_SYS (rmdir
, int, (char const *name
));
1861 _GL_CXXALIASWARN (rmdir
);
1862 #elif defined GNULIB_POSIXCHECK
1864 # if HAVE_RAW_DECL_RMDIR
1865 _GL_WARN_ON_USE (rmdir
, "rmdir is unportable - "
1866 "use gnulib module rmdir for portability");
1872 /* Set the host name of the machine.
1873 The host name may or may not be fully qualified.
1875 Put LEN bytes of NAME into the host name.
1876 Return 0 if successful, otherwise, set errno and return -1.
1878 Platforms with no ability to set the hostname return -1 and set
1881 _GL_FUNCDECL_SYS (sethostname
, int, (const char *name
, size_t len
)
1882 _GL_ARG_NONNULL ((1)));
1884 /* Need to cast, because on Solaris 11 2011-10, Mac OS X 10.5, IRIX 6.5
1885 and FreeBSD 6.4 the second parameter is int. On Solaris 11
1886 2011-10, the first parameter is not const. */
1887 _GL_CXXALIAS_SYS_CAST (sethostname
, int, (const char *name
, size_t len
));
1888 _GL_CXXALIASWARN (sethostname
);
1889 #elif defined GNULIB_POSIXCHECK
1891 # if HAVE_RAW_DECL_SETHOSTNAME
1892 _GL_WARN_ON_USE (sethostname
, "sethostname is unportable - "
1893 "use gnulib module sethostname for portability");
1899 /* Pause the execution of the current thread for N seconds.
1900 Returns the number of seconds left to sleep.
1901 See the POSIX:2008 specification
1902 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html>. */
1904 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1906 # define sleep rpl_sleep
1908 _GL_FUNCDECL_RPL (sleep
, unsigned int, (unsigned int n
));
1909 _GL_CXXALIAS_RPL (sleep
, unsigned int, (unsigned int n
));
1912 _GL_FUNCDECL_SYS (sleep
, unsigned int, (unsigned int n
));
1914 _GL_CXXALIAS_SYS (sleep
, unsigned int, (unsigned int n
));
1916 _GL_CXXALIASWARN (sleep
);
1917 #elif defined GNULIB_POSIXCHECK
1919 # if HAVE_RAW_DECL_SLEEP
1920 _GL_WARN_ON_USE (sleep
, "sleep is unportable - "
1921 "use gnulib module sleep for portability");
1928 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1930 # define symlink rpl_symlink
1932 _GL_FUNCDECL_RPL (symlink
, int, (char const *contents
, char const *file
)
1933 _GL_ARG_NONNULL ((1, 2)));
1934 _GL_CXXALIAS_RPL (symlink
, int, (char const *contents
, char const *file
));
1937 _GL_FUNCDECL_SYS (symlink
, int, (char const *contents
, char const *file
)
1938 _GL_ARG_NONNULL ((1, 2)));
1940 _GL_CXXALIAS_SYS (symlink
, int, (char const *contents
, char const *file
));
1942 _GL_CXXALIASWARN (symlink
);
1943 #elif defined GNULIB_POSIXCHECK
1945 # if HAVE_RAW_DECL_SYMLINK
1946 _GL_WARN_ON_USE (symlink
, "symlink is not portable - "
1947 "use gnulib module symlink for portability");
1954 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1956 # define symlinkat rpl_symlinkat
1958 _GL_FUNCDECL_RPL (symlinkat
, int,
1959 (char const *contents
, int fd
, char const *file
)
1960 _GL_ARG_NONNULL ((1, 3)));
1961 _GL_CXXALIAS_RPL (symlinkat
, int,
1962 (char const *contents
, int fd
, char const *file
));
1965 _GL_FUNCDECL_SYS (symlinkat
, int,
1966 (char const *contents
, int fd
, char const *file
)
1967 _GL_ARG_NONNULL ((1, 3)));
1969 _GL_CXXALIAS_SYS (symlinkat
, int,
1970 (char const *contents
, int fd
, char const *file
));
1972 _GL_CXXALIASWARN (symlinkat
);
1973 #elif defined GNULIB_POSIXCHECK
1975 # if HAVE_RAW_DECL_SYMLINKAT
1976 _GL_WARN_ON_USE (symlinkat
, "symlinkat is not portable - "
1977 "use gnulib module symlinkat for portability");
1983 /* Change the size of the file designated by FILENAME to become equal to LENGTH.
1984 Return 0 if successful, otherwise -1 and errno set.
1985 See the POSIX:2008 specification
1986 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html>. */
1988 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
1990 # define truncate rpl_truncate
1992 _GL_FUNCDECL_RPL (truncate
, int, (const char *filename
, off_t length
)
1993 _GL_ARG_NONNULL ((1)));
1994 _GL_CXXALIAS_RPL (truncate
, int, (const char *filename
, off_t length
));
1997 _GL_FUNCDECL_SYS (truncate
, int, (const char *filename
, off_t length
)
1998 _GL_ARG_NONNULL ((1)));
2000 _GL_CXXALIAS_SYS (truncate
, int, (const char *filename
, off_t length
));
2002 _GL_CXXALIASWARN (truncate
);
2003 #elif defined GNULIB_POSIXCHECK
2005 # if HAVE_RAW_DECL_TRUNCATE
2006 _GL_WARN_ON_USE (truncate
, "truncate is unportable - "
2007 "use gnulib module truncate for portability");
2013 /* Store at most BUFLEN characters of the pathname of the terminal FD is
2014 open on in BUF. Return 0 on success, otherwise an error number. */
2016 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2018 # define ttyname_r rpl_ttyname_r
2020 _GL_FUNCDECL_RPL (ttyname_r
, int,
2021 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
2022 _GL_CXXALIAS_RPL (ttyname_r
, int,
2023 (int fd
, char *buf
, size_t buflen
));
2026 _GL_FUNCDECL_SYS (ttyname_r
, int,
2027 (int fd
, char *buf
, size_t buflen
) _GL_ARG_NONNULL ((2)));
2029 _GL_CXXALIAS_SYS (ttyname_r
, int,
2030 (int fd
, char *buf
, size_t buflen
));
2032 _GL_CXXALIASWARN (ttyname_r
);
2033 #elif defined GNULIB_POSIXCHECK
2035 # if HAVE_RAW_DECL_TTYNAME_R
2036 _GL_WARN_ON_USE (ttyname_r
, "ttyname_r is not portable - "
2037 "use gnulib module ttyname_r for portability");
2044 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2046 # define unlink rpl_unlink
2048 _GL_FUNCDECL_RPL (unlink
, int, (char const *file
) _GL_ARG_NONNULL ((1)));
2049 _GL_CXXALIAS_RPL (unlink
, int, (char const *file
));
2051 _GL_CXXALIAS_SYS (unlink
, int, (char const *file
));
2053 _GL_CXXALIASWARN (unlink
);
2054 #elif defined GNULIB_POSIXCHECK
2056 # if HAVE_RAW_DECL_UNLINK
2057 _GL_WARN_ON_USE (unlink
, "unlink is not portable - "
2058 "use gnulib module unlink for portability");
2065 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2067 # define unlinkat rpl_unlinkat
2069 _GL_FUNCDECL_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
)
2070 _GL_ARG_NONNULL ((2)));
2071 _GL_CXXALIAS_RPL (unlinkat
, int, (int fd
, char const *file
, int flag
));
2074 _GL_FUNCDECL_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
)
2075 _GL_ARG_NONNULL ((2)));
2077 _GL_CXXALIAS_SYS (unlinkat
, int, (int fd
, char const *file
, int flag
));
2079 _GL_CXXALIASWARN (unlinkat
);
2080 #elif defined GNULIB_POSIXCHECK
2082 # if HAVE_RAW_DECL_UNLINKAT
2083 _GL_WARN_ON_USE (unlinkat
, "unlinkat is not portable - "
2084 "use gnulib module openat for portability");
2090 /* Pause the execution of the current thread for N microseconds.
2091 Returns 0 on completion, or -1 on range error.
2092 See the POSIX:2001 specification
2093 <http://www.opengroup.org/susv3xsh/usleep.html>. */
2095 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2097 # define usleep rpl_usleep
2099 _GL_FUNCDECL_RPL (usleep
, int, (useconds_t n
));
2100 _GL_CXXALIAS_RPL (usleep
, int, (useconds_t n
));
2103 _GL_FUNCDECL_SYS (usleep
, int, (useconds_t n
));
2105 _GL_CXXALIAS_SYS (usleep
, int, (useconds_t n
));
2107 _GL_CXXALIASWARN (usleep
);
2108 #elif defined GNULIB_POSIXCHECK
2110 # if HAVE_RAW_DECL_USLEEP
2111 _GL_WARN_ON_USE (usleep
, "usleep is unportable - "
2112 "use gnulib module usleep for portability");
2118 /* Write up to COUNT bytes starting at BUF to file descriptor FD.
2119 See the POSIX:2008 specification
2120 <http://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html>. */
2122 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
2124 # define write rpl_write
2126 _GL_FUNCDECL_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
)
2127 _GL_ARG_NONNULL ((2)));
2128 _GL_CXXALIAS_RPL (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2130 /* Need to cast, because on mingw, the third parameter is
2132 and the return type is 'int'. */
2133 _GL_CXXALIAS_SYS_CAST (write
, ssize_t
, (int fd
, const void *buf
, size_t count
));
2135 _GL_CXXALIASWARN (write
);
2138 _GL_INLINE_HEADER_END
2140 #endif /* _GL_UNISTD_H */
2141 #endif /* _GL_INCLUDING_UNISTD_H */
2142 #endif /* _GL_UNISTD_H */