Current LUA status for non-x86 is pretty horrible. Attached is a patch which fixes some of issues. Could someone test it? Testing on x86 should be enough. Could someone propose a test for LUA which could be run as part of all_functional_test if lua is compiled to avoid regressions in LUA.
diff --git a/lua/Makefile.core.def b/lua/Makefile.core.def index f646046..416d41f 100644 --- a/lua/Makefile.core.def +++ b/lua/Makefile.core.def @@ -28,7 +28,6 @@ module = { common = contrib/lua/lstrlib.c; common = contrib/lua/grub_main.c; common = contrib/lua/grub_lib.c; - cflags = -Wno-error; cflags = '$(CFLAGS_POSIX)'; cppflags = '$(CPPFLAGS_POSIX)'; diff --git a/lua/lauxlib.c b/lua/lauxlib.c index e7e0f47..ab3c869 100644 --- a/lua/lauxlib.c +++ b/lua/lauxlib.c @@ -598,12 +598,14 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) { c = grub_getc(lf.f); if (c == '#') { /* Unix exec. file? */ lf.extraline = 1; - while ((c = grub_getc(lf.f)) != GRUB_EOF && c != '\n') ; /* skip first line */ + while ((c = grub_getc(lf.f)) != GRUB_EOF && c != '\n') + ; /* skip first line */ if (c == '\n') c = grub_getc(lf.f); } if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */ /* skip eventual `#!...' */ - while ((c = grub_getc(lf.f)) != GRUB_EOF && c != LUA_SIGNATURE[0]) ; + while ((c = grub_getc(lf.f)) != GRUB_EOF && c != LUA_SIGNATURE[0]) + ; lf.extraline = 0; } lf.ungetc = c; diff --git a/lua/lcode.c b/lua/lcode.c index 64f726b..05dc3bf 100644 --- a/lua/lcode.c +++ b/lua/lcode.c @@ -834,8 +834,12 @@ int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) { void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) { - int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1; + int c; int b = (tostore == LUA_MULTRET) ? 0 : tostore; + if (nelems == 0) + c = 1; + else + c = ((unsigned) nelems + LFIELDS_PER_FLUSH - 1)/LFIELDS_PER_FLUSH; lua_assert(tostore != 0); if (c <= MAXARG_C) luaK_codeABC(fs, OP_SETLIST, base, b, c); diff --git a/lua/ldo.h b/lua/ldo.h index 98fddac..abd0b84 100644 --- a/lua/ldo.h +++ b/lua/ldo.h @@ -21,11 +21,11 @@ #define incr_top(L) {luaD_checkstack(L,1); L->top++;} -#define savestack(L,p) ((char *)(p) - (char *)L->stack) -#define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) +#define savestack(L,p) ((TValue *)(p) - (TValue *)L->stack) +#define restorestack(L,n) ((TValue *)((TValue *)L->stack + (n))) -#define saveci(L,p) ((char *)(p) - (char *)L->base_ci) -#define restoreci(L,n) ((CallInfo *)((char *)L->base_ci + (n))) +#define saveci(L,p) ((CallInfo *)(p) - (CallInfo *)L->base_ci) +#define restoreci(L,n) ((CallInfo *)((CallInfo *)L->base_ci + (n))) /* results from luaD_precall */ diff --git a/lua/lobject.h b/lua/lobject.h index 6234d50..8dd3600 100644 --- a/lua/lobject.h +++ b/lua/lobject.h @@ -40,7 +40,7 @@ typedef union GCObject GCObject; ** Common Header for all collectable objects (in macro form, to be ** included in other objects) */ -#define CommonHeader GCObject *next; lu_byte tt; lu_byte marked +#define CommonHeader GCObject __attribute__ ((aligned)) *next; lu_byte tt; lu_byte marked /* diff --git a/lua/lstate.c b/lua/lstate.c index 0c1b97f..2a7964a 100644 --- a/lua/lstate.c +++ b/lua/lstate.c @@ -24,9 +24,9 @@ #include "ltm.h" -#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE) -#define fromstate(l) (cast(lu_byte *, (l)) - LUAI_EXTRASPACE) -#define tostate(l) (cast(lua_State *, cast(lu_byte *, l) + LUAI_EXTRASPACE)) +#define state_size(x) (sizeof(x) + LUAI_EXTRASPACE * sizeof (lua_State)) +#define fromstate(l) (cast(lua_State *, (l)) - LUAI_EXTRASPACE) +#define tostate(l) (cast(lua_State *, cast(lua_State *, l) + LUAI_EXTRASPACE)) /* diff --git a/lua/luaconf.h b/lua/luaconf.h index 77e6c19..652e8d1 100644 --- a/lua/luaconf.h +++ b/lua/luaconf.h @@ -554,13 +554,48 @@ #define luai_numadd(a,b) ((a)+(b)) #define luai_numsub(a,b) ((a)-(b)) #define luai_nummul(a,b) ((a)*(b)) -#define luai_numdiv(a,b) ((a)/(b)) #if 0 #define luai_nummod(a,b) ((a) - floor((a)/(b))*(b)) #define luai_numpow(a,b) (pow(a,b)) #else -#define luai_nummod(a,b) ((a) % (b)) +static inline LUA_NUMBER +luai_numdiv (LUA_NUMBER a, LUA_NUMBER b) +{ + int neg = 0; + unsigned res; + if (a < 0) + { + a = -a; + neg = !neg; + } + if (b < 0) + { + b = -b; + neg = !neg; + } + res = (unsigned) a / (unsigned) b; + return neg ? -res : res; +} + +static inline LUA_NUMBER +luai_nummod (LUA_NUMBER a, LUA_NUMBER b) +{ + int neg = 0; + unsigned res; + if (a < 0) + { + a = -a; + neg = !neg; + } + if (b < 0) + { + b = -b; + neg = !neg; + } + res = (unsigned) a % (unsigned) b; + return neg ? -res : res; +} static inline LUA_NUMBER luai_numpow (LUA_NUMBER a, LUA_NUMBER b) @@ -640,7 +675,7 @@ union luai_Cast { double l_d; long l_l; }; ** aligned in 16-byte boundaries, then you should add long double in the ** union.) Probably you do not need to change this. */ -#define LUAI_USER_ALIGNMENT_T union { void *s; long l; long long ll; } +#define LUAI_USER_ALIGNMENT_T grub_properly_aligned_t /*
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel