add updated lua patchset from Steven Barth (cyrus) as explained in http://lists.openwrt.org/pipermail/openwrt-devel/2008-May/002170.html

SVN-Revision: 11239
This commit is contained in:
Felix Fietkau 2008-05-22 14:20:36 +00:00
parent b8652e42e8
commit 6fa85238f5
5 changed files with 4026 additions and 100 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,24 +1,83 @@
#
# Copyright (C) 2006 OpenWrt.org
#
Index: lua-5.1.3/Makefile
===================================================================
--- lua-5.1.3.orig/Makefile 2008-02-20 00:06:06.000000000 +0100
+++ lua-5.1.3/Makefile 2008-02-20 00:06:07.000000000 +0100
@@ -38,7 +38,7 @@
diff -ur lua-5.1.3-pt1/Makefile lua-5.1.3-pt2/Makefile
--- lua-5.1.3-pt1/Makefile 2008-04-05 14:23:14.000000000 +0200
+++ lua-5.1.3-pt2/Makefile 2008-04-05 15:13:38.000000000 +0200
@@ -37,8 +37,8 @@
# What to install.
TO_BIN= lua luac
TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
-TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp
-TO_LIB= liblua.a
+TO_INC= lua.h luaconf.h lualib.h lauxlib.h ../etc/lua.hpp lnum_config.h
+TO_LIB= liblua.a liblua.so liblua.so.$R
TO_MAN= lua.1 luac.1
# Lua version and release.
Index: lua-5.1.3/src/Makefile
===================================================================
--- lua-5.1.3.orig/src/Makefile 2008-02-20 00:06:06.000000000 +0100
+++ lua-5.1.3/src/Makefile 2008-02-20 00:06:07.000000000 +0100
diff -ur lua-5.1.3-pt1/src/ldo.h lua-5.1.3-pt2/src/ldo.h
--- lua-5.1.3-pt1/src/ldo.h 2008-04-05 14:23:14.000000000 +0200
+++ lua-5.1.3-pt2/src/ldo.h 2008-04-05 14:25:40.000000000 +0200
@@ -46,7 +46,7 @@
LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
-LUAI_FUNC void luaD_growstack (lua_State *L, int n);
+LUA_API void luaD_growstack (lua_State *L, int n);
LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
diff -ur lua-5.1.3-pt1/src/lfunc.h lua-5.1.3-pt2/src/lfunc.h
--- lua-5.1.3-pt1/src/lfunc.h 2008-04-05 14:23:14.000000000 +0200
+++ lua-5.1.3-pt2/src/lfunc.h 2008-04-05 14:25:40.000000000 +0200
@@ -18,7 +18,7 @@
cast(int, sizeof(TValue *)*((n)-1)))
-LUAI_FUNC Proto *luaF_newproto (lua_State *L);
+LUA_API Proto *luaF_newproto (lua_State *L);
LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
diff -ur lua-5.1.3-pt1/src/lmem.h lua-5.1.3-pt2/src/lmem.h
--- lua-5.1.3-pt1/src/lmem.h 2008-04-05 14:23:14.000000000 +0200
+++ lua-5.1.3-pt2/src/lmem.h 2008-04-05 14:25:40.000000000 +0200
@@ -38,9 +38,9 @@
((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
+LUA_API void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
size_t size);
-LUAI_FUNC void *luaM_toobig (lua_State *L);
+LUA_API void *luaM_toobig (lua_State *L);
LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
size_t size_elem, int limit,
const char *errormsg);
diff -ur lua-5.1.3-pt1/src/lstring.h lua-5.1.3-pt2/src/lstring.h
--- lua-5.1.3-pt1/src/lstring.h 2008-04-05 14:23:14.000000000 +0200
+++ lua-5.1.3-pt2/src/lstring.h 2008-04-05 14:25:40.000000000 +0200
@@ -25,7 +25,7 @@
LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
+LUA_API TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
#endif
diff -ur lua-5.1.3-pt1/src/lundump.h lua-5.1.3-pt2/src/lundump.h
--- lua-5.1.3-pt1/src/lundump.h 2008-04-05 14:23:14.000000000 +0200
+++ lua-5.1.3-pt2/src/lundump.h 2008-04-05 14:25:40.000000000 +0200
@@ -17,7 +17,7 @@
LUAI_FUNC void luaU_header (char* h);
/* dump one chunk; from ldump.c */
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
#ifdef luac_c
/* print one chunk; from print.c */
diff -ur lua-5.1.3-pt1/src/Makefile lua-5.1.3-pt2/src/Makefile
--- lua-5.1.3-pt1/src/Makefile 2008-04-05 14:23:31.000000000 +0200
+++ lua-5.1.3-pt2/src/Makefile 2008-04-05 14:25:40.000000000 +0200
@@ -23,6 +23,7 @@
PLATS= aix ansi bsd freebsd generic linux macosx mingw posix solaris
@ -26,7 +85,7 @@ Index: lua-5.1.3/src/Makefile
+LUA_SO= liblua.so
CORE_O= lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o \
lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o \
lundump.o lvm.o lzio.o
lundump.o lvm.o lzio.o lnum.o
@@ -33,11 +34,12 @@
LUA_O= lua.o
@ -42,7 +101,7 @@ Index: lua-5.1.3/src/Makefile
default: $(PLAT)
@@ -47,15 +49,21 @@
@@ -47,14 +49,23 @@
a: $(ALL_A)
@ -60,15 +119,16 @@ Index: lua-5.1.3/src/Makefile
+
+$(LUA_T): $(LUA_O) $(LUA_SO)
+ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUA_O) $(LIBS)
-$(LUAC_T): $(LUAC_O) $(LUA_A)
- $(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
+
+$(LUAC_T): $(LUAC_O) $(LUA_SO)
+ $(CC) -o $@ -L. -llua $(MYLDFLAGS) $(LUAC_O) $(LIBS)
-$(LUAC_T): $(LUAC_O) $(LUA_A)
+$(LUAC_T)-host: $(LUAC_O) $(LUA_A)
$(CC) -o $@ $(MYLDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS)
clean:
$(RM) $(ALL_T) $(ALL_O)
@@ -96,7 +104,7 @@
@@ -96,7 +107,7 @@
$(MAKE) all MYCFLAGS=
linux:
@ -77,71 +137,3 @@ Index: lua-5.1.3/src/Makefile
macosx:
$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
Index: lua-5.1.3/src/ldo.h
===================================================================
--- lua-5.1.3.orig/src/ldo.h 2008-02-20 00:06:06.000000000 +0100
+++ lua-5.1.3/src/ldo.h 2008-02-20 00:06:07.000000000 +0100
@@ -46,7 +46,7 @@
LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult);
LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize);
LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
-LUAI_FUNC void luaD_growstack (lua_State *L, int n);
+LUA_API void luaD_growstack (lua_State *L, int n);
LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
Index: lua-5.1.3/src/lfunc.h
===================================================================
--- lua-5.1.3.orig/src/lfunc.h 2008-02-20 00:06:06.000000000 +0100
+++ lua-5.1.3/src/lfunc.h 2008-02-20 00:06:07.000000000 +0100
@@ -18,7 +18,7 @@
cast(int, sizeof(TValue *)*((n)-1)))
-LUAI_FUNC Proto *luaF_newproto (lua_State *L);
+LUA_API Proto *luaF_newproto (lua_State *L);
LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e);
LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e);
LUAI_FUNC UpVal *luaF_newupval (lua_State *L);
Index: lua-5.1.3/src/lmem.h
===================================================================
--- lua-5.1.3.orig/src/lmem.h 2008-02-20 00:06:06.000000000 +0100
+++ lua-5.1.3/src/lmem.h 2008-02-20 00:06:07.000000000 +0100
@@ -38,9 +38,9 @@
((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t))))
-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
+LUA_API void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize,
size_t size);
-LUAI_FUNC void *luaM_toobig (lua_State *L);
+LUA_API void *luaM_toobig (lua_State *L);
LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size,
size_t size_elem, int limit,
const char *errormsg);
Index: lua-5.1.3/src/lstring.h
===================================================================
--- lua-5.1.3.orig/src/lstring.h 2008-02-20 00:06:06.000000000 +0100
+++ lua-5.1.3/src/lstring.h 2008-02-20 00:06:07.000000000 +0100
@@ -25,7 +25,7 @@
LUAI_FUNC void luaS_resize (lua_State *L, int newsize);
LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e);
-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
+LUA_API TString *luaS_newlstr (lua_State *L, const char *str, size_t l);
#endif
Index: lua-5.1.3/src/lundump.h
===================================================================
--- lua-5.1.3.orig/src/lundump.h 2008-02-20 00:06:06.000000000 +0100
+++ lua-5.1.3/src/lundump.h 2008-02-20 00:06:07.000000000 +0100
@@ -17,7 +17,7 @@
LUAI_FUNC void luaU_header (char* h);
/* dump one chunk; from ldump.c */
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
+LUA_API int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip);
#ifdef luac_c
/* print one chunk; from print.c */

View file

@ -0,0 +1,113 @@
diff -ur lua-5.1.3-pt2/src/ldump.c lua-5.1.3-pt3/src/ldump.c
--- lua-5.1.3-pt2/src/ldump.c 2008-04-05 14:25:13.000000000 +0200
+++ lua-5.1.3-pt3/src/ldump.c 2008-04-05 14:28:27.000000000 +0200
@@ -67,12 +67,12 @@
{
if (s==NULL || getstr(s)==NULL)
{
- size_t size=0;
+ unsigned int size=0;
DumpVar(size,D);
}
else
{
- size_t size=s->tsv.len+1; /* include trailing '\0' */
+ unsigned int size=s->tsv.len+1; /* include trailing '\0' */
DumpVar(size,D);
DumpBlock(getstr(s),size,D);
}
diff -ur lua-5.1.3-pt2/src/lundump.c lua-5.1.3-pt3/src/lundump.c
--- lua-5.1.3-pt2/src/lundump.c 2008-04-05 14:25:13.000000000 +0200
+++ lua-5.1.3-pt3/src/lundump.c 2008-04-05 14:28:27.000000000 +0200
@@ -25,6 +25,7 @@
ZIO* Z;
Mbuffer* b;
const char* name;
+ int swap;
} LoadState;
#ifdef LUAC_TRUST_BINARIES
@@ -40,7 +41,6 @@
}
#endif
-#define LoadMem(S,b,n,size) LoadBlock(S,b,(n)*(size))
#define LoadByte(S) (lu_byte)LoadChar(S)
#define LoadVar(S,x) LoadMem(S,&x,1,sizeof(x))
#define LoadVector(S,b,n,size) LoadMem(S,b,n,size)
@@ -52,6 +52,49 @@
IF (r!=0, "unexpected end");
}
+static void LoadMem (LoadState* S, void* b, int n, size_t size)
+{
+ LoadBlock(S,b,n*size);
+ if (S->swap)
+ {
+ char* p=(char*) b;
+ char c;
+ switch (size)
+ {
+ case 1:
+ break;
+ case 2:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[1]; p[1]=c;
+ p+=2;
+ }
+ break;
+ case 4:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[3]; p[3]=c;
+ c=p[1]; p[1]=p[2]; p[2]=c;
+ p+=4;
+ }
+ break;
+ case 8:
+ while (n--)
+ {
+ c=p[0]; p[0]=p[7]; p[7]=c;
+ c=p[1]; p[1]=p[6]; p[6]=c;
+ c=p[2]; p[2]=p[5]; p[5]=c;
+ c=p[3]; p[3]=p[4]; p[4]=c;
+ p+=8;
+ }
+ break;
+ default:
+ IF(1, "bad size");
+ break;
+ }
+ }
+}
+
static int LoadChar(LoadState* S)
{
char x;
@@ -83,7 +126,7 @@
static TString* LoadString(LoadState* S)
{
- size_t size;
+ unsigned int size;
LoadVar(S,size);
if (size==0)
return NULL;
@@ -194,6 +237,7 @@
char s[LUAC_HEADERSIZE];
luaU_header(h);
LoadBlock(S,s,LUAC_HEADERSIZE);
+ S->swap=(s[6]!=h[6]); s[6]=h[6];
IF (memcmp(h,s,LUAC_HEADERSIZE)!=0, "bad header");
}
@@ -228,7 +272,7 @@
*h++=(char)LUAC_FORMAT;
*h++=(char)*(char*)&x; /* endianness */
*h++=(char)sizeof(int);
- *h++=(char)sizeof(size_t);
+ *h++=(char)sizeof(unsigned int);
*h++=(char)sizeof(Instruction);
*h++=(char)sizeof(lua_Number);

View file

@ -1,8 +1,7 @@
Index: lua-5.1.3/src/luaconf.h
===================================================================
--- lua-5.1.3.orig/src/luaconf.h 2008-04-13 16:18:00.338123105 +0200
+++ lua-5.1.3/src/luaconf.h 2008-04-13 16:18:14.110907972 +0200
@@ -36,7 +36,6 @@
diff -ur lua-luci-5.1.3/src/luaconf.h lua-luci-5.1.3-new/src/luaconf.h
--- lua-luci-5.1.3/src/luaconf.h 2008-04-14 13:19:54.000000000 +0200
+++ lua-luci-5.1.3-new/src/luaconf.h 2008-04-14 13:19:17.000000000 +0200
@@ -38,7 +38,6 @@
#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
@ -10,10 +9,10 @@ Index: lua-5.1.3/src/luaconf.h
#endif
#if defined(LUA_USE_MACOSX)
Index: lua-5.1.3/src/Makefile
===================================================================
--- lua-5.1.3.orig/src/Makefile 2008-04-13 16:18:18.695169214 +0200
+++ lua-5.1.3/src/Makefile 2008-04-13 16:24:41.036957630 +0200
Nur in lua-luci-5.1.3-new/src: luaconf.h.orig.
diff -ur lua-luci-5.1.3/src/Makefile lua-luci-5.1.3-new/src/Makefile
--- lua-luci-5.1.3/src/Makefile 2008-04-14 13:19:57.000000000 +0200
+++ lua-luci-5.1.3-new/src/Makefile 2008-04-14 13:19:17.000000000 +0200
@@ -17,6 +17,7 @@
MYCFLAGS=
MYLDFLAGS=
@ -22,7 +21,7 @@ Index: lua-5.1.3/src/Makefile
# == END OF USER SETTINGS. NO NEED TO CHANGE ANYTHING BELOW THIS LINE =========
@@ -83,7 +84,7 @@
@@ -86,7 +87,7 @@
@echo "MYLIBS = $(MYLIBS)"
# convenience targets for popular platforms
@ -31,7 +30,7 @@ Index: lua-5.1.3/src/Makefile
none:
@echo "Please choose a platform:"
@echo " $(PLATS)"
@@ -98,16 +99,16 @@
@@ -101,16 +102,16 @@
$(MAKE) all MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" MYLIBS="-Wl,-E"
freebsd:
@ -51,3 +50,4 @@ Index: lua-5.1.3/src/Makefile
# use this on Mac OS X 10.3-
# $(MAKE) all MYCFLAGS=-DLUA_USE_MACOSX
Nur in lua-luci-5.1.3-new/src: Makefile.orig.

View file

@ -0,0 +1,15 @@
--- b/src/luaconf.h 2008-05-06 20:10:46.000000000 +0200
+++ a/src/luaconf.h 2008-05-06 20:10:27.000000000 +0200
@@ -95,9 +95,9 @@
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
-#define LUA_ROOT "/usr/local/"
-#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
+#define LUA_ROOT "/usr/"
+#define LUA_LDIR LUA_ROOT "share/lua/"
+#define LUA_CDIR LUA_ROOT "lib/lua/"
#define LUA_PATH_DEFAULT \
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"