diff --git a/src/microsoft/compiler/dxcapi.h b/src/microsoft/compiler/dxcapi.h index 08a98748c38..0cb61dff272 100644 --- a/src/microsoft/compiler/dxcapi.h +++ b/src/microsoft/compiler/dxcapi.h @@ -23,16 +23,52 @@ #endif #endif -#ifdef _WIN32 - +#include #ifndef CROSS_PLATFORM_UUIDOF // Warning: This macro exists in WinAdapter.h as well -#define CROSS_PLATFORM_UUIDOF(interface, spec) \ - struct __declspec(uuid(spec)) interface; +#if defined(_MSC_VER) +#define CROSS_PLATFORM_UUIDOF(iface, spec) \ + struct __declspec(uuid(spec)) iface; +#else /* defined(_MSC_VER) */ +#if defined(__MINGW32__) +#include +#include +#ifndef _Maybenull_ +#define _Maybenull_ #endif - -#else - +#ifndef _In_count_ +#define _In_count_(x) +#endif +#ifndef _In_opt_count_ +#define _In_opt_count_(x) +#endif +#ifndef _In_bytecount_ +#define _In_bytecount_(x) +#endif +#endif /* defined(__MINGW32__) */ +#ifndef __CRT_UUID_DECL +#define __CRT_UUID_DECL(type, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + extern "C++" \ + { \ + template <> \ + struct __mesa_emulated_uuidof_s \ + { \ + static constexpr IID __uuid_inst = { \ + l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}; \ + }; \ + template <> \ + constexpr const GUID &__mesa_emulated_uuidof() \ + { \ + return __mesa_emulated_uuidof_s::__uuid_inst; \ + } \ + template <> \ + constexpr const GUID &__mesa_emulated_uuidof() \ + { \ + return __mesa_emulated_uuidof_s::__uuid_inst; \ + } \ + } +#define __uuidof(T) __mesa_emulated_uuidof::type>() +#endif /*__CRT_UUID_DECL */ constexpr uint8_t nybble_from_hex(char c) { return ((c >= '0' && c <= '9') ? (c - '0') @@ -50,30 +86,37 @@ constexpr uint8_t byte_from_hexstr(const char str[2]) { return nybble_from_hex(str[0]) << 4 | nybble_from_hex(str[1]); } -constexpr GUID guid_from_string(const char str[37]) { - return GUID{ static_cast(byte_from_hexstr(str)) << 24 | - static_cast(byte_from_hexstr(str + 2)) << 16 | - static_cast(byte_from_hexstr(str + 4)) << 8 | - byte_from_hexstr(str + 6), - static_cast( - static_cast(byte_from_hexstr(str + 9)) << 8 | - byte_from_hexstr(str + 11)), - static_cast( - static_cast(byte_from_hexstr(str + 14)) << 8 | - byte_from_hexstr(str + 16)), - {byte_from_hexstr(str + 19), byte_from_hexstr(str + 21), - byte_from_hexstr(str + 24), byte_from_hexstr(str + 26), - byte_from_hexstr(str + 28), byte_from_hexstr(str + 30), - byte_from_hexstr(str + 32), byte_from_hexstr(str + 34)} }; +constexpr unsigned short short_from_hexstr(const char str[2], unsigned shift) +{ + return ((unsigned short)(nybble_from_hex(str[0]) << 4 | + nybble_from_hex(str[1]))) + << shift; } -#define CROSS_PLATFORM_UUIDOF(interface, spec) \ - struct interface; \ - template <> constexpr GUID uuidof() { \ - constexpr IID _IID = guid_from_string(spec); \ - return _IID; \ - } +constexpr unsigned long word_from_hexstr(const char str[2], unsigned shift) +{ + return ((unsigned long)(nybble_from_hex(str[0]) << 4 | + nybble_from_hex(str[1]))) + << shift; +} +#define CROSS_PLATFORM_UUIDOF(iface, spec) \ + struct iface; \ + __CRT_UUID_DECL( \ + iface, \ + word_from_hexstr(spec, 24) | word_from_hexstr(spec + 2, 16) | \ + word_from_hexstr(spec + 4, 8) | word_from_hexstr(spec + 6, 0), \ + short_from_hexstr(spec + 9, 8) | short_from_hexstr(spec + 11, 0), \ + short_from_hexstr(spec + 14, 8) | short_from_hexstr(spec + 16, 0), \ + byte_from_hexstr(spec + 19), byte_from_hexstr(spec + 21), \ + byte_from_hexstr(spec + 24), byte_from_hexstr(spec + 26), \ + byte_from_hexstr(spec + 28), byte_from_hexstr(spec + 30), \ + byte_from_hexstr(spec + 32), byte_from_hexstr(spec + 34)) + +#endif /* defined(_MSC_VER) */ +#endif /* CROSS_PLATFORM_UUIDOF */ + +#ifndef _WIN32 CROSS_PLATFORM_UUIDOF(INoMarshal, "ECC8691B-C1DB-4DC0-855E-65F6C551AF49") struct INoMarshal : public IUnknown {};