Commit c58dd062 by Alan Mishchenko

Fixing reported memory alignment issue.

parent 0f22046b
...@@ -45,6 +45,9 @@ ARCHFLAGS ?= $(shell $(CC) arch_flags.c -o arch_flags && ./arch_flags) ...@@ -45,6 +45,9 @@ ARCHFLAGS ?= $(shell $(CC) arch_flags.c -o arch_flags && ./arch_flags)
OPTFLAGS ?= -g -O #-DABC_NAMESPACE=xxx OPTFLAGS ?= -g -O #-DABC_NAMESPACE=xxx
CFLAGS += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(OPTFLAGS) $(ARCHFLAGS) -Isrc CFLAGS += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(OPTFLAGS) $(ARCHFLAGS) -Isrc
ifneq ($(findstring arm,$(shell uname -m)),)
CFLAGS += -DABC_MEMALIGN=4
endif
# Set -Wno-unused-bug-set-variable for GCC 4.6.0 and greater only # Set -Wno-unused-bug-set-variable for GCC 4.6.0 and greater only
ifneq ($(or $(findstring gcc,$(CC)),$(findstring g++,$(CC))),) ifneq ($(or $(findstring gcc,$(CC)),$(findstring g++,$(CC))),)
......
...@@ -366,6 +366,10 @@ void Aig_MmFlexStop( Aig_MmFlex_t * p, int fVerbose ) ...@@ -366,6 +366,10 @@ void Aig_MmFlexStop( Aig_MmFlex_t * p, int fVerbose )
char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes ) char * Aig_MmFlexEntryFetch( Aig_MmFlex_t * p, int nBytes )
{ {
char * pTemp; char * pTemp;
#ifdef ABC_MEMALIGN
// extend size to max alignment
nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
#endif
// check if there are still free entries // check if there are still free entries
if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd ) if ( p->pCurrent == NULL || p->pCurrent + nBytes > p->pEnd )
{ // need to allocate more entries { // need to allocate more entries
...@@ -535,6 +539,10 @@ char * Aig_MmStepEntryFetch( Aig_MmStep_t * p, int nBytes ) ...@@ -535,6 +539,10 @@ char * Aig_MmStepEntryFetch( Aig_MmStep_t * p, int nBytes )
{ {
if ( nBytes == 0 ) if ( nBytes == 0 )
return NULL; return NULL;
#ifdef ABC_MEMALIGN
// extend size to max alignment
nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
#endif
if ( nBytes > p->nMapSize ) if ( nBytes > p->nMapSize )
{ {
if ( p->nChunks == p->nChunksAlloc ) if ( p->nChunks == p->nChunksAlloc )
...@@ -564,6 +572,10 @@ void Aig_MmStepEntryRecycle( Aig_MmStep_t * p, char * pEntry, int nBytes ) ...@@ -564,6 +572,10 @@ void Aig_MmStepEntryRecycle( Aig_MmStep_t * p, char * pEntry, int nBytes )
{ {
if ( nBytes == 0 ) if ( nBytes == 0 )
return; return;
#ifdef ABC_MEMALIGN
// extend size to max alignment
nBytes += (ABC_MEMALIGN - nBytes % ABC_MEMALIGN) % ABC_MEMALIGN;
#endif
if ( nBytes > p->nMapSize ) if ( nBytes > p->nMapSize )
{ {
// ABC_FREE( pEntry ); // ABC_FREE( pEntry );
......
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