Hi Viktor,
To avoid ASM the compiler needs to know the call and sizes at compile time.
Too many combinations for a job that may not be perfect and maybe unused.
It's possible to simplify overwriting the stack with struct of byte array more call more choice but I think with some
optimizations will have problems: I really don't like either solution.
Otherwise I think that can be used win64 implement also for win32 with some
modifications.
What do you think of the patch attached (names are irrelevant)?
Also I would suggest copying items parameters inside HB_WINARG to avoid changes
if they are not passed by reference.
Best regards,
Xavi
El 09/02/2010 14:49, Viktor Szakáts escribió:
Hi,
From this point it's users responsibility to
pass parameters properly.
Ok. Next topic: coverage of potential C .dll functions.
IMO it's unworkable cover functions of n parameters with n size,
seems reasonable to restrict to 15 the number of parameters.
This limit already exists, and it should be enough for
a start. Anyway, once the scheme is developed, it will be
easy to extend if it's worth it or required. For vast
majority of cases 15 is enough.
Currently only covering sizes of 4, 8 bytes in win32 and 8 bytes in win64.
This means that calls to PosibleDLLfunc( WORD wPar, BYTE bPar ) are not
possible.
4 and 8 byte parameters are enough for all win32
calling conventions. So it's possible to pass BYTE
already.
How many types of data have to be supported?
win32: 4 or 8 for arguments, return value can be 4, 8 bytes or double/float.
plus each in two variations: cdecl or stdcall (winapi)
win64: 8 for argument, return value is also 8 bytes
BYTE, WORD, DWORD, PVOID, float, double.
For win64 current solution covers all combinations, as
there is a much simpler calling convention there, see:
http://msdn.microsoft.com/en-us/library/ms235286(VS.80).aspx
Brgds,
Viktor
Index: win_dll.c
===================================================================
--- win_dll.c (revision 13835)
+++ win_dll.c (working copy)
@@ -61,7 +61,7 @@
#include "hbapiitm.h"
#include "hbvm.h"
-#if !defined( __CYGWIN__ ) && !defined( HB_NO_ASM )
+#if !defined( __CYGWIN__ )
/* ==================================================================
* DynaCall support comments below
@@ -156,8 +156,14 @@
#pragma pack()
+#define HB_OS_WIN_64_32
+
#if ! defined( HB_OS_WIN_64 )
+# define HB_U64 HB_U32
+#endif
+#if ! defined( HB_OS_WIN_64_32 )
+
static HB_DYNRETVAL hb_DynaCall( int iFlags, FARPROC lpFunction, int nArgs,
HB_DYNPARAM Parm[], void * pRet, int nRetSiz )
{
/* Call the specified function with the given parameters. Build a
@@ -384,7 +390,7 @@
#define _DLLEXEC_MAXPARAM 15
-#if defined( HB_OS_WIN_64 )
+#if defined( HB_OS_WIN_64_32 )
typedef struct
{
@@ -554,7 +560,7 @@
if( iRtype == 0 )
iRtype = CTYPE_UNSIGNED_LONG;
-#if defined( HB_OS_WIN_64 )
+#if defined( HB_OS_WIN_64_32 )
{
HB_WINCALL wcall;
@@ -575,7 +581,7 @@
wcall.pArg = NULL;
for( tmp = 0; tmp < iParams; ++tmp )
- wcall.pArg[ tmp ].bByRef = HB_ISBYREF( iFirst + 1 + tmp );
+ wcall.pArg[ tmp ].bByRef = HB_ISBYREF( iFirst + tmp );
switch( iParams )
{
@@ -601,7 +607,7 @@
{
if( wcall.pArg[ tmp ].bByRef )
{
- switch( HB_ITEM_TYPE( hb_param( iFirst + 1 + tmp, HB_IT_ANY ) )
)
+ switch( HB_ITEM_TYPE( hb_param( iFirst + tmp, HB_IT_ANY ) ) )
{
case HB_IT_LOGICAL:
hb_storl( wcall.pArg[ tmp ].nValue != 0, tmp );
@@ -900,7 +906,7 @@
if( pbUNICODE )
*pbUNICODE = HB_FALSE;
-#if defined( HB_OS_WIN_64 ) /* TOFIX: Remove this when UNICODE support gets
implemented for non-Win64. */
+#if defined( HB_OS_WIN_64_32 ) /* TOFIX: Remove this when UNICODE support gets
implemented for non-Win64. */
#if defined( UNICODE )
if( ! lpFunction && szProc ) /* try with WIDE suffix? */
{
@@ -1074,4 +1080,4 @@
hb_DllExec( DC_CALL_STDCALL, hb_parni( 2 ), ( FARPROC ) hb_parptr( 1 ),
NULL, hb_pcount(), 3 );
}
-#endif /* HB_OS_WIN && && !__CYGWIN__ !HB_NO_ASM */
+#endif /* HB_OS_WIN && && !__CYGWIN__ */
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour