aboutsummaryrefslogtreecommitdiff
path: root/lib/strto.c
diff options
context:
space:
mode:
authorRoland Gaudig2021-07-23 12:29:18 +0000
committerTom Rini2021-07-27 14:50:47 -0400
commit0b016428a7be4518e4e880536d8ecd8f980fcfd8 (patch)
tree86185f7fca1212c57c2e64a0b15632b5cc9ff2e9 /lib/strto.c
parent55efa84d0f523b0609d6947d232c000824315a68 (diff)
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 <roland.gaudig@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/strto.c')
-rw-r--r--lib/strto.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/strto.c b/lib/strto.c
index c00bb5895df..f8b53d846b3 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;