From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15770 invoked by alias); 21 Aug 2009 10:19:48 -0000 Received: (qmail 15762 invoked by uid 22791); 21 Aug 2009 10:19:48 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mtagate7.de.ibm.com (HELO mtagate7.de.ibm.com) (195.212.29.156) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 21 Aug 2009 10:19:41 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.14.3/8.13.8) with ESMTP id n7LAJSCV716540 for ; Fri, 21 Aug 2009 10:19:28 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n7LAJMeX2748518 for ; Fri, 21 Aug 2009 12:19:28 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n7LAJMXY008945 for ; Fri, 21 Aug 2009 12:19:22 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id n7LAJLTL008933; Fri, 21 Aug 2009 12:19:21 +0200 Message-Id: <200908211019.n7LAJLTL008933@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 21 Aug 2009 12:19:21 +0200 Subject: Re: i370 port To: mutazilah@gmail.com (Paul Edwards) Date: Fri, 21 Aug 2009 16:46:00 -0000 From: "Ulrich Weigand" Cc: gcc@gcc.gnu.org In-Reply-To: <330DD244C65240E79CEC30F479932A39@Paullaptop> from "Paul Edwards" at Aug 21, 2009 08:34:27 AM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-08/txt/msg00392.txt.bz2 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.Weigand@de.ibm.com