Commit 61d9e721 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

[buddy]

Remove more sanity checks when NDEBUG is set.

* src/kernel.h (CHECKnc): New macro.
* src/kernel.c (bdd_var, bdd_low, bdd_high, bdd_ithvar,
bdd_nithvar): Use it.
parent c44b60f0
2011-04-04 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Remove more sanity checks when NDEBUG is set.
* src/kernel.h (CHECKnc): New macro.
* src/kernel.c (bdd_var, bdd_low, bdd_high, bdd_ithvar,
bdd_nithvar): Use it.
2011-04-03 Alexandre Duret-Lutz <adl@lrde.epita.fr>
* src/kernel.h (CHECK, CHECKa, CHECKn): Disable if NDEBUG is set.
......
......@@ -874,11 +874,13 @@ RETURN {* The I'th variable on succes, otherwise the constant false bdd *}
ALSO {* bdd\_setvarnum, bdd\_nithvar, bddtrue, bddfalse *} */
BDD bdd_ithvar(int var)
{
#ifndef NDEBUG
if (var < 0 || var >= bddvarnum)
{
bdd_error(BDD_VAR);
return bddfalse;
}
#endif
return bddvarset[var*2];
}
......@@ -900,11 +902,13 @@ ALSO {* bdd\_setvarnum, bdd\_ithvar, bddtrue, bddfalse *}
*/
BDD bdd_nithvar(int var)
{
#ifndef NDEBUG
if (var < 0 || var >= bddvarnum)
{
bdd_error(BDD_VAR);
return bddfalse;
}
#endif
return bddvarset[var*2+1];
}
......@@ -937,10 +941,8 @@ RETURN {* The variable number. *}
int bdd_var(BDD root)
{
CHECK(root);
if (root < 2)
return bdd_error(BDD_ILLBDD);
return (bddlevel2var[LEVEL(root)]);
CHECKnc(root);
return bddlevel2var[LEVEL(root)];
}
......@@ -956,10 +958,8 @@ ALSO {* bdd\_high *}
BDD bdd_low(BDD root)
{
CHECK(root);
if (root < 2)
return bdd_error(BDD_ILLBDD);
return (LOW(root));
CHECKnc(root);
return LOW(root);
}
......@@ -975,10 +975,8 @@ ALSO {* bdd\_low *}
BDD bdd_high(BDD root)
{
CHECK(root);
if (root < 2)
return bdd_error(BDD_ILLBDD);
return (HIGH(root));
CHECKnc(root);
return HIGH(root);
}
......
......@@ -58,6 +58,7 @@
#define CHECK(r) (void)(r);
#define CHECKa(r,a) (void)(r); (void)(a);
#define CHECKn(r) (void)(r);
#define CHECKnc(r) (void)(r);
#else
/* Sanity check argument and return eventual error code */
#define CHECK(r)\
......@@ -79,6 +80,12 @@
{ bdd_error(BDD_ILLBDD); return; }\
else if (r >= 2 && LOW(r) == -1)\
{ bdd_error(BDD_ILLBDD); return; }
/* r is non-constant */
#define CHECKnc(r)\
if (root < 2) \
return bdd_error(BDD_ILLBDD)
#endif
/*=== SEMI-INTERNAL TYPES ==============================================*/
......@@ -220,7 +227,7 @@ extern void bdd_fdd_done(void);
extern void bdd_reorder_init(void);
extern void bdd_reorder_done(void);
extern int bdd_reorder_ready(void);
extern int bdd_reorder_ready(void) __purefn;
extern void bdd_reorder_auto(void);
extern int bdd_reorder_vardown(int);
extern int bdd_reorder_varup(int);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment