eal: uninline some string formatting helper

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>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
This commit is contained in:
Dmitry Kozlyuk 2022-08-27 14:32:21 +03:00 committed by David Marchand
parent 107dc0664c
commit 347623c9c7
3 changed files with 35 additions and 28 deletions

View File

@ -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;
}

View File

@ -873,34 +873,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

View File

@ -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;