aboutsummaryrefslogtreecommitdiffstats
path: root/strtou64.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--strtou64.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/strtou64.c b/strtou64.c
new file mode 100644
index 0000000..1deb3a5
--- /dev/null
+++ b/strtou64.c
@@ -0,0 +1,31 @@
+/* See LICENSE file for copyright and license details. */
+#include "libsimple.h"
+#ifndef TEST
+
+#define RET_MAX 18446744073709551615ULL
+
+
+uint_least64_t
+libsimple_strtou64(const char *restrict nptr, char **restrict end, int base) /* TODO test, man */
+{
+ uintmax_t r = strtoumax(nptr, end, base);
+#if UINTMAX_MAX > RET_MAX
+ if(r > RET_MAX) {
+ r = RET_MAX;
+ errno = ERANGE;
+ }
+#endif
+ return (uint_least64_t)r;
+}
+
+
+#else
+#include "test.h"
+
+int
+main(void)
+{
+ return 0;
+}
+
+#endif