xref: /titanic_50/usr/src/lib/libast/common/features/dirent (revision 356f72340a69936724c69f2f87fffa6f5887f885)
1set	prototyped
2
3set	nodefine
4lib	stat64 -D_LARGEFILE64_SOURCE
5typ	off64_t -D_LARGEFILE64_SOURCE
6set	define
7
8lib	opendir
9hdr	dirent,ndir
10sys	dir
11nxt	dirent
12
13tst	botch_d_ino_dirent64 -D_LARGEFILE64_SOURCE note{ dirent64.d_ino vs. readdir64 mismatch }end compile{
14	#if !__arm__
15	)
16	#endif
17	#include <dirent.h>
18	int
19	main()
20	{
21		struct dirent64	ent;
22		char		aha[5-((int)sizeof(ent.d_ino))];
23		return sizeof(aha);
24	}
25}end
26
27if ( ! _lib_opendir ) {
28	/*
29	 * <dirent.h> for systems with no opendir()
30	 */
31
32	#ifndef _DIRENT_H
33	#define _DIRENT_H
34
35	typedef struct
36	{
37		int		dd_fd;		/* file descriptor		*/
38	#ifdef _DIR_PRIVATE_
39		_DIR_PRIVATE_
40	#endif
41	} DIR;
42
43	struct dirent
44	{
45		long		d_fileno;	/* entry serial number		*/
46		int		d_reclen;	/* entry length			*/
47		int		d_namlen;	/* entry name length		*/
48		char		d_name[1];	/* entry name			*/
49	};
50
51	#ifndef _DIR_PRIVATE_
52
53	#ifdef	rewinddir
54	#undef	rewinddir
55	#define rewinddir(p)	seekdir(p,0L)
56	#endif
57
58	extern DIR*		opendir(const char*);
59	extern void		closedir(DIR*);
60	extern struct dirent*	readdir(DIR*);
61	extern void		seekdir(DIR*, long);
62	extern long		telldir(DIR*);
63
64	#endif
65
66	#endif
67}
68elif ( _nxt_dirent && _lib_stat64 && _typ_off64_t && _botch_d_ino_dirent64 ) pass{
69cat <<!
70	/*
71	 * <dirent.h> for [fl]stat64 and off64_t with sizeof(ino64_t)==4
72	 */
73
74	#ifndef _AST_STD_H
75
76	#include $_nxt_dirent	/* the native <dirent.h> */
77
78	#else
79
80	#ifndef _DIR64_H
81	#define _DIR64_H
82
83	#include <ast_std.h>
84
85	#if _typ_off64_t
86	#undef	off_t
87	#endif
88
89	#undef	__ino64_t
90	#define __ino64_t	int64_t
91
92	#include $_nxt_dirent	/* the native <dirent.h> */
93
94	#undef	__ino64_t
95	#define __ino64_t	__ino64_t
96
97	#if _typ_off64_t
98	#define	off_t		off64_t
99	#endif
100
101	#if _lib_readdir64 && _typ_struct_dirent64
102	#ifndef	dirent
103	#define dirent		dirent64
104	#endif
105	#ifndef	readdir
106	#define readdir		readdir64
107	#endif
108	#endif
109
110	#endif
111
112	#endif
113!
114}end
115elif ( _nxt_dirent && _lib_stat64 && _typ_off64_t ) pass{
116cat <<!
117	/*
118	 * <dirent.h> for [fl]stat64 and off64_t
119	 */
120
121	#ifndef _AST_STD_H
122
123	#include $_nxt_dirent	/* the native <dirent.h> */
124
125	#else
126
127	#ifndef _DIR64_H
128	#define _DIR64_H
129
130	#include <ast_std.h>
131
132	#if _typ_off64_t
133	#undef	off_t
134	#endif
135
136	#include $_nxt_dirent	/* the native <dirent.h> */
137
138	#if _typ_off64_t
139	#define	off_t		off64_t
140	#endif
141
142	#if _lib_readdir64 && _typ_struct_dirent64
143	#ifndef	dirent
144	#define dirent		dirent64
145	#endif
146	#ifndef	readdir
147	#define readdir		readdir64
148	#endif
149	#endif
150
151	#endif
152
153	#endif
154!
155}end
156elif ( _nxt_dirent && _hdr_dirent ) pass{
157cat <<!
158	/*
159	 * <dirent.h> for systems with ok <dirent.h>
160	 */
161
162	#ifndef _DIRENT_H
163
164	#include $_nxt_dirent	/* the native <dirent.h> */
165
166	#ifndef _DIRENT_H
167	#define _DIRENT_H
168	#endif
169
170	#endif
171!
172}end
173elif ( _hdr_ndir ) {
174	/*
175	 * <dirent.h> for systems with opendir() and <ndir.h>
176	 */
177
178	#ifndef _DIRENT_H
179	#define _DIRENT_H
180
181	#if defined(__STDPP__directive) && defined(__STDPP__hide)
182	__STDPP__directive pragma pp:hide closedir opendir readdir seekdir telldir
183	#else
184	#define closedir	______closedir
185	#define opendir		______opendir
186	#define readdir		______readdir
187	#define seekdir		______seekdir
188	#define telldir		______telldir
189	#endif
190
191	#include <ndir.h>
192
193	#if defined(__STDPP__directive) && defined(__STDPP__hide)
194	__STDPP__directive pragma pp:nohide closedir opendir readdir seekdir telldir
195	#else
196	#undef	closedir
197	#undef	opendir
198	#undef	readdir
199	#undef	seekdir
200	#undef	telldir
201	#endif
202
203	#ifndef dirent
204	#define dirent	direct
205	#endif
206
207	#if !defined(d_fileno) && !defined(d_ino)
208	#define d_fileno	d_ino
209	#endif
210
211	#ifdef	rewinddir
212	#undef	rewinddir
213	#define rewinddir(p)	seekdir(p,0L)
214	#endif
215
216	extern DIR*		opendir(const char*);
217	extern void		closedir(DIR*);
218	extern struct dirent*	readdir(DIR*);
219	extern void		seekdir(DIR*, long);
220	extern long		telldir(DIR*);
221
222	#endif
223}
224elif ( _sys_dir ) {
225	/*
226	 * <dirent.h> for systems with opendir() and no <ndir.h>
227	 */
228
229	#ifndef _DIRENT_H
230	#define _DIRENT_H
231
232	#if defined(__STDPP__directive) && defined(__STDPP__hide)
233	__STDPP__directive pragma pp:hide closedir opendir readdir seekdir telldir
234	#else
235	#define closedir	______closedir
236	#define opendir		______opendir
237	#define readdir		______readdir
238	#define seekdir		______seekdir
239	#define telldir		______telldir
240	#endif
241
242	#include <sys/dir.h>
243
244	#if defined(__STDPP__directive) && defined(__STDPP__hide)
245	__STDPP__directive pragma pp:nohide closedir opendir readdir seekdir telldir
246	#else
247	#undef	closedir
248	#undef	opendir
249	#undef	readdir
250	#undef	seekdir
251	#undef	telldir
252	#endif
253
254	#ifndef dirent
255	#define dirent	direct
256	#endif
257
258	#if !defined(d_fileno) && !defined(d_ino)
259	#define d_fileno	d_ino
260	#endif
261
262	#ifdef	rewinddir
263	#undef	rewinddir
264	#define rewinddir(p)	seekdir(p,0L)
265	#endif
266
267	extern DIR*		opendir(const char*);
268	extern void		closedir(DIR*);
269	extern struct dirent*	readdir(DIR*);
270	extern void		seekdir(DIR*, long);
271	extern long		telldir(DIR*);
272
273	#endif
274}
275endif
276