core  array_cache  math  swrast  swrast_setup  tnl  tnl_dd 
Main Page   Data Structures   File List   Data Fields   Globals   Related Pages  

imports.h File Reference

Standard C library function wrappers. More...

#include "glheader.h"

General macros

#define NULL   0

[Pseudo] static array declaration.

MACs and BeOS don't support static larger than 32kb, so ...

#define DEFARRAY(TYPE, NAME, SIZE)   TYPE NAME[SIZE]
 Define a [static] unidimensional array. More...

#define DEFMARRAY(TYPE, NAME, SIZE1, SIZE2)   TYPE NAME[SIZE1][SIZE2]
 Define a [static] bi-dimensional array. More...

#define DEFMNARRAY(TYPE, NAME, SIZE1, SIZE2, SIZE3)   TYPE NAME[SIZE1][SIZE2][SIZE3]
 Define a [static] tri-dimensional array. More...

#define CHECKARRAY(NAME, CMD)   do {} while(0)
 Verifies a [static] array was properly allocated. More...

#define UNDEFARRAY(NAME)
 Undefine (free) a [static] array. More...


External pixel buffer allocation.

If you want Mesa's depth/stencil/accum/etc buffers to be allocated with a specialized allocator you can define MESA_EXTERNAL_BUFFERALLOC and implement _ext_mesa_alloc_pixelbuffer() _ext_mesa_free_pixelbuffer() in your application.

Author:
Contributed by Gerk Huisma (gerk@five-d.demon.nl).


#define MESA_PBUFFER_ALLOC(BYTES)   (void *) _mesa_align_malloc(BYTES, 512)
 Allocate a pixel buffer. More...

#define MESA_PBUFFER_FREE(PTR)   _mesa_align_free(PTR)
 Free a pixel buffer. More...


Defines

#define ADD_POINTERS(A, B)   ( (A) + (unsigned long) (B) )
#define MAX_GLUSHORT   0xffff
#define MAX_GLUINT   0xffffffff
#define M_PI   (3.1415926536)
#define FLT_MIN   (1.0e-37)
#define DEG2RAD   (M_PI/180.0)
#define SQRTF(X)   (float) sqrt((float) (X))
#define INV_SQRTF(X)   (1.0F / SQRTF(X))
#define LOG2(x)   ((GLfloat) (log(x) * 1.442695F))
#define IS_INF_OR_NAN(x)   (!finite(x))
#define IS_NEGATIVE(x)   (x < 0.0F)
#define DIFFERENT_SIGNS(x, y)   ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
#define CEILF(x)   ((GLfloat) ceil(x))
#define FLOORF(x)   ((GLfloat) floor(x))
#define FABSF(x)   ((GLfloat) fabs(x))
#define IROUND(f)   ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
#define IROUND_POS(f)   (IROUND(f))
#define IFLOOR(x)   ifloor(x)
#define ICEIL(x)   iceil(x)
#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f)   ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
#define CLAMPED_FLOAT_TO_UBYTE(ub, f)   ub = ((GLubyte) IROUND((f) * 255.0F))
#define COPY_FLOAT(dst, src)   (dst) = (src)
#define START_FAST_MATH(x)   x = 0
#define END_FAST_MATH(x)   (void)(x)

Functions

INLINE int ifloor (float f)
INLINE int iceil (float f)
void_mesa_malloc (size_t bytes)
 Wrapper around either malloc() or xf86malloc(). More...

void_mesa_calloc (size_t bytes)
 Wrapper around either calloc() or xf86calloc(). More...

void _mesa_free (void *ptr)
 Wrapper around either free() or xf86free(). More...

void_mesa_align_malloc (size_t bytes, unsigned long alignment)
 Allocate aligned memory. More...

void_mesa_align_calloc (size_t bytes, unsigned long alignment)
 Same as _mesa_align_malloc(), but using _mesa_calloc() instead of _mesa_malloc(). More...

void _mesa_align_free (void *ptr)
 Free memory allocated with _mesa_align_malloc() or _mesa_align_calloc(). More...

void_mesa_realloc (void *oldBuffer, size_t oldSize, size_t newSize)
 Wrapper around either memcpy() or xf86memcpy(). More...

void_mesa_memcpy (void *dest, const void *src, size_t n)
void _mesa_memset (void *dst, int val, size_t n)
 Wrapper around either memset() or xf86memset(). More...

void _mesa_memset16 (unsigned short *dst, unsigned short val, size_t n)
 Fill memory with a constant 16bit word. More...

void _mesa_bzero (void *dst, size_t n)
 Wrapper around either memcpy() or xf86memcpy() or bzero(). More...

double _mesa_sin (double a)
 Wrapper around either sin() or xf86sin(). More...

double _mesa_cos (double a)
 Wrapper around either cos() or xf86cos(). More...

double _mesa_sqrtd (double x)
 Wrapper around either sqrt() or xf86sqrt(). More...

float _mesa_sqrtf (float x)
 Single precision square root. More...

float _mesa_inv_sqrtf (float x)
 inv_sqrt - A single precision 1/sqrt routine for IEEE format floats. More...

double _mesa_pow (double x, double y)
 Wrapper around either pow() or xf86pow(). More...

float _mesa_log2 (float x)
unsigned int _mesa_bitcount (unsigned int n)
 Return number of bits set in given GLuint. More...

GLhalfARB _mesa_float_to_half (float f)
 Convert a 4-byte float to a 2-byte half float. More...

float _mesa_half_to_float (GLhalfARB h)
 Convert a 2-byte half float to a 4-byte float. More...

char * _mesa_getenv (const char *var)
 Wrapper for getenv(). More...

char * _mesa_strstr (const char *haystack, const char *needle)
 Wrapper around either strstr() or xf86strstr(). More...

char * _mesa_strncat (char *dest, const char *src, size_t n)
 Wrapper around either strncat() or xf86strncat(). More...

char * _mesa_strcpy (char *dest, const char *src)
 Wrapper around either strcpy() or xf86strcpy(). More...

char * _mesa_strncpy (char *dest, const char *src, size_t n)
 Wrapper around either strncpy() or xf86strncpy(). More...

size_t _mesa_strlen (const char *s)
 Wrapper around either strlen() or xf86strlen(). More...

int _mesa_strcmp (const char *s1, const char *s2)
 Wrapper around either strcmp() or xf86strcmp(). More...

int _mesa_strncmp (const char *s1, const char *s2, size_t n)
 Wrapper around either strncmp() or xf86strncmp(). More...

char * _mesa_strdup (const char *s)
 Implemented using _mesa_malloc() and _mesa_strcpy. More...

int _mesa_atoi (const char *s)
 Wrapper around either atoi() or xf86atoi(). More...

double _mesa_strtod (const char *s, char **end)
 Wrapper around either strtod() or xf86strtod(). More...

int _mesa_sprintf (char *str, const char *fmt,...)
 Wrapper around either vsprintf() or xf86vsprintf(). More...

void _mesa_printf (const char *fmtString,...)
 Wrapper around either printf() or xf86printf(), using vsprintf() for the formatting. More...

void _mesa_warning (__GLcontext *gc, const char *fmtString,...)
void _mesa_problem (const __GLcontext *ctx, const char *fmtString,...)
void _mesa_error (__GLcontext *ctx, GLenum error, const char *fmtString,...)
void _mesa_debug (const __GLcontext *ctx, const char *fmtString,...)
void _mesa_init_default_imports (__GLimports *imports, void *driverCtx)
 Initialize a __GLimports object to point to the functions in this file. More...


Detailed Description

Standard C library function wrappers.

This file provides wrappers for all the standard C library functions like malloc(), free(), printf(), getenv(), etc.


Define Documentation

#define ADD_POINTERS A,
B       ( (A) + (unsigned long) (B) )
 

#define ALIGN_CALLOC BYTES,
     _mesa_align_calloc(BYTES, N)
 

Allocate and zero BYTES bytes aligned at N bytes.

#define ALIGN_CALLOC_STRUCT T,
     (struct T *) _mesa_align_calloc(sizeof(struct T), N)
 

Allocate and zero a structure of type T aligned at N bytes.

#define ALIGN_FREE PTR       _mesa_align_free(PTR)
 

Free aligned memory.

#define ALIGN_MALLOC BYTES,
     _mesa_align_malloc(BYTES, N)
 

Allocate BYTES aligned at N bytes.

#define ALIGN_MALLOC_STRUCT T,
     (struct T *) _mesa_align_malloc(sizeof(struct T), N)
 

Allocate a structure of type T aligned at N bytes.

#define CALLOC BYTES       _mesa_calloc(BYTES)
 

Allocate and zero BYTES bytes.

#define CALLOC_STRUCT      (struct T *) _mesa_calloc(sizeof(struct T))
 

Allocate and zero a structure of type T.

#define CEILF      ((GLfloat) ceil(x))
 

#define CHECKARRAY NAME,
CMD       do {} while(0)
 

Verifies a [static] array was properly allocated.

#define CLAMPED_FLOAT_TO_UBYTE ub,
     ub = ((GLubyte) IROUND((f) * 255.0F))
 

#define COPY_FLOAT dst,
src       (dst) = (src)
 

#define DEFARRAY TYPE,
NAME,
SIZE       TYPE NAME[SIZE]
 

Define a [static] unidimensional array.

#define DEFMARRAY TYPE,
NAME,
SIZE1,
SIZE2       TYPE NAME[SIZE1][SIZE2]
 

Define a [static] bi-dimensional array.

#define DEFMNARRAY TYPE,
NAME,
SIZE1,
SIZE2,
SIZE3       TYPE NAME[SIZE1][SIZE2][SIZE3]
 

Define a [static] tri-dimensional array.

#define DEG2RAD   (M_PI/180.0)
 

#define DIFFERENT_SIGNS x,
y       ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
 

#define END_FAST_MATH      (void)(x)
 

#define FABSF      ((GLfloat) fabs(x))
 

#define FLOORF      ((GLfloat) floor(x))
 

#define FLT_MIN   (1.0e-37)
 

#define FREE PTR       _mesa_free(PTR)
 

Free memory.

#define ICEIL      iceil(x)
 

#define IFLOOR      ifloor(x)
 

#define INV_SQRTF X       (1.0F / SQRTF(X))
 

#define IROUND      ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
 

#define IROUND_POS      (IROUND(f))
 

#define IS_INF_OR_NAN      (!finite(x))
 

#define IS_NEGATIVE      (x < 0.0F)
 

#define LOG2      ((GLfloat) (log(x) * 1.442695F))
 

#define M_PI   (3.1415926536)
 

#define MALLOC BYTES       _mesa_malloc(BYTES)
 

Allocate BYTES bytes.

#define MALLOC_STRUCT      (struct T *) _mesa_malloc(sizeof(struct T))
 

Allocate a structure of type T.

#define MAX_GLUINT   0xffffffff
 

#define MAX_GLUSHORT   0xffff
 

#define MEMCPY DST,
SRC,
BYTES       _mesa_memcpy(DST, SRC, BYTES)
 

Copy BYTES bytes from SRC into DST.

#define MEMSET DST,
VAL,
     _mesa_memset(DST, VAL, N)
 

Set N bytes in DST to VAL.

#define MEMSET16 DST,
VAL,
     _mesa_memset16( (DST), (VAL), (size_t) (N) )
 

#define MESA_PBUFFER_ALLOC BYTES       (void *) _mesa_align_malloc(BYTES, 512)
 

Allocate a pixel buffer.

#define MESA_PBUFFER_FREE PTR       _mesa_align_free(PTR)
 

Free a pixel buffer.

#define NULL   0
 

#define SQRTF X       (float) sqrt((float) (X))
 

#define START_FAST_MATH      x = 0
 

#define UNCLAMPED_FLOAT_TO_UBYTE ub,
     ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
 

#define UNDEFARRAY NAME   
 

Undefine (free) a [static] array.


Function Documentation

void* _mesa_align_calloc size_t    bytes,
unsigned long    alignment
 

Same as _mesa_align_malloc(), but using _mesa_calloc() instead of _mesa_malloc().

void _mesa_align_free void   ptr
 

Free memory allocated with _mesa_align_malloc() or _mesa_align_calloc().

Parameters:
ptr  pointer to the memory to be freed.
The actual address to free is stored in the word immediately before the address the client sees.

void* _mesa_align_malloc size_t    bytes,
unsigned long    alignment
 

Allocate aligned memory.

Parameters:
bytes  number of bytes to allocate.
alignment  alignment (must be greater than zero).
Allocates extra memory to accommodate rounding up the address for alignment and to record the real malloc address.

See also:
_mesa_align_free().

int _mesa_atoi const char *    s
 

Wrapper around either atoi() or xf86atoi().

unsigned int _mesa_bitcount unsigned int    n
 

Return number of bits set in given GLuint.

void _mesa_bzero void   dst,
size_t    n
 

Wrapper around either memcpy() or xf86memcpy() or bzero().

void* _mesa_calloc size_t    bytes
 

Wrapper around either calloc() or xf86calloc().

double _mesa_cos double    a
 

Wrapper around either cos() or xf86cos().

void _mesa_debug const __GLcontext *    ctx,
const char *    fmtString,
...   
 

void _mesa_error __GLcontext *    ctx,
GLenum    error,
const char *    fmtString,
...   
 

GLhalfARB _mesa_float_to_half float    f
 

Convert a 4-byte float to a 2-byte half float.

Based on code from: http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html

void _mesa_free void   ptr
 

Wrapper around either free() or xf86free().

char* _mesa_getenv const char *    var
 

Wrapper for getenv().

float _mesa_half_to_float GLhalfARB    h
 

Convert a 2-byte half float to a 4-byte float.

Based on code from: http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html

void _mesa_init_default_imports __GLimports *    imports,
void   driverCtx
 

Initialize a __GLimports object to point to the functions in this file.

This is to be called from device drivers.

Also, do some one-time initializations.

Parameters:
imports  the object to initialize.
driverCtx  pointer to device driver-specific data.

float _mesa_inv_sqrtf float    x
 

inv_sqrt - A single precision 1/sqrt routine for IEEE format floats.

written by Josh Vanderhoof, based on newsgroup posts by James Van Buskirk and Vesa Karvonen.

float _mesa_log2 float    x
 

void* _mesa_malloc size_t    bytes
 

Wrapper around either malloc() or xf86malloc().

void* _mesa_memcpy void   dest,
const void   src,
size_t    n
 

void _mesa_memset void   dst,
int    val,
size_t    n
 

Wrapper around either memset() or xf86memset().

void _mesa_memset16 unsigned short *    dst,
unsigned short    val,
size_t    n
 

Fill memory with a constant 16bit word.

Parameters:
dst  destination pointer.
val  value.
n  number of words.

double _mesa_pow double    x,
double    y
 

Wrapper around either pow() or xf86pow().

void _mesa_printf const char *    fmtString,
...   
 

Wrapper around either printf() or xf86printf(), using vsprintf() for the formatting.

void _mesa_problem const __GLcontext *    ctx,
const char *    fmtString,
...   
 

void* _mesa_realloc void   oldBuffer,
size_t    oldSize,
size_t    newSize
 

Wrapper around either memcpy() or xf86memcpy().

double _mesa_sin double    a
 

Wrapper around either sin() or xf86sin().

int _mesa_sprintf char *    str,
const char *    fmt,
...   
 

Wrapper around either vsprintf() or xf86vsprintf().

double _mesa_sqrtd double    x
 

Wrapper around either sqrt() or xf86sqrt().

float _mesa_sqrtf float    x
 

Single precision square root.

int _mesa_strcmp const char *    s1,
const char *    s2
 

Wrapper around either strcmp() or xf86strcmp().

char* _mesa_strcpy char *    dest,
const char *    src
 

Wrapper around either strcpy() or xf86strcpy().

char* _mesa_strdup const char *    s
 

Implemented using _mesa_malloc() and _mesa_strcpy.

size_t _mesa_strlen const char *    s
 

Wrapper around either strlen() or xf86strlen().

char* _mesa_strncat char *    dest,
const char *    src,
size_t    n
 

Wrapper around either strncat() or xf86strncat().

int _mesa_strncmp const char *    s1,
const char *    s2,
size_t    n
 

Wrapper around either strncmp() or xf86strncmp().

char* _mesa_strncpy char *    dest,
const char *    src,
size_t    n
 

Wrapper around either strncpy() or xf86strncpy().

char* _mesa_strstr const char *    haystack,
const char *    needle
 

Wrapper around either strstr() or xf86strstr().

double _mesa_strtod const char *    s,
char **    end
 

Wrapper around either strtod() or xf86strtod().

void _mesa_warning __GLcontext *    gc,
const char *    fmtString,
...   
 

INLINE int iceil float    f [static]
 

INLINE int ifloor float    f [static]
 


Generated on Sun May 16 15:55:12 2004 for Mesa Core by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001