summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vsprintf.h13
-rw-r--r--lib/strto.c5
2 files changed, 18 insertions, 0 deletions
diff --git a/include/vsprintf.h b/include/vsprintf.h
index fe951471426..9da6ce7cc4d 100644
--- a/include/vsprintf.h
+++ b/include/vsprintf.h
@@ -45,6 +45,19 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base);
unsigned long hextoul(const char *cp, char **endp);
/**
+ * hex_strtoull - convert a string in hex to an unsigned long long
+ *
+ * @cp: The string to be converted
+ * @endp: Updated to point to the first character not converted
+ * Return: value decoded from string (0 if invalid)
+ *
+ * Converts a hex string to an unsigned long long. If there are invalid
+ * characters at the end these are ignored. In the worst case, if all characters
+ * are invalid, 0 is returned
+ */
+unsigned long long hextoull(const char *cp, char **endp);
+
+/**
* dec_strtoul - convert a string in decimal to an unsigned long
*
* @cp: The string to be converted
diff --git a/lib/strto.c b/lib/strto.c
index f83ac67c666..206d1e91847 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -78,6 +78,11 @@ ulong hextoul(const char *cp, char **endp)
return simple_strtoul(cp, endp, 16);
}
+unsigned long long hextoull(const char *cp, char **endp)
+{
+ return simple_strtoull(cp, endp, 16);
+}
+
ulong dectoul(const char *cp, char **endp)
{
return simple_strtoul(cp, endp, 10);