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 253E8A04F6; Sat, 21 Dec 2019 19:09:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD7CB1C01; Sat, 21 Dec 2019 19:09:01 +0100 (CET) Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by dpdk.org (Postfix) with ESMTP id 233091252 for ; Sat, 21 Dec 2019 19:09:00 +0100 (CET) Received: by mail-pf1-f193.google.com with SMTP id x185so7016463pfc.5 for ; Sat, 21 Dec 2019 10:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IhJehQkZJcYu20CCfltrqkxJWw9zvVMgrn/yAgkvK+M=; b=TDWddwEVQSsBLdB7vpzzwU73PQ1MiV0ot3uWDjhQdC60wm4rsLUHC4INvm0Ag1ki36 kIsLAWkdhrV84Vw+4GeD3ujgxDk9OYIlGrfwt0in6+73Va+rEoPQF7Olse9m5pmu1lvt QKvfbje0xu6cQHtQW3h5GcZ+XCllA6STVQmww0leU0Gwqm1b41X5+0Etnpoc8oHRhRrI vZW+3MDjRtC1GizvWaYnsdRzcCdMuWUfAeYhLU35t+9RJtqizW2hPzXosG00aosXj+lm jY0EICgh23LaZW0ill1R91di25/62opI467RY9re68PDVcO5F7ne+jOSJwcRFWrx+mHw Lx4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IhJehQkZJcYu20CCfltrqkxJWw9zvVMgrn/yAgkvK+M=; b=NI06Zm/WEwdIgtBd1VVsPdCGAGLuLAqz+uA9yvgSweGLiHUpIhOYUlpro/fOV80zWo zxHXkbR4BDYskiy7rlVGLGAsh/3PKQSu7skpBXviOBrzOUnlrlUmc9kQnHB1nFVimI+7 yDOt56/VfyL5oWE3xdsloFEJiPcvANKRQxfPPZ33J/X47ZY+xBBlNGw05E3NI0XOCW1U FX5AOT/4MFoUGYR//bu6yFDt9H3cMK75FvBvXu3w0xFghPoVWzNed10Bt8MTv2Nlqb8A WIvZcvlrHLS5QVK16qEkiSvn3VUxNl+Ie3YBxwi28akwkGLbK7+rrKnO8+jN+rsBSqvg 2dGg== X-Gm-Message-State: APjAAAV+sGhqv7L3HYRTZ2EAKz7b+V6gK9K8okTOnnaenS+6MxMWL72U +PzEMAtbSotUmlWs8l/qvWvnqQ== X-Google-Smtp-Source: APXvYqzb9aYRH/tshM1Xxl1mgOf0Jq3u1XmXPO6HgzmlUoiBOHePj84o3dAkkVTRlK3HkV7oSqxU0g== X-Received: by 2002:aa7:8283:: with SMTP id s3mr23240882pfm.106.1576951739348; Sat, 21 Dec 2019 10:08:59 -0800 (PST) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id m128sm17218784pfm.183.2019.12.21.10.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Dec 2019 10:08:59 -0800 (PST) Date: Sat, 21 Dec 2019 10:08:56 -0800 From: Stephen Hemminger To: Honnappa Nagarahalli 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" Message-ID: <20191221100856.5ebfce01@hermes.lan> In-Reply-To: References: <1571125801-45773-1-git-send-email-joyce.kong@arm.com> <1576648808-24765-2-git-send-email-joyce.kong@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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" On Sat, 21 Dec 2019 16:07:23 +0000 Honnappa Nagarahalli wrote: > Converting these into macros will help remove the size based duplication of APIs. I came up with the following macro: > > #define RTE_GET_BIT(nr, var, ret, memorder) \ > ({ \ > if (sizeof(var) == sizeof(uint32_t)) { \ > uint32_t mask1 = 1U << (nr)%32; \ > ret = __atomic_load_n(&var, (memorder)) & mask1;\ > } \ > else {\ > uint64_t mask2 = 1UL << (nr)%64;\ > ret = __atomic_load_n(&var, (memorder)) & mask2;\ > } \ > }) Follow on if you want to do it as macros, then use typeof() to make the mask any size.