Merge branch 'gallium-i915-current' into gallium-0.1
[mesa.git] / src / gallium / include / pipe / p_util.h
index 1bc00ac7a022410aac0076e111ac9fcc2ec0de69..a66ab765f72875ec5a12b94e048e851c0b176607 100644 (file)
@@ -28,6 +28,7 @@
 #ifndef P_UTIL_H
 #define P_UTIL_H
 
+#include "p_config.h"
 #include "p_compiler.h"
 #include "p_debug.h"
 #include "p_pointer.h"
@@ -40,7 +41,9 @@ extern "C" {
 #endif
 
 
-#if defined(WIN32) && defined(DEBUG) /* memory debugging */
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG) 
+
+/* memory debugging */
 
 #include "p_debug.h"
 
@@ -53,9 +56,7 @@ extern "C" {
 #define REALLOC( _ptr, _old_size, _size ) \
    debug_realloc( __FILE__, __LINE__, __FUNCTION__,  _ptr, _old_size, _size )
 
-#else
-   
-#ifdef WIN32
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
 
 void * __stdcall
 EngAllocMem(
@@ -67,17 +68,33 @@ void __stdcall
 EngFreeMem(
     void *Mem );
 
-static INLINE void *
-MALLOC( unsigned size )
-{
-#ifdef WINCE
-   /* TODO: Need to abstract this */
-   return malloc( size );
+#define MALLOC( _size ) EngAllocMem( 0, _size, 'D3AG' )
+#define _FREE( _ptr ) EngFreeMem( _ptr )
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+
+void *
+ExAllocatePool(
+    unsigned long PoolType, 
+    size_t NumberOfBytes);
+
+void 
+ExFreePool(void *P);
+
+#define MALLOC(_size) ExAllocatePool(0, _size)
+#define _FREE(_ptr) ExFreePool(_ptr)
+
 #else
-   return EngAllocMem( 0, size, 'D3AG' );
+
+#define MALLOC( SIZE )  malloc( SIZE )
+#define CALLOC( COUNT, SIZE )   calloc( COUNT, SIZE )
+#define FREE( PTR )  free( PTR )
+#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE )  realloc( OLDPTR, NEWSIZE )
+
 #endif
-}
 
+
+#ifndef CALLOC
 static INLINE void *
 CALLOC( unsigned count, unsigned size )
 {
@@ -87,20 +104,19 @@ CALLOC( unsigned count, unsigned size )
    }
    return ptr;
 }
+#endif /* !CALLOC */
 
+#ifndef FREE
 static INLINE void
 FREE( void *ptr )
 {
    if( ptr ) {
-#ifdef WINCE
-      /* TODO: Need to abstract this */
-      free( ptr );
-#else
-      EngFreeMem( ptr );
-#endif
+      _FREE( ptr );
    }
 }
+#endif /* !FREE */
 
+#ifndef REALLOC
 static INLINE void *
 REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
 {
@@ -117,19 +133,8 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
    FREE( old_ptr );
    return new_ptr;
 }
+#endif /* !REALLOC */
 
-#else /* !WIN32 */
-
-#define MALLOC( SIZE )  malloc( SIZE )
-
-#define CALLOC( COUNT, SIZE )   calloc( COUNT, SIZE )
-
-#define FREE( PTR )  free( PTR )
-
-#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE )  realloc( OLDPTR, NEWSIZE )
-
-#endif /* !WIN32 */
-#endif /* !DEBUG */
 
 #define MALLOC_STRUCT(T)   (struct T *) MALLOC(sizeof(struct T))
 
@@ -138,14 +143,6 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
 #define GETENV( X ) debug_get_option( X, NULL )
 
 
-#ifdef WIN32
-int rpl_vsnprintf(char *, size_t, const char *, va_list);
-int rpl_snprintf(char *str, size_t size, const char *format, ...);
-#define vsnprintf rpl_vsnprintf
-#define snprintf rpl_snprintf
-#endif
-
-
 /**
  * Return memory on given byte alignment
  */
@@ -413,6 +410,54 @@ extern void pipe_copy_rect(ubyte * dst, unsigned cpp, unsigned dst_pitch,
                            int src_pitch, unsigned src_x, int src_y);
 
 
+
+#ifdef WIN32
+
+#if !defined(_INC_MATH) || !defined(__cplusplus)
+
+static INLINE float cosf( float f ) 
+{
+   return (float) cos( (double) f );
+}
+
+static INLINE float sinf( float f ) 
+{
+   return (float) sin( (double) f );
+}
+
+static INLINE float ceilf( float f ) 
+{
+   return (float) ceil( (double) f );
+}
+
+static INLINE float floorf( float f ) 
+{
+   return (float) floor( (double) f );
+}
+
+static INLINE float powf( float f, float g ) 
+{
+   return (float) pow( (double) f, (double) g );
+}
+
+static INLINE float sqrtf( float f ) 
+{
+   return (float) sqrt( (double) f );
+}
+
+static INLINE float fabsf( float f ) 
+{
+   return (float) fabs( (double) f );
+}
+
+static INLINE float logf( float f ) 
+{
+   return (float) cos( (double) f );
+}
+#endif  /* _INC_MATH */
+#endif
+
+
 #ifdef __cplusplus
 }
 #endif