*
* 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
/*
* Mesa 3-D graphics library
- * Version: 6.5
+ * Version: 7.1
*
- * Copyright (C) 1999-2006 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"),
*dst++ = val;
}
-/** Wrapper around either memcpy() or bzero() */
+/** Wrapper around either memset() or bzero() */
void
_mesa_bzero( void *dst, size_t n )
{
_mesa_ffs(int i)
{
#if (defined(_WIN32) && !defined(__MINGW32__) ) || defined(__IBMC__) || defined(__IBMCPP__)
- register int bit = 0;
- if (i != 0) {
- if ((i & 0xffff) == 0) {
- bit += 16;
- i >>= 16;
- }
- if ((i & 0xff) == 0) {
- bit += 8;
- i >>= 8;
- }
- if ((i & 0xf) == 0) {
- bit += 4;
- i >>= 4;
- }
- while ((i & 1) == 0) {
- bit++;
- i >>= 1;
- }
+ register int bit = 1;
+ if ((i & 0xffff) == 0) {
+ bit += 16;
+ i >>= 16;
}
- return bit;
+ 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
* if no bits set.
*/
int
+#ifdef __MINGW32__
+_mesa_ffsll(long val)
+#else
_mesa_ffsll(long long val)
+#endif
{
#ifdef ffsll
return ffsll(val);
assert(sizeof(val) == 8);
- bit = ffs(val);
+ bit = _mesa_ffs(val);
if (bit != 0)
return bit;
- bit = ffs(val >> 32);
+ bit = _mesa_ffs(val >> 32);
if (bit != 0)
return 32 + bit;
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 );
- fprintf(stderr,"%s", s);
}
/** Wrapper around vsprintf() */
/*@{*/
/**
- * 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 via fprintf().
*/
void
_mesa_warning( GLcontext *ctx, const char *fmtString, ... )
}
/**
- * 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 via fprintf().
*/
void
_mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
}
/**
- * 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, ... )
}
/**
- * 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 via fprintf().
+ * \param fmtString printf()-style format string, followed by optional args.
*/
void
_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )