summaryrefslogtreecommitdiff
path: root/sys/modules/lua
diff options
context:
space:
mode:
authorlneto <lneto@NetBSD.org>2014-07-19 18:38:33 +0000
committerlneto <lneto@NetBSD.org>2014-07-19 18:38:33 +0000
commitc4b1eb35e827c43a0dcf41027c98aaedf46be036 (patch)
treef80015954e9c51266af4f2e1c57f2134cbcc1d62 /sys/modules/lua
parentc6d74635a1d93d95a3770bd621dcd83ed33100c2 (diff)
lua: updated from 5.1 to 5.3 work3
* lua(1): - changed lua_Integer to intmax_t - updated distrib/sets/lists and etc/mtree - updated bsd.lua.mk - fixed bozohttpd (lua-bozo.c) - compatibilized bindings: gpio, sqlite * lua(4): - removed floating-point and libc dependencies using '#ifndef _KERNEL' - fixed division by zero and exponentiation - libkern: added isalnum(), iscntrl(), isgraph(), isprint() and ispunct() - acpica: removed isprint() from acnetbsd.h - libc: moved strcspn.c, strpbrk.c and strspn.c to common - removed stub headers - compatibilized bindings: luapmf, luasystm * reorganized luaconf.h * updated doc/CHANGES and doc/RESPONSIBLE
Diffstat (limited to 'sys/modules/lua')
-rw-r--r--sys/modules/lua/Makefile41
-rw-r--r--sys/modules/lua/assert.h34
-rw-r--r--sys/modules/lua/ctype.h66
-rw-r--r--sys/modules/lua/errno.h0
-rw-r--r--sys/modules/lua/inttypes.h0
-rw-r--r--sys/modules/lua/limits.h8
-rw-r--r--sys/modules/lua/locale.h47
-rw-r--r--sys/modules/lua/lua.c8
-rw-r--r--sys/modules/lua/math.h6
-rw-r--r--sys/modules/lua/setjmp.h10
-rw-r--r--sys/modules/lua/signal.h6
-rw-r--r--sys/modules/lua/stdarg.h0
-rw-r--r--sys/modules/lua/stddef.h10
-rw-r--r--sys/modules/lua/stdio.h49
-rw-r--r--sys/modules/lua/stdlib.h45
-rw-r--r--sys/modules/lua/string.h21
-rw-r--r--sys/modules/lua/test.lua6
17 files changed, 14 insertions, 343 deletions
diff --git a/sys/modules/lua/Makefile b/sys/modules/lua/Makefile
index bf4dd1ab5e2..ece4aa38f2d 100644
--- a/sys/modules/lua/Makefile
+++ b/sys/modules/lua/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2014/07/19 17:21:24 lneto Exp $
+# $NetBSD: Makefile,v 1.8 2014/07/19 18:38:35 lneto Exp $
.include "../Makefile.inc"
@@ -8,43 +8,16 @@
KMOD= lua
SRCS= lua.c
-WARNS= 1
+WARNS= 0
# Lua core source code
-SRCS+= lapi.c \
- lcode.c \
- ldebug.c \
- ldo.c \
- ldump.c \
- lfunc.c \
- lgc.c \
- llex.c \
- lmem.c \
- lobject.c \
- lopcodes.c \
- lparser.c \
- lstate.c \
- lstring.c \
- ltable.c \
- ltm.c \
- lundump.c \
- lvm.c \
- lzio.c
-
-# Lua auxlib source code
-SRCS+= lauxlib.c
+SRCS+= lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c \
+ llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c \
+ lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c
# Lua stdlibs source code
-SRCS+= lbaselib.c \
- ldblib.c \
- lstrlib.c \
- ltablib.c \
- linit.c
-
-# Compatability code
-SRCS+= strcspn.c \
- strpbrk.c \
- strspn.c
+SRCS+= lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c \
+ lstrlib.c ltablib.c lutf8lib.c linit.c
CPPFLAGS+= -I${S}/../external/mit/lua/dist/src \
-I${S}/sys
diff --git a/sys/modules/lua/assert.h b/sys/modules/lua/assert.h
deleted file mode 100644
index 01d6c343a5b..00000000000
--- a/sys/modules/lua/assert.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* $NetBSD */
-
-/*
- * Copyright (c) 2011, Marc Balmer <mbalmer@NetBSD.org>.
- * 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.
- * 3. The name of the Author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * 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 REGENTS 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.
- */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
diff --git a/sys/modules/lua/ctype.h b/sys/modules/lua/ctype.h
deleted file mode 100644
index 192ae7dc17c..00000000000
--- a/sys/modules/lua/ctype.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/* $NetBSD */
-
-/*
- * Copyright (c) 2011, Lourival Neto <lneto@NetBSD.org>.
- * 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.
- * 3. The name of the Author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * 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 REGENTS 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.
- */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
-
-#include <sys/systm.h>
-
-#ifndef _LUA_INCLUDE_CTYPE_
-#define _LUA_INCLUDE_CTYPE_
-
-LIBKERN_INLINE int
-isalnum(int ch)
-{
- return (isalpha(ch) || isdigit(ch));
-}
-
-LIBKERN_INLINE int
-iscntrl(int ch)
-{
- return ((ch >= 0x00 && ch <= 0x1F) || ch == 0x7F);
-}
-
-LIBKERN_INLINE int
-isprint(int ch)
-{
- return (ch >= 0x20 && ch <= 0x7E);
-}
-
-LIBKERN_INLINE int
-ispunct(int ch)
-{
- return (isprint(ch) && ch != ' ' && !isalnum(ch));
-}
-
-#endif
-
diff --git a/sys/modules/lua/errno.h b/sys/modules/lua/errno.h
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sys/modules/lua/errno.h
+++ /dev/null
diff --git a/sys/modules/lua/inttypes.h b/sys/modules/lua/inttypes.h
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sys/modules/lua/inttypes.h
+++ /dev/null
diff --git a/sys/modules/lua/limits.h b/sys/modules/lua/limits.h
deleted file mode 100644
index 5c922c60c1e..00000000000
--- a/sys/modules/lua/limits.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* $NetBSD */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
-
-#include <machine/limits.h>
diff --git a/sys/modules/lua/locale.h b/sys/modules/lua/locale.h
deleted file mode 100644
index 17cb5ebe29b..00000000000
--- a/sys/modules/lua/locale.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* $NetBSD */
-
-/*
- * Copyright (c) 2011, Lourival Neto <lneto@NetBSD.org>.
- * 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.
- * 3. The name of the Author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * 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 REGENTS 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.
- */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
-
-#include <sys/null.h>
-
-#ifndef _LUA_INCLUDE_LOCALE_
-#define _LUA_INCLUDE_LOCALE_
-
-struct lconv {
- char *decimal_point;
-};
-
-#define localeconv() NULL
-#endif
-
diff --git a/sys/modules/lua/lua.c b/sys/modules/lua/lua.c
index 6aed4cc3153..636ec326d18 100644
--- a/sys/modules/lua/lua.c
+++ b/sys/modules/lua/lua.c
@@ -1,4 +1,4 @@
-/* $NetBSD: lua.c,v 1.11 2014/07/19 17:20:02 lneto Exp $ */
+/* $NetBSD: lua.c,v 1.12 2014/07/19 18:38:35 lneto Exp $ */
/*
* Copyright (c) 2014 by Lourival Vieira Neto <lneto@NetBSD.org>.
@@ -194,7 +194,7 @@ lua_attach(device_t parent, device_t self, void *aux)
NULL, 0, &lua_max_instr, 0,
CTL_CREATE, CTL_EOL);
- aprint_normal_dev(self, "%s %s\n", LUA_RELEASE, LUA_COPYRIGHT);
+ aprint_normal_dev(self, "%s\n", LUA_COPYRIGHT);
}
static int
@@ -424,7 +424,7 @@ luaioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
VOP_UNLOCK(nd.ni_vp);
klua_lock(s->K);
error = lua_load(s->K->L, lua_reader, &ls,
- strrchr(load->path, '/') + 1);
+ strrchr(load->path, '/') + 1, "bt");
vn_close(nd.ni_vp, FREAD, cred);
switch (error) {
case 0: /* no error */
@@ -509,7 +509,7 @@ lua_require(lua_State *L)
md->open(L);
md->refcount++;
LIST_INSERT_HEAD(&s->lua_modules, md, mod_next);
- return 0;
+ return 1;
}
lua_pushstring(L, "module not found");
diff --git a/sys/modules/lua/math.h b/sys/modules/lua/math.h
deleted file mode 100644
index 5d079ed3467..00000000000
--- a/sys/modules/lua/math.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* $NetBSD */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
diff --git a/sys/modules/lua/setjmp.h b/sys/modules/lua/setjmp.h
deleted file mode 100644
index 3870f09efca..00000000000
--- a/sys/modules/lua/setjmp.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* $NetBSD */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
-
-#include <machine/types.h>
-#include <sys/systm.h>
-
diff --git a/sys/modules/lua/signal.h b/sys/modules/lua/signal.h
deleted file mode 100644
index 5d079ed3467..00000000000
--- a/sys/modules/lua/signal.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* $NetBSD */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
diff --git a/sys/modules/lua/stdarg.h b/sys/modules/lua/stdarg.h
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/sys/modules/lua/stdarg.h
+++ /dev/null
diff --git a/sys/modules/lua/stddef.h b/sys/modules/lua/stddef.h
deleted file mode 100644
index 408bba368ba..00000000000
--- a/sys/modules/lua/stddef.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* $NetBSD */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
-
-#include <sys/types.h>
-#include <sys/null.h>
-
diff --git a/sys/modules/lua/stdio.h b/sys/modules/lua/stdio.h
deleted file mode 100644
index da5822ea416..00000000000
--- a/sys/modules/lua/stdio.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* $NetBSD */
-/*
- * Copyright (c) 2011, Lourival Neto <lneto@NetBSD.org>.
- * 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.
- * 3. The name of the Author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * 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 REGENTS 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.
- */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
-
-#include <sys/param.h>
-
-#ifndef _LUA_INCLUDE_STDIO
-#define _LUA_INCLUDE_STDIO
-
-#define fprintf(output, ...) printf(__VA_ARGS__)
-
-#define BUFSIZ (1024)
-
-#define putchar(c) printf("%c", c)
-
-#define fputs(s, f) printf("%s", s)
-
-#endif
-
diff --git a/sys/modules/lua/stdlib.h b/sys/modules/lua/stdlib.h
deleted file mode 100644
index d3cf9bc10da..00000000000
--- a/sys/modules/lua/stdlib.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* $NetBSD */
-
-/*
- * Copyright (c) 2011-2014, Lourival Neto <lneto@NetBSD.org>.
- * 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.
- * 3. The name of the Author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * 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 REGENTS 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.
- */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
-
-#include <sys/param.h>
-#include <sys/kmem.h>
-
-#ifndef _LUA_INCLUDE_STDLIB_
-#define _LUA_INCLUDE_STDLIB_
-
-#define exit(EXIT_FAILURE) return
-
-#endif
-
diff --git a/sys/modules/lua/string.h b/sys/modules/lua/string.h
deleted file mode 100644
index f54ade99316..00000000000
--- a/sys/modules/lua/string.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/* $NetBSD */
-
-/*
- * This file is a placeholder only, to allow Lua to be compiled from
- * unchanged sources.
- */
-
-#include <sys/param.h>
-
-#ifndef _LUA_INCLUDE_STRING_
-#define _LUA_INCLUDE_STRING_
-
-#define strcoll strcmp
-
-char *strncat(char *dst, const char *src, size_t n);
-size_t strspn(const char *s, const char *charset);
-size_t strcspn(const char *s, const char *charset);
-char *strpbrk(const char *s, const char *charset);
-
-#endif
-
diff --git a/sys/modules/lua/test.lua b/sys/modules/lua/test.lua
index 123dd493c87..113f760edc3 100644
--- a/sys/modules/lua/test.lua
+++ b/sys/modules/lua/test.lua
@@ -1,8 +1,8 @@
-require 'core'
+systm = require 'systm'
-core.print("hello, kernel world!\n")
+systm.print("hello, kernel world!\n")
function onClose()
- core.print('I am about to be closed\n')
+ systm.print('I am about to be closed\n')
end