[PATCH 03/10] lib: implement simple_strtoll

Sascha Hauer s.hauer at pengutronix.de
Mon Apr 10 00:14:13 PDT 2017


Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 include/linux/kernel.h | 1 +
 lib/strtox.c           | 8 ++++++++
 2 files changed, 9 insertions(+)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 945e063f02..b4d2f09081 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -92,6 +92,7 @@ void __noreturn panic(const char *fmt, ...);
 extern unsigned long simple_strtoul(const char *,char **,unsigned int);
 extern long simple_strtol(const char *,char **,unsigned int);
 extern unsigned long long simple_strtoull(const char *,char **,unsigned int);
+extern long long simple_strtoll(const char *,char **,unsigned int);
 
 /*
  * min()/max()/clamp() macros that also do
diff --git a/lib/strtox.c b/lib/strtox.c
index cfe61240cc..ba183c1dd3 100644
--- a/lib/strtox.c
+++ b/lib/strtox.c
@@ -65,3 +65,11 @@ unsigned long long simple_strtoull (const char *cp, char **endp, unsigned int ba
 	return result;
 }
 EXPORT_SYMBOL(simple_strtoull);
+
+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);
+}
+EXPORT_SYMBOL(simple_strtoll);
-- 
2.11.0




More information about the barebox mailing list