Mesa (master): Noop dispatch: move warning code out of the generated functions

Kristian Høgsberg krh at kemper.freedesktop.org
Mon Jan 4 04:49:42 UTC 2010


Module: Mesa
Branch: master
Commit: c3047e73f78b4f337a2f66acdc95133d61a2b535
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c3047e73f78b4f337a2f66acdc95133d61a2b535

Author: Kristian Høgsberg <krh at bitplanet.net>
Date:   Sun Jan  3 22:46:43 2010 -0500

Noop dispatch: move warning code out of the generated functions

This reduces libGL size by 11% here, going from 360968 bytes to
320008 bytes.

---

 src/mesa/glapi/glapi.c |   28 +++++++---------------------
 1 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c
index 21cc448..37c6977 100644
--- a/src/mesa/glapi/glapi.c
+++ b/src/mesa/glapi/glapi.c
@@ -73,7 +73,6 @@
 #include "glapioffsets.h"
 #include "glapitable.h"
 
-
 /***** BEGIN NO-OP DISPATCH *****/
 
 static GLboolean WarnFlag = GL_FALSE;
@@ -97,23 +96,18 @@ _glapi_set_warning_func( _glapi_warning_func func )
    warning_func = func;
 }
 
-static GLboolean
-warn(void)
+static int
+warn(const char *func)
 {
 #if !defined(_WIN32_WCE)
    if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG"))
        && warning_func) {
-      return GL_TRUE;
-   }
-   else {
-      return GL_FALSE;
+      warning_func(NULL, "GL User Error: called without context: %s", func);
    }
-#else
-   return GL_FALSE;
 #endif
+   return 0;
 }
 
-
 #define KEYWORD1 static
 #define KEYWORD1_ALT static
 #define KEYWORD2 GLAPIENTRY
@@ -122,15 +116,10 @@ warn(void)
 #define F NULL
 
 #define DISPATCH(func, args, msg)					      \
-   if (warn()) {							      \
-      warning_func(NULL, "GL User Error: called without context: %s", #func); \
-   }
+   warn(#func);
 
 #define RETURN_DISPATCH(func, args, msg)				      \
-   if (warn()) {							      \
-      warning_func(NULL, "GL User Error: called without context: %s", #func); \
-   }									      \
-   return 0
+   return warn(#func);
 
 #define DISPATCH_TABLE_NAME __glapi_noop_table
 #define UNUSED_TABLE_NAME __unused_noop_functions
@@ -139,10 +128,7 @@ warn(void)
 
 static GLint NoOpUnused(void)
 {
-   if (warn()) {
-      warning_func(NULL, "GL User Error: calling extension function without a current context\n");
-   }
-   return 0;
+   return warn("extension function");
 }
 
 #include "glapitemp.h"




More information about the mesa-commit mailing list