Skip to content

Commit f14b0cc

Browse files
authored
Direct3D WSL build header changes (microsoft#5843)
Header changes to make Direct3D WSL build work: - Move non-WIN32 IMalloc definition back to `WinAdapter.h` (it was there until commit 44f8833) - Define DEFINE_ENUM_FLAG_OPERATORS only if it was not already defined
1 parent 0390942 commit f14b0cc

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

include/dxc/Support/WinIncludes.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ template <class T> void swap(CComHeapPtr<T> &a, CComHeapPtr<T> &b) {
6666
#include "dxc/WinAdapter.h"
6767

6868
#ifdef __cplusplus
69+
#if !defined(DEFINE_ENUM_FLAG_OPERATORS)
6970
// Define operator overloads to enable bit operations on enum values that are
7071
// used to define flags. Use DEFINE_ENUM_FLAG_OPERATORS(YOUR_TYPE) to enable
7172
// these operators on YOUR_TYPE.
@@ -113,6 +114,7 @@ template <class T> struct _ENUM_FLAG_SIZED_INTEGER {
113114
((_ENUM_FLAG_SIZED_INTEGER<ENUMTYPE>::type)b)); \
114115
} \
115116
}
117+
#endif // !defined(DEFINE_ENUM_FLAG_OPERATORS)
116118
#else
117119
#define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) // NOP, C allows these operators.
118120
#endif
@@ -127,15 +129,7 @@ template <class T> struct _ENUM_FLAG_SIZED_INTEGER {
127129
#else // defined(_WIN32) && !defined(DXC_DISABLE_ALLOCATOR_OVERRIDES)
128130

129131
#ifndef _WIN32
130-
CROSS_PLATFORM_UUIDOF(IMalloc, "00000002-0000-0000-C000-000000000046")
131-
struct IMalloc : public IUnknown {
132-
virtual void *Alloc(SIZE_T size) = 0;
133-
virtual void *Realloc(void *ptr, SIZE_T size) = 0;
134-
virtual void Free(void *ptr) = 0;
135-
virtual SIZE_T GetSize(void *pv) = 0;
136-
virtual int DidAlloc(void *pv) = 0;
137-
virtual void HeapMinimize(void) = 0;
138-
};
132+
struct IMalloc;
139133
#endif
140134

141135
HRESULT DxcCoGetMalloc(DWORD dwMemContext, IMalloc **ppMalloc);

include/dxc/WinAdapter.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,16 @@ struct IUnknown {
583583
CROSS_PLATFORM_UUIDOF(INoMarshal, "ECC8691B-C1DB-4DC0-855E-65F6C551AF49")
584584
struct INoMarshal : public IUnknown {};
585585

586+
CROSS_PLATFORM_UUIDOF(IMalloc, "00000002-0000-0000-C000-000000000046")
587+
struct IMalloc : public IUnknown {
588+
virtual void *Alloc(SIZE_T size) = 0;
589+
virtual void *Realloc(void *ptr, SIZE_T size) = 0;
590+
virtual void Free(void *ptr) = 0;
591+
virtual SIZE_T GetSize(void *pv) = 0;
592+
virtual int DidAlloc(void *pv) = 0;
593+
virtual void HeapMinimize(void) = 0;
594+
};
595+
586596
CROSS_PLATFORM_UUIDOF(ISequentialStream, "0C733A30-2A1C-11CE-ADE5-00AA0044773D")
587597
struct ISequentialStream : public IUnknown {
588598
virtual HRESULT Read(void *pv, ULONG cb, ULONG *pcbRead) = 0;

0 commit comments

Comments
 (0)