xref: /titanic_41/usr/src/lib/libast/common/features/map.c (revision 8700009e2cc8cb186241e1fdd74973da1121ee4c)
1 /***********************************************************************
2 *                                                                      *
3 *               This software is part of the ast package               *
4 *           Copyright (c) 1985-2007 AT&T Knowledge Ventures            *
5 *                      and is licensed under the                       *
6 *                  Common Public License, Version 1.0                  *
7 *                      by AT&T Knowledge Ventures                      *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *            http://www.opensource.org/licenses/cpl1.0.txt             *
11 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12 *                                                                      *
13 *              Information and Software Systems Research               *
14 *                            AT&T Research                             *
15 *                           Florham Park NJ                            *
16 *                                                                      *
17 *                 Glenn Fowler <gsf@research.att.com>                  *
18 *                  David Korn <dgk@research.att.com>                   *
19 *                   Phong Vo <kpv@research.att.com>                    *
20 *                                                                      *
21 ***********************************************************************/
22 #pragma prototyped
23 
24 /*
25  * some systems may pull in <ast_common.h> and its <ast_map.h>
26  * which we are in the process of generating ... this prevents it
27  */
28 
29 #define _def_map_ast	1
30 
31 #include "FEATURE/lib"
32 #include "FEATURE/mmap"
33 #include "FEATURE/vmalloc"
34 
35 int
36 main()
37 {
38 	printf("#pragma prototyped\n");
39 	printf("\n");
40 	printf("/*\n");
41 	printf(" * prototypes provided for standard interfaces hijacked\n");
42 	printf(" * by ast and mapped to _ast_* but already prototyped\n");
43 	printf(" * unmapped in native headers included by <ast_std.h>\n");
44 	printf(" */\n");
45 	printf("\n");
46 	printf("#if _BLD_ast && defined(__EXPORT__)\n");
47 	printf("#define extern		__EXPORT__\n");
48 	printf("#endif\n");
49 	printf("\n");
50 #if __MVS__
51 #undef	_map_libc
52 #define _map_libc	1
53 	printf("\n");
54 	printf("/* mvs.390 libc.dll routines can't be intercepted by user dlls */\n");
55 	printf("#undef	_mem_dd_fd_DIR\n");
56 	printf("#undef	_typ_long_double\n");
57 #endif
58 #if _map_libc
59 #undef	_map_malloc
60 #define _map_malloc	1
61 	printf("\n");
62 	printf("#define	_map_libc	1\n");
63 	printf("#undef	basename\n");
64 	printf("#define basename	_ast_basename\n");
65 	printf("#undef	dirname\n");
66 	printf("#define dirname		_ast_dirname\n");
67 	printf("#undef	eaccess\n");
68 	printf("#define eaccess		_ast_eaccess\n");
69 #if !_lib_execvpe
70 	printf("#undef	execvpe\n");
71 	printf("#define execvpe		_ast_execvpe\n");
72 	printf("extern int		execvpe(const char*, char* const[], char* const[]);\n");
73 #endif
74 	printf("#undef	fnmatch\n");
75 	printf("#define fnmatch		_ast_fnmatch\n");
76 	printf("#undef	fts_children\n");
77 	printf("#define fts_children    _ast_fts_children\n");
78 	printf("#undef	fts_close\n");
79 	printf("#define fts_close       _ast_fts_close\n");
80 	printf("#undef	fts_flags\n");
81 	printf("#define fts_flags       _ast_fts_flags\n");
82 	printf("#undef	fts_notify\n");
83 	printf("#define fts_notify      _ast_fts_notify\n");
84 	printf("#undef	fts_open\n");
85 	printf("#define fts_open	_ast_fts_open\n");
86 	printf("#undef	fts_read\n");
87 	printf("#define fts_read	_ast_fts_read\n");
88 	printf("#undef	fts_set\n");
89 	printf("#define fts_set		_ast_fts_set\n");
90 	printf("#undef	ftw\n");
91 	printf("#define ftw		_ast_ftw\n");
92 	printf("#undef	ftwalk\n");
93 	printf("#define ftwalk		_ast_ftwalk\n");
94 	printf("#undef	ftwflags\n");
95 	printf("#define ftwflags	_ast_ftwflags\n");
96 #if !_WINIX
97 	printf("#undef	getcwd\n");
98 	printf("#define getcwd		_ast_getcwd\n");
99 	printf("extern char*		getcwd(char*, size_t);\n");
100 #endif
101 	printf("#undef	getdate\n");
102 	printf("#define getdate		_ast_getdate\n");
103 #if _lib_getopt || _lib_getsubopt || _lib_getopt_long || _lib_getopt_long_only
104 	printf("#undef	getopt\n");
105 	printf("#define getopt		_ast_getopt\n");
106 	printf("#undef	getsubopt\n");
107 	printf("#define getsubopt       _ast_getsubopt\n");
108 	printf("#undef	getopt_long\n");
109 	printf("#define getopt_long	_ast_getopt_long\n");
110 	printf("#undef	getopt_long_only\n");
111 	printf("#define getopt_long_only _ast_getopt_long_only\n");
112 #endif
113 	printf("#undef	getwd\n");
114 	printf("#define getwd		_ast_getwd\n");
115 	printf("extern char*		getwd(char*);\n");
116 	printf("#undef	glob\n");
117 	printf("#define glob		_ast_glob\n");
118 	printf("#undef	globfree\n");
119 	printf("#define globfree	_ast_globfree\n");
120 	printf("#undef	memdup\n");
121 	printf("#define memdup		_ast_memdup\n");
122 	printf("#undef	memfatal\n");
123 	printf("#define memfatal	_ast_memfatal\n");
124 	printf("#undef	memhash\n");
125 	printf("#define memhash		_ast_memhash\n");
126 	printf("#undef	memsum\n");
127 	printf("#define memsum		_ast_memsum\n");
128 	printf("#undef	mkstemp\n");
129 	printf("#define mkstemp		_ast_mkstemp\n");
130 	printf("extern int		mkstemp(char*);\n");
131 	printf("#undef	mktemp\n");
132 	printf("#define mktemp		_ast_mktemp\n");
133 	printf("extern char*		mktemp(char*);\n");
134 	printf("#undef	mktime\n");
135 	printf("#define mktime		_ast_mktime\n");
136 	printf("#undef	nftw\n");
137 	printf("#define nftw		_ast_nftw\n");
138 	printf("#undef	optesc\n");
139 	printf("#define optesc		_ast_optesc\n");
140 	printf("#undef	optget\n");
141 	printf("#define optget		_ast_optget\n");
142 	printf("#undef	opthelp\n");
143 	printf("#define opthelp		_ast_opthelp\n");
144 	printf("#undef	optjoin\n");
145 	printf("#define optjoin		_ast_optjoin\n");
146 	printf("#undef	optstr\n");
147 	printf("#define optstr		_ast_optstr\n");
148 	printf("#undef	optusage\n");
149 	printf("#define optusage	_ast_optusage\n");
150 	printf("#undef	pathaccess\n");
151 	printf("#define pathaccess	_ast_pathaccess\n");
152 	printf("#undef	pathbin\n");
153 	printf("#define pathbin		_ast_pathbin\n");
154 	printf("#undef	pathcanon\n");
155 	printf("#define pathcanon	_ast_pathcanon\n");
156 	printf("#undef	pathcat\n");
157 	printf("#define pathcat		_ast_pathcat\n");
158 	printf("#undef	pathcd\n");
159 	printf("#define pathcd		_ast_pathcd\n");
160 	printf("#undef	pathcheck\n");
161 	printf("#define pathcheck	_ast_pathcheck\n");
162 	printf("#undef	pathexists\n");
163 	printf("#define pathexists	_ast_pathexists\n");
164 	printf("#undef	pathfind\n");
165 	printf("#define pathfind	_ast_pathfind\n");
166 	printf("#undef	pathgetlink\n");
167 	printf("#define pathgetlink	_ast_pathgetlink\n");
168 	printf("#undef	pathinclude\n");
169 	printf("#define pathinclude	_ast_pathinclude\n");
170 	printf("#undef	pathkey\n");
171 	printf("#define pathkey		_ast_pathkey\n");
172 	printf("#undef	pathnative\n");
173 	printf("#define pathnative	_ast_pathnative\n");
174 	printf("#undef	pathpath\n");
175 	printf("#define pathpath	_ast_pathpath\n");
176 	printf("#undef	pathposix\n");
177 	printf("#define pathposix	_ast_pathposix\n");
178 	printf("#undef	pathprobe\n");
179 	printf("#define pathprobe	_ast_pathprobe\n");
180 	printf("#undef	pathrepl\n");
181 	printf("#define pathrepl	_ast_pathrepl\n");
182 	printf("#undef	pathsetlink\n");
183 	printf("#define pathsetlink	_ast_pathsetlink\n");
184 	printf("#undef	pathshell\n");
185 	printf("#define pathshell	_ast_pathshell\n");
186 	printf("#undef	pathstat\n");
187 	printf("#define pathstat	_ast_pathstat\n");
188 	printf("#undef	pathtemp\n");
189 	printf("#define pathtemp	_ast_pathtemp\n");
190 	printf("#undef	pathtmp\n");
191 	printf("#define pathtmp		_ast_pathtmp\n");
192 	printf("#undef	procclose\n");
193 	printf("#define procclose	_ast_procclose\n");
194 	printf("#undef	procfree\n");
195 	printf("#define procfree	_ast_procfree\n");
196 	printf("#undef	procopen\n");
197 	printf("#define procopen	_ast_procopen\n");
198 	printf("#undef	procrun\n");
199 	printf("#define procrun		_ast_procrun\n");
200 	printf("#undef	putenv\n");
201 	printf("#define putenv		_ast_putenv\n");
202 	printf("#undef	re_comp\n");
203 	printf("#define re_comp		_ast_re_comp\n");
204 	printf("#undef	re_exec\n");
205 	printf("#define re_exec		_ast_re_exec\n");
206 	printf("#undef	realpath\n");
207 	printf("#define realpath	_ast_realpath\n");
208 	printf("extern char*		realpath(const char*, char*);\n");
209 	printf("#undef	regaddclass\n");
210 	printf("#define regaddclass	_ast_regaddclass\n");
211 	printf("#undef	regalloc\n");
212 	printf("#define regalloc	_ast_regalloc\n");
213 	printf("#undef	regcache\n");
214 	printf("#define regcache	_ast_regcache\n");
215 	printf("#undef	regclass\n");
216 	printf("#define regclass	_ast_regclass\n");
217 	printf("#undef	regcmp\n");
218 	printf("#define regcmp		_ast_regcmp\n");
219 	printf("#undef	regcollate\n");
220 	printf("#define regcollate      _ast_regcollate\n");
221 	printf("#undef	regcomb\n");
222 	printf("#define regcomb		_ast_regcomb\n");
223 	printf("#undef	regcomp\n");
224 	printf("#define regcomp		_ast_regcomp\n");
225 	printf("#undef	regdecomp\n");
226 	printf("#define regdecomp	_ast_regdecomp\n");
227 	printf("#undef	regdup\n");
228 	printf("#define regdup		_ast_regdup\n");
229 	printf("#undef	regerror\n");
230 	printf("#define regerror	_ast_regerror\n");
231 	printf("#undef	regex\n");
232 	printf("#define regex		_ast_regex\n");
233 	printf("#undef	regexec\n");
234 	printf("#define regexec		_ast_regexec\n");
235 	printf("#undef	regfatal\n");
236 	printf("#define regfatal	_ast_regfatal\n");
237 	printf("#undef	regfatalpat\n");
238 	printf("#define regfatalpat     _ast_regfatalpat\n");
239 	printf("#undef	regfree\n");
240 	printf("#define regfree		_ast_regfree\n");
241 	printf("#undef	regncomp\n");
242 	printf("#define regncomp	_ast_regncomp\n");
243 	printf("#undef	regnexec\n");
244 	printf("#define regnexec	_ast_regnexec\n");
245 	printf("#undef	regrecord\n");
246 	printf("#define regrecord       _ast_regrecord\n");
247 	printf("#undef	regrexec\n");
248 	printf("#define regrexec	_ast_regrexec\n");
249 	printf("#undef	regstat\n");
250 	printf("#define regstat		_ast_regstat\n");
251 	printf("#undef	regsub\n");
252 	printf("#define regsub		_ast_regsub\n");
253 	printf("#undef	regsubcomp\n");
254 	printf("#define regsubcomp	_ast_regsubcomp\n");
255 	printf("#undef	regsubexec\n");
256 	printf("#define regsubexec	_ast_regsubexec\n");
257 	printf("#undef	regsubflags\n");
258 	printf("#define regsubflags	_ast_regsubflags\n");
259 	printf("#undef	regsubfree\n");
260 	printf("#define regsubfree	_ast_regsubfree\n");
261 	printf("#undef	remove\n");
262 	printf("#define remove		_ast_remove\n");
263 	printf("extern int		remove(const char*);\n");
264 	printf("#undef	resolvepath\n");
265 	printf("#define resolvepath	_ast_resolvepath\n");
266 	printf("extern char*		resolvepath(const char*, char*, size_t);\n");
267 	printf("#undef	setenv\n");
268 	printf("#define setenv		_ast_setenv\n");
269 	printf("extern int		setenv(const char*, const char*, int);\n");
270 	printf("#undef	setenviron\n");
271 	printf("#define setenviron      _ast_setenviron\n");
272 	printf("#undef	sigcritical\n");
273 	printf("#define sigcritical      _ast_sigcritical\n");
274 	printf("#undef	signal\n");
275 	printf("#define signal      	_ast_signal\n");
276 	printf("#undef	sigunblock\n");
277 	printf("#define sigunblock      _ast_sigunblock\n");
278 	printf("#undef	stracmp\n");
279 	printf("#define stracmp		_ast_stracmp\n");
280 	printf("#undef	strcopy\n");
281 	printf("#define strcopy		_ast_strcopy\n");
282 	printf("#undef	strelapsed\n");
283 	printf("#define strelapsed	_ast_strelapsed\n");
284 	printf("#undef	stresc\n");
285 	printf("#define stresc		_ast_stresc\n");
286 	printf("#undef	streval\n");
287 	printf("#define streval		_ast_streval\n");
288 	printf("#undef	strexpr\n");
289 	printf("#define strexpr		_ast_strexpr\n");
290 	printf("#undef	strftime\n");
291 	printf("#define strftime	_ast_strftime\n");
292 	printf("#undef	strgid\n");
293 	printf("#define strgid		_ast_strgid\n");
294 	printf("#undef	strgrpmatch\n");
295 	printf("#define strgrpmatch	_ast_strgrpmatch\n");
296 	printf("#undef	strhash\n");
297 	printf("#define strhash		_ast_strhash\n");
298 	printf("#undef	strkey\n");
299 	printf("#define strkey		_ast_strkey\n");
300 	printf("#undef	strlcat\n");
301 	printf("#define strlcat		_ast_strlcat\n");
302 	printf("extern size_t		strlcat(char*, const char*, size_t);\n");
303 	printf("#undef	strlcpy\n");
304 	printf("#define strlcpy		_ast_strlcpy\n");
305 	printf("extern size_t		strlcpy(char*, const char*, size_t);\n");
306 	printf("#undef	strlook\n");
307 	printf("#define strlook		_ast_strlook\n");
308 	printf("#undef	strmatch\n");
309 	printf("#define strmatch	_ast_strmatch\n");
310 #endif
311 #if _map_libc || _lib_strmode
312 	printf("#undef	strmode\n");
313 	printf("#define strmode		_ast_strmode\n");
314 #endif
315 #if _map_libc
316 	printf("#undef	strnacmp\n");
317 	printf("#define strnacmp	_ast_strnacmp\n");
318 	printf("#undef	strncopy\n");
319 	printf("#define strncopy	_ast_strncopy\n");
320 	printf("#undef	strntod\n");
321 	printf("#define strntod		_ast_strntod\n");
322 	printf("#undef	strntol\n");
323 	printf("#define strntol		_ast_strntol\n");
324 	printf("#undef	strntold\n");
325 	printf("#define strntold	_ast_strntold\n");
326 	printf("#undef	strntoll\n");
327 	printf("#define strntoll	_ast_strntoll\n");
328 	printf("#undef	strntoul\n");
329 	printf("#define strntoul	_ast_strntoul\n");
330 	printf("#undef	strntoull\n");
331 	printf("#define strntoull	_ast_strntoull\n");
332 	printf("#undef	stropt\n");
333 	printf("#define stropt		_ast_stropt\n");
334 	printf("#undef	strperm\n");
335 	printf("#define strperm		_ast_strperm\n");
336 	printf("#undef	strpsearch\n");
337 	printf("#define strpsearch	_ast_strpsearch\n");
338 #if !_lib_strptime
339 	printf("#undef	strptime\n");
340 	printf("#define strptime	_ast_strptime\n");
341 #endif
342 	printf("#undef	strsearch\n");
343 	printf("#define strsearch	_ast_strsearch\n");
344 	printf("#undef	strsort\n");
345 	printf("#define strsort		_ast_strsort\n");
346 	printf("#undef	strsubmatch\n");
347 	printf("#define strsubmatch	_ast_strsubmatch\n");
348 	printf("#undef	strsum\n");
349 	printf("#define strsum		_ast_strsum\n");
350 	printf("#undef	strtape\n");
351 	printf("#define strtape		_ast_strtape\n");
352 	printf("#undef	strtoip4\n");
353 	printf("#define strtoip4	_ast_strtoip4\n");
354 	printf("#undef	strton\n");
355 	printf("#define strton		_ast_strton\n");
356 	printf("#undef	strtonll\n");
357 	printf("#define strtonll	_ast_strtonll\n");
358 	printf("#undef	struid\n");
359 	printf("#define struid		_ast_struid\n");
360 	printf("#undef	struniq\n");
361 	printf("#define struniq		_ast_struniq\n");
362 	printf("#undef	system\n");
363 	printf("#define system		_ast_system\n");
364 	printf("extern int		system(const char*);\n");
365 	printf("#undef	tempnam\n");
366 	printf("#define tempnam		_ast_tempnam\n");
367 	printf("extern char*		tempnam(const char*, const char*);\n");
368 	printf("#undef	tmpnam\n");
369 	printf("#define tmpnam		_ast_tmpnam\n");
370 	printf("extern char*		tmpnam(char*);\n");
371 	printf("#undef	touch\n");
372 	printf("#define touch		_ast_touch\n");
373 	printf("#undef	wordexp\n");
374 	printf("#define wordexp		_ast_wordexp\n");
375 	printf("#undef	wordfree\n");
376 	printf("#define wordfree	_ast_wordfree\n");
377 	printf("#undef	unsetenv\n");
378 	printf("#define unsetenv	_ast_unsetenv\n");
379 #endif
380 #if _std_malloc
381 	printf("\n");
382 	printf("/* no local malloc override */\n");
383 	printf("#define	_std_malloc	1\n");
384 #else
385 #if _map_malloc
386 	printf("\n");
387 	printf("/* cannot override local malloc */\n");
388 	printf("#define	_map_malloc	1\n");
389 	printf("#undef	calloc\n");
390 	printf("#define calloc		_ast_calloc\n");
391 	printf("extern void*		calloc(size_t, size_t);\n");
392 	printf("#undef	cfree\n");
393 	printf("#define cfree		_ast_cfree\n");
394 	printf("extern void		cfree(void*);\n");
395 	printf("#undef	free\n");
396 	printf("#define free		_ast_free\n");
397 	printf("extern void		free(void*);\n");
398 #if _lib_mallinfo
399 	printf("#undef	mallinfo\n");
400 	printf("#define mallinfo	_ast_mallinfo\n");
401 #endif
402 	printf("#undef	malloc\n");
403 	printf("#define malloc		_ast_malloc\n");
404 	printf("extern void*		malloc(size_t);\n");
405 #if _lib_mallopt
406 	printf("#undef	mallopt\n");
407 	printf("#define mallopt		_ast_mallopt\n");
408 #endif
409 #if _lib_memalign
410 	printf("#undef	memalign\n");
411 	printf("#define memalign	_ast_memalign\n");
412 	printf("extern void*		memalign(size_t, size_t);\n");
413 #endif
414 #if _lib_mstats
415 	printf("#undef	mstats\n");
416 	printf("#define mstats		_ast_mstats\n");
417 #endif
418 #if _lib_pvalloc
419 	printf("#undef	pvalloc\n");
420 	printf("#define pvalloc		_ast_pvalloc\n");
421 #endif
422 	printf("#undef	realloc\n");
423 	printf("#define realloc		_ast_realloc\n");
424 	printf("extern void*		realloc(void*, size_t);\n");
425 	printf("#undef	strdup\n");
426 	printf("#define strdup		_ast_strdup\n");
427 	printf("extern char*		strdup(const char*);\n");
428 #if _lib_valloc
429 	printf("#undef	valloc\n");
430 	printf("#define valloc		_ast_valloc\n");
431 	printf("extern void*		valloc(size_t);\n");
432 #endif
433 #endif
434 #endif
435 
436 	/*
437 	 * overriding <stdlib.h> strto*() is problematic to say the least
438 	 */
439 
440 #if _map_libc || _std_strtol
441 #if !__CYGWIN__
442 	printf("#undef	strtol\n");
443 	printf("#define strtol		_ast_strtol\n");
444 	printf("#undef	strtoul\n");
445 	printf("#define strtoul		_ast_strtoul\n");
446 #endif
447 	printf("#undef	strtoll\n");
448 	printf("#define strtoll		_ast_strtoll\n");
449 	printf("#undef	strtoull\n");
450 	printf("#define strtoull	_ast_strtoull\n");
451 #endif
452 #if _map_libc || _std_strtod
453 	printf("#undef	strtod\n");
454 	printf("#define strtod		_ast_strtod\n");
455 #endif
456 #if _map_libc || _std_strtold
457 	printf("#undef	strtold\n");
458 	printf("#define strtold		_ast_strtold\n");
459 #endif
460 #if !__CYGWIN__
461 #if _npt_strtol || _map_libc || _std_strtol
462 #if _npt_strtol && !_map_libc && !_std_strtol
463 	printf("#ifndef _ISOC99_SOURCE\n");
464 #endif
465 	printf("extern long		strtol(const char*, char**, int);\n");
466 #if _npt_strtol && !_map_libc && !_std_strtol
467 	printf("#endif\n");
468 #endif
469 #endif
470 #if _npt_strtoul || _map_libc || _std_strtol
471 #if _npt_strtoul && !_map_libc && !_std_strtol
472 	printf("#ifndef _ISOC99_SOURCE\n");
473 #endif
474 	printf("extern unsigned long	strtoul(const char*, char**, int);\n");
475 #if _npt_strtoul && !_map_libc && !_std_strtol
476 	printf("#endif\n");
477 #endif
478 #endif
479 #endif
480 #if _npt_strtod || _map_libc || _std_strtod
481 #if _npt_strtod && !_map_libc && !_std_strtod
482 	printf("#ifndef _ISOC99_SOURCE\n");
483 #endif
484 	printf("extern double		strtod(const char*, char**);\n");
485 #if _npt_strtod && !_map_libc && !_std_strtod
486 	printf("#endif\n");
487 #endif
488 #endif
489 	printf("#if !_UWIN\n");
490 	printf("#undef	extern\n");
491 	printf("#endif\n");
492 #if _npt_strtold || _map_libc || _std_strtold
493 #if _npt_strtold && !_map_libc && !_std_strtold
494 	printf("#ifndef _ISOC99_SOURCE\n");
495 #endif
496 	printf("extern _ast_fltmax_t	strtold(const char*, char**);\n");
497 #if _npt_strtold && !_map_libc && !_std_strtold
498 	printf("#endif\n");
499 #endif
500 #endif
501 	printf("#undef	extern\n");
502 #if _npt_strtoll || _map_libc || _std_strtol
503 #if _npt_strtoll && !_map_libc && !_std_strtol
504 	printf("#ifndef _ISOC99_SOURCE\n");
505 #endif
506 	printf("extern _ast_intmax_t		strtoll(const char*, char**, int);\n");
507 #if _npt_strtoll && !_map_libc && !_std_strtol
508 	printf("#endif\n");
509 #endif
510 #endif
511 #if _npt_strtoull || _map_libc || _std_strtol
512 #if _npt_strtoull && !_map_libc && !_std_strtol
513 	printf("#ifndef _ISOC99_SOURCE\n");
514 #endif
515 	printf("extern unsigned _ast_intmax_t	strtoull(const char*, char**, int);\n");
516 #if _npt_strtoull && !_map_libc && !_std_strtoul
517 	printf("#endif\n");
518 #endif
519 #endif
520 	printf("\n");
521 	printf("#undef	extern\n");
522 	return 0;
523 }
524