From patchwork Mon Jul 10 08:51:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 13306489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 781B8EB64D9 for ; Mon, 10 Jul 2023 08:51:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.561088.877391 (Exim 4.92) (envelope-from ) id 1qImcY-0005JL-Q4; Mon, 10 Jul 2023 08:51:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 561088.877391; Mon, 10 Jul 2023 08:51:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qImcY-0005JC-Lz; Mon, 10 Jul 2023 08:51:50 +0000 Received: by outflank-mailman (input) for mailman id 561088; Mon, 10 Jul 2023 08:51:49 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qImcX-0005Iv-Qk for xen-devel@lists.xenproject.org; Mon, 10 Jul 2023 08:51:49 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0616.outbound.protection.outlook.com [2a01:111:f400:fe0c::616]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 01668577-1eff-11ee-b239-6b7b168915f2; Mon, 10 Jul 2023 10:51:48 +0200 (CEST) Received: from AS8PR04MB8788.eurprd04.prod.outlook.com (2603:10a6:20b:42f::21) by AS4PR04MB9315.eurprd04.prod.outlook.com (2603:10a6:20b:4e6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.29; Mon, 10 Jul 2023 08:51:46 +0000 Received: from AS8PR04MB8788.eurprd04.prod.outlook.com ([fe80::cbc0:69aa:c9a2:198e]) by AS8PR04MB8788.eurprd04.prod.outlook.com ([fe80::cbc0:69aa:c9a2:198e%7]) with mapi id 15.20.6565.016; Mon, 10 Jul 2023 08:51:46 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 01668577-1eff-11ee-b239-6b7b168915f2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=boDeWuly+CArVxcmaeYsFzKsPDXCvc5MRTx6r1Ccapry0XZHNmgdMumajk9xRITRvNAHB1GnWOnxzrGpLzs0XJvyw3sjw9vdYYtbTrNJP7gqIfKlojLsFJLqGJbc81qoAaQWLzE/MShv2YsKTysxKY6VaYd36HkBPTpbxiwNkDoAxl61wQhsmBILzGfZcJxFVkjd2GbhYh8gI6v/G9qrzdCIiL0VIKFw3wg8rfSynRsDtphc591zU6ja5+rHoDxS9vzKn7bCK/r69X3/3TYS0YeKJ3Dafb1yLBGYL+Fz8YqAY4Sq1CsjC3rR735bbLa+L4+IRRai+mK4SZzcI9BtXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tEZqfEecVCoAUXwOun3bnx9/68WK0/jJ2cWnhbpIMB4=; b=PF6xwndGerjT8tw/LkfWcGZvKVmwzQie0114bTUZj1VOlqH/bmAz7HYgWW7hMmiBgFgU0tIkO/yjTtQ358Zn+CRzKjKolvGvcG6PDMhB6uHp5sttfM2YB/uZXhq81+H2Z+Ng6uoBIs35PfnmcFN9js25yqRz09qpkkOKW2IZEgUvl1mDLUtzE8XOnvjZTsNUZMOrOQEXe9W1EzZ8ZnbwAjchIlOuKuAEH0lt+LMl0tcKWlku9TWSADxgD5TDfU7LNeHUKpYADYQfTWgjx5ME+SeN9pYypJlLYTBlWpvrzuJc84bwCSdHAt6LOyhRzmke56Hl14N9XNRjYs7gwdmXuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tEZqfEecVCoAUXwOun3bnx9/68WK0/jJ2cWnhbpIMB4=; b=r4HjOhRjApcM5FmymXKsMvObQOvyu9f13oaaqCEnXaLo12sIz4mFmAUwqcut376jyD2Zef5UFdeyWArb5fAdMj0mZusmkCyWV8sBHj8rAALwvcu4wXRdKR4u//uyIjLiqgaYThrsefLdsToNTJ7sfWDivXD5bd4/hdJpQHK9N6MaiKV0bngpY7sahg7kMBgRlb0W3ZUJECrAMG8hDcoUB2NbvM5i56zRKkpNYdjUANl66vAl+idvrLu4xzf4aO9zZJpHqMzusu2K9Eu18UKdwWvn6iFjSsIhLM86PNBE7Bv5r4ZQ06CSWyeUzkRZYhNkPqI39iMlOy3Lv6fhZFcG+w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Message-ID: <109efb43-a519-73f6-2a26-2b420090ab2b@suse.com> Date: Mon, 10 Jul 2023 10:51:45 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: [PATCH v3 1/8] common: move a few macros out of xen/lib.h Content-Language: en-US From: Jan Beulich To: "xen-devel@lists.xenproject.org" Cc: Andrew Cooper , Wei Liu , Julien Grall , Stefano Stabellini , George Dunlap References: In-Reply-To: X-ClientProxiedBy: FR2P281CA0117.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9d::7) To AS8PR04MB8788.eurprd04.prod.outlook.com (2603:10a6:20b:42f::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8788:EE_|AS4PR04MB9315:EE_ X-MS-Office365-Filtering-Correlation-Id: 29d5f7fb-262d-4b15-2534-08db8122e498 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6vWreUL6Zd5iA+zK4pxxSyIOGGKfsuQt5MUGif/pKDea0KefKenLB8eieNCWIa9MK2fUTQTWvYrWtY2OByGhlxs8dqr0gjcI93WO0GArl6nC4/gYTo6RXrIHDiGTmqQGNaZkGXUv+3ztpXA77ADopESSgC2mVy0AzxKXuI4WJLUrmW5aDvFQ/Q33twwyq6CPGFfyLZXJ1GxhNY29jMu1y03RO+X8Rm/x/G6XiIU5FN+CUc9oed2PFrD2Vzm06Sg1HhyHDE3l8fEZu06rIW2o4kVvBnoa5D+KF3STwT9s8YBCvNY5ftAs5oDUwSTisiPcoFNtyeWJR+9zGQmc/31EjWmdyGYwBisVAORtCt/6TT6PIHDT/38RbvivDqq3FSHBAmVubZhU8q+DDbtfboIYJkI5cpoNL0jDDfR5HFZlcZge6DODQJU8LHpyLITqOb5W7D62Cp8F4+ljq9xp7qJBNaKeVyOqbbVAtYe7Xnu6AtTY0NPQAzs49m+b6brlYmRGqMAkaNbWKzt4VWKmUW8nVxBklw3ZLqYgQp/reqjhuhZmjThahQRQLjxsMPCrhrixzTMzfuzR0KySJ/xai5PzvVJc+9TbH3kXA+I7avtyM1Nga3cVxJtF3e3SUC0UiohHhVySUs+bD2/D5IcNf4Y6UA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR04MB8788.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(366004)(396003)(346002)(39860400002)(136003)(376002)(451199021)(31686004)(478600001)(4326008)(54906003)(2616005)(86362001)(31696002)(36756003)(2906002)(26005)(6512007)(6506007)(6486002)(186003)(38100700002)(66556008)(5660300002)(316002)(41300700001)(8936002)(66476007)(66946007)(8676002)(6916009)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?LHqge01mVVpCTYvgqq50FM986bgg?= =?utf-8?q?B0j3fxClf4628q3HbZZ4xgu1SvQOhSz63qDgnB6GJEQfaGA2eIHDDNngZo51WK3Va?= =?utf-8?q?zHUQi+9/ypj+NYqkvS3n0Mb9oAO3ZHnGQjWJYbga+79+x4J/lpcCbuf48SvLyqEWV?= =?utf-8?q?gqM/Pk3/ObaAGOtTQaa+ZHzGpRIZb+dJbQFgizz1N622aUR88ONaQX9RtPDjw618Y?= =?utf-8?q?LFErudd4VqEdCftNAM2hQgqXWKPlxJAEpGVCeUW1aWbsOUb3OPdaOrDWcXGFgZ0zw?= =?utf-8?q?dPcLWqElQO/Q1MASiGwjqGCY5eyI+JNhcmC1A1BZuaTOfTdQ1l7uixerGARQdIed7?= =?utf-8?q?0EpYQ3evJnRPe8sxvdOofG7S7VlsL+n4vhu5hY/t/2B6OR99iCzdFOtb6sMKztFJK?= =?utf-8?q?X0P4fmbmWhp6u6iEP1cHHr7/QWZYIh1fjlqQyg/JWk4GvwLzIAqeg4L/zDtgyi7tE?= =?utf-8?q?WQpSb1f7ycD9ST6Msds3YMMp7pWk2n8uZgT5bI/s74UwWSSOhSYnraF/lIkkW0TQs?= =?utf-8?q?JkPXhfzv2D4DFgQz2HumDY946k0sqbxFsCs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NBVlAH5sdjy+ClWMlhT?= =?utf-8?q?tRhlGr/qq3wHTFJiZxcpOYWCm909FpBWx/k8YiWwe439IYwfooeG5QVs45ZtjnzMd?= =?utf-8?q?9r7XRju62ZQT?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29d5f7fb-262d-4b15-2534-08db8122e498 X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8788.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2023 08:51:46.7935 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: U4v3w9ptASt+7jWppW4uYPuHow5qQtkVuzmJ5TMXeVoUFksc8KOPnyma5aa8aDjk/EQoc2H4YtJ4+1aHvsiMoA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9315 Introduce xen/macros.h for this purpose. For now xen/lib.h simply includes xen/macro.h, until consumers can be suitable cleaned up. Signed-off-by: Jan Beulich Reviewed-by: Oleksii Kurochko Reviewed-by: Shawn Anastasio --- v3: New. --- a/xen/include/xen/lib.h +++ b/xen/include/xen/lib.h @@ -1,26 +1,7 @@ #ifndef __LIB_H__ #define __LIB_H__ -#define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1)) - -#define IS_ALIGNED(val, align) (!((val) & ((align) - 1))) - -#define DIV_ROUND(n, d) (((n) + (d) / 2) / (d)) -#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) - -#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) -#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) - -#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x -#define count_args(args...) \ - count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) - -/* Indirect macros required for expanded argument pasting. */ -#define PASTE_(a, b) a ## b -#define PASTE(a, b) PASTE_(a, b) - -#define __STR(...) #__VA_ARGS__ -#define STR(...) __STR(__VA_ARGS__) +#include #ifndef __ASSEMBLY__ --- /dev/null +++ b/xen/include/xen/macros.h @@ -0,0 +1,34 @@ +#ifndef __MACROS_H__ +#define __MACROS_H__ + +#define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1)) + +#define IS_ALIGNED(val, align) (!((val) & ((align) - 1))) + +#define DIV_ROUND(n, d) (((n) + (d) / 2) / (d)) +#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) + +#define MASK_EXTR(v, m) (((v) & (m)) / ((m) & -(m))) +#define MASK_INSR(v, m) (((v) * ((m) & -(m))) & (m)) + +#define count_args_(dot, a1, a2, a3, a4, a5, a6, a7, a8, x, ...) x +#define count_args(args...) \ + count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0) + +/* Indirect macros required for expanded argument pasting. */ +#define PASTE_(a, b) a ## b +#define PASTE(a, b) PASTE_(a, b) + +#define __STR(...) #__VA_ARGS__ +#define STR(...) __STR(__VA_ARGS__) + +#endif /* __MACROS_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */