aboutsummaryrefslogtreecommitdiff
path: root/arch/powerpc/boot/stdlib.c
diff options
context:
space:
mode:
authorScott Wood <scottwood@freescale.com>2007-09-06 05:21:10 +1000
committerPaul Mackerras <paulus@samba.org>2007-09-14 01:33:23 +1000
commit9de782770b84768e1aa2e6454223ef30768de84e (patch)
tree24067851c7b5315f1b6c0ade463d039ee3e65a61 /arch/powerpc/boot/stdlib.c
parent4674f2f33948432469e52d5bcaeda9904e34fe46 (diff)
[POWERPC] bootwrapper: Add strtoull()
This will be needed by PlanetCore firmware support. Signed-off-by: Scott Wood <scottwood@freescale.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot/stdlib.c')
-rw-r--r--arch/powerpc/boot/stdlib.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/arch/powerpc/boot/stdlib.c b/arch/powerpc/boot/stdlib.c
new file mode 100644
index 00000000000..e00d58c29ee
--- /dev/null
+++ b/arch/powerpc/boot/stdlib.c
@@ -0,0 +1,45 @@
+/*
+ * stdlib functions
+ *
+ * Author: Scott Wood <scottwood@freescale.com>
+ *
+ * Copyright (c) 2007 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#include "stdlib.h"
+
+/* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
+unsigned long long int strtoull(const char *ptr, char **end, int base)
+{
+ unsigned long long ret = 0;
+
+ if (base > 36)
+ goto out;
+
+ while (*ptr) {
+ int digit;
+
+ if (*ptr >= '0' && *ptr <= '9' && *ptr < '0' + base)
+ digit = *ptr - '0';
+ else if (*ptr >= 'A' && *ptr < 'A' + base - 10)
+ digit = *ptr - 'A' + 10;
+ else if (*ptr >= 'a' && *ptr < 'a' + base - 10)
+ digit = *ptr - 'a' + 10;
+ else
+ break;
+
+ ret *= base;
+ ret += digit;
+ ptr++;
+ }
+
+out:
+ if (end)
+ *end = (char *)ptr;
+
+ return ret;
+}