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 2DBAB459D8; Thu, 19 Sep 2024 21:41:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 716B7433ED; Thu, 19 Sep 2024 21:40:51 +0200 (CEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2063.outbound.protection.outlook.com [40.107.22.63]) by mails.dpdk.org (Postfix) with ESMTP id D3737433D8 for ; Thu, 19 Sep 2024 21:40:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=n1aDDGgaRnxXhsEVlUG9G37KsiFfFGWFwA6BZB4U2jyTbanoNMzU+qjn12bS6ACuPNAyk8ZkyTtAH0lJCi+1EKLCPWwmrJg13bgZtcfr4tkDXZHbd/PI42fAr4XykaLm9E0l/DoOLEurZgJZU9SCoxaKAI5d2frMxB2S7GQhVllGCOGezWqALRLT42gKwomXYwWHKm6mV1F8VbVcO+G5uzSKbuwuE7aZ8YZGZz2dk4cWg1Mnx/PJ9Ec6ioRpEW7wOggo3dxko3I1e0LC07ZuRhEdQ31kYVGx7+o0+coxLt+OW7a0aFg7WNSMtrrVnd4XMbiSNRq4ofB47d9aT2U54w== 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=kAMnS3bFjvwo8WTmreeA1t2qpUMkpkVEYXgZYwlahGuJ0w6UgUmBx85LjuJ7dHASAebG0OKUkyV6FEibFyUMDcWrdMxUY7l7oEdE7/EzK27eYkF9EmQfY8GZmKZ6d8fEHen+XgcQnqAEfIQGI6ZJpdpaRjKF8dYRt7DDuSjChwbhHGW/zktg8KwKRc/Ri03aUbpXQjG0/A2qDEs3fCDTdV3qORWwbuY3RXuM9zqTVB15EmbjYRHm0eBkx3ctiURzDO1WXrN6d6SwCmQLUdQ8gXu0h8zt15moEYPRTzEx2ExwcfxHNqejEFlPqONFkTKUCQGnVCFQxJVRMOysLy1SDQ== 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=HtofKB7xluDjJOed8+SloHar72jeCEJGW6I6p9e/V7jhUdJpx5SIx6TQnmnarug6leVCjIk3UJ2d45FFYFgMuf0E/OdXOk4L3RlJyl4GITJriWVH9jWBczwh8KTYxH2u7mmy7juQfBbYUp6wIhAB0BQdRL1fPCdB4t3vKvE3KsPtb4CuB1mJu09UIobPxbtIgFdG8tbjLm8D9JQkBK1+sig+U3h/rOYITqouNkwQzawY86GFy80At2/e5tie+U6luxNZtPbTyCf+wF+IEFoVc88AKhkPWgIFR8pKUKE+nbfwrwC5Bn2cykocgTmXqlsIQDujFuOpf+aClNRrAKsf9w== Received: from DU2P250CA0003.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:231::8) by AM9PR07MB7810.eurprd07.prod.outlook.com (2603:10a6:20b:300::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.21; Thu, 19 Sep 2024 19:40:43 +0000 Received: from DB1PEPF00039233.eurprd03.prod.outlook.com (2603:10a6:10:231:cafe::b0) by DU2P250CA0003.outlook.office365.com (2603:10a6:10:231::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7962.28 via Frontend Transport; Thu, 19 Sep 2024 19:40:42 +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 DB1PEPF00039233.mail.protection.outlook.com (10.167.8.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Thu, 19 Sep 2024 19:40:42 +0000 Received: from seliicinfr00050.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.60) with Microsoft SMTP Server id 15.2.1544.11; Thu, 19 Sep 2024 21:40:41 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00050.seli.gic.ericsson.se (Postfix) with ESMTP id 88F441C006B; Thu, 19 Sep 2024 21:40:41 +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 v10 3/7] eal: extend bit manipulation functionality Date: Thu, 19 Sep 2024 21:31:20 +0200 Message-ID: <20240919193124.737943-4-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240919193124.737943-1-mattias.ronnblom@ericsson.com> References: <20240918090445.725283-2-mattias.ronnblom@ericsson.com> <20240919193124.737943-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: DB1PEPF00039233:EE_|AM9PR07MB7810:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c9c52a9-c61a-4a73-5f48-08dcd8e2f280 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?utf-8?B?U1A5NnlkMDYxbXk0ckk1NjAxZ0lCWG9lVmFZRVRndWsvWGUxVXdWdk85MkZq?= =?utf-8?B?aUJWMmlBSlR3STdmcmJUQzlxWFJaemlvY0twTFNqekk0V0VOZjJiNXU2T3Vs?= =?utf-8?B?QzVkMUVMRksvRDRVeUN3Mk1aYmJmUlBVQmlCOXFmbUwwVWlSeU5VWEwrcVBi?= =?utf-8?B?OWdueTkzZnltVDhtWUlmY2t1Y0lDVHgwMDhKUWpWSlVSTTBSUGQ4VEkrWTAv?= =?utf-8?B?dG84Nm5ZUlEzV1k0SlUycGZvTnFqV25QTEw1RFErNmtzNVJXSGJBZUFySHdS?= =?utf-8?B?c29WMnBWaW1zYnl6cFljbXcrVFdNMGJVcTdLWklEUFpaWDFtNFVzS2M4aEMw?= =?utf-8?B?WEZNTy90ZXhGYXY2NC9rSFc5UE1BL1hkdy94YzcvWTFGckVrNGE4OERJZkhI?= =?utf-8?B?YWxuUjFuWm9VRGJJN3k4RFg2WWZzdXp1TW1MVCthTTVFSGhmQU52eW4rcnVt?= =?utf-8?B?UFFpSUtpTm8rZ0lpSVJmMU5QS1lDVERnNjI5UHduQlpob2dicUYyUTlTRXdU?= =?utf-8?B?UU9EcFBNMFpLOHVoRGhkeUpDSVJiUlBEK1FnMTJndm1QSUpUVkU4NjBoUXpW?= =?utf-8?B?eUw0OEJrQVJScGg4YzI4d3VtREFSRDJ2c0JtYzZaU3RVTjBkZGFJZytwYWdR?= =?utf-8?B?SVBaa2JWMVhOQUhaU3hsRExnbldVejU0MDE4eTB3WVdqcVRiNmszb29zeTh0?= =?utf-8?B?VmM1ODA0TTN1Nnc2ZVlGK0lRZkxMV25ZNGZsdjM2d1pUbTM3MjI3ZUh1Yk5P?= =?utf-8?B?UXVpRlZwdWVadFZTb0VEOTlOUXNBanRsUHlEVkZ5MHNPcmc1L0ZaUWM3bWkz?= =?utf-8?B?c24vR0RhNURCdlV2dGxtOFluRmxYdHJWL0lCd2U2R2R3UTBKaGI3Qmd6UUEv?= =?utf-8?B?T3VIMWVRMVJIbTUvVUJmclhHM3N1cnlEUTRoeTc1U0hBL2JLYXVVY0Y2Sno4?= =?utf-8?B?WmIyTFN6bnM0bER5ZWhOL2xOZHhQQ1hIM1U0VTEzNFRxUkcrZllWWWdEc3pB?= =?utf-8?B?VnllOGpxQ1ZwM1UxdVR6OU1TSEd0cGI1ZUsveUNzcWJKNDJzaFF2SUZsVmlk?= =?utf-8?B?Y1BGR2hBaVBQVlpCL0p1Nm14RFVGRnlaRmR5S3FNSVZ6ZlRuVXZnS2puTzZW?= =?utf-8?B?ZDNFTGYwQUZlam4rUVc5bnFqUEk2YjhSWUI0QisyUTRINnRXNitQa1l0U1Ev?= =?utf-8?B?YzdaNjFETUpWcXNnZUZndExrbGY5MWgyZ0xocW9QcmZKaERlNmJEVHZCUndi?= =?utf-8?B?STh6Z3hGM1hubVpLTDRiUldLdU5TYjlTZVJTQTdZVlgxVCtiMGFOMTNhNEZG?= =?utf-8?B?K0U0SzFzMEozb2oxZzl2OUpkVkhGTjhRbDN6czRCYnFiVG8wYThTQjlKY2Nh?= =?utf-8?B?UmFkTWlkaEhpazlKZjh2S2l6bTVjaEF2bVJxV3FRWmZTYXVaNEZDOUdaN2R4?= =?utf-8?B?RXVzUjV3ejhZUUdBZ2Y2VFdhKzRpZm1LakdTTjgrNzJlWTFjbFkwVEpLK3Yr?= =?utf-8?B?OG1mM3pUMHovbFMvUjJKNEQ5T3ZOYkdxWEd0U0dyY1VkeWwyQWVPMTFOWWFY?= =?utf-8?B?ckZBcmxjSm96MnJaaVI4OU8waSs4U1IxcTNBMzRYTGp3Q0dENGt0TVd1dVVP?= =?utf-8?B?SFhRQWp4M0FneklwOEdHYkt3SHRRZk9SYmZuejAySWh2aDR2SVBpa3Jkc3BQ?= =?utf-8?B?NHIySDkya0h0cEtoczFjNEFHVERWWWhlN1oyUDMxME5WUFNCRE1pQ3dMemxY?= =?utf-8?B?Q21TdzZiRDhxSld3djBURW9aT2t1YVNGTWZrL2kxZVNMOU43am5jdFdpV1gy?= =?utf-8?B?OWRMOVhBdGwvZnY1bVk0TTkrYTlQZGhWNjFVVmh6MmxSczV5UWFQaDZpemN3?= =?utf-8?Q?Pif7glLooKfSc?= 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)(82310400026)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Sep 2024 19:40:42.1694 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c9c52a9-c61a-4a73-5f48-08dcd8e2f280 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: DB1PEPF00039233.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR07MB7810 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