extern "C" {
#endif
-#if defined (PLATFORM_UNIX)
// 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
#define QUOTE_MACRO_u_HELPER(x) u###x
#define QUOTE_MACRO_u(x) QUOTE_MACRO_u_HELPER(x)
-#endif
-
#include <pal_char16.h>
#include <pal_error.h>
#include <pal_mstypes.h>
#define GetLogicalProcessorCacheSizeFromOS PAL_GetLogicalProcessorCacheSizeFromOS
-#ifdef PLATFORM_UNIX
-
/* PAL_CS_NATIVE_DATA_SIZE is defined as sizeof(PAL_CRITICAL_SECTION_NATIVE_DATA) */
#if defined(__APPLE__) && defined(__i386__)
#error PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
#endif
-#endif // PLATFORM_UNIX
-
//
typedef struct _CRITICAL_SECTION {
PVOID DebugInfo;
HANDLE LockSemaphore;
ULONG_PTR SpinCount;
-#ifdef PLATFORM_UNIX
BOOL bInternal;
volatile DWORD dwInitState;
union CSNativeDataStorage
BYTE rgNativeDataStorage[PAL_CS_NATIVE_DATA_SIZE];
VOID * pvAlign; // make sure the storage is machine-pointer-size aligned
} csnds;
-#endif // PLATFORM_UNIX
} CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
PALIMPORT VOID PALAPI EnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
/* Some C runtime functions needs to be reimplemented by the PAL.
To avoid name collisions, those functions have been renamed using
defines */
-#ifdef PLATFORM_UNIX
#ifndef PAL_STDCPP_COMPAT
#define exit PAL_exit
#define atexit PAL_atexit
#endif // _AMD64_
#endif // !PAL_STDCPP_COMPAT
-#endif // PLATFORM_UNIX
#ifndef _CONST_RETURN
#ifdef __cplusplus
#if defined(_MSC_VER)
#define alloca _alloca
-#elif defined(PLATFORM_UNIX)
-#define _alloca alloca
#else
-// MingW
-#define _alloca __builtin_alloca
-#define alloca __builtin_alloca
+#define _alloca alloca
#endif //_MSC_VER
-#if defined(__GNUC__) && defined(PLATFORM_UNIX)
#define alloca __builtin_alloca
-#endif // __GNUC__
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
// Platform-specific library naming
//
-#ifdef PLATFORM_UNIX
#ifdef __APPLE__
#define MAKEDLLNAME_W(name) u"lib" name u".dylib"
#define MAKEDLLNAME_A(name) "lib" name ".dylib"
#define MAKEDLLNAME_W(name) u"lib" name u".so"
#define MAKEDLLNAME_A(name) "lib" name ".so"
#endif
-#else // PLATFORM_UNIX
-#define MAKEDLLNAME_W(name) name L".dll"
-#define MAKEDLLNAME_A(name) name ".dll"
-#endif // PLATFORM_UNIX
#ifdef UNICODE
#define MAKEDLLNAME(x) MAKEDLLNAME_W(x)
// vc++, for whom wchar_t is already a typedef instead of a built-in.
#ifndef PAL_STDCPP_COMPAT
-#if defined (PLATFORM_UNIX) && defined(__GNUC__)
#undef wchar_t
#undef __WCHAR_TYPE__
#define __WCHAR_TYPE__ __wchar_16_cpp__
#define wchar_t __wchar_16_cpp__
-#endif // PLATFORM_UNIX
// Set up the wchar_t type (which got preprocessed to __wchar_16_cpp__).
// In C++11, the standard gives us char16_t, which is what we want (and matches types with u"")
// **** WARNING: Linking C and C++ objects will break with -fstrict-aliasing with GCC/Clang
// due to conditional typedef
#if !defined(_WCHAR_T_DEFINED) || !defined(_MSC_VER)
-#if defined (PLATFORM_UNIX)
#if defined(__cplusplus)
#undef __WCHAR_TYPE__
#define __WCHAR_TYPE__ char16_t
#define __WCHAR_TYPE__ unsigned short
typedef unsigned short wchar_t;
#endif // __cplusplus
-#endif // PLATFORM_UNIX
+
#ifndef _WCHAR_T_DEFINED
#define _WCHAR_T_DEFINED
#endif // !_WCHAR_T_DEFINED
typedef void VOID;
-#ifndef PLATFORM_UNIX
-typedef long LONG;
-typedef unsigned long ULONG;
-#else
typedef int LONG; // NOTE: diff from windows.h, for LP64 compat
typedef unsigned int ULONG; // NOTE: diff from windows.h, for LP64 compat
-#endif
typedef __int64 LONGLONG;
typedef unsigned __int64 ULONGLONG;
typedef char *PSZ;
typedef ULONGLONG DWORDLONG;
-#ifndef PLATFORM_UNIX
-typedef unsigned long DWORD;
-#else
typedef unsigned int DWORD; // NOTE: diff from windows.h, for LP64 compat
-#endif
-
typedef unsigned int DWORD32, *PDWORD32;
typedef int BOOL;
#endif
#endif // _AMD64_
-#ifndef FEATURE_PAL
-
-#ifdef _WIN64
-typedef unsigned __int64 size_t;
-typedef unsigned __int64 UINT_PTR;
-typedef unsigned __int64 ULONG_PTR;
-typedef unsigned __int64 DWORD_PTR;
-typedef unsigned __int64 SIZE_T;
-#else
-typedef __w64 unsigned int size_t;
-typedef __w64 unsigned int UINT_PTR;
-typedef __w64 unsigned long ULONG_PTR;
-typedef __w64 unsigned long DWORD_PTR;
-typedef __w64 unsigned long SIZE_T;
-#endif
-typedef char CHAR;
-typedef int INT;
-typedef long LONG;
-typedef unsigned char UCHAR;
-typedef unsigned short USHORT;
-typedef unsigned short WORD;
-typedef unsigned int UINT;
-typedef unsigned long ULONG;
-typedef unsigned long DWORD;
-typedef unsigned __int64 ULONGLONG;
-
-
-typedef LONG HRESULT;
-
-#ifndef SUCCEEDED
-#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
-#endif
-
-#ifndef FAILED
-#define FAILED(hr) (((HRESULT)(hr)) < 0)
-#endif
-
-#define S_OK ((HRESULT)0x00000000L)
-
-#endif // !FEATURE_PAL
-
#define INTSAFE_E_ARITHMETIC_OVERFLOW ((HRESULT)0x80070216L) // 0x216 = 534 = ERROR_ARITHMETIC_OVERFLOW
#ifndef LOWORD
#define _ReturnAddress() __builtin_return_address(0)
-#ifdef PLATFORM_UNIX
#define DIRECTORY_SEPARATOR_CHAR_A '/'
#define DIRECTORY_SEPARATOR_CHAR_W W('/')
#define DIRECTORY_SEPARATOR_STR_A "/"
#define PATH_SEPARATOR_CHAR_W W(':')
#define PATH_SEPARATOR_STR_W W(":")
#define VOLUME_SEPARATOR_CHAR_W W('/')
-#else // PLATFORM_UNIX
-#define DIRECTORY_SEPARATOR_CHAR_A '\\'
-#define DIRECTORY_SEPARATOR_CHAR_W W('\\')
-#define DIRECTORY_SEPARATOR_STR_A "\\"
-#define DIRECTORY_SEPARATOR_STR_W W("\\")
-#define PATH_SEPARATOR_CHAR_W W(';')
-#define PATH_SEPARATOR_STR_W W(";")
-#define VOLUME_SEPARATOR_CHAR_W W(':')
-#endif // PLATFORM_UNIX
#ifndef IMAGE_IMPORT_DESC_FIELD
#define IMAGE_IMPORT_DESC_FIELD(img, f) ((img).u.f)
#ifndef __VSASSERT_H__
#define __VSASSERT_H__
-#ifndef FEATURE_PAL
-#error "FEATURE_PAL must be defined for this file"
-#else // FEATURE_PAL
-
#define VSASSERT(e, szMsg) \
do { \
if (!(e)) { \
#define VsIgnoreAllocs(f)
-#endif // FEATURE_PAL
#endif // __VSASSERT_H__
#pragma once
#endif
-#if defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-#define _NATIVE_WCHAR_T_DEFINED
-#endif // defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-
-#if defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-#define _vsnprintf vsnprintf
-#endif // defined(PLATFORM_UNIX) && !defined (FEATURE_PAL)
-
#include <stdio.h> // for _vsnprintf, getc, getwc
#include <string.h> // for memset
#include <stdarg.h> // for va_start, etc.
#define _WCHAR_T_DEFINED
#endif
-#ifndef FEATURE_PAL
-#ifndef _HRESULT_DEFINED
-#define _HRESULT_DEFINED
-typedef LONG HRESULT;
-#endif // !_HRESULT_DEFINED
-#endif // !FEATURE_PAL
-
#ifndef SUCCEEDED
#define SUCCEEDED(hr) ((HRESULT)(hr) >= 0)
#endif
STRSAFEAPI StringLengthWorkerW(const WCHAR* psz, size_t cchMax, size_t* pcch);
#endif // STRSAFE_INLINE
-#ifndef STRSAFE_LIB_IMPL
-#ifndef FEATURE_PAL
-// these functions are always inline
-STRSAFE_INLINE_API StringGetsExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-STRSAFE_INLINE_API StringGetsExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-#endif // !FEATURE_PAL
-#endif
-
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCopyW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCopyW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCopyExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCopyExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCopyNW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchSrc)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCopyNW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbSrc)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCopyNExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCopyNExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCatW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCatW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCatExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCatExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCatNW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCatNW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbMaxAppend)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchCatNExW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbCatNExW(WCHAR* pszDest, size_t cbDest, const WCHAR* pszSrc, size_t cbMaxAppend, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
--*/
-#ifndef FEATURE_PAL
-#ifndef STRSAFE_LIB_IMPL
-STRSAFE_INLINE_API StringCchGetsA(char* pszDest, size_t cchDest);
-STRSAFE_INLINE_API StringCchGetsW(WCHAR* pszDest, size_t cchDest);
-#ifdef UNICODE
-#define StringCchGets StringCchGetsW
-#else
-#define StringCchGets StringCchGetsA
-#endif // !UNICODE
-
-STRSAFE_INLINE_API StringCchGetsA(char* pszDest, size_t cchDest)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1
- cbDest = cchDest * sizeof(char);
-
- hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, NULL, NULL, 0);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringCchGetsW(WCHAR* pszDest, size_t cchDest)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(WCHAR) since cchDest < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- cbDest = cchDest * sizeof(WCHAR);
-
- hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, NULL, NULL, 0);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // !STRSAFE_NO_CCH_FUNCTIONS
-#endif // !STRSAFE_LIB_IMPL
-#endif // !FEATURE_PAL
#ifndef STRSAFE_NO_CB_FUNCTIONS
/*++
--*/
-#ifndef FEATURE_PAL
-#ifndef STRSAFE_LIB_IMPL
-STRSAFE_INLINE_API StringCbGetsA(char* pszDest, size_t cbDest);
-STRSAFE_INLINE_API StringCbGetsW(WCHAR* pszDest, size_t cbDest);
-#ifdef UNICODE
-#define StringCbGets StringCbGetsW
-#else
-#define StringCbGets StringCbGetsA
-#endif // !UNICODE
-
-STRSAFE_INLINE_API StringCbGetsA(char* pszDest, size_t cbDest)
-{
- HRESULT hr;
- size_t cchDest;
-
- // convert to count of characters
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, NULL, NULL, 0);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringCbGetsW(WCHAR* pszDest, size_t cbDest)
-{
- HRESULT hr;
- size_t cchDest;
-
- // convert to count of characters
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, NULL, NULL, 0);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // !STRSAFE_NO_CB_FUNCTIONS
-#endif // !STRSAFE_LIB_IMPL
-#endif // !FEATURE_PAL
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
--*/
-#ifndef FEATURE_PAL
-#ifndef STRSAFE_LIB_IMPL
-STRSAFE_INLINE_API StringCchGetsExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-STRSAFE_INLINE_API StringCchGetsExW(WCHAR* pszDest, size_t cchDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags);
-#ifdef UNICODE
-#define StringCchGetsEx StringCchGetsExW
-#else
-#define StringCchGetsEx StringCchGetsExA
-#endif // !UNICODE
-
-STRSAFE_INLINE_API StringCchGetsExA(char* pszDest, size_t cchDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(char) since cchDest < STRSAFE_MAX_CCH and sizeof(char) is 1
- cbDest = cchDest * sizeof(char);
-
- hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags);
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringCchGetsExW(WCHAR* pszDest, size_t cchDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- size_t cbDest;
-
- // safe to multiply cchDest * sizeof(WCHAR) since cchDest < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- cbDest = cchDest * sizeof(WCHAR);
-
- hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, pcchRemaining, dwFlags);
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // !STRSAFE_NO_CCH_FUNCTIONS
-#endif // !STRSAFE_LIB_IMPL
-#endif // !FEATURE_PAL
#ifndef STRSAFE_NO_CB_FUNCTIONS
/*++
--*/
-#ifndef FEATURE_PAL
-#ifndef STRSAFE_LIB_IMPL
-STRSAFE_INLINE_API StringCbGetsExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pbRemaining, unsigned long dwFlags);
-STRSAFE_INLINE_API StringCbGetsExW(WCHAR* pszDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags);
-#ifdef UNICODE
-#define StringCbGetsEx StringCbGetsExW
-#else
-#define StringCbGetsEx StringCbGetsExA
-#endif // !UNICODE
-
-STRSAFE_INLINE_API StringCbGetsExA(char* pszDest, size_t cbDest, char** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(char);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringGetsExWorkerA(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags);
- }
-
- if (SUCCEEDED(hr) ||
- (hr == STRSAFE_E_INSUFFICIENT_BUFFER) ||
- (hr == STRSAFE_E_END_OF_FILE))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(char) since cchRemaining < STRSAFE_MAX_CCH and sizeof(char) is 1
- *pcbRemaining = (cchRemaining * sizeof(char)) + (cbDest % sizeof(char));
- }
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringCbGetsExW(WCHAR* pszDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcbRemaining, unsigned long dwFlags)
-{
- HRESULT hr;
- size_t cchDest;
- size_t cchRemaining = 0;
-
- cchDest = cbDest / sizeof(WCHAR);
-
- if (cchDest > STRSAFE_MAX_CCH)
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- hr = StringGetsExWorkerW(pszDest, cchDest, cbDest, ppszDestEnd, &cchRemaining, dwFlags);
- }
-
- if (SUCCEEDED(hr) ||
- (hr == STRSAFE_E_INSUFFICIENT_BUFFER) ||
- (hr == STRSAFE_E_END_OF_FILE))
- {
- if (pcbRemaining)
- {
- // safe to multiply cchRemaining * sizeof(WCHAR) since cchRemaining < STRSAFE_MAX_CCH and sizeof(WCHAR) is 2
- *pcbRemaining = (cchRemaining * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR));
- }
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // !STRSAFE_NO_CB_FUNCTIONS
-#endif // !STRSAFE_LIB_IMPL
-#endif // !FEATURE_PAL
#ifndef STRSAFE_NO_CCH_FUNCTIONS
/*++
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCchLengthW(const WCHAR* psz, size_t cchMax, size_t* pcch)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CCH_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCbLengthW(const WCHAR* psz, size_t cbMax, size_t* pcb)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
#endif // !STRSAFE_NO_CB_FUNCTIONS
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCopyWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr = S_OK;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCopyExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCopyExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCopyNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchSrc)
{
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCopyNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchSrc)
{
HRESULT hr = S_OK;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCopyNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCopyNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCatWorkerA(char* pszDest, size_t cchDest, const char* pszSrc)
{
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCatWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCatExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCatExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCatNWorkerA(char* pszDest, size_t cchDest, const char* pszSrc, size_t cchMaxAppend)
{
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCatNWorkerW(WCHAR* pszDest, size_t cchDest, const WCHAR* pszSrc, size_t cchMaxAppend)
{
HRESULT hr;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringCatNExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, const char* pszSrc, size_t cchMaxAppend, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringCatNExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, const WCHAR* pszSrc, size_t cchMaxAppend, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
{
HRESULT hr = S_OK;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
STRSAFEAPI StringLengthWorkerA(const char* psz, size_t cchMax, size_t* pcch)
{
return hr;
}
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
STRSAFEAPI StringLengthWorkerW(const WCHAR* psz, size_t cchMax, size_t* pcch)
{
HRESULT hr = S_OK;
return hr;
}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
#endif // STRSAFE_INLINE
-#ifndef STRSAFE_LIB_IMPL
-#ifndef FEATURE_PAL
-STRSAFE_INLINE_API StringGetsExWorkerA(char* pszDest, size_t cchDest, size_t cbDest, char** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr = S_OK;
- char* pszDestEnd = pszDest;
- size_t cchRemaining = 0;
-
- // ASSERT(cbDest == (cchDest * sizeof(char)) ||
- // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char)));
-
- // only accept valid flags
- if (dwFlags & (~STRSAFE_VALID_FLAGS))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- if (dwFlags & STRSAFE_IGNORE_NULLS)
- {
- if (pszDest == NULL)
- {
- if ((cchDest != 0) || (cbDest != 0))
- {
- // NULL pszDest and non-zero cchDest/cbDest is invalid
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- }
- }
-
- if (SUCCEEDED(hr))
- {
- if (cchDest <= 1)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- if (cchDest == 1)
- {
- *pszDestEnd = '\0';
- }
-
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- else
- {
- char ch;
-
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- while ((cchRemaining > 1) && (ch = (char)getc(stdin)) != '\n')
- {
- if (ch == EOF)
- {
- if (pszDestEnd == pszDest)
- {
- // we failed to read anything from stdin
- hr = STRSAFE_E_END_OF_FILE;
- }
- break;
- }
-
- *pszDestEnd = ch;
-
- pszDestEnd++;
- cchRemaining--;
- }
-
- if (cchRemaining > 0)
- {
- // there is extra room
- if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
- {
- memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(char)) + (cbDest % sizeof(char)));
- }
- }
-
- *pszDestEnd = '\0';
- }
- }
- }
-
- if (FAILED(hr))
- {
- if (pszDest)
- {
- if (dwFlags & STRSAFE_FILL_ON_FAILURE)
- {
- memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
- if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
- }
- else if (cchDest > 0)
- {
- pszDestEnd = pszDest + cchDest - 1;
- cchRemaining = 1;
-
- // null terminate the end of the string
- *pszDestEnd = '\0';
- }
- }
-
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
- {
- if (cchDest > 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- // null terminate the beginning of the string
- *pszDestEnd = '\0';
- }
- }
- }
- }
-
- if (SUCCEEDED(hr) ||
- (hr == STRSAFE_E_INSUFFICIENT_BUFFER) ||
- (hr == STRSAFE_E_END_OF_FILE))
- {
- if (ppszDestEnd)
- {
- *ppszDestEnd = pszDestEnd;
- }
-
- if (pcchRemaining)
- {
- *pcchRemaining = cchRemaining;
- }
- }
-
- return hr;
-}
-
-#if defined(FEATURE_PAL) || !defined(PLATFORM_UNIX)
-STRSAFE_INLINE_API StringGetsExWorkerW(WCHAR* pszDest, size_t cchDest, size_t cbDest, WCHAR** ppszDestEnd, size_t* pcchRemaining, unsigned long dwFlags)
-{
- HRESULT hr = S_OK;
- WCHAR* pszDestEnd = pszDest;
- size_t cchRemaining = 0;
-
- // ASSERT(cbDest == (cchDest * sizeof(char)) ||
- // cbDest == (cchDest * sizeof(char)) + (cbDest % sizeof(char)));
-
- // only accept valid flags
- if (dwFlags & (~STRSAFE_VALID_FLAGS))
- {
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- else
- {
- if (dwFlags & STRSAFE_IGNORE_NULLS)
- {
- if (pszDest == NULL)
- {
- if ((cchDest != 0) || (cbDest != 0))
- {
- // NULL pszDest and non-zero cchDest/cbDest is invalid
- hr = STRSAFE_E_INVALID_PARAMETER;
- }
- }
- }
-
- if (SUCCEEDED(hr))
- {
- if (cchDest <= 1)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- if (cchDest == 1)
- {
- *pszDestEnd = L'\0';
- }
-
- hr = STRSAFE_E_INSUFFICIENT_BUFFER;
- }
- else
- {
- WCHAR ch;
-
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- while ((cchRemaining > 1) && (ch = (WCHAR)getwc(stdin)) != L'\n')
- {
- if (ch == EOF)
- {
- if (pszDestEnd == pszDest)
- {
- // we failed to read anything from stdin
- hr = STRSAFE_E_END_OF_FILE;
- }
- break;
- }
-
- *pszDestEnd = ch;
-
- pszDestEnd++;
- cchRemaining--;
- }
-
- if (cchRemaining > 0)
- {
- // there is extra room
- if (dwFlags & STRSAFE_FILL_BEHIND_NULL)
- {
- memset(pszDestEnd + 1, STRSAFE_GET_FILL_PATTERN(dwFlags), ((cchRemaining - 1) * sizeof(WCHAR)) + (cbDest % sizeof(WCHAR)));
- }
- }
-
- *pszDestEnd = L'\0';
- }
- }
- }
-
- if (FAILED(hr))
- {
- if (pszDest)
- {
- if (dwFlags & STRSAFE_FILL_ON_FAILURE)
- {
- memset(pszDest, STRSAFE_GET_FILL_PATTERN(dwFlags), cbDest);
-
- if (STRSAFE_GET_FILL_PATTERN(dwFlags) == 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
- }
- else if (cchDest > 0)
- {
- pszDestEnd = pszDest + cchDest - 1;
- cchRemaining = 1;
-
- // null terminate the end of the string
- *pszDestEnd = L'\0';
- }
- }
-
- if (dwFlags & (STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION))
- {
- if (cchDest > 0)
- {
- pszDestEnd = pszDest;
- cchRemaining = cchDest;
-
- // null terminate the beginning of the string
- *pszDestEnd = L'\0';
- }
- }
- }
- }
-
- if (SUCCEEDED(hr) ||
- (hr == STRSAFE_E_INSUFFICIENT_BUFFER) ||
- (hr == STRSAFE_E_END_OF_FILE))
- {
- if (ppszDestEnd)
- {
- *ppszDestEnd = pszDestEnd;
- }
-
- if (pcchRemaining)
- {
- *pcchRemaining = cchRemaining;
- }
- }
-
- return hr;
-}
-#endif // FEATURE_PAL || !PLATFORM_UNIX
-#endif // !FEATURE_PAL
-#endif // !STRSAFE_LIB_IMPL
-
#endif // _STRSAFE_H_INCLUDED_
#undef va_arg
#endif
-#if !defined(_MSC_VER) && defined(FEATURE_PAL) && defined(_WIN64)
+#if !defined(_MSC_VER) && defined(_WIN64)
#undef _BitScanForward64
#endif
#ifdef PAL_PERF
-#ifndef PLATFORM_UNIX
-/* PAL Headers */
-#include "perftrace.h"
-
-/* Standard Headers */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#define snprintf _snprintf
-#define MiscGetenv getenv
-#define pthread_getspecific TlsGetValue
-#define THREADSilentGetCurrentThreadId GetCurrentThreadId
-#define getpid GetCurrentProcessId
-#define PAL_fgets fgets // on Windows, we want fgets.
-#define PAL_fwrite fwrite // on Windows, we want fwrite.
-#define PAL_fseek fseek // on Windows, we want fseek.
-
-#else
/* PAL Headers */
#include "pal/palinternal.h"
#include "pal/perftrace.h"
#include <unistd.h>
SET_DEFAULT_DEBUG_CHANNEL(MISC);
-#endif //End of PLATFORM_UNIX
#define PAL_PERF_MAX_LOGLINE 0x400 /* 1K */
ULONGLONG total_duration; /* Total CPU clock ticks of all the threads */
ULONGLONG pal_duration; /* Total CPU clock ticks spent inside PAL */
-#ifndef PLATFORM_UNIX
- DWORD process_id;
-#else
pid_t process_id;
-#endif
char start_time[32]; /* must be at least 26 characters */
} pal_perf_program_info;
-#ifndef PLATFORM_UNIX
-typedef FILE PERF_FILE;
-#define PERF_FILEFN(x) x
-#else
typedef PAL_FILE PERF_FILE;
#define PERF_FILEFN(x) PAL_ ## x
-#endif
static ULONGLONG PERFGetTicks();
static double PERFComputeStandardDeviation(pal_perf_api_info *api);
static PAL_API_NAME API_list[PAL_API_NUMBER] ;
static pal_perf_program_info program_info;
-#ifndef PLATFORM_UNIX
-static DWORD PERF_tlsTableKey=0 ;
-#else
static pthread_key_t PERF_tlsTableKey=0 ;
-#endif
static pal_thread_list_node * process_pal_thread_list=NULL;
static BOOL pal_profile_on=FALSE;
static const char PAL_PERF_HISTOGRAM_STEP[]="PAL_PERF_HISTOGRAM_STEP";
static const char traced_apis_filename[]="PerfTracedAPIs.txt";
static const char perf_enabled_filename[]="AllPerfEnabledAPIs.txt";
-#ifndef PLATFORM_UNIX
-static const char PATH_SEPARATOR[] = "\\";
-#else
static const char PATH_SEPARATOR[] = "/";
-#endif
-#ifndef PLATFORM_UNIX
-#define LLFORMAT "%I64u"
-#else
#define LLFORMAT "%llu"
-#endif
static
ULONGLONG
PERFInitProgramInfo(LPWSTR command_line, LPWSTR exe_path)
{
ULONGLONG start_tick;
-#ifndef PLATFORM_UNIX
- time_t tv;
-#else
struct timeval tv;
-#endif
if (WideCharToMultiByte(CP_ACP, 0, command_line, -1,
program_info.command_line, PAL_PERF_MAX_LOGLINE-1, NULL, NULL) == 0)
gethostname(program_info.hostname, PAL_PERF_MAX_FUNCTION_NAME);
program_info.process_id = getpid();
-#ifndef PLATFORM_UNIX
- time( &tv );
- strcpy(program_info.start_time, ctime( &tv ));
-#else
gettimeofday(&tv, NULL);
ctime_r(&tv.tv_sec, program_info.start_time);
-#endif
// estimate the cpu clock cycles
start_tick = PERFGetTicks();
if (start_tick != 0)
{
-#ifndef PLATFORM_UNIX
- Sleep(1000); //Sleep on Windows takes milliseconds as argument
-#else
sleep(1);
-#endif
program_info.cpu_clock_frequency = (double) (PERFGetTicks() - start_tick);
}
else
pal_profile_on = FALSE; // turn it off until we setup everything.
// allocate the TLS index for structures
-#ifndef PLATFORM_UNIX
- if( ( PERF_tlsTableKey = TlsAlloc() ) == -1 )
- ret = FALSE;
-#else
if( pthread_key_create(&PERF_tlsTableKey , NULL) != 0 )
ret = FALSE;
-#endif
if( ret == TRUE )
{
else
{
-#ifndef PLATFORM_UNIX
- TlsFree(PERF_tlsTableKey );
-#else
pthread_key_delete(PERF_tlsTableKey );
-#endif
ret = FALSE;
}
}
return;
PERFlushAllLogs();
-#ifndef PLATFORM_UNIX
- TlsFree(PERF_tlsTableKey );
-#else
- pthread_key_delete(PERF_tlsTableKey );
-#endif
+ pthread_key_delete(PERF_tlsTableKey );
PAL_free(pal_function_map);
}
local_info->start_ticks = 0;
memset(log_buf, 0, PAL_PERF_PROFILE_BUFFER_SIZE);
-#ifndef PLATFORM_UNIX
- if ( TlsSetValue(PERF_tlsTableKey, local_info) == 0)
- ret = FALSE;
-#else
if (pthread_setspecific(PERF_tlsTableKey, local_info) != 0)
ret = FALSE;
-#endif
PERFAllocThreadInfoExit:
if (ret == TRUE)
char * pal_perf_histogram_size_env;
char * pal_perf_histogram_step_env;
-#ifdef PLATFORM_UNIX
PAL_FILE * hFile;
-#else
- FILE * hFile;
-#endif
if((pal_function_map == NULL) || (PAL_API_NUMBER < 0) )
{
if(input_file_name)
{
-#ifdef PLATFORM_UNIX
hFile = PAL_fopen(input_file_name, "r+");
-#else
- hFile = fopen(input_file_name, "r+");
-#endif
if ( hFile == NULL )
{
memset(pal_function_map, 1, PAL_API_NUMBER);
}
-#ifdef PLATFORM_UNIX
PAL_fclose(hFile);
-#else
- fclose(hFile);
-#endif
ret = TRUE;
}
}
return ret;
}
-#ifdef PLATFORM_UNIX
hFile = PAL_fopen(input_file_name, "r+");
-#else
- hFile = fopen(input_file_name, "r+");
-#endif
if ( hFile != NULL )
{
}
}
-#ifdef PLATFORM_UNIX
PAL_fclose(hFile);
-#else
- fclose(hFile);
-#endif
}
return ret;
short bufused = 0;
-#ifndef PLATFORM_UNIX
- DWORD tv;
- DWORD last_error;
- last_error = GetLastError();
-#else
struct timeval tv;
-#endif
if(!pal_perf_enabled || pal_function_map==NULL || !pal_profile_on ) // haven't initialize, just quit.
PERFFlushLog(local_info, FALSE);
}
-#ifndef PLATFORM_UNIX
- tv = GetTickCount();
-#else
gettimeofday(&tv, NULL);
-#endif
buf_off = local_info->buf_offset;
-#ifndef PLATFORM_UNIX
- bufused = snprintf(&write_buf[buf_off], PAL_PERF_MAX_LOGLINE, "----> %d %lu entry.\n", pal_api_id, tv );
-#else
bufused = snprintf(&write_buf[buf_off], PAL_PERF_MAX_LOGLINE, "----> %d %lu %06u entry.\n", pal_api_id, tv.tv_sec, tv.tv_usec );
-#endif
local_info->buf_offset += bufused;
}
if(nested_tracing)
local_info->profile_enabled = TRUE;
*pal_perf_start_tick = PERFGetTicks();
}
-#ifndef PLATFORM_UNIX
- SetLastError( last_error );
-#endif
return;
}
short bufused = 0;
DWORD off;
ULONGLONG duration = 0;
-#ifndef PLATFORM_UNIX
- DWORD timev;
- DWORD last_error;
- last_error = GetLastError();
-#else
struct timeval timev;
-#endif
if(!pal_perf_enabled || (pal_function_map == NULL) || !pal_profile_on ) // haven't initiallize yet, just quit.
return;
if(summary_only)
{
local_info->profile_enabled = TRUE;
-#ifndef PLATFORM_UNIX
- SetLastError( last_error );
-#endif
return;
}
-#ifndef PLATFORM_UNIX
- timev = GetTickCount();
-#else
gettimeofday(&timev, NULL);
-#endif
buf = local_info->pal_write_buf;
if(local_info->buf_offset >= PAL_PERF_BUFFER_FULL)
}
off = local_info->buf_offset;
-#ifndef PLATFORM_UNIX
- bufused = snprintf(&buf[off], PAL_PERF_MAX_LOGLINE, "<---- %d %lu exit. \n", pal_api_id, timev);
-#else
bufused = snprintf(&buf[off], PAL_PERF_MAX_LOGLINE, "<---- %d %lu %06u exit. \n", pal_api_id, timev.tv_sec, timev.tv_usec );
-#endif
local_info->buf_offset += bufused;
local_info->profile_enabled = TRUE;
}
-#ifndef PLATFORM_UNIX
- SetLastError( last_error );
-#endif
return;
}
{
pal_perf_thread_info * local_info=NULL;
pal_perf_api_info * table;
-#ifndef PLATFORM_UNIX
- DWORD last_error;
- last_error = GetLastError();
-#endif
if(!pal_perf_enabled || pal_function_map==NULL || !pal_profile_on ) // haven't initialize, just quit.
return;
local_info= (pal_perf_thread_info * )pthread_getspecific(PERF_tlsTableKey);
if (local_info==NULL )
{
-#ifndef PLATFORM_UNIX
- SetLastError( last_error );
-#endif
return;
}
else{
table[pal_api_id].entries++;
}
}
-#ifndef PLATFORM_UNIX
- SetLastError( last_error );
-#endif
return;
}
PERFEnableThreadProfile(BOOL isInternal)
{
pal_perf_thread_info * local_info;
-#ifndef PLATFORM_UNIX
- DWORD last_error;
- last_error = GetLastError();
-#endif
if (!pal_perf_enabled)
return;
if (NULL != (local_info = (pal_perf_thread_info*)pthread_getspecific(PERF_tlsTableKey)))
local_info->start_ticks = PERFGetTicks();
}
}
-#ifndef PLATFORM_UNIX
- SetLastError( last_error );
-#endif
}
PERFDisableThreadProfile(BOOL isInternal)
{
pal_perf_thread_info * local_info;
-#ifndef PLATFORM_UNIX
- DWORD last_error;
- last_error = GetLastError();
-#endif
if (!pal_perf_enabled)
return;
if (NULL != (local_info = (pal_perf_thread_info*)pthread_getspecific(PERF_tlsTableKey)))
local_info->total_duration = PERFGetTicks() - local_info->start_ticks;
}
}
-#ifndef PLATFORM_UNIX
- SetLastError( last_error );
-#endif
}
char *
PERFIsValidPath( const char * path )
{
-#ifndef PLATFORM_UNIX
- DWORD result;
-#else
DIR * dir;
-#endif
if(( path==NULL) || (strlen(path)==0))
return NULL;
-#ifndef PLATFORM_UNIX
- result = GetFileAttributesA( path );
- if ((result != INVALID_FILE_ATTRIBUTES) && (result & FILE_ATTRIBUTE_DIRECTORY))
- {
- return ((char *) path );
- }
-#else
dir = opendir(path);
if( dir!=NULL)
{
closedir(dir);
return ((char *)path);
}
-#endif
return NULL;
}
return PERFGetTicks();
}
-#ifndef PLATFORM_UNIX
-#undef snprintf
-#undef MiscGetenv
-#undef pthread_key_t
-#undef pthread_getspecific
-#endif /* ifndef PLATFORM_UNIX definitions */
-
#endif /* PAL_PERF */
/*
** Run only on 64 bit platforms
*/
- #if defined(BIT64) && defined(PLATFORM_UNIX)
+ #if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest("%p", NULL, "NULL", "0000000000000000");
DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456");
DoPointerTest("%Lp", ptr, "pointer to 0x123456", "00123456");
DoI64Test("%I64p", lptr, "pointer to 0x1234567887654321",
"1234567887654321");
- #endif //defined(BIT64) && defined(PLATFORM_UNIX)
+ #endif //defined(BIT64)
PAL_Terminate();
return PASS;
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest(convert("%p"), NULL, convert("0000000000000000"));
DoPointerTest(convert("%p"), ptr, convert("0000000000123456"));
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest("%p", NULL, "NULL", "0000000000000000");
DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456");
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("00000000"));
DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"),
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoTest("%p", NULL, "NULL", "0000000000000000", "0x0");
DoTest("%p", ptr, "pointer to 0x123456", "0000000000123456", "0x123456");
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest(convert("%p"), NULL, "NULL", "0000000000000000", "0x0");
DoPointerTest(convert("%p"), ptr, "pointer to 0x123456", "0000000000123456",
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest("%p", NULL, "NULL", "0000000000000000");
DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456");
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest("%p", NULL, "NULL", "0000000000000000");
DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456");
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest(convert("%p"), NULL, convert("0000000000000000"));
DoPointerTest(convert("%p"), ptr, convert("0000000000123456"));
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest("%p", NULL, "NULL", "0000000000000000");
DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456");
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest("%p", NULL, "NULL", "0000000000000000");
DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456");
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest("%p", NULL, "NULL", "0000000000000000");
DoPointerTest("%p", ptr, "pointer to 0x123456", "0000000000123456");
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
DoPointerTest(convert("%p"), NULL, convert("NULL"), convert("0000000000000000"));
DoPointerTest(convert("%p"), ptr, convert("pointer to 0x123456"),
const char *szDotNetInstallEnvVar = "DOTNET_INSTALL";
const char *szQASupportDirEnvVar = "QA_SUPPORT_DIR";
-#ifdef PLATFORM_UNIX
#define SEPERATOR "/"
-#else
-#define SEPERATOR "\\"
-#endif
char *getBuildNumber()
{
char *szBuildFileName = "buildinfo.txt";
Fail("ERROR: Couldn't allocate enough memory to potentially store build number\n");
}
-#ifndef PLATFORM_UNIX
- pDirectoryName = getenv(szDotNetInstallEnvVar);
- if (pDirectoryName == NULL)
- {
- /* This condition may exist if the test is being run in say the Dev environment.*/
- Trace("WARNING: Coriolis Test Environment may not be setup correctly. Variable DOTNET_INSTALL not set\n");
- _snprintf(szTempValue, 99, "0000.00");
- return szTempValue;
- }
-#else
pDirectoryName = getenv(szQASupportDirEnvVar);
if (pDirectoryName == NULL)
{
return szTempValue;
}
-#endif //PLATFORM_UNIX
-
-#ifndef PLATFORM_UNIX
- _snprintf(szBuildFileLoc, MAX_PATH, "%s%s%s", pDirectoryName, SEPERATOR, szBuildFileName);
-#else
// To avoid buffer overruns for pDirectoryName
_snprintf(szBuildFileLoc, MAX_PATH, "%s/../1.0%s%s", pDirectoryName, SEPERATOR, szBuildFileName);
-#endif //PLATFORM_UNIX
fp = fopen( szBuildFileLoc, "r");
if( fp == NULL)
{
- from an object management perspective it doesn't really gain
us anything over what we already have."
*/
-#ifdef PLATFORM_UNIX
-
ZeroMemory( objectSuffix, MAX_PATH );
if(GetParameters(argc, argv))
Trace("Test Failed\n");
}
-#endif //PLATFORM_UNIX
PAL_Terminate();
return testReturnCode;
}
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
Trace("Testing for 64 Bit Platforms \n");
if(memcmp(OutBuffer,
convert("Pal 00000000000123AB and foo Testing"),
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
ptrValue = (LONG *) malloc(sizeof(LONG));
if(ptrValue == NULL)
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
/* Compare START_VALUE with BaseVariableToManipulate, they're equal,
so exchange
*/
/* Exchanged, these should be equal now */
if(BaseVariableToManipulate != ValueToExchange)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: A successful compare and exchange should have occurred, "
"making the variable have the value of %ll, as opposed to the "
"current value of %ll.",
ValueToExchange,BaseVariableToManipulate);
-#else
- Fail("ERROR: A successful compare and exchange should have occurred, "
- "making the variable have the value of %I64, as opposed to the "
- "current value of %d.",
- ValueToExchange,BaseVariableToManipulate);
-
-#endif
}
/* Check to make sure it returns the original number which
*/
if(TheReturn != START_VALUE)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: The return value after the first exchange should be the "
"former value of the variable, which was %ll, but it is now %ll.",
START_VALUE,TheReturn);
-#else
- Fail("ERROR: The return value after the first exchange should be the "
- "former value of the variable, which was %I64, but it is now %I64.",
- START_VALUE,TheReturn);
-#endif
}
if(BaseVariableToManipulate != TempValue)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: An attempted exchange should have failed due to "
"the compare failing. But, it seems to have succeeded. The "
"value should be %ll but is %ll in this case.",
TempValue,BaseVariableToManipulate);
-#else
- Fail("ERROR: An attempted exchange should have failed due to "
- "the compare failing. But, it seems to have succeeded. The "
- "value should be %I64 but is %I64 in this case.",
- TempValue,BaseVariableToManipulate);
-#endif
}
-#endif //if defined(BIT64) && defined(PLATFORM_UNIX)
+#endif //if defined(BIT64)
PAL_Terminate();
return PASS;
}
/*
** Run only on 64 bit platforms
*/
- #if defined(BIT64) && defined(PLATFORM_UNIX)
+ #if defined(BIT64)
//Create MAX_THREADS threads that will operate on the global counter
for (i=0;i<MAX_THREADS;i++)
Fail("Test Case Failed: InterlockedDecrement \n");
}
- #endif //defined(BIT64) && defined(PLATFORM_UNIX)
+ #endif //defined(BIT64)
PAL_Terminate();
return PASS;
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
/* Compare START_VALUE with BaseVariableToManipulate, they're equal,
so exchange
*/
/* Decremented twice, it should be -2 now */
if(TheValue != -2)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: After being decremented twice, the value should be -2, "
"but it is really %ll.",TheValue);
-#else
- Fail("ERROR: After being decremented twice, the value should be -2, "
- "but it is really %I64.",TheValue);
-#endif
}
/* Check to make sure it returns itself */
if(TheReturn != TheValue)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: The function should have returned the new value of %d "
"but instead returned %ll.",TheValue,TheReturn);
-#else
- Fail("ERROR: After being decremented twice, the value should be -2, "
- "but it is really %I64.",TheValue);
-#endif
}
-#endif //defined(BIT64) && defined(PLATFORM_UNIX)
+#endif //defined(BIT64)
PAL_Terminate();
return PASS;
}
return FAIL;
}
- #if defined(BIT64) && defined(PLATFORM_UNIX)
+ #if defined(BIT64)
//Create MAX_THREADS threads that will operate on the global counter
for (i=0;i<MAX_THREADS;i++)
Fail("Test Case Failed: InterlockedDecrement \n");
}
-#endif //defined(BIT64) && defined(PLATFORM_UNIX)
+#endif //defined(BIT64)
PAL_Terminate();
return PASS;
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
TheReturn = InterlockedExchange64(&TheValue,NewValue);
*/
if(TheValue != NewValue)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: The value which was exchanged should now be %ll, but "
"instead it is %ll.",NewValue,TheValue);
-#else
- Fail("ERROR: The value which was exchanged should now be %I64, but "
- "instead it is %I64.",NewValue,TheValue);
-#endif
}
/* Check to make sure it returns the origional number which 'TheValue' was
if(TheReturn != START_VALUE)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: The value returned should be the value before the "
"exchange happened, which was %ll, but %ll was returned.",
START_VALUE,TheReturn);
-#else
- Fail("ERROR: The value returned should be the value before the "
- "exchange happened, which was %I64, but %I64 was returned.",
- START_VALUE,TheReturn);
-#endif
}
-#endif // BIT64 && PLATFORM_UNIX
+#endif // BIT64
PAL_Terminate();
return PASS;
}
/*
** Run only on 64 bit platforms
*/
-#if defined(BIT64) && defined(PLATFORM_UNIX)
+#if defined(BIT64)
InterlockedIncrement64(&TheValue);
TheReturn = InterlockedIncrement64(&TheValue);
/* Incremented twice, it should be 2 now */
if(TheValue != 2)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: The value was incremented twice and shoud now be 2, "
"but it is really %ll",TheValue);
-#else
- Fail("ERROR: The value was incremented twice and shoud now be 2, "
- "but it is really %I64",TheValue);
-#endif
}
/* Check to make sure it returns itself */
if(TheReturn != TheValue)
{
-#ifdef PLATFORM_UNIX
Fail("ERROR: The function should return the new value, which shoud "
"have been %d, but it returned %ll.",TheValue,TheReturn);
-#else
- Fail("ERROR: The function should return the new value, which shoud "
- "have been %d, but it returned %I64.",TheValue,TheReturn);
-#endif
}
-#endif //defined(BIT64) && defined(PLATFORM_UNIX)
+#endif //defined(BIT64)
PAL_Terminate();
return PASS;
}
/*
** Run only on 64 bit platforms
*/
- #if defined(BIT64) && defined(PLATFORM_UNIX)
+ #if defined(BIT64)
//Create MAX_THREADS threads that will operate on the global counter
for (i=0;i<MAX_THREADS;i++)
{
Fail("Test Case Failed: InterlockedDecrement \n");
}
- #endif //defined(BIT64) && defined(PLATFORM_UNIX)
+ #endif //defined(BIT64)
PAL_Terminate();
return PASS;
#include <palsuite.h>
-#ifndef PLATFORM_UNIX
-#define LLFORMAT "%I64u"
-#else
#define LLFORMAT "%llu"
-#endif
ULONGLONG dwCreateThreadTestParameter = 0;