Commit 5fdfe286 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz
Browse files

[buddy]

Tag functions with attributes pure, const, or noreturn.

* src/bdd.h (__purefn, __constfn, __noreturnfn): Define
new macros.
* src/bdd.h, src/bddio.c, src/bvec.h, src/imatrix.h: Use them
to tag many functions as suggested by -Wsuggest-attribute=pure,
-Wsuggest-attribute=const, -Wsuggest-attribute=noreturn.
parent 61d9e721
2011-04-04 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Tag functions with attributes pure, const, or noreturn.
* src/bdd.h (__purefn, __constfn, __noreturnfn): Define
new macros.
* src/bdd.h, src/bddio.c, src/bvec.h, src/imatrix.h: Use them
to tag many functions as suggested by -Wsuggest-attribute=pure,
-Wsuggest-attribute=const, -Wsuggest-attribute=noreturn.
2011-04-04 Alexandre Duret-Lutz <adl@lrde.epita.fr>
Remove more sanity checks when NDEBUG is set.
......
......@@ -38,6 +38,16 @@
#ifndef _BDD_H
#define _BDD_H
#if __GNUC__ >= 3
#define __purefn __attribute__((__pure__))
#define __constfn __attribute__((__const__))
#define __noreturnfn __attribute__((__noreturn__))
#else
#define __purefn
#define __constfn
#define __noreturnfn
#endif
/* Allow this headerfile to define C++ constructs if requested */
#ifdef __cplusplus
#define CPLUSPLUS
......@@ -231,33 +241,33 @@ extern int bdd_init(int, int);
extern void bdd_done(void);
extern int bdd_setvarnum(int);
extern int bdd_extvarnum(int);
extern int bdd_isrunning(void);
extern int bdd_isrunning(void) __purefn;
extern int bdd_setmaxnodenum(int);
extern int bdd_setmaxincrease(int);
extern int bdd_setminfreenodes(int);
extern int bdd_getnodenum(void);
extern int bdd_getallocnum(void);
extern char* bdd_versionstr(void);
extern int bdd_versionnum(void);
extern int bdd_getnodenum(void) __purefn;
extern int bdd_getallocnum(void) __purefn;
extern char* bdd_versionstr(void) __purefn;
extern int bdd_versionnum(void) __constfn;
extern void bdd_stats(bddStat *);
extern void bdd_cachestats(bddCacheStat *);
extern void bdd_fprintstat(FILE *);
extern void bdd_printstat(void);
extern void bdd_default_gbchandler(int, bddGbcStat *);
extern void bdd_default_errhandler(int);
extern const char *bdd_errstring(int);
extern void bdd_default_errhandler(int) __noreturnfn;
extern const char *bdd_errstring(int) __constfn;
extern void bdd_clear_error(void);
#ifndef CPLUSPLUS
extern BDD bdd_true(void);
extern BDD bdd_false(void);
extern BDD bdd_true(void) __constfn;
extern BDD bdd_false(void) __constfn;
#endif
extern int bdd_varnum(void);
extern BDD bdd_ithvar(int);
extern BDD bdd_nithvar(int);
extern int bdd_var(BDD);
extern BDD bdd_low(BDD);
extern BDD bdd_high(BDD);
extern int bdd_varlevel(int);
extern int bdd_varnum(void) __purefn;
extern BDD bdd_ithvar(int) __purefn;
extern BDD bdd_nithvar(int) __purefn;
extern int bdd_var(BDD) __purefn;
extern BDD bdd_low(BDD) __purefn;
extern BDD bdd_high(BDD) __purefn;
extern int bdd_varlevel(int) __purefn;
extern BDD bdd_addref(BDD);
extern BDD bdd_delref(BDD);
extern void bdd_gbc(void);
......@@ -342,7 +352,7 @@ extern int bdd_load(FILE *ifile, BDD *);
extern int bdd_swapvar(int v1, int v2);
extern void bdd_default_reohandler(int);
extern void bdd_reorder(int);
extern int bdd_reorder_gain(void);
extern int bdd_reorder_gain(void) __purefn;
extern bddsizehandler bdd_reorder_probe(bddsizehandler);
extern void bdd_clrvarblocks(void);
extern int bdd_addvarblock(BDD, int);
......@@ -353,8 +363,8 @@ extern int bdd_autoreorder(int);
extern int bdd_autoreorder_times(int, int);
extern int bdd_var2level(int);
extern int bdd_level2var(int);
extern int bdd_getreorder_times(void);
extern int bdd_getreorder_method(void);
extern int bdd_getreorder_times(void) __purefn;
extern int bdd_getreorder_method(void) __purefn;
extern void bdd_enable_reorder(void);
extern void bdd_disable_reorder(void);
extern int bdd_reorder_verbose(int);
......
......@@ -578,7 +578,7 @@ static void loadhash_add(int key, int data)
lh_table[pos].data = data;
}
__purefn
static int loadhash_get(int key)
{
int hash = lh_table[key % lh_nodenum].first;
......
......@@ -72,7 +72,7 @@ typedef BVEC bvec;
#ifdef CPLUSPLUS
extern "C" {
#endif
/* Prototypes for bvec.c */
extern BVEC bvec_copy(BVEC v);
extern BVEC bvec_true(int bitnum);
......@@ -82,8 +82,8 @@ extern BVEC bvec_var(int bitnum, int offset, int step);
extern BVEC bvec_varfdd(int var);
extern BVEC bvec_varvec(int bitnum, int *var);
extern BVEC bvec_coerce(int bitnum, BVEC v);
extern int bvec_isconst(BVEC e);
extern int bvec_val(BVEC e);
extern int bvec_isconst(BVEC e) __purefn;
extern int bvec_val(BVEC e) __purefn;
extern void bvec_free(BVEC v);
extern BVEC bvec_addref(BVEC v);
extern BVEC bvec_delref(BVEC v);
......@@ -136,7 +136,7 @@ class bvec
int bitnum(void) const { return roots.bitnum; }
int empty(void) const { return roots.bitnum==0; }
bvec operator=(const bvec &src);
private:
BVEC roots;
......@@ -149,8 +149,8 @@ private:
friend bvec bvec_varfddpp(int var);
friend bvec bvec_varvecpp(int bitnum, int *var);
friend bvec bvec_coerce(int bitnum, const bvec &v);
friend int bvec_isconst(const bvec &e);
friend int bvec_val(const bvec &e);
friend int bvec_isconst(const bvec &e);
friend int bvec_val(const bvec &e);
friend bvec bvec_copy(const bvec &v);
friend bvec bvec_map1(const bvec &a,
bdd (*fun)(const bdd &));
......@@ -289,7 +289,7 @@ inline bdd bvec_neq(const bvec &left, const bvec &right)
#define bvec_false(a) bvec_falsepp(a)
#define bvec_con(a,b) bvec_conpp((a),(b))
#endif /* CPLUSPLUS */
#endif /* _BVEC_H */
......
......@@ -37,6 +37,8 @@
#ifndef _IMATRIX_H
#define _IMATRIX_H
#include "bdd.h" /* for __purefn */
typedef struct _imatrix
{
char **rows;
......@@ -50,7 +52,7 @@ extern void imatrixFPrint(imatrix*,FILE *);
extern void imatrixPrint(imatrix*);
extern void imatrixSet(imatrix*,int,int);
extern void imatrixClr(imatrix*,int,int);
extern int imatrixDepends(imatrix*,int,int);
extern int imatrixDepends(imatrix*,int,int) __purefn;
#endif /* _IMATRIX_H */
......
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