From nobody Thu Feb 16 11:56:39 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PHYMD1nRhz3q5vd; Thu, 16 Feb 2023 11:56:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PHYMC6wfcz4CZd; Thu, 16 Feb 2023 11:56:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nZTWJq0DiVLJ72rC2sWWm8dTH5w9akSi4hKBmn9Nasc=; b=POsjQaD8Zo49UZ9WdFSN8NEhsDgsJjV11hzIX84QWvHN0RYZKY5/14pRd9xrFYkW1J6TTK C+dsbJT9rzRY6HQsCnKCTmB4gpV6unzGXkJroaTcosq5c2E8gwy1msTNUv0Y4KfPA52AFt cPcW8RAHw3KzkOW8OmF5VcJcKv1ZSTnWLpaS/0XR9iF84b14B506JKLnQWM9gheBT4lSzq PQwxbGF52acBu4OZJ93maYU0l+VoRB51SGGRfAar9SEq0JzEumseI+y5HcKriihN0L/NLs 1OxN6smMsIbRRe9FHueOduxraCJPAfXP6nuuObiPAQUoTbg+OWpZ0AxX5e7EEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548600; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=nZTWJq0DiVLJ72rC2sWWm8dTH5w9akSi4hKBmn9Nasc=; b=iEn+WXIzLOo2Hk/tAzJMP+v/C/mgG+ezvkqPVXvkEXuNua+V6Ychz1P1nUNAfpLY5kPiE7 0s+tE2/mgVtZynQYLK93GzxbUgAHOBdfmCKrVUeg+qmcWfcmfETX1W/LP6vdAL1veA6upR seOWLEKyNpGix6x1qGWmZfmegKdjwtCci/em2zguBRbFzUU0yysFjqB2Yyfkep/Wr0LUmG 2O9xmsEs9FgTb4kBHi8c7z0toHuBjfRmgTvJQvUJTnuY34PQNgi6LnZq9RdzZk5O5QG3Az gSF+1xSUg1CWwjOGnNeEoJaJPtKUlgtnDRIE++jIwipBZeOPdtfDrVpODybGcA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676548600; a=rsa-sha256; cv=none; b=RwKhDZkBpOMmf6wXbSyYrs7Atftv5DCJtk+T62BadUJ1WsWQkwLN3zxPhgZ5Fc4f6zxOp/ a9twtxf0d7hy2aj4rAhSe9c6JjV/vWtYN33A8Zhgd0pLGvErlL7T5HwuX4PaikR26yBi+k JVWZ3RwqhI3bsxVLE/SvSJG4co80EPeOhsuKE3MYwe1nM7e1fpO5kTTUnZ6CXdDgobRDrn pjSwNFdP0ok20sZMLVnxiNkYjIDnOiRn2nPYiZ9/IlgB4HyHlu/DC1Wn371y8D/+8nUeE4 IHIDaY0dpE6uCnktVDpPoOyitIVSyTu10rEP+cCk7ImA1BeJcYTjzaPRQiFc/w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PHYMC61znz137m; Thu, 16 Feb 2023 11:56:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31GBuds0056521; Thu, 16 Feb 2023 11:56:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31GBudRB056520; Thu, 16 Feb 2023 11:56:39 GMT (envelope-from git) Date: Thu, 16 Feb 2023 11:56:39 GMT Message-Id: <202302161156.31GBudRB056520@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 070d7997501f - stable/13 - linuxkpi: Move `IS_ENABLED()` and friends to List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 070d7997501f39ec351e2872b86407dacc12bc8a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=070d7997501f39ec351e2872b86407dacc12bc8a commit 070d7997501f39ec351e2872b86407dacc12bc8a Author: Jean-Sébastien Pédron AuthorDate: 2023-02-13 20:52:08 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-02-16 11:55:21 +0000 linuxkpi: Move `IS_ENABLED()` and friends to The header is included in like it is on Linux. Some DRM code depends on this header "pollution". Reviewed by: bz Approved by: bz Differential Revision: https://reviews.freebsd.org/D38567 (cherry picked from commit 4b0552d5f4ea0bd09d7f0f178810886472e84d63) --- sys/compat/linuxkpi/common/include/linux/kconfig.h | 78 ++++++++++++++++++++++ sys/compat/linuxkpi/common/include/linux/kernel.h | 43 +----------- sys/compat/linuxkpi/common/include/linux/xarray.h | 1 + 3 files changed, 80 insertions(+), 42 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kconfig.h b/sys/compat/linuxkpi/common/include/linux/kconfig.h new file mode 100644 index 000000000000..b109d664ce8f --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/kconfig.h @@ -0,0 +1,78 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 The FreeBSD Foundation + * + * This software was developed by Björn Zeeb under sponsorship from + * the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _LINUXKPI_LINUX_KCONFIG_H_ +#define _LINUXKPI_LINUX_KCONFIG_H_ + +/* + * Checking if an option is defined would be easy if we could do CPP inside CPP. + * The defined case whether -Dxxx or -Dxxx=1 are easy to deal with. In either + * case the defined value is "1". A more general -Dxxx= case will require + * more effort to deal with all possible "true" values. Hope we do not have + * to do this as well. + * The real problem is the undefined case. To avoid this problem we do the + * concat/varargs trick: "yyy" ## xxx can make two arguments if xxx is "1" + * by having a #define for yyy_1 which is "ignore,". + * Otherwise we will just get "yyy". + * Need to be careful about variable substitutions in macros though. + * This way we make a (true, false) problem a (don't care, true, false) or a + * (don't care true, false). Then we can use a variadic macro to only select + * the always well known and defined argument #2. And that seems to be + * exactly what we need. Use 1 for true and 0 for false to also allow + * #if IS_*() checks pre-compiler checks which do not like #if true. + */ +#define ___XAB_1 dontcare, +#define ___IS_XAB(_ignore, _x, ...) (_x) +#define __IS_XAB(_x) ___IS_XAB(_x 1, 0) +#define _IS_XAB(_x) __IS_XAB(__CONCAT(___XAB_, _x)) + +/* This is if CONFIG_ccc=y. */ +#define IS_BUILTIN(_x) _IS_XAB(_x) +/* This is if CONFIG_ccc=m. */ +#define IS_MODULE(_x) _IS_XAB(_x ## _MODULE) +/* This is if CONFIG_ccc is compiled in(=y) or a module(=m). */ +#define IS_ENABLED(_x) (IS_BUILTIN(_x) || IS_MODULE(_x)) +/* + * This is weird case. If the CONFIG_ccc is builtin (=y) this returns true; + * or if the CONFIG_ccc is a module (=m) and the caller is built as a module + * (-DMODULE defined) this returns true, but if the callers is not a module + * (-DMODULE not defined, which means caller is BUILTIN) then it returns + * false. In other words, a module can reach the kernel, a module can reach + * a module, but the kernel cannot reach a module, and code never compiled + * cannot be reached either. + * XXX -- I'd hope the module-to-module case would be handled by a proper + * module dependency definition (MODULE_DEPEND() in FreeBSD). + */ +#define IS_REACHABLE(_x) (IS_BUILTIN(_x) || \ + (IS_MODULE(_x) && IS_BUILTIN(MODULE))) + +#endif /* _LINUXKPI_LINUX_KCONFIG_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index aee299efa732..22b25a202395 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -760,46 +761,4 @@ mac_pton(const char *macin, uint8_t *macout) #define DECLARE_FLEX_ARRAY(_t, _n) \ struct { struct { } __dummy_ ## _n; _t _n[0]; } -/* - * Checking if an option is defined would be easy if we could do CPP inside CPP. - * The defined case whether -Dxxx or -Dxxx=1 are easy to deal with. In either - * case the defined value is "1". A more general -Dxxx= case will require - * more effort to deal with all possible "true" values. Hope we do not have - * to do this as well. - * The real problem is the undefined case. To avoid this problem we do the - * concat/varargs trick: "yyy" ## xxx can make two arguments if xxx is "1" - * by having a #define for yyy_1 which is "ignore,". - * Otherwise we will just get "yyy". - * Need to be careful about variable substitutions in macros though. - * This way we make a (true, false) problem a (don't care, true, false) or a - * (don't care true, false). Then we can use a variadic macro to only select - * the always well known and defined argument #2. And that seems to be - * exactly what we need. Use 1 for true and 0 for false to also allow - * #if IS_*() checks pre-compiler checks which do not like #if true. - */ -#define ___XAB_1 dontcare, -#define ___IS_XAB(_ignore, _x, ...) (_x) -#define __IS_XAB(_x) ___IS_XAB(_x 1, 0) -#define _IS_XAB(_x) __IS_XAB(__CONCAT(___XAB_, _x)) - -/* This is if CONFIG_ccc=y. */ -#define IS_BUILTIN(_x) _IS_XAB(_x) -/* This is if CONFIG_ccc=m. */ -#define IS_MODULE(_x) _IS_XAB(_x ## _MODULE) -/* This is if CONFIG_ccc is compiled in(=y) or a module(=m). */ -#define IS_ENABLED(_x) (IS_BUILTIN(_x) || IS_MODULE(_x)) -/* - * This is weird case. If the CONFIG_ccc is builtin (=y) this returns true; - * or if the CONFIG_ccc is a module (=m) and the caller is built as a module - * (-DMODULE defined) this returns true, but if the callers is not a module - * (-DMODULE not defined, which means caller is BUILTIN) then it returns - * false. In other words, a module can reach the kernel, a module can reach - * a module, but the kernel cannot reach a module, and code never compiled - * cannot be reached either. - * XXX -- I'd hope the module-to-module case would be handled by a proper - * module dependency definition (MODULE_DEPEND() in FreeBSD). - */ -#define IS_REACHABLE(_x) (IS_BUILTIN(_x) || \ - (IS_MODULE(_x) && IS_BUILTIN(MODULE))) - #endif /* _LINUXKPI_LINUX_KERNEL_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/xarray.h b/sys/compat/linuxkpi/common/include/linux/xarray.h index 8a9d8fa3ea41..004efebc55d6 100644 --- a/sys/compat/linuxkpi/common/include/linux/xarray.h +++ b/sys/compat/linuxkpi/common/include/linux/xarray.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include