From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 96DF6459C6; Wed, 18 Sep 2024 11:14:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7313242E57; Wed, 18 Sep 2024 11:14:11 +0200 (CEST) Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2044.outbound.protection.outlook.com [40.107.104.44]) by mails.dpdk.org (Postfix) with ESMTP id 3599B4025C for ; Wed, 18 Sep 2024 11:14:08 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=XABxzAutX9oBdtirPEtytqU4pRhyyj6TyZZIf1k6TFC4UclvFm1UdHTl6aVh92qbqCLKjdhAPvjqDtqMy2ycR1M/Qcakpy3vGvBRpjGLejo0fXtJg9r5XyAsn7tEqDPPFAuppUXycSilTQaPhMXtcj0SOXNc0kZES2siIXlutgtnxi/4q87Z2220MN4QRsOWNydbCmLZBC7QJf3Gj9k8Tm5brVj8LhJ/2g1f74Ha7XZ46eHi5HGWH3ac3qaopLgdIpMGGn1wYoNLf0Rx8jJauXmZ+6wNGYPwj6CQWEAMvk+XKFDY/6gbcMoZYpmQVDmCUMN4PHL06hifrHOfdzUK/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5UKgQdVaciDeShGgGbM6oo5b5b9ozFm128R5ONKGWa0=; b=egwSnYRPcFTmDtEEohOCX98xMrsIZlKiq0dakiTN3zCL75baKseGgGVOrJkeBcbyl2gy8Cq7dRhUECC58Rs5k9bQkHD8k/EnSCwhC9TKu/eACtLoOGAPnWO527kIxNY0nIomxdNl/LzRM5ZNVg1DrEEp5bWmA8gv8GhUl7qapcIzseLhzVBeRpkTLlizIn55twpWasj9NdM+sJcaoF2n+cVOW5B4Db/u3zEfy1JVXWZDNF/37OWBLqfFrROCjQNhX/FV8vuQWVoimaPk+7DIN2+l9O5Tdp3rSOjjzSAFJIJFvIOFF6wIE9zU+ehJS88IZnPTkR1ShfHUhKvx7oKpxw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 192.176.1.74) smtp.rcpttodomain=dpdk.org smtp.mailfrom=ericsson.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=ericsson.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericsson.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5UKgQdVaciDeShGgGbM6oo5b5b9ozFm128R5ONKGWa0=; b=yR6Ry8OnDI8IW9om/56Eug5tbcnBY5Wc0Vu9Z7z2XvaGvj0Tq79RM4b7dQ2mx35+iizTn4lbbjX/jwgsdJ4ZgmMnRd83FHE2nnGWdrHtBWVU6AnN6N3qTiKzeLUMM6AMQzgUeWdCCvAlmd5TD034cTHXm/Ku7RgwYN3Nt3DqmC7ldDNc/9hIQz/ES11W12MQEQFzMAZAhVhf+hHd83hPj9IosD07YJ4yQejL5OCHZl3K3zWb6eKXPIXVBC1I1AX9oxixSPUvCJ2ItDb/mf4WoY3puwFZ/Mm+7JS/VJ6Nl7fUqQ4LQcs1QopfM7d9s4yv9Vil6Q/AyTpZFlW3Qa8YLw== Received: from AS4P189CA0041.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5dd::15) by PR3PR07MB6602.eurprd07.prod.outlook.com (2603:10a6:102:66::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.24; Wed, 18 Sep 2024 09:14:03 +0000 Received: from AM4PEPF00027A5D.eurprd04.prod.outlook.com (2603:10a6:20b:5dd:cafe::d5) by AS4P189CA0041.outlook.office365.com (2603:10a6:20b:5dd::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Wed, 18 Sep 2024 09:14:03 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 192.176.1.74) smtp.mailfrom=ericsson.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=ericsson.com; Received-SPF: Pass (protection.outlook.com: domain of ericsson.com designates 192.176.1.74 as permitted sender) receiver=protection.outlook.com; client-ip=192.176.1.74; helo=oa.msg.ericsson.com; pr=C Received: from oa.msg.ericsson.com (192.176.1.74) by AM4PEPF00027A5D.mail.protection.outlook.com (10.167.16.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Wed, 18 Sep 2024 09:14:03 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.62) with Microsoft SMTP Server id 15.2.1544.11; Wed, 18 Sep 2024 11:14:03 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 14A21380061; Wed, 18 Sep 2024 11:14:03 +0200 (CEST) From: =?UTF-8?q?Mattias=20R=C3=B6nnblom?= To: CC: , Heng Wang , "Stephen Hemminger" , Tyler Retzlaff , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Jack Bond-Preston , David Marchand , Chengwen Feng , =?UTF-8?q?Mattias=20R=C3=B6nnblom?= Subject: [PATCH v9 2/6] eal: extend bit manipulation functionality Date: Wed, 18 Sep 2024 11:04:41 +0200 Message-ID: <20240918090445.725283-3-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918090445.725283-1-mattias.ronnblom@ericsson.com> References: <20240917104811.723863-2-mattias.ronnblom@ericsson.com> <20240918090445.725283-1-mattias.ronnblom@ericsson.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM4PEPF00027A5D:EE_|PR3PR07MB6602:EE_ X-MS-Office365-Filtering-Correlation-Id: cd4e618d-d901-4eb2-fe06-08dcd7c23d96 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|376014|82310400026|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?S3pYTGVRR2s4N0NZNksvK0hnbWJIaHJONDVBWjQwU29ES3dNclR1WXlyNTRU?= =?utf-8?B?UW1lMzh1cGRRRC9DSVkydFcrTDB1bmNZbkVTQUtsejhyeTBickRjUkdNM1dh?= =?utf-8?B?blU5Tk5lQ2U3MUVaZWZlWGw4ZFJuZFdFSlMzMW9yQjJSVzZoVE9LSU43OVR5?= =?utf-8?B?eWFwTGlVWThvRzdVRXZyYXJybXVmTmdzWk1SNnFnVXdRNWRpb3lpRnNWQU5S?= =?utf-8?B?T2ZkM3gwOVEwNmdkZ21sampyR2N4RjRUQVBrQXk5QjBNc2J1aFoyeXd3Tk1G?= =?utf-8?B?eERaSmRVdi9iRGZUa0drZk9iVXVGbmRhVUJHUFVXbzBJK29uMENxcG1SWE41?= =?utf-8?B?MW5oN2hRUTk0TFBuYzJCWHNvcUJML2h0bE8wNVRZZDVYMkVRNUM3SmFiY1Fq?= =?utf-8?B?TVVWNURnV1BySjVRcEY5cGpWSWcxNlJJa093S1hrdFg3bkt0U1ovdC92WkZG?= =?utf-8?B?OG9COWZDQ0t3OWZJYnFUdjhxY2pZd2RaZWNXTHRzb0prOThwc2pXL29UcDl2?= =?utf-8?B?MTd3bzdnVDZhdmpMVEpkcmw4bUtxSmRxVVBHZ05mdzNBYm1FZWp6T2gvOFJT?= =?utf-8?B?QndiQkVEZDFKMXFJOEFTYXdueUxNVlVXVG1vVVlLbTl4OURHekh5WjkyTGNo?= =?utf-8?B?aWJieHJVc29JZEtOcVpKQUVUR1RneTNGTWFsSHZ5UXkyVUV4SnZPaVd3N091?= =?utf-8?B?Q3FPWkQyMVVrNCtGYktUNXhxNjROcjdwdTMyYktjOStjb0lLaGtYY3NMY09Z?= =?utf-8?B?MHJhVTBrcGYwRXhMS1hqVUxiUGpLcUZ4YkphS0lvcVBiZm5RTUh6aXE1bllS?= =?utf-8?B?Mndoa1Fkb1c1Q2hMWkdWcW1TWW9IZlhRMUZ0MW0zWlhwSUhKdGl4USt4ZGJ4?= =?utf-8?B?UkJRc0xrbmU4SHV0OUpQVDY1UkRDV3NCQ0k3UUlvZ2xqTG1id1QrVlVVNTVR?= =?utf-8?B?cDlWaXNReFJiMHUwTzFMMDNSanFNQ2VCY1cxUjN5UnBzK3lxbGhFUHpoMDda?= =?utf-8?B?SHNvcm02YmdyOSt3SzVCaHlXOWk2VXV1VXFEZ243L293YmZ5aGZmbTB2SUNn?= =?utf-8?B?RE05bU9JVmc5aE96b3p0SkZyQjlhdG5mSVlwS0FsMGxXZXZxZTg0cHNIYlFs?= =?utf-8?B?OGVSMDJSY1pHb3J6WUt1cXJUUEg1STVXZXZrTnZ6Qkc4cHZKVExZaU5tZVph?= =?utf-8?B?K3pOZURocmpQMUJVVmxXMXZSSHo2MUY5ZUJITDN5Y1M2L05iT0UrRDQxeUs2?= =?utf-8?B?UVVpOXZ3WUJjbG50VHlPYlF6M3hhSlhpNEFhVFJoMWZRcmxCczBxUk5OODc5?= =?utf-8?B?UEZiTmUxSnBCZzhlbFBmZjdqUXA4SVo0cmRCaVZsR3VvazBZazJxZUdTZWky?= =?utf-8?B?VmdaazIrZUFiMUVlSGhlUVQ5a1N4dlNoZXpZVkErcElBWmwybkkxalJrY2wz?= =?utf-8?B?QmZMUFRtL1NrK0t5ZnpsMHBzVkJ1cmMxWUFIWWhxdmdaNTZDQ3pjU3ZFaCtr?= =?utf-8?B?R2dPRlZ4RjF1Nk1FMzFQQlNyRmZjVlNPOVhPSEUrN3dQdVJKblJSaVM4MUYx?= =?utf-8?B?THBvWEpBTzFtN1RXdnEvRlZ4MFVITFBtK08wejZITnpVcjFrYmF5anN3U2xI?= =?utf-8?B?VlpsUXdEYi9KTkRDWW5ieFNGNVRmYVNyWENkc2llN3R2dmkwS0dmVi84dWZN?= =?utf-8?B?WnZEaHNtclFlREM3cndVUWhiOTdQRkI0dEZ1ZmQ1a25uVEo2cUxjd2lCODd0?= =?utf-8?B?ZlV5NEtleW4zM3Y0LzJFRWp1WDJGYTVnK2R1d1VhRUNTR3QrSUptZEJXVEdW?= =?utf-8?B?czc3ZnlXOU9MaEh5M2FqOXNLS1RqbDBLbWNOaTRqUTYrYXMvQmFQQ0M0ejZ4?= =?utf-8?Q?a7GlHvkhyhhe6?= X-Forefront-Antispam-Report: CIP:192.176.1.74; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:oa.msg.ericsson.com; PTR:office365.se.ericsson.net; CAT:NONE; SFS:(13230040)(36860700013)(376014)(82310400026)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Sep 2024 09:14:03.6075 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd4e618d-d901-4eb2-fe06-08dcd7c23d96 X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=92e84ceb-fbfd-47ab-be52-080c6b87953f; Ip=[192.176.1.74]; Helo=[oa.msg.ericsson.com] X-MS-Exchange-CrossTenant-AuthSource: AM4PEPF00027A5D.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR07MB6602 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add functionality to test and modify the value of individual bits in 32-bit or 64-bit words. These functions have no implications on memory ordering, atomicity and does not use volatile and thus does not prevent any compiler optimizations. Signed-off-by: Mattias Rönnblom Acked-by: Morten Brørup Acked-by: Tyler Retzlaff Acked-by: Jack Bond-Preston -- PATCH v3: * Remove unnecessary include. * Remove redundant 'fun' parameter from the __RTE_GEN_BIT_*() macros (Jack Bond-Preston). * Introduce __RTE_BIT_BIT_OPS() macro, consistent with how things are done when generating the atomic bit operations. * Refer to volatile bit op functions as variants instead of families (macro parameter naming). RFC v6: * Have rte_bit_test() accept const-marked bitsets. RFC v4: * Add rte_bit_flip() which, believe it or not, flips the value of a bit. * Mark macro-generated private functions as experimental. * Use macros to generate *assign*() functions. RFC v3: * Work around lack of C++ support for _Generic (Tyler Retzlaff). * Fix ','-related checkpatch warnings. --- lib/eal/include/rte_bitops.h | 260 ++++++++++++++++++++++++++++++++++- 1 file changed, 258 insertions(+), 2 deletions(-) diff --git a/lib/eal/include/rte_bitops.h b/lib/eal/include/rte_bitops.h index 449565eeae..6915b945ba 100644 --- a/lib/eal/include/rte_bitops.h +++ b/lib/eal/include/rte_bitops.h @@ -2,6 +2,7 @@ * Copyright(c) 2020 Arm Limited * Copyright(c) 2010-2019 Intel Corporation * Copyright(c) 2023 Microsoft Corporation + * Copyright(c) 2024 Ericsson AB */ #ifndef _RTE_BITOPS_H_ @@ -11,12 +12,14 @@ * @file * Bit Operations * - * This file defines a family of APIs for bit operations - * without enforcing memory ordering. + * This file provides functionality for low-level, single-word + * arithmetic and bit-level operations, such as counting or + * setting individual bits. */ #include +#include #include #ifdef __cplusplus @@ -105,6 +108,197 @@ extern "C" { #define RTE_FIELD_GET64(mask, reg) \ ((typeof(mask))(((reg) & (mask)) >> rte_ctz64(mask))) +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Test bit in word. + * + * Generic selection macro to test the value of a bit in a 32-bit or + * 64-bit word. The type of operation depends on the type of the @c + * addr parameter. + * + * This macro does not give any guarantees in regards to memory + * ordering or atomicity. + * + * @param addr + * A pointer to the word to modify. + * @param nr + * The index of the bit. + */ +#define rte_bit_test(addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_test32, \ + const uint32_t *: __rte_bit_test32, \ + uint64_t *: __rte_bit_test64, \ + const uint64_t *: __rte_bit_test64)(addr, nr) + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Set bit in word. + * + * Generic selection macro to set a bit in a 32-bit or 64-bit + * word. The type of operation depends on the type of the @c addr + * parameter. + * + * This macro does not give any guarantees in regards to memory + * ordering or atomicity. + * + * @param addr + * A pointer to the word to modify. + * @param nr + * The index of the bit. + */ +#define rte_bit_set(addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_set32, \ + uint64_t *: __rte_bit_set64)(addr, nr) + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Clear bit in word. + * + * Generic selection macro to clear a bit in a 32-bit or 64-bit + * word. The type of operation depends on the type of the @c addr + * parameter. + * + * This macro does not give any guarantees in regards to memory + * ordering or atomicity. + * + * @param addr + * A pointer to the word to modify. + * @param nr + * The index of the bit. + */ +#define rte_bit_clear(addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_clear32, \ + uint64_t *: __rte_bit_clear64)(addr, nr) + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Assign a value to a bit in word. + * + * Generic selection macro to assign a value to a bit in a 32-bit or 64-bit + * word. The type of operation depends on the type of the @c addr parameter. + * + * This macro does not give any guarantees in regards to memory + * ordering or atomicity. + * + * @param addr + * A pointer to the word to modify. + * @param nr + * The index of the bit. + * @param value + * The new value of the bit - true for '1', or false for '0'. + */ +#define rte_bit_assign(addr, nr, value) \ + _Generic((addr), \ + uint32_t *: __rte_bit_assign32, \ + uint64_t *: __rte_bit_assign64)(addr, nr, value) + +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice. + * + * Flip a bit in word. + * + * Generic selection macro to change the value of a bit to '0' if '1' + * or '1' if '0' in a 32-bit or 64-bit word. The type of operation + * depends on the type of the @c addr parameter. + * + * This macro does not give any guarantees in regards to memory + * ordering or atomicity. + * + * @param addr + * A pointer to the word to modify. + * @param nr + * The index of the bit. + */ +#define rte_bit_flip(addr, nr) \ + _Generic((addr), \ + uint32_t *: __rte_bit_flip32, \ + uint64_t *: __rte_bit_flip64)(addr, nr) + +#define __RTE_GEN_BIT_TEST(variant, qualifier, size) \ + __rte_experimental \ + static inline bool \ + __rte_bit_ ## variant ## test ## size(const qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + return *addr & mask; \ + } + +#define __RTE_GEN_BIT_SET(variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## set ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = (uint ## size ## _t)1 << nr; \ + *addr |= mask; \ + } \ + +#define __RTE_GEN_BIT_CLEAR(variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## clear ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + RTE_ASSERT(nr < size); \ + \ + uint ## size ## _t mask = ~((uint ## size ## _t)1 << nr); \ + (*addr) &= mask; \ + } \ + +#define __RTE_GEN_BIT_ASSIGN(variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## assign ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr, bool value) \ + { \ + if (value) \ + __rte_bit_ ## variant ## set ## size(addr, nr); \ + else \ + __rte_bit_ ## variant ## clear ## size(addr, nr); \ + } + +#define __RTE_GEN_BIT_FLIP(variant, qualifier, size) \ + __rte_experimental \ + static inline void \ + __rte_bit_ ## variant ## flip ## size(qualifier uint ## size ## _t *addr, \ + unsigned int nr) \ + { \ + bool value; \ + \ + value = __rte_bit_ ## variant ## test ## size(addr, nr); \ + __rte_bit_ ## variant ## assign ## size(addr, nr, !value); \ + } + +#define __RTE_GEN_BIT_OPS(v, qualifier, size) \ + __RTE_GEN_BIT_TEST(v, qualifier, size) \ + __RTE_GEN_BIT_SET(v, qualifier, size) \ + __RTE_GEN_BIT_CLEAR(v, qualifier, size) \ + __RTE_GEN_BIT_ASSIGN(v, qualifier, size) \ + __RTE_GEN_BIT_FLIP(v, qualifier, size) + +#define __RTE_GEN_BIT_OPS_SIZE(size) \ + __RTE_GEN_BIT_OPS(,, size) + +__RTE_GEN_BIT_OPS_SIZE(32) +__RTE_GEN_BIT_OPS_SIZE(64) + /*------------------------ 32-bit relaxed operations ------------------------*/ /** @@ -787,6 +981,68 @@ rte_log2_u64(uint64_t v) #ifdef __cplusplus } + +/* + * Since C++ doesn't support generic selection (i.e., _Generic), + * function overloading is used instead. Such functions must be + * defined outside 'extern "C"' to be accepted by the compiler. + */ + +#undef rte_bit_test +#undef rte_bit_set +#undef rte_bit_clear +#undef rte_bit_assign +#undef rte_bit_flip + +#define __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, size, arg1_type, arg1_name) \ + static inline void \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2(fun, qualifier, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 32, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2(fun, qualifier, 64, arg1_type, arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, size, ret_type, arg1_type, \ + arg1_name) \ + static inline ret_type \ + rte_bit_ ## fun(qualifier uint ## size ## _t *addr, \ + arg1_type arg1_name) \ + { \ + return __rte_bit_ ## fun ## size(addr, arg1_name); \ + } + +#define __RTE_BIT_OVERLOAD_2R(fun, qualifier, ret_type, arg1_type, arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 32, ret_type, arg1_type, \ + arg1_name) \ + __RTE_BIT_OVERLOAD_SZ_2R(fun, qualifier, 64, ret_type, arg1_type, \ + arg1_name) + +#define __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, size, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + static inline void \ + rte_bit_ ## fun(uint ## size ## _t *addr, arg1_type arg1_name, \ + arg2_type arg2_name) \ + { \ + __rte_bit_ ## fun ## size(addr, arg1_name, arg2_name); \ + } + +#define __RTE_BIT_OVERLOAD_3(fun, qualifier, arg1_type, arg1_name, arg2_type, \ + arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 32, arg1_type, arg1_name, \ + arg2_type, arg2_name) \ + __RTE_BIT_OVERLOAD_SZ_3(fun, qualifier, 64, arg1_type, arg1_name, \ + arg2_type, arg2_name) + +__RTE_BIT_OVERLOAD_2R(test, const, bool, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(set,, unsigned int, nr) +__RTE_BIT_OVERLOAD_2(clear,, unsigned int, nr) +__RTE_BIT_OVERLOAD_3(assign,, unsigned int, nr, bool, value) +__RTE_BIT_OVERLOAD_2(flip,, unsigned int, nr) + #endif #endif /* _RTE_BITOPS_H_ */ -- 2.34.1