From 314c5e850dc999e9a7e796274b3025c202e4db2a Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Sun, 22 Jun 2008 19:07:01 +0000 Subject: [PATCH] 2008-06-22 21:03 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbsetup.h + Added HB_OS_WIN_64 macro to replace _WIN64. [TOMERGE 1.0.0RC1] * contrib/hbwhat32/_winsys.c * contrib/hbwhat32/_winsock.c * contrib/hbwhat32/_wincall.c * contrib/gtwvg/wvtutils.c ! Fixed WIN64 compile errors. [TOMERGE 1.0.0RC1] * contrib/hbw32/dllcall.c * contrib/hbw32/w32_ole.c * _WIN64 -> HB_OS_WIN_64 [TOMERGE 1.0.0RC1] --- harbour/ChangeLog | 20 ++- harbour/contrib/gtwvg/wvtutils.c | 2 +- harbour/contrib/hbw32/dllcall.c | 2 +- harbour/contrib/hbw32/w32_ole.c | 2 +- harbour/contrib/hbwhat32/_wincall.c | 203 +++++++++++++++------------- harbour/contrib/hbwhat32/_winsock.c | 5 +- harbour/contrib/hbwhat32/_winsys.c | 13 +- harbour/include/hbsetup.h | 6 + 8 files changed, 146 insertions(+), 107 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f322e6ffc5..efde267d67 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,11 +8,29 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-22 21:03 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * include/hbsetup.h + + Added HB_OS_WIN_64 macro to replace _WIN64. + [TOMERGE 1.0.0RC1] + + * contrib/hbwhat32/_winsys.c + * contrib/hbwhat32/_winsock.c + * contrib/hbwhat32/_wincall.c + * contrib/gtwvg/wvtutils.c + ! Fixed WIN64 compile errors. + [TOMERGE 1.0.0RC1] + + * contrib/hbw32/dllcall.c + * contrib/hbw32/w32_ole.c + * _WIN64 -> HB_OS_WIN_64 + [TOMERGE 1.0.0RC1] + 2008-06-22 13:19 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * contrib/hbcurl/hbcurl.c + Code cleanup for 64bit. Only calls to Harbour APIs are generating warnings now. (hb_xgrab, hb_xrealloc, - hb_fsWriteLarge, hb_fsReadLarge, hb_retclen, hb_storlen) + hb_fsWriteLarge, hb_fsReadLarge, hb_retclen, hb_storclen) + [TOMERGE 1.0.0RC1] 2008-06-22 12:24 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * contrib/hbw32ddr/w32_ddrw.cpp diff --git a/harbour/contrib/gtwvg/wvtutils.c b/harbour/contrib/gtwvg/wvtutils.c index 3827853bf7..f9c2898e2e 100644 --- a/harbour/contrib/gtwvg/wvtutils.c +++ b/harbour/contrib/gtwvg/wvtutils.c @@ -600,7 +600,7 @@ HB_FUNC( WVT_SETPOINTER ) break; } - SetClassLong( _s->hWnd, GCL_HCURSOR, ( DWORD ) hCursor ); + SetClassLong( _s->hWnd, GCLP_HCURSOR, ( DWORD ) hCursor ); } //-------------------------------------------------------------------// diff --git a/harbour/contrib/hbw32/dllcall.c b/harbour/contrib/hbw32/dllcall.c index 528fddc73c..73bb86285a 100644 --- a/harbour/contrib/hbw32/dllcall.c +++ b/harbour/contrib/hbw32/dllcall.c @@ -239,7 +239,7 @@ RESULT DynaCall( int iFlags, LPVOID lpFunction, int nArgs, /* Call the specified function with the given parameters. Build a proper stack and take care of correct return value processing. */ RESULT Res = { 0 }; -#if defined(HB_WINCE) || defined(_WIN64) +#if defined(HB_WINCE) || defined(HB_OS_WIN_64) HB_SYMBOL_UNUSED( iFlags ); HB_SYMBOL_UNUSED( lpFunction ); HB_SYMBOL_UNUSED( nArgs ); diff --git a/harbour/contrib/hbw32/w32_ole.c b/harbour/contrib/hbw32/w32_ole.c index 80020967e7..d60855472f 100644 --- a/harbour/contrib/hbw32/w32_ole.c +++ b/harbour/contrib/hbw32/w32_ole.c @@ -91,7 +91,7 @@ #define HB_LONG_LONG_OFF #endif -#if defined( __cplusplus ) && !defined( _WIN64 ) && \ +#if defined( __cplusplus ) && !defined( HB_OS_WIN_64 ) && \ ( defined( __BORLANDC__ ) || defined( _MSC_VER ) ) # define HB_ID_REF( type, id ) id #else diff --git a/harbour/contrib/hbwhat32/_wincall.c b/harbour/contrib/hbwhat32/_wincall.c index e5dc8d2203..8b7e71a94e 100644 --- a/harbour/contrib/hbwhat32/_wincall.c +++ b/harbour/contrib/hbwhat32/_wincall.c @@ -57,14 +57,6 @@ linking the VMGUI library code into it. #ifndef __MINGW32__ -//------------------------------------------------------------------ -#include -//#include -#define WIN32_LEAN_AND_MEAN -//#include -//#include "dynacall.h" -//------------------------------------------------------------------ - #define DC_MICROSOFT 0x0000 // Default #define DC_BORLAND 0x0001 // Borland compat #define DC_CALL_CDECL 0x0010 // __cdecl @@ -80,22 +72,25 @@ linking the VMGUI library code into it. #pragma pack(1) -typedef union RESULT { // Various result types - int Int; // Generic four-byte type - long Long; // Four-byte long - void *Pointer; // 32-bit pointer - float Float; // Four byte real - double Double; // 8-byte real - __int64 int64; // big int (64-bit) +typedef union RESULT +{ // Various result types + int Int; // Generic four-byte type + long Long; // Four-byte long + void *Pointer; // 32-bit pointer + float Float; // Four byte real + double Double; // 8-byte real + __int64 int64; // big int (64-bit) } RESULT; -typedef struct DYNAPARM { - DWORD dwFlags; // Parameter flags - int nWidth; // Byte width - union { // - DWORD dwArg; // 4-byte argument - void *pArg; // Pointer to argument - }; +typedef struct DYNAPARM +{ + DWORD dwFlags; // Parameter flags + int nWidth; // Byte width + union + { + DWORD dwArg; // 4-byte argument + void *pArg; // Pointer to argument + }; } DYNAPARM; #pragma pack() @@ -107,84 +102,104 @@ RESULT DynaCall(int Flags, DWORD lpFunction, int nArgs, DYNAPARM Parm[], LPVOID pRet, int nRetSiz) { - // Call the specified function with the given parameters. Build a - // proper stack and take care of correct return value processing. - RESULT Res = { 0 }; - int i, nInd, nSize; - DWORD dwEAX, dwEDX, dwVal, *pStack, dwStSize = 0; - BYTE *pArg; + RESULT Res = { 0 }; +#if defined(HB_WINCE) || defined(HB_OS_WIN_64) + HB_SYMBOL_UNUSED( Flags ); + HB_SYMBOL_UNUSED( lpFunction ); + HB_SYMBOL_UNUSED( nArgs ); + HB_SYMBOL_UNUSED( Parm ); + HB_SYMBOL_UNUSED( pRet ); + HB_SYMBOL_UNUSED( nRetSiz ); +#else + // Call the specified function with the given parameters. Build a + // proper stack and take care of correct return value processing. + int i, nInd, nSize; + DWORD dwEAX, dwEDX, dwVal, *pStack, dwStSize = 0; + BYTE *pArg; - // Reserve 256 bytes of stack space for our arguments - _asm mov pStack, esp - _asm sub esp, 0x100 + // Reserve 256 bytes of stack space for our arguments + _asm mov pStack, esp + _asm sub esp, 0x100 - // Push args onto the stack. Every argument is aligned on a - // 4-byte boundary. We start at the rightmost argument. - for (i = 0; i < nArgs; i++) { - nInd = (nArgs - 1) - i; - // Start at the back of the arg ptr, aligned on a DWORD - nSize = (Parm[nInd].nWidth + 3) / 4 * 4; - pArg = (BYTE *)Parm[nInd].pArg + nSize - 4; - dwStSize += (DWORD)nSize; // Count no of bytes on stack - while (nSize > 0) { - // Copy argument to the stack - if (Parm[nInd].dwFlags & DC_FLAG_ARGPTR) { - // Arg has a ptr to a variable that has the arg - dwVal = *(DWORD *)pArg; // Get first four bytes - pArg -= 4; // Next part of argument - } - else { - // Arg has the real arg - dwVal = Parm[nInd].dwArg; - } - // Do push dwVal - pStack--; // ESP = ESP - 4 - *pStack = dwVal; // SS:[ESP] = dwVal - nSize -= 4; - } - } - if ((pRet != NULL) && ((Flags & DC_BORLAND) || (nRetSiz > 8))) { - // Return value isn't passed through registers, memory copy - // is performed instead. Pass the pointer as hidden arg. - dwStSize += 4; // Add stack size - pStack--; // ESP = ESP - 4 - *pStack = (DWORD)pRet; // SS:[ESP] = pMem - } + // Push args onto the stack. Every argument is aligned on a + // 4-byte boundary. We start at the rightmost argument. + for(i = 0; i < nArgs; i++) + { + nInd = (nArgs - 1) - i; + // Start at the back of the arg ptr, aligned on a DWORD + nSize = (Parm[nInd].nWidth + 3) / 4 * 4; + pArg = (BYTE *)Parm[nInd].pArg + nSize - 4; + dwStSize += (DWORD)nSize; // Count no of bytes on stack + while (nSize > 0) + { + // Copy argument to the stack + if (Parm[nInd].dwFlags & DC_FLAG_ARGPTR) + { + // Arg has a ptr to a variable that has the arg + dwVal = *(DWORD *)pArg; // Get first four bytes + pArg -= 4; // Next part of argument + } + else + { + // Arg has the real arg + dwVal = Parm[nInd].dwArg; + } + // Do push dwVal + pStack--; // ESP = ESP - 4 + *pStack = dwVal; // SS:[ESP] = dwVal + nSize -= 4; + } + } - _asm add esp, 0x100 // Restore to original position - _asm sub esp, dwStSize // Adjust for our new parameters + if((pRet != NULL) && ((Flags & DC_BORLAND) || (nRetSiz > 8))) + { + // Return value isn't passed through registers, memory copy + // is performed instead. Pass the pointer as hidden arg. + dwStSize += 4; // Add stack size + pStack--; // ESP = ESP - 4 + *pStack = (DWORD)pRet; // SS:[ESP] = pMem + } - // Stack is now properly built, we can call the function - _asm call [lpFunction] + _asm add esp, 0x100 // Restore to original position + _asm sub esp, dwStSize // Adjust for our new parameters - _asm mov dwEAX, eax // Save eax/edx registers - _asm mov dwEDX, edx // + // Stack is now properly built, we can call the function + _asm call [lpFunction] - // Possibly adjust stack and read return values. - if (Flags & DC_CALL_CDECL) { - _asm add esp, dwStSize - } - if (Flags & DC_RETVAL_MATH4) { - _asm fstp dword ptr [Res] - } - else if (Flags & DC_RETVAL_MATH8) { - _asm fstp qword ptr [Res] - } - else if (pRet == NULL) { - _asm mov eax, [dwEAX] - _asm mov DWORD PTR [Res], eax - _asm mov edx, [dwEDX] - _asm mov DWORD PTR [Res + 4], edx - } - else if (((Flags & DC_BORLAND) == 0) && (nRetSiz <= 8)) { - // Microsoft optimized less than 8-bytes structure passing - _asm mov ecx, DWORD PTR [pRet] - _asm mov eax, [dwEAX] - _asm mov DWORD PTR [ecx], eax - _asm mov edx, [dwEDX] - _asm mov DWORD PTR [ecx + 4], edx - } - return Res; + _asm mov dwEAX, eax // Save eax/edx registers + _asm mov dwEDX, edx // + + // Possibly adjust stack and read return values. + if (Flags & DC_CALL_CDECL) + { + _asm add esp, dwStSize + } + if (Flags & DC_RETVAL_MATH4) + { + _asm fstp dword ptr [Res] + } + else if (Flags & DC_RETVAL_MATH8) + { + _asm fstp qword ptr [Res] + } + else if (pRet == NULL) + { + _asm mov eax, [dwEAX] + _asm mov DWORD PTR [Res], eax + _asm mov edx, [dwEDX] + _asm mov DWORD PTR [Res + 4], edx + } + else if (((Flags & DC_BORLAND) == 0) && (nRetSiz <= 8)) + { + // Microsoft optimized less than 8-bytes structure passing + _asm mov ecx, DWORD PTR [pRet] + _asm mov eax, [dwEAX] + _asm mov DWORD PTR [ecx], eax + _asm mov edx, [dwEDX] + _asm mov DWORD PTR [ecx + 4], edx + } +#endif + return Res; } #endif diff --git a/harbour/contrib/hbwhat32/_winsock.c b/harbour/contrib/hbwhat32/_winsock.c index 5eb14b7514..5dbb524fe9 100644 --- a/harbour/contrib/hbwhat32/_winsock.c +++ b/harbour/contrib/hbwhat32/_winsock.c @@ -755,7 +755,7 @@ HB_FUNC( WSAASYNCSELECT ) int _stdcall _WSACondFunc( LPWSABUF lpCallerId, LPWSABUF lpCallerData, LPQOS lpSQOS, LPQOS lpGQOS, LPWSABUF lpCalleeId, LPWSABUF lpCalleeData, - GROUP * g, DWORD dwCallbackData ) + GROUP * g, DWORD_PTR dwCallbackData ) { int res = CF_ACCEPT ; @@ -777,8 +777,7 @@ int _stdcall _WSACondFunc( LPWSABUF lpCallerId, LPWSABUF lpCallerData, LPQOS lp res = hb_itemGetNI( (PHB_ITEM) hb_param( -1, HB_IT_ANY ) ); } - return res ; - + return res; } diff --git a/harbour/contrib/hbwhat32/_winsys.c b/harbour/contrib/hbwhat32/_winsys.c index c7300f1d3f..806e3fbdf1 100644 --- a/harbour/contrib/hbwhat32/_winsys.c +++ b/harbour/contrib/hbwhat32/_winsys.c @@ -1056,13 +1056,14 @@ NOTE: This function is not supported and returns .F. under Windows 9x */ HB_FUNC( GETPROCESSWORKINGSETSIZE ) { - DWORD MinimumWorkingSetSize=0; - DWORD MaximumWorkingSetSize=0; + PSIZE_T MinimumWorkingSetSize = NULL; + PSIZE_T MaximumWorkingSetSize = NULL; hb_retl(GetProcessWorkingSetSize(ISNIL(1) ? GetCurrentProcess() : (HANDLE) hb_parnl( 1 ), - &MinimumWorkingSetSize, &MaximumWorkingSetSize )); - hb_stornl(MinimumWorkingSetSize,2); - hb_stornl(MaximumWorkingSetSize,3); + MinimumWorkingSetSize, MaximumWorkingSetSize )); + + hb_stornl( MinimumWorkingSetSize ? ( long ) *MinimumWorkingSetSize : 0, 2 ); + hb_stornl( MaximumWorkingSetSize ? ( long ) *MaximumWorkingSetSize : 0, 3 ); } //-------------------------------------------------------------------// @@ -1085,7 +1086,7 @@ DWORD VirtualQuery( LPCVOID lpAddress, PMEMORY_BASIC_INFORMATION lpBuffer, SIZE */ HB_FUNC( VIRTUALQUERY ) { - if (hb_parni(1) >= sizeof(MEMORY_BASIC_INFORMATION)) + if( hb_parni(1) >= sizeof(MEMORY_BASIC_INFORMATION) ) { hb_retl(VirtualQuery((void *) hb_parnl(1), (struct _MEMORY_BASIC_INFORMATION *) hb_parnl(2), sizeof(MEMORY_BASIC_INFORMATION))); } diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index a8681391e2..60f2f1c8ea 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -283,6 +283,12 @@ #endif #endif +#ifndef HB_OS_WIN_64 + #if defined(_WIN64) + #define HB_OS_WIN_64 + #endif +#endif + #if !defined(HB_WINCE) && \ ( defined(_WINCE) || defined(__CEGCC__) || defined(__MINGW32CE__) ) #define HB_WINCE