diff options
| author | marsunet <marc.sunet@amd.com> | 2021-12-21 17:04:22 -0800 |
|---|---|---|
| committer | marsunet <marc.sunet@amd.com> | 2021-12-21 17:04:22 -0800 |
| commit | fba8184491e0b7ae6fab7ac01b4600d230dc4569 (patch) | |
| tree | c13194764867a4ad8f46702356b22dccc1e56dd3 /contrib/DirectX-Headers/include/wsl/winadapter.h | |
| parent | 8b1583b65d77188ef35a89e75f145f29c3e3b5d7 (diff) | |
Diffstat (limited to 'contrib/DirectX-Headers/include/wsl/winadapter.h')
| -rw-r--r-- | contrib/DirectX-Headers/include/wsl/winadapter.h | 340 |
1 files changed, 340 insertions, 0 deletions
diff --git a/contrib/DirectX-Headers/include/wsl/winadapter.h b/contrib/DirectX-Headers/include/wsl/winadapter.h new file mode 100644 index 0000000..8400f4a --- /dev/null +++ b/contrib/DirectX-Headers/include/wsl/winadapter.h | |||
| @@ -0,0 +1,340 @@ | |||
| 1 | // Copyright (c) Microsoft Corporation. | ||
| 2 | // Licensed under the MIT License. | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | // These #defines prevent the idl-generated headers from trying to include | ||
| 7 | // Windows.h from the SDK rather than this one. | ||
| 8 | #define RPC_NO_WINDOWS_H | ||
| 9 | #define COM_NO_WINDOWS_H | ||
| 10 | |||
| 11 | // Allcaps type definitions | ||
| 12 | #include <stddef.h> | ||
| 13 | #include <stdint.h> | ||
| 14 | #include <string.h> | ||
| 15 | #include <limits.h> | ||
| 16 | |||
| 17 | // Note: using fixed-width here to match Windows widths | ||
| 18 | // Specifically this is different for 'long' vs 'LONG' | ||
| 19 | typedef uint8_t UINT8; | ||
| 20 | typedef int8_t INT8; | ||
| 21 | typedef uint16_t UINT16; | ||
| 22 | typedef int16_t INT16; | ||
| 23 | typedef uint32_t UINT32, UINT, ULONG, DWORD, BOOL; | ||
| 24 | typedef int32_t INT32, INT, LONG; | ||
| 25 | typedef uint64_t UINT64, ULONG_PTR; | ||
| 26 | typedef int64_t INT64, LONG_PTR; | ||
| 27 | typedef void VOID, *HANDLE, *RPC_IF_HANDLE, *LPVOID; | ||
| 28 | typedef const void *LPCVOID; | ||
| 29 | typedef size_t SIZE_T; | ||
| 30 | typedef float FLOAT; | ||
| 31 | typedef double DOUBLE; | ||
| 32 | typedef unsigned char BYTE; | ||
| 33 | typedef int HWND; | ||
| 34 | |||
| 35 | // Note: WCHAR is not the same between Windows and Linux, to enable | ||
| 36 | // string manipulation APIs to work with resulting strings. | ||
| 37 | // APIs to D3D/DXCore will work on Linux wchars, but beware with | ||
| 38 | // interactions directly with the Windows kernel. | ||
| 39 | typedef char CHAR, *PSTR, *LPSTR, TCHAR, *PTSTR; | ||
| 40 | typedef const char *LPCSTR, *PCSTR, *LPCTSTR, *PCTSTR; | ||
| 41 | typedef wchar_t WCHAR, *PWSTR, *LPWSTR, *PWCHAR; | ||
| 42 | typedef const wchar_t *LPCWSTR, *PCWSTR; | ||
| 43 | |||
| 44 | #undef LONG_MAX | ||
| 45 | #define LONG_MAX INT_MAX | ||
| 46 | #undef ULONG_MAX | ||
| 47 | #define ULONG_MAX UINT_MAX | ||
| 48 | |||
| 49 | // Misc defines | ||
| 50 | #define interface struct | ||
| 51 | #define MIDL_INTERFACE(x) interface | ||
| 52 | #define __analysis_assume(x) | ||
| 53 | #define TRUE 1u | ||
| 54 | #define FALSE 0u | ||
| 55 | #define DECLARE_INTERFACE(iface) interface iface | ||
| 56 | #define PURE = 0 | ||
| 57 | #define THIS_ | ||
| 58 | #define DECLSPEC_UUID(x) | ||
| 59 | #define DECLSPEC_NOVTABLE | ||
| 60 | #define DECLSPEC_SELECTANY | ||
| 61 | #define EXTERN_C extern "C" | ||
| 62 | |||
| 63 | typedef struct _GUID { | ||
| 64 | uint32_t Data1; | ||
| 65 | uint16_t Data2; | ||
| 66 | uint16_t Data3; | ||
| 67 | uint8_t Data4[ 8 ]; | ||
| 68 | } GUID; | ||
| 69 | |||
| 70 | #ifdef __cplusplus | ||
| 71 | #ifdef INITGUID | ||
| 72 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) extern "C" const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } | ||
| 73 | #else | ||
| 74 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) extern "C" const GUID name | ||
| 75 | #endif | ||
| 76 | |||
| 77 | template <typename T> GUID uuidof() = delete; | ||
| 78 | template <typename T> GUID uuidof(T*) { return uuidof<T>(); } | ||
| 79 | template <typename T> GUID uuidof(T**) { return uuidof<T>(); } | ||
| 80 | template <typename T> GUID uuidof(T&) { return uuidof<T>(); } | ||
| 81 | #define __uuidof(x) uuidof(x) | ||
| 82 | #else | ||
| 83 | #ifdef INITGUID | ||
| 84 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } | ||
| 85 | #else | ||
| 86 | #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) extern const GUID name | ||
| 87 | #endif | ||
| 88 | #endif | ||
| 89 | |||
| 90 | typedef GUID IID; | ||
| 91 | typedef GUID UUID; | ||
| 92 | typedef GUID CLSID; | ||
| 93 | #ifdef __cplusplus | ||
| 94 | #define REFGUID const GUID & | ||
| 95 | #define REFIID const IID & | ||
| 96 | #define REFCLSID const IID & | ||
| 97 | |||
| 98 | __inline int InlineIsEqualGUID(REFGUID rguid1, REFGUID rguid2) | ||
| 99 | { | ||
| 100 | return ( | ||
| 101 | ((uint32_t *)&rguid1)[0] == ((uint32_t *)&rguid2)[0] && | ||
| 102 | ((uint32_t *)&rguid1)[1] == ((uint32_t *)&rguid2)[1] && | ||
| 103 | ((uint32_t *)&rguid1)[2] == ((uint32_t *)&rguid2)[2] && | ||
| 104 | ((uint32_t *)&rguid1)[3] == ((uint32_t *)&rguid2)[3]); | ||
| 105 | } | ||
| 106 | #else | ||
| 107 | #define REFGUID const GUID * | ||
| 108 | #define REFIID const IID * | ||
| 109 | #define REFCLSID const IID * | ||
| 110 | #endif | ||
| 111 | |||
| 112 | // SAL annotations | ||
| 113 | #define _In_ | ||
| 114 | #define _In_z_ | ||
| 115 | #define _In_opt_ | ||
| 116 | #define _In_opt_z_ | ||
| 117 | #define _In_reads_(x) | ||
| 118 | #define _In_reads_opt_(x) | ||
| 119 | #define _In_reads_bytes_(x) | ||
| 120 | #define _In_reads_bytes_opt_(x) | ||
| 121 | #define _In_range_(x, y) | ||
| 122 | #define _In_bytecount_(x) | ||
| 123 | #define _Out_ | ||
| 124 | #define _Out_opt_ | ||
| 125 | #define _Outptr_ | ||
| 126 | #define _Outptr_opt_result_z_ | ||
| 127 | #define _Outptr_opt_result_bytebuffer_(x) | ||
| 128 | #define _COM_Outptr_ | ||
| 129 | #define _COM_Outptr_result_maybenull_ | ||
| 130 | #define _COM_Outptr_opt_ | ||
| 131 | #define _COM_Outptr_opt_result_maybenull_ | ||
| 132 | #define _Out_writes_(x) | ||
| 133 | #define _Out_writes_z_(x) | ||
| 134 | #define _Out_writes_opt_(x) | ||
| 135 | #define _Out_writes_all_(x) | ||
| 136 | #define _Out_writes_all_opt_(x) | ||
| 137 | #define _Out_writes_to_opt_(x, y) | ||
| 138 | #define _Out_writes_bytes_(x) | ||
| 139 | #define _Out_writes_bytes_all_(x) | ||
| 140 | #define _Out_writes_bytes_all_opt_(x) | ||
| 141 | #define _Out_writes_bytes_opt_(x) | ||
| 142 | #define _Inout_ | ||
| 143 | #define _Inout_opt_ | ||
| 144 | #define _Inout_updates_(x) | ||
| 145 | #define _Inout_updates_bytes_(x) | ||
| 146 | #define _Field_size_(x) | ||
| 147 | #define _Field_size_opt_(x) | ||
| 148 | #define _Field_size_bytes_(x) | ||
| 149 | #define _Field_size_full_(x) | ||
| 150 | #define _Field_size_bytes_full_(x) | ||
| 151 | #define _Field_size_bytes_full_opt_(x) | ||
| 152 | #define _Field_size_bytes_part_(x, y) | ||
| 153 | #define _Field_range_(x, y) | ||
| 154 | #define _Field_z_ | ||
| 155 | #define _Check_return_ | ||
| 156 | #define _IRQL_requires_(x) | ||
| 157 | #define _IRQL_requires_min_(x) | ||
| 158 | #define _IRQL_requires_max_(x) | ||
| 159 | #define _At_(x, y) | ||
| 160 | #define _Always_(x) | ||
| 161 | #define _Return_type_success_(x) | ||
| 162 | #define _Translates_Win32_to_HRESULT_(x) | ||
| 163 | #define _Maybenull_ | ||
| 164 | #define _Outptr_result_maybenull_ | ||
| 165 | #define _Outptr_result_nullonfailure_ | ||
| 166 | #define _Analysis_assume_(x) | ||
| 167 | #define _Success_(x) | ||
| 168 | #define _In_count_(x) | ||
| 169 | #define _In_opt_count_(x) | ||
| 170 | #define _Use_decl_annotations_ | ||
| 171 | |||
| 172 | // Calling conventions | ||
| 173 | #define __cdecl | ||
| 174 | #define __stdcall | ||
| 175 | #define STDMETHODCALLTYPE | ||
| 176 | #define STDAPICALLTYPE | ||
| 177 | #define STDAPI extern "C" HRESULT STDAPICALLTYPE | ||
| 178 | #define WINAPI | ||
| 179 | #define STDMETHOD(name) virtual HRESULT name | ||
| 180 | #define STDMETHOD_(type,name) virtual type name | ||
| 181 | #define IFACEMETHOD(method) /*__override*/ STDMETHOD(method) | ||
| 182 | #define IFACEMETHOD_(type, method) /*__override*/ STDMETHOD_(type, method) | ||
| 183 | |||
| 184 | // Error codes | ||
| 185 | typedef LONG HRESULT; | ||
| 186 | #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) | ||
| 187 | #define FAILED(hr) (((HRESULT)(hr)) < 0) | ||
| 188 | #define S_OK ((HRESULT)0L) | ||
| 189 | #define S_FALSE ((HRESULT)1L) | ||
| 190 | #define E_NOTIMPL ((HRESULT)0x80000001L) | ||
| 191 | #define E_OUTOFMEMORY ((HRESULT)0x80000002L) | ||
| 192 | #define E_INVALIDARG ((HRESULT)0x80000003L) | ||
| 193 | #define E_NOINTERFACE ((HRESULT)0x80000004L) | ||
| 194 | #define E_POINTER ((HRESULT)0x80000005L) | ||
| 195 | #define E_HANDLE ((HRESULT)0x80000006L) | ||
| 196 | #define E_ABORT ((HRESULT)0x80000007L) | ||
| 197 | #define E_FAIL ((HRESULT)0x80000008L) | ||
| 198 | #define E_ACCESSDENIED ((HRESULT)0x80000009L) | ||
| 199 | #define E_UNEXPECTED ((HRESULT)0x8000FFFFL) | ||
| 200 | #define DXGI_ERROR_DEVICE_HUNG ((HRESULT)0x887A0006L) | ||
| 201 | #define DXGI_ERROR_DEVICE_REMOVED ((HRESULT)0x887A0005L) | ||
| 202 | #define DXGI_ERROR_DEVICE_RESET ((HRESULT)0x887A0007L) | ||
| 203 | #define DXGI_ERROR_DRIVER_INTERNAL_ERROR ((HRESULT)0x887A0020L) | ||
| 204 | #define DXGI_ERROR_INVALID_CALL ((HRESULT)0x887A0001L) | ||
| 205 | |||
| 206 | typedef struct _LUID | ||
| 207 | { | ||
| 208 | ULONG LowPart; | ||
| 209 | LONG HighPart; | ||
| 210 | } LUID; | ||
| 211 | |||
| 212 | struct RECT | ||
| 213 | { | ||
| 214 | int left; | ||
| 215 | int top; | ||
| 216 | int right; | ||
| 217 | int bottom; | ||
| 218 | }; | ||
| 219 | |||
| 220 | typedef union _LARGE_INTEGER { | ||
| 221 | struct { | ||
| 222 | uint32_t LowPart; | ||
| 223 | uint32_t HighPart; | ||
| 224 | } u; | ||
| 225 | int64_t QuadPart; | ||
| 226 | } LARGE_INTEGER; | ||
| 227 | |||
| 228 | typedef union _ULARGE_INTEGER { | ||
| 229 | struct { | ||
| 230 | uint32_t LowPart; | ||
| 231 | uint32_t HighPart; | ||
| 232 | } u; | ||
| 233 | uint64_t QuadPart; | ||
| 234 | } ULARGE_INTEGER; | ||
| 235 | |||
| 236 | struct SECURITY_ATTRIBUTES; | ||
| 237 | struct STATSTG; | ||
| 238 | |||
| 239 | #ifdef __cplusplus | ||
| 240 | // ENUM_FLAG_OPERATORS | ||
| 241 | // Define operator overloads to enable bit operations on enum values that are | ||
| 242 | // used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable these | ||
| 243 | // operators on YOUR_TYPE. | ||
| 244 | extern "C++" { | ||
| 245 | template <size_t S> | ||
| 246 | struct _ENUM_FLAG_INTEGER_FOR_SIZE; | ||
| 247 | |||
| 248 | template <> | ||
| 249 | struct _ENUM_FLAG_INTEGER_FOR_SIZE<1> | ||
| 250 | { | ||
| 251 | typedef int8_t type; | ||
| 252 | }; | ||
| 253 | |||
| 254 | template <> | ||
| 255 | struct _ENUM_FLAG_INTEGER_FOR_SIZE<2> | ||
| 256 | { | ||
| 257 | typedef int16_t type; | ||
| 258 | }; | ||
| 259 | |||
| 260 | template <> | ||
| 261 | struct _ENUM_FLAG_INTEGER_FOR_SIZE<4> | ||
| 262 | { | ||
| 263 | typedef int32_t type; | ||
| 264 | }; | ||
| 265 | |||
| 266 | template <> | ||
| 267 | struct _ENUM_FLAG_INTEGER_FOR_SIZE<8> | ||
| 268 | { | ||
| 269 | typedef int64_t type; | ||
| 270 | }; | ||
| 271 | |||
| 272 | // used as an approximation of std::underlying_type<T> | ||
| 273 | template <class T> | ||
| 274 | struct _ENUM_FLAG_SIZED_INTEGER | ||
| 275 | { | ||
| 276 | typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type; | ||
| 277 | }; | ||
| 278 | |||
| 279 | } | ||
| 280 | #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \ | ||
| 281 | extern "C++" { \ | ||
| 282 | inline constexpr ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) | ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \ | ||
| 283 | inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) |= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \ | ||
| 284 | inline constexpr ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) & ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \ | ||
| 285 | inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) &= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \ | ||
| 286 | inline constexpr ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a)); } \ | ||
| 287 | inline constexpr ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)a) ^ ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \ | ||
| 288 | inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE &)(((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type &)a) ^= ((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); } \ | ||
| 289 | } | ||
| 290 | #endif | ||
| 291 | |||
| 292 | // D3DX12 uses these | ||
| 293 | #include <stdlib.h> | ||
| 294 | #define HeapAlloc(heap, flags, size) malloc(size) | ||
| 295 | #define HeapFree(heap, flags, ptr) free(ptr) | ||
| 296 | |||
| 297 | #ifdef __cplusplus | ||
| 298 | // IUnknown | ||
| 299 | |||
| 300 | interface DECLSPEC_UUID("00000000-0000-0000-C000-000000000046") DECLSPEC_NOVTABLE IUnknown | ||
| 301 | { | ||
| 302 | virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject) = 0; | ||
| 303 | virtual ULONG STDMETHODCALLTYPE AddRef() = 0; | ||
| 304 | virtual ULONG STDMETHODCALLTYPE Release() = 0; | ||
| 305 | |||
| 306 | template <class Q> HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp) { | ||
| 307 | return QueryInterface(uuidof<Q>(), (void **)pp); | ||
| 308 | } | ||
| 309 | }; | ||
| 310 | |||
| 311 | template <> constexpr GUID uuidof<IUnknown>() | ||
| 312 | { | ||
| 313 | return { 0x00000000, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } }; | ||
| 314 | } | ||
| 315 | |||
| 316 | extern "C++" | ||
| 317 | { | ||
| 318 | template<typename T> void** IID_PPV_ARGS_Helper(T** pp) | ||
| 319 | { | ||
| 320 | static_cast<IUnknown*>(*pp); | ||
| 321 | return reinterpret_cast<void**>(pp); | ||
| 322 | } | ||
| 323 | } | ||
| 324 | |||
| 325 | #define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType) | ||
| 326 | #endif | ||
| 327 | |||
| 328 | #if defined(lint) | ||
| 329 | // Note: lint -e530 says don't complain about uninitialized variables for | ||
| 330 | // this variable. Error 527 has to do with unreachable code. | ||
| 331 | // -restore restores checking to the -save state | ||
| 332 | #define UNREFERENCED_PARAMETER(P) \ | ||
| 333 | /*lint -save -e527 -e530 */ \ | ||
| 334 | { \ | ||
| 335 | (P) = (P); \ | ||
| 336 | } \ | ||
| 337 | /*lint -restore */ | ||
| 338 | #else | ||
| 339 | #define UNREFERENCED_PARAMETER(P) (P) | ||
| 340 | #endif | ||
