diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b5a94fef3c..41bd7e79db 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,17 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-15 20:52 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/vm/hvm.c + * register default RT symbols after setting exception handler + + * harbour/source/vm/fm.c + % keep process heap address in static variable when HeapAlloc() + is used. + + * harbour/source/vm/extrap.c + * casting to pacify warnings + 2009-01-15 13:48 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/vm/set.c * do not check for HVM stack existence in ST HVM to avoid compiler diff --git a/harbour/source/vm/extrap.c b/harbour/source/vm/extrap.c index 7939bd886a..c6c183ce96 100644 --- a/harbour/source/vm/extrap.c +++ b/harbour/source/vm/extrap.c @@ -260,9 +260,9 @@ LONG WINAPI hb_win32ExceptionHandler( struct _EXCEPTION_POINTERS * pExceptionInf char buf[ 64 ]; #if defined( HB_OS_WIN_64 ) /* TOFIX: me32.szExePath seemed trashed in some (standalone) tests. */ - hb_snprintf( buf, sizeof( buf ), "0x%016" PFLL "X 0x%016" PFLL "X %s\n", me32.modBaseAddr, me32.modBaseSize, me32.szExePath ); + hb_snprintf( buf, sizeof( buf ), "0x%016" PFLL "X 0x%016" PFLL "X %s\n", ( HB_PTRDIFF ) me32.modBaseAddr, ( HB_PTRDIFF ) me32.modBaseSize, me32.szExePath ); #else - hb_snprintf( buf, sizeof( buf ), "0x%08X 0x%08X %s\n", me32.modBaseAddr, me32.modBaseSize, me32.szExePath ); + hb_snprintf( buf, sizeof( buf ), "0x%08lX 0x%08lX %s\n", ( HB_PTRDIFF ) me32.modBaseAddr, ( HB_PTRDIFF ) me32.modBaseSize, me32.szExePath ); #endif hb_strncat( errmsg, buf, errmsglen ); } while( pModule32Next( hModuleSnap, &me32 ) ); diff --git a/harbour/source/vm/fm.c b/harbour/source/vm/fm.c index 4d953cb02a..5d944e8ccf 100644 --- a/harbour/source/vm/fm.c +++ b/harbour/source/vm/fm.c @@ -157,9 +157,12 @@ # define realloc( p, n ) ( void * ) LocalReAlloc( ( HLOCAL ) ( p ), ( n ), LMEM_MOVEABLE ) # define free( p ) LocalFree( ( HLOCAL ) ( p ) ) # else -# define malloc( n ) ( void * ) HeapAlloc( GetProcessHeap(), 0, ( n ) ) -# define realloc( p, n ) ( void * ) HeapReAlloc( GetProcessHeap(), 0, ( void * ) ( p ), ( n ) ) -# define free( p ) HeapFree( GetProcessHeap(), 0, ( void * ) ( p ) ) + static HANDLE s_hProcessHeap = NULL; +# define HB_FM_NEED_INIT +# define HB_FM_HEAP_INIT +# define malloc( n ) ( void * ) HeapAlloc( s_hProcessHeap, 0, ( n ) ) +# define realloc( p, n ) ( void * ) HeapReAlloc( s_hProcessHeap, 0, ( void * ) ( p ), ( n ) ) +# define free( p ) HeapFree( s_hProcessHeap, 0, ( void * ) ( p ) ) # endif #endif @@ -177,7 +180,11 @@ #endif -#ifndef HB_FM_STATISTICS +#if defined( HB_FM_STATISTICS ) +# if !defined( HB_FM_NEED_INIT ) +# define HB_FM_NEED_INIT +# endif +#else # undef HB_PARANOID_MEM_CHECK #endif @@ -185,6 +192,9 @@ # define HB_TR_LEVEL HB_TR_ERROR #endif +#ifdef HB_FM_NEED_INIT +static BOOL s_fInited = FALSE; +#endif #ifdef HB_FM_STATISTICS @@ -227,7 +237,6 @@ typedef struct _HB_MEMINFO */ #define HB_TRACE_FM HB_TRACE_STEALTH -static BOOL s_fInited = FALSE; static BOOL s_fStatistic = FALSE; static LONG s_lMemoryBlocks = 0; /* memory blocks used */ @@ -323,7 +332,7 @@ void * hb_xalloc( ULONG ulSize ) /* allocates fixed memory, returns NULL if( ulSize == 0 ) hb_errInternal( HB_EI_XALLOCNULLSIZE, NULL, NULL, NULL ); -#ifdef HB_FM_STATISTICS +#ifdef HB_FM_NEED_INIT if( !s_fInited ) hb_xinit(); #endif @@ -402,7 +411,7 @@ void * hb_xgrab( ULONG ulSize ) /* allocates fixed memory, exits on fail if( ulSize == 0 ) hb_errInternal( HB_EI_XGRABNULLSIZE, NULL, NULL, NULL ); -#ifdef HB_FM_STATISTICS +#ifdef HB_FM_NEED_INIT if( !s_fInited ) hb_xinit(); #endif @@ -755,9 +764,11 @@ void hb_xinit( void ) /* Initialize fixed memory subsystem */ { HB_TRACE(HB_TR_DEBUG, ("hb_xinit()")); -#ifdef HB_FM_STATISTICS +#ifdef HB_FM_NEED_INIT if( !s_fInited ) { + +#ifdef HB_FM_STATISTICS char buffer[ 5 ]; if( hb_getenv_buffer( "HB_FM_STAT", buffer, sizeof( buffer ) ) ) @@ -767,14 +778,19 @@ void hb_xinit( void ) /* Initialize fixed memory subsystem */ else if( hb_stricmp( "no", buffer ) == 0 ) s_fStatistic = FALSE; } -#ifndef HB_FM_STATISTICS_DYN_OFF +#ifdef HB_FM_STATISTICS_DYN_OFF else s_fStatistic = TRUE; /* enabled by default */ +#endif /* HB_FM_STATISTICS_DYN_OFF */ +#endif /* HB_FM_STATISTICS */ + +#if defined( HB_FM_HEAP_INIT ) + s_hProcessHeap = GetProcessHeap(); #endif s_fInited = TRUE; } -#endif +#endif /* HB_FM_NEED_INIT */ } /* Returns pointer to string containing printable version diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index f3a5cb8f5c..a0c475ca25 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -850,12 +850,12 @@ void hb_vmInit( BOOL bStartMainProc ) /* initialize internal data structures */ s_aStatics.type = HB_IT_NIL; - hb_vmSymbolInit_RT(); /* initialize symbol table with runtime support functions */ - hb_xinit(); hb_vmSetExceptionHandler(); + hb_vmSymbolInit_RT(); /* initialize symbol table with runtime support functions */ + #if defined( HB_MT_VM ) hb_threadInit(); hb_vmStackInit( hb_threadStateNew() ); /* initialize HVM thread stack */