From 5ba8b665f3b1f4067f46e044e421e50b753165d6 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Thu, 26 Nov 2009 21:26:13 +0000 Subject: [PATCH] 2009-11-26 22:26 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/vm/garbage.c % small improvement in HB_GC_AUTO code * harbour/include/hbdefs.h ! reverted the hack which casted file handles to unsigned values I added two weeks ago - it was also converting FS_ERROR value from -1 to 4294967295. Please remember that on some platforms negative handles can exist and are valid. Only -1 indicates an error. * harbour/utils/hbtest/rt_file.prg + added regression test for FOPEN() FS_ERROR value * harbour/contrib/hbwin/legacycd.c * harbour/contrib/hbwin/legacyco.c * added missing EOL at EOF --- harbour/ChangeLog | 18 ++++++++++++++++++ harbour/contrib/hbwin/legacycd.c | 2 +- harbour/contrib/hbwin/legacyco.c | 2 +- harbour/include/hbdefs.h | 2 +- harbour/src/vm/garbage.c | 17 ++++++++++++----- harbour/utils/hbtest/rt_file.prg | 1 + 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 6b4c2ab0e1..3d5a137c2c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,24 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-11-26 22:26 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/src/vm/garbage.c + % small improvement in HB_GC_AUTO code + + * harbour/include/hbdefs.h + ! reverted the hack which casted file handles to unsigned values + I added two weeks ago - it was also converting FS_ERROR value + from -1 to 4294967295. Please remember that on some platforms + negative handles can exist and are valid. Only -1 indicates an + error. + + * harbour/utils/hbtest/rt_file.prg + + added regression test for FOPEN() FS_ERROR value + + * harbour/contrib/hbwin/legacycd.c + * harbour/contrib/hbwin/legacyco.c + * added missing EOL at EOF + 2009-11-26 09:34 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) - contrib/hbide/resources/tabmodified.PNG * contrib/xhb/Makefile diff --git a/harbour/contrib/hbwin/legacycd.c b/harbour/contrib/hbwin/legacycd.c index 139450644d..55828d7e46 100644 --- a/harbour/contrib/hbwin/legacycd.c +++ b/harbour/contrib/hbwin/legacycd.c @@ -76,4 +76,4 @@ HB_FUNC( SETLASTERROR ) SetLastError( hb_parnl( 1 ) ); } -#endif \ No newline at end of file +#endif diff --git a/harbour/contrib/hbwin/legacyco.c b/harbour/contrib/hbwin/legacyco.c index 1dfc15fb70..6d7399ba56 100644 --- a/harbour/contrib/hbwin/legacyco.c +++ b/harbour/contrib/hbwin/legacyco.c @@ -123,4 +123,4 @@ HB_FUNC( __OLEPDISP ) ( IDispatch * ) ( HB_PTRUINT ) hb_parnint( 1 ) ); } -#endif \ No newline at end of file +#endif diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index cccaa799bf..39f2a8726d 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -612,7 +612,7 @@ typedef unsigned long HB_COUNTER; #else typedef void * HB_FHANDLE; #endif - typedef HB_PTRUINT HB_NHANDLE; + typedef HB_PTRDIFF HB_NHANDLE; # define hb_numToHandle( h ) ( ( HB_FHANDLE ) ( HB_NHANDLE ) ( h ) ) #else typedef int HB_FHANDLE; diff --git a/harbour/src/vm/garbage.c b/harbour/src/vm/garbage.c index 0ee2abfe35..377b2a7485 100644 --- a/harbour/src/vm/garbage.c +++ b/harbour/src/vm/garbage.c @@ -131,10 +131,15 @@ typedef struct HB_GARBAGE_ #define HB_GC_DELETELST 4 /* item will be deleted during finalization */ #ifdef HB_GC_AUTO +#define HB_GC_AUTO_CHECK 100000 +#define HB_GC_AUTO_MAX ( ( HB_PTRUINT ) ( -1 ) ); /* number of allocated memory blocks */ -static ULONG s_ulBlocks = 0; +static HB_PTRUINT s_ulBlocks = 0; /* number of allocated memory blocks after last GC activation */ -static ULONG s_ulBlocksMarked = 0; +static HB_PTRUINT s_ulBlocksMarked = 0; +/* number of allocated memory blocks which should force next GC activation */ +static HB_PTRUINT s_ulBlocksCheck = HB_GC_AUTO_CHECK; + # define HB_GC_AUTO_INC ++s_ulBlocks; # define HB_GC_AUTO_DEC --s_ulBlocks; #else @@ -202,7 +207,7 @@ void * hb_gcAllocate( ULONG ulSize, const HB_GC_FUNCS * pFuncs ) pAlloc->used = s_uUsedFlag; HB_GC_LOCK #ifdef HB_GC_AUTO - if( s_ulBlocks > s_ulBlocksMarked + 100000 ) + if( s_ulBlocks > s_ulBlocksCheck ) { HB_GC_UNLOCK hb_gcCollectAll( TRUE ); @@ -233,7 +238,7 @@ void * hb_gcAllocRaw( ULONG ulSize, const HB_GC_FUNCS * pFuncs ) HB_GC_LOCK #ifdef HB_GC_AUTO - if( s_ulBlocks > s_ulBlocksMarked + 100000 ) + if( s_ulBlocks > s_ulBlocksCheck ) { HB_GC_UNLOCK hb_gcCollectAll( TRUE ); @@ -703,9 +708,11 @@ void hb_gcCollectAll( BOOL fForce ) #ifdef HB_GC_AUTO /* store number of marked blocks for automatic GC activation */ s_ulBlocksMarked = s_ulBlocks; + s_ulBlocksCheck = s_ulBlocksMarked + HB_GC_AUTO_CHECK; + if( s_ulBlocksCheck <= s_ulBlocksMarked ) + s_ulBlocksCheck = HB_GC_AUTO_MAX; #endif - /* call memory manager cleanup function */ hb_xclean(); diff --git a/harbour/utils/hbtest/rt_file.prg b/harbour/utils/hbtest/rt_file.prg index 4706af2b49..d470201e15 100644 --- a/harbour/utils/hbtest/rt_file.prg +++ b/harbour/utils/hbtest/rt_file.prg @@ -137,6 +137,7 @@ PROCEDURE Main_FILE() TEST_LINE( TESTFIER( FErase( 1 ) ) , 'E: 3 R: -1' ) TEST_LINE( TESTFIER( FErase( "NOT_HERE.$$$" ) ) , 'E: 2 R: -1' ) TEST_LINE( TESTFIER( FRename( "NOT_HERE.$$$", 'A' ) ) , 'E: 2 R: -1' ) + TEST_LINE( TESTFIER( FOpen( "NOT_HERE.$$$" ) ) , 'E: 2 R: -1' ) nFlags := FO_READWRITE fhnd := FOpen( cFileName, nFlags )