xref: /netbsd-src/external/gpl3/gdb/lib/libgnulib/arch/vax/gnulib/import/dirent.h (revision 901e7e84758515fbf39dfc064cb0b45ab146d8b0)
1 /* This file is automatically generated.  DO NOT EDIT! */
2 /* Generated from: NetBSD: mknative-gdb,v 1.16 2023/07/31 17:09:59 christos Exp  */
3 /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp  */
4 
5 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
6 /* A GNU-like <dirent.h>.
7    Copyright (C) 2006-2022 Free Software Foundation, Inc.
8 
9    This file is free software: you can redistribute it and/or modify
10    it under the terms of the GNU Lesser General Public License as
11    published by the Free Software Foundation; either version 2.1 of the
12    License, or (at your option) any later version.
13 
14    This file is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU Lesser General Public License for more details.
18 
19    You should have received a copy of the GNU Lesser General Public License
20    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
21 
22 #ifndef _GL_DIRENT_H
23 
24 #if __GNUC__ >= 3
25 #pragma GCC system_header
26 #endif
27 
28 
29 /* The include_next requires a split double-inclusion guard.  */
30 #if 1
31 # include_next <dirent.h>
32 #endif
33 
34 #ifndef _GL_DIRENT_H
35 #define _GL_DIRENT_H
36 
37 /* Get ino_t.  Needed on some systems, including glibc 2.8.  */
38 #include <sys/types.h>
39 
40 #if !1
41 /* Define types DIR and 'struct dirent'.  */
42 # if !GNULIB_defined_struct_dirent
43 struct dirent
44 {
45   char d_type;
46   char d_name[1];
47 };
48 /* Possible values for 'd_type'.  */
49 #  define DT_UNKNOWN 0
50 #  define DT_FIFO    1          /* FIFO */
51 #  define DT_CHR     2          /* character device */
52 #  define DT_DIR     4          /* directory */
53 #  define DT_BLK     6          /* block device */
54 #  define DT_REG     8          /* regular file */
55 #  define DT_LNK    10          /* symbolic link */
56 #  define DT_SOCK   12          /* socket */
57 #  define DT_WHT    14          /* whiteout */
58 typedef struct gl_directory DIR;
59 #  define GNULIB_defined_struct_dirent 1
60 # endif
61 #endif
62 
63 /* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers
64    that can be freed by passing them as the Ith argument to the
65    function F.  */
66 #ifndef _GL_ATTRIBUTE_DEALLOC
67 # if __GNUC__ >= 11
68 #  define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i)))
69 # else
70 #  define _GL_ATTRIBUTE_DEALLOC(f, i)
71 # endif
72 #endif
73 
74 /* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly
75    allocated memory.  */
76 /* Applies to: functions.  */
77 #ifndef _GL_ATTRIBUTE_MALLOC
78 # if __GNUC__ >= 3 || defined __clang__
79 #  define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
80 # else
81 #  define _GL_ATTRIBUTE_MALLOC
82 # endif
83 #endif
84 
85 /* The __attribute__ feature is available in gcc versions 2.5 and later.
86    The attribute __pure__ was added in gcc 2.96.  */
87 #ifndef _GL_ATTRIBUTE_PURE
88 # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
89 #  define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
90 # else
91 #  define _GL_ATTRIBUTE_PURE /* empty */
92 # endif
93 #endif
94 
95 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
96 /* C++ compatible function declaration macros.
97    Copyright (C) 2010-2022 Free Software Foundation, Inc.
98 
99    This program is free software: you can redistribute it and/or modify it
100    under the terms of the GNU Lesser General Public License as published
101    by the Free Software Foundation; either version 2 of the License, or
102    (at your option) any later version.
103 
104    This program is distributed in the hope that it will be useful,
105    but WITHOUT ANY WARRANTY; without even the implied warranty of
106    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
107    Lesser General Public License for more details.
108 
109    You should have received a copy of the GNU Lesser General Public License
110    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
111 
112 #ifndef _GL_CXXDEFS_H
113 #define _GL_CXXDEFS_H
114 
115 /* Begin/end the GNULIB_NAMESPACE namespace.  */
116 #if defined __cplusplus && defined GNULIB_NAMESPACE
117 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
118 # define _GL_END_NAMESPACE }
119 #else
120 # define _GL_BEGIN_NAMESPACE
121 # define _GL_END_NAMESPACE
122 #endif
123 
124 /* The three most frequent use cases of these macros are:
125 
126    * For providing a substitute for a function that is missing on some
127      platforms, but is declared and works fine on the platforms on which
128      it exists:
129 
130        #if @GNULIB_FOO@
131        # if !@HAVE_FOO@
132        _GL_FUNCDECL_SYS (foo, ...);
133        # endif
134        _GL_CXXALIAS_SYS (foo, ...);
135        _GL_CXXALIASWARN (foo);
136        #elif defined GNULIB_POSIXCHECK
137        ...
138        #endif
139 
140    * For providing a replacement for a function that exists on all platforms,
141      but is broken/insufficient and needs to be replaced on some platforms:
142 
143        #if @GNULIB_FOO@
144        # if @REPLACE_FOO@
145        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
146        #   undef foo
147        #   define foo rpl_foo
148        #  endif
149        _GL_FUNCDECL_RPL (foo, ...);
150        _GL_CXXALIAS_RPL (foo, ...);
151        # else
152        _GL_CXXALIAS_SYS (foo, ...);
153        # endif
154        _GL_CXXALIASWARN (foo);
155        #elif defined GNULIB_POSIXCHECK
156        ...
157        #endif
158 
159    * For providing a replacement for a function that exists on some platforms
160      but is broken/insufficient and needs to be replaced on some of them and
161      is additionally either missing or undeclared on some other platforms:
162 
163        #if @GNULIB_FOO@
164        # if @REPLACE_FOO@
165        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
166        #   undef foo
167        #   define foo rpl_foo
168        #  endif
169        _GL_FUNCDECL_RPL (foo, ...);
170        _GL_CXXALIAS_RPL (foo, ...);
171        # else
172        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
173        _GL_FUNCDECL_SYS (foo, ...);
174        #  endif
175        _GL_CXXALIAS_SYS (foo, ...);
176        # endif
177        _GL_CXXALIASWARN (foo);
178        #elif defined GNULIB_POSIXCHECK
179        ...
180        #endif
181 */
182 
183 /* _GL_EXTERN_C declaration;
184    performs the declaration with C linkage.  */
185 #if defined __cplusplus
186 # define _GL_EXTERN_C extern "C"
187 #else
188 # define _GL_EXTERN_C extern
189 #endif
190 
191 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
192    declares a replacement function, named rpl_func, with the given prototype,
193    consisting of return type, parameters, and attributes.
194    Example:
195      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
196                                   _GL_ARG_NONNULL ((1)));
197  */
198 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
199   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
200 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
201   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
202 
203 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
204    declares the system function, named func, with the given prototype,
205    consisting of return type, parameters, and attributes.
206    Example:
207      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
208                                   _GL_ARG_NONNULL ((1)));
209  */
210 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
211   _GL_EXTERN_C rettype func parameters_and_attributes
212 
213 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
214    declares a C++ alias called GNULIB_NAMESPACE::func
215    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
216    Example:
217      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
218 
219    Wrapping rpl_func in an object with an inline conversion operator
220    avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
221    actually used in the program.  */
222 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
223   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
224 #if defined __cplusplus && defined GNULIB_NAMESPACE
225 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
226     namespace GNULIB_NAMESPACE                                \
227     {                                                         \
228       static const struct _gl_ ## func ## _wrapper            \
229       {                                                       \
230         typedef rettype (*type) parameters;                   \
231                                                               \
232         inline operator type () const                         \
233         {                                                     \
234           return ::rpl_func;                                  \
235         }                                                     \
236       } func = {};                                            \
237     }                                                         \
238     _GL_EXTERN_C int _gl_cxxalias_dummy
239 #else
240 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
241     _GL_EXTERN_C int _gl_cxxalias_dummy
242 #endif
243 
244 /* _GL_CXXALIAS_MDA (func, rettype, parameters);
245    is to be used when func is a Microsoft deprecated alias, on native Windows.
246    It declares a C++ alias called GNULIB_NAMESPACE::func
247    that redirects to _func, if GNULIB_NAMESPACE is defined.
248    Example:
249      _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
250  */
251 #define _GL_CXXALIAS_MDA(func,rettype,parameters) \
252   _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
253 
254 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
255    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
256    except that the C function rpl_func may have a slightly different
257    declaration.  A cast is used to silence the "invalid conversion" error
258    that would otherwise occur.  */
259 #if defined __cplusplus && defined GNULIB_NAMESPACE
260 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
261     namespace GNULIB_NAMESPACE                                     \
262     {                                                              \
263       static const struct _gl_ ## func ## _wrapper                 \
264       {                                                            \
265         typedef rettype (*type) parameters;                        \
266                                                                    \
267         inline operator type () const                              \
268         {                                                          \
269           return reinterpret_cast<type>(::rpl_func);               \
270         }                                                          \
271       } func = {};                                                 \
272     }                                                              \
273     _GL_EXTERN_C int _gl_cxxalias_dummy
274 #else
275 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
276     _GL_EXTERN_C int _gl_cxxalias_dummy
277 #endif
278 
279 /* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
280    is like  _GL_CXXALIAS_MDA (func, rettype, parameters);
281    except that the C function func may have a slightly different declaration.
282    A cast is used to silence the "invalid conversion" error that would
283    otherwise occur.  */
284 #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
285   _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
286 
287 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
288    declares a C++ alias called GNULIB_NAMESPACE::func
289    that redirects to the system provided function func, if GNULIB_NAMESPACE
290    is defined.
291    Example:
292      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
293 
294    Wrapping func in an object with an inline conversion operator
295    avoids a reference to func unless GNULIB_NAMESPACE::func is
296    actually used in the program.  */
297 #if defined __cplusplus && defined GNULIB_NAMESPACE
298 # define _GL_CXXALIAS_SYS(func,rettype,parameters)            \
299     namespace GNULIB_NAMESPACE                                \
300     {                                                         \
301       static const struct _gl_ ## func ## _wrapper            \
302       {                                                       \
303         typedef rettype (*type) parameters;                   \
304                                                               \
305         inline operator type () const                         \
306         {                                                     \
307           return ::func;                                      \
308         }                                                     \
309       } func = {};                                            \
310     }                                                         \
311     _GL_EXTERN_C int _gl_cxxalias_dummy
312 #else
313 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
314     _GL_EXTERN_C int _gl_cxxalias_dummy
315 #endif
316 
317 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
318    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
319    except that the C function func may have a slightly different declaration.
320    A cast is used to silence the "invalid conversion" error that would
321    otherwise occur.  */
322 #if defined __cplusplus && defined GNULIB_NAMESPACE
323 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
324     namespace GNULIB_NAMESPACE                          \
325     {                                                   \
326       static const struct _gl_ ## func ## _wrapper      \
327       {                                                 \
328         typedef rettype (*type) parameters;             \
329                                                         \
330         inline operator type () const                   \
331         {                                               \
332           return reinterpret_cast<type>(::func);        \
333         }                                               \
334       } func = {};                                      \
335     }                                                   \
336     _GL_EXTERN_C int _gl_cxxalias_dummy
337 #else
338 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
339     _GL_EXTERN_C int _gl_cxxalias_dummy
340 #endif
341 
342 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
343    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
344    except that the C function is picked among a set of overloaded functions,
345    namely the one with rettype2 and parameters2.  Two consecutive casts
346    are used to silence the "cannot find a match" and "invalid conversion"
347    errors that would otherwise occur.  */
348 #if defined __cplusplus && defined GNULIB_NAMESPACE
349   /* The outer cast must be a reinterpret_cast.
350      The inner cast: When the function is defined as a set of overloaded
351      functions, it works as a static_cast<>, choosing the designated variant.
352      When the function is defined as a single variant, it works as a
353      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
354 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
355     namespace GNULIB_NAMESPACE                                                \
356     {                                                                         \
357       static const struct _gl_ ## func ## _wrapper                            \
358       {                                                                       \
359         typedef rettype (*type) parameters;                                   \
360                                                                               \
361         inline operator type () const                                         \
362         {                                                                     \
363           return reinterpret_cast<type>((rettype2 (*) parameters2)(::func));  \
364         }                                                                     \
365       } func = {};                                                            \
366     }                                                                         \
367     _GL_EXTERN_C int _gl_cxxalias_dummy
368 #else
369 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
370     _GL_EXTERN_C int _gl_cxxalias_dummy
371 #endif
372 
373 /* _GL_CXXALIASWARN (func);
374    causes a warning to be emitted when ::func is used but not when
375    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
376    variants.  */
377 #if defined __cplusplus && defined GNULIB_NAMESPACE
378 # define _GL_CXXALIASWARN(func) \
379    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
380 # define _GL_CXXALIASWARN_1(func,namespace) \
381    _GL_CXXALIASWARN_2 (func, namespace)
382 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
383    we enable the warning only when not optimizing.  */
384 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
385 #  define _GL_CXXALIASWARN_2(func,namespace) \
386     _GL_WARN_ON_USE (func, \
387                      "The symbol ::" #func " refers to the system function. " \
388                      "Use " #namespace "::" #func " instead.")
389 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
390 #  define _GL_CXXALIASWARN_2(func,namespace) \
391      extern __typeof__ (func) func
392 # else
393 #  define _GL_CXXALIASWARN_2(func,namespace) \
394      _GL_EXTERN_C int _gl_cxxalias_dummy
395 # endif
396 #else
397 # define _GL_CXXALIASWARN(func) \
398     _GL_EXTERN_C int _gl_cxxalias_dummy
399 #endif
400 
401 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
402    causes a warning to be emitted when the given overloaded variant of ::func
403    is used but not when GNULIB_NAMESPACE::func is used.  */
404 #if defined __cplusplus && defined GNULIB_NAMESPACE
405 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
406    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
407                         GNULIB_NAMESPACE)
408 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
409    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
410 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
411    we enable the warning only when not optimizing.  */
412 # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
413 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
414     _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
415                          "The symbol ::" #func " refers to the system function. " \
416                          "Use " #namespace "::" #func " instead.")
417 # else
418 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
419      _GL_EXTERN_C int _gl_cxxalias_dummy
420 # endif
421 #else
422 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
423     _GL_EXTERN_C int _gl_cxxalias_dummy
424 #endif
425 
426 #endif /* _GL_CXXDEFS_H */
427 
428 /* The definition of _GL_ARG_NONNULL is copied here.  */
429 /* A C macro for declaring that specific arguments must not be NULL.
430    Copyright (C) 2009-2022 Free Software Foundation, Inc.
431 
432    This program is free software: you can redistribute it and/or modify it
433    under the terms of the GNU Lesser General Public License as published
434    by the Free Software Foundation; either version 2 of the License, or
435    (at your option) any later version.
436 
437    This program is distributed in the hope that it will be useful,
438    but WITHOUT ANY WARRANTY; without even the implied warranty of
439    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
440    Lesser General Public License for more details.
441 
442    You should have received a copy of the GNU Lesser General Public License
443    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
444 
445 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
446    that the values passed as arguments n, ..., m must be non-NULL pointers.
447    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
448 #ifndef _GL_ARG_NONNULL
449 # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
450 #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
451 # else
452 #  define _GL_ARG_NONNULL(params)
453 # endif
454 #endif
455 
456 /* The definition of _GL_WARN_ON_USE is copied here.  */
457 /* A C macro for emitting warnings if a function is used.
458    Copyright (C) 2010-2022 Free Software Foundation, Inc.
459 
460    This program is free software: you can redistribute it and/or modify it
461    under the terms of the GNU Lesser General Public License as published
462    by the Free Software Foundation; either version 2 of the License, or
463    (at your option) any later version.
464 
465    This program is distributed in the hope that it will be useful,
466    but WITHOUT ANY WARRANTY; without even the implied warranty of
467    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
468    Lesser General Public License for more details.
469 
470    You should have received a copy of the GNU Lesser General Public License
471    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
472 
473 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
474    for FUNCTION which will then trigger a compiler warning containing
475    the text of "literal string" anywhere that function is called, if
476    supported by the compiler.  If the compiler does not support this
477    feature, the macro expands to an unused extern declaration.
478 
479    _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
480    attribute used in _GL_WARN_ON_USE.  If the compiler does not support
481    this feature, it expands to empty.
482 
483    These macros are useful for marking a function as a potential
484    portability trap, with the intent that "literal string" include
485    instructions on the replacement function that should be used
486    instead.
487    _GL_WARN_ON_USE is for functions with 'extern' linkage.
488    _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
489    linkage.
490 
491    However, one of the reasons that a function is a portability trap is
492    if it has the wrong signature.  Declaring FUNCTION with a different
493    signature in C is a compilation error, so this macro must use the
494    same type as any existing declaration so that programs that avoid
495    the problematic FUNCTION do not fail to compile merely because they
496    included a header that poisoned the function.  But this implies that
497    _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
498    have a declaration.  Use of this macro implies that there must not
499    be any other macro hiding the declaration of FUNCTION; but
500    undefining FUNCTION first is part of the poisoning process anyway
501    (although for symbols that are provided only via a macro, the result
502    is a compilation error rather than a warning containing
503    "literal string").  Also note that in C++, it is only safe to use if
504    FUNCTION has no overloads.
505 
506    For an example, it is possible to poison 'getline' by:
507    - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
508      [getline]) in configure.ac, which potentially defines
509      HAVE_RAW_DECL_GETLINE
510    - adding this code to a header that wraps the system <stdio.h>:
511      #undef getline
512      #if HAVE_RAW_DECL_GETLINE
513      _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
514        "not universally present; use the gnulib module getline");
515      #endif
516 
517    It is not possible to directly poison global variables.  But it is
518    possible to write a wrapper accessor function, and poison that
519    (less common usage, like &environ, will cause a compilation error
520    rather than issue the nice warning, but the end result of informing
521    the developer about their portability problem is still achieved):
522      #if HAVE_RAW_DECL_ENVIRON
523      static char ***
524      rpl_environ (void) { return &environ; }
525      _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
526      # undef environ
527      # define environ (*rpl_environ ())
528      #endif
529    or better (avoiding contradictory use of 'static' and 'extern'):
530      #if HAVE_RAW_DECL_ENVIRON
531      static char ***
532      _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
533      rpl_environ (void) { return &environ; }
534      # undef environ
535      # define environ (*rpl_environ ())
536      #endif
537    */
538 #ifndef _GL_WARN_ON_USE
539 
540 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
541 /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
542 #  define _GL_WARN_ON_USE(function, message) \
543 _GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
544 #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
545   __attribute__ ((__warning__ (message)))
546 # elif __clang_major__ >= 4
547 /* Another compiler attribute is available in clang.  */
548 #  define _GL_WARN_ON_USE(function, message) \
549 _GL_WARN_EXTERN_C __typeof__ (function) function \
550   __attribute__ ((__diagnose_if__ (1, message, "warning")))
551 #  define _GL_WARN_ON_USE_ATTRIBUTE(message) \
552   __attribute__ ((__diagnose_if__ (1, message, "warning")))
553 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
554 /* Verify the existence of the function.  */
555 #  define _GL_WARN_ON_USE(function, message) \
556 _GL_WARN_EXTERN_C __typeof__ (function) function
557 #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
558 # else /* Unsupported.  */
559 #  define _GL_WARN_ON_USE(function, message) \
560 _GL_WARN_EXTERN_C int _gl_warn_on_use
561 #  define _GL_WARN_ON_USE_ATTRIBUTE(message)
562 # endif
563 #endif
564 
565 /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
566    is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
567    function is declared with the given prototype, consisting of return type,
568    parameters, and attributes.
569    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
570    not work in this case.  */
571 #ifndef _GL_WARN_ON_USE_CXX
572 # if !defined __cplusplus
573 #  define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
574      _GL_WARN_ON_USE (function, msg)
575 # else
576 #  if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
577 /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
578 #   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
579 extern rettype_gcc function parameters_and_attributes \
580   __attribute__ ((__warning__ (msg)))
581 #  elif __clang_major__ >= 4
582 /* Another compiler attribute is available in clang.  */
583 #   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
584 extern rettype_clang function parameters_and_attributes \
585   __attribute__ ((__diagnose_if__ (1, msg, "warning")))
586 #  elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
587 /* Verify the existence of the function.  */
588 #   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
589 extern rettype_gcc function parameters_and_attributes
590 #  else /* Unsupported.  */
591 #   define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
592 _GL_WARN_EXTERN_C int _gl_warn_on_use
593 #  endif
594 # endif
595 #endif
596 
597 /* _GL_WARN_EXTERN_C declaration;
598    performs the declaration with C linkage.  */
599 #ifndef _GL_WARN_EXTERN_C
600 # if defined __cplusplus
601 #  define _GL_WARN_EXTERN_C extern "C"
602 # else
603 #  define _GL_WARN_EXTERN_C extern
604 # endif
605 #endif
606 
607 
608 /* Declare overridden functions.  */
609 
610 #if 1
611 # if 0
612 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
613 #   undef closedir
614 #   define closedir rpl_closedir
615 #   define GNULIB_defined_closedir 1
616 #  endif
617 _GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
618 _GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
619 # else
620 #  if !1
621 _GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
622 #  endif
623 _GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
624 # endif
625 _GL_CXXALIASWARN (closedir);
626 #elif defined GNULIB_POSIXCHECK
627 # undef closedir
628 # if HAVE_RAW_DECL_CLOSEDIR
629 _GL_WARN_ON_USE (closedir, "closedir is not portable - "
630                  "use gnulib module closedir for portability");
631 # endif
632 #endif
633 
634 #if 1
635 # if 0
636 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
637 #   undef opendir
638 #   define opendir rpl_opendir
639 #   define GNULIB_defined_opendir 1
640 #  endif
641 _GL_FUNCDECL_RPL (opendir, DIR *,
642                   (const char *dir_name)
643                   _GL_ARG_NONNULL ((1))
644                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
645 _GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
646 # else
647 #  if !1 || __GNUC__ >= 11
648 _GL_FUNCDECL_SYS (opendir, DIR *,
649                   (const char *dir_name)
650                   _GL_ARG_NONNULL ((1))
651                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
652 #  endif
653 _GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
654 # endif
655 _GL_CXXALIASWARN (opendir);
656 #else
657 # if 1 && __GNUC__ >= 11 && !defined opendir
658 /* For -Wmismatched-dealloc: Associate opendir with closedir or
659    rpl_closedir.  */
660 _GL_FUNCDECL_SYS (opendir, DIR *,
661                   (const char *dir_name)
662                   _GL_ARG_NONNULL ((1))
663                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
664 # endif
665 # if defined GNULIB_POSIXCHECK
666 #  undef opendir
667 #  if HAVE_RAW_DECL_OPENDIR
668 _GL_WARN_ON_USE (opendir, "opendir is not portable - "
669                  "use gnulib module opendir for portability");
670 #  endif
671 # endif
672 #endif
673 
674 #if 1
675 # if !1
676 _GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
677 # endif
678 _GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
679 _GL_CXXALIASWARN (readdir);
680 #elif defined GNULIB_POSIXCHECK
681 # undef readdir
682 # if HAVE_RAW_DECL_READDIR
683 _GL_WARN_ON_USE (readdir, "readdir is not portable - "
684                  "use gnulib module readdir for portability");
685 # endif
686 #endif
687 
688 #if 1
689 # if !1
690 _GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
691 # endif
692 _GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
693 _GL_CXXALIASWARN (rewinddir);
694 #elif defined GNULIB_POSIXCHECK
695 # undef rewinddir
696 # if HAVE_RAW_DECL_REWINDDIR
697 _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
698                  "use gnulib module rewinddir for portability");
699 # endif
700 #endif
701 
702 #if 1
703 /* Return the file descriptor associated with the given directory stream,
704    or -1 if none exists.  */
705 # if 0
706 /* On kLIBC, dirfd() is a macro that does not work.  Undefine it.  */
707 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE) || defined dirfd
708 #   undef dirfd
709 #   define dirfd rpl_dirfd
710 #  endif
711 _GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
712 _GL_CXXALIAS_RPL (dirfd, int, (DIR *));
713 
714 #  ifdef __KLIBC__
715 /* Gnulib internal hooks needed to maintain the dirfd metadata.  */
716 _GL_EXTERN_C int _gl_register_dirp_fd (int fd, DIR *dirp)
717      _GL_ARG_NONNULL ((2));
718 _GL_EXTERN_C void _gl_unregister_dirp_fd (int fd);
719 #  endif
720 # else
721 #  if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
722     /* dirfd is defined as a macro and not as a function.
723        Turn it into a function and get rid of the macro.  */
724 static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
725 #   undef dirfd
726 #  endif
727 #  if !(1 || defined dirfd)
728 _GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
729 #  endif
730 _GL_CXXALIAS_SYS (dirfd, int, (DIR *));
731 # endif
732 _GL_CXXALIASWARN (dirfd);
733 #elif defined GNULIB_POSIXCHECK
734 # undef dirfd
735 # if HAVE_RAW_DECL_DIRFD
736 _GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
737                  "use gnulib module dirfd for portability");
738 # endif
739 #endif
740 
741 #if 1
742 /* Open a directory stream visiting the given directory file
743    descriptor.  Return NULL and set errno if fd is not visiting a
744    directory.  On success, this function consumes fd (it will be
745    implicitly closed either by this function or by a subsequent
746    closedir).  */
747 # if 1
748 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
749 #   undef fdopendir
750 #   define fdopendir rpl_fdopendir
751 #  endif
752 _GL_FUNCDECL_RPL (fdopendir, DIR *,
753                   (int fd)
754                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
755 _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
756 # else
757 #  if !1 || !1 || __GNUC__ >= 11
758 _GL_FUNCDECL_SYS (fdopendir, DIR *,
759                   (int fd)
760                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
761 #  endif
762 _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
763 # endif
764 _GL_CXXALIASWARN (fdopendir);
765 #else
766 # if 1 && __GNUC__ >= 11 && !defined fdopendir
767 /* For -Wmismatched-dealloc: Associate fdopendir with closedir or
768    rpl_closedir.  */
769 _GL_FUNCDECL_SYS (fdopendir, DIR *,
770                   (int fd)
771                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
772 # endif
773 # if defined GNULIB_POSIXCHECK
774 #  undef fdopendir
775 #  if HAVE_RAW_DECL_FDOPENDIR
776 _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
777                  "use gnulib module fdopendir for portability");
778 #  endif
779 # endif
780 #endif
781 
782 #if 0
783 /* Scan the directory DIR, calling FILTER on each directory entry.
784    Entries for which FILTER returns nonzero are individually malloc'd,
785    sorted using qsort with CMP, and collected in a malloc'd array in
786    *NAMELIST.  Returns the number of entries selected, or -1 on error.  */
787 # if !1
788 _GL_FUNCDECL_SYS (scandir, int,
789                   (const char *dir, struct dirent ***namelist,
790                    int (*filter) (const struct dirent *),
791                    int (*cmp) (const struct dirent **, const struct dirent **))
792                   _GL_ARG_NONNULL ((1, 2, 4)));
793 # endif
794 /* Need to cast, because on glibc systems, the fourth parameter is
795                         int (*cmp) (const void *, const void *).  */
796 _GL_CXXALIAS_SYS_CAST (scandir, int,
797                        (const char *dir, struct dirent ***namelist,
798                         int (*filter) (const struct dirent *),
799                         int (*cmp) (const struct dirent **, const struct dirent **)));
800 _GL_CXXALIASWARN (scandir);
801 #elif defined GNULIB_POSIXCHECK
802 # undef scandir
803 # if HAVE_RAW_DECL_SCANDIR
804 _GL_WARN_ON_USE (scandir, "scandir is unportable - "
805                  "use gnulib module scandir for portability");
806 # endif
807 #endif
808 
809 #if 0
810 /* Compare two 'struct dirent' entries alphabetically.  */
811 # if !1
812 _GL_FUNCDECL_SYS (alphasort, int,
813                   (const struct dirent **, const struct dirent **)
814                   _GL_ATTRIBUTE_PURE
815                   _GL_ARG_NONNULL ((1, 2)));
816 # endif
817 /* Need to cast, because on glibc systems, the parameters are
818                        (const void *, const void *).  */
819 _GL_CXXALIAS_SYS_CAST (alphasort, int,
820                        (const struct dirent **, const struct dirent **));
821 _GL_CXXALIASWARN (alphasort);
822 #elif defined GNULIB_POSIXCHECK
823 # undef alphasort
824 # if HAVE_RAW_DECL_ALPHASORT
825 _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
826                  "use gnulib module alphasort for portability");
827 # endif
828 #endif
829 
830 
831 #endif /* _GL_DIRENT_H */
832 #endif /* _GL_DIRENT_H */
833