Paul Edwards wrote: > >> /* Store in OUTPUT a string (made with alloca) containing an > >> assembler-name for a local static variable named NAME. > >> LABELNO is an integer which is different for each call. */ > >> > >> #ifdef TARGET_PDPMAC > >> #define ASM_FORMAT_PRIVATE_NAME(OUTPUT, NAME, LABELNO) \ > >> { \ > >> (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10); \ > >> sprintf ((OUTPUT), "__%d", (LABELNO)); \ > >> } > > > > How does this work? ASM_FORMAT_PRIVATE_NAME is not supposed > > to completely ignore the NAME argument, the function may well > > be called with the same LABELNO but different NAME strings, > > and this must not result in conflicting symbols ... > > I have compiled the entire GCC and not come up with any duplicate > static function names, so I think the number is always unique.
Hmm, I see that in the 3.2.x code base this is indeed true. However, in later compilers ASM_FORMAT_PRIVATE_NAME is used for other purposes by the middle-end, not just static function or variable names. You definitely can get number collisions in later compilers ... > > At this point, you may refer to "current_function_decl" to > > retrieve information about the function currently being output. > > In particular, you can retrieve the original source-level name > > associated with the routine via DECL_NAME (current_function_decl). > > Thanks a lot! I couldn't use that directly, but this: Why not? I'd have thought something like printf ("%s", IDENTIFIER_POINTER (DECL_NAME (current_function_decl))); should work fine ... > c:\devel\gcc\gcc\config\i370>cvs diff -r 1.37 i370.c B.t.w. if you use the -u or -c option to cvs diff, the diffs are a lot more readable ... > < mvs_function_name); > --- > > fname_as_string(0)); This is a bit problematic as fname_as_string is a function defined in the C front-end. If you were e.g. to build the Fortran compiler, your back-end gets linked against the Fortran front-end instead of the C front-end, and that function simply will not be there. Generally, the rule is that the back-end must not directly call front-end routines. In any case, for C source code fname_as_string does pretty much nothing else than what I suggested above ... Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE ulrich.weig...@de.ibm.com