X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fimports.c;h=d798f80e25316612ba3d0b6616c8113ed1079896;hb=eded7f010d344a909cf9c403eb3bdad91804d174;hp=0afc4ea4313e82ba03162aea1cce210fb94e3dbb;hpb=f959f6e1dc27c71fc0ccc56e09b29101b3bf3b97;p=mesa.git diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 0afc4ea4313..d798f80e253 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -12,29 +12,17 @@ * * Eventually, I want to move roll the glheader.h file into this. * - * The OpenGL SI's __GLimports structure allows per-context specification of - * replacements for the standard C lib functions. In practice that's probably - * never needed; compile-time replacements are far more likely. - * - * The _mesa_*() functions defined here don't in general take a context - * parameter. I guess we can change that someday, if need be. - * So for now, the __GLimports stuff really isn't used. - * * \todo Functions still needed: * - scanf * - qsort - * - bsearch * - rand and RAND_MAX - * - * \note When compiled into a XFree86 module these functions wrap around - * XFree86 own wrappers. */ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 7.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -58,6 +46,7 @@ #include "imports.h" #include "context.h" +#include "version.h" #define MAXSTRING 4000 /* for vsnprintf() */ @@ -71,42 +60,29 @@ extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg); #endif #endif - /**********************************************************************/ /** \name Memory */ /*@{*/ -/** Wrapper around either malloc() or xf86malloc() */ +/** Wrapper around malloc() */ void * _mesa_malloc(size_t bytes) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86malloc(bytes); -#else return malloc(bytes); -#endif } -/** Wrapper around either calloc() or xf86calloc() */ +/** Wrapper around calloc() */ void * _mesa_calloc(size_t bytes) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86calloc(1, bytes); -#else return calloc(1, bytes); -#endif } -/** Wrapper around either free() or xf86free() */ +/** Wrapper around free() */ void _mesa_free(void *ptr) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - xf86free(ptr); -#else free(ptr); -#endif } /** @@ -123,16 +99,22 @@ _mesa_free(void *ptr) void * _mesa_align_malloc(size_t bytes, unsigned long alignment) { - unsigned long ptr, buf; +#if defined(HAVE_POSIX_MEMALIGN) + void *mem; + + (void) posix_memalign(& mem, alignment, bytes); + return mem; +#else + uintptr_t ptr, buf; ASSERT( alignment > 0 ); - ptr = (unsigned long) _mesa_malloc(bytes + alignment + sizeof(void *)); + ptr = (uintptr_t) _mesa_malloc(bytes + alignment + sizeof(void *)); if (!ptr) return NULL; - buf = (ptr + alignment + sizeof(void *)) & ~(unsigned long)(alignment - 1); - *(unsigned long *)(buf - sizeof(void *)) = ptr; + buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); + *(uintptr_t *)(buf - sizeof(void *)) = ptr; #ifdef DEBUG /* mark the non-aligned area */ @@ -143,23 +125,36 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment) #endif return (void *) buf; +#endif /* defined(HAVE_POSIX_MEMALIGN) */ } -/** Same as _mesa_align_malloc(), but using _mesa_calloc() instead of - * _mesa_malloc() */ +/** + * Same as _mesa_align_malloc(), but using _mesa_calloc() instead of + * _mesa_malloc() + */ void * _mesa_align_calloc(size_t bytes, unsigned long alignment) { - unsigned long ptr, buf; +#if defined(HAVE_POSIX_MEMALIGN) + void *mem; + + mem = _mesa_align_malloc(bytes, alignment); + if (mem != NULL) { + (void) memset(mem, 0, bytes); + } + + return mem; +#else + uintptr_t ptr, buf; ASSERT( alignment > 0 ); - ptr = (unsigned long) _mesa_calloc(bytes + alignment + sizeof(void *)); + ptr = (uintptr_t) _mesa_calloc(bytes + alignment + sizeof(void *)); if (!ptr) return NULL; - buf = (ptr + alignment + sizeof(void *)) & ~(unsigned long)(alignment - 1); - *(unsigned long *)(buf - sizeof(void *)) = ptr; + buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1); + *(uintptr_t *)(buf - sizeof(void *)) = ptr; #ifdef DEBUG /* mark the non-aligned area */ @@ -170,69 +165,84 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment) #endif return (void *)buf; +#endif /* defined(HAVE_POSIX_MEMALIGN) */ } /** - * Free memory allocated with _mesa_align_malloc() or _mesa_align_calloc(). - * + * Free memory which was allocated with either _mesa_align_malloc() + * or _mesa_align_calloc(). * \param 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_free(void *ptr) { -#if 0 - _mesa_free( (void *)(*(unsigned long *)((unsigned long)ptr - sizeof(void *))) ); +#if defined(HAVE_POSIX_MEMALIGN) + free(ptr); #else void **cubbyHole = (void **) ((char *) ptr - sizeof(void *)); void *realAddr = *cubbyHole; _mesa_free(realAddr); -#endif +#endif /* defined(HAVE_POSIX_MEMALIGN) */ +} + +/** + * Reallocate memory, with alignment. + */ +void * +_mesa_align_realloc(void *oldBuffer, size_t oldSize, size_t newSize, + unsigned long alignment) +{ + const size_t copySize = (oldSize < newSize) ? oldSize : newSize; + void *newBuf = _mesa_align_malloc(newSize, alignment); + if (newBuf && oldBuffer && copySize > 0) { + _mesa_memcpy(newBuf, oldBuffer, copySize); + } + if (oldBuffer) + _mesa_align_free(oldBuffer); + return newBuf; } -/** Wrapper around either memcpy() or xf86memcpy() */ + + +/** Reallocate memory */ void * _mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize) { const size_t copySize = (oldSize < newSize) ? oldSize : newSize; void *newBuffer = _mesa_malloc(newSize); - if (newBuffer && copySize > 0) + if (newBuffer && oldBuffer && copySize > 0) _mesa_memcpy(newBuffer, oldBuffer, copySize); if (oldBuffer) _mesa_free(oldBuffer); return newBuffer; } - +/** memcpy wrapper */ void * _mesa_memcpy(void *dest, const void *src, size_t n) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86memcpy(dest, src, n); -#elif defined(SUNOS4) +#if defined(SUNOS4) return memcpy((char *) dest, (char *) src, (int) n); #else return memcpy(dest, src, n); #endif } -/** Wrapper around either memset() or xf86memset() */ +/** Wrapper around memset() */ void _mesa_memset( void *dst, int val, size_t n ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - xf86memset( dst, val, n ); -#elif defined(SUNOS4) +#if defined(SUNOS4) memset( (char *) dst, (int) val, (int) n ); #else memset(dst, val, n); #endif } -/** Fill memory with a constant 16bit word. - * +/** + * Fill memory with a constant 16bit word. * \param dst destination pointer. * \param val value. * \param n number of words. @@ -244,19 +254,28 @@ _mesa_memset16( unsigned short *dst, unsigned short val, size_t n ) *dst++ = val; } -/** Wrapper around either memcpy() or xf86memcpy() or bzero() */ +/** Wrapper around either memset() or bzero() */ void _mesa_bzero( void *dst, size_t n ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - xf86memset( dst, 0, n ); -#elif defined(__FreeBSD__) +#if defined(__FreeBSD__) bzero( dst, n ); #else memset( dst, 0, n ); #endif } +/** Wrapper around memcmp() */ +int +_mesa_memcmp( const void *s1, const void *s2, size_t n ) +{ +#if defined(SUNOS4) + return memcmp( (char *) s1, (char *) s2, (int) n ); +#else + return memcmp(s1, s2, n); +#endif +} + /*@}*/ @@ -264,37 +283,46 @@ _mesa_bzero( void *dst, size_t n ) /** \name Math */ /*@{*/ -/** Wrapper around either sin() or xf86sin() */ +/** Wrapper around sin() */ double _mesa_sin(double a) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86sin(a); -#else return sin(a); -#endif } -/** Wrapper around either cos() or xf86cos() */ +/** Single precision wrapper around sin() */ +float +_mesa_sinf(float a) +{ + return (float) sin((double) a); +} + +/** Wrapper around cos() */ double _mesa_cos(double a) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86cos(a); -#else return cos(a); -#endif } -/** Wrapper around either sqrt() or xf86sqrt() */ +/** Single precision wrapper around asin() */ +float +_mesa_asinf(float x) +{ + return (float) asin((double) x); +} + +/** Single precision wrapper around atan() */ +float +_mesa_atanf(float x) +{ + return (float) atan((double) x); +} + +/** Wrapper around sqrt() */ double _mesa_sqrtd(double x) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86sqrt(x); -#else return sqrt(x); -#endif } @@ -312,7 +340,8 @@ _mesa_sqrtd(double x) */ static short sqrttab[0x100]; /* declare table of square roots */ -static void init_sqrt_table(void) +void +_mesa_init_sqrt_table(void) { #if defined(USE_IEEE) && !defined(DEBUG) unsigned short i; @@ -492,24 +521,80 @@ _mesa_inv_sqrtf(float n) return x3 * r3; #endif -#elif defined(XFree86LOADER) && defined(IN_MODULE) - return 1.0F / xf86sqrt(n); #else return (float) (1.0 / sqrt(n)); #endif } -/** - * Wrapper around either pow() or xf86pow(). - */ +/** Wrapper around pow() */ double _mesa_pow(double x, double y) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86pow(x, y); -#else return pow(x, y); +} + + +/** + * Find the first bit set in a word. + */ +int +_mesa_ffs(int i) +{ +#if (defined(_WIN32) && !defined(__MINGW32__) ) || defined(__IBMC__) || defined(__IBMCPP__) + register int bit = 1; + if ((i & 0xffff) == 0) { + bit += 16; + i >>= 16; + } + if ((i & 0xff) == 0) { + bit += 8; + i >>= 8; + } + if ((i & 0xf) == 0) { + bit += 4; + i >>= 4; + } + if ((i & 0x3) == 0) { + bit += 2; + i >>= 2; + } + return (i) ? (bit + ((i + 1) & 0x01)) : 0; +#else + return ffs(i); +#endif +} + + +/** + * Find position of first bit set in given value. + * XXX Warning: this function can only be used on 64-bit systems! + * \return position of least-significant bit set, starting at 1, return zero + * if no bits set. + */ +int +#ifdef __MINGW32__ +_mesa_ffsll(long val) +#else +_mesa_ffsll(long long val) +#endif +{ +#ifdef ffsll + return ffsll(val); +#else + int bit; + + assert(sizeof(val) == 8); + + bit = _mesa_ffs(val); + if (bit != 0) + return bit; + + bit = _mesa_ffs(val >> 32); + if (bit != 0) + return 32 + bit; + + return 0; #endif } @@ -536,7 +621,7 @@ _mesa_bitcount(unsigned int n) GLhalfARB _mesa_float_to_half(float val) { - const int flt = *((int *) &val); + const int flt = *((int *) (void *) &val); const int flt_m = flt & 0x7fffff; const int flt_e = (flt >> 23) & 0xff; const int flt_s = (flt >> 31) & 0x1; @@ -662,13 +747,30 @@ _mesa_half_to_float(GLhalfARB val) } flt = (flt_s << 31) | (flt_e << 23) | flt_m; - result = *((float *) &flt); + result = *((float *) (void *) &flt); return result; } /*@}*/ +/**********************************************************************/ +/** \name Sort & Search */ +/*@{*/ + +/** + * Wrapper for bsearch(). + */ +void * +_mesa_bsearch( const void *key, const void *base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *) ) +{ + return bsearch(key, base, nmemb, size, compar); +} + +/*@}*/ + + /**********************************************************************/ /** \name Environment vars */ /*@{*/ @@ -679,8 +781,8 @@ _mesa_half_to_float(GLhalfARB val) char * _mesa_getenv( const char *var ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86getenv(var); +#if defined(_XBOX) + return NULL; #else return getenv(var); #endif @@ -693,114 +795,86 @@ _mesa_getenv( const char *var ) /** \name String */ /*@{*/ -/** Wrapper around either strstr() or xf86strstr() */ +/** Wrapper around strstr() */ char * _mesa_strstr( const char *haystack, const char *needle ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strstr(haystack, needle); -#else return strstr(haystack, needle); -#endif } -/** Wrapper around either strncat() or xf86strncat() */ +/** Wrapper around strncat() */ char * _mesa_strncat( char *dest, const char *src, size_t n ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strncat(dest, src, n); -#else return strncat(dest, src, n); -#endif } -/** Wrapper around either strcpy() or xf86strcpy() */ +/** Wrapper around strcpy() */ char * _mesa_strcpy( char *dest, const char *src ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strcpy(dest, src); -#else return strcpy(dest, src); -#endif } -/** Wrapper around either strncpy() or xf86strncpy() */ +/** Wrapper around strncpy() */ char * _mesa_strncpy( char *dest, const char *src, size_t n ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strncpy(dest, src, n); -#else return strncpy(dest, src, n); -#endif } -/** Wrapper around either strlen() or xf86strlen() */ +/** Wrapper around strlen() */ size_t _mesa_strlen( const char *s ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strlen(s); -#else return strlen(s); -#endif } -/** Wrapper around either strcmp() or xf86strcmp() */ +/** Wrapper around strcmp() */ int _mesa_strcmp( const char *s1, const char *s2 ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strcmp(s1, s2); -#else return strcmp(s1, s2); -#endif } -/** Wrapper around either strncmp() or xf86strncmp() */ +/** Wrapper around strncmp() */ int _mesa_strncmp( const char *s1, const char *s2, size_t n ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strncmp(s1, s2, n); -#else return strncmp(s1, s2, n); -#endif } -/** Implemented using _mesa_malloc() and _mesa_strcpy */ +/** + * Implemented using _mesa_malloc() and _mesa_strcpy. + * Note that NULL is handled accordingly. + */ char * _mesa_strdup( const char *s ) { - int l = _mesa_strlen(s); - char *s2 = (char *) _mesa_malloc(l + 1); - if (s2) - _mesa_strcpy(s2, s); - return s2; + if (s) { + size_t l = _mesa_strlen(s); + char *s2 = (char *) _mesa_malloc(l + 1); + if (s2) + _mesa_strcpy(s2, s); + return s2; + } + else { + return NULL; + } } -/** Wrapper around either atoi() or xf86atoi() */ +/** Wrapper around atoi() */ int _mesa_atoi(const char *s) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86atoi(s); -#else return atoi(s); -#endif } -/** Wrapper around either strtod() or xf86strtod() */ +/** Wrapper around strtod() */ double _mesa_strtod( const char *s, char **end ) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86strtod(s, end); -#else return strtod(s, end); -#endif } /*@}*/ @@ -810,37 +884,33 @@ _mesa_strtod( const char *s, char **end ) /** \name I/O */ /*@{*/ -/** Wrapper around either vsprintf() or xf86vsprintf() */ +/** Wrapper around vsprintf() */ int _mesa_sprintf( char *str, const char *fmt, ... ) { int r; va_list args; va_start( args, fmt ); - va_end( args ); -#if defined(XFree86LOADER) && defined(IN_MODULE) - r = xf86vsprintf( str, fmt, args ); -#else r = vsprintf( str, fmt, args ); -#endif + va_end( args ); return r; } -/** Wrapper around either printf() or xf86printf(), using vsprintf() for - * the formatting. */ +/** Wrapper around printf(), using vsprintf() for the formatting. */ void _mesa_printf( const char *fmtString, ... ) { - char s[MAXSTRING]; va_list args; va_start( args, fmtString ); - vsnprintf(s, MAXSTRING, fmtString, args); + vfprintf(stderr, fmtString, args); va_end( args ); -#if defined(XFree86LOADER) && defined(IN_MODULE) - xf86printf("%s", s); -#else - printf("%s", s); -#endif +} + +/** Wrapper around vsprintf() */ +int +_mesa_vsprintf( char *str, const char *fmt, va_list args ) +{ + return vsprintf( str, fmt, args ); } /*@}*/ @@ -851,14 +921,11 @@ _mesa_printf( const char *fmtString, ... ) /*@{*/ /** - * Display a warning. + * Report a warning (a recoverable error condition) to stderr if + * either DEBUG is defined or the MESA_DEBUG env var is set. * * \param ctx GL context. * \param fmtString printf() alike format string. - * - * If debugging is enabled (either at compile-time via the DEBUG macro, or - * run-time via the MESA_DEBUG environment variable), prints the warning to - * stderr, either via fprintf() or xf86printf(). */ void _mesa_warning( GLcontext *ctx, const char *fmtString, ... ) @@ -876,22 +943,16 @@ _mesa_warning( GLcontext *ctx, const char *fmtString, ... ) debug = _mesa_getenv("MESA_DEBUG") ? GL_TRUE : GL_FALSE; #endif if (debug) { -#if defined(XFree86LOADER) && defined(IN_MODULE) - xf86fprintf(stderr, "Mesa warning: %s\n", str); -#else fprintf(stderr, "Mesa warning: %s\n", str); -#endif } } /** - * This function is called when the Mesa user has stumbled into a code - * path which may not be implemented fully or correctly. + * Report an internla implementation problem. + * Prints the message to stderr via fprintf(). * * \param ctx GL context. * \param s problem description string. - * - * Prints the message to stderr, either via fprintf() or xf86fprintf(). */ void _mesa_problem( const GLcontext *ctx, const char *fmtString, ... ) @@ -904,28 +965,21 @@ _mesa_problem( const GLcontext *ctx, const char *fmtString, ... ) vsnprintf( str, MAXSTRING, fmtString, args ); va_end( args ); -#if defined(XFree86LOADER) && defined(IN_MODULE) - xf86fprintf(stderr, "Mesa implementation error: %s\n", str); - xf86fprintf(stderr, "Please report to the DRI project at dri.sourceforge.net\n"); -#else - fprintf(stderr, "Mesa implementation error: %s\n", str); - fprintf(stderr, "Please report to the Mesa bug database at www.mesa3d.org\n" ); -#endif + fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str); + fprintf(stderr, "Please report at bugzilla.freedesktop.org\n"); } /** - * Display an error message. + * Record an OpenGL state error. These usually occur when the users + * passes invalid parameters to a GL function. * - * If in debug mode, print error message. - * Also, record the error code by calling _mesa_record_error(). + * 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(). * * \param ctx the GL context. * \param error the error value. * \param fmtString printf() style format string, followed by optional args - * - * If debugging is enabled (either at compile-time via the DEBUG macro, or - * run-time via the MESA_DEBUG environment variable), interperts the error code and - * prints the error message via _mesa_debug(). */ void _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) @@ -981,6 +1035,9 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) case GL_TABLE_TOO_LARGE: errstr = "GL_TABLE_TOO_LARGE"; break; + case GL_INVALID_FRAMEBUFFER_OPERATION_EXT: + errstr = "GL_INVALID_FRAMEBUFFER_OPERATION"; + break; default: errstr = "unknown"; break; @@ -992,199 +1049,35 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) } /** - * Report debug information. + * Report debug information. Print error message to stderr via fprintf(). + * No-op if DEBUG mode not enabled. * * \param ctx GL context. - * \param fmtString printf() alike format string. - * - * Prints the message to stderr, either via fprintf() or xf86printf(). + * \param fmtString printf()-style format string, followed by optional args. */ void _mesa_debug( const GLcontext *ctx, const char *fmtString, ... ) { +#ifdef DEBUG char s[MAXSTRING]; va_list args; va_start(args, fmtString); vsnprintf(s, MAXSTRING, fmtString, args); va_end(args); -#if defined(XFree86LOADER) && defined(IN_MODULE) - xf86fprintf(stderr, "Mesa: %s", s); -#else fprintf(stderr, "Mesa: %s", s); -#endif -} - -/*@}*/ - - -/**********************************************************************/ -/** \name Default Imports Wrapper */ -/*@{*/ - -/** Wrapper around _mesa_malloc() */ -static void * -default_malloc(__GLcontext *gc, size_t size) -{ - (void) gc; - return _mesa_malloc(size); -} - -/** Wrapper around _mesa_malloc() */ -static void * -default_calloc(__GLcontext *gc, size_t numElem, size_t elemSize) -{ - (void) gc; - return _mesa_calloc(numElem * elemSize); -} - -/** Wrapper around either realloc() or xf86realloc() */ -static void * -default_realloc(__GLcontext *gc, void *oldAddr, size_t newSize) -{ - (void) gc; -#if defined(XFree86LOADER) && defined(IN_MODULE) - return xf86realloc(oldAddr, newSize); -#else - return realloc(oldAddr, newSize); -#endif -} - -/** Wrapper around _mesa_free() */ -static void -default_free(__GLcontext *gc, void *addr) -{ - (void) gc; - _mesa_free(addr); -} - -/** Wrapper around _mesa_getenv() */ -static char * CAPI -default_getenv( __GLcontext *gc, const char *var ) -{ - (void) gc; - return _mesa_getenv(var); -} - -/** Wrapper around _mesa_warning() */ -static void -default_warning(__GLcontext *gc, char *str) -{ - _mesa_warning(gc, str); -} - -/** Wrapper around _mesa_problem() */ -static void -default_fatal(__GLcontext *gc, char *str) -{ - _mesa_problem(gc, str); - abort(); -} - -/** Wrapper around atoi() */ -static int CAPI -default_atoi(__GLcontext *gc, const char *str) -{ - (void) gc; - return atoi(str); -} - -/** Wrapper around vsprintf() */ -static int CAPI -default_sprintf(__GLcontext *gc, char *str, const char *fmt, ...) -{ - int r; - va_list args; - va_start( args, fmt ); - r = vsprintf( str, fmt, args ); - va_end( args ); - return r; -} - -/** Wrapper around fopen() */ -static void * CAPI -default_fopen(__GLcontext *gc, const char *path, const char *mode) -{ - return fopen(path, mode); -} - -/** Wrapper around fclose() */ -static int CAPI -default_fclose(__GLcontext *gc, void *stream) -{ - return fclose((FILE *) stream); -} - -/** Wrapper around vfprintf() */ -static int CAPI -default_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...) -{ - int r; - va_list args; - va_start( args, fmt ); - r = vfprintf( (FILE *) stream, fmt, args ); - va_end( args ); - return r; -} - -/** - * \todo this really is driver-specific and can't be here - */ -static __GLdrawablePrivate * -default_GetDrawablePrivate(__GLcontext *gc) -{ - return NULL; +#endif /* DEBUG */ + (void) ctx; + (void) fmtString; } /*@}*/ /** - * 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. - * - * \param imports the object to initialize. - * \param driverCtx pointer to device driver-specific data. + * Wrapper for exit(). */ void -_mesa_init_default_imports(__GLimports *imports, void *driverCtx) +_mesa_exit( int status ) { - /* XXX maybe move this one-time init stuff into context.c */ - static GLboolean initialized = GL_FALSE; - if (!initialized) { - init_sqrt_table(); - -#if defined(_FPU_GETCW) && defined(_FPU_SETCW) - { - const char *debug = _mesa_getenv("MESA_DEBUG"); - if (debug && _mesa_strcmp(debug, "FP")==0) { - /* die on FP exceptions */ - fpu_control_t mask; - _FPU_GETCW(mask); - mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM - | _FPU_MASK_OM | _FPU_MASK_UM); - _FPU_SETCW(mask); - } - } -#endif - initialized = GL_TRUE; - } - - imports->malloc = default_malloc; - imports->calloc = default_calloc; - imports->realloc = default_realloc; - imports->free = default_free; - imports->warning = default_warning; - imports->fatal = default_fatal; - imports->getenv = default_getenv; /* not used for now */ - imports->atoi = default_atoi; - imports->sprintf = default_sprintf; - imports->fopen = default_fopen; - imports->fclose = default_fclose; - imports->fprintf = default_fprintf; - imports->getDrawablePrivate = default_GetDrawablePrivate; - imports->other = driverCtx; + exit(status); }