From patchwork Tue Jan 31 15:27:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1734955 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=VSJverNt; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P5pwm0drlz23gV for ; Wed, 1 Feb 2023 02:33:28 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 6A03E85B41; Tue, 31 Jan 2023 16:29:49 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="VSJverNt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8CF4085AEC; Tue, 31 Jan 2023 16:28:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 405F085B09 for ; Tue, 31 Jan 2023 16:28:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x12d.google.com with SMTP id m15so1991418ilh.9 for ; Tue, 31 Jan 2023 07:28:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tQhk8H2s1OkHbMRzkEd7yw2Z5bROF2qYAKUXSC5eUr0=; b=VSJverNtI0IsePRWdZZa4RsBeekCA3m/lvAFXSxUqi6n1CT/DoILP0ZC2btlmDiagM l87Q676QrH++Wi1UdRMOGSpv7HF/x6s7lHQEspzuTIfwaS9rn/MeYUocKy0M2qF6qQqo jj4zAbxNufsQXvKCrDAciIA5Cn8xoxvSxdBqc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tQhk8H2s1OkHbMRzkEd7yw2Z5bROF2qYAKUXSC5eUr0=; b=UyTuq77F4IrheUdVQMyqE5rbRIo0kkiJdcYH9MuSFr1oMwYsMG49bSinT6abWs46Sf 7vhuiEhCyuOkrpdYNZxRhp64Z5ex8iofbaNX7E/m0wShAWHQr3VLqasM+dgDE4swMC4H h3y5K5SA4S7/g2EPkcvwEx3mWt/NiloCcowJke1fEm8NcollQL/ftGsXpQSTna3tlZWz JloytRnUP33fXuAjmPHcTXaLQuuettiIe0cef7mIN6uGfcpi+MLXSu69zBgH7c+35UDi 0/EdOnCz/W8wHoZ9lbt+D9CUSWkaoCA3kwXeREEBPz9Z8DGXLOXPWICkK//iWfE3GiIU 1NEQ== X-Gm-Message-State: AO0yUKUe7AupJwyveo4YVf/x/+z82cohIfJ+7GuYeoSAonkTv5uBxgGO 84PCXBhb5rDBxwKSw1apKKIjctPQOhBWKp9H X-Google-Smtp-Source: AK7set8aHClByMQmUQa9ejc9c/E53LBd2apHoLAWFV1b+DwUz0MZREK8axiw8+WQ52Wgz2pbkY8BUg== X-Received: by 2002:a92:c544:0:b0:310:f912:5a68 with SMTP id a4-20020a92c544000000b00310f9125a68mr5748173ilj.3.1675178885240; Tue, 31 Jan 2023 07:28:05 -0800 (PST) Received: from sjg1.lan (c-73-14-173-85.hsd1.co.comcast.net. [73.14.173.85]) by smtp.gmail.com with ESMTPSA id u4-20020a02cb84000000b0039db6cffcbasm5649328jap.71.2023.01.31.07.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 07:28:04 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Masahiro Yamada Subject: [PATCH 31/32] kconfig: Move closer to the Linux version Date: Tue, 31 Jan 2023 08:27:01 -0700 Message-Id: <20230131152702.249197-32-sjg@chromium.org> X-Mailer: git-send-email 2.39.1.456.gfc5497dd1b-goog In-Reply-To: <20230131152702.249197-1-sjg@chromium.org> References: <20230131152702.249197-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This header file originally came from Linux and it has changed a little upstream since. Bring in some of these changes. Note that IS_ENABLED() in U-Boot supports a three-parameter version, so it not equivalent to the Linux version. Signed-off-by: Simon Glass --- include/linux/kconfig.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h index 0cd29cea708..162916b2d68 100644 --- a/include/linux/kconfig.h +++ b/include/linux/kconfig.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __LINUX_KCONFIG_H #define __LINUX_KCONFIG_H @@ -13,6 +14,21 @@ #include #endif +#define __ARG_PLACEHOLDER_1 0, +#define __take_second_arg(__ignored, val, ...) val + +/* + * The use of "&&" / "||" is limited in certain expressions. + * The following enable to calculate "and" / "or" with macro expansion only. + */ +#define __and(x, y) ___and(x, y) +#define ___and(x, y) ____and(__ARG_PLACEHOLDER_##x, y) +#define ____and(arg1_or_junk, y) __take_second_arg(arg1_or_junk y, 0) + +#define __or(x, y) ___or(x, y) +#define ___or(x, y) ____or(__ARG_PLACEHOLDER_##x, y) +#define ____or(arg1_or_junk, y) __take_second_arg(arg1_or_junk 1, y) + /* * Helper macros to use CONFIG_ options in C/CPP expressions. Note that * these only work with boolean and tristate options. @@ -26,11 +42,9 @@ * 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, def_val) _config_enabled(cfg, def_val) -#define _config_enabled(value, def_val) __config_enabled(__ARG_PLACEHOLDER_##value, def_val) -#define __config_enabled(arg1_or_junk, def_val) ___config_enabled(arg1_or_junk 1, def_val) -#define ___config_enabled(__ignored, val, ...) val +#define __is_defined(cfg, def_val) ___is_defined(cfg, def_val) +#define ___is_defined(value, def_val) ____is_defined(__ARG_PLACEHOLDER_##value, def_val) +#define ____is_defined(arg1_or_junk, def_val) __take_second_arg(arg1_or_junk 1, def_val) /* * Count number of arguments to a variadic macro. Currently only need @@ -49,7 +63,7 @@ #define __IS_ENABLED_1(option) __IS_ENABLED_3(option, (1), (0)) #define __IS_ENABLED_2(option, case1) __IS_ENABLED_3(option, case1, ()) #define __IS_ENABLED_3(option, case1, case0) \ - __concat(__unwrap, config_enabled(option, 0)) (case1, case0) + __concat(__unwrap, __is_defined(option, 0)) (case1, case0) /* * IS_ENABLED(CONFIG_FOO) returns 1 if CONFIG_FOO is enabled for the phase being