1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *          Copyright (c) 1985-2013 AT&T Intellectual Property          *
5 *                      and is licensed under the                       *
6 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *               Glenn Fowler <glenn.s.fowler@gmail.com>                *
18 *                    David Korn <dgkorn@gmail.com>                     *
19 *                     Phong Vo <phongvo@gmail.com>                     *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 /*
24  * Glenn Fowler
25  * AT&T Research
26  *
27  * generate POSIX fcntl.h
28  */
29 
30 #include "FEATURE/standards"	/* iffe --include-first */
31 #include "FEATURE/lib"
32 
33 #include <sys/types.h>
34 
35 #define getdtablesize	______getdtablesize
36 #define getpagesize	______getpagesize
37 #define ioctl		______ioctl
38 
39 #if _typ_off64_t
40 #undef	off_t
41 #ifdef __STDC__
42 #define	off_t		off_t
43 #endif
44 #endif
45 
46 #if _hdr_fcntl
47 #include <fcntl.h>
48 #endif
49 #if _hdr_unistd
50 #include <unistd.h>
51 #endif
52 #if _sys_socket
53 #include <sys/socket.h>
54 #endif
55 
56 #include <sys/stat.h>
57 
58 #include "FEATURE/fs"
59 
60 #undef	getdtablesize
61 #undef	getpagesize
62 #undef	ioctl
63 
64 #include "FEATURE/tty"
65 
66 #if _typ_off64_t
67 #undef	off_t
68 #define	off_t	off64_t
69 #endif
70 
71 /*
72  * some bit macros may in fact be bits
73  */
74 
75 static unsigned int
hibit(unsigned int m)76 hibit(unsigned int m)
77 {
78 	unsigned int	b;
79 
80 	while (b = m & (m - 1))
81 		m = b;
82 	return m;
83 }
84 
85 #define ORIGIN_EXTENSION	"ast extension"
86 #define ORIGIN_FAILSAFE		"just in case _*_SOURCE circumvented"
87 #define ORIGIN_IGNORE		"not implemented"
88 
89 int
main(int argc,char ** argv)90 main(int argc, char** argv)
91 {
92 	unsigned int	f_local = 0;
93 	unsigned int	f_local_use;
94 	unsigned int	f_lck = 0;
95 	unsigned int	o_local = 2;
96 	unsigned int	o_local_min;
97 	unsigned int	o_local_use;
98 
99 	printf("#pragma prototyped\n");
100 	printf("\n");
101 	printf("#if _typ_off64_t\n");
102 	printf("#undef	off_t\n");
103 	printf("#ifdef __STDC__\n");
104 	printf("#define	off_t		off_t\n");
105 	printf("#endif\n");
106 	printf("#endif\n");
107 	printf("\n");
108 	printf("#include <ast_fs.h>\n");
109 	printf("\n");
110 	printf("#if _typ_off64_t\n");
111 	printf("#undef	off_t\n");
112 	printf("#ifdef __STDC__\n");
113 	printf("#define	off_t		off_t\n");
114 	printf("#endif\n");
115 	printf("#endif\n");
116 	printf("\n");
117 	printf("#include <fcntl.h>\n");
118 #if _hdr_mman
119 	printf("#include <mman.h>\n");
120 #else
121 #if _sys_mman
122 	printf("#include <sys/mman.h>\n");
123 #endif
124 #endif
125 	printf("\n");
126 #ifndef	FD_CLOEXEC
127 	printf("#define FD_CLOEXEC	1\n");
128 	printf("\n");
129 #endif
130 
131 #ifdef	F_DUPFD
132 	if (F_DUPFD > f_local) f_local = F_DUPFD;
133 #endif
134 #ifdef	F_DUPFD_CLOEXEC
135 	if (F_DUPFD_CLOEXEC > f_local) f_local = F_DUPFD_CLOEXEC;
136 #else
137 #define NEED_F	1
138 #endif
139 #ifdef	F_GETFD
140 	if (F_GETFD > f_local) f_local = F_GETFD;
141 #endif
142 #ifdef	F_GETFL
143 	if (F_GETFL > f_local) f_local = F_GETFL;
144 #endif
145 #ifdef	F_GETLK
146 	if (F_GETLK > f_local) f_local = F_GETLK;
147 #endif
148 #ifdef	F_RDLCK
149 	if (F_RDLCK > f_lck) f_lck = F_RDLCK;
150 #endif
151 #ifdef	F_SETFD
152 	if (F_SETFD > f_local) f_local = F_SETFD;
153 #endif
154 #ifdef	F_SETFL
155 	if (F_SETFL > f_local) f_local = F_SETFL;
156 #endif
157 #ifdef	F_SETLK
158 	if (F_SETLK > f_local) f_local = F_SETLK;
159 #endif
160 #ifdef	F_SETLKW
161 	if (F_SETLKW > f_local) f_local = F_SETLKW;
162 #endif
163 #ifdef	F_UNLCK
164 	if (F_UNLCK > f_lck) f_lck = F_UNLCK;
165 #endif
166 #ifdef	F_WRLCK
167 	if (F_WRLCK > f_lck) f_lck = F_WRLCK;
168 #endif
169 #ifdef	F_EXLCK
170 	if (F_EXLCK > f_local) f_local = F_EXLCK;
171 #endif
172 #ifdef	F_GETLEASE
173 	if (F_GETLEASE > f_local) f_local = F_GETLEASE;
174 #endif
175 #ifdef	F_GETLK64
176 	if (F_GETLK64 > f_local) f_local = F_GETLK64;
177 #endif
178 #ifdef	F_GETOWN
179 	if (F_GETOWN > f_local) f_local = F_GETOWN;
180 #endif
181 #ifdef	F_GETOWN_EX
182 	if (F_GETOWN_EX > f_local) f_local = F_GETOWN_EX;
183 #endif
184 #ifdef	F_GETSIG
185 	if (F_GETSIG > f_local) f_local = F_GETSIG;
186 #endif
187 #ifdef	F_NOTIFY
188 	if (F_NOTIFY > f_local) f_local = F_NOTIFY;
189 #endif
190 #ifdef	F_SETLEASE
191 	if (F_SETLEASE > f_local) f_local = F_SETLEASE;
192 #endif
193 #ifdef	F_SETLK64
194 	if (F_SETLK64 > f_local) f_local = F_SETLK64;
195 #endif
196 #ifdef	F_SETLKW64
197 	if (F_SETLKW64 > f_local) f_local = F_SETLKW64;
198 #endif
199 #ifdef	F_SETOWN
200 	if (F_SETOWN > f_local) f_local = F_SETOWN;
201 #endif
202 #ifdef	F_SETOWN_EX
203 	if (F_SETOWN_EX > f_local) f_local = F_SETOWN_EX;
204 #endif
205 #ifdef	F_SETSIG
206 	if (F_SETSIG > f_local) f_local = F_SETSIG;
207 #endif
208 #ifdef	F_SHLCK
209 	if (F_SHLCK > f_local) f_local = F_SHLCK;
210 #endif
211 #ifdef	F_SHARE
212 	if (F_SHARE > f_local) f_local = F_SHARE;
213 #endif
214 #ifdef	F_UNSHARE
215 	if (F_UNSHARE > f_local) f_local = F_UNSHARE;
216 #endif
217 #ifdef	F_BADFD /* Create Poison FD */
218 	if (F_BADFD > f_local) f_local = F_BADFD;
219 #endif
220 
221 #if	NEED_F
222 #if	_lib_fcntl
223 	printf("#define _lib_fcntl	1\n");
224 #endif
225 
226 	/*
227 	 * pick a range for ast F_* local extensions that has a chance
228 	 * of remaining constant over time
229 	 */
230 
231 	if (f_local < 30000)
232 		f_local = 30000;
233 	else if (f_local < 1000000)
234 		f_local = 1000000;
235 	else
236 		f_local++;
237 #ifndef F_DUPFD_CLOEXEC
238 	f_local_use = f_local + 0;
239 	printf("#define F_DUPFD_CLOEXEC	(%d)	/* %s */\n", f_local, ORIGIN_EXTENSION);
240 #endif
241 	printf("#define _ast_F_LOCAL	%d	/* %s up to %d */\n", f_local, ORIGIN_EXTENSION, f_local_use);
242 #endif
243 #ifdef F_DUPFD_CLOEXEC
244 	printf("#ifndef F_DUPFD_CLOEXEC\n");
245 	printf("#define F_DUPFD_CLOEXEC	(%d)	/* %s */\n", (int)F_DUPFD_CLOEXEC, ORIGIN_FAILSAFE);
246 	printf("#endif\n");
247 #endif
248 	printf("\n");
249 
250 #ifdef	O_APPEND
251 	if (O_APPEND > o_local) o_local = O_APPEND;
252 #endif
253 #ifdef	O_CREAT
254 	if (O_CREAT > o_local) o_local = O_CREAT;
255 #endif
256 #ifdef	O_EXCL
257 	if (O_EXCL > o_local) o_local = O_EXCL;
258 #endif
259 #ifdef	O_NOCTTY
260 	if (O_NOCTTY > o_local) o_local = O_NOCTTY;
261 #endif
262 #ifdef	O_NONBLOCK
263 	if (O_NONBLOCK > o_local) o_local = O_NONBLOCK;
264 #endif
265 #ifdef	O_TRUNC
266 	if (O_TRUNC > o_local) o_local = O_TRUNC;
267 #endif
268 #ifdef O_BLKSEEK
269 	if (O_BLKSEEK > o_local) o_local = O_BLKSEEK;
270 #endif
271 #ifdef O_LARGEFILE
272 	if (O_LARGEFILE > o_local) o_local = O_LARGEFILE;
273 #endif
274 #ifdef O_LARGEFILE128
275 	if (O_LARGEFILE128 > o_local) o_local = O_LARGEFILE128;
276 #endif
277 #ifdef O_NOATIME
278 	if (O_NOATIME > o_local) o_local = O_NOATIME;
279 #endif
280 #ifdef O_NOFOLLOW
281 	if (O_NOFOLLOW > o_local) o_local = O_NOFOLLOW;
282 #endif
283 #ifdef O_NOLINKS
284 	if (O_NOLINKS > o_local) o_local = O_NOLINKS;
285 #endif
286 #ifdef O_PRIV
287 	if (O_PRIV > o_local) o_local = O_PRIV;
288 #endif
289 #ifdef O_DSYNC
290 	if (O_DSYNC > o_local) o_local = O_DSYNC;
291 #endif
292 #ifdef O_RSYNC
293 	if (O_RSYNC > o_local) o_local = O_RSYNC;
294 #endif
295 #ifdef O_SYNC
296 	if (O_SYNC > o_local) o_local = O_SYNC;
297 #endif
298 #ifdef O_TEMPORARY
299 	if (O_TEMPORARY > o_local) o_local = O_TEMPORARY;
300 #endif
301 #ifdef O_TMPFILE
302 	if (O_TMPFILE > o_local) o_local = O_TMPFILE;
303 #endif
304 #ifdef O_XATTR
305 	if (O_XATTR > o_local) o_local = O_XATTR;
306 #endif
307 #ifdef O_DIRECT
308 	if (O_DIRECT > o_local) o_local = O_DIRECT;
309 #endif
310 #ifndef O_DIRECTORY
311 #ifdef	O_OPENDIR
312 #define O_DIRECTORY		O_OPENDIR
313 #define O_DIRECTORY_origin	"O_OPENDIR"
314 #endif
315 #else
316 	if (O_DIRECTORY > o_local) o_local = O_DIRECTORY;
317 #endif
318 #ifdef O_OPENDIR
319 	if (O_OPENDIR > o_local) o_local = O_OPENDIR;
320 #endif
321 #ifndef O_SEARCH
322 #ifdef	O_PATH
323 #define O_SEARCH	O_PATH
324 #define O_SEARCH_origin	"O_PATH"
325 #endif
326 #else
327 	if (O_SEARCH > o_local) o_local = O_SEARCH;
328 #endif
329 #ifdef O_PATH
330 	if (O_PATH > o_local) o_local = O_PATH;
331 #endif
332 #ifdef O_EXEC
333 	if (O_EXEC > o_local) o_local = O_EXEC;
334 #endif
335 #ifdef O_CLOEXEC
336 	if (O_CLOEXEC > o_local) o_local = O_CLOEXEC;
337 #endif
338 #ifdef O_NDELAY
339 	if (O_NDELAY > o_local) o_local = O_NDELAY;
340 #endif
341 #ifdef O_TTY_INIT
342 	if (O_TTY_INIT > o_local) o_local = O_TTY_INIT;
343 #endif
344 
345 	/*
346 	 * O_DIRECTORY and O_SEARCH are problematic and get special treatment.
347 	 * For some reason some systems make it hard to coax these values
348 	 * from the standard headers. This rigmarole makes sure they appear
349 	 * in the ast headers if they are implemented by the kernel, even absent
350 	 * native definitions. If you touch this code make sure you get it right.
351 	 *
352 	 * O_*_native are native implementation specific values
353 	 * that this file compilation may have failed to coax
354 	 * out of the native compilation system which ast
355 	 * nontheless would still like to use
356 	 *
357 	 * based on the assumption that the native system
358 	 * honors binary compatibility, subsequent code uses
359 	 * these values to probe the actual system call
360 	 * to determine if the feature is implemented anyway
361 	 */
362 
363 #if __linux__
364 #define O_DIRECTORY_native	00200000
365 #define O_SEARCH_native		010000000,020000000,0100000000
366 /* #elif __some_other_os_that_wont_implement_posix_by_default__ */
367 #endif
368 
369 	{
370 		unsigned int	o_directory = 0;
371 		unsigned int	o_search = 0;
372 		char*		o_directory_origin = ORIGIN_EXTENSION;
373 		char*		o_search_origin = ORIGIN_IGNORE;
374 #ifdef	O_SEARCH
375 		o_search = O_SEARCH;
376 #ifndef O_SEARCH_origin
377 #define O_SEARCH_origin		ORIGIN_FAILSAFE
378 #endif
379 		o_search_origin = O_SEARCH_origin;
380 #elif defined(O_SEARCH_native)
381 		{
382 			int		i;
383 			char		tmp[256];
384 			unsigned int	o_search_native[] = { O_SEARCH_native };
385 			snprintf(tmp, sizeof(tmp), "%s.s", argv[1]);
386 			if (!mkdir(tmp, S_IXUSR|S_IXGRP|S_IXOTH))
387 				for (i = 0; i < (int)(sizeof(o_search_native)/sizeof(o_search_native[0])); i++)
388 					if (!close(open(tmp, o_search_native[i])))
389 					{
390 						o_search_origin = "kernel bits otherwise undefined";
391 						o_search = o_search_native[i];
392 						if (o_search > o_local)
393 							o_local = o_search;
394 						break;
395 					}
396 		}
397 #endif
398 #ifdef	O_DIRECTORY
399 		o_directory = O_DIRECTORY;
400 #ifndef O_DIRECTORY_origin
401 #define O_DIRECTORY_origin	ORIGIN_FAILSAFE
402 #endif
403 		o_directory_origin = O_DIRECTORY_origin;
404 #elif defined(O_DIRECTORY_native)
405 		{
406 			int		i;
407 			char		tmp[256];
408 			unsigned int	o_directory_native[] = { O_DIRECTORY_native };
409 			snprintf(tmp, sizeof(tmp), "%s.d", argv[1]);
410 			if (!mkdir(tmp, S_IXUSR|S_IXGRP|S_IXOTH))
411 				for (i = 0; i < (int)(sizeof(o_directory_native)/sizeof(o_directory_native[0])); i++)
412 					if (!close(open(tmp, O_DIRECTORY_native)))
413 					{
414 						snprintf(tmp, sizeof(tmp), "%s.f", argv[1]);
415 						if (!close(open(tmp, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR)) && close(open(tmp, o_directory_native[i]|O_RDONLY))))
416 						{
417 							o_directory_origin = "kernel bits otherwise undefined";
418 							o_directory = o_directory_native[i];
419 							if (o_directory > o_local)
420 								o_local = o_directory;
421 						}
422 			}
423 		}
424 #endif
425 		o_local_min = hibit(o_local);
426 		o_local_use = o_local = 020000000000;
427 
428 		printf("#define O_INTERCEPT		%012o	/* %s */\n", o_local, ORIGIN_EXTENSION);
429 		printf("#ifndef O_SEARCH\n");
430 		if (o_search)
431 			printf("#define O_SEARCH		%012o	/* %s */\n", o_search, o_search_origin);
432 		else
433 			printf("#define O_SEARCH		0		/* %s */\n", o_search_origin);
434 		printf("#endif\n");
435 		if (!o_directory)
436 			o_local_use = o_directory = o_local >> 1;
437 		printf("#ifndef O_DIRECTORY\n");
438 		printf("#define O_DIRECTORY		%012o	/* %s */\n", o_directory, o_directory_origin);
439 		printf("#endif\n");
440 
441 	}
442 
443 	printf("#ifndef O_CLOEXEC\n");
444 #ifdef O_CLOEXEC
445 	printf("#define O_CLOEXEC		%012o	/* %s */\n", (int)O_CLOEXEC, ORIGIN_FAILSAFE);
446 #else
447 	o_local_use = o_local >> 2;
448 	printf("#define O_CLOEXEC		%012o	/* %s */\n", o_local_use, ORIGIN_EXTENSION);
449 #endif
450 	printf("#endif\n");
451 
452 #ifndef	O_NOCTTY
453 #ifdef	TIOCNOTTY
454 	printf("#ifndef O_NOCTTY\n");
455 	o_local_use = o_local >> 3;
456 	printf("#define O_NOCTTY		%012o	/* %s */\n", o_local_use, ORIGIN_EXTENSION);
457 	printf("#endif\n");
458 #endif
459 #endif
460 #ifndef	O_NONBLOCK
461 	printf("#ifndef O_NONBLOCK\n");
462 	printf("#ifdef  O_NDELAY\n");
463 #ifdef O_NDELAY
464 	printf("#define O_NONBLOCK		%012o	/* O_NDELAY */\n", (int)O_NDELAY);
465 #else
466 	printf("#define O_NONBLOCK		O_NDELAY\n");
467 #endif
468 	printf("#else\n");
469 	printf("#ifdef  FNDELAY\n");
470 #ifdef FNDELAY
471 	printf("#define O_NONBLOCK		%012o	/* FNDELAY */\n", FNDELAY);
472 #else
473 	printf("#define O_NONBLOCK		FNDELAY\n");
474 #endif
475 	printf("#else\n");
476 	o_local_use = o_local >> 4;
477 	printf("#define O_NONBLOCK		%012o	/* %s */\n", o_local_use, ORIGIN_EXTENSION);
478 	printf("#endif\n");
479 	printf("#endif\n");
480 	printf("#endif\n");
481 #endif
482 
483 	printf("\n");
484 	printf("#define _ast_O_LOCAL		%012o	/* %s up to %012o%s */\n", o_local_use, ORIGIN_EXTENSION, o_local, o_local_use <= o_local_min ? " *** encroaches on native O_* flags ***" : "");
485 	printf("\n");
486 
487 #ifndef	O_NDELAY
488 	printf("#ifndef O_NDELAY\n");
489 	printf("#define O_NDELAY		O_NONBLOCK\n");
490 	printf("#endif\n");
491 #endif
492 #ifndef	O_ACCMODE
493 	printf("#define O_ACCMODE		(O_RDONLY|O_WRONLY|O_RDWR)\n");
494 #endif
495 #ifndef	O_BINARY
496 	printf("#define O_BINARY		0		/* %s */\n", ORIGIN_IGNORE);
497 #endif
498 #ifdef O_DIRECT
499 	printf("#ifndef O_DIRECT\n");
500 	printf("#define O_DIRECT		%012o	/* %s */\n", (int)O_DIRECT, ORIGIN_FAILSAFE);
501 	printf("#endif\n");
502 #endif
503 #ifdef O_NOFOLLOW
504 	printf("#ifndef O_NOFOLLOW\n");
505 	printf("#define O_NOFOLLOW		%012o	/* %s */\n", (int)O_NOFOLLOW, ORIGIN_FAILSAFE);
506 	printf("#endif\n");
507 #endif
508 #ifdef O_NOATIME
509 	printf("#ifndef O_NOATIME\n");
510 	printf("#define O_NOATIME		%012o	/* %s */\n", (int)O_NOATIME, ORIGIN_FAILSAFE);
511 	printf("#endif\n");
512 #endif
513 #ifndef	O_TEMPORARY
514 	printf("#define O_TEMPORARY		0		/* %s */\n", ORIGIN_IGNORE);
515 #endif
516 #ifndef	O_TEXT
517 	printf("#define O_TEXT			0		/* %s */\n", ORIGIN_IGNORE);
518 #endif
519 #if !defined(SOCK_CLOEXEC) || !defined(SOCK_NONBLOCK)
520 	printf("\n");
521 #ifndef SOCK_CLOEXEC
522 	printf("#ifndef SOCK_CLOEXEC\n");
523 	printf("#define _ast_SOCK_CLOEXEC	1\n");
524 	printf("#define SOCK_CLOEXEC		02000000 /* %s */\n", ORIGIN_EXTENSION);
525 	printf("#endif\n");
526 #endif
527 #ifndef SOCK_NONBLOCK
528 	printf("#ifndef SOCK_NONBLOCK\n");
529 	printf("#define _ast_SOCK_NONBLOCK	1\n");
530 	printf("#define SOCK_NONBLOCK		04000	/* %s */\n", ORIGIN_EXTENSION);
531 	printf("#endif\n");
532 #endif
533 #endif
534 
535 	printf("\n");
536 	printf("#define F_dupfd_cloexec		F_DUPFD_CLOEXEC /* OBSOLETE */\n");
537 	printf("#define O_cloexec		O_CLOEXEC /* OBSOLETE*/\n");
538 #if !defined(AT_FDCWD) || !defined(AT_SYMLINK_NOFOLLOW) || !defined(AT_REMOVEDIR) || !defined(AT_SYMLINK_FOLLOW) || !defined(AT_EACCESS)
539 	printf("\n");
540 #ifndef AT_FDCWD
541 	/* AT_FDCWD must be < -256 for portability reasons */
542 	printf("#define AT_FDCWD		-666	/* %s */\n", ORIGIN_EXTENSION);
543 #endif
544 #ifndef AT_SYMLINK_NOFOLLOW
545 	printf("#define AT_SYMLINK_NOFOLLOW	0x100	/* %s */\n", ORIGIN_EXTENSION);
546 #endif
547 #ifndef AT_REMOVEDIR
548 	printf("#define AT_REMOVEDIR		0x200	/* %s*/\n", ORIGIN_EXTENSION);
549 #endif
550 #ifndef AT_SYMLINK_FOLLOW
551 	printf("#define AT_SYMLINK_FOLLOW	0x400	/* %s*/\n", ORIGIN_EXTENSION);
552 #endif
553 #ifndef AT_EACCESS
554 	printf("#define AT_EACCESS		0x800	/* %s*/\n", ORIGIN_EXTENSION);
555 #endif
556 #endif
557 	printf("\n");
558 	printf("#include <ast_fs.h>\n");
559 	printf("#if _typ_off64_t\n");
560 	printf("#undef	off_t\n");
561 	printf("#define	off_t		off64_t\n");
562 	printf("#endif\n");
563 	printf("#if _lib_fstat64\n");
564 	printf("#define fstat		fstat64\n");
565 	printf("#endif\n");
566 	printf("#if _lib_fstatat64\n");
567 	printf("#define fstatat		fstatat64\n");
568 	printf("#endif\n");
569 	printf("#if _lib_lstat64\n");
570 	printf("#define lstat		lstat64\n");
571 	printf("#endif\n");
572 	printf("#if _lib_stat64\n");
573 	printf("#define stat		stat64\n");
574 	printf("#endif\n");
575 	printf("#if _lib_creat64\n");
576 	printf("#define creat		creat64\n");
577 	printf("#endif\n");
578 	printf("#if _lib_mmap64\n");
579 	printf("#define mmap		mmap64\n");
580 	printf("#endif\n");
581 	printf("#if _lib_open64\n");
582 	printf("#undef	open\n");
583 	printf("#define open		open64\n");
584 	printf("#endif\n");
585 
586 	printf("\n");
587 	printf("#if _BLD_ast && defined(__EXPORT__)\n");
588 	printf("#define extern	__EXPORT__\n");
589 	printf("#endif\n");
590 	printf("#if !_lib_faccessat\n");
591 	printf("extern int	faccessat(int, const char*, mode_t, int);\n");
592 	printf("#endif\n");
593 	printf("#if !_lib_fchmodat\n");
594 	printf("extern int	fchmodat(int, const char*, mode_t, int);\n");
595 	printf("#endif\n");
596 	printf("#if !_lib_fchownat\n");
597 	printf("extern int	fchownat(int, const char*, uid_t, gid_t, int);\n");
598 	printf("#endif\n");
599 	printf("#if !_lib_fstatat\n");
600 	printf("struct stat;\n");
601 	printf("extern int	fstatat(int, const char*, struct stat*, int);\n");
602 	printf("#endif\n");
603 	printf("#if !_lib_linkat\n");
604 	printf("extern int	linkat(int, const char*, int, const char*, int);\n");
605 	printf("#endif\n");
606 	printf("#if !_lib_mkdirat\n");
607 	printf("extern int	mkdirat(int, const char*, mode_t);\n");
608 	printf("#endif\n");
609 	printf("#if !_lib_mkfifoat\n");
610 	printf("extern int	mkfifoat(int, const char*, mode_t);\n");
611 	printf("#endif\n");
612 	printf("#if !_lib_mknodat\n");
613 	printf("extern int	mknodat(int, const char*, mode_t, dev_t);\n");
614 	printf("#endif\n");
615 	printf("#if !_lib_openat\n");
616 	printf("extern int	openat(int, const char*, int, ...);\n");
617 	printf("#endif\n");
618 	printf("#if !_lib_readlinkat\n");
619 	printf("extern ssize_t	readlinkat(int, const char*, char*, size_t);\n");
620 	printf("#endif\n");
621 	printf("#if !_lib_renameat\n");
622 	printf("extern int	renameat(int, const char*, int, const char*);\n");
623 	printf("#endif\n");
624 	printf("#if !_lib_symlinkat\n");
625 	printf("extern int	symlinkat(const char*, int, const char*);\n");
626 	printf("#endif\n");
627 	printf("#if !_lib_unlinkat\n");
628 	printf("extern int	unlinkat(int, const char*, int);\n");
629 	printf("#endif\n");
630 	printf("\n");
631 	printf("#undef	extern\n");
632 
633 	return 0;
634 }
635