about summary refs log tree commit diff
path: root/src/stdlib/strtoll.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/strtoll.c')
-rw-r--r--src/stdlib/strtoll.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/stdlib/strtoll.c b/src/stdlib/strtoll.c
new file mode 100644
index 00000000..9ab66fd9
--- /dev/null
+++ b/src/stdlib/strtoll.c
@@ -0,0 +1,17 @@
+#include <stdlib.h>
+#include <inttypes.h>
+#include <errno.h>
+#include <limits.h>
+
+long long strtoll(const char *s, char **p, int base)
+{
+	intmax_t x = strtoimax(s, p, base);
+	if (x > LLONG_MAX) {
+		errno = ERANGE;
+		return LLONG_MAX;
+	} else if (x < LLONG_MIN) {
+		errno = ERANGE;
+		return LLONG_MIN;
+	}
+	return x;
+}