diff options
author | Jeremy Koritzinsky <jkoritzinsky@gmail.com> | 2019-01-17 16:58:34 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-17 16:58:34 -0800 |
commit | 8da1974d2d9ff47e45334f359199a3d50c8e0cbb (patch) | |
tree | 0d30034577888b4d8e3c039e53c762271f2bf157 /tests | |
parent | 00f8c81034543d7e100fe0ff687aaaace9775f80 (diff) | |
download | coreclr-8da1974d2d9ff47e45334f359199a3d50c8e0cbb.tar.gz coreclr-8da1974d2d9ff47e45334f359199a3d50c8e0cbb.tar.bz2 coreclr-8da1974d2d9ff47e45334f359199a3d50c8e0cbb.zip |
Unify xplatform.h and platformdefines.h (#21389)
* Move most of xplatform.h into platformdefines.h and clean up the interop CMake files.
* Fix build-break off Windows.
* Fix typo.
* Fix another break off-Windows.
* Fix signed/unsigned mismatch
Diffstat (limited to 'tests')
94 files changed, 349 insertions, 428 deletions
diff --git a/tests/src/Common/Platform/platformdefines.cpp b/tests/src/Common/Platform/platformdefines.cpp index 7e21ab0bb3..0380117640 100644 --- a/tests/src/Common/Platform/platformdefines.cpp +++ b/tests/src/Common/Platform/platformdefines.cpp @@ -159,19 +159,19 @@ error_t TP_getenv_s(size_t* pReturnValue, LPWSTR buffer, size_t sizeInWords, LPC return 0; } -error_t TP_putenv_s(LPTSTR name, LPTSTR value) +error_t TP_putenv_s(LPWSTR name, LPWSTR value) { if (NULL == name || NULL == value) return 1; #ifdef WINDOWS - if( 0 != _putenv_s(name, value)) + if( 0 != _wputenv_s(name, value)) return 2; else return 0; #else int retVal = 0; - char *assignment = (char*) malloc(sizeof(char) * (strlen(name) + strlen(value) + 1)); - sprintf(assignment, "%s=%s", name, value); + char *assignment = (char*) malloc(sizeof(char) * (wcslen(name) + wcslen(value) + 1)); + sprintf(assignment, "%s=%s", HackyConvertToSTR(name), HackyConvertToSTR(value)); if (0 != putenv(assignment)) retVal = 2; @@ -445,18 +445,18 @@ BSTR TP_SysAllocString(LPCWSTR psz) #else if(psz == NULL) return NULL; - return TP_SysAllocStringLen(psz, (DWORD)wcslen(psz)); + return CoreClrBStrAlloc(psz, (DWORD)wcslen(psz)); #endif } -BSTR TP_SysAllocStringLen(LPCWSTR psz, size_t len) +BSTR CoreClrBStrAlloc(LPCWSTR psz, size_t len) { ULONG cbTotal = 0; if (FAILED(CbSysStringSize((ULONG)len, FALSE, &cbTotal))) return NULL; - BSTR bstr = (BSTR)TP_CoTaskMemAlloc(cbTotal); + BSTR bstr = (BSTR)CoreClrAlloc(cbTotal); if(bstr != NULL){ @@ -480,7 +480,7 @@ BSTR TP_SysAllocStringLen(LPCWSTR psz, size_t len) return bstr; } -BSTR TP_SysAllocStringByteLen(LPCSTR psz, size_t len) +BSTR CoreClrBStrAlloc(LPCSTR psz, size_t len) { #ifdef WINDOWS return SysAllocStringByteLen(psz, (UINT)len); @@ -491,7 +491,7 @@ BSTR TP_SysAllocStringByteLen(LPCSTR psz, size_t len) if (FAILED(CbSysStringSize(len, TRUE, &cbTotal))) return NULL; - bstr = (BSTR)TP_CoTaskMemAlloc(cbTotal); + bstr = (BSTR)CoreClrAlloc(cbTotal); if (bstr != NULL) { #if defined(_WIN64) @@ -515,14 +515,14 @@ BSTR TP_SysAllocStringByteLen(LPCSTR psz, size_t len) #endif } -void TP_SysFreeString(BSTR bstr) +void CoreClrBStrFree(BSTR bstr) { #ifdef WINDOWS return SysFreeString(bstr); #else if (bstr == NULL) return; - TP_CoTaskMemFree((BYTE *)bstr - sizeof(DWORD_PTR)); + CoreClrFree((BYTE *)bstr - sizeof(DWORD_PTR)); #endif } @@ -553,3 +553,63 @@ DWORD TP_SysStringLen(BSTR bstr) return (unsigned int)((((DWORD *)bstr)[-1]) / sizeof(OLECHAR)); #endif } + +size_t TP_strncpy_s(char* strDest, size_t numberOfElements, const char *strSource, size_t count) +{ + // NOTE: Need to pass count + 1 since strncpy_s does not count null, + // while snprintf does. + return snprintf(strDest, count + 1, "%s", strSource); +} + +size_t TP_strcpy_s(char *dest, size_t n, char const *src) +{ + return snprintf(dest, n, "%s", src); +} + +int TP_wcsncpy_s(LPWSTR strDestination, size_t size1, LPCWSTR strSource, size_t size2) +{ + // copy sizeInBytes bytes of strSource into strDestination + if (NULL == strDestination || NULL == strSource) return 1; + + size_t cnt = 0; + while (cnt < size1 && '\0' != strSource[cnt]) + { + strDestination[cnt] = strSource[cnt]; + cnt++; + } + + strDestination[cnt] = '\0'; + return 0; +} + +int TP_wcsncpy_s(LPWSTR strDestination, size_t size1, LPCWSTR strSource) +{ + return wcsncpy_s(strDestination, size1, strSource, 0); +} + +int TP_wcsncmp(LPCWSTR str1, LPCWSTR str2,size_t len) +{ + // < 0 str1 less than str2 + // 0 str1 identical to str2 + // > 0 str1 greater than str2 + if (NULL == str1 && NULL != str2) return -1; + if (NULL != str1 && NULL == str2) return 1; + if (NULL == str1 && NULL == str2) return 0; + + while (*str1 == *str2 && '\0' != *str1 && '\0' != *str2 && len--!= 0) + { + str1++; + str2++; + } + + if ('\0' == *str1 && '\0' == *str2) return 0; + if ('\0' != *str1) return -1; + if ('\0' != *str2) return 1; + + return (*str1 > *str2) ? 1 : -1; +} + +int TP_wmemcmp(LPCWSTR str1, LPCWSTR str2,size_t len) +{ + return wcsncmp(str1, str2, len); +} diff --git a/tests/src/Common/Platform/platformdefines.h b/tests/src/Common/Platform/platformdefines.h index 0a33bc11fa..0471ecd062 100644 --- a/tests/src/Common/Platform/platformdefines.h +++ b/tests/src/Common/Platform/platformdefines.h @@ -4,6 +4,7 @@ #include <stdio.h> +#include <memory.h> #include <stdlib.h> #include <string.h> #include <cstdint> @@ -11,11 +12,31 @@ #ifndef _PLATFORMDEFINES__H #define _PLATFORMDEFINES__H +#ifdef _MSC_VER +// Our tests don't care about secure CRT +#define _CRT_SECURE_NO_WARNINGS 1 +#endif + + +// Ensure that both UNICODE and _UNICODE are set. +#ifndef _UNICODE +#define _UNICODE +#endif +#ifndef UNICODE +#define UNICODE +#endif + +#include <wchar.h> + // // types and constants // #ifdef WINDOWS + +#define NOMINMAX + #include <windows.h> +#include <combaseapi.h> #define FS_SEPERATOR L"\\" #define PATH_DELIMITER L";" @@ -73,6 +94,10 @@ typedef unsigned int ULONG, *PULONG; #define WINAPI __stdcall #endif +#ifndef STDMETHODCALLTYPE +#define STDMETHODCALLTYPE +#endif + #ifndef _MSC_VER #if __i386__ #define __stdcall __attribute__((stdcall)) @@ -102,17 +127,14 @@ LPWSTR HackyConvertToWSTR(const char* pszInput); typedef pthread_t THREAD_ID; typedef void* (*MacWorker)(void*); typedef DWORD __stdcall (*LPTHREAD_START_ROUTINE)(void*); -#ifdef UNICODE typedef WCHAR TCHAR; -#else // ANSI -typedef char TCHAR; -#endif // UNICODE typedef char* LPSTR; typedef const char* LPCSTR; typedef TCHAR* LPTSTR; typedef const TCHAR* LPCTSTR; typedef void* FARPROC; -typedef void* HMODULE; +typedef void* HANDLE; +typedef HANDLE HMODULE; typedef void* ULONG_PTR; typedef int error_t; typedef void* LPVOID; @@ -142,14 +164,60 @@ void TP_JoinThread(THREAD_ID tThread); void TP_DebugBreak(); DWORD TP_GetFullPathName(LPWSTR fileName, DWORD nBufferLength, LPWSTR lpBuffer); + +size_t TP_strncpy_s(char* strDest, size_t numberOfElements, const char *strSource, size_t count); +size_t TP_strcpy_s(char *dest, size_t n, char const *src); +int TP_wcsncpy_s(LPWSTR strDestination, size_t size1, LPCWSTR strSource, size_t size2); +int TP_wcsncpy_s(LPWSTR strDestination, size_t size1, LPCWSTR strSource); +int TP_wcsncmp(LPCWSTR str1, LPCWSTR str2,size_t len); +int TP_wmemcmp(LPCWSTR str1, LPCWSTR str2,size_t len); + typedef WCHAR* BSTR; -BSTR TP_SysAllocStringByteLen(LPCSTR psz, size_t len); -void TP_SysFreeString(BSTR bstr); + +BSTR CoreClrBStrAlloc(LPCSTR psz, size_t len); +BSTR CoreClrBStrAlloc(LPCWSTR psz, size_t len); + +inline void *CoreClrBStrAlloc(size_t cb) +{ + // A null is automatically applied in the SysAllocStringByteLen API. + // Remove a single OLECHAR for the implied null. + // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/oleauto/nf-oleauto-sysallocstringbytelen + if (cb >= sizeof(OLECHAR)) + cb -= sizeof(OLECHAR); + + return CoreClrBStrAlloc((LPCSTR)nullptr, cb); +} + +void CoreClrBStrFree(BSTR bstr); + +inline void CoreClrBStrFree(void* p) +{ + CoreClrBStrFree((BSTR)p); +} + size_t TP_SysStringByteLen(BSTR bstr); -BSTR TP_SysAllocStringLen(LPCWSTR psz, size_t len); BSTR TP_SysAllocString(LPCWSTR psz); DWORD TP_SysStringLen(BSTR bstr); + +inline void *CoreClrAlloc(size_t cb) +{ +#ifdef WINDOWS + return ::CoTaskMemAlloc(cb); +#else + return ::malloc(cb); +#endif +} + +inline void CoreClrFree(void *p) +{ +#ifdef WINDOWS + return ::CoTaskMemFree(p); +#else + return ::free(p); +#endif +} + // // Method redirects // @@ -158,8 +226,6 @@ DWORD TP_SysStringLen(BSTR bstr); #define TP_LoadLibraryW(l) LoadLibraryW(l) #define TP_LoadLibraryA(l) LoadLibraryA(l) #define TP_GetProcAddress(m,e) GetProcAddress(m,e) -#define TP_CoTaskMemAlloc(t) CoTaskMemAlloc(t) -#define TP_CoTaskMemFree(t) CoTaskMemFree(t) #define TP_DebugBreak() DebugBreak() #define TP_rand rand #define TP_srand srand @@ -176,8 +242,6 @@ DWORD TP_SysStringLen(BSTR bstr); #define TP_LoadLibraryW(l) dlopen(l, 0) #define TP_LoadLibraryA(l) dlopen(l, 0) #define TP_GetProcAddress(m,e) dlsym(m,e) -#define TP_CoTaskMemAlloc(t) malloc(t) -#define TP_CoTaskMemFree(t) free(t) #define TP_rand arc4random #define TP_srand srandom #define wcscpy_s TP_scpy_s @@ -185,13 +249,19 @@ DWORD TP_SysStringLen(BSTR bstr); #define GetFullPathNameW(fname,buflen,buf,filepart) TP_GetFullPathName(fname,buflen,buf) #define wcslen TP_slen #define _wgetenv_s TP_getenv_s -#define _putenv_s TP_putenv_s +#define _wputenv_s TP_putenv_s #define ZeroMemory TP_ZeroMemory #define _itow_s TP_itow_s #define _itoa_s TP_itoa_s #define wcsstr TP_sstr #define strcmp TP_scmp_s #define wcscmp TP_wcmp_s +#define strncpy_s TP_strncpy_s +#define strcpy_s TP_strcpy_s +#define wcsncpy_s TP_wcsncpy_s +#define wcsncpy_s TP_wcsncpy_s +#define wcsncmp TP_wcsncmp +#define wmemcmp TP_wmemcmp #endif #endif diff --git a/tests/src/Interop/ArrayMarshalling/BoolArray/CMakeLists.txt b/tests/src/Interop/ArrayMarshalling/BoolArray/CMakeLists.txt index 88dffee18f..021ad35234 100644 --- a/tests/src/Interop/ArrayMarshalling/BoolArray/CMakeLists.txt +++ b/tests/src/Interop/ArrayMarshalling/BoolArray/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (MarshalBoolArrayNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES MarshalBoolArrayNative.cpp) # add the executable diff --git a/tests/src/Interop/ArrayMarshalling/BoolArray/MarshalBoolArrayNative.cpp b/tests/src/Interop/ArrayMarshalling/BoolArray/MarshalBoolArrayNative.cpp index e5ae64a8e1..67c6fbe236 100644 --- a/tests/src/Interop/ArrayMarshalling/BoolArray/MarshalBoolArrayNative.cpp +++ b/tests/src/Interop/ArrayMarshalling/BoolArray/MarshalBoolArrayNative.cpp @@ -3,6 +3,7 @@ // #include <xplatform.h> +#include <platformdefines.h> #include <stdio.h> #include <stdlib.h> diff --git a/tests/src/Interop/ArrayMarshalling/ByValArray/CMakeLists.txt b/tests/src/Interop/ArrayMarshalling/ByValArray/CMakeLists.txt index 043339cd08..5f8d5d4e2c 100644 --- a/tests/src/Interop/ArrayMarshalling/ByValArray/CMakeLists.txt +++ b/tests/src/Interop/ArrayMarshalling/ByValArray/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (MarshalArrayByValNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES MarshalArrayByValNative.cpp) # add the executable diff --git a/tests/src/Interop/ArrayMarshalling/SafeArray/CMakeLists.txt b/tests/src/Interop/ArrayMarshalling/SafeArray/CMakeLists.txt index e5ff0f6858..bb80d2ed0b 100644 --- a/tests/src/Interop/ArrayMarshalling/SafeArray/CMakeLists.txt +++ b/tests/src/Interop/ArrayMarshalling/SafeArray/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (SafeArrayNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES SafeArrayNative.cpp RecordNative.cpp) # add the executable diff --git a/tests/src/Interop/ArrayMarshalling/SafeArray/SafeArrayNative.cpp b/tests/src/Interop/ArrayMarshalling/SafeArray/SafeArrayNative.cpp index 76f4b54d4c..455435323b 100644 --- a/tests/src/Interop/ArrayMarshalling/SafeArray/SafeArrayNative.cpp +++ b/tests/src/Interop/ArrayMarshalling/SafeArray/SafeArrayNative.cpp @@ -5,7 +5,6 @@ #include <xplatform.h> #include <oleauto.h> #include <algorithm> -#include <platformdefines.h> #define RETURN_IF_FAILED(x) if(FAILED(hr = (x))) { return hr; } @@ -139,7 +138,7 @@ HRESULT Reverse(StringType str, StringType *res) HRESULT ReverseBSTR(BSTR str, BSTR *res) { size_t strDataLen = TP_SysStringByteLen(str); - BSTR resLocal = TP_SysAllocStringByteLen(reinterpret_cast<LPCSTR>(str), strDataLen); + BSTR resLocal = CoreClrBStrAlloc(reinterpret_cast<LPCSTR>(str), strDataLen); if (resLocal == nullptr) return E_INVALIDARG; diff --git a/tests/src/Interop/BestFitMapping/BestFitMappingNative.cpp b/tests/src/Interop/BestFitMapping/BestFitMappingNative.cpp index 35b4f0bf7a..bd92382a2d 100755 --- a/tests/src/Interop/BestFitMapping/BestFitMappingNative.cpp +++ b/tests/src/Interop/BestFitMapping/BestFitMappingNative.cpp @@ -6,6 +6,7 @@ #include <stdlib.h> #include <locale.h> #include <xplatform.h> +#include <platformdefines.h> #pragma warning( push ) #pragma warning( disable : 4996) @@ -473,4 +474,4 @@ extern "C" DLL_EXPORT void __cdecl DoSCallBack_LPSTR_InOutByRef(SCallBackInOutBy } CoreClrFree(pStr); } -#pragma warning( pop )
\ No newline at end of file +#pragma warning( pop ) diff --git a/tests/src/Interop/BestFitMapping/CMakeLists.txt b/tests/src/Interop/BestFitMapping/CMakeLists.txt index 8971ec3a66..f2fe36f70e 100755 --- a/tests/src/Interop/BestFitMapping/CMakeLists.txt +++ b/tests/src/Interop/BestFitMapping/CMakeLists.txt @@ -1,18 +1,11 @@ cmake_minimum_required (VERSION 2.6) project (BestFitMappingNative) set(SOURCES BestFitMappingNative.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (BestFitMappingNative SHARED ${SOURCES}) target_link_libraries(BestFitMappingNative ${LINK_LIBRARIES_ADDITIONAL}) -#get_cmake_property(_variableNames VARIABLES) -#foreach (_variableName ${_variableNames}) -# message(STATUS "${_variableName}=${${_variableName}}") -#endforeach() - - -#SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - # add the install targets -install (TARGETS BestFitMappingNative DESTINATION bin)
\ No newline at end of file +install (TARGETS BestFitMappingNative DESTINATION bin) diff --git a/tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp b/tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp index 4afebb3c22..a9af9569de 100644 --- a/tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp +++ b/tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include "ClientTests.h" +#include <platformdefines.h> #include <cstdint> #include <limits> diff --git a/tests/src/Interop/COM/NativeClients/Primitives/StringTests.cpp b/tests/src/Interop/COM/NativeClients/Primitives/StringTests.cpp index 32b5187070..96a713faff 100644 --- a/tests/src/Interop/COM/NativeClients/Primitives/StringTests.cpp +++ b/tests/src/Interop/COM/NativeClients/Primitives/StringTests.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include "ClientTests.h" +#include <platformdefines.h> #include <vector> #include <sstream> @@ -188,7 +189,7 @@ namespace }; // BSTR string - using BStr = AnyStr<OLECHAR, &CoreClrBstrAlloc, &CoreClrBstrFree>; + using BStr = AnyStr<OLECHAR, &CoreClrBStrAlloc, &CoreClrBStrFree>; // Wide string using WStr = AnyStr<WCHAR, &CoreClrAlloc, &CoreClrFree>; diff --git a/tests/src/Interop/DllImportAttribute/ExeFile/CMakeLists.txt b/tests/src/Interop/DllImportAttribute/ExeFile/CMakeLists.txt index 388b7bc5ee..4ee6e218f9 100644 --- a/tests/src/Interop/DllImportAttribute/ExeFile/CMakeLists.txt +++ b/tests/src/Interop/DllImportAttribute/ExeFile/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required (VERSION 2.6) project (ExeFile) set(SOURCES ExeFile.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_executable (ExeFile ${SOURCES}) target_link_libraries(ExeFile ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS ExeFile DESTINATION bin)
\ No newline at end of file +install (TARGETS ExeFile DESTINATION bin) diff --git a/tests/src/Interop/DllImportAttribute/FileNameContainDot/CMakeLists.txt b/tests/src/Interop/DllImportAttribute/FileNameContainDot/CMakeLists.txt index 90de03eca8..24a960c15a 100644 --- a/tests/src/Interop/DllImportAttribute/FileNameContainDot/CMakeLists.txt +++ b/tests/src/Interop/DllImportAttribute/FileNameContainDot/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required (VERSION 2.6) project (DllFile.Probe) set(SOURCES DllFile.Probe.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (DllFile.Probe SHARED ${SOURCES}) target_link_libraries(DllFile.Probe ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS DllFile.Probe DESTINATION bin)
\ No newline at end of file +install (TARGETS DllFile.Probe DESTINATION bin) diff --git a/tests/src/Interop/DllImportAttribute/FileNameContainDot/DllFile.Probe.cpp b/tests/src/Interop/DllImportAttribute/FileNameContainDot/DllFile.Probe.cpp index 4dcbe60449..e090949055 100644 --- a/tests/src/Interop/DllImportAttribute/FileNameContainDot/DllFile.Probe.cpp +++ b/tests/src/Interop/DllImportAttribute/FileNameContainDot/DllFile.Probe.cpp @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <locale.h> -#include <xplatform.h> +#include <platformdefines.h> #pragma warning( push ) #pragma warning( disable : 4996) @@ -13,4 +13,4 @@ extern "C" DLL_EXPORT int __cdecl Sum(int a, int b) { return a + b; -}
\ No newline at end of file +} diff --git a/tests/src/Interop/DllImportAttribute/Simple/CMakeLists.txt b/tests/src/Interop/DllImportAttribute/Simple/CMakeLists.txt index 71c8d39d24..21ac4518d2 100644 --- a/tests/src/Interop/DllImportAttribute/Simple/CMakeLists.txt +++ b/tests/src/Interop/DllImportAttribute/Simple/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required (VERSION 2.6) project (DllFileProbe) set(SOURCES DllFileProbe.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (DllFileProbe SHARED ${SOURCES}) target_link_libraries(DllFileProbe ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS DllFileProbe DESTINATION bin)
\ No newline at end of file +install (TARGETS DllFileProbe DESTINATION bin) diff --git a/tests/src/Interop/DllImportAttribute/Simple/DllFileProbe.cpp b/tests/src/Interop/DllImportAttribute/Simple/DllFileProbe.cpp index 4dcbe60449..e090949055 100644 --- a/tests/src/Interop/DllImportAttribute/Simple/DllFileProbe.cpp +++ b/tests/src/Interop/DllImportAttribute/Simple/DllFileProbe.cpp @@ -5,7 +5,7 @@ #include <stdio.h> #include <stdlib.h> #include <locale.h> -#include <xplatform.h> +#include <platformdefines.h> #pragma warning( push ) #pragma warning( disable : 4996) @@ -13,4 +13,4 @@ extern "C" DLL_EXPORT int __cdecl Sum(int a, int b) { return a + b; -}
\ No newline at end of file +} diff --git a/tests/src/Interop/ExecInDefAppDom/CMakeLists.txt b/tests/src/Interop/ExecInDefAppDom/CMakeLists.txt index e1c903c34d..85cc2d86cb 100644 --- a/tests/src/Interop/ExecInDefAppDom/CMakeLists.txt +++ b/tests/src/Interop/ExecInDefAppDom/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (ExecInDefAppDomDll) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES ExecInDefAppDomDll.cpp ) # add the executable diff --git a/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDomDll.cpp b/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDomDll.cpp index 676087b7e4..da76ddadaa 100644 --- a/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDomDll.cpp +++ b/tests/src/Interop/ExecInDefAppDom/ExecInDefAppDomDll.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include <xplatform.h> +#include <platformdefines.h> #ifdef WINDOWS #include "mscoree.h" @@ -78,4 +79,4 @@ CallExecuteInDefaultAppDomain(LPCWSTR pwzAssemblyPath, return E_FAIL; } -#endif // WINDOWS
\ No newline at end of file +#endif // WINDOWS diff --git a/tests/src/Interop/FuncPtrAsDelegateParam/CMakeLists.txt b/tests/src/Interop/FuncPtrAsDelegateParam/CMakeLists.txt index 3393155189..25a6b83bab 100644 --- a/tests/src/Interop/FuncPtrAsDelegateParam/CMakeLists.txt +++ b/tests/src/Interop/FuncPtrAsDelegateParam/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (FuncPtrAsDelegateParamNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES FuncPtrAsDelegateParamNative.cpp ) # add the executable @@ -8,4 +8,4 @@ add_library (FuncPtrAsDelegateParamNative SHARED ${SOURCES}) target_link_libraries(FuncPtrAsDelegateParamNative ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS FuncPtrAsDelegateParamNative DESTINATION bin)
\ No newline at end of file +install (TARGETS FuncPtrAsDelegateParamNative DESTINATION bin) diff --git a/tests/src/Interop/Interop.cmake b/tests/src/Interop/Interop.cmake index 64d39834d1..f66aece301 100644 --- a/tests/src/Interop/Interop.cmake +++ b/tests/src/Interop/Interop.cmake @@ -1 +1,3 @@ -# Settings for all Interop native assets
\ No newline at end of file +# Settings for all Interop native assets + +include_directories(${INC_PLATFORM_DIR}) diff --git a/tests/src/Interop/MarshalAPI/FunctionPointer/CMakeLists.txt b/tests/src/Interop/MarshalAPI/FunctionPointer/CMakeLists.txt index 00d7fff858..fbcb51e787 100644 --- a/tests/src/Interop/MarshalAPI/FunctionPointer/CMakeLists.txt +++ b/tests/src/Interop/MarshalAPI/FunctionPointer/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (FunctionPointerNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES FunctionPointerNative.cpp) # add the executable diff --git a/tests/src/Interop/MarshalAPI/FunctionPointer/FunctionPointerNative.cpp b/tests/src/Interop/MarshalAPI/FunctionPointer/FunctionPointerNative.cpp index 96b81481ca..4463158f43 100644 --- a/tests/src/Interop/MarshalAPI/FunctionPointer/FunctionPointerNative.cpp +++ b/tests/src/Interop/MarshalAPI/FunctionPointer/FunctionPointerNative.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include <stdio.h> #include <xplatform.h> +#include <platformdefines.h> extern "C" DLL_EXPORT bool __cdecl CheckFcnPtr(bool(STDMETHODCALLTYPE *fcnptr)(__int64)) { diff --git a/tests/src/Interop/MarshalAPI/IUnknown/CMakeLists.txt b/tests/src/Interop/MarshalAPI/IUnknown/CMakeLists.txt index 218462f6b9..6dfecd17fa 100644 --- a/tests/src/Interop/MarshalAPI/IUnknown/CMakeLists.txt +++ b/tests/src/Interop/MarshalAPI/IUnknown/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (IUnknownNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES IUnknownNative.cpp) # add the executable diff --git a/tests/src/Interop/NativeCallable/CMakeLists.txt b/tests/src/Interop/NativeCallable/CMakeLists.txt index e8ab51f8ef..5a178d2ca1 100644 --- a/tests/src/Interop/NativeCallable/CMakeLists.txt +++ b/tests/src/Interop/NativeCallable/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (NativeCallableDll) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES NativeCallableDll.cpp ) # add the executable diff --git a/tests/src/Interop/NativeCallable/NativeCallableDll.cpp b/tests/src/Interop/NativeCallable/NativeCallableDll.cpp index a90109bed5..277d8cc249 100644 --- a/tests/src/Interop/NativeCallable/NativeCallableDll.cpp +++ b/tests/src/Interop/NativeCallable/NativeCallableDll.cpp @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include <xplatform.h> +#include <platformdefines.h> typedef int (STDMETHODCALLTYPE *CALLBACKPROC)(int n); diff --git a/tests/src/Interop/NativeLibrary/CMakeLists.txt b/tests/src/Interop/NativeLibrary/CMakeLists.txt index f7d98ba507..b08f7b3020 100644 --- a/tests/src/Interop/NativeLibrary/CMakeLists.txt +++ b/tests/src/Interop/NativeLibrary/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (NativeLibrary) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES NativeLibrary.cpp) # add the executable diff --git a/tests/src/Interop/NativeLibrary/NativeLibrary.cpp b/tests/src/Interop/NativeLibrary/NativeLibrary.cpp index 7c1090f10f..48653891a7 100644 --- a/tests/src/Interop/NativeLibrary/NativeLibrary.cpp +++ b/tests/src/Interop/NativeLibrary/NativeLibrary.cpp @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #include <stdio.h> -#include <xplatform.h> +#include <platformdefines.h> extern "C" DLL_EXPORT int NativeSum(int a, int b) { diff --git a/tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/CMakeLists.txt b/tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/CMakeLists.txt index f940a21e65..b332bcb4c4 100644 --- a/tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Array/MarshalArrayAsField/LPArrayNative/CMakeLists.txt @@ -1,9 +1,9 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (MarshalArrayByValArrayNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") include_directories("../..") -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES MarshalArrayByValArrayNative.cpp ) diff --git a/tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/CMakeLists.txt b/tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/CMakeLists.txt index 6f27e1c53f..414726138f 100644 --- a/tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Array/MarshalArrayAsParam/LPArrayNative/CMakeLists.txt @@ -1,9 +1,8 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (MarshalArrayLPArrayNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") include_directories("../..") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES MarshalArrayLPArrayNative.cpp ) diff --git a/tests/src/Interop/PInvoke/ArrayWithOffset/CMakeLists.txt b/tests/src/Interop/PInvoke/ArrayWithOffset/CMakeLists.txt index 5af6a506f1..937c3c1736 100644 --- a/tests/src/Interop/PInvoke/ArrayWithOffset/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/ArrayWithOffset/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (ArrayWithOffsetNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES ArrayWithOffsetNative.cpp ) diff --git a/tests/src/Interop/PInvoke/AsAny/CMakeLists.txt b/tests/src/Interop/PInvoke/AsAny/CMakeLists.txt index 1c03bf3019..81820edf99 100644 --- a/tests/src/Interop/PInvoke/AsAny/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/AsAny/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (AsAnyNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES AsAnyNative.cpp ) diff --git a/tests/src/Interop/PInvoke/Attributes/LCID/CMakeLists.txt b/tests/src/Interop/PInvoke/Attributes/LCID/CMakeLists.txt index 18a4d9e3ba..0aa07914cf 100644 --- a/tests/src/Interop/PInvoke/Attributes/LCID/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Attributes/LCID/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (LCIDNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES LCIDNative.cpp ) diff --git a/tests/src/Interop/PInvoke/BestFitMapping/Char/BestFitMappingNative.cpp b/tests/src/Interop/PInvoke/BestFitMapping/Char/BestFitMappingNative.cpp index d8a0a2fb2f..e691b2ef3c 100644 --- a/tests/src/Interop/PInvoke/BestFitMapping/Char/BestFitMappingNative.cpp +++ b/tests/src/Interop/PInvoke/BestFitMapping/Char/BestFitMappingNative.cpp @@ -5,7 +5,7 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#include <xplatform.h> +#include <platformdefines.h> extern "C" bool DLL_EXPORT STDMETHODCALLTYPE Char_In(char c) diff --git a/tests/src/Interop/PInvoke/BestFitMapping/Char/CMakeLists.txt b/tests/src/Interop/PInvoke/BestFitMapping/Char/CMakeLists.txt index 430abbe0a0..37c6b13861 100644 --- a/tests/src/Interop/PInvoke/BestFitMapping/Char/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/BestFitMapping/Char/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (Char_BestFitMappingNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES BestFitMappingNative.cpp ) diff --git a/tests/src/Interop/PInvoke/BestFitMapping/LPStr/CMakeLists.txt b/tests/src/Interop/PInvoke/BestFitMapping/LPStr/CMakeLists.txt index a1940ee86b..971de04ce1 100644 --- a/tests/src/Interop/PInvoke/BestFitMapping/LPStr/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/BestFitMapping/LPStr/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (LPStr_BestFitMappingNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES BestFitMappingNative.cpp ) diff --git a/tests/src/Interop/PInvoke/CriticalHandles/CMakeLists.txt b/tests/src/Interop/PInvoke/CriticalHandles/CMakeLists.txt index 2dfa7e44e8..f704c03c10 100644 --- a/tests/src/Interop/PInvoke/CriticalHandles/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/CriticalHandles/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (CriticalHandlesNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES CriticalHandlesNative.cpp ) diff --git a/tests/src/Interop/PInvoke/DateTime/CMakeLists.txt b/tests/src/Interop/PInvoke/DateTime/CMakeLists.txt index ada49fb3c9..dadc5b18c8 100644 --- a/tests/src/Interop/PInvoke/DateTime/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/DateTime/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (NativeDateTime) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES NativeDateTime.cpp ) diff --git a/tests/src/Interop/PInvoke/Decimal/PInvoke/CMakeLists.txt b/tests/src/Interop/PInvoke/Decimal/PInvoke/CMakeLists.txt index edb87ee7f4..59c293aba0 100644 --- a/tests/src/Interop/PInvoke/Decimal/PInvoke/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Decimal/PInvoke/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (DecNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES DecNative.cpp ) diff --git a/tests/src/Interop/PInvoke/Decimal/ReversePInvoke/CMakeLists.txt b/tests/src/Interop/PInvoke/Decimal/ReversePInvoke/CMakeLists.txt index a644cb4a84..266f473032 100644 --- a/tests/src/Interop/PInvoke/Decimal/ReversePInvoke/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Decimal/ReversePInvoke/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (RevNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES RevNative.cpp ) diff --git a/tests/src/Interop/PInvoke/Delegate/MarshalDelegateAsField/CMakeLists.txt b/tests/src/Interop/PInvoke/Delegate/MarshalDelegateAsField/CMakeLists.txt index c0a6fc57d8..0b89e00b28 100644 --- a/tests/src/Interop/PInvoke/Delegate/MarshalDelegateAsField/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Delegate/MarshalDelegateAsField/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (PInvoke_Delegate_AsField) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES AsFieldNative.cpp ) diff --git a/tests/src/Interop/PInvoke/Delegate/MarshalDelegateAsParam/CMakeLists.txt b/tests/src/Interop/PInvoke/Delegate/MarshalDelegateAsParam/CMakeLists.txt index 1be5cfa1b9..379f490c7f 100644 --- a/tests/src/Interop/PInvoke/Delegate/MarshalDelegateAsParam/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Delegate/MarshalDelegateAsParam/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (PInvoke_Delegate_AsParam) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES AsParamNative.cpp ) diff --git a/tests/src/Interop/PInvoke/DllImportPath/CMakeLists.txt b/tests/src/Interop/PInvoke/DllImportPath/CMakeLists.txt index 34634b5b02..31b257beef 100644 --- a/tests/src/Interop/PInvoke/DllImportPath/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/DllImportPath/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (DllImportPath) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES DllImportPathNative.cpp ) diff --git a/tests/src/Interop/PInvoke/DllImportPath/DllImportPathNative.cpp b/tests/src/Interop/PInvoke/DllImportPath/DllImportPathNative.cpp index e3ad7cd220..113a08254e 100644 --- a/tests/src/Interop/PInvoke/DllImportPath/DllImportPathNative.cpp +++ b/tests/src/Interop/PInvoke/DllImportPath/DllImportPathNative.cpp @@ -4,6 +4,7 @@ #include <stdio.h> #include <xplatform.h> +#include <platformdefines.h> LPCWSTR strManaged = W("Managed\0String\0"); LPCWSTR strNative = W(" Native\0String\0"); diff --git a/tests/src/Interop/PInvoke/ExactSpelling/CMakeLists.txt b/tests/src/Interop/PInvoke/ExactSpelling/CMakeLists.txt index 27850f4d3b..95648097d9 100644 --- a/tests/src/Interop/PInvoke/ExactSpelling/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/ExactSpelling/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (ExactSpellingNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES ExactSpellingNative.cpp) diff --git a/tests/src/Interop/PInvoke/ExactSpelling/ExactSpellingNative.cpp b/tests/src/Interop/PInvoke/ExactSpelling/ExactSpellingNative.cpp index a4dad9df67..f77c31f6d7 100644 --- a/tests/src/Interop/PInvoke/ExactSpelling/ExactSpellingNative.cpp +++ b/tests/src/Interop/PInvoke/ExactSpelling/ExactSpellingNative.cpp @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. #include <stdio.h> -#include <xplatform.h> +#include <platformdefines.h> int intManaged = 1000; int intNative = 2000; diff --git a/tests/src/Interop/PInvoke/Miscellaneous/HandleRef/CMakeLists.txt b/tests/src/Interop/PInvoke/Miscellaneous/HandleRef/CMakeLists.txt index c5f031aafc..b4a03d7c37 100644 --- a/tests/src/Interop/PInvoke/Miscellaneous/HandleRef/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Miscellaneous/HandleRef/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (HandleRefNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES HandleRefNative.cpp ) diff --git a/tests/src/Interop/PInvoke/Miscellaneous/HandleRef/HandleRefNative.cpp b/tests/src/Interop/PInvoke/Miscellaneous/HandleRef/HandleRefNative.cpp index 9104bf6239..3a6c89577e 100644 --- a/tests/src/Interop/PInvoke/Miscellaneous/HandleRef/HandleRefNative.cpp +++ b/tests/src/Interop/PInvoke/Miscellaneous/HandleRef/HandleRefNative.cpp @@ -4,6 +4,7 @@ #include <stdio.h> #include <xplatform.h> +#include <platformdefines.h> const int intManaged = 1000; const int intNative = 2000; diff --git a/tests/src/Interop/PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/CMakeLists.txt b/tests/src/Interop/PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/CMakeLists.txt index b7a9790eb4..253c9a9309 100644 --- a/tests/src/Interop/PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/CMakeLists.txt @@ -1,13 +1,10 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (MAWSPINative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES MAWSPINative.cpp -) -# Additional files to reference: -# MAWSPINative.def +) # add the executable add_library (MAWSPINative SHARED ${SOURCES}) # add the install targets diff --git a/tests/src/Interop/PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/MAWSPINative.cpp b/tests/src/Interop/PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/MAWSPINative.cpp index 721a486f41..0ace6b1f04 100644 --- a/tests/src/Interop/PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/MAWSPINative.cpp +++ b/tests/src/Interop/PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/MAWSPINative.cpp @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include <xplatform.h> +#include <platformdefines.h> extern "C" DLL_EXPORT int STDMETHODCALLTYPE GetInt() { diff --git a/tests/src/Interop/PInvoke/NativeCallManagedComVisible/CMakeLists.txt b/tests/src/Interop/PInvoke/NativeCallManagedComVisible/CMakeLists.txt index db153817c3..6630f9ca81 100644 --- a/tests/src/Interop/PInvoke/NativeCallManagedComVisible/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/NativeCallManagedComVisible/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (ComVisibleNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES ComVisibleNative.cpp ) diff --git a/tests/src/Interop/PInvoke/NativeCallManagedComVisible/ComVisibleNative.cpp b/tests/src/Interop/PInvoke/NativeCallManagedComVisible/ComVisibleNative.cpp index c674f662de..f79e8ac4b6 100644 --- a/tests/src/Interop/PInvoke/NativeCallManagedComVisible/ComVisibleNative.cpp +++ b/tests/src/Interop/PInvoke/NativeCallManagedComVisible/ComVisibleNative.cpp @@ -7,6 +7,7 @@ #include <windows.h> #include <Objbase.h> #include <xplatform.h> +#include <platformdefines.h> // // Standard function to call the managed COM. diff --git a/tests/src/Interop/PInvoke/Primitives/Int/CMakeLists.txt b/tests/src/Interop/PInvoke/Primitives/Int/CMakeLists.txt index ba99147123..5d6513fec6 100644 --- a/tests/src/Interop/PInvoke/Primitives/Int/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Primitives/Int/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (PInvokeIntNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES PInvokeIntNative.cpp) add_library (PInvokeIntNative SHARED ${SOURCES}) # add the install targets diff --git a/tests/src/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp b/tests/src/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp index b18456c0cf..b5b863c986 100644 --- a/tests/src/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp +++ b/tests/src/Interop/PInvoke/Primitives/Int/PInvokeIntNative.cpp @@ -4,6 +4,7 @@ #include <stdio.h> #include <xplatform.h> +#include <platformdefines.h> int intManaged = 1000; int intNative = 2000; diff --git a/tests/src/Interop/PInvoke/Primitives/RuntimeHandles/CMakeLists.txt b/tests/src/Interop/PInvoke/Primitives/RuntimeHandles/CMakeLists.txt index e12b647983..b9dca0a33c 100644 --- a/tests/src/Interop/PInvoke/Primitives/RuntimeHandles/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Primitives/RuntimeHandles/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (RuntimeHandlesNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES RuntimeHandlesNative.cpp) add_library (RuntimeHandlesNative SHARED ${SOURCES}) # add the install targets diff --git a/tests/src/Interop/PInvoke/Primitives/RuntimeHandles/RuntimeHandlesNative.cpp b/tests/src/Interop/PInvoke/Primitives/RuntimeHandles/RuntimeHandlesNative.cpp index 2a95a1a542..e9b77e30d8 100644 --- a/tests/src/Interop/PInvoke/Primitives/RuntimeHandles/RuntimeHandlesNative.cpp +++ b/tests/src/Interop/PInvoke/Primitives/RuntimeHandles/RuntimeHandlesNative.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include <xplatform.h> +#include <platformdefines.h> extern "C" DLL_EXPORT BOOL STDMETHODCALLTYPE Marshal_In(HANDLE expected, HANDLE actual) { diff --git a/tests/src/Interop/PInvoke/SafeHandles/CMakeLists.txt b/tests/src/Interop/PInvoke/SafeHandles/CMakeLists.txt index 6c1321e37d..0440352a2e 100644 --- a/tests/src/Interop/PInvoke/SafeHandles/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/SafeHandles/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (PInvoke_SafeHandle) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES SafeHandleNative.cpp ) diff --git a/tests/src/Interop/PInvoke/SafeHandles/Interface/CMakeLists.txt b/tests/src/Interop/PInvoke/SafeHandles/Interface/CMakeLists.txt index 8fd1a0ff52..eed1ce29cb 100644 --- a/tests/src/Interop/PInvoke/SafeHandles/Interface/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/SafeHandles/Interface/CMakeLists.txt @@ -1,9 +1,8 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (PInvoke_SafeHandle_MarshalAs_Interface) -include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories("..") -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") +include_directories("..") set(SOURCES InterfaceNative.cpp ) diff --git a/tests/src/Interop/PInvoke/SafeHandles/Interface/InterfaceNative.cpp b/tests/src/Interop/PInvoke/SafeHandles/Interface/InterfaceNative.cpp index eaf5c8fdb1..62983c6376 100644 --- a/tests/src/Interop/PInvoke/SafeHandles/Interface/InterfaceNative.cpp +++ b/tests/src/Interop/PInvoke/SafeHandles/Interface/InterfaceNative.cpp @@ -7,6 +7,7 @@ #include <windows.h> #include <oleauto.h> #include <xplatform.h> +#include <platformdefines.h> #include "StructDefs.h" /////////////////////////////////Internal Helper Methods diff --git a/tests/src/Interop/PInvoke/SafeHandles/ReleaseHandle/CMakeLists.txt b/tests/src/Interop/PInvoke/SafeHandles/ReleaseHandle/CMakeLists.txt index baf7c1e810..53a02888ad 100644 --- a/tests/src/Interop/PInvoke/SafeHandles/ReleaseHandle/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/SafeHandles/ReleaseHandle/CMakeLists.txt @@ -1,8 +1,7 @@ -#VCXPROJ + cmake_minimum_required (VERSION 2.6) project (PInvoke_SafeHandle_ReleaseHandle) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES ReleaseHandleNative.cpp ) diff --git a/tests/src/Interop/PInvoke/SafeHandles/ReleaseHandle/ReleaseHandleNative.cpp b/tests/src/Interop/PInvoke/SafeHandles/ReleaseHandle/ReleaseHandleNative.cpp index 2f90a35f5b..cbf76d69c3 100644 --- a/tests/src/Interop/PInvoke/SafeHandles/ReleaseHandle/ReleaseHandleNative.cpp +++ b/tests/src/Interop/PInvoke/SafeHandles/ReleaseHandle/ReleaseHandleNative.cpp @@ -6,6 +6,7 @@ #include <stdlib.h> #include <windows.h> #include <xplatform.h> +#include <platformdefines.h> bool g_myResourceReleaseMethodCalled = false; diff --git a/tests/src/Interop/PInvoke/SafeHandles/SafeHandleNative.cpp b/tests/src/Interop/PInvoke/SafeHandles/SafeHandleNative.cpp index 0cbcd87914..520597ad32 100644 --- a/tests/src/Interop/PInvoke/SafeHandles/SafeHandleNative.cpp +++ b/tests/src/Interop/PInvoke/SafeHandles/SafeHandleNative.cpp @@ -6,6 +6,7 @@ #include <stdlib.h> #include <windows.h> #include <xplatform.h> +#include <platformdefines.h> #include "StructDefs.h" //all the unmanaged struct defs are in this file //Global Handle Return Value diff --git a/tests/src/Interop/PInvoke/SizeParamIndex/PInvoke/PassingByOut/CMakeLists.txt b/tests/src/Interop/PInvoke/SizeParamIndex/PInvoke/PassingByOut/CMakeLists.txt index 90058da221..52a6b3e00f 100644 --- a/tests/src/Interop/PInvoke/SizeParamIndex/PInvoke/PassingByOut/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/SizeParamIndex/PInvoke/PassingByOut/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required (VERSION 2.6) project (PInvokePassingByOutNative) -include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories("..") -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") +include_directories("..") set(SOURCES PInvokePassingByOutNative.cpp ) diff --git a/tests/src/Interop/PInvoke/SizeParamIndex/PInvoke/PassingByRef/CMakeLists.txt b/tests/src/Interop/PInvoke/SizeParamIndex/PInvoke/PassingByRef/CMakeLists.txt index f3349b1d1d..083a6bf39a 100644 --- a/tests/src/Interop/PInvoke/SizeParamIndex/PInvoke/PassingByRef/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/SizeParamIndex/PInvoke/PassingByRef/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required (VERSION 2.6) project (PInvokePassingByRefNative) -include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories("..") -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") +include_directories("..") set(SOURCES PInvokePassingByRefNative.cpp ) diff --git a/tests/src/Interop/PInvoke/SizeParamIndex/ReversePInvoke/PassingByOut/CMakeLists.txt b/tests/src/Interop/PInvoke/SizeParamIndex/ReversePInvoke/PassingByOut/CMakeLists.txt index 4dbfc7c327..f9639aa95a 100644 --- a/tests/src/Interop/PInvoke/SizeParamIndex/ReversePInvoke/PassingByOut/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/SizeParamIndex/ReversePInvoke/PassingByOut/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required (VERSION 2.6) project (ReversePInvokePassingByOutNative) -include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories("..") -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") +include_directories("..") set(SOURCES ReversePInvokePassingByOutNative.cpp ) diff --git a/tests/src/Interop/PInvoke/SizeParamIndex/ReversePInvoke/PassingByRef/CMakeLists.txt b/tests/src/Interop/PInvoke/SizeParamIndex/ReversePInvoke/PassingByRef/CMakeLists.txt index 34e702b609..180d43c967 100644 --- a/tests/src/Interop/PInvoke/SizeParamIndex/ReversePInvoke/PassingByRef/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/SizeParamIndex/ReversePInvoke/PassingByRef/CMakeLists.txt @@ -1,8 +1,7 @@ cmake_minimum_required (VERSION 2.6) project (ReversePInvokePassingByRefNative) -include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories("..") -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") +include_directories("..") set(SOURCES ReversePInvokePassingByRefNative.cpp ) diff --git a/tests/src/Interop/PInvoke/Varargs/CMakeLists.txt b/tests/src/Interop/PInvoke/Varargs/CMakeLists.txt index aa5a676aa1..2a627c0520 100644 --- a/tests/src/Interop/PInvoke/Varargs/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Varargs/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (VarargsNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES VarargsNative.cpp ) # add the executable diff --git a/tests/src/Interop/PInvoke/Variant/CMakeLists.txt b/tests/src/Interop/PInvoke/Variant/CMakeLists.txt index 536ffb3840..4edbe61b18 100644 --- a/tests/src/Interop/PInvoke/Variant/CMakeLists.txt +++ b/tests/src/Interop/PInvoke/Variant/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (VariantNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES VariantNative.cpp) # add the executable diff --git a/tests/src/Interop/PrimitiveMarshalling/Bool/BoolNative.cpp b/tests/src/Interop/PrimitiveMarshalling/Bool/BoolNative.cpp index edbc8cb92a..fbd1859813 100644 --- a/tests/src/Interop/PrimitiveMarshalling/Bool/BoolNative.cpp +++ b/tests/src/Interop/PrimitiveMarshalling/Bool/BoolNative.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include <xplatform.h> +#include <platformdefines.h> #include <stdio.h> diff --git a/tests/src/Interop/PrimitiveMarshalling/Bool/CMakeLists.txt b/tests/src/Interop/PrimitiveMarshalling/Bool/CMakeLists.txt index 4877b53a7a..7e5c257130 100644 --- a/tests/src/Interop/PrimitiveMarshalling/Bool/CMakeLists.txt +++ b/tests/src/Interop/PrimitiveMarshalling/Bool/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required (VERSION 2.6) project (NativeBool) set(SOURCES BoolNative.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (BoolNative SHARED ${SOURCES}) @@ -15,4 +16,4 @@ target_link_libraries(BoolNative ${LINK_LIBRARIES_ADDITIONAL}) #SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) # add the install targets -install (TARGETS BoolNative DESTINATION bin)
\ No newline at end of file +install (TARGETS BoolNative DESTINATION bin) diff --git a/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/CMakeLists.txt b/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/CMakeLists.txt index 70dffaa54e..92f21f908a 100644 --- a/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/CMakeLists.txt +++ b/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required (VERSION 2.6) project (MarshalEnumNative) set(SOURCES MarshalEnumNative.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (MarshalEnumNative SHARED ${SOURCES}) target_link_libraries(MarshalEnumNative ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS MarshalEnumNative DESTINATION bin)
\ No newline at end of file +install (TARGETS MarshalEnumNative DESTINATION bin) diff --git a/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/MarshalEnumNative.cpp b/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/MarshalEnumNative.cpp index f46eb6a881..a62e27f0fe 100644 --- a/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/MarshalEnumNative.cpp +++ b/tests/src/Interop/PrimitiveMarshalling/EnumMarshalling/MarshalEnumNative.cpp @@ -1,3 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + #include <xplatform.h> #include <stdio.h> #include <stdlib.h> diff --git a/tests/src/Interop/PrimitiveMarshalling/UIntPtr/CMakeLists.txt b/tests/src/Interop/PrimitiveMarshalling/UIntPtr/CMakeLists.txt index 62ce00481b..2f706af2c1 100644 --- a/tests/src/Interop/PrimitiveMarshalling/UIntPtr/CMakeLists.txt +++ b/tests/src/Interop/PrimitiveMarshalling/UIntPtr/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (UIntPtrNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES UIntPtrNative.cpp ) # add the executable diff --git a/tests/src/Interop/RefCharArray/CMakeLists.txt b/tests/src/Interop/RefCharArray/CMakeLists.txt index e07b407ab0..a366c31d81 100755 --- a/tests/src/Interop/RefCharArray/CMakeLists.txt +++ b/tests/src/Interop/RefCharArray/CMakeLists.txt @@ -1,18 +1,11 @@ cmake_minimum_required (VERSION 2.6) project (RefCharArrayNative) set(SOURCES RefCharArrayNative.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (RefCharArrayNative SHARED ${SOURCES}) target_link_libraries(RefCharArrayNative ${LINK_LIBRARIES_ADDITIONAL}) -#get_cmake_property(_variableNames VARIABLES) -#foreach (_variableName ${_variableNames}) -# message(STATUS "${_variableName}=${${_variableName}}") -#endforeach() - - -#SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) - # add the install targets -install (TARGETS RefCharArrayNative DESTINATION bin)
\ No newline at end of file +install (TARGETS RefCharArrayNative DESTINATION bin) diff --git a/tests/src/Interop/RefCharArray/RefCharArrayNative.cpp b/tests/src/Interop/RefCharArray/RefCharArrayNative.cpp index e5972cbf3a..9606e9c82f 100755 --- a/tests/src/Interop/RefCharArray/RefCharArrayNative.cpp +++ b/tests/src/Interop/RefCharArray/RefCharArrayNative.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include <xplatform.h> +#include <platformdefines.h> #include <stdio.h> #include <stdlib.h> @@ -99,4 +100,4 @@ typedef BOOL (__stdcall * DelegatePInvoke_Stdcall)(char **pstr); extern "C" DLL_EXPORT DelegatePInvoke_Stdcall __stdcall DelegatePinvoke_Stdcall() { return MarshalRefCharArray_Stdcall; -}
\ No newline at end of file +} diff --git a/tests/src/Interop/RefInt/CMakeLists.txt b/tests/src/Interop/RefInt/CMakeLists.txt index 6525c0ef3a..af63eff930 100755 --- a/tests/src/Interop/RefInt/CMakeLists.txt +++ b/tests/src/Interop/RefInt/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (RefIntNative) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES RefIntNative.cpp ) # add the executable @@ -7,4 +8,4 @@ add_library(RefIntNative SHARED ${SOURCES}) target_link_libraries(RefIntNative ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS RefIntNative DESTINATION bin)
\ No newline at end of file +install (TARGETS RefIntNative DESTINATION bin) diff --git a/tests/src/Interop/SimpleStruct/CMakeLists.txt b/tests/src/Interop/SimpleStruct/CMakeLists.txt index a797a2680b..a0ebd66d25 100644 --- a/tests/src/Interop/SimpleStruct/CMakeLists.txt +++ b/tests/src/Interop/SimpleStruct/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (SimpleStructNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES SimpleStructNative.cpp ) # add the executable diff --git a/tests/src/Interop/SizeConst/CMakeLists.txt b/tests/src/Interop/SizeConst/CMakeLists.txt index c162365bf2..720e8f6ba8 100644 --- a/tests/src/Interop/SizeConst/CMakeLists.txt +++ b/tests/src/Interop/SizeConst/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (SizeConstNative) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES SizeConstNative.cpp) # add the executable diff --git a/tests/src/Interop/SizeConst/SizeConstNative.cpp b/tests/src/Interop/SizeConst/SizeConstNative.cpp index 05288f08ad..6caf4ea6fd 100644 --- a/tests/src/Interop/SizeConst/SizeConstNative.cpp +++ b/tests/src/Interop/SizeConst/SizeConstNative.cpp @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -#include <xplatform.h> +#include <platformdefines.h> const int ARRAY_SIZE = 100; typedef struct { char arr[ARRAY_SIZE]; } S_CHARByValArray; diff --git a/tests/src/Interop/StringMarshalling/AnsiBSTR/AnsiBStrTestNative.cpp b/tests/src/Interop/StringMarshalling/AnsiBSTR/AnsiBStrTestNative.cpp index ca9d92c791..a5214f6d0b 100644 --- a/tests/src/Interop/StringMarshalling/AnsiBSTR/AnsiBStrTestNative.cpp +++ b/tests/src/Interop/StringMarshalling/AnsiBSTR/AnsiBStrTestNative.cpp @@ -35,7 +35,7 @@ extern "C" DLL_EXPORT BSTR STDMETHODCALLTYPE Marshal_In(/*[in]*/ BSTR s) printf("\tThe length of Actual:%zd\n", len); } - return TP_SysAllocStringByteLen(strReturn, lenstrReturn); + return CoreClrBStrAlloc(strReturn, lenstrReturn); } //Test Method2 @@ -66,18 +66,18 @@ extern "C" DLL_EXPORT BSTR STDMETHODCALLTYPE Marshal_InOut(/*[In,Out]*/ BSTR s) *((UINT *)s - 1) = (UINT) TP_SysStringByteLen(s); //Return - return TP_SysAllocStringByteLen(strReturn, lenstrReturn); + return CoreClrBStrAlloc(strReturn, lenstrReturn); } extern "C" DLL_EXPORT BSTR STDMETHODCALLTYPE Marshal_Out(/*[Out]*/ BSTR s) { - s = TP_SysAllocStringByteLen(strNative, lenstrNative); + s = CoreClrBStrAlloc(strNative, lenstrNative); //In-Place Change memcpy((char *)s, strNative, lenstrNative); *((UINT *)s - 1) = (UINT) TP_SysStringByteLen(s); //Return - return TP_SysAllocStringByteLen(strReturn, lenstrReturn); + return CoreClrBStrAlloc(strReturn, lenstrReturn); } extern "C" DLL_EXPORT BSTR STDMETHODCALLTYPE MarshalPointer_In(/*[in]*/ BSTR *s) @@ -101,7 +101,7 @@ extern "C" DLL_EXPORT BSTR STDMETHODCALLTYPE MarshalPointer_In(/*[in]*/ BSTR *s) printf("\tThe length of Actual:%zd\n", len); } - return TP_SysAllocStringByteLen(strReturn, lenstrReturn); + return CoreClrBStrAlloc(strReturn, lenstrReturn); } extern "C" DLL_EXPORT BSTR STDMETHODCALLTYPE MarshalPointer_InOut(/*[in,out]*/ BSTR *s) @@ -128,15 +128,15 @@ extern "C" DLL_EXPORT BSTR STDMETHODCALLTYPE MarshalPointer_InOut(/*[in,out]*/ B } //Allocate New - TP_SysFreeString(*s); - *s = TP_SysAllocStringByteLen(strNative, lenstrNative); + CoreClrBStrFree(*s); + *s = CoreClrBStrAlloc(strNative, lenstrNative); //Return - return TP_SysAllocStringByteLen(strReturn, lenstrReturn); + return CoreClrBStrAlloc(strReturn, lenstrReturn); } extern "C" DLL_EXPORT BSTR STDMETHODCALLTYPE MarshalPointer_Out(/*[out]*/ BSTR *s) { - *s = TP_SysAllocStringByteLen(strNative, lenstrNative); - return TP_SysAllocStringByteLen(strReturn, lenstrReturn); + *s = CoreClrBStrAlloc(strNative, lenstrNative); + return CoreClrBStrAlloc(strReturn, lenstrReturn); } diff --git a/tests/src/Interop/StringMarshalling/AnsiBSTR/CMakeLists.txt b/tests/src/Interop/StringMarshalling/AnsiBSTR/CMakeLists.txt index 2bf14359a0..621fed88f8 100644 --- a/tests/src/Interop/StringMarshalling/AnsiBSTR/CMakeLists.txt +++ b/tests/src/Interop/StringMarshalling/AnsiBSTR/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (AnsiBStrTestNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES AnsiBStrTestNative.cpp) # add the executable diff --git a/tests/src/Interop/StringMarshalling/BSTR/BSTRTestNative.cpp b/tests/src/Interop/StringMarshalling/BSTR/BSTRTestNative.cpp index 0365167bcc..2208d4c8bf 100644 --- a/tests/src/Interop/StringMarshalling/BSTR/BSTRTestNative.cpp +++ b/tests/src/Interop/StringMarshalling/BSTR/BSTRTestNative.cpp @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#include <xplatform.h> #include <platformdefines.h> WCHAR strManaged[] = W("Managed\0String\0"); @@ -69,7 +70,7 @@ extern "C" DLL_EXPORT BSTR MarshalPointer_InOut(/*[in,out]*/BSTR *s) } //Allocate New - TP_SysFreeString(*s); + CoreClrBStrFree(*s); *s = TP_SysAllocString(strNative); //Return @@ -97,7 +98,7 @@ extern "C" DLL_EXPORT BOOL __cdecl RPinvoke_DelMarshal_InOut(Test_DelMarshal_InO return FALSE; } - TP_SysFreeString(str); + CoreClrBStrFree(str); return TRUE; } @@ -211,7 +212,7 @@ extern "C" DLL_EXPORT BOOL MarshalPointer_Struct_InOut(Person* person) typedef BOOL (* Test_DelMarshal_Struct_In)(Person person); extern "C" DLL_EXPORT BOOL RPInvoke_DelMarshal_Struct_In(Test_DelMarshal_Struct_In d) { - Person * pPerson = (Person *)TP_CoTaskMemAlloc(sizeof(Person)); + Person * pPerson = (Person *)CoreClrAlloc(sizeof(Person)); pPerson->age = 21; pPerson->name = TP_SysAllocString(strNative); @@ -227,7 +228,7 @@ extern "C" DLL_EXPORT BOOL RPInvoke_DelMarshal_Struct_In(Test_DelMarshal_Struct_ typedef BOOL (* Test_DelMarshalPointer_Struct_InOut)(Person * person); extern "C" DLL_EXPORT BOOL RPInvoke_DelMarshalStructPointer_InOut(Test_DelMarshalPointer_Struct_InOut d) { - Person * pPerson = (Person *)TP_CoTaskMemAlloc(sizeof(Person)); + Person * pPerson = (Person *)CoreClrAlloc(sizeof(Person)); pPerson->age = 21; pPerson->name = TP_SysAllocString(strNative); diff --git a/tests/src/Interop/StringMarshalling/BSTR/CMakeLists.txt b/tests/src/Interop/StringMarshalling/BSTR/CMakeLists.txt index d485437f54..23b559b6ab 100644 --- a/tests/src/Interop/StringMarshalling/BSTR/CMakeLists.txt +++ b/tests/src/Interop/StringMarshalling/BSTR/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (BSTRTestNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES BSTRTestNative.cpp) # add the executable diff --git a/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt b/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt index 3d30d825b7..3798d5a260 100644 --- a/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt +++ b/tests/src/Interop/StringMarshalling/LPSTR/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required (VERSION 2.6) project (LPSTRTestNative) set(SOURCES LPSTRTestNative.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (LPSTRTestNative SHARED ${SOURCES}) diff --git a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTestNative.cpp b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTestNative.cpp index 5a036729c0..399db99702 100644 --- a/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTestNative.cpp +++ b/tests/src/Interop/StringMarshalling/LPSTR/LPSTRTestNative.cpp @@ -3,6 +3,8 @@ // See the LICENSE file in the project root for more information. #include <xplatform.h> +#include <platformdefines.h> + const char* strManaged = "Managed\0String\0"; size_t lenstrManaged = 7; // the length of strManaged diff --git a/tests/src/Interop/StringMarshalling/LPTSTR/CMakeLists.txt b/tests/src/Interop/StringMarshalling/LPTSTR/CMakeLists.txt index f99a6e5ab7..a4c528bfab 100644 --- a/tests/src/Interop/StringMarshalling/LPTSTR/CMakeLists.txt +++ b/tests/src/Interop/StringMarshalling/LPTSTR/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required (VERSION 2.6) project (LPTSTRTestNative) set(SOURCES LPTSTRTestNative.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (LPTSTRTestNative SHARED ${SOURCES}) target_link_libraries(LPTSTRTestNative ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS LPTSTRTestNative DESTINATION bin)
\ No newline at end of file +install (TARGETS LPTSTRTestNative DESTINATION bin) diff --git a/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestNative.cpp b/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestNative.cpp index 833c3166d8..73960006c1 100644 --- a/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestNative.cpp +++ b/tests/src/Interop/StringMarshalling/LPTSTR/LPTSTRTestNative.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include <xplatform.h> +#include <platformdefines.h> const WCHAR* strManaged = W("Managed\0String\0"); size_t lenstrManaged = 7; // the length of strManaged diff --git a/tests/src/Interop/StringMarshalling/UTF8/CMakeLists.txt b/tests/src/Interop/StringMarshalling/UTF8/CMakeLists.txt index 37c952df10..03b47546e4 100644 --- a/tests/src/Interop/StringMarshalling/UTF8/CMakeLists.txt +++ b/tests/src/Interop/StringMarshalling/UTF8/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required (VERSION 2.6) project (UTF8TestNative) set(SOURCES UTF8TestNative.cpp ) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") # add the executable add_library (UTF8TestNative SHARED ${SOURCES}) target_link_libraries(UTF8TestNative ${LINK_LIBRARIES_ADDITIONAL}) # add the install targets -install (TARGETS UTF8TestNative DESTINATION bin)
\ No newline at end of file +install (TARGETS UTF8TestNative DESTINATION bin) diff --git a/tests/src/Interop/StringMarshalling/UTF8/UTF8TestNative.cpp b/tests/src/Interop/StringMarshalling/UTF8/UTF8TestNative.cpp index 3dde7f8139..0192d76e39 100644 --- a/tests/src/Interop/StringMarshalling/UTF8/UTF8TestNative.cpp +++ b/tests/src/Interop/StringMarshalling/UTF8/UTF8TestNative.cpp @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. #include <xplatform.h> +#include <platformdefines.h> const int NSTRINGS = 6; #ifdef _WIN32 @@ -281,4 +282,4 @@ extern "C" DLL_EXPORT void __cdecl Utf8DelegateAsParameter(Callback managedCallb managedCallback(pszNative, i); free_utf8_string(pszNative); } -}
\ No newline at end of file +} diff --git a/tests/src/Interop/StringMarshalling/VBByRefStr/CMakeLists.txt b/tests/src/Interop/StringMarshalling/VBByRefStr/CMakeLists.txt index 39d1f77133..f736342844 100644 --- a/tests/src/Interop/StringMarshalling/VBByRefStr/CMakeLists.txt +++ b/tests/src/Interop/StringMarshalling/VBByRefStr/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (VBByRefStrNative) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES VBByRefStrNative.cpp ) # add the executable diff --git a/tests/src/Interop/StructMarshalling/PInvoke/CMakeLists.txt b/tests/src/Interop/StructMarshalling/PInvoke/CMakeLists.txt index 860c2e8c80..5ea19af664 100644 --- a/tests/src/Interop/StructMarshalling/PInvoke/CMakeLists.txt +++ b/tests/src/Interop/StructMarshalling/PInvoke/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (MarshalStructAsParam) -include_directories(${INC_PLATFORM_DIR}) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") set(SOURCES MarshalStructAsParamDLL.cpp) # add the executable diff --git a/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/CMakeLists.txt b/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/CMakeLists.txt index 7278b94877..2f4907271d 100644 --- a/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/CMakeLists.txt +++ b/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalExpStruct/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required (VERSION 2.6) project (ReversePInvokeNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES ExpStructAsParamNative.cpp ) diff --git a/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/CMakeLists.txt b/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/CMakeLists.txt index 0b3aef3904..397a73b673 100644 --- a/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/CMakeLists.txt +++ b/tests/src/Interop/StructMarshalling/ReversePInvoke/MarshalSeqStruct/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required (VERSION 2.6) project (SeqPInvokeNative) include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") -include_directories(${INC_PLATFORM_DIR}) set(SOURCES SeqStructDelRevPInvokeNative.cpp ) diff --git a/tests/src/Interop/common/types.h b/tests/src/Interop/common/types.h deleted file mode 100755 index cabcd425f2..0000000000 --- a/tests/src/Interop/common/types.h +++ /dev/null @@ -1,103 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -#ifndef _INTEROP_TYPES__H -#define _INTEROP_TYPES__H - -#include <stddef.h> - -#undef INT_MIN -#define INT_MIN (-2147483647 - 1) - -typedef char16_t WCHAR; -typedef int BOOL; -typedef WCHAR *LPWSTR, *PWSTR; -typedef const WCHAR *LPCWSTR, *PCWSTR; - -typedef char* LPSTR; -typedef const char* LPCSTR; -typedef void* FARPROC; -typedef void* HANDLE; -typedef void* HMODULE; -typedef int error_t; -typedef void* LPVOID; -typedef unsigned char BYTE; -typedef WCHAR OLECHAR; -typedef ptrdiff_t INT_PTR; -typedef size_t UINT_PTR; - -typedef unsigned long long ULONG64; -typedef unsigned long long LONG64; -typedef double DOUBLE; -typedef float FLOAT; -typedef int INT, *LPINT; -typedef unsigned int UINT; -typedef int LONG; -typedef char CHAR, *PCHAR; -typedef unsigned short USHORT; -typedef signed short SHORT; -typedef unsigned short WORD, *PWORD, *LPWORD; -typedef int LONG; - -typedef size_t SIZE_T; - -typedef union tagCY { - struct { -#if BIGENDIAN - LONG Hi; - LONG Lo; -#else - LONG Lo; - LONG Hi; -#endif - }; - LONG64 int64; -} CY, *LPCY; - -typedef CY CURRENCY; - -typedef struct tagDEC { - // Decimal.cs treats the first two shorts as one long - // And they seriable the data so we need to little endian - // seriliazation - // The wReserved overlaps with Variant's vt member -#if BIGENDIAN - union { - struct { - BYTE sign; - BYTE scale; - }; - USHORT signscale; - }; - USHORT wReserved; -#else - USHORT wReserved; - union { - struct { - BYTE scale; - BYTE sign; - }; - USHORT signscale; - }; -#endif - LONG Hi32; - union { - struct { - LONG Lo32; - LONG Mid32; - }; - ULONG64 Lo64; - }; -} DECIMAL, *LPDECIMAL; - - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#endif //_INTEROP_TYPES__H diff --git a/tests/src/Interop/common/xplatform.h b/tests/src/Interop/common/xplatform.h index a051692df6..e5ea13606a 100644 --- a/tests/src/Interop/common/xplatform.h +++ b/tests/src/Interop/common/xplatform.h @@ -5,120 +5,89 @@ #ifndef __XPLAT_H__ #define __XPLAT_H__ -#ifdef _MSC_VER -// Our tests don't care about secure CRT -#define _CRT_SECURE_NO_WARNINGS 1 -#endif +#include <platformdefines.h> -// Ensure that both UNICODE and _UNICODE are set. -#ifndef _UNICODE -#define _UNICODE -#endif -#ifndef UNICODE -#define UNICODE -#endif +#ifndef WINDOWS -// common headers -#include <stdio.h> -#include <memory.h> -#include <stdlib.h> +#include <stddef.h> -// This macro is used to standardize the wide character string literals between UNIX and Windows. -// Unix L"" is UTF32, and on windows it's UTF16. Because of built-in assumptions on the size -// of string literals, it's important to match behaviour between Unix and Windows. Unix will be defined -// as u"" (char16_t) -#ifdef _WIN32 -#define W(str) L##str -#else // !_WIN32 -#define W(str) u##str -#endif //_WIN32 +#undef INT_MIN +#define INT_MIN (-2147483647 - 1) +typedef ptrdiff_t INT_PTR; +typedef size_t UINT_PTR; -// include -#ifdef _WIN32 - #define NOMINMAX - #include <windows.h> - #include <combaseapi.h> +typedef unsigned long long ULONG64; +typedef unsigned long long LONG64; +typedef double DOUBLE; +typedef float FLOAT; +typedef int INT, *LPINT; +typedef unsigned int UINT; +typedef char CHAR, *PCHAR; +typedef unsigned short USHORT; +typedef signed short SHORT; +typedef unsigned short WORD, *PWORD, *LPWORD; +typedef int LONG; - #ifndef snprintf - #define snprintf _snprintf - #endif //snprintf +typedef size_t SIZE_T; +typedef union tagCY { + struct { +#if BIGENDIAN + LONG Hi; + LONG Lo; #else - #include "types.h" + LONG Lo; + LONG Hi; #endif -#include <wchar.h> - -// dllexport -#if defined _WIN32 -#define DLL_EXPORT __declspec(dllexport) - -#else //!_Win32 - -#if __GNUC__ >= 4 -#define DLL_EXPORT __attribute__ ((visibility ("default"))) + }; + LONG64 int64; +} CY, *LPCY; + +typedef CY CURRENCY; + +typedef struct tagDEC { + // Decimal.cs treats the first two shorts as one long + // And they seriable the data so we need to little endian + // seriliazation + // The wReserved overlaps with Variant's vt member +#if BIGENDIAN + union { + struct { + BYTE sign; + BYTE scale; + }; + USHORT signscale; + }; + USHORT wReserved; #else -#define DLL_EXPORT + USHORT wReserved; + union { + struct { + BYTE scale; + BYTE sign; + }; + USHORT signscale; + }; #endif - -#endif //_WIN32 - -// Calling conventions -#ifndef _WIN32 - -#define STDMETHODCALLTYPE - -#if __i386__ -#define __stdcall __attribute__((stdcall)) -#define __cdecl __attribute__((cdecl)) -#else -#define __stdcall -#define __cdecl + LONG Hi32; + union { + struct { + LONG Lo32; + LONG Mid32; + }; + ULONG64 Lo64; + }; +} DECIMAL, *LPDECIMAL; + + +#ifndef TRUE +#define TRUE 1 #endif -#endif //!_WIN32 -inline void *CoreClrAlloc(size_t cb) -{ -#ifdef _WIN32 - return ::CoTaskMemAlloc(cb); -#else - return ::malloc(cb); -#endif -} - -inline void CoreClrFree(void *p) -{ -#ifdef _WIN32 - return ::CoTaskMemFree(p); -#else - return ::free(p); -#endif -} - -inline void *CoreClrBstrAlloc(size_t cb) -{ -#ifdef _WIN32 - // A null is automatically applied in the SysAllocStringByteLen API. - // Remove a single OLECHAR for the implied null. - // https://docs.microsoft.com/en-us/previous-versions/windows/desktop/api/oleauto/nf-oleauto-sysallocstringbytelen - if (cb >= sizeof(OLECHAR)) - cb -= sizeof(OLECHAR); - - return ::SysAllocStringByteLen(nullptr, static_cast<UINT>(cb)); -#else - return nullptr; +#ifndef FALSE +#define FALSE 0 #endif -} - -inline void CoreClrBstrFree(void *p) -{ -#ifdef _WIN32 - return ::SysFreeString((BSTR)p); -#endif -} - -// redirected types not-windows only -#ifndef _WIN32 class IUnknown { @@ -128,76 +97,6 @@ public: virtual unsigned long Release() = 0; }; -// function implementation -size_t strncpy_s(char* strDest, size_t numberOfElements, const char *strSource, size_t count) -{ - // NOTE: Need to pass count + 1 since strncpy_s does not count null, - // while snprintf does. - return snprintf(strDest, count + 1, "%s", strSource); -} - -size_t strcpy_s(char *dest, size_t n, char const *src) -{ - return snprintf(dest, n, "%s", src); -} - -#ifndef wcslen -size_t wcslen(const WCHAR *str) -{ - size_t len = 0; - while ('\0' != *(str + len)) len++; - return len; -} -#endif - -int wcsncpy_s(LPWSTR strDestination, size_t size1, LPCWSTR strSource, size_t size2) -{ - // copy sizeInBytes bytes of strSource into strDestination - if (NULL == strDestination || NULL == strSource) return 1; - - int cnt = 0; - while (cnt < size1 && '\0' != strSource[cnt]) - { - strDestination[cnt] = strSource[cnt]; - cnt++; - } - - strDestination[cnt] = '\0'; - return 0; -} - -int wcsncpy_s(LPWSTR strDestination, size_t size1, LPCWSTR strSource) -{ - return wcsncpy_s(strDestination, size1, strSource, 0); -} - -int wcsncmp(LPCWSTR str1, LPCWSTR str2,size_t len) -{ - // < 0 str1 less than str2 - // 0 str1 identical to str2 - // > 0 str1 greater than str2 - if (NULL == str1 && NULL != str2) return -1; - if (NULL != str1 && NULL == str2) return 1; - if (NULL == str1 && NULL == str2) return 0; - - while (*str1 == *str2 && '\0' != *str1 && '\0' != *str2 && len--!= 0) - { - str1++; - str2++; - } - - if ('\0' == *str1 && '\0' == *str2) return 0; - if ('\0' != *str1) return -1; - if ('\0' != *str2) return 1; - - return (*str1 > *str2) ? 1 : -1; -} - -int wmemcmp(LPCWSTR str1, LPCWSTR str2,size_t len) -{ - return wcsncmp(str1, str2, len); -} - #define DECIMAL_NEG ((BYTE)0x80) #define DECIMAL_SCALE(dec) ((dec).u.u.scale) #define DECIMAL_SIGN(dec) ((dec).u.u.sign) |