Alexandre Julliard : include: Make CLIENT_CALL_RETURN definition platform-specific to handle the return type incompatibility in NdrClientCall .
Alexandre Julliard
julliard at winehq.org
Thu Jun 2 11:22:58 CDT 2011
Module: wine
Branch: master
Commit: f061917296b9dda6d441e6d34e9a90a08370627b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f061917296b9dda6d441e6d34e9a90a08370627b
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Jun 1 22:10:58 2011 +0200
include: Make CLIENT_CALL_RETURN definition platform-specific to handle the return type incompatibility in NdrClientCall.
---
dlls/rpcrt4/cproxy.c | 2 +-
dlls/rpcrt4/ndr_stubless.c | 20 ++++++++++----------
include/rpcndr.h | 16 ++++++++++------
3 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/dlls/rpcrt4/cproxy.c b/dlls/rpcrt4/cproxy.c
index d0c56c7..8352ba3 100644
--- a/dlls/rpcrt4/cproxy.c
+++ b/dlls/rpcrt4/cproxy.c
@@ -95,7 +95,7 @@ __ASM_GLOBAL_FUNC(call_stubless_func,
"addl %edx,%esp\n\t"
"jmp *%ecx" );
-HRESULT WINAPI ObjectStubless(DWORD *args)
+CLIENT_CALL_RETURN WINAPI ObjectStubless(DWORD *args)
{
DWORD index = args[0];
void **iface = (void **)args[2];
diff --git a/dlls/rpcrt4/ndr_stubless.c b/dlls/rpcrt4/ndr_stubless.c
index 9edebf8..3fd4cf8 100644
--- a/dlls/rpcrt4/ndr_stubless.c
+++ b/dlls/rpcrt4/ndr_stubless.c
@@ -548,10 +548,7 @@ void client_do_args_old_format(PMIDL_STUB_MESSAGE pStubMsg,
}
}
-/* the return type should be CLIENT_CALL_RETURN, but this is incompatible
- * with the way gcc returns structures. "void *" should be the largest type
- * that MIDL should allow you to return anyway */
-LONG_PTR WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, ...)
+CLIENT_CALL_RETURN WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pFormat, ...)
{
/* pointer to start of stack where arguments start */
RPC_MESSAGE rpcMsg;
@@ -629,7 +626,7 @@ LONG_PTR WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
if (!(pProcHeader->Oi_flags & RPC_FC_PROC_OIF_OBJECT))
{
pFormat = client_get_handle(&stubMsg, pProcHeader, pHandleFormat, &hBinding);
- if (!pFormat) return 0;
+ if (!pFormat) goto done;
}
bV2Format = (pStubDesc->Version >= 0x20000);
@@ -899,9 +896,9 @@ LONG_PTR WINAPIV NdrClientCall2(PMIDL_STUB_DESC pStubDesc, PFORMAT_STRING pForma
client_free_handle(&stubMsg, pProcHeader, pHandleFormat, hBinding);
}
+done:
TRACE("RetVal = 0x%lx\n", RetVal);
-
- return RetVal;
+ return *(CLIENT_CALL_RETURN *)&RetVal;
}
/* Calls a function with the specified arguments, restoring the stack
@@ -1638,7 +1635,7 @@ struct async_call_data
ULONG_PTR NdrCorrCache[256];
};
-LONG_PTR WINAPIV NdrAsyncClientCall(PMIDL_STUB_DESC pStubDesc,
+CLIENT_CALL_RETURN WINAPIV NdrAsyncClientCall(PMIDL_STUB_DESC pStubDesc,
PFORMAT_STRING pFormat, ...)
{
/* pointer to start of stack where arguments start */
@@ -1658,6 +1655,7 @@ LONG_PTR WINAPIV NdrAsyncClientCall(PMIDL_STUB_DESC pStubDesc,
const NDR_PROC_HEADER * pProcHeader = (const NDR_PROC_HEADER *)&pFormat[0];
/* -Oif or -Oicf generated format */
BOOL bV2Format = FALSE;
+ LONG_PTR RetVal;
__ms_va_list args;
TRACE("pStubDesc %p, pFormat %p, ...\n", pStubDesc, pFormat);
@@ -1720,7 +1718,7 @@ LONG_PTR WINAPIV NdrAsyncClientCall(PMIDL_STUB_DESC pStubDesc,
async_call_data->pHandleFormat = pFormat;
pFormat = client_get_handle(pStubMsg, pProcHeader, async_call_data->pHandleFormat, &async_call_data->hBinding);
- if (!pFormat) return 0;
+ if (!pFormat) goto done;
bV2Format = (pStubDesc->Version >= 0x20000);
@@ -1846,8 +1844,10 @@ LONG_PTR WINAPIV NdrAsyncClientCall(PMIDL_STUB_DESC pStubDesc,
}
}
+done:
TRACE("returning 0\n");
- return 0;
+ RetVal = 0;
+ return *(CLIENT_CALL_RETURN *)&RetVal;
}
RPC_STATUS NdrpCompleteAsyncClientCall(RPC_ASYNC_STATE *pAsync, void *Reply)
diff --git a/include/rpcndr.h b/include/rpcndr.h
index 1754f5e..eb65192 100644
--- a/include/rpcndr.h
+++ b/include/rpcndr.h
@@ -414,11 +414,17 @@ typedef struct _MIDL_STUBLESS_PROXY_INFO
PMIDL_SYNTAX_INFO pSyntaxInfo;
} MIDL_STUBLESS_PROXY_INFO, *PMIDL_STUBLESS_PROXY_INFO;
+
+#if defined(__i386__) && !defined(__MSC_VER) && !defined(__MINGW32__) && !defined(__CYGWIN__)
+/* Calling convention for returning structures/unions is different between Windows and gcc on i386 */
+typedef LONG_PTR CLIENT_CALL_RETURN;
+#else
typedef union _CLIENT_CALL_RETURN
{
void *Pointer;
LONG_PTR Simple;
} CLIENT_CALL_RETURN;
+#endif
typedef enum {
STUB_UNMARSHAL,
@@ -645,15 +651,13 @@ RPCRTAPI void RPC_ENTRY
RPCRTAPI unsigned char* RPC_ENTRY
NdrUserMarshalSimpleTypeConvert( ULONG *pFlags, unsigned char *pBuffer, unsigned char FormatChar );
-/* Note: this should return a CLIENT_CALL_RETURN, but calling convention for
- * returning structures/unions is different between Windows and gcc on i386. */
-LONG_PTR RPC_VAR_ENTRY
+CLIENT_CALL_RETURN RPC_VAR_ENTRY
NdrClientCall2( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... );
-LONG_PTR RPC_VAR_ENTRY
+CLIENT_CALL_RETURN RPC_VAR_ENTRY
NdrClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... );
-LONG_PTR RPC_VAR_ENTRY
+CLIENT_CALL_RETURN RPC_VAR_ENTRY
NdrAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... );
-LONG_PTR RPC_VAR_ENTRY
+CLIENT_CALL_RETURN RPC_VAR_ENTRY
NdrDcomAsyncClientCall( PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ... );
RPCRTAPI void RPC_ENTRY
More information about the wine-cvs
mailing list