From 3c1d415bd3fef686b27f853bdf3eaf1f0a9bb0be Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 18 Jul 2019 15:31:22 -0300 Subject: Details - Macro 'checkliveness' (for debug) always uses 'L', to avoid warnings. - Some old 'while' changed to 'for' in 'testes/gc.lua'. - In 'testes/libs/makefile', do not make files depend on 'ltests.h', which may not even exist. --- lobject.h | 10 +++++----- testes/gc.lua | 22 +++++++--------------- testes/libs/makefile | 10 +++++----- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/lobject.h b/lobject.h index 95f8e188..f21e8a91 100644 --- a/lobject.h +++ b/lobject.h @@ -89,8 +89,8 @@ typedef struct TValue { #define righttt(obj) (ttypetag(obj) == gcvalue(obj)->tt) #define checkliveness(L,obj) \ - lua_longassert(!iscollectable(obj) || \ - (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj))))) + ((void)L, lua_longassert(!iscollectable(obj) || \ + (righttt(obj) && (L == NULL || !isdead(G(L),gcvalue(obj)))))) /* Macros to set values */ @@ -100,7 +100,7 @@ typedef struct TValue { #define setobj(L,obj1,obj2) \ { TValue *io1=(obj1); const TValue *io2=(obj2); \ io1->value_ = io2->value_; io1->tt_ = io2->tt_; \ - (void)L; checkliveness(L,io1); lua_assert(!isreallyempty(io1)); } + checkliveness(L,io1); lua_assert(!isreallyempty(io1)); } /* ** different types of assignments, according to destination @@ -651,14 +651,14 @@ typedef union Node { #define setnodekey(L,node,obj) \ { Node *n_=(node); const TValue *io_=(obj); \ n_->u.key_val = io_->value_; n_->u.key_tt = io_->tt_; \ - (void)L; checkliveness(L,io_); } + checkliveness(L,io_); } /* copy a value from a key */ #define getnodekey(L,obj,node) \ { TValue *io_=(obj); const Node *n_=(node); \ io_->value_ = n_->u.key_val; io_->tt_ = n_->u.key_tt; \ - (void)L; checkliveness(L,io_); } + checkliveness(L,io_); } /* diff --git a/testes/gc.lua b/testes/gc.lua index 6d24e0d8..9ea054c1 100644 --- a/testes/gc.lua +++ b/testes/gc.lua @@ -99,35 +99,28 @@ local function GC() GC1(); GC2() end do print("creating many objects") - local contCreate = 0 - local limit = 5000 - while contCreate <= limit do + for i = 1, limit do local a = {}; a = nil - contCreate = contCreate+1 end local a = "a" - contCreate = 0 - while contCreate <= limit do - a = contCreate .. "b"; + for i = 1, limit do + a = i .. "b"; a = string.gsub(a, '(%d%d*)', "%1 %1") a = "a" - contCreate = contCreate+1 end - contCreate = 0 a = {} function a:test () - while contCreate <= limit do - load(string.format("function temp(a) return 'a%d' end", contCreate), "")() - assert(temp() == string.format('a%d', contCreate)) - contCreate = contCreate+1 + for i = 1, limit do + load(string.format("function temp(a) return 'a%d' end", i), "")() + assert(temp() == string.format('a%d', i)) end end @@ -166,9 +159,8 @@ print('long strings') x = "01234567890123456789012345678901234567890123456789012345678901234567890123456789" assert(string.len(x)==80) s = '' -n = 0 k = math.min(300, (math.maxinteger // 80) // 2) -while n < k do s = s..x; n=n+1; j=tostring(n) end +for n = 1, k do s = s..x; j=tostring(n) end assert(string.len(s) == k*80) s = string.sub(s, 1, 10000) s, i = string.gsub(s, '(%d%d%d%d)', '') diff --git a/testes/libs/makefile b/testes/libs/makefile index 698f8984..a1330920 100644 --- a/testes/libs/makefile +++ b/testes/libs/makefile @@ -11,17 +11,17 @@ CFLAGS = -Wall -std=gnu99 -O2 -I$(LUA_DIR) -fPIC -shared all: lib1.so lib11.so lib2.so lib21.so lib2-v2.so touch all -lib1.so: lib1.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h +lib1.so: lib1.c $(LUA_DIR)/luaconf.h $(CC) $(CFLAGS) -o lib1.so lib1.c -lib11.so: lib11.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h +lib11.so: lib11.c $(LUA_DIR)/luaconf.h $(CC) $(CFLAGS) -o lib11.so lib11.c -lib2.so: lib2.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h +lib2.so: lib2.c $(LUA_DIR)/luaconf.h $(CC) $(CFLAGS) -o lib2.so lib2.c -lib21.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h +lib21.so: lib21.c $(LUA_DIR)/luaconf.h $(CC) $(CFLAGS) -o lib21.so lib21.c -lib2-v2.so: lib21.c $(LUA_DIR)/luaconf.h $(LUA_DIR)/ltests.h +lib2-v2.so: lib21.c $(LUA_DIR)/luaconf.h $(CC) $(CFLAGS) -o lib2-v2.so lib22.c -- cgit v1.2.3-55-g6feb