From dfef0a390443379c3991b97d8871f301321c36f6 Mon Sep 17 00:00:00 2001 From: "Yi Zhang (CLR)" Date: Mon, 2 May 2016 21:00:21 -0700 Subject: Fix calling convention mismatch in 7 interop tests and enable [NativeCallable] in all architectures. --- .../FuncPtrAsDelegateParamManaged.cs | Bin 2480 -> 1253 bytes .../FuncPtrAsDelegateParamNative.cpp | 10 +++++----- .../GetFcnPtrForDel_Negative_Security.cs | 4 ++-- .../Interop/MarshalAPI/IUnknown/IUnknownNative.cpp | 2 +- .../src/Interop/NativeCallable/NativeCallableDll.cpp | 2 +- .../EnumMarshalling/MarshalEnumNative.cpp | 4 ++-- tests/src/Interop/RefInt/RefIntNative.cpp | 4 ++-- tests/src/Interop/SimpleStruct/SimpleStructNative.cpp | 10 +++++----- tests/src/Interop/common/xplatform.h | 2 +- 9 files changed, 19 insertions(+), 19 deletions(-) (limited to 'tests/src/Interop') diff --git a/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParamManaged.cs b/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParamManaged.cs index 324f9a22a8..31c7535d47 100644 Binary files a/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParamManaged.cs and b/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParamManaged.cs differ diff --git a/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParamNative.cpp b/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParamNative.cpp index 9c9d36dbef..796f1ca3ba 100644 --- a/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParamNative.cpp +++ b/tests/src/Interop/FuncPtrAsDelegateParam/FuncPtrAsDelegateParamNative.cpp @@ -8,14 +8,14 @@ //Cdecl -1 678 -int WINAPI CdeTest() +int _cdecl CdeTest() { return -1; } -typedef int (WINAPI *pFunc)(); -typedef int (WINAPI *Cdeclcaller)(pFunc); -extern "C" DLL_EXPORT BOOL WINAPI DoCallBack_Cdecl(Cdeclcaller caller) +typedef int (_cdecl *pFunc)(); +typedef int (_cdecl *Cdeclcaller)(pFunc); +extern "C" DLL_EXPORT BOOL _cdecl DoCallBack_Cdecl(Cdeclcaller caller) { printf("DoCallBack_Cdecl\n"); @@ -25,4 +25,4 @@ extern "C" DLL_EXPORT BOOL WINAPI DoCallBack_Cdecl(Cdeclcaller caller) return FALSE; } return TRUE; -} \ No newline at end of file +} diff --git a/tests/src/Interop/MarshalAPI/FunctionPointer/GetFcnPtrForDel_Negative_Security.cs b/tests/src/Interop/MarshalAPI/FunctionPointer/GetFcnPtrForDel_Negative_Security.cs index 3724404d59..de74495caf 100644 --- a/tests/src/Interop/MarshalAPI/FunctionPointer/GetFcnPtrForDel_Negative_Security.cs +++ b/tests/src/Interop/MarshalAPI/FunctionPointer/GetFcnPtrForDel_Negative_Security.cs @@ -8,7 +8,7 @@ using System.Runtime.InteropServices; partial class FunctionPtr { - [DllImport("FunctionPointerNative")] + [DllImport("FunctionPointerNative", CallingConvention=CallingConvention.Cdecl)] public static extern bool CheckFcnPtr(IntPtr fcnptr); public delegate bool DelegateWithLong(long l); //Singlecast delegate @@ -84,4 +84,4 @@ partial class FunctionPtr throw new Exception("Failed multicast call"); } } -#pragma warning restore 618 \ No newline at end of file +#pragma warning restore 618 diff --git a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownNative.cpp b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownNative.cpp index 674c3fb297..bdc382be7e 100644 --- a/tests/src/Interop/MarshalAPI/IUnknown/IUnknownNative.cpp +++ b/tests/src/Interop/MarshalAPI/IUnknown/IUnknownNative.cpp @@ -4,7 +4,7 @@ #include #include -extern "C" DLL_EXPORT BOOL __stdcall Marshal_IUnknown(/*[in]*/IUnknown *o) +extern "C" DLL_EXPORT BOOL _cdecl Marshal_IUnknown(/*[in]*/IUnknown *o) { //Call AddRef and Release on the passed IUnknown //test if the ref counts get updated as expected diff --git a/tests/src/Interop/NativeCallable/NativeCallableDll.cpp b/tests/src/Interop/NativeCallable/NativeCallableDll.cpp index 6ba63ff875..0eb82914f1 100644 --- a/tests/src/Interop/NativeCallable/NativeCallableDll.cpp +++ b/tests/src/Interop/NativeCallable/NativeCallableDll.cpp @@ -4,7 +4,7 @@ #include -typedef int (*CALLBACKADDPROC)(int n); +typedef int (WINAPI *CALLBACKADDPROC)(int n); extern "C" DLL_EXPORT int WINAPI CallManagedAdd(CALLBACKADDPROC pCallbackAddProc, int n) { diff --git a/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/MarshalEnumNative.cpp b/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/MarshalEnumNative.cpp index c1e37ca4bf..3d8f861547 100644 --- a/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/MarshalEnumNative.cpp +++ b/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/MarshalEnumNative.cpp @@ -5,7 +5,7 @@ typedef void *voidPtr; -extern "C" DLL_EXPORT long WINAPI CdeclEnum(int r,BOOL *result) +extern "C" DLL_EXPORT long _cdecl CdeclEnum(int r,BOOL *result) { if(r != 3) { @@ -17,7 +17,7 @@ extern "C" DLL_EXPORT long WINAPI CdeclEnum(int r,BOOL *result) } -extern "C" DLL_EXPORT voidPtr WINAPI GetFptr(int i) +extern "C" DLL_EXPORT voidPtr _cdecl GetFptr(int i) { return (voidPtr) &CdeclEnum; } diff --git a/tests/src/Interop/RefInt/RefIntNative.cpp b/tests/src/Interop/RefInt/RefIntNative.cpp index 8154cca6ed..5673315859 100755 --- a/tests/src/Interop/RefInt/RefIntNative.cpp +++ b/tests/src/Interop/RefInt/RefIntNative.cpp @@ -35,7 +35,7 @@ extern "C" BOOL DLL_EXPORT __stdcall MarshalRefInt_Stdcall(int * pint) } typedef BOOL (_cdecl *Cdeclcaller)(int* pint); -extern "C" BOOL DLL_EXPORT __stdcall DoCallBack_MarshalRefInt_Cdecl(Cdeclcaller caller) +extern "C" BOOL DLL_EXPORT _cdecl DoCallBack_MarshalRefInt_Cdecl(Cdeclcaller caller) { //Check the Input int itemp = iNative; @@ -71,7 +71,7 @@ extern "C" BOOL DLL_EXPORT __stdcall DoCallBack_MarshalRefInt_Stdcall(Stdcallca } typedef BOOL (_cdecl * DelegatePInvokeCdecl)(int * pint); -extern "C" DLL_EXPORT DelegatePInvokeCdecl MarshalRefInt_DelegatePInvoke_Cdecl() +extern "C" DLL_EXPORT DelegatePInvokeCdecl _cdecl MarshalRefInt_DelegatePInvoke_Cdecl() { return MarshalRefInt_Cdcel; } diff --git a/tests/src/Interop/SimpleStruct/SimpleStructNative.cpp b/tests/src/Interop/SimpleStruct/SimpleStructNative.cpp index 24517b8f10..5fe82146b8 100644 --- a/tests/src/Interop/SimpleStruct/SimpleStructNative.cpp +++ b/tests/src/Interop/SimpleStruct/SimpleStructNative.cpp @@ -26,7 +26,7 @@ typedef struct { }ExplStruct; extern "C" -DLL_EXPORT BOOL WINAPI CdeclSimpleStructByRef(Sstr *p) +DLL_EXPORT BOOL _cdecl CdeclSimpleStructByRef(Sstr *p) { p->a = 100; p->b=1; @@ -35,7 +35,7 @@ DLL_EXPORT BOOL WINAPI CdeclSimpleStructByRef(Sstr *p) } extern "C" -DLL_EXPORT BOOL WINAPI CdeclSimpleExplStructByRef(ExplStruct *p) +DLL_EXPORT BOOL _cdecl CdeclSimpleExplStructByRef(ExplStruct *p) { if((p->a != 0) || (p->udata.i != 10)) { @@ -48,7 +48,7 @@ DLL_EXPORT BOOL WINAPI CdeclSimpleExplStructByRef(ExplStruct *p) } extern "C" -DLL_EXPORT Sstr_simple* WINAPI CdeclSimpleStruct(Sstr_simple p,BOOL *result) +DLL_EXPORT Sstr_simple* _cdecl CdeclSimpleStruct(Sstr_simple p,BOOL *result) { Sstr_simple *pSimpleStruct; if((p.a !=100) || (p.b != FALSE) || (p.c != 3.142)) @@ -65,7 +65,7 @@ DLL_EXPORT Sstr_simple* WINAPI CdeclSimpleStruct(Sstr_simple p,BOOL *result) } extern "C" -DLL_EXPORT ExplStruct* WINAPI CdeclSimpleExplStruct(ExplStruct p,BOOL *result) +DLL_EXPORT ExplStruct* _cdecl CdeclSimpleExplStruct(ExplStruct p,BOOL *result) { ExplStruct *pExplStruct; if((p.a !=1) || (p.udata.b != FALSE)) @@ -81,7 +81,7 @@ DLL_EXPORT ExplStruct* WINAPI CdeclSimpleExplStruct(ExplStruct p,BOOL *result) } extern "C" -DLL_EXPORT voidPtr WINAPI GetFptr(int i) +DLL_EXPORT voidPtr _cdecl GetFptr(int i) { switch(i) { diff --git a/tests/src/Interop/common/xplatform.h b/tests/src/Interop/common/xplatform.h index 3e7267fe07..c84ac9b1de 100644 --- a/tests/src/Interop/common/xplatform.h +++ b/tests/src/Interop/common/xplatform.h @@ -57,7 +57,7 @@ #define WINAPI __stdcall #endif -#ifndef __stdcall +#ifndef _MSC_VER #if __i386__ #define __stdcall __attribute__((stdcall)) #define _cdecl __attribute__((cdecl)) -- cgit v1.2.3