Commit e3f2dde1 by Alan Mishchenko

Upgrading epd and mtr packages to be compatible with the latest release of CUDD 2.4.2

parent e881eaf6
...@@ -12,12 +12,39 @@ ...@@ -12,12 +12,39 @@
Author [In-Ho Moon] Author [In-Ho Moon]
Copyright [ This file was created at the University of Colorado at Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
Boulder. The University of Colorado at Boulder makes no warranty
about the suitability of this software for any purpose. It is
presented on an AS IS basis.]
Revision [$Id: epd.c,v 1.1.1.1 2003/02/24 22:23:57 wjiang Exp $] All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University of Colorado nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.]
Revision [$Id: epd.c,v 1.10 2004/08/13 18:20:30 fabio Exp $]
******************************************************************************/ ******************************************************************************/
...@@ -25,13 +52,11 @@ ...@@ -25,13 +52,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#include "util_hack.h" #include "util.h"
#include "epd.h" #include "epd.h"
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
/**Function******************************************************************** /**Function********************************************************************
Synopsis [Allocates an EpDouble struct.] Synopsis [Allocates an EpDouble struct.]
...@@ -44,11 +69,11 @@ ABC_NAMESPACE_IMPL_START ...@@ -44,11 +69,11 @@ ABC_NAMESPACE_IMPL_START
******************************************************************************/ ******************************************************************************/
EpDouble * EpDouble *
EpdAlloc() EpdAlloc(void)
{ {
EpDouble *epd; EpDouble *epd;
epd = ABC_ALLOC(EpDouble, 1); epd = ALLOC(EpDouble, 1);
return(epd); return(epd);
} }
...@@ -91,15 +116,15 @@ EpdCmp(const char *key1, const char *key2) ...@@ -91,15 +116,15 @@ EpdCmp(const char *key1, const char *key2)
void void
EpdFree(EpDouble *epd) EpdFree(EpDouble *epd)
{ {
ABC_FREE(epd); FREE(epd);
} }
/**Function******************************************************************** /**Function********************************************************************
Synopsis [Multiplies two arbitrary precision double values.] Synopsis [Converts an arbitrary precision double value to a string.]
Description [Multiplies two arbitrary precision double values.] Description [Converts an arbitrary precision double value to a string.]
SideEffects [] SideEffects []
...@@ -1250,12 +1275,13 @@ EpdIsNanOrInf(EpDouble *epd) ...@@ -1250,12 +1275,13 @@ EpdIsNanOrInf(EpDouble *epd)
int int
IsInfDouble(double value) IsInfDouble(double value)
{ {
IeeeDouble *ptr = (IeeeDouble *)(&value); EpType val;
if (ptr->exponent == EPD_EXP_INF && val.value = value;
ptr->mantissa0 == 0 && if (val.bits.exponent == EPD_EXP_INF &&
ptr->mantissa1 == 0) { val.bits.mantissa0 == 0 &&
if (ptr->sign == 0) val.bits.mantissa1 == 0) {
if (val.bits.sign == 0)
return(1); return(1);
else else
return(-1); return(-1);
...@@ -1278,13 +1304,14 @@ IsInfDouble(double value) ...@@ -1278,13 +1304,14 @@ IsInfDouble(double value)
int int
IsNanDouble(double value) IsNanDouble(double value)
{ {
IeeeNan *ptr = (IeeeNan *)(&value); EpType val;
if (ptr->exponent == EPD_EXP_INF && val.value = value;
ptr->sign == 1 && if (val.nan.exponent == EPD_EXP_INF &&
ptr->quiet_bit == 1 && val.nan.sign == 1 &&
ptr->mantissa0 == 0 && val.nan.quiet_bit == 1 &&
ptr->mantissa1 == 0) { val.nan.mantissa0 == 0 &&
val.nan.mantissa1 == 0) {
return(1); return(1);
} }
return(0); return(0);
...@@ -1305,15 +1332,16 @@ IsNanDouble(double value) ...@@ -1305,15 +1332,16 @@ IsNanDouble(double value)
int int
IsNanOrInfDouble(double value) IsNanOrInfDouble(double value)
{ {
IeeeNan *ptr = (IeeeNan *)(&value); EpType val;
if (ptr->exponent == EPD_EXP_INF && val.value = value;
ptr->mantissa0 == 0 && if (val.nan.exponent == EPD_EXP_INF &&
ptr->mantissa1 == 0 && val.nan.mantissa0 == 0 &&
(ptr->sign == 1 || ptr->quiet_bit == 0)) { val.nan.mantissa1 == 0 &&
(val.nan.sign == 1 || val.nan.quiet_bit == 0)) {
return(1); return(1);
} }
return(0); return(0);
} }
ABC_NAMESPACE_IMPL_END
ABC_NAMESPACE_IMPL_END
...@@ -12,22 +12,47 @@ ...@@ -12,22 +12,47 @@
Author [In-Ho Moon] Author [In-Ho Moon]
Copyright [This file was created at the University of Colorado at Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
Boulder. The University of Colorado at Boulder makes no warranty
about the suitability of this software for any purpose. It is
presented on an AS IS basis.]
Revision [$Id: epd.h,v 1.1.1.1 2003/02/24 22:23:57 wjiang Exp $] All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University of Colorado nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.]
Revision [$Id: epd.h,v 1.9 2004/08/13 18:20:30 fabio Exp $]
******************************************************************************/ ******************************************************************************/
#ifndef _EPD #ifndef _EPD
#define _EPD #define _EPD
ABC_NAMESPACE_HEADER_START ABC_NAMESPACE_HEADER_START
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Constant declarations */ /* Constant declarations */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -101,12 +126,14 @@ struct IeeeNanStruct { /* LITTLE_ENDIAN */ ...@@ -101,12 +126,14 @@ struct IeeeNanStruct { /* LITTLE_ENDIAN */
SeeAlso [] SeeAlso []
******************************************************************************/ ******************************************************************************/
struct EpDoubleStruct { union EpTypeUnion {
union {
double value; double value;
struct IeeeDoubleStruct bits; struct IeeeDoubleStruct bits;
struct IeeeNanStruct nan; struct IeeeNanStruct nan;
} type; };
struct EpDoubleStruct {
union EpTypeUnion type;
int exponent; int exponent;
}; };
...@@ -116,51 +143,53 @@ struct EpDoubleStruct { ...@@ -116,51 +143,53 @@ struct EpDoubleStruct {
typedef struct EpDoubleStruct EpDouble; typedef struct EpDoubleStruct EpDouble;
typedef struct IeeeDoubleStruct IeeeDouble; typedef struct IeeeDoubleStruct IeeeDouble;
typedef struct IeeeNanStruct IeeeNan; typedef struct IeeeNanStruct IeeeNan;
typedef union EpTypeUnion EpType;
/**AutomaticStart*************************************************************/
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Function prototypes */ /* Function prototypes */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
EpDouble *EpdAlloc(); extern EpDouble *EpdAlloc(void);
int EpdCmp(const char *key1, const char *key2); extern int EpdCmp(const char *key1, const char *key2);
void EpdFree(EpDouble *epd); extern void EpdFree(EpDouble *epd);
void EpdGetString(EpDouble *epd, char *str); extern void EpdGetString(EpDouble *epd, char *str);
void EpdConvert(double value, EpDouble *epd); extern void EpdConvert(double value, EpDouble *epd);
void EpdMultiply(EpDouble *epd1, double value); extern void EpdMultiply(EpDouble *epd1, double value);
void EpdMultiply2(EpDouble *epd1, EpDouble *epd2); extern void EpdMultiply2(EpDouble *epd1, EpDouble *epd2);
void EpdMultiply2Decimal(EpDouble *epd1, EpDouble *epd2); extern void EpdMultiply2Decimal(EpDouble *epd1, EpDouble *epd2);
void EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3); extern void EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
void EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3); extern void EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
void EpdDivide(EpDouble *epd1, double value); extern void EpdDivide(EpDouble *epd1, double value);
void EpdDivide2(EpDouble *epd1, EpDouble *epd2); extern void EpdDivide2(EpDouble *epd1, EpDouble *epd2);
void EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3); extern void EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
void EpdAdd(EpDouble *epd1, double value); extern void EpdAdd(EpDouble *epd1, double value);
void EpdAdd2(EpDouble *epd1, EpDouble *epd2); extern void EpdAdd2(EpDouble *epd1, EpDouble *epd2);
void EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3); extern void EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
void EpdSubtract(EpDouble *epd1, double value); extern void EpdSubtract(EpDouble *epd1, double value);
void EpdSubtract2(EpDouble *epd1, EpDouble *epd2); extern void EpdSubtract2(EpDouble *epd1, EpDouble *epd2);
void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3); extern void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
void EpdPow2(int n, EpDouble *epd); extern void EpdPow2(int n, EpDouble *epd);
void EpdPow2Decimal(int n, EpDouble *epd); extern void EpdPow2Decimal(int n, EpDouble *epd);
void EpdNormalize(EpDouble *epd); extern void EpdNormalize(EpDouble *epd);
void EpdNormalizeDecimal(EpDouble *epd); extern void EpdNormalizeDecimal(EpDouble *epd);
void EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent); extern void EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent);
int EpdGetExponent(double value); extern int EpdGetExponent(double value);
int EpdGetExponentDecimal(double value); extern int EpdGetExponentDecimal(double value);
void EpdMakeInf(EpDouble *epd, int sign); extern void EpdMakeInf(EpDouble *epd, int sign);
void EpdMakeZero(EpDouble *epd, int sign); extern void EpdMakeZero(EpDouble *epd, int sign);
void EpdMakeNan(EpDouble *epd); extern void EpdMakeNan(EpDouble *epd);
void EpdCopy(EpDouble *from, EpDouble *to); extern void EpdCopy(EpDouble *from, EpDouble *to);
int EpdIsInf(EpDouble *epd); extern int EpdIsInf(EpDouble *epd);
int EpdIsZero(EpDouble *epd); extern int EpdIsZero(EpDouble *epd);
int EpdIsNan(EpDouble *epd); extern int EpdIsNan(EpDouble *epd);
int EpdIsNanOrInf(EpDouble *epd); extern int EpdIsNanOrInf(EpDouble *epd);
int IsInfDouble(double value); extern int IsInfDouble(double value);
int IsNanDouble(double value); extern int IsNanDouble(double value);
int IsNanOrInfDouble(double value); extern int IsNanOrInfDouble(double value);
/**AutomaticEnd***************************************************************/
ABC_NAMESPACE_HEADER_END ABC_NAMESPACE_HEADER_END
......
...@@ -20,12 +20,39 @@ ...@@ -20,12 +20,39 @@
Author [Fabio Somenzi] Author [Fabio Somenzi]
Copyright [This file was created at the University of Colorado at Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
Boulder. The University of Colorado at Boulder makes no warranty
about the suitability of this software for any purpose. It is
presented on an AS IS basis.]
Revision [$Id: mtr.h,v 1.1.1.1 2003/02/24 22:24:02 wjiang Exp $] All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University of Colorado nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.]
Revision [$Id: mtr.h,v 1.14 2009/02/20 02:03:47 fabio Exp $]
******************************************************************************/ ******************************************************************************/
...@@ -38,7 +65,6 @@ ...@@ -38,7 +65,6 @@
ABC_NAMESPACE_HEADER_START ABC_NAMESPACE_HEADER_START
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Constant declarations */ /* Constant declarations */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -57,23 +83,6 @@ ABC_NAMESPACE_HEADER_START ...@@ -57,23 +83,6 @@ ABC_NAMESPACE_HEADER_START
#define CONST #define CONST
#endif /* !(__STDC__ || __cplusplus) */ #endif /* !(__STDC__ || __cplusplus) */
/* These are potential duplicates. */
#ifndef EXTERN
# ifdef __cplusplus
# ifdef ABC_NAMESPACE
# define EXTERN extern
# else
# define EXTERN extern "C"
# endif
# else
# define EXTERN extern
# endif
#endif
#ifndef ARGS
#define ARGS(protos) protos
#endif
#if defined(__GNUC__) #if defined(__GNUC__)
#define MTR_INLINE __inline__ #define MTR_INLINE __inline__
# if (__GNUC__ >2 || __GNUC_MINOR__ >=7) # if (__GNUC__ >2 || __GNUC_MINOR__ >=7)
...@@ -152,24 +161,24 @@ typedef struct MtrNode { ...@@ -152,24 +161,24 @@ typedef struct MtrNode {
/* Function prototypes */ /* Function prototypes */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
EXTERN MtrNode * Mtr_AllocNode ARGS(()); extern MtrNode * Mtr_AllocNode (void);
EXTERN void Mtr_DeallocNode ARGS((MtrNode *node)); extern void Mtr_DeallocNode (MtrNode *node);
EXTERN MtrNode * Mtr_InitTree ARGS(()); extern MtrNode * Mtr_InitTree (void);
EXTERN void Mtr_FreeTree ARGS((MtrNode *node)); extern void Mtr_FreeTree (MtrNode *node);
EXTERN MtrNode * Mtr_CopyTree ARGS((MtrNode *node, int expansion)); extern MtrNode * Mtr_CopyTree (MtrNode *node, int expansion);
EXTERN void Mtr_MakeFirstChild ARGS((MtrNode *parent, MtrNode *child)); extern void Mtr_MakeFirstChild (MtrNode *parent, MtrNode *child);
EXTERN void Mtr_MakeLastChild ARGS((MtrNode *parent, MtrNode *child)); extern void Mtr_MakeLastChild (MtrNode *parent, MtrNode *child);
EXTERN MtrNode * Mtr_CreateFirstChild ARGS((MtrNode *parent)); extern MtrNode * Mtr_CreateFirstChild (MtrNode *parent);
EXTERN MtrNode * Mtr_CreateLastChild ARGS((MtrNode *parent)); extern MtrNode * Mtr_CreateLastChild (MtrNode *parent);
EXTERN void Mtr_MakeNextSibling ARGS((MtrNode *first, MtrNode *second)); extern void Mtr_MakeNextSibling (MtrNode *first, MtrNode *second);
EXTERN void Mtr_PrintTree ARGS((MtrNode *node)); extern void Mtr_PrintTree (MtrNode *node);
EXTERN MtrNode * Mtr_InitGroupTree ARGS((int lower, int size)); extern MtrNode * Mtr_InitGroupTree (int lower, int size);
EXTERN MtrNode * Mtr_MakeGroup ARGS((MtrNode *root, unsigned int low, unsigned int high, unsigned int flags)); extern MtrNode * Mtr_MakeGroup (MtrNode *root, unsigned int low, unsigned int high, unsigned int flags);
EXTERN MtrNode * Mtr_DissolveGroup ARGS((MtrNode *group)); extern MtrNode * Mtr_DissolveGroup (MtrNode *group);
EXTERN MtrNode * Mtr_FindGroup ARGS((MtrNode *root, unsigned int low, unsigned int high)); extern MtrNode * Mtr_FindGroup (MtrNode *root, unsigned int low, unsigned int high);
EXTERN int Mtr_SwapGroups ARGS((MtrNode *first, MtrNode *second)); extern int Mtr_SwapGroups (MtrNode *first, MtrNode *second);
EXTERN void Mtr_PrintGroups ARGS((MtrNode *root, int silent)); extern void Mtr_PrintGroups (MtrNode *root, int silent);
EXTERN MtrNode * Mtr_ReadGroups ARGS((FILE *fp, int nleaves)); extern MtrNode * Mtr_ReadGroups (FILE *fp, int nleaves);
/**AutomaticEnd***************************************************************/ /**AutomaticEnd***************************************************************/
......
...@@ -26,20 +26,45 @@ ...@@ -26,20 +26,45 @@
Author [Fabio Somenzi] Author [Fabio Somenzi]
Copyright [This file was created at the University of Colorado at Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
Boulder. The University of Colorado at Boulder makes no warranty
about the suitability of this software for any purpose. It is All rights reserved.
presented on an AS IS basis.]
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University of Colorado nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.]
******************************************************************************/ ******************************************************************************/
#include "util_hack.h" #include "util.h"
#include "mtrInt.h" #include "mtrInt.h"
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Constant declarations */ /* Constant declarations */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -57,7 +82,7 @@ ABC_NAMESPACE_IMPL_START ...@@ -57,7 +82,7 @@ ABC_NAMESPACE_IMPL_START
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#ifndef lint #ifndef lint
static char rcsid[] MTR_UNUSED = "$Id: mtrBasic.c,v 1.1.1.1 2003/02/24 22:24:02 wjiang Exp $"; static char rcsid[] MTR_UNUSED = "$Id: mtrBasic.c,v 1.13 2009/02/20 02:03:47 fabio Exp $";
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -90,12 +115,11 @@ static char rcsid[] MTR_UNUSED = "$Id: mtrBasic.c,v 1.1.1.1 2003/02/24 22:24:02 ...@@ -90,12 +115,11 @@ static char rcsid[] MTR_UNUSED = "$Id: mtrBasic.c,v 1.1.1.1 2003/02/24 22:24:02
******************************************************************************/ ******************************************************************************/
MtrNode * MtrNode *
Mtr_AllocNode( Mtr_AllocNode(void)
)
{ {
MtrNode *node; MtrNode *node;
node = ABC_ALLOC(MtrNode,1); node = ALLOC(MtrNode,1);
return node; return node;
} /* Mtr_AllocNode */ } /* Mtr_AllocNode */
...@@ -116,7 +140,7 @@ void ...@@ -116,7 +140,7 @@ void
Mtr_DeallocNode( Mtr_DeallocNode(
MtrNode * node /* node to be deallocated */) MtrNode * node /* node to be deallocated */)
{ {
ABC_FREE(node); FREE(node);
return; return;
} /* end of Mtr_DeallocNode */ } /* end of Mtr_DeallocNode */
...@@ -134,8 +158,7 @@ Mtr_DeallocNode( ...@@ -134,8 +158,7 @@ Mtr_DeallocNode(
******************************************************************************/ ******************************************************************************/
MtrNode * MtrNode *
Mtr_InitTree( Mtr_InitTree(void)
)
{ {
MtrNode *node; MtrNode *node;
...@@ -403,12 +426,12 @@ Mtr_PrintTree( ...@@ -403,12 +426,12 @@ Mtr_PrintTree(
if (node == NULL) return; if (node == NULL) return;
(void) fprintf(stdout, (void) fprintf(stdout,
#if SIZEOF_VOID_P == 8 #if SIZEOF_VOID_P == 8
"N=0x%-8lx C=0x%-8lx Y=0x%-8lx E=0x%-8lx P=0x%-8lx F=%x L=%d S=%d\n", "N=0x%-8lx C=0x%-8lx Y=0x%-8lx E=0x%-8lx P=0x%-8lx F=%x L=%u S=%u\n",
(unsigned long) node, (unsigned long) node->child, (unsigned long) node, (unsigned long) node->child,
(unsigned long) node->younger, (unsigned long) node->elder, (unsigned long) node->younger, (unsigned long) node->elder,
(unsigned long) node->parent, node->flags, node->low, node->size); (unsigned long) node->parent, node->flags, node->low, node->size);
#else #else
"N=0x%-8x C=0x%-8x Y=0x%-8x E=0x%-8x P=0x%-8x F=%x L=%d S=%d\n", "N=0x%-8x C=0x%-8x Y=0x%-8x E=0x%-8x P=0x%-8x F=%x L=%hu S=%hu\n",
(unsigned) node, (unsigned) node->child, (unsigned) node, (unsigned) node->child,
(unsigned) node->younger, (unsigned) node->elder, (unsigned) node->younger, (unsigned) node->elder,
(unsigned) node->parent, node->flags, node->low, node->size); (unsigned) node->parent, node->flags, node->low, node->size);
...@@ -428,4 +451,3 @@ Mtr_PrintTree( ...@@ -428,4 +451,3 @@ Mtr_PrintTree(
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_END
...@@ -26,19 +26,45 @@ ...@@ -26,19 +26,45 @@
Author [Fabio Somenzi] Author [Fabio Somenzi]
Copyright [This file was created at the University of Colorado at Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
Boulder. The University of Colorado at Boulder makes no warranty
about the suitability of this software for any purpose. It is All rights reserved.
presented on an AS IS basis.]
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University of Colorado nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.]
******************************************************************************/ ******************************************************************************/
#include "util_hack.h" #include "util.h"
#include "mtrInt.h" #include "mtrInt.h"
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Constant declarations */ /* Constant declarations */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -56,7 +82,7 @@ ABC_NAMESPACE_IMPL_START ...@@ -56,7 +82,7 @@ ABC_NAMESPACE_IMPL_START
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
#ifndef lint #ifndef lint
static char rcsid[] MTR_UNUSED = "$Id: mtrGroup.c,v 1.1.1.1 2003/02/24 22:24:02 wjiang Exp $"; static char rcsid[] MTR_UNUSED = "$Id: mtrGroup.c,v 1.18 2009/02/20 02:03:47 fabio Exp $";
#endif #endif
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
...@@ -69,7 +95,7 @@ static char rcsid[] MTR_UNUSED = "$Id: mtrGroup.c,v 1.1.1.1 2003/02/24 22:24:02 ...@@ -69,7 +95,7 @@ static char rcsid[] MTR_UNUSED = "$Id: mtrGroup.c,v 1.1.1.1 2003/02/24 22:24:02
/* Static function prototypes */ /* Static function prototypes */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int mtrShiftHL ARGS((MtrNode *node, int shift)); static int mtrShiftHL (MtrNode *node, int shift);
/**AutomaticEnd***************************************************************/ /**AutomaticEnd***************************************************************/
...@@ -517,7 +543,11 @@ Mtr_PrintGroups( ...@@ -517,7 +543,11 @@ Mtr_PrintGroups(
assert(root != NULL); assert(root != NULL);
assert(root->younger == NULL || root->younger->elder == root); assert(root->younger == NULL || root->younger->elder == root);
assert(root->elder == NULL || root->elder->younger == root); assert(root->elder == NULL || root->elder->younger == root);
if (!silent) (void) printf("(%d",root->low); #if SIZEOF_VOID_P == 8
if (!silent) (void) printf("(%u",root->low);
#else
if (!silent) (void) printf("(%hu",root->low);
#endif
if (MTR_TEST(root,MTR_TERMINAL) || root->child == NULL) { if (MTR_TEST(root,MTR_TERMINAL) || root->child == NULL) {
if (!silent) (void) printf(","); if (!silent) (void) printf(",");
} else { } else {
...@@ -530,7 +560,11 @@ Mtr_PrintGroups( ...@@ -530,7 +560,11 @@ Mtr_PrintGroups(
} }
} }
if (!silent) { if (!silent) {
(void) printf("%d", root->low + root->size - 1); #if SIZEOF_VOID_P == 8
(void) printf("%u", root->low + root->size - 1);
#else
(void) printf("%hu", root->low + root->size - 1);
#endif
if (root->flags != MTR_DEFAULT) { if (root->flags != MTR_DEFAULT) {
(void) printf("|"); (void) printf("|");
if (MTR_TEST(root,MTR_FIXED)) (void) printf("F"); if (MTR_TEST(root,MTR_FIXED)) (void) printf("F");
...@@ -596,12 +630,15 @@ Mtr_ReadGroups( ...@@ -596,12 +630,15 @@ Mtr_ReadGroups(
if (err == EOF) { if (err == EOF) {
break; break;
} else if (err != 3) { } else if (err != 3) {
Mtr_FreeTree(root);
return(NULL); return(NULL);
} else if (low < 0 || low+size > nleaves || size < 1) { } else if (low < 0 || low+size > nleaves || size < 1) {
Mtr_FreeTree(root);
return(NULL); return(NULL);
} else if (strlen(attrib) > 8 * sizeof(MtrHalfWord)) { } else if (strlen(attrib) > 8 * sizeof(MtrHalfWord)) {
/* Not enough bits in the flags word to store these many /* Not enough bits in the flags word to store these many
** attributes. */ ** attributes. */
Mtr_FreeTree(root);
return(NULL); return(NULL);
} }
...@@ -631,7 +668,10 @@ Mtr_ReadGroups( ...@@ -631,7 +668,10 @@ Mtr_ReadGroups(
} }
node = Mtr_MakeGroup(root, (MtrHalfWord) low, (MtrHalfWord) size, node = Mtr_MakeGroup(root, (MtrHalfWord) low, (MtrHalfWord) size,
flags); flags);
if (node == NULL) return(NULL); if (node == NULL) {
Mtr_FreeTree(root);
return(NULL);
}
} }
return(root); return(root);
...@@ -692,4 +732,3 @@ mtrShiftHL( ...@@ -692,4 +732,3 @@ mtrShiftHL(
} /* end of mtrShiftHL */ } /* end of mtrShiftHL */
ABC_NAMESPACE_IMPL_END ABC_NAMESPACE_IMPL_END
...@@ -12,28 +12,52 @@ ...@@ -12,28 +12,52 @@
Author [Fabio Somenzi] Author [Fabio Somenzi]
Copyright [This file was created at the University of Colorado at Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
Boulder. The University of Colorado at Boulder makes no warranty
about the suitability of this software for any purpose. It is
presented on an AS IS basis.]
Revision [$Id: mtrInt.h,v 1.1.1.1 2003/02/24 22:24:02 wjiang Exp $] All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the University of Colorado nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.]
Revision [$Id: mtrInt.h,v 1.2 2004/08/13 18:15:12 fabio Exp $]
******************************************************************************/ ******************************************************************************/
#ifndef _MTRINT #ifndef _MTRINT
#define _MTRINT #define _MTRINT
#include "mtr.h" #include "mtr.h"
ABC_NAMESPACE_HEADER_START
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Nested includes */ /* Nested includes */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
ABC_NAMESPACE_HEADER_START
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Constant declarations */ /* Constant declarations */
...@@ -63,11 +87,8 @@ ABC_NAMESPACE_HEADER_START ...@@ -63,11 +87,8 @@ ABC_NAMESPACE_HEADER_START
/* Function prototypes */ /* Function prototypes */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
ABC_NAMESPACE_HEADER_END
/**AutomaticEnd***************************************************************/ /**AutomaticEnd***************************************************************/
ABC_NAMESPACE_HEADER_END
#endif /* _MTRINT */ #endif /* _MTRINT */
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