From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8DABBA0352; Mon, 23 Dec 2019 06:45:26 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 56CBA1C01; Mon, 23 Dec 2019 06:45:26 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr150043.outbound.protection.outlook.com [40.107.15.43]) by dpdk.org (Postfix) with ESMTP id E35A21252 for ; Mon, 23 Dec 2019 06:45:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=idSPT1snsPF9Svj2U0aPYcMPEyw4WKxzJ47ve/McSrM=; b=hsmM74LOMfqpDpGjc+jlb/fBO4x4/FZ9jvejqLKaxPRY7FzQ4cnREA2+5WuvGwduIldB497wex70FXyUeFvTqVAGA/Xb62jrpmQFY8UG+q/2ApOrK9k9d5bk3lVHQmDTO5+Xui4rjiu33y4Os56SFZFjIUfc0Ru6d7vnHS2EceE= Received: from VI1PR08CA0224.eurprd08.prod.outlook.com (2603:10a6:802:15::33) by AM0PR08MB2945.eurprd08.prod.outlook.com (2603:10a6:208:63::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14; Mon, 23 Dec 2019 05:45:23 +0000 Received: from AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::208) by VI1PR08CA0224.outlook.office365.com (2603:10a6:802:15::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14 via Frontend Transport; Mon, 23 Dec 2019 05:45:22 +0000 Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT014.mail.protection.outlook.com (10.152.16.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14 via Frontend Transport; Mon, 23 Dec 2019 05:45:22 +0000 Received: ("Tessian outbound 1da651c29646:v40"); Mon, 23 Dec 2019 05:45:22 +0000 X-CR-MTA-TID: 64aa7808 Received: from d7a595ef3972.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id E3139353-EC35-4B71-8ED8-F692CE9285D8.1; Mon, 23 Dec 2019 05:45:17 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d7a595ef3972.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 23 Dec 2019 05:45:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HmWAtaNrLeYv6iUPOoEmju2h9e00mnm2cl7plGg4Qkg7tQB1ytI2IYQK4klZzYSXY41pqH6he7V5slnPMKWqqjd6xrkpoT2CTXj5BA1BPjv6HQK02wLqrDu3RembuMIMdGADxnBckUvH62BP5xPA2C60lqXrVInw6OTL8yGLIAcvcnTWr9MMpQR5L1SocJLcWKLMJXy+WbNF0zMCg5bhtRV+FIEZ0OXpwCuiojqY+rh3iWSHUn+6uVTdHrGEV2SllnZZ+qZ47T6SiB5UlDhENG0ljTnNZ+q1rudzrvHghyURWrWCTL3QeLXzRGjeSj5ETccvlxANWK7eSJD0CBKgAw== 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-SenderADCheck; bh=idSPT1snsPF9Svj2U0aPYcMPEyw4WKxzJ47ve/McSrM=; b=K869IvRSCLRu/CAlXtN2cpaUyCYQdHp6ymcmUflwyb4ROTQ9SyfCEpuMyLDaVx+y2dV5fflsE8DzS+TJM2VrTGD+EbdNpl8z1TreJ678gOH+XQrzDrt1y9qngNuwxIWWK7jHTEMG6Lum0gRmVu7HPUKFHV++3G1/pUFE5HB98DOVG1JpVLWMMuEUgpzjaxnYcTZVJH+umnaL7+ChfIVn+mR3BCoiiRIvSN4lV7UyCtYgDwb1QPU6PLLLU6quvJGq5hVbW2gxT/IeqKsf6kXAHWttgHnVyzstlcBBfHG67nn5xj21WbPkBNVRQG8QFSrMSHd0d54Z0MQjVMV9L0ML1Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=idSPT1snsPF9Svj2U0aPYcMPEyw4WKxzJ47ve/McSrM=; b=hsmM74LOMfqpDpGjc+jlb/fBO4x4/FZ9jvejqLKaxPRY7FzQ4cnREA2+5WuvGwduIldB497wex70FXyUeFvTqVAGA/Xb62jrpmQFY8UG+q/2ApOrK9k9d5bk3lVHQmDTO5+Xui4rjiu33y4Os56SFZFjIUfc0Ru6d7vnHS2EceE= Received: from VE1PR08MB5149.eurprd08.prod.outlook.com (20.179.30.27) by VE1PR08MB5085.eurprd08.prod.outlook.com (20.179.29.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2559.14; Mon, 23 Dec 2019 05:45:13 +0000 Received: from VE1PR08MB5149.eurprd08.prod.outlook.com ([fe80::9df4:7af6:b62d:f94e]) by VE1PR08MB5149.eurprd08.prod.outlook.com ([fe80::9df4:7af6:b62d:f94e%7]) with mapi id 15.20.2559.017; Mon, 23 Dec 2019 05:45:13 +0000 From: Honnappa Nagarahalli To: Stephen Hemminger CC: Joyce Kong , "thomas@monjalon.net" , "david.marchand@redhat.com" , "mb@smartsharesystems.com" , "jerinj@marvell.com" , "bruce.richardson@intel.com" , "ravi1.kumar@amd.com" , "rmody@marvell.com" , "shshaikh@marvell.com" , "xuanziyang2@huawei.com" , "cloud.wangxiaoyun@huawei.com" , "zhouguoyang@huawei.com" , Phil Yang , Gavin Hu , nd , "dev@dpdk.org" , Honnappa Nagarahalli , nd Thread-Topic: [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs Thread-Index: AQHVtWiBQ1n0Dk5tDEKroTViQBZDeKfCfMMAgAJBDyCAACrIAIACUrww Date: Mon, 23 Dec 2019 05:45:13 +0000 Message-ID: References: <1571125801-45773-1-git-send-email-joyce.kong@arm.com> <1576648808-24765-2-git-send-email-joyce.kong@arm.com> <20191221100856.5ebfce01@hermes.lan> In-Reply-To: <20191221100856.5ebfce01@hermes.lan> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 966a71ae-f59d-4c77-874e-1b1207c1e293.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; x-originating-ip: [217.140.111.135] x-ms-publictraffictype: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 2f3988b1-e1b7-413c-d2e9-08d7876b4d8c X-MS-TrafficTypeDiagnostic: VE1PR08MB5085:|VE1PR08MB5085:|AM0PR08MB2945: x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-ms-exchange-transport-forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:5797;OLM:5797; x-forefront-prvs: 0260457E99 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(376002)(39860400002)(396003)(346002)(366004)(136003)(199004)(189003)(33656002)(478600001)(76116006)(71200400001)(4326008)(52536014)(66446008)(54906003)(66946007)(64756008)(66556008)(5660300002)(66476007)(316002)(186003)(26005)(6916009)(8676002)(6506007)(7416002)(86362001)(2906002)(55016002)(9686003)(7696005)(81166006)(4744005)(81156014)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VE1PR08MB5085; H:VE1PR08MB5149.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: H3uwm6JiViOyB+L/1H6W2lO2i6NdjC7gFnEfPgnCVYTUo8yu2WTutcd76aVjEFrQncNN/P6lHfMXGQSgGAhZYh1r4sgw4L9zTA+UOXZwrYRJJKXKpkgR9kJcZkV+qeH12DfafkxfMZsw6C2PKhYTWUqY5rTPd4SlUQmtqsYgMeoxy+7KjspC/XNRDSivTG1xrXpXOvtp8iQ9dx/5n0Xs1XtfWBV4QrT1/skGGgn4XZ6mcZR89pIInDcMEdrMeefY0FNVrkO7jthGO20F96tPXg/Hoe7m8SwtOXFuiaT5zVeglFZN1W4nkJQ8qzdIL2MUzgTaxk8O2eR/uyRYzJ/ddbms6n+gtwwqduH5wqabwTBm4W4IzcNjcmWguD5iFuuaTIXIENyBeO9cgk6fOwP1CXMdqVm+5a7li7ZvbepqXVtRBfLqvRehhhwQG7eXdwx7 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5085 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Honnappa.Nagarahalli@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT014.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(396003)(136003)(376002)(346002)(189003)(199004)(54906003)(86362001)(5660300002)(316002)(9686003)(2906002)(55016002)(4744005)(52536014)(36906005)(70586007)(76130400001)(7696005)(70206006)(26005)(186003)(81156014)(8676002)(26826003)(6862004)(6506007)(356004)(81166006)(336012)(8936002)(4326008)(33656002)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM0PR08MB2945; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:Pass; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; MX:1; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: 05188c06-2987-41af-5123-08d7876b4842 NoDisclaimer: True X-Forefront-PRVS: 0260457E99 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: exBtfmrWFPu9x8ZtCAqKAMeUyqz3xoHs8aw9PyrPbEsECX2ej69R6JJjCJX+0+mxvgUYQUH0ty67UqQ8DWJsN4SHHCmTdNK3sZrqzPc508eRlGSY3tqGlDaTYyCN6V1jpOAhUh44dACSOHnKuM4eSAzbgmea/BDVc/bhAPDz9M0A/n56HiAvjDw6lPAyxDCDTWXjRsISeQhTc8kkvuzdJ99RUL06uh1eJaZMuIf87SRiZHs8UwOZ4cdAUU6Fxm9rvY+XGzgQPOIZ9uFF4DXx1n/4HG0LHlQ4yrUveKmaAnZ11xUsKk6ECkORZxr2VT3WhqA4CwdPkAZxFisdIeel4zjym55ael/rhxe5Y6g+u5ECp9JwjgM+1nuH5AadnmdvmS3tnoGJt3skthn9uwszfrkrvCBWJ6AsKWD6B9KSFbueMfbBjZYmFQxjPoYrrzKl X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2019 05:45:22.7949 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f3988b1-e1b7-413c-d2e9-08d7876b4d8c X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2945 Subject: Re: [dpdk-dev] [PATCH v6 1/6] lib/eal: implement the family of rte bit operation APIs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" >=20 > On Sat, 21 Dec 2019 16:07:23 +0000 > Honnappa Nagarahalli wrote: >=20 > > Converting these into macros will help remove the size based duplicatio= n of > APIs. I came up with the following macro: > > > > #define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ > > if (sizeof(var) =3D=3D sizeof(uint32_t)) { \ > > uint32_t mask1 =3D 1U << (nr)%32; \ > > ret =3D __atomic_load_n(&var, (memorder)) & mask1;\ > > } \ > > else {\ > > uint64_t mask2 =3D 1UL << (nr)%64;\ > > ret =3D __atomic_load_n(&var, (memorder)) & mask2;\ > > } \ > > }) >=20 >=20 > Follow on if you want to do it as macros, then use typeof() to make the m= ask > any size. Yes, that makes it much simple #define RTE_GET_BIT(nr, var, ret, memorder) \ ({ \ typeof(var) mask; \ if (sizeof(var) =3D=3D sizeof(uint32_t)) { \ mask =3D 1U << (nr)%32; \ } else {\ mask =3D 1UL << (nr)%64;\ } \ ret =3D __atomic_load_n(&var, (memorder)) & mask;\ })