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