1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A GNU-like <dirent.h>.
3    Copyright (C) 2006-2014 Free Software Foundation, Inc.
4 
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 of the License, or
8    (at your option) any later version.
9 
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.
14 
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
17 
18 #ifndef _GL_DIRENT_H
19 
20 #if __GNUC__ >= 3
21 #pragma GCC system_header
22 #endif
23 
24 
25 /* The include_next requires a split double-inclusion guard.  */
26 #if 1
27 # include_next <dirent.h>
28 #endif
29 
30 #ifndef _GL_DIRENT_H
31 #define _GL_DIRENT_H
32 
33 /* Get ino_t.  Needed on some systems, including glibc 2.8.  */
34 #include <sys/types.h>
35 
36 #if !1
37 /* Define types DIR and 'struct dirent'.  */
38 # if !GNULIB_defined_struct_dirent
39 struct dirent
40 {
41   char d_type;
42   char d_name[1];
43 };
44 /* Possible values for 'd_type'.  */
45 #  define DT_UNKNOWN 0
46 #  define DT_FIFO    1          /* FIFO */
47 #  define DT_CHR     2          /* character device */
48 #  define DT_DIR     4          /* directory */
49 #  define DT_BLK     6          /* block device */
50 #  define DT_REG     8          /* regular file */
51 #  define DT_LNK    10          /* symbolic link */
52 #  define DT_SOCK   12          /* socket */
53 #  define DT_WHT    14          /* whiteout */
54 typedef struct gl_directory DIR;
55 #  define GNULIB_defined_struct_dirent 1
56 # endif
57 #endif
58 
59 /* The __attribute__ feature is available in gcc versions 2.5 and later.
60    The attribute __pure__ was added in gcc 2.96.  */
61 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
62 # define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
63 #else
64 # define _GL_ATTRIBUTE_PURE /* empty */
65 #endif
66 
67 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
68 #ifndef _GL_CXXDEFS_H
69 #define _GL_CXXDEFS_H
70 
71 /* The three most frequent use cases of these macros are:
72 
73    * For providing a substitute for a function that is missing on some
74      platforms, but is declared and works fine on the platforms on which
75      it exists:
76 
77        #if @GNULIB_FOO@
78        # if !@HAVE_FOO@
79        _GL_FUNCDECL_SYS (foo, ...);
80        # endif
81        _GL_CXXALIAS_SYS (foo, ...);
82        _GL_CXXALIASWARN (foo);
83        #elif defined GNULIB_POSIXCHECK
84        ...
85        #endif
86 
87    * For providing a replacement for a function that exists on all platforms,
88      but is broken/insufficient and needs to be replaced on some platforms:
89 
90        #if @GNULIB_FOO@
91        # if @REPLACE_FOO@
92        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
93        #   undef foo
94        #   define foo rpl_foo
95        #  endif
96        _GL_FUNCDECL_RPL (foo, ...);
97        _GL_CXXALIAS_RPL (foo, ...);
98        # else
99        _GL_CXXALIAS_SYS (foo, ...);
100        # endif
101        _GL_CXXALIASWARN (foo);
102        #elif defined GNULIB_POSIXCHECK
103        ...
104        #endif
105 
106    * For providing a replacement for a function that exists on some platforms
107      but is broken/insufficient and needs to be replaced on some of them and
108      is additionally either missing or undeclared on some other platforms:
109 
110        #if @GNULIB_FOO@
111        # if @REPLACE_FOO@
112        #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
113        #   undef foo
114        #   define foo rpl_foo
115        #  endif
116        _GL_FUNCDECL_RPL (foo, ...);
117        _GL_CXXALIAS_RPL (foo, ...);
118        # else
119        #  if !@HAVE_FOO@   or   if !@HAVE_DECL_FOO@
120        _GL_FUNCDECL_SYS (foo, ...);
121        #  endif
122        _GL_CXXALIAS_SYS (foo, ...);
123        # endif
124        _GL_CXXALIASWARN (foo);
125        #elif defined GNULIB_POSIXCHECK
126        ...
127        #endif
128 */
129 
130 /* _GL_EXTERN_C declaration;
131    performs the declaration with C linkage.  */
132 #if defined __cplusplus
133 # define _GL_EXTERN_C extern "C"
134 #else
135 # define _GL_EXTERN_C extern
136 #endif
137 
138 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
139    declares a replacement function, named rpl_func, with the given prototype,
140    consisting of return type, parameters, and attributes.
141    Example:
142      _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
143                                   _GL_ARG_NONNULL ((1)));
144  */
145 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
146   _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
147 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
148   _GL_EXTERN_C rettype rpl_func parameters_and_attributes
149 
150 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
151    declares the system function, named func, with the given prototype,
152    consisting of return type, parameters, and attributes.
153    Example:
154      _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
155                                   _GL_ARG_NONNULL ((1)));
156  */
157 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
158   _GL_EXTERN_C rettype func parameters_and_attributes
159 
160 /* _GL_CXXALIAS_RPL (func, rettype, parameters);
161    declares a C++ alias called GNULIB_NAMESPACE::func
162    that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
163    Example:
164      _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
165  */
166 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
167   _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
168 #if defined __cplusplus && defined GNULIB_NAMESPACE
169 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
170     namespace GNULIB_NAMESPACE                                \
171     {                                                         \
172       rettype (*const func) parameters = ::rpl_func;          \
173     }                                                         \
174     _GL_EXTERN_C int _gl_cxxalias_dummy
175 #else
176 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
177     _GL_EXTERN_C int _gl_cxxalias_dummy
178 #endif
179 
180 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
181    is like  _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
182    except that the C function rpl_func may have a slightly different
183    declaration.  A cast is used to silence the "invalid conversion" error
184    that would otherwise occur.  */
185 #if defined __cplusplus && defined GNULIB_NAMESPACE
186 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
187     namespace GNULIB_NAMESPACE                                     \
188     {                                                              \
189       rettype (*const func) parameters =                           \
190         reinterpret_cast<rettype(*)parameters>(::rpl_func);        \
191     }                                                              \
192     _GL_EXTERN_C int _gl_cxxalias_dummy
193 #else
194 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
195     _GL_EXTERN_C int _gl_cxxalias_dummy
196 #endif
197 
198 /* _GL_CXXALIAS_SYS (func, rettype, parameters);
199    declares a C++ alias called GNULIB_NAMESPACE::func
200    that redirects to the system provided function func, if GNULIB_NAMESPACE
201    is defined.
202    Example:
203      _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
204  */
205 #if defined __cplusplus && defined GNULIB_NAMESPACE
206   /* If we were to write
207        rettype (*const func) parameters = ::func;
208      like above in _GL_CXXALIAS_RPL_1, the compiler could optimize calls
209      better (remove an indirection through a 'static' pointer variable),
210      but then the _GL_CXXALIASWARN macro below would cause a warning not only
211      for uses of ::func but also for uses of GNULIB_NAMESPACE::func.  */
212 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
213     namespace GNULIB_NAMESPACE                     \
214     {                                              \
215       static rettype (*func) parameters = ::func;  \
216     }                                              \
217     _GL_EXTERN_C int _gl_cxxalias_dummy
218 #else
219 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
220     _GL_EXTERN_C int _gl_cxxalias_dummy
221 #endif
222 
223 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
224    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
225    except that the C function func may have a slightly different declaration.
226    A cast is used to silence the "invalid conversion" error that would
227    otherwise occur.  */
228 #if defined __cplusplus && defined GNULIB_NAMESPACE
229 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
230     namespace GNULIB_NAMESPACE                          \
231     {                                                   \
232       static rettype (*func) parameters =               \
233         reinterpret_cast<rettype(*)parameters>(::func); \
234     }                                                   \
235     _GL_EXTERN_C int _gl_cxxalias_dummy
236 #else
237 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
238     _GL_EXTERN_C int _gl_cxxalias_dummy
239 #endif
240 
241 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
242    is like  _GL_CXXALIAS_SYS (func, rettype, parameters);
243    except that the C function is picked among a set of overloaded functions,
244    namely the one with rettype2 and parameters2.  Two consecutive casts
245    are used to silence the "cannot find a match" and "invalid conversion"
246    errors that would otherwise occur.  */
247 #if defined __cplusplus && defined GNULIB_NAMESPACE
248   /* The outer cast must be a reinterpret_cast.
249      The inner cast: When the function is defined as a set of overloaded
250      functions, it works as a static_cast<>, choosing the designated variant.
251      When the function is defined as a single variant, it works as a
252      reinterpret_cast<>. The parenthesized cast syntax works both ways.  */
253 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
254     namespace GNULIB_NAMESPACE                                                \
255     {                                                                         \
256       static rettype (*func) parameters =                                     \
257         reinterpret_cast<rettype(*)parameters>(                               \
258           (rettype2(*)parameters2)(::func));                                  \
259     }                                                                         \
260     _GL_EXTERN_C int _gl_cxxalias_dummy
261 #else
262 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
263     _GL_EXTERN_C int _gl_cxxalias_dummy
264 #endif
265 
266 /* _GL_CXXALIASWARN (func);
267    causes a warning to be emitted when ::func is used but not when
268    GNULIB_NAMESPACE::func is used.  func must be defined without overloaded
269    variants.  */
270 #if defined __cplusplus && defined GNULIB_NAMESPACE
271 # define _GL_CXXALIASWARN(func) \
272    _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
273 # define _GL_CXXALIASWARN_1(func,namespace) \
274    _GL_CXXALIASWARN_2 (func, namespace)
275 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
276    we enable the warning only when not optimizing.  */
277 # if !__OPTIMIZE__
278 #  define _GL_CXXALIASWARN_2(func,namespace) \
279     _GL_WARN_ON_USE (func, \
280                      "The symbol ::" #func " refers to the system function. " \
281                      "Use " #namespace "::" #func " instead.")
282 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
283 #  define _GL_CXXALIASWARN_2(func,namespace) \
284      extern __typeof__ (func) func
285 # else
286 #  define _GL_CXXALIASWARN_2(func,namespace) \
287      _GL_EXTERN_C int _gl_cxxalias_dummy
288 # endif
289 #else
290 # define _GL_CXXALIASWARN(func) \
291     _GL_EXTERN_C int _gl_cxxalias_dummy
292 #endif
293 
294 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
295    causes a warning to be emitted when the given overloaded variant of ::func
296    is used but not when GNULIB_NAMESPACE::func is used.  */
297 #if defined __cplusplus && defined GNULIB_NAMESPACE
298 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
299    _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
300                         GNULIB_NAMESPACE)
301 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
302    _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
303 /* To work around GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
304    we enable the warning only when not optimizing.  */
305 # if !__OPTIMIZE__
306 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
307     _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \
308                          "The symbol ::" #func " refers to the system function. " \
309                          "Use " #namespace "::" #func " instead.")
310 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
311 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
312      extern __typeof__ (func) func
313 # else
314 #  define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
315      _GL_EXTERN_C int _gl_cxxalias_dummy
316 # endif
317 #else
318 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
319     _GL_EXTERN_C int _gl_cxxalias_dummy
320 #endif
321 
322 #endif /* _GL_CXXDEFS_H */
323 
324 /* The definition of _GL_ARG_NONNULL is copied here.  */
325 /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
326    that the values passed as arguments n, ..., m must be non-NULL pointers.
327    n = 1 stands for the first argument, n = 2 for the second argument etc.  */
328 #ifndef _GL_ARG_NONNULL
329 # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3
330 #  define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
331 # else
332 #  define _GL_ARG_NONNULL(params)
333 # endif
334 #endif
335 
336 /* The definition of _GL_WARN_ON_USE is copied here.  */
337 #ifndef _GL_WARN_ON_USE
338 
339 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
340 /* A compiler attribute is available in gcc versions 4.3.0 and later.  */
341 #  define _GL_WARN_ON_USE(function, message) \
342 extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
343 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
344 /* Verify the existence of the function.  */
345 #  define _GL_WARN_ON_USE(function, message) \
346 extern __typeof__ (function) function
347 # else /* Unsupported.  */
348 #  define _GL_WARN_ON_USE(function, message) \
349 _GL_WARN_EXTERN_C int _gl_warn_on_use
350 # endif
351 #endif
352 
353 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string")
354    is like _GL_WARN_ON_USE (function, "string"), except that the function is
355    declared with the given prototype, consisting of return type, parameters,
356    and attributes.
357    This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
358    not work in this case.  */
359 #ifndef _GL_WARN_ON_USE_CXX
360 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
361 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
362 extern rettype function parameters_and_attributes \
363      __attribute__ ((__warning__ (msg)))
364 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
365 /* Verify the existence of the function.  */
366 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
367 extern rettype function parameters_and_attributes
368 # else /* Unsupported.  */
369 #  define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \
370 _GL_WARN_EXTERN_C int _gl_warn_on_use
371 # endif
372 #endif
373 
374 /* _GL_WARN_EXTERN_C declaration;
375    performs the declaration with C linkage.  */
376 #ifndef _GL_WARN_EXTERN_C
377 # if defined __cplusplus
378 #  define _GL_WARN_EXTERN_C extern "C"
379 # else
380 #  define _GL_WARN_EXTERN_C extern
381 # endif
382 #endif
383 
384 
385 /* Declare overridden functions.  */
386 
387 #if 1
388 # if 0
389 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
390 #   undef opendir
391 #   define opendir rpl_opendir
392 #  endif
393 _GL_FUNCDECL_RPL (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
394 _GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
395 # else
396 #  if !1
397 _GL_FUNCDECL_SYS (opendir, DIR *, (const char *dir_name) _GL_ARG_NONNULL ((1)));
398 #  endif
399 _GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
400 # endif
401 _GL_CXXALIASWARN (opendir);
402 #elif defined GNULIB_POSIXCHECK
403 # undef opendir
404 # if HAVE_RAW_DECL_OPENDIR
405 _GL_WARN_ON_USE (opendir, "opendir is not portable - "
406                  "use gnulib module opendir for portability");
407 # endif
408 #endif
409 
410 #if 1
411 # if !1
412 _GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
413 # endif
414 _GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
415 _GL_CXXALIASWARN (readdir);
416 #elif defined GNULIB_POSIXCHECK
417 # undef readdir
418 # if HAVE_RAW_DECL_READDIR
419 _GL_WARN_ON_USE (readdir, "readdir is not portable - "
420                  "use gnulib module readdir for portability");
421 # endif
422 #endif
423 
424 #if 0
425 # if !1
426 _GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
427 # endif
428 _GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
429 _GL_CXXALIASWARN (rewinddir);
430 #elif defined GNULIB_POSIXCHECK
431 # undef rewinddir
432 # if HAVE_RAW_DECL_REWINDDIR
433 _GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
434                  "use gnulib module rewinddir for portability");
435 # endif
436 #endif
437 
438 #if 1
439 # if 0
440 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
441 #   undef closedir
442 #   define closedir rpl_closedir
443 #  endif
444 _GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
445 _GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
446 # else
447 #  if !1
448 _GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
449 #  endif
450 _GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
451 # endif
452 _GL_CXXALIASWARN (closedir);
453 #elif defined GNULIB_POSIXCHECK
454 # undef closedir
455 # if HAVE_RAW_DECL_CLOSEDIR
456 _GL_WARN_ON_USE (closedir, "closedir is not portable - "
457                  "use gnulib module closedir for portability");
458 # endif
459 #endif
460 
461 #if 1
462 /* Return the file descriptor associated with the given directory stream,
463    or -1 if none exists.  */
464 # if 0
465 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
466 #   undef dirfd
467 #   define dirfd rpl_dirfd
468 #  endif
469 _GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
470 _GL_CXXALIAS_RPL (dirfd, int, (DIR *));
471 # else
472 #  if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
473     /* dirfd is defined as a macro and not as a function.
474        Turn it into a function and get rid of the macro.  */
475 static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
476 #   undef dirfd
477 #  endif
478 #  if !(1 || defined dirfd)
479 _GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
480 #  endif
481 _GL_CXXALIAS_SYS (dirfd, int, (DIR *));
482 # endif
483 _GL_CXXALIASWARN (dirfd);
484 #elif defined GNULIB_POSIXCHECK
485 # undef dirfd
486 # if HAVE_RAW_DECL_DIRFD
487 _GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
488                  "use gnulib module dirfd for portability");
489 # endif
490 #endif
491 
492 #if 1
493 /* Open a directory stream visiting the given directory file
494    descriptor.  Return NULL and set errno if fd is not visiting a
495    directory.  On success, this function consumes fd (it will be
496    implicitly closed either by this function or by a subsequent
497    closedir).  */
498 # if 0
499 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
500 #   undef fdopendir
501 #   define fdopendir rpl_fdopendir
502 #  endif
503 _GL_FUNCDECL_RPL (fdopendir, DIR *, (int fd));
504 _GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
505 # else
506 #  if !1 || !1
507 _GL_FUNCDECL_SYS (fdopendir, DIR *, (int fd));
508 #  endif
509 _GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
510 # endif
511 _GL_CXXALIASWARN (fdopendir);
512 #elif defined GNULIB_POSIXCHECK
513 # undef fdopendir
514 # if HAVE_RAW_DECL_FDOPENDIR
515 _GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
516                  "use gnulib module fdopendir for portability");
517 # endif
518 #endif
519 
520 #if 0
521 /* Scan the directory DIR, calling FILTER on each directory entry.
522    Entries for which FILTER returns nonzero are individually malloc'd,
523    sorted using qsort with CMP, and collected in a malloc'd array in
524    *NAMELIST.  Returns the number of entries selected, or -1 on error.  */
525 # if !1
526 _GL_FUNCDECL_SYS (scandir, int,
527                   (const char *dir, struct dirent ***namelist,
528                    int (*filter) (const struct dirent *),
529                    int (*cmp) (const struct dirent **, const struct dirent **))
530                   _GL_ARG_NONNULL ((1, 2, 4)));
531 # endif
532 /* Need to cast, because on glibc systems, the fourth parameter is
533                         int (*cmp) (const void *, const void *).  */
534 _GL_CXXALIAS_SYS_CAST (scandir, int,
535                        (const char *dir, struct dirent ***namelist,
536                         int (*filter) (const struct dirent *),
537                         int (*cmp) (const struct dirent **, const struct dirent **)));
538 _GL_CXXALIASWARN (scandir);
539 #elif defined GNULIB_POSIXCHECK
540 # undef scandir
541 # if HAVE_RAW_DECL_SCANDIR
542 _GL_WARN_ON_USE (scandir, "scandir is unportable - "
543                  "use gnulib module scandir for portability");
544 # endif
545 #endif
546 
547 #if 0
548 /* Compare two 'struct dirent' entries alphabetically.  */
549 # if !1
550 _GL_FUNCDECL_SYS (alphasort, int,
551                   (const struct dirent **, const struct dirent **)
552                   _GL_ATTRIBUTE_PURE
553                   _GL_ARG_NONNULL ((1, 2)));
554 # endif
555 /* Need to cast, because on glibc systems, the parameters are
556                        (const void *, const void *).  */
557 _GL_CXXALIAS_SYS_CAST (alphasort, int,
558                        (const struct dirent **, const struct dirent **));
559 _GL_CXXALIASWARN (alphasort);
560 #elif defined GNULIB_POSIXCHECK
561 # undef alphasort
562 # if HAVE_RAW_DECL_ALPHASORT
563 _GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
564                  "use gnulib module alphasort for portability");
565 # endif
566 #endif
567 
568 
569 #endif /* _GL_DIRENT_H */
570 #endif /* _GL_DIRENT_H */
571