libs/vkd3d: Make vkd3d debug compatible with MinGW headers.

This commit is contained in:
Józef Kucia 2016-09-28 09:42:49 +02:00
parent 821d978950
commit ef80cdedc3
4 changed files with 27 additions and 15 deletions

View File

@ -139,7 +139,6 @@ typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
# ifdef __GNUC__
# define DECLSPEC_SELECTANY __attribute__((weak))
# define DECLSPEC_HIDDEN __attribute__((visibility("hidden")))
# endif
/* Macros for COM interfaces */
@ -190,6 +189,17 @@ typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES;
# endif /* NONAMELESSUNION */
#endif /* __C89_NAMELESS */
/* 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 */
/* Define min() & max() macros */
#ifndef min
# define min(a, b) (((a) <= (b)) ? (a) : (b))

View File

@ -84,8 +84,8 @@ void vkd3d_dbg_printf(enum vkd3d_dbg_level level, const char *function, const ch
static char *get_buffer(void)
{
static char buffers[64][VKD3D_DEBUG_BUFFER_SIZE];
static unsigned int buffer_index;
unsigned int current_index;
static ULONG buffer_index;
ULONG current_index;
current_index = InterlockedIncrement(&buffer_index) % ARRAY_SIZE(buffers);
return buffers[current_index];

View File

@ -28,22 +28,24 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#if HAVE_SYNC_ADD_AND_FETCH
#ifndef _WIN32
# if HAVE_SYNC_ADD_AND_FETCH
static inline ULONG InterlockedIncrement(ULONG volatile *x)
{
return __sync_add_and_fetch(x, 1);
}
#else
# error "InterlockedIncrement not implemented for this platform"
#endif /* HAVE_SYNC_ADD_AND_FETCH */
# else
# error "InterlockedIncrement not implemented for this platform"
# endif /* HAVE_SYNC_ADD_AND_FETCH */
#if HAVE_SYNC_SUB_AND_FETCH
# if HAVE_SYNC_SUB_AND_FETCH
static inline ULONG InterlockedDecrement(ULONG volatile *x)
{
return __sync_sub_and_fetch(x, 1);
}
#else
# error "InterlockedDecrement not implemented for this platform"
#endif
# else
# error "InterlockedDecrement not implemented for this platform"
# endif
#endif /* _WIN32 */
#endif /* __VKD3D_COMMON_H */

View File

@ -72,10 +72,10 @@ static inline const char *debugstr_guid(const GUID *guid)
if (!guid)
return "(null)";
return vkd3d_dbg_sprintf("{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1],
guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5],
guid->Data4[6], guid->Data4[7]);
return vkd3d_dbg_sprintf("{%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
(unsigned long)guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
guid->Data4[5], guid->Data4[6], guid->Data4[7]);
}
#endif /* __VKD3D_DEBUG_H */