aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-05-05 16:43:14 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2011-05-05 16:43:14 -0300
commit3cf1729a0219b8b461e171dc88ece36530596c74 (patch)
tree3dd5a83c2739406b69a95675065205831f3130f5
parent74b0bb3a458adc8e0d845d67e0f9486679466d26 (diff)
downloadlua-3cf1729a0219b8b461e171dc88ece36530596c74.tar.gz
lua-3cf1729a0219b8b461e171dc88ece36530596c74.tar.bz2
lua-3cf1729a0219b8b461e171dc88ece36530596c74.zip
new macro 'lua_longassert' that is equivalent to an assertion without
a stringfication of the condition, to avoid too long string literals (limited by C90 to ~510 characters)
-rw-r--r--llimits.h5
-rw-r--r--lobject.h7
2 files changed, 7 insertions, 5 deletions
diff --git a/llimits.h b/llimits.h
index 72f32a8d..a5d18957 100644
--- a/llimits.h
+++ b/llimits.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llimits.h,v 1.87 2011/02/01 16:52:38 roberto Exp roberto $ 2** $Id: llimits.h,v 1.88 2011/02/28 17:32:10 roberto Exp roberto $
3** Limits, basic types, and some other `installation-dependent' definitions 3** Limits, basic types, and some other `installation-dependent' definitions
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -59,9 +59,12 @@ typedef LUAI_UACNUMBER l_uacNumber;
59/* internal assertions for in-house debugging */ 59/* internal assertions for in-house debugging */
60#if defined(lua_assert) 60#if defined(lua_assert)
61#define check_exp(c,e) (lua_assert(c), (e)) 61#define check_exp(c,e) (lua_assert(c), (e))
62/* to avoid problems with conditions too long */
63#define lua_longassert(c) { if (!(c)) lua_assert(0); }
62#else 64#else
63#define lua_assert(c) /* empty */ 65#define lua_assert(c) /* empty */
64#define check_exp(c,e) (e) 66#define check_exp(c,e) (e)
67#define lua_longassert(c) /* empty */
65#endif 68#endif
66 69
67/* 70/*
diff --git a/lobject.h b/lobject.h
index 671915f0..ed0f0294 100644
--- a/lobject.h
+++ b/lobject.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.h,v 2.51 2011/05/04 17:04:06 roberto Exp roberto $ 2** $Id: lobject.h,v 2.52 2011/05/05 15:53:23 roberto Exp roberto $
3** Type definitions for Lua objects 3** Type definitions for Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -152,10 +152,9 @@ typedef struct lua_TValue {
152/* Macros for internal tests */ 152/* Macros for internal tests */
153#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt) 153#define righttt(obj) (ttype(obj) == gcvalue(obj)->gch.tt)
154 154
155#define checkconsistency(obj) lua_assert(!iscollectable(obj) || righttt(obj))
156
157#define checkliveness(g,obj) \ 155#define checkliveness(g,obj) \
158 lua_assert(!iscollectable(obj) || (righttt(obj) && !isdead(g,gcvalue(obj)))) 156 lua_longassert(!iscollectable(obj) || \
157 (righttt(obj) && !isdead(g,gcvalue(obj))))
159 158
160 159
161/* Macros to set values */ 160/* Macros to set values */