From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Grall Subject: Re: [PATCH v2] asm-offsets: encode magic asm-offset runes as strings. Date: Wed, 23 Apr 2014 14:17:57 +0100 Message-ID: <5357BD85.8080804@linaro.org> References: <1395766541-23979-1-git-send-email-julien.grall@linaro.org> <1395766541-23979-3-git-send-email-julien.grall@linaro.org> <5332CDE00200007800002490@nat28.tlf.novell.com> <20140326131625.GB7885@deinos.phlegethon.org> <5332ED80.5070305@linaro.org> <533300BC02000078000027D4@nat28.tlf.novell.com> <20140327180134.GN91759@deinos.phlegethon.org> <53353D9202000078000033F6@nat28.tlf.novell.com> <20140328112854.GB87844@deinos.phlegethon.org> <53356D990200007800003595@nat28.tlf.novell.com> <20140403160747.GL38209@deinos.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wcx3p-0007To-Ld for xen-devel@lists.xenproject.org; Wed, 23 Apr 2014 13:18:02 +0000 Received: by mail-ee0-f52.google.com with SMTP id e49so783873eek.11 for ; Wed, 23 Apr 2014 06:17:59 -0700 (PDT) In-Reply-To: <20140403160747.GL38209@deinos.phlegethon.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tim Deegan Cc: xen-devel@lists.xenproject.org, Keir Fraser , stefano.stabellini@citrix.com, ian.campbell@citrix.com, Jan Beulich List-Id: xen-devel@lists.xenproject.org Hi Tim, I will resend a second version of my clang series soon. Can I add this patch into it? Thanks, On 04/03/2014 05:07 PM, Tim Deegan wrote: > Newer versions of clang attempt to parse inline assembler even when > not asked to assemble it. Wrap our not-for-assembly runes as strings > of the form ``.ascii "==>MAGIC RUNES<=="'' so clang doesn't choke on > them. > > While we're at it, assemble more of the final output line in the C > file, to make the sed expression shorter. > > Reported-by: Julien Grall > Suggested-by: Jan Beulich > Signed-off-by: Tim Deegan > --- > v2: make up the '#define' in the C source rather then in sed. > Not quite as neat as I'd hoped: need to match an extra space > to stop the second sed expression eating the # in #define. > > diff --git a/xen/Makefile b/xen/Makefile > index 79fa8f2..afbc962 100644 > --- a/xen/Makefile > +++ b/xen/Makefile > @@ -150,7 +150,7 @@ include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s > echo "#ifndef __ASM_OFFSETS_H__"; \ > echo "#define __ASM_OFFSETS_H__"; \ > echo ""; \ > - sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ > + sed -rne "/==>/{s:.*==>(.*)<==.*:\1:; s: [\$$#]: :; p;}"; \ > echo ""; \ > echo "#endif") <$< >$@ > > diff --git a/xen/arch/arm/arm32/asm-offsets.c b/xen/arch/arm/arm32/asm-offsets.c > index ac628c0..cd1dff7 100644 > --- a/xen/arch/arm/arm32/asm-offsets.c > +++ b/xen/arch/arm/arm32/asm-offsets.c > @@ -13,11 +13,12 @@ > #include > #include > > -#define DEFINE(_sym, _val) \ > - __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) ) > -#define BLANK() \ > - __asm__ __volatile__ ( "\n->" : : ) > -#define OFFSET(_sym, _str, _mem) \ > +#define DEFINE(_sym, _val) \ > + asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ > + : : "i" (_val) ) > +#define BLANK() \ > + asm volatile ( "\n.ascii\"==><==\"" : : ) > +#define OFFSET(_sym, _str, _mem) \ > DEFINE(_sym, offsetof(_str, _mem)); > > void __dummy__(void) > diff --git a/xen/arch/arm/arm64/asm-offsets.c b/xen/arch/arm/arm64/asm-offsets.c > index d7572fa..a3ce816 100644 > --- a/xen/arch/arm/arm64/asm-offsets.c > +++ b/xen/arch/arm/arm64/asm-offsets.c > @@ -12,11 +12,12 @@ > #include > #include > > -#define DEFINE(_sym, _val) \ > - __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) ) > -#define BLANK() \ > - __asm__ __volatile__ ( "\n->" : : ) > -#define OFFSET(_sym, _str, _mem) \ > +#define DEFINE(_sym, _val) \ > + asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ > + : : "i" (_val) ) > +#define BLANK() \ > + asm volatile ( "\n.ascii\"==><==\"" : : ) > +#define OFFSET(_sym, _str, _mem) \ > DEFINE(_sym, offsetof(_str, _mem)); > > void __dummy__(void) > diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c > index b0098b3..9acb648 100644 > --- a/xen/arch/x86/x86_64/asm-offsets.c > +++ b/xen/arch/x86/x86_64/asm-offsets.c > @@ -14,11 +14,12 @@ > #include > #include > > -#define DEFINE(_sym, _val) \ > - __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) ) > -#define BLANK() \ > - __asm__ __volatile__ ( "\n->" : : ) > -#define OFFSET(_sym, _str, _mem) \ > +#define DEFINE(_sym, _val) \ > + asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \ > + : : "i" (_val) ) > +#define BLANK() \ > + asm volatile ( "\n.ascii\"==><==\"" : : ) > +#define OFFSET(_sym, _str, _mem) \ > DEFINE(_sym, offsetof(_str, _mem)); > > void __dummy__(void) > -- Julien Grall