*/
+#include "pipe/p_config.h"
+
+#if defined(PIPE_OS_LINUX)
+#include <unistd.h>
+#endif
+
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
#include "pipe/p_debug.h"
#include "pb_buffer.h"
#include "pb_buffer_fenced.h"
-#ifndef WIN32
-#include <unistd.h>
-#endif
/**
/* Wait on outstanding fences */
while (fenced_list->numDelayed) {
_glthread_UNLOCK_MUTEX(fenced_list->mutex);
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
sched_yield();
#endif
_fenced_buffer_list_check_free(fenced_list, 1);
**************************************************************************/
+#include "pipe/p_config.h"
+
#include <stdarg.h>
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
#include <windows.h>
#include <winddi.h>
#else
#include "util/u_string.h"
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
static INLINE void
_EngDebugPrint(const char *format, ...)
{
void _debug_vprintf(const char *format, va_list ap)
{
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
#ifndef WINCE
/* EngDebugPrint does not handle float point arguments, so we need to use
* our own vsnprintf implementation. It is also very slow, so buffer until
__asm("int3");
#elif (defined(__i386__) || defined(__386__)) && defined(__MSC__)
_asm {int 3};
-#elif defined(WIN32) && !defined(WINCE)
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
EngDebugBreak();
#else
abort();
}
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
static const char *
find(const char *start, const char *end, char c)
{
debug_get_option(const char *name, const char *dfault)
{
const char *result;
-#ifdef WIN32
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
ULONG_PTR iFile = 0;
const void *pMap = NULL;
const char *sol, *eol, *sep;
* @author José Fonseca <jrfonseca@tungstengraphics.com>
*/
-#ifdef WIN32
+#include "pipe/p_config.h"
+
+#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
#include <windows.h>
#include <winddi.h>
#else
#define DEBUG_MEMORY_MAGIC 0x6e34090aU
-#if defined(WIN32) && !defined(WINCE)
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
#define real_malloc(_size) EngAllocMem(0, _size, 'D3AG')
#define real_free(_ptr) EngFreeMem(_ptr)
#else
*/
-#ifndef WIN32
+#include "util/u_time.h"
+
+#if defined(PIPE_OS_LINUX)
#include <sys/time.h>
-#else
+#elif defined(PIPE_OS_WINDOWS)
#include <windows.h>
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <winddi.h>
#endif
-
-#include "util/u_time.h"
+#else
+#error Unsupported OS
+#endif
-#ifdef WIN32
+#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))
+#endif
#endif
void
util_time_get(struct util_time *t)
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
gettimeofday(&t->tv, NULL);
-#else
+#elif defined(PIPE_OS_WINDOWS)
EngQueryPerformanceCounter(&t->counter);
#endif
}
int64_t usecs,
struct util_time *t2)
{
-#ifndef WIN32
+#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;
-#else
+#elif defined(PIPE_OS_WINDOWS)
if(!frequency)
EngQueryPerformanceFrequency(&frequency);
t2->counter = t1->counter + (usecs * frequency + 999999LL)/1000000LL;
util_time_diff(const struct util_time *t1,
const struct util_time *t2)
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
return (t2->tv.tv_usec - t1->tv.tv_usec) +
(t2->tv.tv_sec - t1->tv.tv_sec)*1000000;
-#else
+#elif defined(PIPE_OS_WINDOWS)
+ if(!frequency)
+ EngQueryPerformanceFrequency(&frequency);
return (t2->counter - t1->counter)*1000000LL/frequency;
#endif
}
util_time_compare(const struct util_time *t1,
const struct util_time *t2)
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
if (t1->tv.tv_sec < t2->tv.tv_sec)
return -1;
else if(t1->tv.tv_sec > t2->tv.tv_sec)
return 1;
else
return 0;
-#else
+#elif defined(PIPE_OS_WINDOWS)
if (t1->counter < t2->counter)
return -1;
else if(t1->counter > t2->counter)
}
-#ifdef WIN32
+#if defined(PIPE_OS_WINDOWS)
void util_time_sleep(unsigned usecs)
{
LONGLONG start, curr, end;
#define U_TIME_H_
-#ifndef WIN32
+#include "pipe/p_config.h"
+
+#if defined(PIPE_OS_LINUX)
#include <time.h> /* timeval */
#include <unistd.h> /* usleep */
#endif
*/
struct util_time
{
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
struct timeval tv;
#else
long long counter;
const struct util_time *end,
const struct util_time *curr);
-#ifndef WIN32
+#if defined(PIPE_OS_LINUX)
#define util_time_sleep usleep
#else
void
#ifndef P_UTIL_H
#define P_UTIL_H
+#include "p_config.h"
#include "p_compiler.h"
#include "p_debug.h"
#include "p_pointer.h"
#endif
-#if defined(WIN32) && defined(DEBUG) /* memory debugging */
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG) /* memory debugging */
#include "p_debug.h"
#else
-#ifdef WIN32
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
void * __stdcall
EngAllocMem(
return new_ptr;
}
-#else /* !WIN32 */
+#else /* !PIPE_SUBSYSTEM_WINDOWS_DISPLAY */
#define MALLOC( SIZE ) malloc( SIZE )
#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE ) realloc( OLDPTR, NEWSIZE )
-#endif /* !WIN32 */
+#endif /* !PIPE_SUBSYSTEM_WINDOWS_DISPLAY */
#endif /* !DEBUG */
#define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))