Mesa (master): trace: Add initializer for static variables

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Mon Apr 20 14:11:53 UTC 2009


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

Author: Jakob Bornecrantz <jakob at vmware.com>
Date:   Mon Apr 20 16:05:01 2009 +0200

trace: Add initializer for static variables

---

 src/gallium/drivers/trace/tr_dump.c   |   15 +++++++++++++--
 src/gallium/drivers/trace/tr_dump.h   |    5 +++++
 src/gallium/drivers/trace/tr_screen.c |    2 ++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 63811b7..3a1409e 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -62,6 +62,7 @@ static unsigned refcount = 0;
 static pipe_mutex call_mutex;
 static long unsigned call_no = 0;
 static boolean dumping = FALSE;
+static boolean initialized = FALSE;
 
 
 static INLINE void
@@ -227,10 +228,22 @@ trace_dump_trace_close(void)
    }
 }
 
+void trace_dump_init()
+{
+   if (initialized)
+      return;
+
+   pipe_mutex_init(call_mutex);
+   dumping = FALSE;
+   initialized = TRUE;
+}
+
 boolean trace_dump_trace_begin()
 {
    const char *filename;
 
+   assert(initialized);
+
    filename = debug_get_option("GALLIUM_TRACE", NULL);
    if(!filename)
       return FALSE;
@@ -241,8 +254,6 @@ boolean trace_dump_trace_begin()
       if(!stream)
          return FALSE;
 
-      pipe_mutex_init(call_mutex);
-
       trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
       trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
       trace_dump_writes("<trace version='0.1'>\n");
diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h
index 8b72b5c..31ac708 100644
--- a/src/gallium/drivers/trace/tr_dump.h
+++ b/src/gallium/drivers/trace/tr_dump.h
@@ -43,6 +43,11 @@ struct pipe_surface;
 struct pipe_transfer;
 
 /*
+ * Call before use.
+ */
+void trace_dump_init(void);
+
+/*
  * Low level dumping controls.
  *
  * Opening the trace file and checking if that is opened.
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 549525b..12a8535 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -840,6 +840,8 @@ trace_screen_create(struct pipe_screen *screen)
    if(!screen)
       goto error1;
 
+   trace_dump_init();
+
    if(!trace_dump_trace_begin())
       goto error1;
 




More information about the mesa-commit mailing list