From patchwork Mon Mar 18 11:18:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fengchengwen X-Patchwork-Id: 138452 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2B3DC43CE3; Mon, 18 Mar 2024 12:21:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B2A4740A8A; Mon, 18 Mar 2024 12:21:08 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by mails.dpdk.org (Postfix) with ESMTP id 9EE2D4027F for ; Mon, 18 Mar 2024 12:21:00 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Tysn833DNz1xrfl; Mon, 18 Mar 2024 19:19:08 +0800 (CST) Received: from dggpeml500024.china.huawei.com (unknown [7.185.36.10]) by mail.maildlp.com (Postfix) with ESMTPS id 2B4241400C9; Mon, 18 Mar 2024 19:20:59 +0800 (CST) Received: from localhost.localdomain (10.50.165.33) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Mon, 18 Mar 2024 19:20:58 +0800 From: Chengwen Feng To: , CC: Subject: [PATCH v4 3/6] argparse: replace flag enum with marco Date: Mon, 18 Mar 2024 11:18:35 +0000 Message-ID: <20240318111838.16991-4-fengchengwen@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240318111838.16991-1-fengchengwen@huawei.com> References: <20240220131502.47510-1-fengchengwen@huawei.com> <20240318111838.16991-1-fengchengwen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.50.165.33] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) 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 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) /** - * Flag definition (in bitmask form) for an argument. + * Flag for that argument support occur multiple times. + * This flag can be set only when the argument is optional. + * When this flag is set, the callback type must be used for parsing. */ -enum rte_argparse_flag { - /* - * Bits 0-1: represent the argument whether has value. - */ - - /** The argument has no value. */ - RTE_ARGPARSE_ARG_NO_VALUE = RTE_SHIFT_VAL64(1, 0), - /** The argument must have a value. */ - RTE_ARGPARSE_ARG_REQUIRED_VALUE = RTE_SHIFT_VAL64(2, 0), - /** The argument has optional value. */ - RTE_ARGPARSE_ARG_OPTIONAL_VALUE = RTE_SHIFT_VAL64(3, 0), - - - /* - * Bits 2-9: represent the value type which used when autosave - */ - - /** The argument's value is int type. */ - RTE_ARGPARSE_ARG_VALUE_INT = RTE_SHIFT_VAL64(1, 2), - /** The argument's value is uint8 type. */ - RTE_ARGPARSE_ARG_VALUE_U8 = RTE_SHIFT_VAL64(2, 2), - /** The argument's value is uint16 type. */ - RTE_ARGPARSE_ARG_VALUE_U16 = RTE_SHIFT_VAL64(3, 2), - /** The argument's value is uint32 type. */ - RTE_ARGPARSE_ARG_VALUE_U32 = RTE_SHIFT_VAL64(4, 2), - /** The argument's value is uint64 type. */ - RTE_ARGPARSE_ARG_VALUE_U64 = RTE_SHIFT_VAL64(5, 2), - /** Max value type. */ - RTE_ARGPARSE_ARG_VALUE_MAX = RTE_SHIFT_VAL64(6, 2), - - - /** - * Bit 10: flag for that argument support occur multiple times. - * This flag can be set only when the argument is optional. - * When this flag is set, the callback type must be used for parsing. - */ - RTE_ARGPARSE_ARG_SUPPORT_MULTI = RTE_BIT64(10), - - /** - * Bits 48-63: reserved for this library implementation usage. - */ - RTE_ARGPARSE_ARG_RESERVED_FIELD = RTE_GENMASK64(63, 48), -}; +#define RTE_ARGPARSE_ARG_SUPPORT_MULTI RTE_BIT64(10) +/** Reserved for this library implementation usage. */ +#define RTE_ARGPARSE_ARG_RESERVED_FIELD RTE_GENMASK64(63, 48) +/**@}*/ /** * A structure used to hold argument's configuration. @@ -126,7 +114,7 @@ struct rte_argparse_arg { */ void *val_set; - /** @see rte_argparse_flag */ + /** Flag definition (RTE_ARGPARSE_ARG_*) for the argument. */ uint64_t flags; };