* 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
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;
#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){
return bstr;
}
-BSTR TP_SysAllocStringByteLen(LPCSTR psz, size_t len)
+BSTR CoreClrBStrAlloc(LPCSTR psz, size_t len)
{
#ifdef WINDOWS
return SysAllocStringByteLen(psz, (UINT)len);
if (FAILED(CbSysStringSize(len, TRUE, &cbTotal)))
return NULL;
- bstr = (BSTR)TP_CoTaskMemAlloc(cbTotal);
+ bstr = (BSTR)CoreClrAlloc(cbTotal);
if (bstr != NULL) {
#if defined(_WIN64)
#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
}
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);
+}
#include <stdio.h>
+#include <memory.h>
#include <stdlib.h>
#include <string.h>
#include <cstdint>
#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";"
#define WINAPI __stdcall
#endif
+#ifndef STDMETHODCALLTYPE
+#define STDMETHODCALLTYPE
+#endif
+
#ifndef _MSC_VER
#if __i386__
#define __stdcall __attribute__((stdcall))
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;
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
//
#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
#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
#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
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
//
#include <xplatform.h>
+#include <platformdefines.h>
#include <stdio.h>
#include <stdlib.h>
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
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
#include <xplatform.h>
#include <oleauto.h>
#include <algorithm>
-#include <platformdefines.h>
#define RETURN_IF_FAILED(x) if(FAILED(hr = (x))) { return hr; }
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;
#include <stdlib.h>
#include <locale.h>
#include <xplatform.h>
+#include <platformdefines.h>
#pragma warning( push )
#pragma warning( disable : 4996)
}
CoreClrFree(pStr);
}
-#pragma warning( pop )
\ No newline at end of file
+#pragma warning( pop )
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)
// See the LICENSE file in the project root for more information.
#include "ClientTests.h"
+#include <platformdefines.h>
#include <cstdint>
#include <limits>
// See the LICENSE file in the project root for more information.
#include "ClientTests.h"
+#include <platformdefines.h>
#include <vector>
#include <sstream>
};
// BSTR string
- using BStr = AnyStr<OLECHAR, &CoreClrBstrAlloc, &CoreClrBstrFree>;
+ using BStr = AnyStr<OLECHAR, &CoreClrBStrAlloc, &CoreClrBStrFree>;
// Wide string
using WStr = AnyStr<WCHAR, &CoreClrAlloc, &CoreClrFree>;
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)
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)
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
-#include <xplatform.h>
+#include <platformdefines.h>
#pragma warning( push )
#pragma warning( disable : 4996)
extern "C" DLL_EXPORT int __cdecl Sum(int a, int b)
{
return a + b;
-}
\ No newline at end of file
+}
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)
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
-#include <xplatform.h>
+#include <platformdefines.h>
#pragma warning( push )
#pragma warning( disable : 4996)
extern "C" DLL_EXPORT int __cdecl Sum(int a, int b)
{
return a + b;
-}
\ No newline at end of file
+}
cmake_minimum_required (VERSION 2.6)
project (ExecInDefAppDomDll)
+include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
set(SOURCES ExecInDefAppDomDll.cpp )
# add the executable
// See the LICENSE file in the project root for more information.
#include <xplatform.h>
+#include <platformdefines.h>
#ifdef WINDOWS
#include "mscoree.h"
return E_FAIL;
}
-#endif // WINDOWS
\ No newline at end of file
+#endif // WINDOWS
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
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)
-# Settings for all Interop native assets
\ No newline at end of file
+# Settings for all Interop native assets
+
+include_directories(${INC_PLATFORM_DIR})
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
// 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))
{
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
cmake_minimum_required (VERSION 2.6)
project (NativeCallableDll)
+include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
set(SOURCES NativeCallableDll.cpp )
# add the executable
// 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);
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
// 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)
{
-#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
)
-#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
)
cmake_minimum_required (VERSION 2.6)
project (ArrayWithOffsetNative)
include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
-include_directories(${INC_PLATFORM_DIR})
set(SOURCES
ArrayWithOffsetNative.cpp
)
cmake_minimum_required (VERSION 2.6)
project (AsAnyNative)
include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
-include_directories(${INC_PLATFORM_DIR})
set(SOURCES
AsAnyNative.cpp
)
cmake_minimum_required (VERSION 2.6)
project (LCIDNative)
include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
-include_directories(${INC_PLATFORM_DIR})
set(SOURCES
LCIDNative.cpp
)
#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)
-#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
)
-#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
)
-#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
)
cmake_minimum_required (VERSION 2.6)
project (NativeDateTime)
include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
-include_directories(${INC_PLATFORM_DIR})
set(SOURCES
NativeDateTime.cpp
)
-#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
)
-#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
)
-#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
)
-#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
)
cmake_minimum_required (VERSION 2.6)
project (DllImportPath)
include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
-include_directories(${INC_PLATFORM_DIR})
set(SOURCES
DllImportPathNative.cpp
)
#include <stdio.h>
#include <xplatform.h>
+#include <platformdefines.h>
LPCWSTR strManaged = W("Managed\0String\0");
LPCWSTR strNative = W(" Native\0String\0");
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)
// 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;
-#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
)
#include <stdio.h>
#include <xplatform.h>
+#include <platformdefines.h>
const int intManaged = 1000;
const int intNative = 2000;
-#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
// 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()
{
-#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
)
#include <windows.h>
#include <Objbase.h>
#include <xplatform.h>
+#include <platformdefines.h>
//
// Standard function to call the managed COM.
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
#include <stdio.h>
#include <xplatform.h>
+#include <platformdefines.h>
int intManaged = 1000;
int intNative = 2000;
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
// 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)
{
-#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
)
-#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
)
#include <windows.h>
#include <oleauto.h>
#include <xplatform.h>
+#include <platformdefines.h>
#include "StructDefs.h"
/////////////////////////////////Internal Helper Methods
-#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
)
#include <stdlib.h>
#include <windows.h>
#include <xplatform.h>
+#include <platformdefines.h>
bool g_myResourceReleaseMethodCalled = false;
#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
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
)
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
)
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
)
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
)
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
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
// See the LICENSE file in the project root for more information.
#include <xplatform.h>
+#include <platformdefines.h>
#include <stdio.h>
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})
#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)
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)
+// 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>
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
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)
// See the LICENSE file in the project root for more information.
#include <xplatform.h>
+#include <platformdefines.h>
#include <stdio.h>
#include <stdlib.h>
extern "C" DLL_EXPORT DelegatePInvoke_Stdcall __stdcall DelegatePinvoke_Stdcall()
{
return MarshalRefCharArray_Stdcall;
-}
\ No newline at end of file
+}
cmake_minimum_required (VERSION 2.6)
project (RefIntNative)
+include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
set(SOURCES RefIntNative.cpp )
# add the executable
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)
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
cmake_minimum_required (VERSION 2.6)
project (SizeConstNative)
+include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
set(SOURCES SizeConstNative.cpp)
# add the executable
// 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;
printf("\tThe length of Actual:%zd\n", len);
}
- return TP_SysAllocStringByteLen(strReturn, lenstrReturn);
+ return CoreClrBStrAlloc(strReturn, lenstrReturn);
}
//Test Method2
*((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)
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)
}
//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);
}
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
// 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");
}
//Allocate New
- TP_SysFreeString(*s);
+ CoreClrBStrFree(*s);
*s = TP_SysAllocString(strNative);
//Return
return FALSE;
}
- TP_SysFreeString(str);
+ CoreClrBStrFree(str);
return TRUE;
}
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);
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);
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
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})
// 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
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)
// 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
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)
// See the LICENSE file in the project root for more information.
#include <xplatform.h>
+#include <platformdefines.h>
const int NSTRINGS = 6;
#ifdef _WIN32
managedCallback(pszNative, i);
free_utf8_string(pszNative);
}
-}
\ No newline at end of file
+}
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
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
cmake_minimum_required (VERSION 2.6)
project (ReversePInvokeNative)
include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
-include_directories(${INC_PLATFORM_DIR})
set(SOURCES
ExpStructAsParamNative.cpp
)
cmake_minimum_required (VERSION 2.6)
project (SeqPInvokeNative)
include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake")
-include_directories(${INC_PLATFORM_DIR})
set(SOURCES
SeqStructDelRevPInvokeNative.cpp
)
+++ /dev/null
-// 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
#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
{
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)