2016-09-21 03:57:24 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2016 Józef Kucia for CodeWeavers
|
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2016-09-21 03:57:24 -07:00
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2016-09-21 03:57:24 -07:00
|
|
|
*
|
2017-06-16 12:05:54 -07:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2016-09-21 03:57:24 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VKD3D_WINDOWS_H
|
|
|
|
#define __VKD3D_WINDOWS_H
|
2017-12-15 06:16:22 -08:00
|
|
|
#ifndef _INC_WINDOWS
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2019-01-31 02:29:32 -08:00
|
|
|
/* Nameless unions */
|
|
|
|
#ifndef __C89_NAMELESS
|
|
|
|
# ifdef NONAMELESSUNION
|
|
|
|
# define __C89_NAMELESS
|
|
|
|
# define __C89_NAMELESSUNIONNAME u
|
|
|
|
# else
|
|
|
|
# define __C89_NAMELESS
|
|
|
|
# define __C89_NAMELESSUNIONNAME
|
|
|
|
# endif /* NONAMELESSUNION */
|
|
|
|
#endif /* __C89_NAMELESS */
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#if !defined(_WIN32) || defined(__WIDL__)
|
|
|
|
|
2020-05-29 04:49:30 -07:00
|
|
|
# if !defined(__WIDL__)
|
|
|
|
# if !defined(VKD3D_WIN32_WCHAR)
|
|
|
|
# include <wchar.h>
|
|
|
|
# endif
|
|
|
|
# include <stdint.h>
|
2017-08-02 01:45:06 -07:00
|
|
|
# endif
|
|
|
|
|
2016-10-10 08:12:22 -07:00
|
|
|
# ifdef __GNUC__
|
|
|
|
# define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
|
|
|
|
# endif
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
/* HRESULT */
|
|
|
|
typedef int HRESULT;
|
2016-09-21 05:15:51 -07:00
|
|
|
# define SUCCEEDED(hr) ((HRESULT)(hr) >= 0)
|
|
|
|
# define FAILED(hr) ((HRESULT)(hr) < 0)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2016-09-21 05:15:51 -07:00
|
|
|
# define _HRESULT_TYPEDEF_(x) ((HRESULT)x)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2016-09-21 05:15:51 -07:00
|
|
|
# define S_OK _HRESULT_TYPEDEF_(0)
|
|
|
|
# define S_FALSE _HRESULT_TYPEDEF_(1)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2016-09-21 05:15:51 -07:00
|
|
|
# define E_NOTIMPL _HRESULT_TYPEDEF_(0x80004001)
|
|
|
|
# define E_NOINTERFACE _HRESULT_TYPEDEF_(0x80004002)
|
|
|
|
# define E_POINTER _HRESULT_TYPEDEF_(0x80004003)
|
|
|
|
# define E_ABORT _HRESULT_TYPEDEF_(0x80004004)
|
|
|
|
# define E_FAIL _HRESULT_TYPEDEF_(0x80004005)
|
|
|
|
# define E_OUTOFMEMORY _HRESULT_TYPEDEF_(0x8007000E)
|
|
|
|
# define E_INVALIDARG _HRESULT_TYPEDEF_(0x80070057)
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2019-01-03 05:23:01 -08:00
|
|
|
# define DXGI_ERROR_NOT_FOUND _HRESULT_TYPEDEF_(0x887a0002)
|
|
|
|
# define DXGI_ERROR_MORE_DATA _HRESULT_TYPEDEF_(0x887a0003)
|
2023-07-16 23:42:48 -07:00
|
|
|
# define DXGI_ERROR_UNSUPPORTED _HRESULT_TYPEDEF_(0x887a0004)
|
2019-01-03 05:23:01 -08:00
|
|
|
|
2020-09-29 14:14:51 -07:00
|
|
|
# define D3DERR_INVALIDCALL _HRESULT_TYPEDEF_(0x8876086c)
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
/* Basic types */
|
|
|
|
typedef unsigned char BYTE;
|
|
|
|
typedef unsigned int DWORD;
|
|
|
|
typedef int INT;
|
|
|
|
typedef unsigned int UINT;
|
|
|
|
typedef int LONG;
|
|
|
|
typedef unsigned int ULONG;
|
|
|
|
typedef float FLOAT;
|
|
|
|
typedef LONG BOOL;
|
|
|
|
|
2016-09-21 05:15:51 -07:00
|
|
|
/* Assuming LP64 model */
|
|
|
|
typedef char INT8;
|
2016-09-21 03:57:24 -07:00
|
|
|
typedef unsigned char UINT8;
|
2016-09-21 05:15:51 -07:00
|
|
|
typedef short INT16;
|
2016-09-21 03:57:24 -07:00
|
|
|
typedef unsigned short UINT16;
|
2016-09-21 05:15:51 -07:00
|
|
|
typedef int INT32;
|
2016-09-21 03:57:24 -07:00
|
|
|
typedef unsigned int UINT32;
|
2020-05-29 04:49:30 -07:00
|
|
|
# if defined(__WIDL__)
|
|
|
|
typedef __int64 INT64;
|
|
|
|
typedef unsigned __int64 UINT64;
|
2016-09-21 05:15:51 -07:00
|
|
|
# else
|
2020-05-29 04:49:30 -07:00
|
|
|
typedef int64_t DECLSPEC_ALIGN(8) INT64;
|
|
|
|
typedef uint64_t DECLSPEC_ALIGN(8) UINT64;
|
2016-09-21 05:15:51 -07:00
|
|
|
# endif
|
2022-02-21 07:18:59 -08:00
|
|
|
typedef INT64 LONG64;
|
2016-09-21 03:57:24 -07:00
|
|
|
typedef long LONG_PTR;
|
|
|
|
typedef unsigned long ULONG_PTR;
|
|
|
|
|
|
|
|
typedef ULONG_PTR SIZE_T;
|
|
|
|
|
2017-08-02 01:45:06 -07:00
|
|
|
# ifdef VKD3D_WIN32_WCHAR
|
2016-09-21 03:57:24 -07:00
|
|
|
typedef unsigned short WCHAR;
|
2017-08-02 01:45:06 -07:00
|
|
|
# else
|
|
|
|
typedef wchar_t WCHAR;
|
|
|
|
# endif /* VKD3D_WIN32_WCHAR */
|
2016-09-21 03:57:24 -07:00
|
|
|
typedef void *HANDLE;
|
|
|
|
|
|
|
|
/* GUID */
|
|
|
|
# ifdef __WIDL__
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
unsigned long Data1;
|
|
|
|
unsigned short Data2;
|
|
|
|
unsigned short Data3;
|
|
|
|
unsigned char Data4[8];
|
|
|
|
} GUID;
|
|
|
|
# else
|
|
|
|
typedef struct _GUID
|
|
|
|
{
|
|
|
|
unsigned int Data1;
|
|
|
|
unsigned short Data2;
|
|
|
|
unsigned short Data3;
|
|
|
|
unsigned char Data4[8];
|
|
|
|
} GUID;
|
|
|
|
# endif
|
|
|
|
|
|
|
|
typedef GUID IID;
|
|
|
|
|
|
|
|
# ifdef INITGUID
|
|
|
|
# ifndef __cplusplus
|
|
|
|
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
2022-03-01 04:21:30 -08:00
|
|
|
const GUID name DECLSPEC_HIDDEN; \
|
2016-09-21 03:57:24 -07:00
|
|
|
const GUID name = \
|
|
|
|
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 }}
|
|
|
|
# else
|
|
|
|
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
2022-03-01 04:21:30 -08:00
|
|
|
EXTERN_C const GUID name DECLSPEC_HIDDEN; \
|
2016-09-21 03:57:24 -07:00
|
|
|
EXTERN_C const GUID name = \
|
|
|
|
{ l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 }}
|
|
|
|
# endif
|
|
|
|
# else
|
|
|
|
# define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
2022-03-01 04:21:30 -08:00
|
|
|
EXTERN_C const GUID name DECLSPEC_HIDDEN;
|
2016-09-21 03:57:24 -07:00
|
|
|
# endif /* INITGUID */
|
|
|
|
|
2018-04-03 02:49:14 -07:00
|
|
|
/* __uuidof emulation */
|
|
|
|
#if defined(__cplusplus) && !defined(_MSC_VER)
|
|
|
|
|
|
|
|
extern "C++"
|
|
|
|
{
|
|
|
|
template<typename T> const GUID &__vkd3d_uuidof();
|
|
|
|
}
|
|
|
|
|
|
|
|
# define __CRT_UUID_DECL(type, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
|
|
|
|
extern "C++" \
|
|
|
|
{ \
|
|
|
|
template<> inline const GUID &__vkd3d_uuidof<type>() \
|
|
|
|
{ \
|
|
|
|
static const IID __uuid_inst = {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}; \
|
|
|
|
return __uuid_inst; \
|
|
|
|
} \
|
|
|
|
template<> inline const GUID &__vkd3d_uuidof<type *>() \
|
|
|
|
{ \
|
|
|
|
return __vkd3d_uuidof<type>(); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
# define __uuidof(type) __vkd3d_uuidof<typeof(type)>()
|
|
|
|
#else
|
|
|
|
# define __CRT_UUID_DECL(type, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
|
|
|
|
#endif /* defined(__cplusplus) && !defined(_MSC_VER) */
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
|
|
|
|
#endif /* !defined(_WIN32) || defined(__WIDL__) */
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
|
|
|
|
#ifndef _WIN32
|
2016-09-21 03:57:24 -07:00
|
|
|
# include <stddef.h>
|
2016-09-21 03:57:24 -07:00
|
|
|
# include <stdlib.h>
|
2016-09-21 03:57:24 -07:00
|
|
|
# include <string.h>
|
2016-09-21 03:57:24 -07:00
|
|
|
|
|
|
|
# define COM_NO_WINDOWS_H
|
|
|
|
|
|
|
|
# define FORCEINLINE inline
|
|
|
|
|
|
|
|
# define CONTAINING_RECORD(address, type, field) \
|
|
|
|
((type *)((char *)(address) - offsetof(type, field)))
|
|
|
|
|
|
|
|
# ifdef __x86_64__
|
2017-09-18 06:40:42 -07:00
|
|
|
# define __stdcall __attribute__((ms_abi))
|
2016-09-21 03:57:24 -07:00
|
|
|
# else
|
2018-05-23 03:14:47 -07:00
|
|
|
# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
|
|
|
|
# define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))
|
|
|
|
# else
|
|
|
|
# define __stdcall __attribute__((__stdcall__))
|
|
|
|
# endif
|
2016-09-21 03:57:24 -07:00
|
|
|
# endif
|
|
|
|
|
2017-09-18 06:40:42 -07:00
|
|
|
# define WINAPI __stdcall
|
|
|
|
# define STDMETHODCALLTYPE __stdcall
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
# ifdef __GNUC__
|
|
|
|
# define DECLSPEC_SELECTANY __attribute__((weak))
|
|
|
|
# endif
|
|
|
|
|
|
|
|
/* Macros for COM interfaces */
|
|
|
|
# define interface struct
|
|
|
|
# define BEGIN_INTERFACE
|
|
|
|
# define END_INTERFACE
|
2018-04-13 03:37:44 -07:00
|
|
|
# define MIDL_INTERFACE(x) struct
|
2016-09-21 03:57:24 -07:00
|
|
|
|
|
|
|
# ifdef __cplusplus
|
|
|
|
# define EXTERN_C extern "C"
|
|
|
|
# else
|
|
|
|
# define EXTERN_C extern
|
|
|
|
# endif
|
|
|
|
|
|
|
|
# define CONST_VTBL const
|
|
|
|
|
|
|
|
# define TRUE 1
|
|
|
|
# define FALSE 0
|
|
|
|
|
|
|
|
# if defined(__cplusplus) && !defined(CINTERFACE)
|
|
|
|
# define REFIID const IID &
|
|
|
|
# define REFGUID const GUID &
|
|
|
|
# else
|
|
|
|
# define REFIID const IID * const
|
|
|
|
# define REFGUID const GUID * const
|
|
|
|
# endif
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#if defined(__cplusplus) && !defined(CINTERFACE)
|
|
|
|
# define IsEqualGUID(guid1, guid2) (!memcmp(&(guid1), &(guid2), sizeof(GUID)))
|
|
|
|
#else
|
|
|
|
# define IsEqualGUID(guid1, guid2) (!memcmp(guid1, guid2, sizeof(GUID)))
|
|
|
|
#endif
|
|
|
|
|
2016-09-21 03:57:24 -07:00
|
|
|
#elif !defined(__WIDL__)
|
|
|
|
|
|
|
|
# include <windows.h>
|
2016-09-21 03:57:24 -07:00
|
|
|
|
2016-09-27 03:13:37 -07:00
|
|
|
#endif /* _WIN32 */
|
|
|
|
|
|
|
|
|
2022-03-01 04:21:30 -08:00
|
|
|
/* Define DECLSPEC_HIDDEN */
|
|
|
|
#ifndef DECLSPEC_HIDDEN
|
|
|
|
# if defined(__MINGW32__)
|
|
|
|
# define DECLSPEC_HIDDEN
|
|
|
|
# elif defined(__GNUC__)
|
|
|
|
# define DECLSPEC_HIDDEN __attribute__((visibility("hidden")))
|
|
|
|
# else
|
|
|
|
# define DECLSPEC_HIDDEN
|
|
|
|
# endif
|
|
|
|
#endif /* DECLSPEC_HIDDEN */
|
|
|
|
|
2016-09-28 00:42:49 -07:00
|
|
|
/* Define min() & max() macros */
|
2017-07-18 09:56:49 -07:00
|
|
|
#ifndef NOMINMAX
|
|
|
|
# ifndef min
|
|
|
|
# define min(a, b) (((a) <= (b)) ? (a) : (b))
|
|
|
|
# endif
|
2016-09-28 00:42:49 -07:00
|
|
|
|
2017-07-18 09:56:49 -07:00
|
|
|
# ifndef max
|
|
|
|
# define max(a, b) (((a) >= (b)) ? (a) : (b))
|
|
|
|
# endif
|
|
|
|
#endif /* NOMINMAX */
|
2016-09-28 00:42:49 -07:00
|
|
|
|
2017-06-15 08:09:50 -07:00
|
|
|
#ifndef DEFINE_ENUM_FLAG_OPERATORS
|
|
|
|
#ifdef __cplusplus
|
|
|
|
# define DEFINE_ENUM_FLAG_OPERATORS(type) \
|
|
|
|
extern "C++" \
|
|
|
|
{ \
|
|
|
|
inline type operator &(type x, type y) { return (type)((int)x & (int)y); } \
|
|
|
|
inline type operator &=(type &x, type y) { return (type &)((int &)x &= (int)y); } \
|
|
|
|
inline type operator ~(type x) { return (type)~(int)x; } \
|
|
|
|
inline type operator |(type x, type y) { return (type)((int)x | (int)y); } \
|
|
|
|
inline type operator |=(type &x, type y) { return (type &)((int &)x |= (int)y); } \
|
|
|
|
inline type operator ^(type x, type y) { return (type)((int)x ^ (int)y); } \
|
|
|
|
inline type operator ^=(type &x, type y) { return (type &)((int &)x ^= (int)y); } \
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define DEFINE_ENUM_FLAG_OPERATORS(type)
|
|
|
|
#endif
|
|
|
|
#endif /* DEFINE_ENUM_FLAG_OPERATORS */
|
|
|
|
|
2017-12-15 06:16:22 -08:00
|
|
|
#endif /* _INC_WINDOWS */
|
2016-09-21 03:57:24 -07:00
|
|
|
#endif /* __VKD3D_WINDOWS_H */
|