From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 2DCFF2B94 for ; Thu, 15 Nov 2018 11:07:56 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Nov 2018 02:07:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,236,1539673200"; d="scan'208";a="86654966" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.124]) ([10.237.220.124]) by fmsmga008.fm.intel.com with ESMTP; 15 Nov 2018 02:07:53 -0800 To: Jerin Jacob Cc: "dev@dpdk.org" , "cristian.dumitrescu@intel.com" , "thomas@monjalon.net" , "bruce.richardson@intel.com" , "ferruh.yigit@intel.com" , "jasvinder.singh@intel.com" References: <369642722f3c4d3d6c184fddb34b4aa7ce308a84.1542213812.git.anatoly.burakov@intel.com> <20181115083955.GA4757@jerin> From: "Burakov, Anatoly" Message-ID: Date: Thu, 15 Nov 2018 10:07:52 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181115083955.GA4757@jerin> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 3/5] common: add missing implementations 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: , X-List-Received-Date: Thu, 15 Nov 2018 10:07:56 -0000 On 15-Nov-18 8:40 AM, Jerin Jacob wrote: > -----Original Message----- >> Date: Wed, 14 Nov 2018 16:47:08 +0000 >> From: Anatoly Burakov >> To: dev@dpdk.org >> CC: cristian.dumitrescu@intel.com, thomas@monjalon.net, >> bruce.richardson@intel.com, ferruh.yigit@intel.com, >> jasvinder.singh@intel.com >> Subject: [dpdk-dev] [PATCH v3 3/5] common: add missing implementations >> X-Mailer: git-send-email 1.7.0.7 >> >> External Email >> >> Implement missing functions for 32-bit safe bsf, as well as 64-bit >> fls and log2. >> >> Signed-off-by: Anatoly Burakov >> Acked-by: Cristian Dumitrescu >> --- > >> +/** >> + * Return the last (most-significant) bit set. >> + * >> + * @note The last (most significant) bit is at position 32. > > s/position 32/position 64 > >> + * @note rte_fls_u32(0) = 0, rte_fls_u32(1) = 1, rte_fls_u32(0x80000000) = 32 > > Fix here too > > IMO, it is better to add unit test case for newly added common functions > in test/test/test_common.c Good catches and good ideas, thanks! > >> + * >> + * @param x >> + * The input parameter. >> + * @return >> + * The last (most-significant) bit set, or 0 if the input is 0. >> + */ >> +static inline int >> +rte_fls_u64(uint64_t x) >> +{ >> + return (x == 0) ? 0 : 64 - __builtin_clzll(x); >> +} >> + > -- Thanks, Anatoly