⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imports.c

📁 mesa-6.5-minigui源码
💻 C
📖 第 1 页 / 共 3 页
字号:
{   size_t l = _mesa_strlen(s);   char *s2 = (char *) _mesa_malloc(l + 1);   if (s2)      _mesa_strcpy(s2, s);   return s2;}/** Wrapper around either atoi() or xf86atoi() */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() */double_mesa_strtod( const char *s, char **end ){#if defined(XFree86LOADER) && defined(IN_MODULE)   return xf86strtod(s, end);#else   return strtod(s, end);#endif}/*@}*//**********************************************************************//** \name I/O *//*@{*//** Wrapper around either vsprintf() or xf86vsprintf() */int_mesa_sprintf( char *str, const char *fmt, ... ){   int r;   va_list args;   va_start( args, fmt );  #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. */void_mesa_printf( const char *fmtString, ... ){   char s[MAXSTRING];   va_list args;   va_start( args, fmtString );     vsnprintf(s, MAXSTRING, fmtString, args);   va_end( args );#if defined(XFree86LOADER) && defined(IN_MODULE)   xf86printf("%s", s);#else   fprintf(stderr,"%s", s);#endif}/** Wrapper around either vsprintf() or xf86vsprintf() */int_mesa_vsprintf( char *str, const char *fmt, va_list args ){#if defined(XFree86LOADER) && defined(IN_MODULE)   return xf86vsprintf( str, fmt, args );#else   return vsprintf( str, fmt, args );#endif}/*@}*//**********************************************************************//** \name Diagnostics *//*@{*//** * Display a warning. * * \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, ... ){   GLboolean debug;   char str[MAXSTRING];   va_list args;   (void) ctx;   va_start( args, fmtString );     (void) vsnprintf( str, MAXSTRING, fmtString, args );   va_end( args );#ifdef DEBUG   debug = GL_TRUE; /* always print warning */#else   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. * * \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, ... ){   va_list args;   char str[MAXSTRING];   (void) ctx;   va_start( args, fmtString );     vsnprintf( str, MAXSTRING, fmtString, args );   va_end( args );#if defined(XFree86LOADER) && defined(IN_MODULE)   xf86fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);   xf86fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");#else   fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);   fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");#endif}/** * Display an error message. * * If in debug mode, print error message. * Also, record the error code by calling _mesa_record_error(). *  * \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, ... ){   const char *debugEnv;   GLboolean debug;   debugEnv = _mesa_getenv("MESA_DEBUG");#ifdef DEBUG   if (debugEnv && _mesa_strstr(debugEnv, "silent"))      debug = GL_FALSE;   else      debug = GL_TRUE;#else   if (debugEnv)      debug = GL_TRUE;   else      debug = GL_FALSE;#endif   if (debug) {      va_list args;      char where[MAXSTRING];      const char *errstr;      va_start( args, fmtString );        vsnprintf( where, MAXSTRING, fmtString, args );      va_end( args );      switch (error) {	 case GL_NO_ERROR:	    errstr = "GL_NO_ERROR";	    break;	 case GL_INVALID_VALUE:	    errstr = "GL_INVALID_VALUE";	    break;	 case GL_INVALID_ENUM:	    errstr = "GL_INVALID_ENUM";	    break;	 case GL_INVALID_OPERATION:	    errstr = "GL_INVALID_OPERATION";	    break;	 case GL_STACK_OVERFLOW:	    errstr = "GL_STACK_OVERFLOW";	    break;	 case GL_STACK_UNDERFLOW:	    errstr = "GL_STACK_UNDERFLOW";	    break;	 case GL_OUT_OF_MEMORY:	    errstr = "GL_OUT_OF_MEMORY";	    break;         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;      }      _mesa_debug(ctx, "User error: %s in %s\n", errstr, where);   }   _mesa_record_error(ctx, error);}  /** * Report debug information. *  * \param ctx GL context. * \param fmtString printf() alike format string. *  * Prints the message to stderr, either via fprintf() or xf86printf(). */void_mesa_debug( const GLcontext *ctx, const char *fmtString, ... ){   char s[MAXSTRING];   va_list args;   (void) ctx;   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 Exit *//*@{*//** * Wrapper for exit(). */void_mesa_exit( int status ){#if defined(XFree86LOADER) && defined(IN_MODULE)   xf86exit(status);#else   exit(status);#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 voiddefault_free(__GLcontext *gc, void *addr){   (void) gc;   _mesa_free(addr);}/** Wrapper around _mesa_getenv() */static char * CAPIdefault_getenv( __GLcontext *gc, const char *var ){   (void) gc;   return _mesa_getenv(var);}/** Wrapper around _mesa_warning() */static voiddefault_warning(__GLcontext *gc, char *str){   _mesa_warning(gc, str);}/** Wrapper around _mesa_problem() */static voiddefault_fatal(__GLcontext *gc, char *str){   _mesa_problem(gc, str);   abort();}/** Wrapper around atoi() */static int CAPIdefault_atoi(__GLcontext *gc, const char *str){   (void) gc;   return atoi(str);}/** Wrapper around vsprintf() */static int CAPIdefault_sprintf(__GLcontext *gc, char *str, const char *fmt, ...){   int r;   va_list args;   (void) gc;   va_start( args, fmt );     r = vsprintf( str, fmt, args );   va_end( args );   return r;}/** Wrapper around fopen() */static void * CAPIdefault_fopen(__GLcontext *gc, const char *path, const char *mode){   (void) gc;   return fopen(path, mode);}/** Wrapper around fclose() */static int CAPIdefault_fclose(__GLcontext *gc, void *stream){   (void) gc;   return fclose((FILE *) stream);}/** Wrapper around vfprintf() */static int CAPIdefault_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...){   int r;   va_list args;   (void) gc;   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){   (void) gc;   return NULL;}/*@}*//** * 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. */void_mesa_init_default_imports(__GLimports *imports, void *driverCtx){   /* XXX maybe move this one-time init stuff into context.c */   static GLboolean initialized = GL_FALSE;   if (!initialized) {      init_sqrt_table();      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;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -