diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5d6a4e649a..ffe2f76398 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,49 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-04-01 22:10 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/doc/Makefile + ! removed unexisting license.txt file + + * harbour/include/hbapidbg.h + * do not export Harbour debugger functions. If someone wants to create + 3-rd party debugger then we should agree the list of functions which + should be public. + + * harbour/include/hbstack.h + * minor cleanup in some definitions + + * harbour/include/hbdefs.h + + added HB_DLL_ENTRY_POINT macro to set default DLL entry point for + different Windows compilers + + * harbour/source/vm/maindllh.c + * harbour/source/vm/maindllp.c + * use HB_DLL_ENTRY_POINT macro + + * harbour/include/hbsetup.h + * added internal macro to disable flatten optimization + + * harbour/include/hbmath.h + * harbour/source/rtl/math.c + * make default math error handler function static + + * harbour/include/hbatomic.h + + added atomic inc/dec inline asm code to OW x86 builds + + * harbour/source/rtl/console.c + * small code reorganization to not mix public and private function calls + + * harbour/source/rtl/hbregex.c + * harbour/source/hbpcre/_hbpcreg.c + * do not use hb_xfree() function pointer directly to avoid problems + with different calling conventions. + + * harbour/config/win/owatcom.cf + * harbour/config/os2/owatcom.cf + * removed unnecessary in recent OpenWatcom versions explicit wlink.lnk + including. + 2009-04-01 14:11 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * utils/hbmk2/hbmk2.prg + Added clipper/rtlink/exospace/blinker self-name recognition. diff --git a/harbour/config/os2/owatcom.cf b/harbour/config/os2/owatcom.cf index 19c2bc45ab..9fb1c752d1 100644 --- a/harbour/config/os2/owatcom.cf +++ b/harbour/config/os2/owatcom.cf @@ -78,7 +78,6 @@ $(foreach file, $(^F), $(link_file)) $(foreach lib, $(LINKLIBS), $(link_lib)) $(foreach lib, $(RDDLIBS), $(link_lib)) $(foreach lib, $(GTLIBS), $(link_lib)) -echo @%WATCOM%/binp/wlink.lnk >> __link__.tmp -$(LD) @__link__.tmp endef diff --git a/harbour/config/win/owatcom.cf b/harbour/config/win/owatcom.cf index abe520a7db..4ed2f04be4 100644 --- a/harbour/config/win/owatcom.cf +++ b/harbour/config/win/owatcom.cf @@ -84,8 +84,7 @@ $(foreach file, $(^F), $(link_file)) $(foreach lib, $(LINKLIBS), $(link_lib)) $(foreach lib, $(RDDLIBS), $(link_lib)) $(foreach lib, $(GTLIBS), $(link_lib)) -echo @%WATCOM%/binnt/wlink.lnk >> __link__.tmp -echo LIB kernel32.lib, user32.lib, ws2_32.lib >> __link__.tmp +echo LIB ws2_32.lib >> __link__.tmp -$(LD) @__link__.tmp endef diff --git a/harbour/include/hbapidbg.h b/harbour/include/hbapidbg.h index b900ff0367..6113828279 100644 --- a/harbour/include/hbapidbg.h +++ b/harbour/include/hbapidbg.h @@ -61,32 +61,32 @@ HB_EXTERN_BEGIN /* HVM debugger function */ typedef void (*HB_DBGENTRY_FUNC) ( int , int , char *, int , PHB_ITEM ); -HB_EXPORT extern HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry ); -HB_EXPORT extern BOOL hb_dbg_InvokeDebug( BOOL bInvoke ); -HB_EXPORT extern ULONG hb_dbg_ProcLevel( void ); -HB_EXPORT extern PHB_ITEM hb_dbg_vmVarSGet( PHB_ITEM pStaticsBase, int nOffset ); -HB_EXPORT extern PHB_ITEM hb_dbg_vmVarLGet( int iLevel, int iLocal ); -HB_EXPORT extern ULONG hb_dbg_vmVarGCount( void ); -HB_EXPORT extern PHB_ITEM hb_dbg_vmVarGGet( int nGlobal, int nOffset ); +extern HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry ); +extern BOOL hb_dbg_InvokeDebug( BOOL bInvoke ); +extern ULONG hb_dbg_ProcLevel( void ); +extern PHB_ITEM hb_dbg_vmVarSGet( PHB_ITEM pStaticsBase, int nOffset ); +extern PHB_ITEM hb_dbg_vmVarLGet( int iLevel, int iLocal ); +extern ULONG hb_dbg_vmVarGCount( void ); +extern PHB_ITEM hb_dbg_vmVarGGet( int nGlobal, int nOffset ); /* internal debugger function */ -HB_EXPORT extern void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame ); -HB_EXPORT extern void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction ); -HB_EXPORT extern void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace ); -HB_EXPORT extern void hb_dbgDelBreak( void *handle, int nBreak ); -HB_EXPORT extern void hb_dbgDelWatch( void *handle, int nWatch ); -HB_EXPORT extern PHB_ITEM hb_dbgGetExpressionValue( void *handle, char *expression ); -HB_EXPORT extern PHB_ITEM hb_dbgGetSourceFiles( void *handle ); -HB_EXPORT extern PHB_ITEM hb_dbgGetWatchValue( void *handle, int nWatch ); -HB_EXPORT extern BOOL hb_dbgIsValidStopLine( void *handle, char *szModule, int nLine ); -HB_EXPORT extern void hb_dbgSetCBTrace( void *handle, BOOL bCBTrace ); -HB_EXPORT extern void hb_dbgSetGo( void *handle ); -HB_EXPORT extern void hb_dbgSetInvoke( void *handle, BOOL ( *pFunInvoke )( void ) ); -HB_EXPORT extern void hb_dbgSetNextRoutine( void *handle ); -HB_EXPORT extern void hb_dbgSetQuit( void *handle ); -HB_EXPORT extern void hb_dbgSetToCursor( void *handle, char *szModule, int nLine ); -HB_EXPORT extern void hb_dbgSetTrace( void *handle ); -HB_EXPORT extern void hb_dbgSetWatch( void *handle, int nWatch, char *szExpr, BOOL bTrace ); +extern void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame ); +extern void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction ); +extern void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace ); +extern void hb_dbgDelBreak( void *handle, int nBreak ); +extern void hb_dbgDelWatch( void *handle, int nWatch ); +extern PHB_ITEM hb_dbgGetExpressionValue( void *handle, char *expression ); +extern PHB_ITEM hb_dbgGetSourceFiles( void *handle ); +extern PHB_ITEM hb_dbgGetWatchValue( void *handle, int nWatch ); +extern BOOL hb_dbgIsValidStopLine( void *handle, char *szModule, int nLine ); +extern void hb_dbgSetCBTrace( void *handle, BOOL bCBTrace ); +extern void hb_dbgSetGo( void *handle ); +extern void hb_dbgSetInvoke( void *handle, BOOL ( *pFunInvoke )( void ) ); +extern void hb_dbgSetNextRoutine( void *handle ); +extern void hb_dbgSetQuit( void *handle ); +extern void hb_dbgSetToCursor( void *handle, char *szModule, int nLine ); +extern void hb_dbgSetTrace( void *handle ); +extern void hb_dbgSetWatch( void *handle, int nWatch, char *szExpr, BOOL bTrace ); HB_EXTERN_END diff --git a/harbour/include/hbatomic.h b/harbour/include/hbatomic.h index 5f347ef88a..673bda8272 100644 --- a/harbour/include/hbatomic.h +++ b/harbour/include/hbatomic.h @@ -292,7 +292,46 @@ HB_EXTERN_BEGIN # endif -# endif +# endif /* x86 */ + +#elif defined( __WATCOMC__ ) && defined( __cplusplus ) + +# if defined( i386 ) || defined( __i386__ ) || defined( __x86_64__ ) || \ + defined( _M_IX86 ) || defined( _M_AMD64 ) + +# if HB_COUNTER_SIZE == 4 + + static inline void hb_atomic_inc32( volatile int * p ) + { + _asm { + mov eax, p + lock inc dword ptr [eax] + } + } + + static inline int hb_atomic_dec32( volatile int * p ) + { + unsigned char c; + _asm { + mov eax, p + lock dec dword ptr [eax] + setne c + } + return c; + } + +# define HB_ATOM_INC( p ) ( hb_atomic_inc32( ( volatile int * ) (p) ) ) +# define HB_ATOM_DEC( p ) ( hb_atomic_dec32( ( volatile int * ) (p) ) ) +# define HB_ATOM_GET( p ) (*(int volatile *)(p)) +# define HB_ATOM_SET( p, n ) do { *((int volatile *)(p)) = (n); } while(0) + +# elif HB_COUNTER_SIZE == 8 + + /* TODO: */ + +# endif + +# endif /* x86 */ #endif /* ??? C compiler ??? */ diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index 05597d9cf8..c9efdab122 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -1260,6 +1260,13 @@ typedef long hbVMIntMax; /* TOFIX */ #define HB_START_PROC_STRICT #endif +#if defined(__WATCOMC__) || defined(__DMC__) || \ + defined(_MSC_VER) || defined(__POCC__) + #define HB_DLL_ENTRY_POINT DllMain +#else + #define HB_DLL_ENTRY_POINT DllEntryPoint +#endif + #if defined(HB_FUNC_CALLCONV) #define HARBOUR void HB_FUNC_CALLCONV #else diff --git a/harbour/include/hbmath.h b/harbour/include/hbmath.h index bde5909408..53b4fcbea6 100644 --- a/harbour/include/hbmath.h +++ b/harbour/include/hbmath.h @@ -125,7 +125,6 @@ extern HB_EXPORT BOOL hb_mathGetError( HB_MATH_EXCEPTION * phb_exc, const char * extern HB_EXPORT int hb_mathSetErrMode( int imode ); extern HB_EXPORT int hb_mathGetErrMode( void ); -extern HB_EXPORT int hb_matherr( HB_MATH_EXCEPTION * pexc ); extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathSetHandler( HB_MATH_HANDLERPROC handlerproc ); extern HB_EXPORT HB_MATH_HANDLERPROC hb_mathGetHandler( void ); diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index 1f34119094..02ca287cd5 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -412,7 +412,7 @@ #define HB_NORETURN_ATTR # endif # if ( ( __GNUC__ > 4 ) || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 1 ) ) && \ - !defined( __ICC ) + !defined( __ICC ) && !defined( HB_NO_FALTTEN ) #define HB_FLATTEN_ATTR \ __attribute__ (( flatten )) # else diff --git a/harbour/include/hbstack.h b/harbour/include/hbstack.h index d727807780..3e79cc8f9a 100644 --- a/harbour/include/hbstack.h +++ b/harbour/include/hbstack.h @@ -200,7 +200,7 @@ typedef struct extern HB_TLS_KEY hb_stack_key; # if defined( __BORLANDC__ ) && defined( HB_STACK_PRELOAD ) && \ !defined( HB_OS_WIN_64 ) && !defined( HB_OS_WIN_CE ) - static __inline void* hb_stack_ptr_from_tls( void ) + static __inline void * hb_stack_ptr_from_tls( void ) { /* mov ecx,hb_stack_key */ _ECX = hb_stack_key; @@ -211,6 +211,7 @@ typedef struct /* ret (if function is not inlined) */ return (void*) _EAX; } +# define hb_stack_ptr_get() hb_stack_ptr_from_tls() # elif defined( __MINGW32__ ) && \ !defined( HB_OS_WIN_64 ) && !defined( HB_OS_WIN_CE ) static __inline__ __attribute__ ((pure, malloc)) void * hb_stack_ptr_from_tls( void ) @@ -224,6 +225,7 @@ typedef struct ); return p; } +# define hb_stack_ptr_get() hb_stack_ptr_from_tls() # define hb_stack_ptr ( ( PHB_STACK ) hb_stack_ptr_from_tls() ) # endif # if !defined( hb_stack_ptr ) @@ -231,19 +233,21 @@ typedef struct # endif # endif # if defined( HB_STACK_PRELOAD ) && !defined( HB_USE_TLS ) -# if ( defined( __BORLANDC__ ) || defined( __MINGW32__ ) ) && \ - !defined( HB_OS_WIN_64 ) && !defined( HB_OS_WIN_CE ) -# define HB_STACK_TLS_PRELOAD PHB_STACK _hb_stack_ptr_ = ( PHB_STACK ) hb_stack_ptr_from_tls(); +# if defined( hb_stack_ptr_get ) +# define HB_STACK_TLS_PRELOAD PHB_STACK _hb_stack_ptr_ = ( PHB_STACK ) hb_stack_ptr_get(); # undef hb_stack_ptr # else # define HB_STACK_TLS_PRELOAD PHB_STACK _hb_stack_ptr_ = hb_stack_ptr; # endif -# define hb_stack ( * _hb_stack_ptr_ ) +# define hb_stack ( * _hb_stack_ptr_ ) +# define hb_stack_ref() ( _hb_stack_ptr_ ) # else -# define hb_stack ( * hb_stack_ptr ) +# define hb_stack ( * hb_stack_ptr ) +# define hb_stack_ref() ( hb_stack_ptr ) # endif # else extern HB_STACK hb_stack; +# define hb_stack_ref() ( &hb_stack ) # endif #endif #if !defined( HB_STACK_TLS_PRELOAD ) && defined( HB_STACK_PRELOAD ) @@ -381,7 +385,7 @@ extern void hb_stackIsStackRef( void *, PHB_TSD_FUNC ); #define hb_stackGetI18N( ) ( hb_stack.pI18N ) #define hb_stackSetI18N( p ) do { hb_stack.pI18N = ( p ); } while ( 0 ) -#define hb_stackId( ) ( ( void * ) &hb_stack ) +#define hb_stackId( ) ( ( void * ) hb_stack_ref() ) #if defined( HB_MT_VM ) # define hb_stackList() ( hb_stack.pStackLst ) # define hb_stackListSet( p ) do { hb_stack.pStackLst = ( p ); } while ( 0 ) diff --git a/harbour/source/hbpcre/_hbpcreg.c b/harbour/source/hbpcre/_hbpcreg.c index e509cc4efe..035ebe41b9 100644 --- a/harbour/source/hbpcre/_hbpcreg.c +++ b/harbour/source/hbpcre/_hbpcreg.c @@ -60,6 +60,11 @@ static void * hb_pcre_grab( size_t size ) return hb_xgrab( size ); } +static void hb_pcre_free( void * ptr ) +{ + hb_xfree( ptr ); +} + #if 1 #include "_hbconf.h" #endif @@ -69,9 +74,9 @@ static void * hb_pcre_grab( size_t size ) #ifndef VPCOMPAT HB_EXTERN_BEGIN PCRE_EXP_DATA_DEFN void *(*pcre_malloc)(size_t) = hb_pcre_grab; -PCRE_EXP_DATA_DEFN void (*pcre_free)(void *) = hb_xfree; +PCRE_EXP_DATA_DEFN void (*pcre_free)(void *) = hb_pcre_free; PCRE_EXP_DATA_DEFN void *(*pcre_stack_malloc)(size_t) = hb_pcre_grab; -PCRE_EXP_DATA_DEFN void (*pcre_stack_free)(void *) = hb_xfree; +PCRE_EXP_DATA_DEFN void (*pcre_stack_free)(void *) = hb_pcre_free; PCRE_EXP_DATA_DEFN int (*pcre_callout)(pcre_callout_block *) = NULL; HB_EXTERN_END #endif diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index cb434d530b..f0dd13d599 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -268,8 +268,6 @@ static void hb_conOutDev( const char * pStr, ULONG ulLen ) hb_gtWrite( ( BYTE * ) pStr, ulLen ); } -typedef void hb_out_func_typedef( const char *, ULONG ); - static char * hb_itemStringCon( PHB_ITEM pItem, ULONG * pulLen, BOOL * pfFreeReq ) { /* logical values in device output (not console, stdout or stderr) are @@ -283,38 +281,21 @@ static char * hb_itemStringCon( PHB_ITEM pItem, ULONG * pulLen, BOOL * pfFreeReq return hb_itemString( pItem, pulLen, pfFreeReq ); } -/* Format items for output, then call specified output function */ -static void hb_conOut( USHORT uiParam, hb_out_func_typedef * pOutFunc ) -{ - char * pszString; - ULONG ulLen; - BOOL bFreeReq; - PHB_ITEM pItem; - - HB_TRACE(HB_TR_DEBUG, ("hb_conOut(%hu, %p)", uiParam, pOutFunc)); - - pItem = hb_param( uiParam, HB_IT_ANY ); - - if( pOutFunc == hb_conOutDev ) - pszString = hb_itemStringCon( pItem, &ulLen, &bFreeReq ); - else - pszString = hb_itemString( pItem, &ulLen, &bFreeReq ); - - if( ulLen ) - pOutFunc( pszString, ulLen ); - - if( bFreeReq ) - hb_xfree( pszString ); -} - HB_FUNC( OUTSTD ) /* writes a list of values to the standard output device */ { USHORT uiPCount = ( USHORT ) hb_pcount(); USHORT uiParam; + char * pszString; + ULONG ulLen; + BOOL fFree; for( uiParam = 1; uiParam <= uiPCount; uiParam++ ) { - hb_conOut( uiParam, hb_conOutStd ); + pszString = hb_itemString( hb_param( uiParam, HB_IT_ANY ), &ulLen, &fFree ); + if( ulLen ) + hb_conOutStd( pszString, ulLen ); + if( fFree ) + hb_xfree( pszString ); if( uiParam < uiPCount ) hb_conOutStd( " ", 1 ); } @@ -324,10 +305,17 @@ HB_FUNC( OUTERR ) /* writes a list of values to the standard error device */ { USHORT uiPCount = ( USHORT ) hb_pcount(); USHORT uiParam; + char * pszString; + ULONG ulLen; + BOOL fFree; for( uiParam = 1; uiParam <= uiPCount; uiParam++ ) { - hb_conOut( uiParam, hb_conOutErr ); + pszString = hb_itemString( hb_param( uiParam, HB_IT_ANY ), &ulLen, &fFree ); + if( ulLen ) + hb_conOutErr( pszString, ulLen ); + if( fFree ) + hb_xfree( pszString ); if( uiParam < uiPCount ) hb_conOutErr( " ", 1 ); } @@ -337,10 +325,17 @@ HB_FUNC( QQOUT ) /* writes a list of values to the current device (screen or pri { USHORT uiPCount = ( USHORT ) hb_pcount(); USHORT uiParam; + char * pszString; + ULONG ulLen; + BOOL fFree; for( uiParam = 1; uiParam <= uiPCount; uiParam++ ) { - hb_conOut( uiParam, hb_conOutAlt ); + pszString = hb_itemString( hb_param( uiParam, HB_IT_ANY ), &ulLen, &fFree ); + if( ulLen ) + hb_conOutAlt( pszString, ulLen ); + if( fFree ) + hb_xfree( pszString ); if( uiParam < uiPCount ) hb_conOutAlt( " ", 1 ); } @@ -493,6 +488,10 @@ HB_FUNC( SETPRC ) /* Sets the current printer row and column positions */ HB_FUNC( DEVOUT ) /* writes a single value to the current device (screen or printer), but is not affected by SET ALTERNATE */ { + char * pszString; + ULONG ulLen; + BOOL fFree; + if( ISCHAR( 2 ) ) { char szOldColor[ HB_CLRSTR_LEN ]; @@ -500,12 +499,22 @@ HB_FUNC( DEVOUT ) /* writes a single value to the current device (screen or prin hb_gtGetColorStr( szOldColor ); hb_gtSetColorStr( hb_parc( 2 ) ); - hb_conOut( 1, hb_conOutDev ); + pszString = hb_itemStringCon( hb_param( 1, HB_IT_ANY ), &ulLen, &fFree ); + if( ulLen ) + hb_conOutDev( pszString, ulLen ); + if( fFree ) + hb_xfree( pszString ); hb_gtSetColorStr( szOldColor ); } else if( hb_pcount() >= 1 ) - hb_conOut( 1, hb_conOutDev ); + { + pszString = hb_itemStringCon( hb_param( 1, HB_IT_ANY ), &ulLen, &fFree ); + if( ulLen ) + hb_conOutDev( pszString, ulLen ); + if( fFree ) + hb_xfree( pszString ); + } } HB_FUNC( DISPOUT ) /* writes a single value to the screen, but is not affected by SET ALTERNATE */ diff --git a/harbour/source/rtl/hbregex.c b/harbour/source/rtl/hbregex.c index f992b7b20b..ef2e65bb1b 100644 --- a/harbour/source/rtl/hbregex.c +++ b/harbour/source/rtl/hbregex.c @@ -541,6 +541,10 @@ static void * hb_pcre_grab( size_t size ) { return hb_xgrab( size ); } +static void hb_pcre_free( void * ptr ) +{ + hb_xfree( ptr ); +} #endif HB_CALL_ON_STARTUP_BEGIN( _hb_regex_init_ ) @@ -553,9 +557,9 @@ HB_CALL_ON_STARTUP_BEGIN( _hb_regex_init_ ) } # endif pcre_malloc = hb_pcre_grab; - pcre_free = hb_xfree; + pcre_free = hb_pcre_free; pcre_stack_malloc = hb_pcre_grab; - pcre_stack_free = hb_xfree; + pcre_stack_free = hb_pcre_free; #endif hb_regexInit( hb_regfree, hb_regcomp, hb_regexec ); HB_CALL_ON_STARTUP_END( _hb_regex_init_ ) diff --git a/harbour/source/rtl/math.c b/harbour/source/rtl/math.c index dbc300e741..0ea25b8b2a 100644 --- a/harbour/source/rtl/math.c +++ b/harbour/source/rtl/math.c @@ -87,6 +87,87 @@ typedef struct #endif } HB_MATHERRDATA, * PHB_MATHERRDATA; +/* Harbour default math error handling routine */ +static int hb_matherr( HB_MATH_EXCEPTION * pexc ) +{ + int mode = hb_mathGetErrMode(); + int iRet = 1; + + HB_TRACE( HB_TR_DEBUG, ( "hb_matherr(%p)", pexc ) ); + + if( pexc == NULL || pexc->handled != 0 ) + { + /* error already handled by other handlers ! */ + return 1; + } + + if( mode == HB_MATH_ERRMODE_USER || mode == HB_MATH_ERRMODE_USERDEFAULT || + mode == HB_MATH_ERRMODE_USERCDEFAULT ) + { + PHB_ITEM pArg1, pArg2, pError; + PHB_ITEM pMatherrResult; + + /* create an error object */ + /* NOTE: In case of HB_MATH_ERRMODE_USER[C]DEFAULT, I am setting both EF_CANSUBSTITUTE and EF_CANDEFAULT to .T. here. + This is forbidden according to the original Cl*pper docs, but I think this reflects the situation best here: + The error handler can either substitute the errorneous value (by returning a numeric value) or choose the + default error handling (by returning .F., as usual) [martin vogel] */ + pError = hb_errRT_New_Subst( ES_ERROR, "MATH", EG_NUMERR, pexc->type, + pexc->error, pexc->funcname, 0, EF_CANSUBSTITUTE | + ( mode == HB_MATH_ERRMODE_USER ? 0 : EF_CANDEFAULT ) ); + + /* Assign the new array to the object data item. */ + /* NOTE: Unfortunately, we cannot decide whether one or two parameters have been used when the + math function has been called, so we always take two */ + pArg1 = hb_itemPutND( NULL, pexc->arg1 ); + pArg2 = hb_itemPutND( NULL, pexc->arg2 ); + hb_errPutArgs( pError, 2, pArg1, pArg2 ); + hb_itemRelease( pArg1 ); + hb_itemRelease( pArg2 ); + + /* launch error codeblock */ + pMatherrResult = hb_errLaunchSubst( pError ); + hb_errRelease( pError ); + + if( pMatherrResult ) + { + if( HB_IS_NUMERIC( pMatherrResult ) ) + { + pexc->retval = hb_itemGetND( pMatherrResult ); + hb_itemGetNLen( pMatherrResult, &pexc->retvalwidth, &pexc->retvaldec ); + pexc->handled = 1; + } + hb_itemRelease( pMatherrResult ); + } + } + + /* math exception not handled by Harbour error routine above ? */ + if( pexc->handled == 0 ) + { + switch( mode ) + { + case HB_MATH_ERRMODE_USER: + /* user failed to handle the math exception, so quit the app [yes, that's the meaning of this mode !!] */ + iRet = 0; + hb_vmRequestQuit(); + break; + + case HB_MATH_ERRMODE_DEFAULT: + case HB_MATH_ERRMODE_USERDEFAULT: + /* return 1 to suppress C RTL error msgs, but leave error handling to the calling Harbour routine */ + break; + + case HB_MATH_ERRMODE_CDEFAULT: + case HB_MATH_ERRMODE_USERCDEFAULT: + /* use the correction value supplied in pexc->retval */ + pexc->handled = 1; + break; + } + } + + return iRet; /* error handling successful */ +} + static void hb_mathErrDataInit( void * Cargo ) { PHB_MATHERRDATA pMathErr = ( PHB_MATHERRDATA ) Cargo; @@ -371,87 +452,6 @@ HB_FUNC( HB_MATHERMODE ) /* ([]) -> */ hb_mathSetErrMode( hb_parni( 1 ) ); } -/* Harbour default math error handling routine */ -int hb_matherr( HB_MATH_EXCEPTION * pexc ) -{ - int mode = hb_mathGetErrMode(); - int iRet = 1; - - HB_TRACE( HB_TR_DEBUG, ( "hb_matherr(%p)", pexc ) ); - - if( pexc == NULL || pexc->handled != 0 ) - { - /* error already handled by other handlers ! */ - return 1; - } - - if( mode == HB_MATH_ERRMODE_USER || mode == HB_MATH_ERRMODE_USERDEFAULT || - mode == HB_MATH_ERRMODE_USERCDEFAULT ) - { - PHB_ITEM pArg1, pArg2, pError; - PHB_ITEM pMatherrResult; - - /* create an error object */ - /* NOTE: In case of HB_MATH_ERRMODE_USER[C]DEFAULT, I am setting both EF_CANSUBSTITUTE and EF_CANDEFAULT to .T. here. - This is forbidden according to the original Cl*pper docs, but I think this reflects the situation best here: - The error handler can either substitute the errorneous value (by returning a numeric value) or choose the - default error handling (by returning .F., as usual) [martin vogel] */ - pError = hb_errRT_New_Subst( ES_ERROR, "MATH", EG_NUMERR, pexc->type, - pexc->error, pexc->funcname, 0, EF_CANSUBSTITUTE | - ( mode == HB_MATH_ERRMODE_USER ? 0 : EF_CANDEFAULT ) ); - - /* Assign the new array to the object data item. */ - /* NOTE: Unfortunately, we cannot decide whether one or two parameters have been used when the - math function has been called, so we always take two */ - pArg1 = hb_itemPutND( NULL, pexc->arg1 ); - pArg2 = hb_itemPutND( NULL, pexc->arg2 ); - hb_errPutArgs( pError, 2, pArg1, pArg2 ); - hb_itemRelease( pArg1 ); - hb_itemRelease( pArg2 ); - - /* launch error codeblock */ - pMatherrResult = hb_errLaunchSubst( pError ); - hb_errRelease( pError ); - - if( pMatherrResult ) - { - if( HB_IS_NUMERIC( pMatherrResult ) ) - { - pexc->retval = hb_itemGetND( pMatherrResult ); - hb_itemGetNLen( pMatherrResult, &pexc->retvalwidth, &pexc->retvaldec ); - pexc->handled = 1; - } - hb_itemRelease( pMatherrResult ); - } - } - - /* math exception not handled by Harbour error routine above ? */ - if( pexc->handled == 0 ) - { - switch( mode ) - { - case HB_MATH_ERRMODE_USER: - /* user failed to handle the math exception, so quit the app [yes, that's the meaning of this mode !!] */ - iRet = 0; - hb_vmRequestQuit(); - break; - - case HB_MATH_ERRMODE_DEFAULT: - case HB_MATH_ERRMODE_USERDEFAULT: - /* return 1 to suppress C RTL error msgs, but leave error handling to the calling Harbour routine */ - break; - - case HB_MATH_ERRMODE_CDEFAULT: - case HB_MATH_ERRMODE_USERCDEFAULT: - /* use the correction value supplied in pexc->retval */ - pexc->handled = 1; - break; - } - } - - return iRet; /* error handling successful */ -} - /* * ************************************************************ diff --git a/harbour/source/vm/maindllh.c b/harbour/source/vm/maindllh.c index e4a0f3de97..157af2d726 100644 --- a/harbour/source/vm/maindllh.c +++ b/harbour/source/vm/maindllh.c @@ -60,9 +60,9 @@ #include "hbvm.h" #include "hbapiitm.h" -#if defined(HB_OS_WIN) +#if defined( HB_OS_WIN ) -BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved ) +HB_EXPORT BOOL WINAPI HB_DLL_ENTRY_POINT( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved ) { HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %d)", hInstance, fdwReason, pvReserved ) ); @@ -83,4 +83,11 @@ BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserve return TRUE; } +#if defined( __DMC__ ) || defined( __WATCOMC__ ) +HB_EXTERN_BEGIN +void hb_forceLinkMainWin( void ) {} +void hb_forceLinkMainStd( void ) {} +HB_EXTERN_END +#endif + #endif diff --git a/harbour/source/vm/maindllp.c b/harbour/source/vm/maindllp.c index 7a4220bd57..d062da11c4 100644 --- a/harbour/source/vm/maindllp.c +++ b/harbour/source/vm/maindllp.c @@ -122,9 +122,7 @@ static FARPROC hb_getProcAddress( LPCSTR szProcName ) return pProcAddr; } -HB_EXPORT BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved ); - -BOOL WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved ) +HB_EXPORT BOOL WINAPI HB_DLL_ENTRY_POINT( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved ) { HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %d)", hInstance, fdwReason, pvReserved ) );