From 7329e722ea800485ce3493d592b8fd909f56636f Mon Sep 17 00:00:00 2001 From: Matias Elo Date: Wed, 18 Nov 2020 18:21:54 +0200 Subject: linux-dpdk: system: use dpdk function rte_str_to_size() directly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove copy of DPDK rte_str_to_size() function. Signed-off-by: Matias Elo Reviewed-by: Jere Leppänen --- platform/linux-dpdk/odp_system_info.c | 53 +---------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) (limited to 'platform/linux-dpdk/odp_system_info.c') diff --git a/platform/linux-dpdk/odp_system_info.c b/platform/linux-dpdk/odp_system_info.c index 3a0f59648..e9c81328f 100644 --- a/platform/linux-dpdk/odp_system_info.c +++ b/platform/linux-dpdk/odp_system_info.c @@ -114,56 +114,6 @@ static uint64_t default_huge_page_size(void) return 0; } -/* - * Converts a numeric string to the equivalent uint64_t value. - * As well as straight number conversion, also recognises the suffixes - * k, m and g for kilobytes, megabytes and gigabytes respectively. - * - * If a negative number is passed in i.e. a string with the first non-black - * character being "-", zero is returned. Zero is also returned in the case of - * an error with the strtoull call in the function. - * largely "inspired" by dpdk: - * lib/librte_eal/common/include/rte_common.h: rte_str_to_size - * - * param str - * String containing number to convert. - * return - * Number. - */ -static inline uint64_t 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; -} - /* * returns a malloced string containing the name of the directory for * huge pages of a given size (0 for default) @@ -222,8 +172,7 @@ static char *get_hugepage_dir(uint64_t hugepage_sz) break; } } else { /* there is an explicit page size, so check it */ - pagesz = - str_to_size(&pagesz_str[pagesize_opt_len]); + pagesz = rte_str_to_size(&pagesz_str[pagesize_opt_len]); if (pagesz == hugepage_sz) { retval = strdup(tokens[MOUNTPT]); break; -- cgit v1.2.3