]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - linux/kstrtox.c
Move c_src dirs back to toplevel
[bcachefs-tools-debian] / linux / kstrtox.c
index 193726514c4218cfc3450ee1625ad88a446a698d..bde558088e3952a1c164d4d12e2813f41fd65bba 100644 (file)
  * If -E is returned, result is not touched.
  */
 #include <errno.h>
-#include <linux/ctype.h>
+#include <ctype.h>
 #include <linux/kernel.h>
-#include <linux/math64.h>
-#include <linux/export.h>
 #include <linux/types.h>
 #include "kstrtox.h"
 
+#define KSTRTOX_OVERFLOW       (1U << 31)
+
 const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
 {
        if (*base == 0) {
@@ -69,7 +69,7 @@ unsigned int _parse_integer(const char *s, unsigned int base, unsigned long long
                 * it in the max base we support (16)
                 */
                if (unlikely(res & (~0ull << 60))) {
-                       if (res > div_u64(ULLONG_MAX - val, base))
+                       if (res > ULLONG_MAX - val / base)
                                overflow = 1;
                }
                res = res * base + val;
@@ -124,7 +124,6 @@ int kstrtoull(const char *s, unsigned int base, unsigned long long *res)
                s++;
        return _kstrtoull(s, base, res);
 }
-EXPORT_SYMBOL(kstrtoull);
 
 /**
  * kstrtoll - convert a string to a long long
@@ -164,7 +163,6 @@ int kstrtoll(const char *s, unsigned int base, long long *res)
        }
        return 0;
 }
-EXPORT_SYMBOL(kstrtoll);
 
 /* Internal, do not use. */
 int _kstrtoul(const char *s, unsigned int base, unsigned long *res)
@@ -180,7 +178,6 @@ int _kstrtoul(const char *s, unsigned int base, unsigned long *res)
        *res = tmp;
        return 0;
 }
-EXPORT_SYMBOL(_kstrtoul);
 
 /* Internal, do not use. */
 int _kstrtol(const char *s, unsigned int base, long *res)
@@ -196,7 +193,6 @@ int _kstrtol(const char *s, unsigned int base, long *res)
        *res = tmp;
        return 0;
 }
-EXPORT_SYMBOL(_kstrtol);
 
 /**
  * kstrtouint - convert a string to an unsigned int
@@ -227,7 +223,6 @@ int kstrtouint(const char *s, unsigned int base, unsigned int *res)
        *res = tmp;
        return 0;
 }
-EXPORT_SYMBOL(kstrtouint);
 
 /**
  * kstrtoint - convert a string to an int
@@ -258,7 +253,6 @@ int kstrtoint(const char *s, unsigned int base, int *res)
        *res = tmp;
        return 0;
 }
-EXPORT_SYMBOL(kstrtoint);
 
 int kstrtou16(const char *s, unsigned int base, u16 *res)
 {
@@ -273,7 +267,6 @@ int kstrtou16(const char *s, unsigned int base, u16 *res)
        *res = tmp;
        return 0;
 }
-EXPORT_SYMBOL(kstrtou16);
 
 int kstrtos16(const char *s, unsigned int base, s16 *res)
 {
@@ -288,7 +281,6 @@ int kstrtos16(const char *s, unsigned int base, s16 *res)
        *res = tmp;
        return 0;
 }
-EXPORT_SYMBOL(kstrtos16);
 
 int kstrtou8(const char *s, unsigned int base, u8 *res)
 {
@@ -303,7 +295,6 @@ int kstrtou8(const char *s, unsigned int base, u8 *res)
        *res = tmp;
        return 0;
 }
-EXPORT_SYMBOL(kstrtou8);
 
 int kstrtos8(const char *s, unsigned int base, s8 *res)
 {
@@ -318,7 +309,6 @@ int kstrtos8(const char *s, unsigned int base, s8 *res)
        *res = tmp;
        return 0;
 }
-EXPORT_SYMBOL(kstrtos8);
 
 /**
  * kstrtobool - convert common user inputs into boolean values
@@ -365,4 +355,3 @@ int kstrtobool(const char *s, bool *res)
 
        return -EINVAL;
 }
-EXPORT_SYMBOL(kstrtobool);