[buddy] fix some -Wpedantic messages

* src/bddop.c: Empty macro arguments are undefined ISO C90 and
ISO C++98.  Use '+' when calling APPLY_SHORTCUTS.
* src/fdd.c, src/kernel.c: Avoid constructs invalid in C90.
* src/bddop.c, src/bddx.h, src/kernel.c, src/kernel.h,
examples/cmilner/cmilner.c: Remove C++ comments.
This commit is contained in:
Alexandre Duret-Lutz 2017-02-01 15:09:40 +01:00
parent f0edfdef2b
commit a2f174f721
6 changed files with 79 additions and 62 deletions

View file

@ -214,7 +214,7 @@ static int has_deadlocks(bdd R, bdd T)
for(int i=0; i<N; i++) for(int i=0; i<N; i++)
C &= bdd_exist(T, primvar, N*3); C &= bdd_exist(T, primvar, N*3);
//C &= bdd_exist(bdd_exist(bdd_exist(T,i*6+3),i*6+5),i*6+1); /* C &= bdd_exist(bdd_exist(bdd_exist(T,i*6+3),i*6+5),i*6+1); */
if(C != bddfalse && R != bddfalse) if(C != bddfalse && R != bddfalse)
return 0; return 0;

View file

@ -676,7 +676,9 @@ static BDD apply_rec(BDD l, BDD r)
break; \ break; \
} }
APPLY_SHORTCUTS(applyop, /* id */); /* empty macro arguments are undefined in ISO C90 and ISO C++98, so
use + when we do not want to call any function.*/
APPLY_SHORTCUTS(applyop, +);
if (__unlikely(ISCONST(l) && ISCONST(r))) if (__unlikely(ISCONST(l) && ISCONST(r)))
res = oprres[applyop][l<<1 | r]; res = oprres[applyop][l<<1 | r];
@ -684,7 +686,7 @@ static BDD apply_rec(BDD l, BDD r)
{ {
entry = BddCache_lookup(&applycache, APPLYHASH(l,r,applyop)); entry = BddCache_lookup(&applycache, APPLYHASH(l,r,applyop));
// Check entry->c last, because not_rec() does not initialize it. /* Check entry->c last, because not_rec() does not initialize it. */
if (entry->i.a == l && entry->i.c == applyop && entry->i.b == r) if (entry->i.a == l && entry->i.c == applyop && entry->i.b == r)
{ {
#ifdef CACHESTATS #ifdef CACHESTATS
@ -928,7 +930,7 @@ int bdd_implies(BDD l, BDD r)
return 0; return 0;
entry = BddCache_lookup(&misccache, IMPLIESHASH(l,r)); entry = BddCache_lookup(&misccache, IMPLIESHASH(l,r));
// Check entry->b last, because not_rec() does not initialize it. /* Check entry->b last, because not_rec() does not initialize it. */
if (entry->i.a == l && entry->i.c == CACHEID_IMPLIES && entry->i.b == r) if (entry->i.a == l && entry->i.c == CACHEID_IMPLIES && entry->i.b == r)
{ {
#ifdef CACHESTATS #ifdef CACHESTATS
@ -944,8 +946,8 @@ int bdd_implies(BDD l, BDD r)
{ {
int hl = HIGH(l); int hl = HIGH(l);
int hr = HIGH(r); int hr = HIGH(r);
// Avoid the recursion if the second implication will trivially /* Avoid the recursion if the second implication will trivially
// fail. fail. */
if ((ISONE(hl) || ISZERO(hr)) && (hl != hr)) if ((ISONE(hl) || ISZERO(hr)) && (hl != hr))
res = 0; res = 0;
else else
@ -1792,7 +1794,7 @@ static BDD simplify_rec(BDD f, BDD d)
entry = BddCache_lookup(&applycache, APPLYHASH(f,d,bddop_simplify)); entry = BddCache_lookup(&applycache, APPLYHASH(f,d,bddop_simplify));
// Check entry->b last, because not_rec() does not initialize it. /* Check entry->b last, because not_rec() does not initialize it. */
if (entry->i.a == f && entry->i.c == bddop_simplify && entry->i.b == d) if (entry->i.a == f && entry->i.c == bddop_simplify && entry->i.b == d)
{ {
#ifdef CACHESTATS #ifdef CACHESTATS

View file

@ -68,9 +68,10 @@
#endif #endif
#endif #endif
// BUDDY_API is used for the public API symbols. It either DLL imports /* BUDDY_API is used for the public API symbols. It either DLL imports
// or DLL exports (or does nothing for static build) BUDDY_LOCAL is ** or DLL exports (or does nothing for static build) BUDDY_LOCAL is
// used for non-api symbols. ** used for non-api symbols.
*/
#ifdef BUDDY_DLL #ifdef BUDDY_DLL
#ifdef BUDDY_DLL_EXPORTS #ifdef BUDDY_DLL_EXPORTS
#define BUDDY_API BUDDY_HELPER_DLL_EXPORT #define BUDDY_API BUDDY_HELPER_DLL_EXPORT

View file

@ -143,12 +143,15 @@ int fdd_extdomain(int *dom, int num)
{ {
fdvaralloc += (num > fdvaralloc) ? num : fdvaralloc; fdvaralloc += (num > fdvaralloc) ? num : fdvaralloc;
Domain* tmp_ptr = (Domain*)realloc(domain, sizeof(Domain)*fdvaralloc); {
Domain* tmp_ptr =
(Domain*)realloc(domain, sizeof(Domain)*fdvaralloc);
if (tmp_ptr == NULL) if (tmp_ptr == NULL)
return bdd_error(BDD_MEMORY); return bdd_error(BDD_MEMORY);
domain = tmp_ptr; domain = tmp_ptr;
} }
} }
}
/* Create bdd variable tables */ /* Create bdd variable tables */
for (n=0 ; n<num ; n++) for (n=0 ; n<num ; n++)
@ -220,11 +223,13 @@ int fdd_overlapdomain(int v1, int v2)
{ {
fdvaralloc += fdvaralloc; fdvaralloc += fdvaralloc;
{
Domain* tmp_ptr = (Domain*)realloc(domain, sizeof(Domain)*fdvaralloc); Domain* tmp_ptr = (Domain*)realloc(domain, sizeof(Domain)*fdvaralloc);
if (tmp_ptr == NULL) if (tmp_ptr == NULL)
return bdd_error(BDD_MEMORY); return bdd_error(BDD_MEMORY);
domain = tmp_ptr; domain = tmp_ptr;
} }
}
d = &domain[fdvarnum]; d = &domain[fdvarnum];
d->realsize = domain[v1].realsize * domain[v2].realsize; d->realsize = domain[v1].realsize * domain[v2].realsize;

View file

@ -194,20 +194,21 @@ int bdd_init(int initnodesize, int cs)
/* Load these globals into local variables to help the /* Load these globals into local variables to help the
optimizer. */ optimizer. */
{
int sz = bddnodesize; int sz = bddnodesize;
BddNodeInit* b = (BddNodeInit*)bddnodes; BddNodeInit* b = (BddNodeInit*)bddnodes;
for (n=0 ; n<sz ; n++) for (n=0 ; n<sz ; n++)
{ {
b[n].z = 0; b[n].z = 0;
b[n].low = -1; b[n].low = -1;
// Initializing HIGH is useless in BuDDy, but it helps the /* Initializing HIGH is useless in BuDDy, but it helps the
// compiler vectorizing the code, and it helps the processor compiler vectorizing the code, and it helps the processor
// write-combining data to memory. write-combining data to memory. */
b[n].high = 0; b[n].high = 0;
b[n].next = n+1; b[n].next = n+1;
} }
b[sz-1].next = 0; b[sz-1].next = 0;
}
bddnodes[0].refcou = bddnodes[1].refcou = MAXREF; bddnodes[0].refcou = bddnodes[1].refcou = MAXREF;
LOW(0) = HIGH(0) = 0; LOW(0) = HIGH(0) = 0;
LOW(1) = HIGH(1) = 1; LOW(1) = HIGH(1) = 1;
@ -340,11 +341,14 @@ int bdd_setvarnum(int num)
} }
} }
else else
{
{ {
BDD* tmp_ptr = (BDD*)realloc(bddvarset,sizeof(BDD)*num*2); BDD* tmp_ptr = (BDD*)realloc(bddvarset,sizeof(BDD)*num*2);
if (__unlikely(tmp_ptr == NULL)) if (__unlikely(tmp_ptr == NULL))
return bdd_error(BDD_MEMORY); return bdd_error(BDD_MEMORY);
bddvarset = tmp_ptr; bddvarset = tmp_ptr;
}
{
int* tmp_ptr2 = (int*)realloc(bddlevel2var,sizeof(int)*(num+1)); int* tmp_ptr2 = (int*)realloc(bddlevel2var,sizeof(int)*(num+1));
if (__unlikely(tmp_ptr2 == NULL)) if (__unlikely(tmp_ptr2 == NULL))
{ {
@ -352,7 +356,9 @@ int bdd_setvarnum(int num)
return bdd_error(BDD_MEMORY); return bdd_error(BDD_MEMORY);
} }
bddlevel2var = tmp_ptr2; bddlevel2var = tmp_ptr2;
tmp_ptr2 = (int*)realloc(bddvar2level,sizeof(int)*(num+1)); }
{
int* tmp_ptr2 = (int*)realloc(bddvar2level,sizeof(int)*(num+1));
if (__unlikely(tmp_ptr2 == NULL)) if (__unlikely(tmp_ptr2 == NULL))
{ {
free(bddvarset); free(bddvarset);
@ -361,6 +367,7 @@ int bdd_setvarnum(int num)
} }
bddvar2level = tmp_ptr2; bddvar2level = tmp_ptr2;
} }
}
if (__likely(bddrefstack != NULL)) if (__likely(bddrefstack != NULL))
free(bddrefstack); free(bddrefstack);
@ -1162,7 +1169,7 @@ BDD bdd_addref(BDD root)
return root; return root;
} }
// Non constant version /* Non constant version */
BDD bdd_delref_nc(BDD root) BDD bdd_delref_nc(BDD root)
{ {
#ifndef NDEBUG #ifndef NDEBUG
@ -1448,6 +1455,7 @@ int bdd_noderesize(int doRehash)
/* copy these global variables into local variables to help the /* copy these global variables into local variables to help the
optimizer */ optimizer */
{
int sz = bddnodesize; int sz = bddnodesize;
BddNodeInit* b = (BddNodeInit*)(bddnodes); BddNodeInit* b = (BddNodeInit*)(bddnodes);
for (n=oldsize ; n<sz ; n++) for (n=oldsize ; n<sz ; n++)
@ -1460,6 +1468,7 @@ int bdd_noderesize(int doRehash)
b[sz-1].next = bddfreepos; b[sz-1].next = bddfreepos;
bddfreepos = oldsize; bddfreepos = oldsize;
bddfreenum += bddnodesize - oldsize; bddfreenum += bddnodesize - oldsize;
}
if (doRehash) if (doRehash)
bdd_gbc_rehash(); bdd_gbc_rehash();

View file

@ -99,8 +99,8 @@ typedef struct s_BddNode /* Node table entry */
int next; int next;
} BddNode; } BddNode;
// This structure is used during initialization of the above /* This structure is used during initialization of the above
// structure, to help gcc vectorize the initializing loop. structure, to help gcc vectorize the initializing loop. */
typedef struct s_BddNodeInit typedef struct s_BddNodeInit
{ {
int z; int z;