From 327a1b5b5a64458f03530e2988a28c6996b77a03 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 27 May 2009 02:46:49 +0000 Subject: [PATCH] 2009-05-27 04:42 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbsetup.h * source/common/hbver.c + Moved CPU detection to core header. Introduced HB_CPU_* macros. Now they can be used to branch code by CPU type. * contrib/rddads/adsmgmnt.c + Added my copyright. * contrib/hbwin/wapi_commctrl.c * contrib/hbwin/wapi_winbase.c * contrib/hbwin/wapi_winuser.c ! Fixed remaining hb_parc() vs hb_parcx() usages. % WAPI_TABCTRL_CREATE() further simplified. Please review, it may be wrong. * utils/hbmk2/hbmk2.prg * Minor internal change. --- harbour/ChangeLog | 20 ++++ harbour/contrib/hbwin/wapi_commctrl.c | 12 +- harbour/contrib/hbwin/wapi_winbase.c | 2 +- harbour/contrib/hbwin/wapi_winuser.c | 2 +- harbour/contrib/rddads/adsmgmnt.c | 13 ++- harbour/include/hbsetup.h | 118 ++++++++++++++++++++ harbour/source/common/hbver.c | 155 ++++++-------------------- harbour/utils/hbmk2/hbmk2.prg | 30 +++-- 8 files changed, 209 insertions(+), 143 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4e51d91e43..f486abdb82 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,26 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-27 04:42 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * include/hbsetup.h + * source/common/hbver.c + + Moved CPU detection to core header. Introduced + HB_CPU_* macros. Now they can be used to branch code + by CPU type. + + * contrib/rddads/adsmgmnt.c + + Added my copyright. + + * contrib/hbwin/wapi_commctrl.c + * contrib/hbwin/wapi_winbase.c + * contrib/hbwin/wapi_winuser.c + ! Fixed remaining hb_parc() vs hb_parcx() usages. + % WAPI_TABCTRL_CREATE() further simplified. + Please review, it may be wrong. + + * utils/hbmk2/hbmk2.prg + * Minor internal change. + 2009-05-27 03:33 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * contrib/hbqt/generator/hbqtgen.prg * contrib/gtqtc/tests/demoqtc.prg diff --git a/harbour/contrib/hbwin/wapi_commctrl.c b/harbour/contrib/hbwin/wapi_commctrl.c index 4c7d3cc4ba..efbb40d09f 100644 --- a/harbour/contrib/hbwin/wapi_commctrl.c +++ b/harbour/contrib/hbwin/wapi_commctrl.c @@ -471,7 +471,7 @@ HB_FUNC( WAPI_IMAGELIST_WRITEEX ) HB_FUNC( WAPI_TABCTRL_INSERTITEM ) { TC_ITEM item; - LPTSTR szText = HB_TCHAR_CONVTO( hb_parc( 3 ) ); + LPTSTR szText = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); item.mask = TCIF_TEXT | TCIF_IMAGE; item.iImage = ISNUM( 4 ) ? wapi_par_INT( 4 ) : -1; @@ -554,7 +554,7 @@ HB_FUNC( WAPI_TABCTRL_SETIMAGELIST ) HB_FUNC( WAPI_TABCTRL_SETITEM ) { TC_ITEM item; - LPTSTR szText = HB_TCHAR_CONVTO( hb_parc( 3 ) ); + LPTSTR szText = HB_TCHAR_CONVTO( hb_parcx( 3 ) ); item.mask = TCIF_TEXT | TCIF_IMAGE; item.iImage = ISNUM( 4 ) ? wapi_par_INT( 4 ) : -1; @@ -763,10 +763,8 @@ HB_FUNC( WAPI_TABCTRL_GETUNICODEFORMAT ) HB_FUNC( WAPI_TABCTRL_CREATE ) { HWND hwnd = ( HWND ) wapi_par_HWND( 1 ); - LONG style = ( LONG ) hb_parnl( 6 ); /* defaults to 0 */ - HFONT hFont = ( HFONT ) SendMessage( hwnd, WM_GETFONT, 0, 0 ); - HWND hbutton = CreateWindowEx( 0, WC_TABCONTROL, NULL, style, hb_parni( 2 ), hb_parni( 3 ) , hb_parni( 4 ), hb_parni( 5 ), hwnd, NULL, GetModuleHandle( NULL ), NULL ); - SendMessage( hbutton, ( UINT ) WM_SETFONT, ( WPARAM ) hFont, 1 ); + HWND hbutton = CreateWindowEx( 0, WC_TABCONTROL, NULL, ( LONG ) hb_parnl( 6 ) /* style */, hb_parni( 2 ), hb_parni( 3 ) , hb_parni( 4 ), hb_parni( 5 ), hwnd, NULL, GetModuleHandle( NULL ), NULL ); + SendMessage( hbutton, ( UINT ) WM_SETFONT, ( WPARAM ) ( HFONT ) SendMessage( hwnd, WM_GETFONT, 0, 0 ), 1 ); wapi_ret_HANDLE( hbutton ); } @@ -776,7 +774,7 @@ HB_FUNC( WAPI_TABCTRL_CREATE ) HB_FUNC( WAPI_TABCTRL_ADDITEM ) { int iCount = TabCtrl_GetItemCount( wapi_par_HWND( 1 ) ); - LPTSTR szText = HB_TCHAR_CONVTO( hb_parc( 2 ) ); + LPTSTR szText = HB_TCHAR_CONVTO( hb_parcx( 2 ) ); TC_ITEM item; item.mask = TCIF_TEXT | TCIF_IMAGE; diff --git a/harbour/contrib/hbwin/wapi_winbase.c b/harbour/contrib/hbwin/wapi_winbase.c index 58c9e47740..38bb9cec45 100644 --- a/harbour/contrib/hbwin/wapi_winbase.c +++ b/harbour/contrib/hbwin/wapi_winbase.c @@ -116,6 +116,6 @@ HB_FUNC( WAPI_GETMODULEHANDLE ) wapi_ret_HANDLE( GetModuleHandle( lpModuleName ) ); - if( ISCHAR( 1 ) ) + if( lpModuleName ) HB_TCHAR_FREE( lpModuleName ); } diff --git a/harbour/contrib/hbwin/wapi_winuser.c b/harbour/contrib/hbwin/wapi_winuser.c index f43cf322d5..e14043dbbc 100644 --- a/harbour/contrib/hbwin/wapi_winuser.c +++ b/harbour/contrib/hbwin/wapi_winuser.c @@ -272,7 +272,7 @@ HB_FUNC( WAPI_LOADBITMAP ) if( ISNUM( 2 ) ) lpBmp = ( LPTSTR ) MAKEINTRESOURCE( wapi_par_INT( 2 ) ); else - lpBmp = ( LPTSTR ) HB_TCHAR_CONVTO( hb_parc( 2 ) ); + lpBmp = ( LPTSTR ) HB_TCHAR_CONVTO( hb_parcx( 2 ) ); hbmp = LoadBitmap( hinst, lpBmp ); if( hbmp ) diff --git a/harbour/contrib/rddads/adsmgmnt.c b/harbour/contrib/rddads/adsmgmnt.c index 461dd38381..da2a88453c 100644 --- a/harbour/contrib/rddads/adsmgmnt.c +++ b/harbour/contrib/rddads/adsmgmnt.c @@ -6,6 +6,7 @@ * Harbour Project source code: * Advantage Database Server RDD (Management functions) * + * Copyright 2008 Viktor Szakats * Copyright 2001 Brian Hays * www - http://www.harbour-project.org * @@ -61,9 +62,9 @@ static ADSHANDLE s_hMgmtHandle = 0; HB_FUNC( ADSMGCONNECT ) { - hb_retnl( AdsMgConnect( ( UNSIGNED8 * ) hb_parcx( 1 ) /* pucServerName */, - ( UNSIGNED8 * ) hb_parc( 2 ) /* pucUserName */, - ( UNSIGNED8 * ) hb_parc( 3 ) /* pucPassword */, + hb_retnl( AdsMgConnect( ( UNSIGNED8 * ) hb_parcx( 1 ) /* pucServerName */, + ( UNSIGNED8 * ) hb_parc( 2 ) /* pucUserName */, + ( UNSIGNED8 * ) hb_parc( 3 ) /* pucPassword */, &s_hMgmtHandle ) ); } @@ -97,7 +98,7 @@ HB_FUNC( ADSMGGETSERVERTYPE ) { UNSIGNED16 usServerType = 0; - hb_retnl( AdsMgGetServerType( s_hMgmtHandle, + hb_retnl( AdsMgGetServerType( s_hMgmtHandle, &usServerType ) == AE_SUCCESS ? usServerType : 0 ); } @@ -430,7 +431,7 @@ HB_FUNC( ADSMGGETUSERNAMES ) * [3] Login user name for data dictionary connections (ADS 6.0 and above) * [4] Client machine IP address (ADS 6.0 and above) * [5] lock type ADS_MGMT_NO_LOCK ADS_MGMT_RECORD_LOCK ADS_MGMT_FILE_LOCK - * + * * returns the advantage error code if it fails. */ HB_FUNC( ADSMGGETLOCKOWNER ) @@ -469,7 +470,7 @@ HB_FUNC( ADSMGGETLOCKOWNER ) #endif } -/* NOTE: For a newer edition of this function, which also returns locktype +/* NOTE: For a newer edition of this function, which also returns locktype info, see ADSMGGETOPENTABLES2(). */ HB_FUNC( ADSMGGETOPENTABLES ) /* nMaxNumberOfFilesToReturn, cUserName, nConnection */ { diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index fbcba540ea..14cc48a81f 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -6,6 +6,7 @@ * Harbour Project source code: * Header file for compiler and runtime configuration * + * Copyright 2000-2009 Viktor Szakats * Copyright 1999 Ryszard Glab * www - http://www.harbour-project.org * @@ -344,6 +345,123 @@ #endif #endif +/* *********************************************************************** + * CPU detection + */ + +/* Partially based on: + http://predef.sourceforge.net/prearch.html + http://poshlib.hookatooka.com/poshlib/trac.cgi/browser/posh.h + */ + +#if defined(__alpha__) || \ + defined(__alpha) || \ + defined(alpha) || \ + defined(_M_ALPHA) + #define HB_CPU_ALPHA + +#elif defined(__amd64__) || \ + defined(__amd64) || \ + defined(__x86_64__) || \ + defined(__x86_64) || \ + defined(_M_AMD64) || \ + defined(_M_X64) || \ + defined(__MINGW64__) + #define HB_CPU_X86_64 + +#elif defined(__arm__) || \ + defined(ARM) || \ + defined(_ARM) || \ + defined(_M_ARM) + #define HB_CPU_ARM + +#elif defined(__hppa__) || \ + defined(__hppa) || \ + defined(hppa) + #define HB_CPU_PARISC + +#elif defined(i386) || \ + defined(__i386__) || \ + defined(__i386) || \ + defined(_M_IX86) || \ + defined(__X86__) || \ + defined(_X86_) || \ + defined(__I86__) || \ + defined(__THW_INTEL__) || \ + defined(__INTEL__) + #define HB_CPU_X86 + +#elif defined(__ia64__) || \ + defined(__ia64) || \ + defined(_IA64) || \ + defined(__IA64__) || \ + defined(_M_IA64) + #define HB_CPU_IA_64 + +#elif defined(__m68k__) || \ + defined(M68000) + #define HB_CPU_M68K + +#elif defined(__mips__) || \ + defined(__mips) || \ + defined(__MIPS__) || \ + defined(mips) || \ + defined(_MIPS) || \ + defined(__MIPS__) || \ + defined(_M_MRX000) || \ + defined(_M_MIPS) + #define HB_CPU_MIPS + +#elif defined(__powerpc64__) + #define HB_CPU_PPC_64 + +#elif defined(__powerpc__) || \ + defined(__powerpc) || \ + defined(__POWERPC__) || \ + defined(__ppc__) || \ + defined(__PPC__) || \ + defined(_ARCH_PPC) || \ + defined(_M_MPPC) || \ + defined(_M_PPC) + #define HB_CPU_PPC + +#elif defined(__THW_RS6000) || \ + defined(_IBMR2) || \ + defined(_POWER) || \ + defined(_ARCH_PWR) || \ + defined(_ARCH_PWR2) + #define HB_CPU_POWER + +#elif defined(__sparc__) || \ + defined(__sparc) + #if defined(__arch64__) || \ + defined(__sparcv9) || \ + defined(__sparc_v9__) + #define HB_CPU_SPARC_64 + #else + #define HB_CPU_SPARC + #endif + +#elif defined(__sh__) || \ + defined(_SH3) || \ + defined(__sh4__) || \ + defined(__SH4__) || \ + defined(_M_SH) + #define HB_CPU_SUPERH + +#elif defined(__370__) || \ + defined(__THW_370__) + #define HB_CPU_SYS370 + +#elif defined(__s390__) || \ + defined(__s390x__) + #define HB_CPU_SYS390 + +#elif defined(__SYSC_ZARCH__) + #define HB_CPU_ZARCH + +#endif + /* *********************************************************************** * Here you can force the EOL string to be CRLF * diff --git a/harbour/source/common/hbver.c b/harbour/source/common/hbver.c index 4bdaeee8af..50da74a2fa 100644 --- a/harbour/source/common/hbver.c +++ b/harbour/source/common/hbver.c @@ -94,128 +94,47 @@ #endif -/* Partially based on: - http://predef.sourceforge.net/prearch.html - http://poshlib.hookatooka.com/poshlib/trac.cgi/browser/posh.h - */ - -#if defined(__alpha__) || \ - defined(__alpha) || \ - defined(alpha) || \ - defined(_M_ALPHA) - #define HB_CPU_STR "Alpha" - -#elif defined(__amd64__) || \ - defined(__amd64) || \ - defined(__x86_64__) || \ - defined(__x86_64) || \ - defined(_M_AMD64) || \ - defined(_M_X64) || \ - defined(__MINGW64__) - #define HB_CPU_STR "x86-64" - -#elif defined(__arm__) || \ - defined(ARM) || \ - defined(_ARM) || \ - defined(_M_ARM) - #define HB_CPU_STR "ARM" - -#elif defined(__hppa__) || \ - defined(__hppa) || \ - defined(hppa) - #define HB_CPU_STR "PA-RISC" - -#elif defined(i386) || \ - defined(__i386__) || \ - defined(__i386) || \ - defined(_M_IX86) || \ - defined(__X86__) || \ - defined(_X86_) || \ - defined(__I86__) || \ - defined(__THW_INTEL__) || \ - defined(__INTEL__) - #define HB_CPU_STR "x86" - -#elif defined(__ia64__) || \ - defined(__ia64) || \ - defined(_IA64) || \ - defined(__IA64__) || \ - defined(_M_IA64) - #define HB_CPU_STR "IA-64" - -#elif defined(__m68k__) || \ - defined(M68000) - #define HB_CPU_STR "m68k" - -#elif defined(__mips__) || \ - defined(__mips) || \ - defined(__MIPS__) || \ - defined(mips) || \ - defined(_MIPS) || \ - defined(__MIPS__) || \ - defined(_M_MRX000) || \ - defined(_M_MIPS) - #define HB_CPU_STR "MIPS" - -#elif defined(__powerpc64__) - #define HB_CPU_STR "PPC64" - -#elif defined(__powerpc__) || \ - defined(__powerpc) || \ - defined(__POWERPC__) || \ - defined(__ppc__) || \ - defined(__PPC__) || \ - defined(_ARCH_PPC) || \ - defined(_M_MPPC) || \ - defined(_M_PPC) - #define HB_CPU_STR "PPC" - -#elif defined(__THW_RS6000) || \ - defined(_IBMR2) || \ - defined(_POWER) || \ - defined(_ARCH_PWR) || \ - defined(_ARCH_PWR2) - #define HB_CPU_STR "POWER" - -#elif defined(__sparc__) || \ - defined(__sparc) - #if defined(__arch64__) || \ - defined(__sparcv9) || \ - defined(__sparc_v9__) - #define HB_CPU_STR "Sparc/64" - #else - #define HB_CPU_STR "Sparc/32" - #endif - -#elif defined(__sh__) || \ - defined(_SH3) || \ - defined(__sh4__) || \ - defined(__SH4__) || \ - defined(_M_SH) - #define HB_CPU_STR "SuperH" - -#elif defined(__370__) || \ - defined(__THW_370__) - #define HB_CPU_STR "System/370" - -#elif defined(__s390__) || \ - defined(__s390x__) - #define HB_CPU_STR "System/390" - -#elif defined(__SYSC_ZARCH__) - #define HB_CPU_STR "z/Architecture" - -#endif - -#ifndef HB_CPU_STR - #define HB_CPU_STR "(unknown)" -#endif - const char * hb_verCPU( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_verCPU()")); - return HB_CPU_STR; +#if defined( HB_CPU_X86 ) + return "x86"; +#elif defined( HB_CPU_X86_64 ) + return "x86-64"; +#elif defined( HB_CPU_IA_64 ) + return "IA-64"; +#elif defined( HB_CPU_PPC ) + return "PPC"; +#elif defined( HB_CPU_PPC_64 ) + return "PPC64"; +#elif defined( HB_CPU_SPARC ) + return "Sparc/32"; +#elif defined( HB_CPU_SPARC_64 ) + return "Sparc/64"; +#elif defined( HB_CPU_ARM ) + return "ARM"; +#elif defined( HB_CPU_MIPS ) + return "MIPS"; +#elif defined( HB_CPU_SUPERH ) + return "SuperH"; +#elif defined( HB_CPU_ZARCH ) + return "z/Architecture"; +#elif defined( HB_CPU_PARISC ) + return "PA-RISC"; +#elif defined( HB_CPU_ALPHA ) + return "Alpha"; +#elif defined( HB_CPU_POWER ) + return "POWER"; +#elif defined( HB_CPU_M68K ) + return "m68k"; +#elif defined( HB_CPU_SYS370 ) + return "System/370"; +#elif defined( HB_CPU_SYS390 ) + return "System/390"; +#else + return "(unknown)"; +#endif } const char * hb_verHostCPU( void ) diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index e9d91175ff..52f37b631e 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -3768,6 +3768,7 @@ STATIC FUNCTION FindNewerHeaders( hbmk, cFileName, cParentDir, tTimeParent, lInc LOCAL tmp LOCAL cNameExtL LOCAL cExt + LOCAL cHeader STATIC s_aExcl := { "windows.h", "ole2.h", "os2.h" } @@ -3845,18 +3846,27 @@ STATIC FUNCTION FindNewerHeaders( hbmk, cFileName, cParentDir, tTimeParent, lInc FClose( fhnd ) ENDIF + cHeader := NIL nPos := 1 - DO WHILE ( tmp := hb_At( '#include "', cFile, nPos ) ) > 0 - nPos := tmp + Len( '#include "' ) - IF ( tmp := hb_At( '"', cFile, nPos ) ) > 0 - IF FindNewerHeaders( hbmk, SubStr( cFile, nPos, tmp - nPos ),; - iif( lCMode, FN_DirGet( cFileName ), cParentDir ), tTimeParent, lIncTry, lCMode, @headstate, nEmbedLevel + 1 ) - headstate[ _HEADSTATE_lAnyNewer ] := .T. - /* Let it continue if we want to scan for header locations */ - IF ! lIncTry - RETURN .T. - ENDIF + DO WHILE .T. + + IF ( tmp := hb_At( '#include "', cFile, nPos ) ) > 0 + nPos := tmp + Len( '#include "' ) + IF ( tmp := hb_At( '"', cFile, nPos ) ) > 0 + cHeader := SubStr( cFile, nPos, tmp - nPos ) ENDIF + ELSE + EXIT + ENDIF + + IF cHeader != NIL .AND. ; + FindNewerHeaders( hbmk, cHeader, iif( lCMode, FN_DirGet( cFileName ), cParentDir ), tTimeParent, lIncTry, lCMode, @headstate, nEmbedLevel + 1 ) + headstate[ _HEADSTATE_lAnyNewer ] := .T. + /* Let it continue if we want to scan for header locations */ + IF ! lIncTry + RETURN .T. + ENDIF + cHeader := NIL ENDIF ENDDO