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 86388A0547; Sat, 13 Mar 2021 02:10:10 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 54B48406B4; Sat, 13 Mar 2021 02:10:10 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6CDB04067C for ; Sat, 13 Mar 2021 02:10:08 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 7E344209B364; Fri, 12 Mar 2021 17:10:07 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7E344209B364 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1615597807; bh=2/cJj4z9Hi8hzSDh4KH4969yZLqADmkQRrwqAFU+SvA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WfMudat308MQC5uyLmOII+gmhg8mdpZ9NvLohP6r9H8iProgPHeApIrZKforjv1+m MwAOCDEsPmj5D8DRRYxgu1QOf6dkM9btRkplT0D4cG7QvtEGbEoWYN+zD9ghVG8wDG K2xCszMhyTUSU8aWd2jKb9rWm0BbjXSKFk83dhsU= Date: Fri, 12 Mar 2021 17:10:07 -0800 From: Tyler Retzlaff To: Morten =?iso-8859-1?Q?Br=F8rup?= Cc: Stephen Hemminger , dev@dpdk.org, anatoly.burakov@intel.com, Ray Kinsella , Neil Horman Message-ID: <20210313011007.GA20712@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1615358466-12761-1-git-send-email-roretzla@linux.microsoft.com> <20210310104942.66ef440e@hermes.local> <20210310225238.GA10267@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <98CBD80474FA8B44BF855DF32C47DC35C61674@smartserver.smartshare.dk> <20210312182419.GC8084@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> <98CBD80474FA8B44BF855DF32C47DC35C6167A@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35C6167A@smartserver.smartshare.dk> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [dpdk-dev] [PATCH] librte_eal/common: fix return type of rte_bsf64 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 Sender: "dev" On Fri, Mar 12, 2021 at 10:13:30PM +0100, Morten Brørup wrote: > > > > > > Please also update the similar math functions in rte_common.h, so the > > return type is consistent across these functions: > > > - rte_bsf32() > > > - rte_bsf32_safe() > > > - rte_fls_u32() > > > - rte_bsf64() > > > - rte_fls_u64() > > > - rte_log2_u32() > > > - rte_log2_u64() > > > > agreed, happy to review the whole set and deal with it all at once. > > Ups. I should have omitted rte_bsf32_safe() from the list. It returns a Boolean. if we can agree that we can use C11 as a base we could just do away with all this dumb 32-bit vs 64-bit static selection at the call site (at least for rte_bsf32() and rte_bsf64() and probably others). i could just introduce the following macro and deprecate the current inline functions. #define rte_bsf(v) \ (uint32_t)_Generic((v), \ uint8_t: __builtin_ctz, \ uint16_t: __builtin_ctz, \ uint32_t: __builtin_ctz, \ default: __builtin_ctzll)(v) uint8_t a = ...; uint16_t b = ...; uint32_t c = ...; uint64_t d = ...; the following would jw as intended, though given the range of the value that may be returned we could narrow the cast to uint8_t so we don't have to sprinkle casts in places where usage like uint8_t x = rte_bsf(v); exists. rte_bsf(a); rte_bsf(b); rte_bsf(c); rte_bsf(d); anyway, if people care let me know otherwise i'm just going to review and fix what is already there.