Index: lib/libc/stdlib/Makefile.inc
===================================================================
RCS file: /cvsroot/src/lib/libc/stdlib/Makefile.inc,v
retrieving revision 1.79
diff -u -r1.79 Makefile.inc
--- lib/libc/stdlib/Makefile.inc	26 Apr 2013 18:29:55 -0000	1.79
+++ lib/libc/stdlib/Makefile.inc	16 Nov 2013 22:02:09 -0000
@@ -30,7 +30,6 @@
 SRCS+=	malloc.c
 .endif
 
-CPPFLAGS.strtoimax.c+=	-I${LIBCDIR}/../../common/lib/libc/stdlib
 CPPFLAGS.strtol.c+=	-I${LIBCDIR}/../../common/lib/libc/stdlib
 CPPFLAGS.strtoq.c+=	-I${LIBCDIR}/../../common/lib/libc/stdlib
 CPPFLAGS.strtouq.c+=	-I${LIBCDIR}/../../common/lib/libc/stdlib
Index: lib/libc/stdlib/strtoimax.c
===================================================================
RCS file: lib/libc/stdlib/strtoimax.c
diff -N lib/libc/stdlib/strtoimax.c
--- lib/libc/stdlib/strtoimax.c	16 Apr 2013 21:44:08 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-/* $DragonFly: src/lib/libc/stdlib/strtoimax.c,v 1.2 2008/08/19 15:50:24 joerg Exp $ */
-
-/*-
- * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
- * Copyright (c) 2003 Citrus Project,
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if HAVE_NBTOOL_CONFIG_H
-#include "nbtool_config.h"
-#endif
-
-#include <sys/cdefs.h>
-__RCSID("$NetBSD: strtoimax.c,v 1.8 2013/04/16 21:44:08 joerg Exp $");
-
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <stdlib.h>
-
-#define	_FUNCNAME	strtoimax
-#define	__INT		intmax_t
-#define	__INT_MIN	INTMAX_MIN
-#define	__INT_MAX	INTMAX_MAX
-
-#include "_strtol.h"
-
-__strong_alias(_strtoimax, strtoimax)
-__strong_alias(_strtoimax_l, strtoimax_l)
Index: common/lib/libc/stdlib/strtoimax.c
===================================================================
RCS file: common/lib/libc/stdlib/strtoimax.c
diff -N common/lib/libc/stdlib/strtoimax.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ common/lib/libc/stdlib/strtoimax.c	16 Nov 2013 22:02:09 -0000
@@ -0,0 +1,68 @@
+/* $DragonFly: src/lib/libc/stdlib/strtoimax.c,v 1.2 2008/08/19 15:50:24 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2005 The DragonFly Project.  All rights reserved.
+ * Copyright (c) 2003 Citrus Project,
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if HAVE_NBTOOL_CONFIG_H
+#include "nbtool_config.h"
+#endif
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: strtoimax.c,v 1.8 2013/04/16 21:44:08 joerg Exp $");
+
+#ifdef _LIBC
+#include "namespace.h"
+#endif
+
+#if defined(_KERNEL)
+#include <sys/param.h>
+#include <lib/libkern/libkern.h>
+#elif defined(_STANDALONE)
+#include <sys/param.h>
+#include <lib/libkern/libkern.h>
+#include <lib/libsa/stand.h>
+#else
+#include <assert.h>
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdlib.h>
+#endif
+
+#define	_FUNCNAME	strtoimax
+#define	__INT		intmax_t
+#define	__INT_MIN	INTMAX_MIN
+#define	__INT_MAX	INTMAX_MAX
+
+#include "_strtol.h"
+
+#ifdef _LIBC
+__weak_alias(_strtoimax, strtoimax)
+__weak_alias(_strtoimax_l, strtoimax_l)
+#endif
Index: sys/lib/libkern/Makefile.libkern
===================================================================
RCS file: /cvsroot/src/sys/lib/libkern/Makefile.libkern,v
retrieving revision 1.26
diff -u -r1.26 Makefile.libkern
--- sys/lib/libkern/Makefile.libkern	23 Jul 2013 14:52:07 -0000	1.26
+++ sys/lib/libkern/Makefile.libkern	16 Nov 2013 22:02:09 -0000
@@ -80,7 +80,7 @@
 .endif
 
 SRCS+=	popcount32.c popcount64.c
-SRCS+=	strtoul.c strtoll.c strtoull.c strtoumax.c
+SRCS+=	strtoul.c strtoll.c strtoull.c strtoimax.c strtoumax.c
 
 SRCS+=	scanc.c skpc.c
 SRCS+=	random.c
Index: sys/lib/libkern/libkern.h
===================================================================
RCS file: /cvsroot/src/sys/lib/libkern/libkern.h,v
retrieving revision 1.108
diff -u -r1.108 libkern.h
--- sys/lib/libkern/libkern.h	28 Aug 2013 16:20:38 -0000	1.108
+++ sys/lib/libkern/libkern.h	16 Nov 2013 22:02:09 -0000
@@ -334,6 +334,7 @@
 u_long	 strtoul(const char *, char **, int);
 long long strtoll(const char *, char **, int);
 unsigned long long strtoull(const char *, char **, int);
+intmax_t  strtoimax(const char *, char **, int);
 uintmax_t strtoumax(const char *, char **, int);
 int	 snprintb(char *, size_t, const char *, uint64_t);
 int	 snprintb_m(char *, size_t, const char *, uint64_t, size_t);
Index: sys/modules/lua/Makefile
===================================================================
RCS file: /cvsroot/src/sys/modules/lua/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- sys/modules/lua/Makefile	31 Oct 2013 16:50:14 -0000	1.2
+++ sys/modules/lua/Makefile	16 Nov 2013 22:02:09 -0000
@@ -44,6 +44,7 @@
 
 CFLAGS+=	-include ${.CURDIR}/luaconf.h
 
-CPPFLAGS+=	-I${S}/../external/mit/lua/dist/src
+CPPFLAGS+=	-I${S}/../external/mit/lua/dist/src \
+		-I${S}/sys
 
 .include <bsd.kmodule.mk>
Index: sys/modules/lua/inttypes.h
===================================================================
RCS file: sys/modules/lua/inttypes.h
diff -N sys/modules/lua/inttypes.h
--- sys/modules/lua/inttypes.h	16 Oct 2013 19:44:57 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,6 +0,0 @@
-/*	$NetBSD: inttypes.h,v 1.1 2013/10/16 19:44:57 mbalmer Exp $ */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
Index: sys/modules/lua/luaconf.h
===================================================================
RCS file: /cvsroot/src/sys/modules/lua/luaconf.h,v
retrieving revision 1.1
diff -u -r1.1 luaconf.h
--- sys/modules/lua/luaconf.h	16 Oct 2013 19:44:57 -0000	1.1
+++ sys/modules/lua/luaconf.h	16 Nov 2013 22:02:10 -0000
@@ -505,8 +505,7 @@
 */
 
 #ifdef _KERNEL
-#define LUA_NUMBER	long long
-
+#define LUA_NUMBER	int64_t
 #else
 #define LUA_NUMBER_DOUBLE
 #define LUA_NUMBER	double
@@ -528,9 +527,9 @@
 */
 
 #ifdef _KERNEL
-#define LUA_NUMBER_SCAN		"%lld"
-#define LUA_NUMBER_FMT		"%lld"
-#define lua_str2number(s,p)	strtoll((s), (p), 10)
+#define LUA_NUMBER_SCAN		"%"SCNd64
+#define LUA_NUMBER_FMT		"%"PRId64
+#define lua_str2number(s,p)	((int64_t) strtoimax((s), (p), 10))
 #else
 #define LUA_NUMBER_SCAN		"%lf"
 #define LUA_NUMBER_FMT		"%.14g"
