1 #include "stdio_impl.h"
8 static unsigned long long strtox(const char *s, char **p, int base, unsigned long long lim)
10 /* FIXME: use a helper function or macro to setup the FILE */
13 f.buf = f.rpos = (void *)s;
14 if ((size_t)s > (size_t)-1/2)
17 f.rend = (unsigned char *)s+(size_t)-1/2;
20 unsigned long long y = __intscan(&f, base, 1, lim);
22 size_t cnt = shcnt(&f);
28 unsigned long long strtoull(const char *restrict s, char **restrict p, int base)
30 return strtox(s, p, base, ULLONG_MAX);
33 long long strtoll(const char *restrict s, char **restrict p, int base)
35 return strtox(s, p, base, LLONG_MIN);
38 unsigned long strtoul(const char *restrict s, char **restrict p, int base)
40 return strtox(s, p, base, ULONG_MAX);
43 long strtol(const char *restrict s, char **restrict p, int base)
45 return strtox(s, p, base, 0UL+LONG_MIN);
48 intmax_t strtoimax(const char *restrict s, char **restrict p, int base)
50 return strtoll(s, p, base);
53 uintmax_t strtoumax(const char *restrict s, char **restrict p, int base)
55 return strtoull(s, p, base);
58 weak_alias(strtol, __strtol_internal);
59 weak_alias(strtoul, __strtoul_internal);
60 weak_alias(strtoll, __strtoll_internal);
61 weak_alias(strtoull, __strtoull_internal);
62 weak_alias(strtoimax, __strtoimax_internal);
63 weak_alias(strtoumax, __strtoumax_internal);