* src/bdd.h: Declare bdd_copypair().

* src/pairs.c (bdd_copypair, bdd_pairalloc): New functions.
(bdd_newpair): Use bdd_pairalloc.
This commit is contained in:
Alexandre Duret-Lutz 2003-05-19 15:58:44 +00:00
parent 38f7ae9a46
commit ed8ae1ed55
3 changed files with 106 additions and 60 deletions

View file

@ -1,3 +1,9 @@
2003-05-19 Alexandre Duret-Lutz <aduret@src.lip6.fr>
* src/bdd.h: Declare bdd_copypair().
* src/pairs.c (bdd_copypair, bdd_pairalloc): New functions.
(bdd_newpair): Use bdd_pairalloc.
2003-05-12 Alexandre Duret-Lutz <aduret@src.lip6.fr> 2003-05-12 Alexandre Duret-Lutz <aduret@src.lip6.fr>
* src/kernel.c (bdd_default_errhandler): Call abort(), not exit(1). * src/kernel.c (bdd_default_errhandler): Call abort(), not exit(1).
@ -44,4 +50,3 @@
* src/kernel.h (DEFAULT_CLOCK): Default to 60 if not already * src/kernel.h (DEFAULT_CLOCK): Default to 60 if not already
defined. defined.
* README: Update build instruction, and file listing. * README: Update build instruction, and file listing.

View file

@ -1,6 +1,6 @@
/*======================================================================== /*========================================================================
Copyright (C) 1996-2002 by Jorn Lind-Nielsen Copyright (C) 1996-2002 by Jorn Lind-Nielsen
All rights reserved All rights reserved
Permission is hereby granted, without written agreement and without Permission is hereby granted, without written agreement and without
license or royalty fees, to use, reproduce, prepare derivative license or royalty fees, to use, reproduce, prepare derivative
@ -28,7 +28,7 @@
========================================================================*/ ========================================================================*/
/************************************************************************* /*************************************************************************
$Header: /Volumes/CVS/repository/spot/spot/buddy/src/bdd.h,v 1.2 2003/05/05 13:45:04 aduret Exp $ $Header: /Volumes/CVS/repository/spot/spot/buddy/src/bdd.h,v 1.3 2003/05/19 15:58:44 aduret Exp $
FILE: bdd.h FILE: bdd.h
DESCR: C,C++ User interface for the BDD package DESCR: C,C++ User interface for the BDD package
AUTH: Jorn Lind AUTH: Jorn Lind
@ -104,7 +104,7 @@ DESCR {* The fields are \\[\baselineskip] \begin{tabular}{lp{10cm}}
{\tt maxnodenum} & user defined maximum number of bdd nodes \\ {\tt maxnodenum} & user defined maximum number of bdd nodes \\
{\tt freenodes} & number of currently free nodes \\ {\tt freenodes} & number of currently free nodes \\
{\tt minfreenodes} & minimum number of nodes that should be left after a {\tt minfreenodes} & minimum number of nodes that should be left after a
garbage collection. \\ garbage collection. \\
{\tt varnum} & number of defined bdd variables \\ {\tt varnum} & number of defined bdd variables \\
{\tt cachesize} & number of entries in the internal caches \\ {\tt cachesize} & number of entries in the internal caches \\
{\tt gbcnum} & number of garbage collections done until now {\tt gbcnum} & number of garbage collections done until now
@ -200,7 +200,7 @@ SECTION {* operator *}
SHORT {* relational product *} SHORT {* relational product *}
PROTO {* #define bdd_relprod(a,b,var) bdd_appex(a,b,bddop_and,var) *} PROTO {* #define bdd_relprod(a,b,var) bdd_appex(a,b,bddop_and,var) *}
DESCR {* Calculates the relational product of {\tt a} and {\tt b} as DESCR {* Calculates the relational product of {\tt a} and {\tt b} as
{\tt a AND b} with the variables in {\tt var} quantified out {\tt a AND b} with the variables in {\tt var} quantified out
afterwards. *} afterwards. *}
RETURN {* The relational product or {\tt bddfalse} on errors. *} RETURN {* The relational product or {\tt bddfalse} on errors. *}
ALSO {* bdd\_appex *} ALSO {* bdd\_appex *}
@ -263,6 +263,7 @@ extern BDD bdd_delref(BDD);
extern void bdd_gbc(void); extern void bdd_gbc(void);
extern int bdd_scanset(BDD, int**, int*); extern int bdd_scanset(BDD, int**, int*);
extern BDD bdd_makeset(int *, int); extern BDD bdd_makeset(int *, int);
extern bddPair* bdd_copypair(bddPair*);
extern bddPair* bdd_newpair(void); extern bddPair* bdd_newpair(void);
extern int bdd_setpair(bddPair*, int, int); extern int bdd_setpair(bddPair*, int, int);
extern int bdd_setpairs(bddPair*, int*, int*, int); extern int bdd_setpairs(bddPair*, int*, int*, int);
@ -395,7 +396,7 @@ extern const BDD bddtrue;
#define BDD_BREAK (-9) /* User called break */ #define BDD_BREAK (-9) /* User called break */
#define BDD_VARNUM (-10) /* Different number of vars. for vector pair */ #define BDD_VARNUM (-10) /* Different number of vars. for vector pair */
#define BDD_NODES (-11) /* Tried to set max. number of nodes to be fewer */ #define BDD_NODES (-11) /* Tried to set max. number of nodes to be fewer */
/* than there already has been allocated */ /* than there already has been allocated */
#define BDD_OP (-12) /* Unknown operator */ #define BDD_OP (-12) /* Unknown operator */
#define BDD_VARSET (-13) /* Illegal variable set */ #define BDD_VARSET (-13) /* Illegal variable set */
#define BDD_VARBLK (-14) /* Bad variable block operation */ #define BDD_VARBLK (-14) /* Bad variable block operation */

View file

@ -1,6 +1,6 @@
/*======================================================================== /*========================================================================
Copyright (C) 1996-2002 by Jorn Lind-Nielsen Copyright (C) 1996-2002 by Jorn Lind-Nielsen
All rights reserved All rights reserved
Permission is hereby granted, without written agreement and without Permission is hereby granted, without written agreement and without
license or royalty fees, to use, reproduce, prepare derivative license or royalty fees, to use, reproduce, prepare derivative
@ -28,7 +28,7 @@
========================================================================*/ ========================================================================*/
/************************************************************************* /*************************************************************************
$Header: /Volumes/CVS/repository/spot/spot/buddy/src/pairs.c,v 1.2 2003/05/05 13:45:08 aduret Exp $ $Header: /Volumes/CVS/repository/spot/spot/buddy/src/pairs.c,v 1.3 2003/05/19 15:58:44 aduret Exp $
FILE: pairs.c FILE: pairs.c
DESCR: Pair management for BDD package. DESCR: Pair management for BDD package.
AUTH: Jorn Lind AUTH: Jorn Lind
@ -113,6 +113,25 @@ void bdd_pairs_vardown(int level)
} }
static bddPair *bdd_pairalloc()
{
bddPair *p;
if ((p=(bddPair*)malloc(sizeof(bddPair))) == NULL)
{
bdd_error(BDD_MEMORY);
return NULL;
}
if ((p->result=(BDD*)malloc(sizeof(BDD)*bddvarnum)) == NULL)
{
free(p);
bdd_error(BDD_MEMORY);
return NULL;
}
return p;
}
int bdd_pairs_resize(int oldsize, int newsize) int bdd_pairs_resize(int oldsize, int newsize)
{ {
bddPair *p; bddPair *p;
@ -137,7 +156,7 @@ SECTION {* kernel *}
SHORT {* creates an empty variable pair table *} SHORT {* creates an empty variable pair table *}
PROTO {* bddPair *bdd_newpair(void) *} PROTO {* bddPair *bdd_newpair(void) *}
DESCR {* Variable pairs of the type {\tt bddPair} are used in DESCR {* Variable pairs of the type {\tt bddPair} are used in
{\tt bdd\_replace} to define which variables to replace with {\tt bdd\_replace} to define which variables to replace with
other variables. This function allocates such an empty table. The other variables. This function allocates such an empty table. The
table can be freed by a call to {\em bdd\_freepair}. *} table can be freed by a call to {\em bdd\_freepair}. *}
RETURN {* Returns a new table of pairs. *} RETURN {* Returns a new table of pairs. *}
@ -148,18 +167,9 @@ bddPair *bdd_newpair(void)
int n; int n;
bddPair *p; bddPair *p;
if ((p=(bddPair*)malloc(sizeof(bddPair))) == NULL) p = bdd_pairalloc();
{ if (p == NULL)
bdd_error(BDD_MEMORY); return NULL;
return NULL;
}
if ((p->result=(BDD*)malloc(sizeof(BDD)*bddvarnum)) == NULL)
{
free(p);
bdd_error(BDD_MEMORY);
return NULL;
}
for (n=0 ; n<bddvarnum ; n++) for (n=0 ; n<bddvarnum ; n++)
p->result[n] = bdd_ithvar(bddlevel2var[n]); p->result[n] = bdd_ithvar(bddlevel2var[n]);
@ -172,6 +182,37 @@ bddPair *bdd_newpair(void)
} }
/*
NAME {* bdd\_copypair *}
SECTION {* kernel *}
SHORT {* clone a pair table *}
PROTO {* bddPair *bdd_copypair(bddPair *from) *}
DESCR {* Duplicate the table of pairs {\tt from}.
This function allocates the cloned table. The
table can be freed by a call to {\em bdd\_freepair}. *}
RETURN {* Returns a new table of pairs. *}
ALSO {* bdd\_newpair, bdd\_freepair, bdd\_replace, bdd\_setpair, bdd\_setpairs *}
*/
bddPair *bdd_copypair(bddPair *from)
{
int n;
bddPair *p;
p = bdd_pairalloc();
if (p == NULL)
return NULL;
for (n=0 ; n<bddvarnum ; n++)
p->result[n] = from->result[n];
p->id = update_pairsid();
p->last = -1;
bdd_register_pair(p);
return p;
}
/* /*
NAME {* bdd\_setpair *} NAME {* bdd\_setpair *}
EXTRA {* bdd\_setbddpair *} EXTRA {* bdd\_setbddpair *}
@ -180,7 +221,7 @@ SHORT {* set one variable pair *}
PROTO {* int bdd_setpair(bddPair *pair, int oldvar, int newvar) PROTO {* int bdd_setpair(bddPair *pair, int oldvar, int newvar)
int bdd_setbddpair(bddPair *pair, BDD oldvar, BDD newvar) *} int bdd_setbddpair(bddPair *pair, BDD oldvar, BDD newvar) *}
DESCR {* Adds the pair {\tt (oldvar,newvar)} to the table of pairs DESCR {* Adds the pair {\tt (oldvar,newvar)} to the table of pairs
{\tt pair}. This results in {\tt oldvar} being substituted {\tt pair}. This results in {\tt oldvar} being substituted
with {\tt newvar} in a call to {\tt bdd\_replace}. In the first with {\tt newvar} in a call to {\tt bdd\_replace}. In the first
version {\tt newvar} is an integer representing the variable version {\tt newvar} is an integer representing the variable
to be replaced with the old variable. to be replaced with the old variable.
@ -245,7 +286,7 @@ SHORT {* defines a whole set of pairs *}
PROTO {* int bdd_setpairs(bddPair *pair, int *oldvar, int *newvar, int size) PROTO {* int bdd_setpairs(bddPair *pair, int *oldvar, int *newvar, int size)
int bdd_setbddpairs(bddPair *pair, int *oldvar, BDD *newvar, int size) *} int bdd_setbddpairs(bddPair *pair, int *oldvar, BDD *newvar, int size) *}
DESCR {* As for {\tt bdd\_setpair} but with {\tt oldvar} and {\tt newvar} DESCR {* As for {\tt bdd\_setpair} but with {\tt oldvar} and {\tt newvar}
being arrays of variables (BDDs) of size {\tt size}. *} being arrays of variables (BDDs) of size {\tt size}. *}
RETURN {* Zero on success, otherwise a negative error code. *} RETURN {* Zero on success, otherwise a negative error code. *}
ALSO {* bdd\_newpair, bdd\_setpair, bdd\_replace, bdd\_compose *} ALSO {* bdd\_newpair, bdd\_setpair, bdd\_replace, bdd\_compose *}
*/ */
@ -283,7 +324,7 @@ SECTION {* kernel *}
SHORT {* frees a table of pairs *} SHORT {* frees a table of pairs *}
PROTO {* void bdd_freepair(bddPair *pair) *} PROTO {* void bdd_freepair(bddPair *pair) *}
DESCR {* Frees the table of pairs {\tt pair} that has been allocated DESCR {* Frees the table of pairs {\tt pair} that has been allocated
by a call to {\tt bdd\_newpair}. *} by a call to {\tt bdd\_newpair}. *}
ALSO {* bdd\_replace, bdd\_newpair, bdd\_setpair, bdd\_resetpair *} ALSO {* bdd\_replace, bdd\_newpair, bdd\_setpair, bdd\_resetpair *}
*/ */
void bdd_freepair(bddPair *p) void bdd_freepair(bddPair *p)
@ -318,7 +359,7 @@ SECTION {* kernel *}
SHORT {* clear all variable pairs *} SHORT {* clear all variable pairs *}
PROTO {* void bdd_resetpair(bddPair *pair) *} PROTO {* void bdd_resetpair(bddPair *pair) *}
DESCR {* Resets the table of pairs {\tt pair} by setting all substitutions DESCR {* Resets the table of pairs {\tt pair} by setting all substitutions
to their default values (that is no change). *} to their default values (that is no change). *}
ALSO {* bdd\_newpair, bdd\_setpair, bdd\_freepair *} ALSO {* bdd\_newpair, bdd\_setpair, bdd\_freepair *}
*/ */
void bdd_resetpair(bddPair *p) void bdd_resetpair(bddPair *p)
@ -332,4 +373,3 @@ void bdd_resetpair(bddPair *p)
/* EOF */ /* EOF */