mesa: don't always enable OES_standard_derivatives
[mesa.git] / src / mesa / main / errors.c
index 4a187b7b0f285f5085cc7e6749bbfba984c068dd..796b6beff7cc21361988adc4c30b099cde254cc9 100644 (file)
@@ -322,7 +322,7 @@ _mesa_log_msg(struct gl_context *ctx, GLenum source, GLenum type,
 
    assert(!emptySlot->message && !emptySlot->length);
 
-   emptySlot->message = MALLOC(len+1);
+   emptySlot->message = malloc(len+1);
    if (emptySlot->message) {
       (void) strncpy(emptySlot->message, buf, (size_t)len);
       emptySlot->message[len] = '\0';
@@ -391,7 +391,7 @@ _mesa_get_msg(struct gl_context *ctx, GLenum *source, GLenum *type,
    }
 
    if (msg->message != (char*)out_of_memory)
-      FREE(msg->message);
+      free(msg->message);
    msg->message = NULL;
    msg->length = 0;
 
@@ -718,11 +718,11 @@ _mesa_DebugMessageControlARB(GLenum source, GLenum type, GLenum severity,
 }
 
 static void GLAPIENTRY
-_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, GLvoid *userParam)
+_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const GLvoid *userParam)
 {
    GET_CURRENT_CONTEXT(ctx);
    ctx->Debug.Callback = callback;
-   ctx->Debug.CallbackData = userParam;
+   ctx->Debug.CallbackData = (void *) userParam;
 }
 
 void
@@ -786,7 +786,7 @@ _mesa_free_errors_data(struct gl_context *ctx)
 
             foreach_s(node, tmp, &ClientIDs->Namespaces[s][t].Severity[sev]) {
                entry = (struct gl_client_severity *)node;
-               FREE(entry);
+               free(entry);
             }
          }
       }
@@ -801,30 +801,39 @@ output_if_debug(const char *prefixString, const char *outputString,
                 GLboolean newline)
 {
    static int debug = -1;
+   static FILE *fout = NULL;
 
-   /* Check the MESA_DEBUG environment variable if it hasn't
-    * been checked yet.  We only have to check it once...
+   /* Init the local 'debug' var once.
+    * Note: the _mesa_init_debug() function should have been called
+    * by now so MESA_DEBUG_FLAGS will be initialized.
     */
    if (debug == -1) {
-      char *env = _mesa_getenv("MESA_DEBUG");
-
-      /* In a debug build, we print warning messages *unless*
-       * MESA_DEBUG is 0.  In a non-debug build, we don't
-       * print warning messages *unless* MESA_DEBUG is
-       * set *to any value*.
+      /* If MESA_LOG_FILE env var is set, log Mesa errors, warnings,
+       * etc to the named file.  Otherwise, output to stderr.
        */
+      const char *logFile = _mesa_getenv("MESA_LOG_FILE");
+      if (logFile)
+         fout = fopen(logFile, "w");
+      if (!fout)
+         fout = stderr;
 #ifdef DEBUG
-      debug = (env != NULL && atoi(env) == 0) ? 0 : 1;
+      /* in debug builds, print messages unless MESA_DEBUG="silent" */
+      if (MESA_DEBUG_FLAGS & DEBUG_SILENT)
+         debug = 0;
+      else
+         debug = 1;
 #else
-      debug = (env != NULL) ? 1 : 0;
+      /* in release builds, be silent unless MESA_DEBUG is set */
+      debug = _mesa_getenv("MESA_DEBUG") != NULL;
 #endif
    }
 
    /* Now only print the string if we're required to do so. */
    if (debug) {
-      fprintf(stderr, "%s: %s", prefixString, outputString);
+      fprintf(fout, "%s: %s", prefixString, outputString);
       if (newline)
-         fprintf(stderr, "\n");
+         fprintf(fout, "\n");
+      fflush(fout);
 
 #if defined(_WIN32) && !defined(_WIN32_WCE)
       /* stderr from windows applications without console is not usually