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