diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f52033f413..5765584700 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,18 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-02-24 13:49 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbsetup.h + * minor modifications in macros + * disabled some GCC function attributes when ICC is used + + * harbour/source/pp/ppcore.c + * casting + + * harbour/source/vm/fm.c + * destroy dlmalloc mspace in hb_xexit() when USE_DL_PREFIX is used + otherwise call malloc_trim(0) to at least reduce allocated memory + 2009-02-24 13:39 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * config/win/msvc.cf * config/win/msvc64.cf diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index 05e6c5cf20..c76fdce44b 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -208,8 +208,9 @@ #define HB_OS_ALLFILE_MASK "*" #undef HB_OS_DRIVE_DELIM_CHR #undef HB_OS_HAS_DRIVE_LETTER - #define HB_OS_OPT_DELIM_LIST "-" #define HB_OS_EOL_LEN 1 + #define HB_OS_OPT_DELIM_LIST "-" + #define HB_ISOPTSEP( c ) ( ( c ) == '-' ) #else /* we are assuming here the DOS compatible OS */ #define HB_OS_PATH_LIST_SEP_CHR ';' @@ -219,16 +220,15 @@ #define HB_OS_ALLFILE_MASK "*.*" #define HB_OS_DRIVE_DELIM_CHR ':' #define HB_OS_HAS_DRIVE_LETTER - #define HB_OS_OPT_DELIM_LIST "/-" #define HB_OS_EOL_LEN 2 /* # of bytes in End of Line marker */ + #define HB_OS_OPT_DELIM_LIST "/-" + #define HB_ISOPTSEP( c ) ( ( c ) == '-' || ( c ) == '/' ) #endif #ifndef _POSIX_PATH_MAX #define _POSIX_PATH_MAX 255 #endif -#define HB_ISOPTSEP( c ) ( strchr( HB_OS_OPT_DELIM_LIST, ( c ) ) != NULL ) - /* NOTE: Compiler _MSC_VER value -------- -------------- @@ -407,13 +407,15 @@ # else #define HB_NORETURN_ATTR # endif -# if ( ( __GNUC__ > 4 ) || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 1 ) ) +# if ( ( __GNUC__ > 4 ) || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 1 ) ) && \ + !defined( __ICC ) #define HB_FLATTEN_ATTR \ __attribute__ (( flatten )) # else #define HB_FLATTEN_ATTR # endif -# if ( ( __GNUC__ > 4 ) || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3 ) ) +# if ( ( __GNUC__ > 4 ) || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 3 ) ) && \ + !defined( __ICC ) #define HB_ALLOC_SIZE_ATTR( _nParam ) \ __attribute__ (( alloc_size (_nParam))) # else diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index d1a9c86345..a631ba5250 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -326,12 +326,12 @@ static void hb_membufRemove( PHB_MEM_BUFFER pBuffer, ULONG ulLeft ) } #endif -static ULONG hb_membufLen( PHB_MEM_BUFFER pBuffer ) +static ULONG hb_membufLen( const PHB_MEM_BUFFER pBuffer ) { return pBuffer->ulLen; } -static char * hb_membufPtr( PHB_MEM_BUFFER pBuffer ) +static char * hb_membufPtr( const PHB_MEM_BUFFER pBuffer ) { return pBuffer->pBufPtr; } diff --git a/harbour/source/vm/fm.c b/harbour/source/vm/fm.c index 82bf2048f6..854b5eb9f6 100644 --- a/harbour/source/vm/fm.c +++ b/harbour/source/vm/fm.c @@ -134,7 +134,7 @@ # pragma warn -rch # elif defined( HB_OS_WIN_CE ) && defined( __POCC__ ) # define ABORT TerminateProcess( GetCurrentProcess(), 0 ) -# elif defined( _MSC_VER ) +# elif defined( _MSC_VER ) && !defined( USE_DL_PREFIX ) # define USE_DL_PREFIX # endif # include "dlmalloc.c" @@ -793,6 +793,25 @@ void hb_xinit( void ) /* Initialize fixed memory subsystem */ #endif /* HB_FM_NEED_INIT */ } +#if defined( HB_FM_DL_ALLOC ) && defined( USE_DL_PREFIX ) +static void dlmalloc_destroy( void ) +{ + if( ok_magic(gm) ) + { + msegmentptr sp = &gm->seg; + while(sp != 0 ) + { + char* base = sp->base; + size_t size = sp->size; + flag_t flag = sp->sflags; + sp = sp->next; + if( (flag & IS_MMAPPED_BIT) && !(flag & EXTERN_BIT) ) + CALL_MUNMAP(base, size); + } + } +} +#endif + /* Returns pointer to string containing printable version of pMem memory block */ @@ -908,6 +927,14 @@ void hb_xexit( void ) /* Deinitialize fixed memory subsystem */ fclose( hLog ); } } + +#if defined( HB_FM_DL_ALLOC ) +# if defined( USE_DL_PREFIX ) + dlmalloc_destroy(); +# else + malloc_trim( 0 ); +# endif +#endif } #else @@ -915,6 +942,14 @@ void hb_xexit( void ) /* Deinitialize fixed memory subsystem */ void hb_xexit( void ) /* Deinitialize fixed memory subsystem */ { HB_TRACE(HB_TR_DEBUG, ("hb_xexit()")); + +#if defined( HB_FM_DL_ALLOC ) +# if defined( USE_DL_PREFIX ) + dlmalloc_destroy(); +# else + malloc_trim( 0 ); +# endif +#endif } #endif