SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
- lib/num2str.c lib/ieee754.c engines/cpu.c \
+ lib/num2str.c lib/ieee754.c lib/strntol.c engines/cpu.c \
engines/mmap.c engines/sync.c engines/null.c engines/net.c \
memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
--- /dev/null
+#include <string.h>
+#include <stdlib.h>
+#include <limits.h>
+
+long strntol(const char *str, size_t sz, char **end, int base)
+{
+ /* Expect that digit representation of LONG_MAX/MIN
+ * not greater than this buffer */
+ char buf[24];
+ long ret;
+ const char *beg = str;
+
+ /* Catch up leading spaces */
+ for (; beg && sz && *beg == ' '; beg++, sz--)
+ ;
+
+ if (!sz || sz >= sizeof(buf)) {
+ if (end)
+ *end = (char *)str;
+ return 0;
+ }
+
+ memcpy(buf, beg, sz);
+ buf[sz] = '\0';
+ ret = strtol(buf, end, base);
+ if (ret == LONG_MIN || ret == LONG_MAX)
+ return ret;
+ if (end)
+ *end = (char *)str + (*end - buf);
+ return ret;
+}