From 2de32f10821a888bf47ff2b65f632499267b9562 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 10 Sep 2007 17:05:30 +0000 Subject: [PATCH] 2007-09-10 19:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbdefs.h + added HB_IMPORT macro * harbour/include/hbset.h * declare hb_set with HB_IMPORT attribute when HB_SET_IMPORT macro is set + added macros to retrieve information from hb_set structure: hb_setGetCPtr(), hb_setGetNI(), hb_setGetNL(), hb_setGetL() In the future these macros will be replaced by functions and direct access to hb_set structure from non core code will be forbidden so please update your code and and replace all hb_set.HB_SET_* with hb_setGet*( HB_SET_* ) f.e. replace: hb_set.HB_SET_SOFTSEEK with: hb_setGetL( HB_SET_SOFTSEEK ) I'll also add hb_setPut*() functions to assign some set values. Both hb_setGet*() and hb_setPut*() functions will validate parameters and in future MT mode will operate on global or thread local structures. * harbour/contrib/rdd_ads/ads1.c * define HB_SET_IMPORT before #include "hbset.h" * use hb_setGet*() to access SET values --- harbour/ChangeLog | 26 +++++++++++++++ harbour/contrib/rdd_ads/ads1.c | 61 +++++++++++++++++++++------------- harbour/include/hbdefs.h | 29 ++++++++++++++++ harbour/include/hbset.h | 14 ++++++-- 4 files changed, 105 insertions(+), 25 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f01971fb60..f78232b692 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,32 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-09-10 19:05 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbdefs.h + + added HB_IMPORT macro + + * harbour/include/hbset.h + * declare hb_set with HB_IMPORT attribute when HB_SET_IMPORT macro is set + + added macros to retrieve information from hb_set structure: + hb_setGetCPtr(), hb_setGetNI(), hb_setGetNL(), hb_setGetL() + In the future these macros will be replaced by functions and + direct access to hb_set structure from non core code will be + forbidden so please update your code and and replace all + hb_set.HB_SET_* + with + hb_setGet*( HB_SET_* ) + f.e. replace: + hb_set.HB_SET_SOFTSEEK + with: + hb_setGetL( HB_SET_SOFTSEEK ) + I'll also add hb_setPut*() functions to assign some set values. + Both hb_setGet*() and hb_setPut*() functions will validate parameters + and in future MT mode will operate on global or thread local structures. + + * harbour/contrib/rdd_ads/ads1.c + * define HB_SET_IMPORT before #include "hbset.h" + * use hb_setGet*() to access SET values + 2007-09-10 17:25 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/dbinfo.ch * harbour/source/rdd/workarea.c diff --git a/harbour/contrib/rdd_ads/ads1.c b/harbour/contrib/rdd_ads/ads1.c index 84b3808452..51e32b134c 100644 --- a/harbour/contrib/rdd_ads/ads1.c +++ b/harbour/contrib/rdd_ads/ads1.c @@ -51,8 +51,9 @@ */ -#define SUPERTABLE ( &adsSuper ) #define HB_OS_WIN_32_USED +#define HB_SET_IMPORT +#define SUPERTABLE ( &adsSuper ) #define MAX_STR_LEN 255 #include "hbapi.h" @@ -69,6 +70,18 @@ #include +/* + * This code is a workaround for not working HB_IMPORT attribute + * it should not be necessary + */ +#ifndef HB_SET_IMPORT + static HB_SET_STRUCT * s_hb_set_ptr = NULL; +# define hb_set ( * s_hb_set_ptr ) +# define HB_ADS_SET_INIT() do { s_hb_set_ptr = hb_GetSetStructPtr(); } while(0) +#else +# define HB_ADS_SET_INIT() do { } while(0) +#endif + static int s_iSetListenerHandle = 0; static USHORT s_uiRddCount = 0; @@ -92,37 +105,37 @@ static void adsSetListener_callback( HB_set_enum setting, HB_set_listener_enum w switch( setting ) { case HB_SET_DATEFORMAT : - AdsSetDateFormat( (UNSIGNED8*) hb_set.HB_SET_DATEFORMAT ); + AdsSetDateFormat( (UNSIGNED8*) hb_setGetCPtr( HB_SET_DATEFORMAT ) ); break; case HB_SET_DEFAULT : - AdsSetDefault( (UNSIGNED8*) hb_set.HB_SET_DEFAULT ); + AdsSetDefault( (UNSIGNED8*) hb_setGetCPtr( HB_SET_DEFAULT ) ); break; case HB_SET_DELETED : - AdsShowDeleted( ! hb_set.HB_SET_DELETED ); + AdsShowDeleted( ! hb_setGetL( HB_SET_DELETED ) ); break; case HB_SET_EPOCH : - AdsSetEpoch( hb_set.HB_SET_EPOCH ); + AdsSetEpoch( hb_setGetNI( HB_SET_EPOCH ) ); break; case HB_SET_EXACT : - AdsSetExact( hb_set.HB_SET_EXACT ); + AdsSetExact( hb_setGetL( HB_SET_EXACT ) ); break; case HB_SET_PATH : - AdsSetSearchPath( (UNSIGNED8*) hb_set.HB_SET_PATH ); + AdsSetSearchPath( (UNSIGNED8*) hb_setGetCPtr( HB_SET_PATH ) ); break; case HB_SET_DECIMALS : - AdsSetDecimals( (UNSIGNED16) hb_set.HB_SET_DECIMALS ); + AdsSetDecimals( (UNSIGNED16) hb_setGetNI( HB_SET_DECIMALS ) ); break; /* Possible TODO? case HB_SET_MFILEEXT : - if( hb_set.HB_SET_MFILEEXT ) + if( hb_setGetCPtr( HB_SET_MFILEEXT ) ) { - hb_retc( hb_set.HB_SET_MFILEEXT ); + hb_retc( hb_setGetCPtr( HB_SET_MFILEEXT ) ); } break; case HB_SET_STRICTREAD : - hb_retl( hb_set.HB_SET_STRICTREAD ); + hb_retl( hb_setGetL( HB_SET_STRICTREAD ) ); break; */ default: @@ -135,13 +148,13 @@ static void adsSetSend( void ) { HB_TRACE(HB_TR_DEBUG, ("adsSetSend()")); - AdsSetDateFormat( (UNSIGNED8*) hb_set.HB_SET_DATEFORMAT ); - AdsSetDefault( (UNSIGNED8*) hb_set.HB_SET_DEFAULT ); - AdsShowDeleted( ! hb_set.HB_SET_DELETED ); - AdsSetEpoch( hb_set.HB_SET_EPOCH ); - AdsSetExact( hb_set.HB_SET_EXACT ); - AdsSetSearchPath( (UNSIGNED8*) hb_set.HB_SET_PATH ); - AdsSetDecimals( (UNSIGNED16) hb_set.HB_SET_DECIMALS ); + AdsSetDateFormat( (UNSIGNED8*) hb_setGetCPtr( HB_SET_DATEFORMAT ) ); + AdsSetDefault( (UNSIGNED8*) hb_setGetCPtr( HB_SET_DEFAULT ) ); + AdsShowDeleted( ! hb_setGetL( HB_SET_DELETED ) ); + AdsSetEpoch( hb_setGetNI( HB_SET_EPOCH ) ); + AdsSetExact( hb_setGetL( HB_SET_EXACT ) ); + AdsSetSearchPath( (UNSIGNED8*) hb_setGetCPtr( HB_SET_PATH ) ); + AdsSetDecimals( (UNSIGNED16) hb_setGetNI( HB_SET_DECIMALS ) ); } static ERRCODE commonError( ADSAREAP pArea, USHORT uiGenCode, USHORT uiSubCode, @@ -1742,7 +1755,7 @@ static ERRCODE adsFlush( ADSAREAP pArea ) { AdsWriteRecord( pArea->hTable ); #if ADS_REQUIRE_VERSION >= 6 - if( hb_set.HB_SET_HARDCOMMIT ) + if( hb_setGetL( HB_SET_HARDCOMMIT ) ) { AdsFlushFileBuffers( pArea->hTable ); } @@ -2531,7 +2544,7 @@ static ERRCODE adsCreate( ADSAREAP pArea, LPDBOPENINFO pCreateInfo ) uRetVal = AdsCreateTable( hConnection, pCreateInfo->abName, pCreateInfo->atomAlias, pArea->iFileType, adsCharType, adsLockType, adsRights, - hb_set.HB_SET_MBLOCKSIZE, + hb_setGetNL( HB_SET_MBLOCKSIZE ), ucfieldDefs, &hTable ); hb_xfree( ucfieldDefs ); @@ -2969,12 +2982,12 @@ static ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) return FAILURE; } - if( hb_set.HB_SET_AUTORDER ) + if( hb_setGetNI( HB_SET_AUTORDER ) ) { DBORDERINFO pOrderInfo; pOrderInfo.itmResult = hb_itemPutNI( NULL, 0 ); pOrderInfo.itmNewVal = NULL; - pOrderInfo.itmOrder = hb_itemPutNI( NULL, hb_set.HB_SET_AUTORDER ); + pOrderInfo.itmOrder = hb_itemPutNI( NULL, hb_setGetNI( HB_SET_AUTORDER ) ); pOrderInfo.atomBagName = NULL; SELF_ORDLSTFOCUS( ( AREAP ) pArea, &pOrderInfo ); hb_itemRelease( pOrderInfo.itmOrder ); @@ -4093,7 +4106,7 @@ static ERRCODE adsSetFilter( ADSAREAP pArea, LPDBFILTERINFO pFilterInfo ) char * szFilter = hb_adsOemToAnsi( pucFilter, hb_itemGetCLen( pFilterInfo->abFilterText ) ); - if( hb_set.HB_SET_OPTIMIZE ) + if( hb_setGetL( HB_SET_OPTIMIZE ) ) { u32RetVal = AdsSetAOF( pArea->hTable, (UNSIGNED8*) szFilter, usResolve ); } @@ -4701,6 +4714,8 @@ static void hb_adsRddInit( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); + HB_ADS_SET_INIT(); + if( hb_rddRegister( "ADS", RDT_FULL ) > 1 || hb_rddRegister( "ADT", RDT_FULL ) > 1 || hb_rddRegister( "ADSCDX", RDT_FULL ) > 1 || diff --git a/harbour/include/hbdefs.h b/harbour/include/hbdefs.h index 5fe52e0016..49c8d88e77 100644 --- a/harbour/include/hbdefs.h +++ b/harbour/include/hbdefs.h @@ -1155,6 +1155,35 @@ typedef PHB_FUNC HB_FUNC_PTR; #define HB_EXPORT #endif +#if defined( __RSXNT__ ) + /* RSXNT does not support any type of export keyword. + Exported (i.e., public) names can be obtained via + the emxexp utility and the output can be used for + input to a module definition file. See emxdev.doc + in the RSXNT doc/ directory for more information. */ + #define HB_IMPORT + +#elif defined( __GNUC__ ) && defined( HB_OS_WIN_32 ) + #define HB_IMPORT __attribute__ (( dllimport )) + +#elif defined( __BORLANDC__ ) + #define HB_IMPORT _declspec( dllimport ) + +#elif defined( __WATCOMC__ ) + #define HB_IMPORT __declspec( dllimport ) + +#elif defined( ASANLM ) || defined( ASANT ) + #define HB_IMPORT + +#elif defined( WIN32 ) + #define HB_IMPORT _declspec( dllimport ) + +#else + #define HB_IMPORT + +#endif + + /* Function declaration macros */ /* NOTE: The prefix is "HB_FUN_" currently, this is needed to diff --git a/harbour/include/hbset.h b/harbour/include/hbset.h index 1e9ce0cbdc..c9ab854135 100644 --- a/harbour/include/hbset.h +++ b/harbour/include/hbset.h @@ -214,8 +214,6 @@ typedef struct #define HB_SET_DBFLOCK_CL53 2 #define HB_SET_DBFLOCK_VFP 3 -extern HB_SET_STRUCT hb_set; - extern void hb_setInitialize( void ); extern void hb_setRelease( void ); extern HB_PATHNAMES * hb_setGetFirstSetPath( void ); @@ -231,6 +229,18 @@ extern int hb_setListenerAdd( HB_SET_LISTENER_CALLBACK * ); extern void hb_setListenerNotify( HB_set_enum, HB_set_listener_enum ); extern int hb_setListenerRemove( int ); +#if defined( HB_SET_IMPORT ) + extern HB_IMPORT HB_SET_STRUCT hb_set; +#else + extern HB_SET_STRUCT hb_set; +#endif + +/* These macros will be replaced by functions */ +#define hb_setGetCPtr( set ) ( ( char * ) hb_set.set ) +#define hb_setGetNI( set ) ( ( int ) hb_set.set ) +#define hb_setGetNL( set ) ( ( long ) hb_set.set ) +#define hb_setGetL( set ) ( ( BOOL ) hb_set.set ) + HB_EXTERN_END #endif /* HB_SET_H_ */