[cogl/cogl-1.10] Fix disabling debugging



commit 0316346014d6d61f4a6e9602d343560264725e12
Author: Neil Roberts <neil linux intel com>
Date:   Thu May 17 14:51:43 2012 +0100

    Fix disabling debugging
    
    When --disable-debug is passed to the configure script it was actually
    still defining COGL_ENABLE_DEBUG so very little would end up being
    disabled. If COGL_ENABLE_DEBUG actually got defined it would also fail
    to compile because _cogl_debug_instances and COGL_DEBUG_N_LONGS from
    cogl-debug.h were only defined if debugging is enabled but they are
    used regardless.
    
    This patch also makes it so that the _COGL_RETURN_IF_FAIL family of
    macros that are used when glib support is disabled are now disabled if
    debugging is disabled. When the glib macros are used they are already
    disabled because we additionally define G_DISABLE_CHECKS.
    
    'COGL_HANDLE_DEBUG' has been removed from the list of defines passed
    when debugging is enabled because CoglHandle has already been removed
    and it is not used anywhere in the code.
    
    Reviewed-by: Robert Bragg <robert linux intel com>
    
    (cherry picked from commit 9811a0101c9cbb4ab95c55a2b41fd10ff4c77d9f)

 cogl/cogl-debug.h       |    7 +++----
 cogl/cogl-framebuffer.c |    2 ++
 cogl/cogl-util.h        |   19 +++++++++++++++----
 configure.ac            |    4 ++--
 4 files changed, 22 insertions(+), 10 deletions(-)
---
diff --git a/cogl/cogl-debug.h b/cogl/cogl-debug.h
index 83534c8..67968d6 100644
--- a/cogl/cogl-debug.h
+++ b/cogl/cogl-debug.h
@@ -71,17 +71,16 @@ typedef enum {
   COGL_DEBUG_N_FLAGS
 } CoglDebugFlags;
 
-#ifdef COGL_ENABLE_DEBUG
-
+extern GHashTable *_cogl_debug_instances;
 #define COGL_DEBUG_N_LONGS COGL_FLAGS_N_LONGS_FOR_SIZE (COGL_DEBUG_N_FLAGS)
 
+#ifdef COGL_ENABLE_DEBUG
+
 /* _cogl_debug_flags currently needs to exported outside of the shared
    library for cogl-pango. The special COGL_EXPORT macro is needed to
    get this to work when building with MSVC */
 COGL_EXPORT extern unsigned long _cogl_debug_flags[COGL_DEBUG_N_LONGS];
 
-extern GHashTable *_cogl_debug_instances;
-
 #define COGL_DEBUG_ENABLED(flag) \
   COGL_FLAGS_GET (_cogl_debug_flags, flag)
 
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c
index e9bde6a..1bbff13 100644
--- a/cogl/cogl-framebuffer.c
+++ b/cogl/cogl-framebuffer.c
@@ -125,7 +125,9 @@ typedef struct _CoglFramebufferStackEntry
 
 extern CoglObjectClass _cogl_onscreen_class;
 
+#ifdef COGL_ENABLE_DEBUG
 static CoglUserDataKey wire_pipeline_key;
+#endif
 
 static void _cogl_offscreen_free (CoglOffscreen *offscreen);
 
diff --git a/cogl/cogl-util.h b/cogl/cogl-util.h
index d657c76..63723e9 100644
--- a/cogl/cogl-util.h
+++ b/cogl/cogl-util.h
@@ -170,7 +170,18 @@ _cogl_util_popcountl (unsigned long num)
 #define _COGL_RETURN_IF_FAIL(EXPR) g_return_if_fail(EXPR)
 #define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) g_return_val_if_fail(EXPR, VAL)
 #else
-#define _COGL_RETURN_IF_FAIL(EXPR) do {	                            \
+#if COGL_ENABLE_DEBUG
+#define _COGL_RETURN_START do {
+#define _COGL_RETURN_END } while (0)
+#else /* COGL_ENABLE_DEBUG */
+/* If debugging is disabled then we don't actually want to do the
+ * check but we still want the code for the expression to be generated
+ * so that it won't give loads of warnings about unused variables.
+ * Therefore we just surround the block with if(0) */
+#define _COGL_RETURN_START do { if (0) {
+#define _COGL_RETURN_END } } while (0)
+#endif /* COGL_ENABLE_DEBUG */
+#define _COGL_RETURN_IF_FAIL(EXPR) _COGL_RETURN_START {             \
    if (!(EXPR))						            \
      {							            \
        fprintf (stderr, "file %s: line %d: assertion `%s' failed",  \
@@ -179,8 +190,8 @@ _cogl_util_popcountl (unsigned long num)
                 #EXPR);						    \
        return;						            \
      };                                                             \
-  } while(0)
-#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) do {	                    \
+  } _COGL_RETURN_END
+#define _COGL_RETURN_VAL_IF_FAIL(EXPR, VAL) _COGL_RETURN_START {    \
    if (!(EXPR))						            \
      {							            \
        fprintf (stderr, "file %s: line %d: assertion `%s' failed",  \
@@ -189,7 +200,7 @@ _cogl_util_popcountl (unsigned long num)
                 #EXPR);						    \
        return (VAL);						    \
      };                                                             \
-  } while(0)
+  } _COGL_RETURN_END
 #endif /* COGL_HAS_GLIB_SUPPORT */
 
 /* Match a CoglPixelFormat according to channel masks, color depth,
diff --git a/configure.ac b/configure.ac
index ecf3d49..1270d75 100644
--- a/configure.ac
+++ b/configure.ac
@@ -181,11 +181,11 @@ AS_CASE(
   [yes],
   [
     test "$cflags_set" = set || CFLAGS="$CFLAGS -g -O0"
-    COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_HANDLE_DEBUG -DCOGL_ENABLE_DEBUG"
+    COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DCOGL_GL_DEBUG -DCOGL_OBJECT_DEBUG -DCOGL_ENABLE_DEBUG"
   ],
   [no],
   [
-    COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DCOGL_ENABLE_DEBUG -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
+    COGL_EXTRA_CFLAGS="$COGL_EXTRA_CFLAGS -DG_DISABLE_CHECKS -DG_DISABLE_CAST_CHECKS"
   ],
   [AC_MSG_ERROR([Unknown argument for --enable-debug])]
 )



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]