From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
To: dev@dpdk.org
Cc: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>, Ray Kinsella <mdr@ashroe.eu>
Subject: [PATCH 2/3] eal: uninline rte_str_to_size
Date: Sun, 21 Aug 2022 23:50:08 +0300 [thread overview]
Message-ID: <20220821205009.1317044-3-dmitry.kozliuk@gmail.com> (raw)
In-Reply-To: <20220821205009.1317044-1-dmitry.kozliuk@gmail.com>
There is no reason for rte_str_to_size() to be inline.
Move the implementation out of <rte_common.h>.
Export it as a stable ABI because it always has been public.
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
---
Now <rte_common.h> doesn't need to #include <ctypes.h> and <stdlib.h>,
but removing them breaks some DPDK code, may break user code too.
I'm not sure what is the compatibility policy in this regard.
If such a breakage is allowed, I'd remove includes and fix DPDK code.
lib/eal/common/eal_common_string_fns.c | 32 ++++++++++++++++++++++++++
lib/eal/include/rte_common.h | 30 ++----------------------
lib/eal/version.map | 1 +
3 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/lib/eal/common/eal_common_string_fns.c b/lib/eal/common/eal_common_string_fns.c
index 0236ae4023..5fc4ee71dc 100644
--- a/lib/eal/common/eal_common_string_fns.c
+++ b/lib/eal/common/eal_common_string_fns.c
@@ -64,3 +64,35 @@ rte_strscpy(char *dst, const char *src, size_t dsize)
rte_errno = E2BIG;
return -rte_errno;
}
+
+uint64_t
+rte_str_to_size(const char *str)
+{
+ char *endptr;
+ unsigned long long size;
+
+ while (isspace((int)*str))
+ str++;
+ if (*str == '-')
+ return 0;
+
+ errno = 0;
+ size = strtoull(str, &endptr, 0);
+ if (errno)
+ return 0;
+
+ if (*endptr == ' ')
+ endptr++; /* allow 1 space gap */
+
+ switch (*endptr) {
+ case 'G': case 'g':
+ size *= 1024; /* fall-through */
+ case 'M': case 'm':
+ size *= 1024; /* fall-through */
+ case 'K': case 'k':
+ size *= 1024; /* fall-through */
+ default:
+ break;
+ }
+ return size;
+}
diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index d517e9f75f..772e40f8c2 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -875,34 +875,8 @@ rte_log2_u64(uint64_t v)
* @return
* Number.
*/
-static inline uint64_t
-rte_str_to_size(const char *str)
-{
- char *endptr;
- unsigned long long size;
-
- while (isspace((int)*str))
- str++;
- if (*str == '-')
- return 0;
-
- errno = 0;
- size = strtoull(str, &endptr, 0);
- if (errno)
- return 0;
-
- if (*endptr == ' ')
- endptr++; /* allow 1 space gap */
-
- switch (*endptr){
- case 'G': case 'g': size *= 1024; /* fall-through */
- case 'M': case 'm': size *= 1024; /* fall-through */
- case 'K': case 'k': size *= 1024; /* fall-through */
- default:
- break;
- }
- return size;
-}
+uint64_t
+rte_str_to_size(const char *str);
/**
* Function to terminate the application immediately, printing an error
diff --git a/lib/eal/version.map b/lib/eal/version.map
index 1f293e768b..773b0902c0 100644
--- a/lib/eal/version.map
+++ b/lib/eal/version.map
@@ -261,6 +261,7 @@ DPDK_23 {
rte_socket_id;
rte_socket_id_by_idx;
rte_srand;
+ rte_str_to_size;
rte_strerror;
rte_strscpy;
rte_strsplit;
--
2.33.1
next prev parent reply other threads:[~2022-08-21 20:50 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-21 20:50 [PATCH 0/3] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
2022-08-21 20:50 ` [PATCH 1/3] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
2022-08-22 7:14 ` Morten Brørup
2022-08-21 20:50 ` Dmitry Kozlyuk [this message]
2022-08-22 7:24 ` [PATCH 2/3] eal: uninline rte_str_to_size Morten Brørup
2022-08-22 14:06 ` Bruce Richardson
2022-08-21 20:50 ` [PATCH 3/3] eal: deduplicate roundup code Dmitry Kozlyuk
2022-08-22 7:25 ` Morten Brørup
2022-08-22 14:06 ` [PATCH 0/3] eal: small rte_common.h fixes and cleanup Bruce Richardson
2022-08-24 3:52 ` fengchengwen
2022-08-25 15:37 ` [PATCH v2 0/4] " Dmitry Kozlyuk
2022-08-25 15:37 ` [PATCH v2 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
2022-08-25 15:37 ` [PATCH v2 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
2022-08-25 15:37 ` [PATCH v2 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
2022-08-25 15:37 ` [PATCH v2 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
2022-08-25 22:33 ` [PATCH v3 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
2022-08-25 22:33 ` [PATCH v3 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
2022-08-25 22:33 ` [PATCH v3 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
2022-08-25 22:33 ` [PATCH v3 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
2022-08-25 22:33 ` [PATCH v3 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
2022-08-27 11:32 ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup Dmitry Kozlyuk
2022-08-27 11:32 ` [PATCH v4 1/4] eal: fix pointer arithmetic with an expression argument Dmitry Kozlyuk
2022-08-27 11:32 ` [PATCH v4 2/4] eal: deduplicate roundup code Dmitry Kozlyuk
2022-08-27 11:32 ` [PATCH v4 3/4] eal: uninline rte_str_to_size Dmitry Kozlyuk
2022-08-27 11:32 ` [PATCH v4 4/4] eal: remove unneeded includes from a public header Dmitry Kozlyuk
2022-08-29 8:29 ` Bruce Richardson
2022-09-21 9:27 ` David Marchand
2022-09-21 11:37 ` David Marchand
2022-09-21 13:30 ` [PATCH v4 0/4] eal: small rte_common.h fixes and cleanup David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220821205009.1317044-3-dmitry.kozliuk@gmail.com \
--to=dmitry.kozliuk@gmail.com \
--cc=dev@dpdk.org \
--cc=mdr@ashroe.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).