mirror of https://github.com/YosysHQ/abc.git
Merge pull request #519 from heshpdx/master
Fix strict aliasing violations
This commit is contained in:
commit
3ce53c361f
|
|
@ -233,7 +233,7 @@ static inline Hop_Obj_t * Hop_ManFetchMemory( Hop_Man_t * p )
|
||||||
if ( p->pListFree == NULL )
|
if ( p->pListFree == NULL )
|
||||||
Hop_ManAddMemory( p );
|
Hop_ManAddMemory( p );
|
||||||
pTemp = p->pListFree;
|
pTemp = p->pListFree;
|
||||||
p->pListFree = *((Hop_Obj_t **)pTemp);
|
memcpy(&p->pListFree, pTemp, sizeof(Hop_Obj_t *));
|
||||||
memset( pTemp, 0, sizeof(Hop_Obj_t) );
|
memset( pTemp, 0, sizeof(Hop_Obj_t) );
|
||||||
if ( p->vObjs )
|
if ( p->vObjs )
|
||||||
{
|
{
|
||||||
|
|
@ -245,8 +245,8 @@ static inline Hop_Obj_t * Hop_ManFetchMemory( Hop_Man_t * p )
|
||||||
}
|
}
|
||||||
static inline void Hop_ManRecycleMemory( Hop_Man_t * p, Hop_Obj_t * pEntry )
|
static inline void Hop_ManRecycleMemory( Hop_Man_t * p, Hop_Obj_t * pEntry )
|
||||||
{
|
{
|
||||||
pEntry->Type = AIG_NONE; // distinquishes dead node from live node
|
pEntry->Type = AIG_NONE; // distinguishes dead node from live node
|
||||||
*((Hop_Obj_t **)pEntry) = p->pListFree;
|
memcpy(pEntry, &p->pListFree, sizeof(Hop_Obj_t *));
|
||||||
p->pListFree = pEntry;
|
p->pListFree = pEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -88,13 +88,15 @@ void Hop_ManStopMemory( Hop_Man_t * p )
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
void Hop_ManAddMemory( Hop_Man_t * p )
|
void Hop_ManAddMemory( Hop_Man_t * p )
|
||||||
{
|
{
|
||||||
char * pMemory;
|
char * pMemory = 0;
|
||||||
|
Hop_Obj_t * pEntry, * pNext;
|
||||||
int i, nBytes;
|
int i, nBytes;
|
||||||
assert( sizeof(Hop_Obj_t) <= 64 );
|
assert( sizeof(Hop_Obj_t) <= 64 );
|
||||||
assert( p->pListFree == NULL );
|
assert( p->pListFree == NULL );
|
||||||
// assert( (Hop_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
|
// assert( (Hop_ManObjNum(p) & IVY_PAGE_MASK) == 0 );
|
||||||
// allocate new memory page
|
// allocate new memory page
|
||||||
nBytes = sizeof(Hop_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
|
nBytes = sizeof(Hop_Obj_t) * (1<<IVY_PAGE_SIZE) + 64;
|
||||||
|
pMemory = pMemory + 64 - (((int)(ABC_PTRUINT_T)pMemory) & 63);
|
||||||
pMemory = ABC_ALLOC( char, nBytes );
|
pMemory = ABC_ALLOC( char, nBytes );
|
||||||
Vec_PtrPush( p->vChunks, pMemory );
|
Vec_PtrPush( p->vChunks, pMemory );
|
||||||
// align memory at the 32-byte boundary
|
// align memory at the 32-byte boundary
|
||||||
|
|
@ -102,13 +104,16 @@ void Hop_ManAddMemory( Hop_Man_t * p )
|
||||||
// remember the manager in the first entry
|
// remember the manager in the first entry
|
||||||
Vec_PtrPush( p->vPages, pMemory );
|
Vec_PtrPush( p->vPages, pMemory );
|
||||||
// break the memory down into nodes
|
// break the memory down into nodes
|
||||||
p->pListFree = (Hop_Obj_t *)pMemory;
|
pEntry = (Hop_Obj_t *)pMemory;
|
||||||
|
p->pListFree = pEntry;
|
||||||
for ( i = 1; i <= IVY_PAGE_MASK; i++ )
|
for ( i = 1; i <= IVY_PAGE_MASK; i++ )
|
||||||
{
|
{
|
||||||
*((char **)pMemory) = pMemory + sizeof(Hop_Obj_t);
|
pNext = pEntry + 1;
|
||||||
pMemory += sizeof(Hop_Obj_t);
|
memcpy( pEntry, &pNext, sizeof(Hop_Obj_t *) );
|
||||||
|
pEntry++;
|
||||||
}
|
}
|
||||||
*((char **)pMemory) = NULL;
|
pNext = NULL;
|
||||||
|
memcpy( pEntry, &pNext, sizeof(Hop_Obj_t *) );
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue