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