From 9ea679410c8061741a49350b3fc969365ffe5547 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 19 Apr 2011 17:12:41 +0200 Subject: [PATCH] Workaround to compile with Clang. Fix Clang warnings. --- src/lj_err.c | 5 +++++ src/lj_record.c | 4 ++-- src/lj_tab.c | 10 +++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/lj_err.c b/src/lj_err.c index 51c8fb9f..7eaffdb6 100644 --- a/src/lj_err.c +++ b/src/lj_err.c @@ -533,6 +533,11 @@ static void *err_unwind(lua_State *L, void *stopcf, int errcode) #if defined(__GNUC__) && !LJ_TARGET_ARM +#ifdef __clang__ +/* http://llvm.org/bugs/show_bug.cgi?id=8703 */ +#define __unwind_word__ word +#endif + #include #define LJ_UEXCLASS 0x4c55414a49543200ULL /* LUAJIT2\0 */ diff --git a/src/lj_record.c b/src/lj_record.c index dc0eea41..36425086 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -556,7 +556,7 @@ static void rec_call_setup(jit_State *J, BCReg func, ptrdiff_t nargs) TRef trfunc, *fbase = &J->base[func]; ptrdiff_t i; for (i = 0; i <= nargs; i++) - getslot(J, func+i); /* Ensure func and all args have a reference. */ + (void)getslot(J, func+i); /* Ensure func and all args have a reference. */ if (!tref_isfunc(fbase[0])) { /* Resolve __call metamethod. */ ix.tab = fbase[0]; copyTV(J->L, &ix.tabv, functv); @@ -634,7 +634,7 @@ void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults) TValue *frame = J->L->base - 1; ptrdiff_t i; for (i = 0; i < gotresults; i++) - getslot(J, rbase+i); /* Ensure all results have a reference. */ + (void)getslot(J, rbase+i); /* Ensure all results have a reference. */ while (frame_ispcall(frame)) { /* Immediately resolve pcall() returns. */ BCReg cbase = (BCReg)frame_delta(frame); if (--J->framedepth < 0) diff --git a/src/lj_tab.c b/src/lj_tab.c index 830e3023..cd200f02 100644 --- a/src/lj_tab.c +++ b/src/lj_tab.c @@ -97,7 +97,7 @@ static GCtab *newtab(lua_State *L, uint32_t asize, uint32_t hbits) { GCtab *t; /* First try to colocate the array part. */ - if (LJ_MAX_COLOSIZE && asize > 0 && asize <= LJ_MAX_COLOSIZE) { + if (LJ_MAX_COLOSIZE != 0 && asize > 0 && asize <= LJ_MAX_COLOSIZE) { lua_assert((sizeof(GCtab) & 7) == 0); t = (GCtab *)lj_mem_newgco(L, sizetabcolo(asize)); t->gct = ~LJ_TTAB; @@ -203,9 +203,9 @@ void LJ_FASTCALL lj_tab_free(global_State *g, GCtab *t) { if (t->hmask > 0) lj_mem_freevec(g, noderef(t->node), t->hmask+1, Node); - if (t->asize > 0 && LJ_MAX_COLOSIZE && t->colo <= 0) + if (t->asize > 0 && LJ_MAX_COLOSIZE != 0 && t->colo <= 0) lj_mem_freevec(g, tvref(t->array), t->asize, TValue); - if (LJ_MAX_COLOSIZE && t->colo) + if (LJ_MAX_COLOSIZE != 0 && t->colo) lj_mem_free(g, t, sizetabcolo((uint32_t)t->colo & 0x7f)); else lj_mem_freet(g, t); @@ -224,7 +224,7 @@ static void resizetab(lua_State *L, GCtab *t, uint32_t asize, uint32_t hbits) uint32_t i; if (asize > LJ_MAX_ASIZE) lj_err_msg(L, LJ_ERR_TABOV); - if (LJ_MAX_COLOSIZE && t->colo > 0) { + if (LJ_MAX_COLOSIZE != 0 && t->colo > 0) { /* A colocated array must be separated and copied. */ TValue *oarray = tvref(t->array); array = lj_mem_newvec(L, asize, TValue); @@ -257,7 +257,7 @@ static void resizetab(lua_State *L, GCtab *t, uint32_t asize, uint32_t hbits) if (!tvisnil(&array[i])) copyTV(L, lj_tab_setinth(L, t, (int32_t)i), &array[i]); /* Physically shrink only separated arrays. */ - if (LJ_MAX_COLOSIZE && t->colo <= 0) + if (LJ_MAX_COLOSIZE != 0 && t->colo <= 0) setmref(t->array, lj_mem_realloc(L, array, oldasize*sizeof(TValue), asize*sizeof(TValue))); }