Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 22 additions & 28 deletions include/wsl/stubs/basetsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ typedef const char *LPCSTR, *PCSTR, *LPCTSTR, *PCTSTR;
typedef wchar_t WCHAR, *PWSTR, *LPWSTR, *PWCHAR;
typedef const wchar_t *LPCWSTR, *PCWSTR;

typedef signed int HRESULT;

#undef LONG_MAX
#define LONG_MAX INT_MAX
#undef ULONG_MAX
#define ULONG_MAX UINT_MAX
#define interface struct

// Misc defines
#define MIDL_INTERFACE(x) interface
Expand All @@ -76,8 +79,6 @@ typedef const wchar_t *LPCWSTR, *PCWSTR;
#define EXTERN_C extern
#endif
#define APIENTRY
#define OUT
#define IN
#define CONST const
#define MAX_PATH 260
#define GENERIC_ALL 0x10000000L
Expand Down Expand Up @@ -118,23 +119,25 @@ typedef struct _GUID {
typedef GUID IID;
typedef GUID UUID;
typedef GUID CLSID;

#ifdef __cplusplus
#define REFGUID const GUID &
#define REFIID const IID &
#define REFCLSID const IID &

__inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2)
typedef const GUID &REFGUID;
typedef const GUID &REFCLSID;
typedef const IID &REFIID;

__inline int IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
{
return (
((uint32_t *)&rguid1)[0] == ((uint32_t *)&rguid2)[0] &&
((uint32_t *)&rguid1)[1] == ((uint32_t *)&rguid2)[1] &&
((uint32_t *)&rguid1)[2] == ((uint32_t *)&rguid2)[2] &&
((uint32_t *)&rguid1)[3] == ((uint32_t *)&rguid2)[3]);
// Optimization:
if (&rguid1 == &rguid2)
return true;

return !memcmp(&rguid1, &rguid2, sizeof(GUID));
}

inline bool operator==(REFGUID guidOne, REFGUID guidOther)
{
return !!InlineIsEqualGUID(guidOne, guidOther);
return !!IsEqualGUID(guidOne, guidOther);
}

inline bool operator!=(REFGUID guidOne, REFGUID guidOther)
Expand Down Expand Up @@ -218,7 +221,6 @@ inline bool operator!=(REFGUID guidOne, REFGUID guidOther)
#define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
#define WINAPI

#define interface struct
#if defined (__cplusplus) && !defined (CINTERFACE)
#define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method
#define STDMETHOD_(type, method) virtual type STDMETHODCALLTYPE method
Expand All @@ -229,6 +231,7 @@ inline bool operator!=(REFGUID guidOne, REFGUID guidOther)
#define DECLARE_INTERFACE_(iface, baseiface) interface DECLSPEC_NOVTABLE iface : public baseiface

interface IUnknown;

extern "C++"
{
template<typename T> void** IID_PPV_ARGS_Helper(T** pp)
Expand Down Expand Up @@ -260,7 +263,6 @@ extern "C++"
#endif

// Error codes
typedef LONG HRESULT;
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
#define FAILED(hr) (((HRESULT)(hr)) < 0)
#define S_OK ((HRESULT)0L)
Expand Down Expand Up @@ -329,7 +331,7 @@ typedef struct _SECURITY_ATTRIBUTES {
WINBOOL bInheritHandle;
} SECURITY_ATTRIBUTES;

struct STATSTG;
typedef struct tagSTATSTG STATSTG;

#ifdef __cplusplus
// ENUM_FLAG_OPERATORS
Expand Down Expand Up @@ -387,20 +389,12 @@ inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_
#endif

// D3DX12 uses these

#ifndef LLVM_SUPPORT_WIN_ADAPTER_H
#include <stdlib.h>
#define HeapAlloc(heap, flags, size) malloc(size)
#define HeapFree(heap, flags, ptr) free(ptr)

#if defined(lint)
// Note: lint -e530 says don't complain about uninitialized variables for
// this variable. Error 527 has to do with unreachable code.
// -restore restores checking to the -save state
#define UNREFERENCED_PARAMETER(P) \
/*lint -save -e527 -e530 */ \
{ \
(P) = (P); \
} \
/*lint -restore */
#else
#define UNREFERENCED_PARAMETER(P) (P)
#endif


#define UNREFERENCED_PARAMETER(P) (void)(P)
2 changes: 1 addition & 1 deletion include/wsl/stubs/rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// Licensed under the MIT License.

// Stub header to satisfy d3d12.h include
#pragma once
#pragma once