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 BC66A43C12; Thu, 7 Mar 2024 19:37:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A93A2402BA; Thu, 7 Mar 2024 19:37:44 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id EA0D740272 for ; Thu, 7 Mar 2024 19:37:42 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 3DDFD20B74C0; Thu, 7 Mar 2024 10:37:42 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 3DDFD20B74C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1709836662; bh=8S+RylF22x6GRy44041+czglB7InWLYtDm4mhQEkFd0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F4pxxXGVQUdGOo+PVZTHWa2WIWKF3MWcXSEidXV7AwDkRjBcDCmrDGH5b+a3RPNz+ UE89+3Icouft0f79MZkP76pm9bM2B8Rv8+dLKDm2+E2S5mhMYI9FRHftZvgAUmvpsG RwkXq4ioCwvOi11U7LF2SPH21h7w1Pflw23ZR/k0= Date: Thu, 7 Mar 2024 10:37:42 -0800 From: Tyler Retzlaff To: David Marchand Cc: Chengwen Feng , thomas@monjalon.net, dev@dpdk.org Subject: Re: [PATCH v2 3/5] argparse: replace flag enum with marco Message-ID: <20240307183742.GB22674@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <20240220131502.47510-1-fengchengwen@huawei.com> <20240307130742.5578-1-fengchengwen@huawei.com> <20240307130742.5578-4-fengchengwen@huawei.com> <20240307174300.GA14353@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Thu, Mar 07, 2024 at 06:58:20PM +0100, David Marchand wrote: > On Thu, Mar 7, 2024 at 6:43 PM Tyler Retzlaff > wrote: > > > > On Thu, Mar 07, 2024 at 01:07:40PM +0000, Chengwen Feng wrote: > > > The enum rte_argparse_flag's value is u64, but an enum in C is > > > represented as an int. This commit replace these enum values with > > > macro. > > > > > > Fixes: e3e579f5bab5 ("argparse: introduce argparse library") > > > Fixes: 5357c248c960 ("argparse: parse unsigned integers") > > > > > > Signed-off-by: Chengwen Feng > > > --- > > > lib/argparse/rte_argparse.h | 78 ++++++++++++++++--------------------- > > > 1 file changed, 33 insertions(+), 45 deletions(-) > > > > > > diff --git a/lib/argparse/rte_argparse.h b/lib/argparse/rte_argparse.h > > > index 47e231bef9..a6a7790cb4 100644 > > > --- a/lib/argparse/rte_argparse.h > > > +++ b/lib/argparse/rte_argparse.h > > > @@ -37,52 +37,40 @@ > > > extern "C" { > > > #endif > > > > > > +/**@{@name Flag definition (in bitmask form) for an argument > > > + * > > > + * @note Bits[0~1] represent the argument whether has value, > > > + * bits[2~9] represent the value type which used when autosave. > > > + * > > > + * @see struct rte_argparse_arg::flags > > > + */ > > > +/** The argument has no value. */ > > > +#define RTE_ARGPARSE_ARG_NO_VALUE RTE_SHIFT_VAL64(1, 0) > > > +/** The argument must have a value. */ > > > +#define RTE_ARGPARSE_ARG_REQUIRED_VALUE RTE_SHIFT_VAL64(2, 0) > > > +/** The argument has optional value. */ > > > +#define RTE_ARGPARSE_ARG_OPTIONAL_VALUE RTE_SHIFT_VAL64(3, 0) > > > +/** The argument's value is int type. */ > > > +#define RTE_ARGPARSE_ARG_VALUE_INT RTE_SHIFT_VAL64(1, 2) > > > +/** The argument's value is uint8 type. */ > > > +#define RTE_ARGPARSE_ARG_VALUE_U8 RTE_SHIFT_VAL64(2, 2) > > > +/** The argument's value is uint16 type. */ > > > +#define RTE_ARGPARSE_ARG_VALUE_U16 RTE_SHIFT_VAL64(3, 2) > > > +/** The argument's value is uint32 type. */ > > > +#define RTE_ARGPARSE_ARG_VALUE_U32 RTE_SHIFT_VAL64(4, 2) > > > +/** The argument's value is uint64 type. */ > > > +#define RTE_ARGPARSE_ARG_VALUE_U64 RTE_SHIFT_VAL64(5, 2) > > > +/** Max value type. */ > > > +#define RTE_ARGPARSE_ARG_VALUE_MAX RTE_SHIFT_VAL64(6, 2) > > > > it was good to get rid of the enum but will the above macros expand to > > signed or unsigned integer given the type of field could we make sure > > they expand unsigned? > > Afaiu, those should expand to unsigned: > #define RTE_SHIFT_VAL64(val, nr) (UINT64_C(val) << (nr)) Thanks for confirming! > > > -- > David Marchand