Imports are services which the device driver or window system or operating system provides to the core renderer. The core renderer (Mesa) will call these functions in order to do memory allocation, simple I/O, etc.
Some drivers will want to override/replace this file with something specialized, but that'll be rare.
Eventually, I want to move roll the glheader.h file into this.
#include "imports.h"
#include "context.h"
#include "version.h"
Math | |
static short | sqrttab [0x100] |
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(). | |
void | _mesa_init_sqrt_table (void) |
float | _mesa_sqrtf (float x) |
Single precision square root. | |
float | _mesa_inv_sqrtf (float n) |
inv_sqrt - A single precision 1/sqrt routine for IEEE format floats. | |
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 val) |
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 val) |
Convert a 4-byte float to a 2-byte half float. | |
float | _mesa_half_to_float (GLhalfARB val) |
Convert a 2-byte half float to a 4-byte float. | |
Defines | |
#define | MAXSTRING 4000 |
Functions | |
void | _mesa_exit (int status) |
Wrapper for exit(). | |
Memory | |
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_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(). | |
Sort & Search | |
void * | _mesa_bsearch (const void *key, const void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)) |
Wrapper for bsearch(). | |
Environment vars | |
char * | _mesa_getenv (const char *var) |
Wrapper for getenv(). | |
String | |
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. | |
I/O | |
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(). | |
Diagnostics | |
static void | output_if_debug (const char *prefixString, const char *outputString, GLboolean newline) |
static const char * | error_string (GLenum error) |
Return string version of GL error code. | |
static void | flush_delayed_errors (GLcontext *ctx) |
When a new type of error is recorded, print a message describing previous errors which were accumulated. | |
void | _mesa_warning (GLcontext *ctx, const char *fmtString,...) |
Report a warning (a recoverable error condition) to stderr if either DEBUG is defined or the MESA_DEBUG env var is set. | |
void | _mesa_problem (const GLcontext *ctx, const char *fmtString,...) |
Report an internal implementation problem. | |
void | _mesa_error (GLcontext *ctx, GLenum error, const char *fmtString,...) |
Record an OpenGL state error. | |
void | _mesa_debug (const GLcontext *ctx, const char *fmtString,...) |
Report debug information. |
#define MAXSTRING 4000 |
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().
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.
bytes | number of bytes to allocate. | |
alignment | alignment (must be greater than zero). |
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, | |||
... | ||||
) |
Report debug information.
Print error message to stderr via fprintf(). No-op if DEBUG mode not enabled.
ctx | GL context. | |
fmtString | printf()-style format string, followed by optional args. |
void _mesa_error | ( | GLcontext * | ctx, | |
GLenum | error, | |||
const char * | fmtString, | |||
... | ||||
) |
Record an OpenGL state error.
These usually occur when the user passes invalid parameters to a GL function.
If debugging is enabled (either at compile-time via the DEBUG macro, or run-time via the MESA_DEBUG environment variable), report the error with _mesa_debug().
ctx | the GL context. | |
error | the error value. | |
fmtString | printf() style format string, followed by optional args |
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!
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.
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.
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, | |||
... | ||||
) |
Report an internal implementation problem.
Prints the message to stderr via fprintf().
ctx | GL context. | |
fmtString | problem description string. |
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 * | ctx, | |
const char * | fmtString, | |||
... | ||||
) |
Report a warning (a recoverable error condition) to stderr if either DEBUG is defined or the MESA_DEBUG env var is set.
ctx | GL context. | |
fmtString | printf()-like format string. |
static const char* error_string | ( | GLenum | error | ) | [static] |
Return string version of GL error code.
static void flush_delayed_errors | ( | GLcontext * | ctx | ) | [static] |
When a new type of error is recorded, print a message describing previous errors which were accumulated.
static void output_if_debug | ( | const char * | prefixString, | |
const char * | outputString, | |||
GLboolean | newline | |||
) | [static] |
short sqrttab[0x100] [static] |