From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id A387C1B514 for ; Thu, 22 Nov 2018 19:56:12 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2018 10:56:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,266,1539673200"; d="scan'208";a="98314883" Received: from irsmsx108.ger.corp.intel.com ([163.33.3.3]) by FMSMGA003.fm.intel.com with ESMTP; 22 Nov 2018 10:56:10 -0800 Received: from irsmsx106.ger.corp.intel.com ([169.254.8.8]) by IRSMSX108.ger.corp.intel.com ([169.254.11.101]) with mapi id 14.03.0415.000; Thu, 22 Nov 2018 18:56:10 +0000 From: "Ananyev, Konstantin" To: "Burakov, Anatoly" , "dev@dpdk.org" CC: Neil Horman , "Mcnamara, John" , "Kovacevic, Marko" , "Dumitrescu, Cristian" , "Singh, Jasvinder" , "Yigit, Ferruh" , "Richardson, Bruce" , "thomas@monjalon.net" Thread-Topic: [dpdk-dev] [PATCH 2/2] bitmap: deprecate and rename rte_bsf64 Thread-Index: AQHUgZKDdOF7syfMPEyH69vh8VFmS6VcJnWw Date: Thu, 22 Nov 2018 18:56:09 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258010CEBB04A@IRSMSX106.ger.corp.intel.com> References: <6279ff04d7d477d3c2c076c643a0093aecb654c6.1542801670.git.anatoly.burakov@intel.com> In-Reply-To: Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDY0MzQ1ZDItMTM2OS00OWUwLWI3NGItMTRiZGI5YzQ5OTM3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSlhTa3VrYXd6TTF0enZIaGlxdXBVallkUUE4amxxekN0T2t3cHExMVJSb3FiYm9QZ01vOHNCeXZPeHdUWXNMQiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 2/2] bitmap: deprecate and rename rte_bsf64 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, 22 Nov 2018 18:56:13 -0000 >=20 > Rename rte_bsf64 to rte_bsf64_safe (this is a "safe" version in > that it prevents undefined behavior by checking if incoming > parameter is zero) and move it to common header. Probably a stupid one: why to rename? Why just not fix rte_bsf64 to make it work with zero value, and keep the same function name? Konstantin >=20 > Signed-off-by: Anatoly Burakov > Acked-by: Cristian Dumitrescu > Acked-by: Jasvinder Singh > --- > doc/guides/rel_notes/deprecation.rst | 5 +++++ > lib/librte_eal/common/include/rte_bitmap.h | 14 ++++--------- > lib/librte_eal/common/include/rte_common.h | 23 ++++++++++++++++++++++ > 3 files changed, 32 insertions(+), 10 deletions(-) >=20 > diff --git a/doc/guides/rel_notes/deprecation.rst b/doc/guides/rel_notes/= deprecation.rst > index 34b28234c..553e99171 100644 > --- a/doc/guides/rel_notes/deprecation.rst > +++ b/doc/guides/rel_notes/deprecation.rst > @@ -22,6 +22,11 @@ Deprecation Notices >=20 > + ``rte_eal_devargs_type_count`` >=20 > +* eal: function ``rte_bsf64`` in ``rte_bitmap.h`` has been renamed to > + ``rte_bsf64_safe`` and moved to ``rte_common.h``. A new ``rte_bsf64`` = function > + will be added in the next release in ``rte_common.h`` that follows con= vention > + set by existing ``rte_bsf32`` function. > + > * pci: Several exposed functions are misnamed. > The following functions are deprecated starting from v17.11 and are re= placed: >=20 > diff --git a/lib/librte_eal/common/include/rte_bitmap.h b/lib/librte_eal/= common/include/rte_bitmap.h > index d2ed6204c..77727c828 100644 > --- a/lib/librte_eal/common/include/rte_bitmap.h > +++ b/lib/librte_eal/common/include/rte_bitmap.h > @@ -93,14 +93,10 @@ __rte_bitmap_index2_set(struct rte_bitmap *bmp) > bmp->index2 =3D (((bmp->index1 << RTE_BITMAP_SLAB_BIT_SIZE_LOG2) + bmp-= >offset1) << RTE_BITMAP_CL_SLAB_SIZE_LOG2); > } >=20 > -static inline int > +static inline int __rte_deprecated > rte_bsf64(uint64_t slab, uint32_t *pos) > { > - if (slab =3D=3D 0) > - return 0; > - > - *pos =3D __builtin_ctzll(slab); > - return 1; > + return rte_bsf64_safe(slab, pos); > } >=20 > static inline uint32_t > @@ -408,9 +404,8 @@ __rte_bitmap_scan_search(struct rte_bitmap *bmp) > value1 =3D bmp->array1[bmp->index1]; > value1 &=3D __rte_bitmap_mask1_get(bmp); >=20 > - if (rte_bsf64(value1, &bmp->offset1)) { > + if (rte_bsf64_safe(value1, &bmp->offset1)) > return 1; > - } >=20 > __rte_bitmap_index1_inc(bmp); > bmp->offset1 =3D 0; > @@ -419,9 +414,8 @@ __rte_bitmap_scan_search(struct rte_bitmap *bmp) > for (i =3D 0; i < bmp->array1_size; i ++, __rte_bitmap_index1_inc(bmp))= { > value1 =3D bmp->array1[bmp->index1]; >=20 > - if (rte_bsf64(value1, &bmp->offset1)) { > + if (rte_bsf64_safe(value1, &bmp->offset1)) > return 1; > - } > } >=20 > return 0; > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/= common/include/rte_common.h > index 87f0f6302..d115b175c 100644 > --- a/lib/librte_eal/common/include/rte_common.h > +++ b/lib/librte_eal/common/include/rte_common.h > @@ -491,6 +491,29 @@ rte_fls_u32(uint32_t x) > return (x =3D=3D 0) ? 0 : 32 - __builtin_clz(x); > } >=20 > +/** > + * Searches the input parameter for the least significant set bit > + * (starting from zero). Safe version (checks for input parameter being = zero). > + * > + * @warning ``pos`` must be a valid pointer. It is not checked! > + * > + * @param v > + * The input parameter. > + * @param pos > + * If ``v`` was not 0, this value will contain position of least sig= nificant > + * bit within the input parameter. > + * @return > + * Returns 0 if ``v`` was 0, otherwise returns 1. > + */ > +static inline int > +rte_bsf64_safe(uint64_t v, uint32_t *pos) > +{ > + if (v =3D=3D 0) > + return 0; > + > + *pos =3D __builtin_ctzll(v); > + return 1; > +} >=20 > #ifndef offsetof > /** Return the offset of a field in a structure. */ > -- > 2.17.1