core | glapi | vbo | math | shader | swrast | swrast_setup | tnl | tnl_dd

imports.h File Reference


Detailed Description

Standard C library function wrappers.

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

#include "compiler.h"
#include "glheader.h"

Data Structures

union  fi_type
 Sometimes we treat GLfloats as GLints. More...

Defines

#define ADD_POINTERS(A, B)   ( (GLubyte *) (A) + (uintptr_t) (B) )
#define MAX_GLUSHORT   0xffff
#define MAX_GLUINT   0xffffffff
#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 LOGF(x)   ((GLfloat) log(x))
#define EXPF(x)   ((GLfloat) exp(x))
#define LDEXPF(x, y)   ((GLfloat) ldexp(x,y))
#define FREXPF(x, y)   ((GLfloat) frexp(x,y))
#define IROUND(f)   ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
#define IROUND64(f)   ((GLint64) (((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 MALLOC(BYTES)   _mesa_malloc(BYTES)
 Memory macros.
#define CALLOC(BYTES)   _mesa_calloc(BYTES)
 Allocate and zero BYTES bytes.
#define MALLOC_STRUCT(T)   (struct T *) _mesa_malloc(sizeof(struct T))
 Allocate a structure of type T.
#define CALLOC_STRUCT(T)   (struct T *) _mesa_calloc(sizeof(struct T))
 Allocate and zero a structure of type T.
#define FREE(PTR)   _mesa_free(PTR)
 Free memory.
#define ALIGN_MALLOC(BYTES, N)   _mesa_align_malloc(BYTES, N)
 Allocate BYTES aligned at N bytes.
#define ALIGN_CALLOC(BYTES, N)   _mesa_align_calloc(BYTES, N)
 Allocate and zero BYTES bytes aligned at N bytes.
#define ALIGN_MALLOC_STRUCT(T, N)   (struct T *) _mesa_align_malloc(sizeof(struct T), N)
 Allocate a structure of type T aligned at N bytes.
#define ALIGN_CALLOC_STRUCT(T, N)   (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 MEMCPY(DST, SRC, BYTES)   _mesa_memcpy(DST, SRC, BYTES)
 Copy BYTES bytes from SRC into DST.
#define MEMSET(DST, VAL, N)   _mesa_memset(DST, VAL, N)
 Set N bytes in DST to VAL.

Functions

static INLINE int ifloor (float f)
static INLINE int iceil (float f)
static INLINE int _mesa_is_pow_two (int x)
 Is x a power of two?
static INLINE GLboolean _mesa_little_endian (void)
 Return 1 if this is a little endian machine, 0 if big endian.
void * _mesa_malloc (size_t bytes)
 Wrapper around malloc().
void * _mesa_calloc (size_t bytes)
 Wrapper around calloc().
void _mesa_free (void *ptr)
 Wrapper around free().
void * _mesa_align_malloc (size_t bytes, unsigned long alignment)
 Allocate aligned memory.
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 which was allocated with either _mesa_align_malloc() or _mesa_align_calloc().
void * _mesa_align_realloc (void *oldBuffer, size_t oldSize, size_t newSize, unsigned long alignment)
 Reallocate memory, with alignment.
void * _mesa_exec_malloc (GLuint size)
void _mesa_exec_free (void *addr)
void * _mesa_realloc (void *oldBuffer, size_t oldSize, size_t newSize)
 Reallocate memory.
void * _mesa_memcpy (void *dest, const void *src, size_t n)
 memcpy wrapper
void _mesa_memset (void *dst, int val, size_t n)
 Wrapper around memset().
void _mesa_memset16 (unsigned short *dst, unsigned short val, size_t n)
 Fill memory with a constant 16bit word.
void _mesa_bzero (void *dst, size_t n)
 Wrapper around either memset() or bzero().
int _mesa_memcmp (const void *s1, const void *s2, size_t n)
 Wrapper around memcmp().
double _mesa_sin (double a)
 Wrapper around sin().
float _mesa_sinf (float a)
 Single precision wrapper around sin().
double _mesa_cos (double a)
 Wrapper around cos().
float _mesa_asinf (float x)
 Single precision wrapper around asin().
float _mesa_atanf (float x)
 Single precision wrapper around atan().
double _mesa_sqrtd (double x)
 Wrapper around sqrt().
float _mesa_sqrtf (float x)
 Single precision square root.
float _mesa_inv_sqrtf (float x)
 inv_sqrt - A single precision 1/sqrt routine for IEEE format floats.
void _mesa_init_sqrt_table (void)
double _mesa_pow (double x, double y)
 Wrapper around pow().
int _mesa_ffs (int32_t i)
 Find the first bit set in a word.
int _mesa_ffsll (int64_t i)
 Find position of first bit set in given value.
unsigned int _mesa_bitcount (unsigned int n)
 Return number of bits set in given GLuint.
GLhalfARB _mesa_float_to_half (float f)
 Convert a 4-byte float to a 2-byte half float.
float _mesa_half_to_float (GLhalfARB h)
 Convert a 2-byte half float to a 4-byte float.
void * _mesa_bsearch (const void *key, const void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *))
 Wrapper for bsearch().
char * _mesa_getenv (const char *var)
 Wrapper for getenv().
char * _mesa_strstr (const char *haystack, const char *needle)
 Wrapper around strstr().
char * _mesa_strncat (char *dest, const char *src, size_t n)
 Wrapper around strncat().
char * _mesa_strcpy (char *dest, const char *src)
 Wrapper around strcpy().
char * _mesa_strncpy (char *dest, const char *src, size_t n)
 Wrapper around strncpy().
size_t _mesa_strlen (const char *s)
 Wrapper around strlen().
int _mesa_strcmp (const char *s1, const char *s2)
 Wrapper around strcmp().
int _mesa_strncmp (const char *s1, const char *s2, size_t n)
 Wrapper around strncmp().
char * _mesa_strdup (const char *s)
 Implemented using _mesa_malloc() and _mesa_strcpy.
int _mesa_atoi (const char *s)
 Wrapper around atoi().
double _mesa_strtod (const char *s, char **end)
 Wrapper around strtod().
unsigned int _mesa_str_checksum (const char *str)
 Compute simple checksum/hash for a string.
int _mesa_sprintf (char *str, const char *fmt,...)
 Wrapper around vsprintf().
int _mesa_snprintf (char *str, size_t size, const char *fmt,...)
 Wrapper around vsnprintf().
void _mesa_printf (const char *fmtString,...)
 Wrapper around printf(), using vsprintf() for the formatting.
void _mesa_fprintf (FILE *f, const char *fmtString,...)
 Wrapper around fprintf(), using vsprintf() for the formatting.
int _mesa_vsprintf (char *str, const char *fmt, va_list args)
 Wrapper around vsprintf().
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_exit (int status)
 Wrapper for exit().


Define Documentation

#define ADD_POINTERS ( A,
 )     ( (GLubyte *) (A) + (uintptr_t) (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 CLAMPED_FLOAT_TO_UBYTE ( ub,
 )     ub = ((GLubyte) IROUND((f) * 255.0F))

#define DEG2RAD   (M_PI/180.0)

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

#define EXPF (  )     ((GLfloat) exp(x))

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

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

#define FREE ( PTR   )     _mesa_free(PTR)

Free memory.

#define FREXPF ( x,
 )     ((GLfloat) frexp(x,y))

#define ICEIL (  )     iceil(x)

#define IFLOOR (  )     ifloor(x)

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

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

#define IROUND64 (  )     ((GLint64) (((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 LDEXPF ( x,
 )     ((GLfloat) ldexp(x,y))

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

#define LOGF (  )     ((GLfloat) log(x))

#define MALLOC ( BYTES   )     _mesa_malloc(BYTES)

Memory macros.

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 SQRTF (  )     (float) sqrt((float) (X))

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


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 which was allocated with either _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().

void* _mesa_align_realloc ( void *  oldBuffer,
size_t  oldSize,
size_t  newSize,
unsigned long  alignment 
)

Reallocate memory, with alignment.

float _mesa_asinf ( float  x  ) 

Single precision wrapper around asin().

float _mesa_atanf ( float  x  ) 

Single precision wrapper around atan().

int _mesa_atoi ( const char *  s  ) 

Wrapper around atoi().

unsigned int _mesa_bitcount ( unsigned int  n  ) 

Return number of bits set in given GLuint.

void* _mesa_bsearch ( const void *  key,
const void *  base,
size_t  nmemb,
size_t  size,
int(*)(const void *, const void *)  compar 
)

Wrapper for bsearch().

void _mesa_bzero ( void *  dst,
size_t  n 
)

Wrapper around either memset() or bzero().

void* _mesa_calloc ( size_t  bytes  ) 

Wrapper around calloc().

double _mesa_cos ( double  a  ) 

Wrapper around cos().

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

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

void _mesa_exec_free ( void *  addr  ) 

void* _mesa_exec_malloc ( GLuint  size  ) 

void _mesa_exit ( int  status  ) 

Wrapper for exit().

int _mesa_ffs ( int32_t  i  ) 

Find the first bit set in a word.

int _mesa_ffsll ( int64_t  val  ) 

Find position of first bit set in given value.

XXX Warning: this function can only be used on 64-bit systems!

Returns:
position of least-significant bit set, starting at 1, return zero if no bits set.

GLhalfARB _mesa_float_to_half ( float  val  ) 

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_fprintf ( FILE *  f,
const char *  fmtString,
  ... 
)

Wrapper around fprintf(), using vsprintf() for the formatting.

void _mesa_free ( void *  ptr  ) 

Wrapper around free().

char* _mesa_getenv ( const char *  var  ) 

Wrapper for getenv().

float _mesa_half_to_float ( GLhalfARB  val  ) 

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_sqrt_table ( void   ) 

float _mesa_inv_sqrtf ( float  n  ) 

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.

static INLINE int _mesa_is_pow_two ( int  x  )  [static]

Is x a power of two?

static INLINE GLboolean _mesa_little_endian ( void   )  [static]

Return 1 if this is a little endian machine, 0 if big endian.

void* _mesa_malloc ( size_t  bytes  ) 

Wrapper around malloc().

int _mesa_memcmp ( const void *  s1,
const void *  s2,
size_t  n 
)

Wrapper around memcmp().

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

memcpy wrapper

void _mesa_memset ( void *  dst,
int  val,
size_t  n 
)

Wrapper around memset().

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 pow().

void _mesa_printf ( const char *  fmtString,
  ... 
)

Wrapper around printf(), 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 
)

Reallocate memory.

double _mesa_sin ( double  a  ) 

Wrapper around sin().

float _mesa_sinf ( float  a  ) 

Single precision wrapper around sin().

int _mesa_snprintf ( char *  str,
size_t  size,
const char *  fmt,
  ... 
)

Wrapper around vsnprintf().

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

Wrapper around vsprintf().

double _mesa_sqrtd ( double  x  ) 

Wrapper around sqrt().

float _mesa_sqrtf ( float  x  ) 

Single precision square root.

unsigned int _mesa_str_checksum ( const char *  str  ) 

Compute simple checksum/hash for a string.

int _mesa_strcmp ( const char *  s1,
const char *  s2 
)

Wrapper around strcmp().

char* _mesa_strcpy ( char *  dest,
const char *  src 
)

Wrapper around strcpy().

char* _mesa_strdup ( const char *  s  ) 

Implemented using _mesa_malloc() and _mesa_strcpy.

Note that NULL is handled accordingly.

size_t _mesa_strlen ( const char *  s  ) 

Wrapper around strlen().

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

Wrapper around strncat().

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

Wrapper around strncmp().

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

Wrapper around strncpy().

char* _mesa_strstr ( const char *  haystack,
const char *  needle 
)

Wrapper around strstr().

double _mesa_strtod ( const char *  s,
char **  end 
)

Wrapper around strtod().

int _mesa_vsprintf ( char *  str,
const char *  fmt,
va_list  args 
)

Wrapper around vsprintf().

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

static INLINE int iceil ( float  f  )  [static]

static INLINE int ifloor ( float  f  )  [static]


Generated on Sun Sep 27 06:47:46 2009 for Mesa Main by  doxygen 1.5.4