summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/util
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-06-23 00:01:17 +1000
committerBen Skeggs <skeggsb@gmail.com>2008-06-23 00:01:17 +1000
commitaa3ab377e6e2e5811cdd704d87c3e24acb5eff72 (patch)
treeab8a443a58a58a6b88f35d4b5730ed1292e44d26 /src/gallium/auxiliary/util
parent8c26a521ee80f5d8a1d0aabd0910233aad400322 (diff)
parente2c3f06e9649b5b87fc9adbca7d1f07841bba895 (diff)
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Conflicts: configs/default
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r--src/gallium/auxiliary/util/Makefile3
-rw-r--r--src/gallium/auxiliary/util/p_debug.c50
-rw-r--r--src/gallium/auxiliary/util/p_debug_mem.c53
-rw-r--r--src/gallium/auxiliary/util/u_blit.c2
-rw-r--r--src/gallium/auxiliary/util/u_pack_color.h12
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c33
-rw-r--r--src/gallium/auxiliary/util/u_time.c74
-rw-r--r--src/gallium/auxiliary/util/u_time.h2
8 files changed, 175 insertions, 54 deletions
diff --git a/src/gallium/auxiliary/util/Makefile b/src/gallium/auxiliary/util/Makefile
index 05bc43131a..db3d810a2e 100644
--- a/src/gallium/auxiliary/util/Makefile
+++ b/src/gallium/auxiliary/util/Makefile
@@ -15,8 +15,7 @@ C_SOURCES = \
u_mm.c \
u_simple_shaders.c \
u_snprintf.c \
- u_time.c \
- u_mm.c
+ u_time.c
include ../../Makefile.template
diff --git a/src/gallium/auxiliary/util/p_debug.c b/src/gallium/auxiliary/util/p_debug.c
index ce7fb58956..9d56f8bfab 100644
--- a/src/gallium/auxiliary/util/p_debug.c
+++ b/src/gallium/auxiliary/util/p_debug.c
@@ -153,7 +153,9 @@ const char *
debug_get_option(const char *name, const char *dfault)
{
const char *result;
-#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+ /* EngMapFile creates the file if it does not exists, so it must either be
+ * disabled on release versions (or put in a less conspicuous place). */
#ifdef DEBUG
ULONG_PTR iFile = 0;
const void *pMap = NULL;
@@ -161,9 +163,6 @@ debug_get_option(const char *name, const char *dfault)
static char output[1024];
result = dfault;
- /* XXX: this creates the file if it does not exists, so it must either be
- * disabled on release versions, or put in a less conspicuous place.
- */
pMap = EngMapFile(L"\\??\\c:\\gallium.cfg", 0, &iFile);
if(pMap) {
sol = (const char *)pMap;
@@ -187,13 +186,15 @@ debug_get_option(const char *name, const char *dfault)
#else
result = dfault;
#endif
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+ /* TODO: implement */
+ result = dfault;
#else
-
result = getenv(name);
if(!result)
result = dfault;
#endif
-
+
debug_printf("%s: %s = %s\n", __FUNCTION__, name, result ? result : "(null)");
return result;
@@ -229,8 +230,34 @@ debug_get_bool_option(const char *name, boolean dfault)
long
debug_get_num_option(const char *name, long dfault)
{
- /* FIXME */
- return dfault;
+ long result;
+ const char *str;
+
+ str = debug_get_option(name, NULL);
+ if(!str)
+ result = dfault;
+ else {
+ long sign;
+ char c;
+ c = *str++;
+ if(c == '-') {
+ sign = -1;
+ c = *str++;
+ }
+ else {
+ sign = 1;
+ }
+ result = 0;
+ while('0' <= c && c <= '9') {
+ result = result*10 + (c - '0');
+ c = *str++;
+ }
+ result *= sign;
+ }
+
+ debug_printf("%s: %s = %li\n", __FUNCTION__, name, result);
+
+ return result;
}
@@ -339,10 +366,12 @@ static const struct debug_named_value pipe_format_names[] = {
DEBUG_NAMED_VALUE(PIPE_FORMAT_A1R5G5B5_UNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_A4R4G4B4_UNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_R5G6B5_UNORM),
+ DEBUG_NAMED_VALUE(PIPE_FORMAT_A2B10G10R10_UNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_L8_UNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_A8_UNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_I8_UNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_A8L8_UNORM),
+ DEBUG_NAMED_VALUE(PIPE_FORMAT_L16_UNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_YCBCR),
DEBUG_NAMED_VALUE(PIPE_FORMAT_YCBCR_REV),
DEBUG_NAMED_VALUE(PIPE_FORMAT_Z16_UNORM),
@@ -408,6 +437,9 @@ static const struct debug_named_value pipe_format_names[] = {
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8_SNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8A8_SNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8X8_SNORM),
+ DEBUG_NAMED_VALUE(PIPE_FORMAT_B6G5R5_SNORM),
+ DEBUG_NAMED_VALUE(PIPE_FORMAT_A8B8G8R8_SNORM),
+ DEBUG_NAMED_VALUE(PIPE_FORMAT_X8B8G8R8_SNORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8_SSCALED),
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8_SSCALED),
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8_SSCALED),
@@ -418,6 +450,8 @@ static const struct debug_named_value pipe_format_names[] = {
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8_SRGB),
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8A8_SRGB),
DEBUG_NAMED_VALUE(PIPE_FORMAT_R8G8B8X8_SRGB),
+ DEBUG_NAMED_VALUE(PIPE_FORMAT_X8UB8UG8SR8S_NORM),
+ DEBUG_NAMED_VALUE(PIPE_FORMAT_B6UG5SR5S_NORM),
DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT1_RGB),
DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT1_RGBA),
DEBUG_NAMED_VALUE(PIPE_FORMAT_DXT3_RGBA),
diff --git a/src/gallium/auxiliary/util/p_debug_mem.c b/src/gallium/auxiliary/util/p_debug_mem.c
index 78497c5f6a..ed18c6540e 100644
--- a/src/gallium/auxiliary/util/p_debug_mem.c
+++ b/src/gallium/auxiliary/util/p_debug_mem.c
@@ -75,6 +75,12 @@ struct debug_memory_header
unsigned magic;
};
+struct debug_memory_footer
+{
+ unsigned magic;
+};
+
+
static struct list_head list = { &list, &list };
static unsigned long last_no = 0;
@@ -98,14 +104,24 @@ data_from_header(struct debug_memory_header *hdr)
return NULL;
}
+static INLINE struct debug_memory_footer *
+footer_from_header(struct debug_memory_header *hdr)
+{
+ if(hdr)
+ return (struct debug_memory_footer *)((char *)hdr + sizeof(struct debug_memory_header) + hdr->size);
+ else
+ return NULL;
+}
+
void *
debug_malloc(const char *file, unsigned line, const char *function,
size_t size)
{
struct debug_memory_header *hdr;
+ struct debug_memory_footer *ftr;
- hdr = real_malloc(sizeof(*hdr) + size);
+ hdr = real_malloc(sizeof(*hdr) + size + sizeof(*ftr));
if(!hdr)
return NULL;
@@ -116,6 +132,9 @@ debug_malloc(const char *file, unsigned line, const char *function,
hdr->size = size;
hdr->magic = DEBUG_MEMORY_MAGIC;
+ ftr = footer_from_header(hdr);
+ ftr->magic = DEBUG_MEMORY_MAGIC;
+
LIST_ADDTAIL(&hdr->head, &list);
return data_from_header(hdr);
@@ -126,6 +145,7 @@ debug_free(const char *file, unsigned line, const char *function,
void *ptr)
{
struct debug_memory_header *hdr;
+ struct debug_memory_footer *ftr;
if(!ptr)
return;
@@ -139,8 +159,17 @@ debug_free(const char *file, unsigned line, const char *function,
return;
}
+ ftr = footer_from_header(hdr);
+ if(ftr->magic != DEBUG_MEMORY_MAGIC) {
+ debug_printf("%s:%u:%s: buffer overflow %p\n",
+ hdr->file, hdr->line, hdr->function,
+ ptr);
+ debug_assert(0);
+ }
+
LIST_DEL(&hdr->head);
hdr->magic = 0;
+ ftr->magic = 0;
real_free(hdr);
}
@@ -160,6 +189,7 @@ debug_realloc(const char *file, unsigned line, const char *function,
void *old_ptr, size_t old_size, size_t new_size )
{
struct debug_memory_header *old_hdr, *new_hdr;
+ struct debug_memory_footer *old_ftr, *new_ftr;
void *new_ptr;
if(!old_ptr)
@@ -179,8 +209,16 @@ debug_realloc(const char *file, unsigned line, const char *function,
return NULL;
}
+ old_ftr = footer_from_header(old_hdr);
+ if(old_ftr->magic != DEBUG_MEMORY_MAGIC) {
+ debug_printf("%s:%u:%s: buffer overflow %p\n",
+ old_hdr->file, old_hdr->line, old_hdr->function,
+ old_ptr);
+ debug_assert(0);
+ }
+
/* alloc new */
- new_hdr = real_malloc(sizeof(*new_hdr) + new_size);
+ new_hdr = real_malloc(sizeof(*new_hdr) + new_size + sizeof(*new_ftr));
if(!new_hdr)
return NULL;
new_hdr->no = old_hdr->no;
@@ -189,14 +227,19 @@ debug_realloc(const char *file, unsigned line, const char *function,
new_hdr->function = old_hdr->function;
new_hdr->size = new_size;
new_hdr->magic = DEBUG_MEMORY_MAGIC;
- LIST_REPLACE(&old_hdr->head, &new_hdr->head);
+ new_ftr = footer_from_header(new_hdr);
+ new_ftr->magic = DEBUG_MEMORY_MAGIC;
+
+ LIST_REPLACE(&old_hdr->head, &new_hdr->head);
+
/* copy data */
new_ptr = data_from_header(new_hdr);
memcpy( new_ptr, old_ptr, old_size < new_size ? old_size : new_size );
/* free old */
old_hdr->magic = 0;
+ old_ftr->magic = 0;
real_free(old_hdr);
return new_ptr;
@@ -220,8 +263,8 @@ debug_memory_end(unsigned long start_no)
void *ptr;
hdr = LIST_ENTRY(struct debug_memory_header, entry, head);
ptr = data_from_header(hdr);
- if(start_no <= hdr->no && hdr->no < last_no ||
- last_no < start_no && (hdr->no < last_no || start_no <= hdr->no)) {
+ if((start_no <= hdr->no && hdr->no < last_no) ||
+ (last_no < start_no && (hdr->no < last_no || start_no <= hdr->no))) {
debug_printf("%s:%u:%s: %u bytes at %p not freed\n",
hdr->file, hdr->line, hdr->function,
hdr->size, ptr);
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 999a3e5099..7b9415d49a 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -281,7 +281,7 @@ util_blit_pixels(struct blit_state *ctx,
texTemp.height[0] = srcH;
texTemp.depth[0] = 1;
texTemp.compressed = 0;
- texTemp.cpp = pf_get_bits(src->format) / 8;
+ texTemp.cpp = pf_get_size(src->format);
tex = screen->texture_create(screen, &texTemp);
if (!tex)
diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h
index 655e2c8259..06abb34d5a 100644
--- a/src/gallium/auxiliary/util/u_pack_color.h
+++ b/src/gallium/auxiliary/util/u_pack_color.h
@@ -255,20 +255,28 @@ util_pack_color(const float rgba[4], enum pipe_format format, void *dest)
static INLINE uint
util_pack_z(enum pipe_format format, double z)
{
+ if (z == 0.0)
+ return 0;
+
switch (format) {
case PIPE_FORMAT_Z16_UNORM:
+ if (z == 1.0)
+ return 0xffff;
return (uint) (z * 0xffff);
case PIPE_FORMAT_Z32_UNORM:
/* special-case to avoid overflow */
if (z == 1.0)
return 0xffffffff;
- else
- return (uint) (z * 0xffffffff);
+ return (uint) (z * 0xffffffff);
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
+ if (z == 1.0)
+ return 0xffffff;
return (uint) (z * 0xffffff);
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_Z24X8_UNORM:
+ if (z == 1.0)
+ return 0xffffff00;
return ((uint) (z * 0xffffff)) << 8;
default:
debug_print_format("gallium: unhandled format in util_pack_z()", format);
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index 5f8d12191d..505d93d727 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -92,8 +92,8 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
decl.Semantic.SemanticName = semantic_names[i];
decl.Semantic.SemanticIndex = semantic_indexes[i];
- decl.u.DeclarationRange.First =
- decl.u.DeclarationRange.Last = i;
+ decl.DeclarationRange.First =
+ decl.DeclarationRange.Last = i;
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
@@ -107,8 +107,8 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
decl.Declaration.Semantic = 1;
decl.Semantic.SemanticName = semantic_names[i];
decl.Semantic.SemanticIndex = semantic_indexes[i];
- decl.u.DeclarationRange.First =
- decl.u.DeclarationRange.Last = i;
+ decl.DeclarationRange.First =
+ decl.DeclarationRange.Last = i;
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
@@ -190,14 +190,13 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
/* declare TEX[0] input */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_INPUT;
+ /* XXX this could be linear... */
+ decl.Declaration.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
decl.Declaration.Semantic = 1;
decl.Semantic.SemanticName = TGSI_SEMANTIC_GENERIC;
decl.Semantic.SemanticIndex = 0;
- /* XXX this could be linear... */
- decl.Declaration.Interpolate = 1;
- decl.Interpolation.Interpolate = TGSI_INTERPOLATE_PERSPECTIVE;
- decl.u.DeclarationRange.First =
- decl.u.DeclarationRange.Last = 0;
+ decl.DeclarationRange.First =
+ decl.DeclarationRange.Last = 0;
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
@@ -209,8 +208,8 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
decl.Declaration.Semantic = 1;
decl.Semantic.SemanticName = TGSI_SEMANTIC_COLOR;
decl.Semantic.SemanticIndex = 0;
- decl.u.DeclarationRange.First =
- decl.u.DeclarationRange.Last = 0;
+ decl.DeclarationRange.First =
+ decl.DeclarationRange.Last = 0;
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
@@ -219,8 +218,8 @@ util_make_fragment_tex_shader(struct pipe_context *pipe,
/* declare sampler */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_SAMPLER;
- decl.u.DeclarationRange.First =
- decl.u.DeclarationRange.Last = 0;
+ decl.DeclarationRange.First =
+ decl.DeclarationRange.Last = 0;
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
@@ -303,8 +302,8 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
decl.Declaration.Semantic = 1;
decl.Semantic.SemanticName = TGSI_SEMANTIC_COLOR;
decl.Semantic.SemanticIndex = 0;
- decl.u.DeclarationRange.First =
- decl.u.DeclarationRange.Last = 0;
+ decl.DeclarationRange.First =
+ decl.DeclarationRange.Last = 0;
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
@@ -316,8 +315,8 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe,
decl.Declaration.Semantic = 1;
decl.Semantic.SemanticName = TGSI_SEMANTIC_COLOR;
decl.Semantic.SemanticIndex = 0;
- decl.u.DeclarationRange.First =
- decl.u.DeclarationRange.Last = 0;
+ decl.DeclarationRange.First =
+ decl.DeclarationRange.Last = 0;
ti += tgsi_build_full_declaration(&decl,
&tokens[ti],
header,
diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c
index 9b97050d51..49dce75289 100644
--- a/src/gallium/auxiliary/util/u_time.c
+++ b/src/gallium/auxiliary/util/u_time.c
@@ -33,26 +33,44 @@
*/
-#include "util/u_time.h"
+#include "pipe/p_config.h"
#if defined(PIPE_OS_LINUX)
#include <sys/time.h>
#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <windows.h>
#include <winddi.h>
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+#include <windows.h>
+extern VOID KeQuerySystemTime(PLARGE_INTEGER);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
#include <windows.h>
#else
#error Unsupported OS
#endif
+#include "util/u_time.h"
+
-#if defined(PIPE_OS_WINDOWS)
-static LONGLONG frequency = 0;
-#if !defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
-#define EngQueryPerformanceFrequency(p) QueryPerformanceFrequency((LARGE_INTEGER*)(p))
-#define EngQueryPerformanceCounter(p) QueryPerformanceCounter((LARGE_INTEGER*)(p))
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+
+static int64_t frequency = 0;
+
+static INLINE void
+util_time_get_frequency(void)
+{
+ if(!frequency) {
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+ LONGLONG temp;
+ EngQueryPerformanceFrequency(&temp);
+ frequency = temp;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+ LARGE_INTEGER temp;
+ QueryPerformanceFrequency(&temp);
+ frequency = temp.QuadPart;
#endif
+ }
+}
#endif
@@ -61,8 +79,20 @@ util_time_get(struct util_time *t)
{
#if defined(PIPE_OS_LINUX)
gettimeofday(&t->tv, NULL);
-#elif defined(PIPE_OS_WINDOWS)
- EngQueryPerformanceCounter(&t->counter);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+ LONGLONG temp;
+ EngQueryPerformanceCounter(&temp);
+ t->counter = temp;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+ /* Updated every 10 miliseconds, measured in units of 100 nanoseconds.
+ * http://msdn.microsoft.com/en-us/library/ms801642.aspx */
+ LARGE_INTEGER temp;
+ KeQuerySystemTime(&temp);
+ t->counter = temp.QuadPart;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+ LARGE_INTEGER temp;
+ QueryPerformanceCounter(&temp);
+ t->counter = temp.QuadPart;
#endif
}
@@ -75,10 +105,17 @@ util_time_add(const struct util_time *t1,
#if defined(PIPE_OS_LINUX)
t2->tv.tv_sec = t1->tv.tv_sec + usecs / 1000000;
t2->tv.tv_usec = t1->tv.tv_usec + usecs % 1000000;
-#elif defined(PIPE_OS_WINDOWS)
- if(!frequency)
- EngQueryPerformanceFrequency(&frequency);
- t2->counter = t1->counter + (usecs * frequency + 999999LL)/1000000LL;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+ util_time_get_frequency();
+ t2->counter = t1->counter + (usecs * frequency + INT64_C(999999))/INT64_C(1000000);
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+ /* 1 tick = 100 nano seconds. */
+ t2->counter = t1->counter + usecs * 10;
+#elif
+ LARGE_INTEGER temp;
+ LONGLONG freq;
+ freq = temp.QuadPart;
+ t2->counter = t1->counter + (usecs * freq)/1000000L;
#endif
}
@@ -90,10 +127,11 @@ util_time_diff(const struct util_time *t1,
#if defined(PIPE_OS_LINUX)
return (t2->tv.tv_usec - t1->tv.tv_usec) +
(t2->tv.tv_sec - t1->tv.tv_sec)*1000000;
-#elif defined(PIPE_OS_WINDOWS)
- if(!frequency)
- EngQueryPerformanceFrequency(&frequency);
- return (t2->counter - t1->counter)*1000000LL/frequency;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE)
+ util_time_get_frequency();
+ return (t2->counter - t1->counter)*INT64_C(1000000)/frequency;
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+ return (t2->counter - t1->counter)/10;
#endif
}
@@ -142,7 +180,7 @@ util_time_timeout(const struct util_time *start,
}
-#if defined(PIPE_OS_WINDOWS)
+#if defined(PIPE_SUBSYSYEM_WINDOWS_DISPLAY)
void util_time_sleep(unsigned usecs)
{
LONGLONG start, curr, end;
diff --git a/src/gallium/auxiliary/util/u_time.h b/src/gallium/auxiliary/util/u_time.h
index 48ec7a4a96..f9963ce0e2 100644
--- a/src/gallium/auxiliary/util/u_time.h
+++ b/src/gallium/auxiliary/util/u_time.h
@@ -61,7 +61,7 @@ struct util_time
#if defined(PIPE_OS_LINUX)
struct timeval tv;
#else
- long long counter;
+ int64_t counter;
#endif
};