summaryrefslogtreecommitdiff
path: root/src/stdlib/strtoull.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/strtoull.c')
-rw-r--r--src/stdlib/strtoull.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/stdlib/strtoull.c b/src/stdlib/strtoull.c
new file mode 100644
index 00000000..20aa7bde
--- /dev/null
+++ b/src/stdlib/strtoull.c
@@ -0,0 +1,14 @@
+#include <stdlib.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <limits.h>
+
+unsigned long long strtoull(const char *s, char **p, int base)
+{
+ uintmax_t x = strtoumax(s, p, base);
+ if (x > ULLONG_MAX) {
+ errno = ERANGE;
+ return ULLONG_MAX;
+ }
+ return x;
+}