VirtualBox

source: kBuild/vendor/grep/3.7/lib/dirent.in.h@ 3576

Last change on this file since 3576 was 3529, checked in by bird, 3 years ago

Imported grep 3.7 from grep-3.7.tar.gz (sha256: c22b0cf2d4f6bbe599c902387e8058990e1eee99aef333a203829e5fd3dbb342), applying minimal auto-props.

  • Property svn:eol-style set to native
File size: 10.0 KB
Line 
1/* A GNU-like <dirent.h>.
2 Copyright (C) 2006-2021 Free Software Foundation, Inc.
3
4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2.1 of the
7 License, or (at your option) any later version.
8
9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17#ifndef _@GUARD_PREFIX@_DIRENT_H
18
19#if __GNUC__ >= 3
20@PRAGMA_SYSTEM_HEADER@
21#endif
22@PRAGMA_COLUMNS@
23
24/* The include_next requires a split double-inclusion guard. */
25#if @HAVE_DIRENT_H@
26# @INCLUDE_NEXT@ @NEXT_DIRENT_H@
27#endif
28
29#ifndef _@GUARD_PREFIX@_DIRENT_H
30#define _@GUARD_PREFIX@_DIRENT_H
31
32/* Get ino_t. Needed on some systems, including glibc 2.8. */
33#include <sys/types.h>
34
35#if !@HAVE_DIRENT_H@
36/* Define types DIR and 'struct dirent'. */
37# if !GNULIB_defined_struct_dirent
38struct dirent
39{
40 char d_type;
41 char d_name[1];
42};
43/* Possible values for 'd_type'. */
44# define DT_UNKNOWN 0
45# define DT_FIFO 1 /* FIFO */
46# define DT_CHR 2 /* character device */
47# define DT_DIR 4 /* directory */
48# define DT_BLK 6 /* block device */
49# define DT_REG 8 /* regular file */
50# define DT_LNK 10 /* symbolic link */
51# define DT_SOCK 12 /* socket */
52# define DT_WHT 14 /* whiteout */
53typedef struct gl_directory DIR;
54# define GNULIB_defined_struct_dirent 1
55# endif
56#endif
57
58/* The __attribute__ feature is available in gcc versions 2.5 and later.
59 The attribute __pure__ was added in gcc 2.96. */
60#ifndef _GL_ATTRIBUTE_PURE
61# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) || defined __clang__
62# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
63# else
64# define _GL_ATTRIBUTE_PURE /* empty */
65# endif
66#endif
67
68/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
69
70/* The definition of _GL_ARG_NONNULL is copied here. */
71
72/* The definition of _GL_WARN_ON_USE is copied here. */
73
74
75/* Declare overridden functions. */
76
77#if @GNULIB_CLOSEDIR@
78# if @REPLACE_CLOSEDIR@
79# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
80# undef closedir
81# define closedir rpl_closedir
82# define GNULIB_defined_closedir 1
83# endif
84_GL_FUNCDECL_RPL (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
85_GL_CXXALIAS_RPL (closedir, int, (DIR *dirp));
86# else
87# if !@HAVE_CLOSEDIR@
88_GL_FUNCDECL_SYS (closedir, int, (DIR *dirp) _GL_ARG_NONNULL ((1)));
89# endif
90_GL_CXXALIAS_SYS (closedir, int, (DIR *dirp));
91# endif
92_GL_CXXALIASWARN (closedir);
93#elif defined GNULIB_POSIXCHECK
94# undef closedir
95# if HAVE_RAW_DECL_CLOSEDIR
96_GL_WARN_ON_USE (closedir, "closedir is not portable - "
97 "use gnulib module closedir for portability");
98# endif
99#endif
100
101#if @GNULIB_OPENDIR@
102# if @REPLACE_OPENDIR@
103# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
104# undef opendir
105# define opendir rpl_opendir
106# define GNULIB_defined_opendir 1
107# endif
108_GL_FUNCDECL_RPL (opendir, DIR *,
109 (const char *dir_name)
110 _GL_ARG_NONNULL ((1))
111 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
112_GL_CXXALIAS_RPL (opendir, DIR *, (const char *dir_name));
113# else
114# if !@HAVE_OPENDIR@ || __GNUC__ >= 11
115_GL_FUNCDECL_SYS (opendir, DIR *,
116 (const char *dir_name)
117 _GL_ARG_NONNULL ((1))
118 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
119# endif
120_GL_CXXALIAS_SYS (opendir, DIR *, (const char *dir_name));
121# endif
122_GL_CXXALIASWARN (opendir);
123#else
124# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined opendir
125/* For -Wmismatched-dealloc: Associate opendir with closedir or
126 rpl_closedir. */
127_GL_FUNCDECL_SYS (opendir, DIR *,
128 (const char *dir_name)
129 _GL_ARG_NONNULL ((1))
130 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
131# endif
132# if defined GNULIB_POSIXCHECK
133# undef opendir
134# if HAVE_RAW_DECL_OPENDIR
135_GL_WARN_ON_USE (opendir, "opendir is not portable - "
136 "use gnulib module opendir for portability");
137# endif
138# endif
139#endif
140
141#if @GNULIB_READDIR@
142# if !@HAVE_READDIR@
143_GL_FUNCDECL_SYS (readdir, struct dirent *, (DIR *dirp) _GL_ARG_NONNULL ((1)));
144# endif
145_GL_CXXALIAS_SYS (readdir, struct dirent *, (DIR *dirp));
146_GL_CXXALIASWARN (readdir);
147#elif defined GNULIB_POSIXCHECK
148# undef readdir
149# if HAVE_RAW_DECL_READDIR
150_GL_WARN_ON_USE (readdir, "readdir is not portable - "
151 "use gnulib module readdir for portability");
152# endif
153#endif
154
155#if @GNULIB_REWINDDIR@
156# if !@HAVE_REWINDDIR@
157_GL_FUNCDECL_SYS (rewinddir, void, (DIR *dirp) _GL_ARG_NONNULL ((1)));
158# endif
159_GL_CXXALIAS_SYS (rewinddir, void, (DIR *dirp));
160_GL_CXXALIASWARN (rewinddir);
161#elif defined GNULIB_POSIXCHECK
162# undef rewinddir
163# if HAVE_RAW_DECL_REWINDDIR
164_GL_WARN_ON_USE (rewinddir, "rewinddir is not portable - "
165 "use gnulib module rewinddir for portability");
166# endif
167#endif
168
169#if @GNULIB_DIRFD@
170/* Return the file descriptor associated with the given directory stream,
171 or -1 if none exists. */
172# if @REPLACE_DIRFD@
173/* On kLIBC, dirfd() is a macro that does not work. Undefine it. */
174# if !(defined __cplusplus && defined GNULIB_NAMESPACE) || defined dirfd
175# undef dirfd
176# define dirfd rpl_dirfd
177# endif
178_GL_FUNCDECL_RPL (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
179_GL_CXXALIAS_RPL (dirfd, int, (DIR *));
180
181# ifdef __KLIBC__
182/* Gnulib internal hooks needed to maintain the dirfd metadata. */
183_GL_EXTERN_C int _gl_register_dirp_fd (int fd, DIR *dirp)
184 _GL_ARG_NONNULL ((2));
185_GL_EXTERN_C void _gl_unregister_dirp_fd (int fd);
186# endif
187# else
188# if defined __cplusplus && defined GNULIB_NAMESPACE && defined dirfd
189 /* dirfd is defined as a macro and not as a function.
190 Turn it into a function and get rid of the macro. */
191static inline int (dirfd) (DIR *dp) { return dirfd (dp); }
192# undef dirfd
193# endif
194# if !(@HAVE_DECL_DIRFD@ || defined dirfd)
195_GL_FUNCDECL_SYS (dirfd, int, (DIR *) _GL_ARG_NONNULL ((1)));
196# endif
197_GL_CXXALIAS_SYS (dirfd, int, (DIR *));
198# endif
199_GL_CXXALIASWARN (dirfd);
200#elif defined GNULIB_POSIXCHECK
201# undef dirfd
202# if HAVE_RAW_DECL_DIRFD
203_GL_WARN_ON_USE (dirfd, "dirfd is unportable - "
204 "use gnulib module dirfd for portability");
205# endif
206#endif
207
208#if @GNULIB_FDOPENDIR@
209/* Open a directory stream visiting the given directory file
210 descriptor. Return NULL and set errno if fd is not visiting a
211 directory. On success, this function consumes fd (it will be
212 implicitly closed either by this function or by a subsequent
213 closedir). */
214# if @REPLACE_FDOPENDIR@
215# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
216# undef fdopendir
217# define fdopendir rpl_fdopendir
218# endif
219_GL_FUNCDECL_RPL (fdopendir, DIR *,
220 (int fd)
221 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
222_GL_CXXALIAS_RPL (fdopendir, DIR *, (int fd));
223# else
224# if !@HAVE_FDOPENDIR@ || !@HAVE_DECL_FDOPENDIR@ || __GNUC__ >= 11
225_GL_FUNCDECL_SYS (fdopendir, DIR *,
226 (int fd)
227 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
228# endif
229_GL_CXXALIAS_SYS (fdopendir, DIR *, (int fd));
230# endif
231_GL_CXXALIASWARN (fdopendir);
232#else
233# if @GNULIB_CLOSEDIR@ && __GNUC__ >= 11 && !defined fdopendir
234/* For -Wmismatched-dealloc: Associate fdopendir with closedir or
235 rpl_closedir. */
236_GL_FUNCDECL_SYS (fdopendir, DIR *,
237 (int fd)
238 _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC (closedir, 1));
239# endif
240# if defined GNULIB_POSIXCHECK
241# undef fdopendir
242# if HAVE_RAW_DECL_FDOPENDIR
243_GL_WARN_ON_USE (fdopendir, "fdopendir is unportable - "
244 "use gnulib module fdopendir for portability");
245# endif
246# endif
247#endif
248
249#if @GNULIB_SCANDIR@
250/* Scan the directory DIR, calling FILTER on each directory entry.
251 Entries for which FILTER returns nonzero are individually malloc'd,
252 sorted using qsort with CMP, and collected in a malloc'd array in
253 *NAMELIST. Returns the number of entries selected, or -1 on error. */
254# if !@HAVE_SCANDIR@
255_GL_FUNCDECL_SYS (scandir, int,
256 (const char *dir, struct dirent ***namelist,
257 int (*filter) (const struct dirent *),
258 int (*cmp) (const struct dirent **, const struct dirent **))
259 _GL_ARG_NONNULL ((1, 2, 4)));
260# endif
261/* Need to cast, because on glibc systems, the fourth parameter is
262 int (*cmp) (const void *, const void *). */
263_GL_CXXALIAS_SYS_CAST (scandir, int,
264 (const char *dir, struct dirent ***namelist,
265 int (*filter) (const struct dirent *),
266 int (*cmp) (const struct dirent **, const struct dirent **)));
267_GL_CXXALIASWARN (scandir);
268#elif defined GNULIB_POSIXCHECK
269# undef scandir
270# if HAVE_RAW_DECL_SCANDIR
271_GL_WARN_ON_USE (scandir, "scandir is unportable - "
272 "use gnulib module scandir for portability");
273# endif
274#endif
275
276#if @GNULIB_ALPHASORT@
277/* Compare two 'struct dirent' entries alphabetically. */
278# if !@HAVE_ALPHASORT@
279_GL_FUNCDECL_SYS (alphasort, int,
280 (const struct dirent **, const struct dirent **)
281 _GL_ATTRIBUTE_PURE
282 _GL_ARG_NONNULL ((1, 2)));
283# endif
284/* Need to cast, because on glibc systems, the parameters are
285 (const void *, const void *). */
286_GL_CXXALIAS_SYS_CAST (alphasort, int,
287 (const struct dirent **, const struct dirent **));
288_GL_CXXALIASWARN (alphasort);
289#elif defined GNULIB_POSIXCHECK
290# undef alphasort
291# if HAVE_RAW_DECL_ALPHASORT
292_GL_WARN_ON_USE (alphasort, "alphasort is unportable - "
293 "use gnulib module alphasort for portability");
294# endif
295#endif
296
297
298#endif /* _@GUARD_PREFIX@_DIRENT_H */
299#endif /* _@GUARD_PREFIX@_DIRENT_H */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette