Message ID | 1545062607-8599-11-git-send-email-yamada.masahiro@socionext.com |
---|---|
State | New |
Headers | show
Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2639949ljp; Mon, 17 Dec 2018 08:10:56 -0800 (PST) X-Google-Smtp-Source: AFSGD/V16Eja0iFBhalg1tzt4ekcHfgcG/Hv5ru8KWe5AitTN34DPbmOrevY5VHo507VX8heW2Xl X-Received: by 2002:a62:5884:: with SMTP id m126mr13302413pfb.177.1545063056513; Mon, 17 Dec 2018 08:10:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545063056; cv=none; d=google.com; s=arc-20160816; b=XnVM9aJqwurjPPOoWOVgQDnWUOqNoNOb9dKBmu0CYfEKqpkO2PH3XLPL+u1HBQDQd0 jW3hIFOnlZtmMk7T3YuDQ+iFnRlKR9n9ghYkrcnQfpYKXkZ7KlHdBHv/78v5vMFdB+N/ TrIhrQ7ij7dBlghqMPQozJtG6785wmpfHiSieyKRfn0/KWph+f9eYLFd11fzWCYPE/yW 8m+2knAuvhBUXIqJ56+5xhIwNDsN5mVUyjfV/enDkW48pWkDJa4B12qp5eNNI26ysTA/ QgUoM0YgqwwvlKMO3F+wNoxyO8RFIftQ5oam+EJ74B/bYmDO9l6+9JIDLX9I1VhJcq5W S75g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=o/MEbJ3S1hhfmW2hGhchL96p7dT26gkeOJCbbt7ujYI=; b=nc37JK+jcYdKTNEm/9i7lXLvnysVlOuCzXPwffxwYUq01QMJ47jRa87WHCmjKw4bu7 va+gNSxlxKUuJMH6DoGPc4+nkHlhYNgSHTLJhlFW6QFMTBKrrbPMu+Su6YoM2Ai1LYNN k4PplzkZW4H+BbSoN8LPfx2a2L8mSRjrp3YqV+dYTN6BlJpefSGBSAqudcKKiSzVY2rs SDiokz9BLQ2kVg0YPM3mTsJj70kXlXa7wJDyucJ+XX5cYs2CMJOqH9LHEreC0J3mj8Cl GptoV1naQxQ5N+VIQBxswfe4MAZJBL3MYi8+65ubdqpGpC7vR1i3m303T745exHm7NXU 5hzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Eu9BMTHW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: <linux-kernel-owner@vger.kernel.org> Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si11346047pgt.213.2018.12.17.08.10.55; Mon, 17 Dec 2018 08:10:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Eu9BMTHW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388129AbeLQQKx (ORCPT <rfc822;igor.opaniuk@linaro.org> + 31 others); Mon, 17 Dec 2018 11:10:53 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:64868 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387635AbeLQQKx (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Dec 2018 11:10:53 -0500 Received: from grover.tkatk1.zaq.ne.jp (zaqdadce369.zaq.ne.jp [218.220.227.105]) (authenticated) by conuserg-07.nifty.com with ESMTP id wBHG3bRn008119; Tue, 18 Dec 2018 01:03:53 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com wBHG3bRn008119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1545062634; bh=o/MEbJ3S1hhfmW2hGhchL96p7dT26gkeOJCbbt7ujYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eu9BMTHWNTBFYlbJ5nxhDX/xlXN7gxMGDpvSFqfP9NsumwKw7Yu0/dNS1ahhxe2Up WGnthgiNa/dtN5WRTRgudM3l3m5zOok6fPxUX7znA4wSc1Vouu0rolq2Sw+e04JRYF Ht0zfpHHbtoij48qC16YZZwhlZAcBkDO83lVya+1eibEUfXgPhwwfEpMRwxuPxPsW/ nxRKhvZyBl8j54qtpQCYCpVSaODEY8L9nkIU0YF4jz7isFdTAhmlqMKMJEPbjN4fr/ h0ibKG7JxoxJtxvuWGdoLoE3cmHjTK6q64ds2WB94zH9Ud5XaVVSXKnY2xBxdUOtg4 c6Z/iCL7IKOXQ== X-Nifty-SrcIP: [218.220.227.105] From: Masahiro Yamada <yamada.masahiro@socionext.com> To: x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>, "H . Peter Anvin" <hpa@zytor.com> Cc: Richard Biener <rguenther@suse.de>, Segher Boessenkool <segher@kernel.crashing.org>, Peter Zijlstra <peterz@infradead.org>, Juergen Gross <jgross@suse.com>, Josh Poimboeuf <jpoimboe@redhat.com>, Kees Cook <keescook@chromium.org>, Linus Torvalds <torvalds@linux-foundation.org>, Masahiro Yamada <yamada.masahiro@socionext.com>, Andrey Ryabinin <aryabinin@virtuozzo.com>, Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org Subject: [PATCH v3 10/12] linux/linkage: add ASM() macro to reduce duplication between C/ASM code Date: Tue, 18 Dec 2018 01:03:25 +0900 Message-Id: <1545062607-8599-11-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> References: <1545062607-8599-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org |
Series |
x86, kbuild: revert macrofying inline assembly code
|
expand
|
diff --git a/include/linux/linkage.h b/include/linux/linkage.h index 7c47b1a..80faeae 100644 --- a/include/linux/linkage.h +++ b/include/linux/linkage.h @@ -12,6 +12,14 @@ #define ASM_NL ; #endif +#ifdef __ASSEMBLY__ +#define _ASM(x...) x ASM_NL +#else +#define _ASM(x...) #x __stringify(\n\t) +#endif +/* Doing two levels allows macros to be used in ASM(...) */ +#define ASM(x...) _ASM(x) + #ifdef __cplusplus #define CPP_ASMLINKAGE extern "C" #else
We often duplicate similar assembly code to use it from .c and .S files. The difference is mostly the presence of double quotes. So, here is a new macro ASM(). (We have similar approach for __ASM_FORM(), etc.) The usage is like this: #define MY_CODE \ ASM( .section ".text" )\ ASM( movl $1, %eax ) In C context, the preprocessor expands it into: ".section \".text\"" "\n\t" "movl $1, %eax" "\n\t" This is perfect for the use from the inline asm(...) in .c files. In assembly context, the preprocessor expands it into: .section ".text" ; movl $1, %eax ; This is fine for the use in .S files. I used double-expansion like __stringify() so that we can use macros in ASM(...). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> --- include/linux/linkage.h | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.7.4