From 0b016428a7be4518e4e880536d8ecd8f980fcfd8 Mon Sep 17 00:00:00 2001 From: Roland Gaudig Date: Fri, 23 Jul 2021 12:29:18 +0000 Subject: lib: strto: add simple_strtoll function Add simple_strtoll function for converting a string containing digits into a long long int value. Signed-off-by: Roland Gaudig Reviewed-by: Simon Glass --- lib/strto.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/strto.c b/lib/strto.c index c00bb5895d..f8b53d846b 100644 --- a/lib/strto.c +++ b/lib/strto.c @@ -143,6 +143,14 @@ unsigned long long simple_strtoull(const char *cp, char **endp, return result; } +long long simple_strtoll(const char *cp, char **endp, unsigned int base) +{ + if (*cp == '-') + return -simple_strtoull(cp + 1, endp, base); + + return simple_strtoull(cp, endp, base); +} + long trailing_strtoln(const char *str, const char *end) { const char *p; -- cgit v1.2.1