From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 06D2C386F820 for ; Thu, 3 Sep 2020 10:18:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 06D2C386F820 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-UCBGNeyrPFypzFtiqDMIog-1; Thu, 03 Sep 2020 06:18:11 -0400 X-MC-Unique: UCBGNeyrPFypzFtiqDMIog-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4486410074D9; Thu, 3 Sep 2020 10:18:10 +0000 (UTC) Received: from zarquon.pink (unknown [10.33.36.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B96A7C5B5; Thu, 3 Sep 2020 10:18:09 +0000 (UTC) To: Joe Buehler Cc: gcc-help@gcc.gnu.org References: <5F48246C.6040402@cox.net> <8dff32c6-4e2c-2a1a-4216-98951f52b552@redhat.com> <5F4FE390.4000404@cox.net> From: Andrew Haley Autocrypt: addr=aph@redhat.com; prefer-encrypt=mutual; keydata= mQENBEoRZWsBCACUiFkb5YgfOfTHmzkESkfmTri14VX9UKdv4TUu9l9S6gFKf56ihWChiG8H pQ6CDTb5uqtZCWBNXoqcC2uCR0SCnWGk46tAW9dO0roEjoP+6AgbY4V5xUZt963XONYu1gnN EDQPB1QKN5L3PCMn0Dwnl1F6Of5BMPc+ErXr2BuMAG5Rb9QJPuWEjP4rMJdQIxeVkSk7oTnm rQJnDPF3WPimgwtaDGC17lZLwt4U9az9PobZxFH8lphexrwGdZX8qxQZEs9qfpW/wY/KFbRf bzSGNJlFd3X1liTofZQpN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SAu0kLTjX6e35FHdWmf2VHR6NbyuV5O/yzf/3iNallmocZIK5I0zY5ndbptd4vEWX4Kd R6d5D1AZrsnlLoFkIPR0WZfzfPtwiW6WVm6upSOQXEEA4YH3sNEFyywihqbp88Fx7BRKRtIS 27/FmbZjZ70N1rA99ld8cGmMha+ylFs4gBmDIpvKFLxlCiZFH7qEnyv4b73q Subject: Re: aph@redhat.com Message-ID: <986746f1-b0fd-d6ef-0ab4-9cfe33a29a35@redhat.com> Date: Thu, 3 Sep 2020 11:18:08 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <5F4FE390.4000404@cox.net> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Sep 2020 10:18:16 -0000 On 02/09/2020 19:25, Joe Buehler wrote: > Andrew Haley wrote: >> On 27/08/2020 22:23, Joe Buehler via Gcc-help wrote: >> >> temp.c: In function main : >> temp.c:4:2: warning: asm operand 0 probably doesn t match constraints >> __asm__ volatile(".8byte %0\n\t" : : "i" ("message %s\n")); >> ^~~~~~~ >> temp.c:4:2: error: impossible constraint in asm >> >> I'd use the "S" constraint. > > Thanks that worked. > >>> I am unable to code something similar manually using inline asm because >>> the string is a format string containing % characters, which inline asm >>> will of course try to interpret. (Does gcc provide anything to escape % >>> chars in a literal string?) >> >> "%%" > > The problem is that I have literal printf format strings in a > multiplatform code base. I need something like a gcc builtin to do > the % doubling. > > #define X(fmt) asm ("lines " __builtin_escape(fmt) " more lines") I'm not sure I really understand the problem. You only need the "%%" if the "%" characters are in the actual asm string, not the parameter passed, which can be any string. If you're assuming that it's possible to create inline asm code portable across non-GCC compilers, then that hasn't ever been so. Having said that, I'm fairly sure that __builtin_escape() could be written in C++. If you were feeling brave! -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671