From patchwork Sat Jan 30 09:47:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 60859 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1635271lbb; Sat, 30 Jan 2016 01:50:07 -0800 (PST) X-Received: by 10.194.156.199 with SMTP id wg7mr15370900wjb.114.1454147407110; Sat, 30 Jan 2016 01:50:07 -0800 (PST) Return-Path: Received: from lists.xen.org (lists.xenproject.org. [50.57.142.19]) by mx.google.com with ESMTPS id hk5si27266068wjb.22.2016.01.30.01.50.06 (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 30 Jan 2016 01:50:07 -0800 (PST) Received-SPF: neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=50.57.142.19; Authentication-Results: mx.google.com; spf=neutral (google.com: 50.57.142.19 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aPS8u-00056Q-KB; Sat, 30 Jan 2016 09:48:32 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aPS8t-00056F-0T for xen-devel@lists.xen.org; Sat, 30 Jan 2016 09:48:31 +0000 Received: from [85.158.143.35] by server-3.bemta-4.messagelabs.com id DD/A1-31122-EE68CA65; Sat, 30 Jan 2016 09:48:30 +0000 X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1454147298!8601647!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 14302 invoked from network); 30 Jan 2016 09:48:29 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-16.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 30 Jan 2016 09:48:29 -0000 Received: from 172.24.1.50 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.50]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BVL85775; Sat, 30 Jan 2016 17:48:11 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Sat, 30 Jan 2016 17:48:02 +0800 From: Shannon Zhao To: Date: Sat, 30 Jan 2016 17:47:28 +0800 Message-ID: <1454147250-7704-2-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1454147250-7704-1-git-send-email-zhaoshenglong@huawei.com> References: <1454147250-7704-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.56AC86DC.00A0, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: ae891f8207c41bf3ac1c7045711c9f46 Cc: Doug Goldstein , shannon.zhao@linaro.org, jbeulich@suse.com, peter.huangpeng@huawei.com Subject: [Xen-devel] [PATCH v6 1/3] Kconfig: import kconfig.h from Linux 4.3 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org From: Shannon Zhao To support using CONFIG_ options in C/CPP expressions, import kconfig.h from the Linux v4.3 tag (commit id 6a13feb9c82803e2b815eca72fa7a9f5561d7861). Only import IS_ENABLED for Xen since Xen doesn't support loadable modules. CC: Doug Goldstein Signed-off-by: Shannon Zhao --- xen/include/xen/kconfig.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 xen/include/xen/kconfig.h -- 2.0.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel diff --git a/xen/include/xen/kconfig.h b/xen/include/xen/kconfig.h new file mode 100644 index 0000000..4d58c5b --- /dev/null +++ b/xen/include/xen/kconfig.h @@ -0,0 +1,31 @@ +#ifndef __XEN_KCONFIG_H +#define __XEN_KCONFIG_H + +#include + +/* + * Helper macros to use CONFIG_ options in C/CPP expressions. Note that + * these only work with boolean option. + */ + +/* + * Getting something that works in C and CPP for an arg that may or may + * not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1" + * we match on the placeholder define, insert the "0," for arg1 and generate + * the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one). + * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when + * the last step cherry picks the 2nd arg, we get a zero. + */ +#define __ARG_PLACEHOLDER_1 0, +#define config_enabled(cfg) _config_enabled(cfg) +#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value) +#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0) +#define ___config_enabled(__ignored, val, ...) val + +/* + * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0 + * otherwise. + */ +#define IS_ENABLED(option) config_enabled(option) + +#endif /* __XEN_KCONFIG_H */