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 B088B459D7; Fri, 20 Sep 2024 12:57:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 112AE43430; Fri, 20 Sep 2024 12:57:21 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2040.outbound.protection.outlook.com [40.107.21.40]) by mails.dpdk.org (Postfix) with ESMTP id 424E743417 for ; Fri, 20 Sep 2024 12:57:16 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YqeNyTETyGmN/9m7rjf9YNfNw7uR9i6iW6u34MfPt/Z5C4NXsnwV8MsIom6hwHhB8ZNTHHrvNEkh5cNFAPekgyrL+9gvIjnMTrCG+R5z4kExKddY1TyRFqw94Ym/aKPsgkNFxhFjtWbAK+r47hReBwr8wMBOqPPZ5TC0D9RecHPa+mCsxl/5cnQZZL8Th2042bgxjpEAiLj+Z4dHZmAne6K5a5jSSpk7xDmNgW7rXfW1Zd2vZZMZfxv/vzdAqw8kYjysKbVoXhY9ijDCFnIpawi7ngdKax2sMH1uXg0TYE1tkW8cH7BRz0sd1ekwi9OEPJkU2A9Rv2BY0y0P7GoP+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=sVdXRCytKTyiZD4rutDO0YUYNrfpxN3WDZBoiRkaCpU=; b=KmPsDqqDObVD7GC40ccl5POHxvz1u0wFgn7l80dR85S+DqgwgFBFkogolj4UveRAdObN/hrEtr7kYxxO7Frbgg+3VOAXNId1OFattnHOlp88JhIXH0pkycIzGBMC96lQ9GQRqbYay+RvfCK41jUMGBNy7x6EGmP57Nvgbs44D+53vSwU67VVsAn0JX5uyM9c5ij10CTL2J03MdaCCF3PmlmSWK4QtXWc87aLLnon2lU4YR01eVQyWWhK4Vgb1Sq1SQioCK1baMYL3PBSy24YrGoE17uA6n+Pv/q4rqZzfRFgdBHDDeSsybkqHJpJkNcyyAusocRugADU20kusJzwAA== 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=sVdXRCytKTyiZD4rutDO0YUYNrfpxN3WDZBoiRkaCpU=; b=RhAlZRe2orx2HNVaGRw9610McbGgARbqwg9mb8At7dV99nUoY9obOw5uovMnTdNK32yguzWU2SehAjoshKmYonJmRaCzks+ea9hOQQW4pCwmyqwntAXOGP3JVyF7ByTe1LBLseQ+E9nF1LmvJ118EH3q68u/vPpZVoeq1Vdx/7nJvCfVD7m5udKR+kyFgmccnGoX3aL/OBt34ORITcnLNlinmj1hvmVpL1sVwCduA2xKk2wV2YimVHF8yn0YZcDi4d5gbHNU83kZIT59ymC7dHohaWolkqNrfWcsKHbRhhWdZmvALpdo5Jtn/bxskB/AvbLEPJYYZ7OIZ/0DnUoe2g== Received: from AS4P195CA0014.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5e2::10) by GVXPR07MB9704.eurprd07.prod.outlook.com (2603:10a6:150:114::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.22; Fri, 20 Sep 2024 10:57:12 +0000 Received: from AM3PEPF0000A796.eurprd04.prod.outlook.com (2603:10a6:20b:5e2:cafe::cd) by AS4P195CA0014.outlook.office365.com (2603:10a6:20b:5e2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.30 via Frontend Transport; Fri, 20 Sep 2024 10:57:12 +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 AM3PEPF0000A796.mail.protection.outlook.com (10.167.16.101) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.13 via Frontend Transport; Fri, 20 Sep 2024 10:57:11 +0000 Received: from seliicinfr00049.seli.gic.ericsson.se (153.88.142.248) by smtp-central.internal.ericsson.com (100.87.178.61) with Microsoft SMTP Server id 15.2.1544.11; Fri, 20 Sep 2024 12:57:11 +0200 Received: from breslau.. (seliicwb00002.seli.gic.ericsson.se [10.156.25.100]) by seliicinfr00049.seli.gic.ericsson.se (Postfix) with ESMTP id 098CB380070; Fri, 20 Sep 2024 12:57:11 +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 v12 3/7] eal: extend bit manipulation functionality Date: Fri, 20 Sep 2024 12:47:50 +0200 Message-ID: <20240920104754.739033-4-mattias.ronnblom@ericsson.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240920104754.739033-1-mattias.ronnblom@ericsson.com> References: <20240920062437.738706-2-mattias.ronnblom@ericsson.com> <20240920104754.739033-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: AM3PEPF0000A796:EE_|GVXPR07MB9704:EE_ X-MS-Office365-Filtering-Correlation-Id: 5eb5277d-fe55-4a46-de00-08dcd962fab4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?B?M2ltY1JheDg2V0RMMXgrZHUweVFibjg0dllHZUcydGVGYlVuNUNseFowMVY3?= =?utf-8?B?NmhwUGpNaXZJOWt4SzI5Y0ZGbjdCM3l0VHRMT0xsVytlQkNFL3NYZjl1YlVG?= =?utf-8?B?WVR5OFJsZ2Jlbmx3ZUpKM0trYVZKaWJ0S3NVSDBnZDFjQVlUZ1VWSzBjeFpT?= =?utf-8?B?Q2w4TFJ3RDNKQzZMQVJtU0d2b2RDYmt4ampKSmgzMXhkQ3A2MDY0bzRxcjZE?= =?utf-8?B?WnVtRVpBZmJkSWh3LzBiL0lHK0VQbldRMmNXZUtnTkdubVFlVjJLOUFnWm94?= =?utf-8?B?Sk1TQjN2akpZVDhYK09ScXQ3aHlMMmVjbDZqV0UxdkhKYzBGVnEvdVJNUnF4?= =?utf-8?B?Q2FtYUxIU2lyZzlVcXp4c3NVUEhha3c2WG44U3lhRy9tdng2TitsbkJlcmtK?= =?utf-8?B?M01tYkQrVFhWZGFLYThhU2NBQ25uV1hPWmxTam9MQ0NPZHRlSmJUMW9DWjg4?= =?utf-8?B?eXI3QjNVMnlNK2Z2cWhBSTRjUWtOb1h3M1MwbHIwbTdUSDcrN0RRS3pSUHJu?= =?utf-8?B?b1JCWFVQSzZTT1pxWGRwSUlwenVwcjRKTUd3OEx4ME1nUnRMTVdsb05kdjU1?= =?utf-8?B?RmhnOEVDeXRYWnRQRkg5Zi9ydHcwcDVIS0hiN1RHQmo4bFZlSXFielVHNy9q?= =?utf-8?B?TlA1aml0VGlwSmxhSU5NVEdDd0VqVlVwSzZ0ZG5YYm9UK3NaL1cwUUY0UmJO?= =?utf-8?B?WDNGQXpERjhJazhNSWJIc0t0MWEwZEU3YWp3dlNsTmV6dkNSZU9aQjVoaUM5?= =?utf-8?B?dmV5Mzd1ak40dGtNSGNFYzZpdDJYbU9MdXhwNjlYS0tDQTFERmtoajErbkVo?= =?utf-8?B?bWoxM0xrYW5jbHZ0SE9LVUJYRVhnZ2JOdEk1UkdHaTNZSUxUTFJGM2NlZUc4?= =?utf-8?B?K1JOeC9kNnNpaDVWZFVKdnNUUklmKzZHYTkvYytPcXd3M1M0dlZJVEpKNVYw?= =?utf-8?B?ZWpkZEVJUXlJTjlKTVdoU2lCcFAxaC9rdGRvOFljQUE4dHUyT2JxQ3VGU3Vx?= =?utf-8?B?UUIvemxaL3NKeHcwZkk5d1dxbnBzZVlvT3pBbC9TdkJzL0lGQ0x0Q3NjVk5i?= =?utf-8?B?dktMUTJMd1gzVi9PbmVMR0NaeUVhU2EwOTBqeEY1SnBydDhNWitibzA1VFRV?= =?utf-8?B?RUxtaGQ2SUdFcHNxR29QYmVmOVV0SXBkSmpINHdLZVNtcHpPRWdvSXVHVFNT?= =?utf-8?B?Q0Y3ZVdpazlnQlZMRGFjRjFkL29lZW5qMjJzb0UvN0V1VmhqeGp2cGVmanRZ?= =?utf-8?B?WTNSL2M1RHJxY3JJWCtYYVEya0ZSQnNtVCtKRWdnYXZtbGJ1NElram9KVGcx?= =?utf-8?B?enM4Q0tBVDBrNm1VMTFPQ04zWW1tcWo3ODBYWHJ5cEpjWW5DTUQwaHN3M0lo?= =?utf-8?B?QnBpaVJURm8vMDVhdFg1K05SR3hTL1NqcmVqdUFVNVpHaW1XNjdmUTZOY3VV?= =?utf-8?B?Z1dROE5mK1RVNWpwMHYrd0xPSmU1Rk0yTWxNZXJmMnRBQ2JNNlM0QUhLNFFa?= =?utf-8?B?WkhybG1sUjNEeURmRWpvVld6eEZmYXlGTzRwcXU0NU51SDU5Y1JvQmwrQWtL?= =?utf-8?B?cUtwVVlCQWY1Rjh2R0Vxa3NYOXlzVllVenM4cGdtRmU3NXVQbHNXay9PT2VD?= =?utf-8?B?YkcwSGFuN1M4clRpWUpqWGFWKzhnK1BibjVzc0ZhMWZYdlFTS3F4di8wR1Aw?= =?utf-8?B?S2JhdGVGc3l4TWE5dGxUSnRQNCtKR2ZnSU9ZM0lqL3ZXbkhBb095MVYrWWRk?= =?utf-8?B?VEc4aERqcTNETldOaUdoV1RPQkNKcTBxeHY3VkhoVGFWZ0xwa05qbExaelhS?= =?utf-8?B?dmpkaVVTZmR5RXFvcUxRVnhsLzViTkZ3Qy80MG9CaHhQMlVTRWRJVVlkdnlp?= =?utf-8?Q?oiKUBq29ELPfs?= 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)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1101; X-OriginatorOrg: ericsson.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2024 10:57:11.5322 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5eb5277d-fe55-4a46-de00-08dcd962fab4 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: AM3PEPF0000A796.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR07MB9704 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.43.0