Skip to content

Commit c7403b8

Browse files
author
Stephen Gutekanst
committed
patch/upgrade DirectX-Headers version
Signed-off-by: Stephen Gutekanst <[email protected]>
1 parent c3df16e commit c7403b8

File tree

5 files changed

+160
-93
lines changed

5 files changed

+160
-93
lines changed

include/dxc/Support/Unicode.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ int WideCharToMultiByte(uint32_t CodePage, uint32_t dwFlags,
3030
const wchar_t *lpWideCharStr, int cchWideChar,
3131
char *lpMultiByteStr, int cbMultiByte,
3232
const char *lpDefaultChar = nullptr,
33-
bool *lpUsedDefaultChar = nullptr);
33+
// Mach change start
34+
// bool *lpUsedDefaultChar = nullptr);
35+
LPBOOL lpUsedDefaultChar = nullptr);
36+
// Mach change end
3437
#endif // _WIN32
3538

3639
namespace Unicode {

include/dxc/Support/WinIncludes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ template <class T> void swap(CComHeapPtr<T> &a, CComHeapPtr<T> &b) {
7171
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable
7272
// these operators on YOUR_TYPE.
7373
extern "C++" {
74+
// Mach change start
75+
#ifdef _WIN32
76+
// Mach change end
7477
template <size_t S> struct _ENUM_FLAG_INTEGER_FOR_SIZE;
7578

7679
template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<1> { typedef int8_t type; };
@@ -83,6 +86,9 @@ template <> struct _ENUM_FLAG_INTEGER_FOR_SIZE<4> { typedef int32_t type; };
8386
template <class T> struct _ENUM_FLAG_SIZED_INTEGER {
8487
typedef typename _ENUM_FLAG_INTEGER_FOR_SIZE<sizeof(T)>::type type;
8588
};
89+
// Mach change start
90+
#endif // _WIN32
91+
// Mach change end
8692
}
8793
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
8894
extern "C++" { \

include/dxc/WinAdapter.h

Lines changed: 136 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@
1616
#define LLVM_SUPPORT_WIN_ADAPTER_H
1717

1818
// Mach change start
19+
#ifndef _WIN32
20+
#include <rpcndr.h>
21+
#include <basetsd.h>
22+
#undef interface
23+
#undef HeapAlloc
24+
#undef HeapFree
25+
#undef __emulated_uuidof
26+
#undef __uuidof
27+
#endif
28+
1929
#include "ZigGNUWinAdapter.h"
2030
// Mach change end
2131

@@ -44,7 +54,9 @@
4454
// Begin: Macro Definitions
4555
//
4656
//===----------------------------------------------------------------------===//
47-
#define C_ASSERT(expr) static_assert((expr), "")
57+
// Mach change start
58+
// #define C_ASSERT(expr) static_assert((expr), "")
59+
// Mach change end
4860
#define ATLASSERT assert
4961

5062
#define CoTaskMemAlloc malloc
@@ -72,11 +84,15 @@
7284
#define STDMETHODCALLTYPE
7385
#define STDMETHODIMP_(type) type STDMETHODCALLTYPE
7486
#define STDMETHODIMP STDMETHODIMP_(HRESULT)
75-
#define STDMETHOD_(type, name) virtual STDMETHODIMP_(type) name
76-
#define STDMETHOD(name) STDMETHOD_(HRESULT, name)
87+
// Mach change start
88+
// #define STDMETHOD_(type, name) virtual STDMETHODIMP_(type) name
89+
// #define STDMETHOD(name) STDMETHOD_(HRESULT, name)
90+
// Mach change end
7791
#define EXTERN_C extern "C"
7892

79-
#define UNREFERENCED_PARAMETER(P) (void)(P)
93+
// Mach change start
94+
// #define UNREFERENCED_PARAMETER(P) (void)(P)
95+
// Mach change end
8096

8197
#define RtlEqualMemory(Destination, Source, Length) \
8298
(!memcmp((Destination), (Source), (Length)))
@@ -92,8 +108,10 @@
92108
#define FillMemory RtlFillMemory
93109
#define ZeroMemory RtlZeroMemory
94110

95-
#define FALSE 0
96-
#define TRUE 1
111+
// Mach change start
112+
// #define FALSE 0
113+
// #define TRUE 1
114+
// Mach change end
97115

98116
// We ignore the code page completely on Linux.
99117
#define GetConsoleOutputCP() 0
@@ -223,18 +241,24 @@
223241
#define S_OK ((HRESULT)0L)
224242
#define S_FALSE ((HRESULT)1L)
225243

226-
#define E_ABORT (HRESULT)0x80004004
227-
#define E_ACCESSDENIED (HRESULT)0x80070005
244+
// Mach change start
245+
// #define E_ABORT (HRESULT)0x80004004
246+
// #define E_ACCESSDENIED (HRESULT)0x80070005
247+
// Mach change end
228248
#define E_BOUNDS (HRESULT)0x8000000B
229-
#define E_FAIL (HRESULT)0x80004005
230-
#define E_HANDLE (HRESULT)0x80070006
231-
#define E_INVALIDARG (HRESULT)0x80070057
232-
#define E_NOINTERFACE (HRESULT)0x80004002
249+
// Mach change start
250+
// #define E_FAIL (HRESULT)0x80004005
251+
// #define E_HANDLE (HRESULT)0x80070006
252+
// #define E_INVALIDARG (HRESULT)0x80070057
253+
// #define E_NOINTERFACE (HRESULT)0x80004002
254+
// Mach change end
233255
#define E_NOTIMPL (HRESULT)0x80004001
234256
#define E_NOT_VALID_STATE (HRESULT)0x8007139F
235-
#define E_OUTOFMEMORY (HRESULT)0x8007000E
236-
#define E_POINTER (HRESULT)0x80004003
237-
#define E_UNEXPECTED (HRESULT)0x8000FFFF
257+
// Mach change start
258+
// #define E_OUTOFMEMORY (HRESULT)0x8007000E
259+
// #define E_POINTER (HRESULT)0x80004003
260+
// #define E_UNEXPECTED (HRESULT)0x8000FFFF
261+
// Mach change end
238262

239263
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
240264
#define FAILED(hr) (((HRESULT)(hr)) < 0)
@@ -273,8 +297,10 @@
273297
#define _COM_Outptr_result_maybenull_
274298
#define _COM_Outptr_opt_result_maybenull_
275299

276-
#define THIS_
277-
#define THIS
300+
// Mach change start
301+
// #define THIS_
302+
// #define THIS
303+
// Mach change end
278304
#define PURE = 0
279305

280306
#define _Maybenull_
@@ -303,20 +329,24 @@
303329
typedef unsigned char BYTE, UINT8;
304330
typedef unsigned char *LPBYTE;
305331

306-
typedef BYTE BOOLEAN;
307-
typedef BOOLEAN *PBOOLEAN;
332+
// Mach change start
333+
// typedef BYTE BOOLEAN;
334+
// typedef BOOLEAN *PBOOLEAN;
308335

309-
typedef bool BOOL;
336+
// typedef bool BOOL;
337+
// Mach change end
310338
typedef BOOL *LPBOOL;
311339

312-
typedef int INT;
313-
typedef long LONG;
314-
typedef unsigned int UINT;
315-
typedef unsigned long ULONG;
316-
typedef long long LONGLONG;
317-
typedef long long LONG_PTR;
318-
typedef unsigned long long ULONG_PTR;
319-
typedef unsigned long long ULONGLONG;
340+
// Mach change start
341+
// typedef int INT;
342+
// typedef long LONG;
343+
// typedef unsigned int UINT;
344+
// typedef unsigned long ULONG;
345+
// typedef long long LONGLONG;
346+
// typedef long long LONG_PTR;
347+
// typedef unsigned long long ULONG_PTR;
348+
// typedef unsigned long long ULONGLONG;
349+
// Mach change end
320350

321351
typedef uint16_t WORD;
322352
typedef uint32_t DWORD;
@@ -350,7 +380,9 @@ typedef const void *LPCVOID;
350380

351381
typedef std::nullptr_t nullptr_t;
352382

353-
typedef signed int HRESULT;
383+
// Mach change start
384+
// typedef signed int HRESULT;
385+
// Mach change end
354386

355387
//===--------------------- Handle Types -----------------------------------===//
356388

@@ -372,30 +404,34 @@ typedef void *HMODULE;
372404

373405
//===--------------------- ID Types and Macros for COM --------------------===//
374406

375-
#ifdef __EMULATE_UUID
376-
struct GUID
377-
#else // __EMULATE_UUID
378-
// These specific definitions are required by clang -fms-extensions.
379-
typedef struct _GUID
380-
#endif // __EMULATE_UUID
381-
{
382-
uint32_t Data1;
383-
uint16_t Data2;
384-
uint16_t Data3;
385-
uint8_t Data4[8];
386-
}
387-
#ifdef __EMULATE_UUID
388-
;
389-
#else // __EMULATE_UUID
390-
GUID;
391-
#endif // __EMULATE_UUID
392-
typedef GUID CLSID;
393-
typedef const GUID &REFGUID;
394-
typedef const GUID &REFCLSID;
395-
396-
typedef GUID IID;
407+
// Mach change start
408+
// #ifdef __EMULATE_UUID
409+
// struct GUID
410+
// #else // __EMULATE_UUID
411+
// // These specific definitions are required by clang -fms-extensions.
412+
// typedef struct _GUID
413+
// #endif // __EMULATE_UUID
414+
// {
415+
// uint32_t Data1;
416+
// uint16_t Data2;
417+
// uint16_t Data3;
418+
// uint8_t Data4[8];
419+
// }
420+
// #ifdef __EMULATE_UUID
421+
// ;
422+
// #else // __EMULATE_UUID
423+
// GUID;
424+
// #endif // __EMULATE_UUID
425+
// typedef GUID CLSID;
426+
// typedef const GUID &REFGUID;
427+
// typedef const GUID &REFCLSID;
428+
429+
// typedef GUID IID;
430+
// Mach change end
397431
typedef IID *LPIID;
398-
typedef const IID &REFIID;
432+
// Mach change start
433+
// typedef const IID &REFIID;
434+
// Mach change end
399435
inline bool IsEqualGUID(REFGUID rguid1, REFGUID rguid2) {
400436
// Optimization:
401437
if (&rguid1 == &rguid2)
@@ -404,13 +440,15 @@ inline bool IsEqualGUID(REFGUID rguid1, REFGUID rguid2) {
404440
return !memcmp(&rguid1, &rguid2, sizeof(GUID));
405441
}
406442

407-
inline bool operator==(REFGUID guidOne, REFGUID guidOther) {
408-
return !!IsEqualGUID(guidOne, guidOther);
409-
}
443+
// Mach change start
444+
// inline bool operator==(REFGUID guidOne, REFGUID guidOther) {
445+
// return !!IsEqualGUID(guidOne, guidOther);
446+
// }
410447

411-
inline bool operator!=(REFGUID guidOne, REFGUID guidOther) {
412-
return !(guidOne == guidOther);
413-
}
448+
// inline bool operator!=(REFGUID guidOne, REFGUID guidOther) {
449+
// return !(guidOne == guidOther);
450+
// }
451+
// Mach change end
414452

415453
inline bool IsEqualIID(REFIID riid1, REFIID riid2) {
416454
return IsEqualGUID(riid1, riid2);
@@ -454,27 +492,32 @@ typedef struct _WIN32_FIND_DATAW {
454492
WCHAR cAlternateFileName[14];
455493
} WIN32_FIND_DATAW, *PWIN32_FIND_DATAW, *LPWIN32_FIND_DATAW;
456494

457-
typedef union _LARGE_INTEGER {
458-
struct {
459-
DWORD LowPart;
460-
DWORD HighPart;
461-
} u;
462-
LONGLONG QuadPart;
463-
} LARGE_INTEGER;
464-
465-
typedef LARGE_INTEGER *PLARGE_INTEGER;
466-
467-
typedef union _ULARGE_INTEGER {
468-
struct {
469-
DWORD LowPart;
470-
DWORD HighPart;
471-
} u;
472-
ULONGLONG QuadPart;
473-
} ULARGE_INTEGER;
474-
475-
typedef ULARGE_INTEGER *PULARGE_INTEGER;
495+
// Mach change start
496+
// typedef union _LARGE_INTEGER {
497+
// struct {
498+
// DWORD LowPart;
499+
// DWORD HighPart;
500+
// } u;
501+
// LONGLONG QuadPart;
502+
// } LARGE_INTEGER;
503+
504+
// typedef LARGE_INTEGER *PLARGE_INTEGER;
505+
506+
// typedef union _ULARGE_INTEGER {
507+
// struct {
508+
// DWORD LowPart;
509+
// DWORD HighPart;
510+
// } u;
511+
// ULONGLONG QuadPart;
512+
// } ULARGE_INTEGER;
513+
514+
// typedef ULARGE_INTEGER *PULARGE_INTEGER;
515+
// Mach change end
476516

477-
typedef struct tagSTATSTG {
517+
// Mach change start
518+
// typedef struct tagSTATSTG {
519+
typedef struct STATSTG {
520+
// Mach change end
478521
LPOLESTR pwcsName;
479522
DWORD type;
480523
ULARGE_INTEGER cbSize;
@@ -556,20 +599,24 @@ template <typename interface> inline GUID __emulated_uuidof();
556599
struct __declspec(uuid(spec)) interface;
557600
#endif
558601

559-
template <typename T> inline void **IID_PPV_ARGS_Helper(T **pp) {
560-
return reinterpret_cast<void **>(pp);
561-
}
562-
#define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType)
602+
// Mach change start
603+
// template <typename T> inline void **IID_PPV_ARGS_Helper(T **pp) {
604+
// return reinterpret_cast<void **>(pp);
605+
// }
606+
// #define IID_PPV_ARGS(ppType) __uuidof(**(ppType)), IID_PPV_ARGS_Helper(ppType)
607+
// Mach change end
563608

564609
#endif // __EMULATE_UUID
565610

566-
// Needed for d3d headers, but fail to create actual interfaces
567-
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
568-
const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
569-
#define DECLSPEC_UUID(x)
570-
#define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x)
571-
#define DECLARE_INTERFACE(iface) struct iface
572-
#define DECLARE_INTERFACE_(iface, parent) DECLARE_INTERFACE(iface) : parent
611+
// Mach change start
612+
// // Needed for d3d headers, but fail to create actual interfaces
613+
// #define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
614+
// const GUID name = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}
615+
// #define DECLSPEC_UUID(x)
616+
// #define MIDL_INTERFACE(x) struct DECLSPEC_UUID(x)
617+
// #define DECLARE_INTERFACE(iface) struct iface
618+
// #define DECLARE_INTERFACE_(iface, parent) DECLARE_INTERFACE(iface) : parent
619+
// Mach change end
573620

574621
//===--------------------- COM Interfaces ---------------------------------===//
575622

include/dxc/ZigGNUWinAdapter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,5 +1113,7 @@ CROSS_PLATFORM_UUIDOF(IDxcPixDxilDebugInfoFactory, "9c2a040d-8068-44ec-8c68-8bfe
11131113

11141114
#endif // __cplusplus
11151115

1116+
#undef ReplaceText
1117+
11161118
#endif // defined(__clang__) && !defined(_MSC_VER) && defined(_WIN32) // Zig windows-gnu target
11171119
#endif // LLVM_SUPPORT_ZIG_GNU_WIN_ADAPTER_H

lib/DxcSupport/Unicode.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ int WideCharToMultiByte(uint32_t CodePage, uint32_t /*dwFlags*/,
7676
const wchar_t *lpWideCharStr, int cchWideChar,
7777
char *lpMultiByteStr, int cbMultiByte,
7878
const char * /*lpDefaultChar*/,
79-
bool * /*lpUsedDefaultChar*/) {
79+
// Mach change start
80+
// bool * /*lpUsedDefaultChar*/) {
81+
LPBOOL /*lpUsedDefaultChar*/) {
82+
// Mach change end
8083

8184
if (cchWideChar == 0) {
8285
SetLastError(ERROR_INVALID_PARAMETER);
@@ -139,14 +142,20 @@ bool WideToEncodedString(const wchar_t *text, size_t cWide, DWORD cp,
139142
}
140143

141144
int cbUTF8 = ::WideCharToMultiByte(cp, flags, text, cWide, nullptr, 0,
142-
nullptr, pUsedDefaultChar);
145+
// Mach change start
146+
// nullptr, pUsedDefaultChar);
147+
nullptr, (LPBOOL)pUsedDefaultChar);
148+
// Mach change end
143149
if (cbUTF8 == 0)
144150
return false;
145151

146152
pValue->resize(cbUTF8);
147153

148154
cbUTF8 = ::WideCharToMultiByte(cp, flags, text, cWide, &(*pValue)[0],
149-
pValue->size(), nullptr, pUsedDefaultChar);
155+
// Mach change start
156+
// pValue->size(), nullptr, pUsedDefaultChar);
157+
pValue->size(), nullptr, (LPBOOL)pUsedDefaultChar);
158+
// Mach change end
150159
DXASSERT(cbUTF8 > 0, "otherwise contents have changed");
151160
DXASSERT((*pValue)[pValue->size()] == '\0',
152161
"otherwise string didn't null-terminate after resize() call");

0 commit comments

Comments
 (0)