[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/5] xen/lib: Move simple_strtoul from common/vsprintf.c to lib



Move the simple_strtoul routine which is used throughout the codebase
from vsprintf.c to its own file in xen/lib.

This allows libfdt to be built on ppc64 even though xen/common doesn't
build yet.

Signed-off-by: Shawn Anastasio <sanastasio@xxxxxxxxxxxxxxxxxxxxx>
---
 xen/common/vsprintf.c    | 37 -------------------------------------
 xen/lib/Makefile         |  1 +
 xen/lib/simple_strtoul.c | 40 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 37 deletions(-)
 create mode 100644 xen/lib/simple_strtoul.c

diff --git a/xen/common/vsprintf.c b/xen/common/vsprintf.c
index b278961cc3..86330d8082 100644
--- a/xen/common/vsprintf.c
+++ b/xen/common/vsprintf.c
@@ -24,43 +24,6 @@
 #include <asm/div64.h>
 #include <asm/page.h>
 
-/**
- * simple_strtoul - convert a string to an unsigned long
- * @cp: The start of the string
- * @endp: A pointer to the end of the parsed string will be placed here
- * @base: The number base to use
- */
-unsigned long simple_strtoul(
-    const char *cp, const char **endp, unsigned int base)
-{
-    unsigned long result = 0,value;
-
-    if (!base) {
-        base = 10;
-        if (*cp == '0') {
-            base = 8;
-            cp++;
-            if ((toupper(*cp) == 'X') && isxdigit(cp[1])) {
-                cp++;
-                base = 16;
-            }
-        }
-    } else if (base == 16) {
-        if (cp[0] == '0' && toupper(cp[1]) == 'X')
-            cp += 2;
-    }
-    while (isxdigit(*cp) &&
-           (value = isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) {
-        result = result*base + value;
-        cp++;
-    }
-    if (endp)
-        *endp = cp;
-    return result;
-}
-
-EXPORT_SYMBOL(simple_strtoul);
-
 /**
  * simple_strtol - convert a string to a signed long
  * @cp: The start of the string
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index b311ea739c..bce76f9742 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -13,6 +13,7 @@ lib-y += memset.o
 lib-y += muldiv64.o
 lib-y += parse-size.o
 lib-y += rbtree.o
+lib-y += simple_strtoul.o
 lib-y += sort.o
 lib-y += strcasecmp.o
 lib-y += strchr.o
diff --git a/xen/lib/simple_strtoul.c b/xen/lib/simple_strtoul.c
new file mode 100644
index 0000000000..e43760ad1d
--- /dev/null
+++ b/xen/lib/simple_strtoul.c
@@ -0,0 +1,40 @@
+/*
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ */
+
+#include <xen/ctype.h>
+
+/**
+ * simple_strtoul - convert a string to an unsigned long
+ * @cp: The start of the string
+ * @endp: A pointer to the end of the parsed string will be placed here
+ * @base: The number base to use
+ */
+unsigned long simple_strtoul(
+    const char *cp, const char **endp, unsigned int base)
+{
+    unsigned long result = 0,value;
+
+    if (!base) {
+        base = 10;
+        if (*cp == '0') {
+            base = 8;
+            cp++;
+            if ((toupper(*cp) == 'X') && isxdigit(cp[1])) {
+                cp++;
+                base = 16;
+            }
+        }
+    } else if (base == 16) {
+        if (cp[0] == '0' && toupper(cp[1]) == 'X')
+            cp += 2;
+    }
+    while (isxdigit(*cp) &&
+           (value = isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) {
+        result = result*base + value;
+        cp++;
+    }
+    if (endp)
+        *endp = cp;
+    return result;
+}
-- 
2.30.2




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.