src/lib/verbose.c 1.7
1.7 2010/04/01 17:31:10 markd
fixed GCC portability issues
Index: src/lib/verbose.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/lib/verbose.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -b -B -U 4 -r1.6 -r1.7
--- src/lib/verbose.c 30 Oct 2008 09:27:23 -0000 1.6
+++ src/lib/verbose.c 1 Apr 2010 17:31:10 -0000 1.7
@@ -36,21 +36,29 @@
verboseVa(verbosity, format, args);
va_end(args);
}
-void verboseTime(int verbosity, char *label, ...)
-/* Print label and how long it's been since last call. Call with
- * a NULL label to initialize. */
+static long lastTime = -1; // previous call time.
+
+void verboseTimeInit(void)
+/* Initialize or reinitialize the previous time for use by verboseTime. */
{
-static long lastTime = 0;
+lastTime = clock1000();
+}
+
+void verboseTime(int verbosity, char *label, ...)
+/* Print label and how long it's been since last call. Start time can be
+ * initialized with verboseTimeInit, otherwise the elapsed time will be
+ * zero. */
+{
+assert(label != NULL); // original version allowed this, but breaks some GCCs
+if (lastTime < 0)
+ verboseTimeInit();
long time = clock1000();
va_list args;
va_start(args, label);
-if (label != NULL)
- {
- verboseVa(verbosity, label, args);
- verbose(verbosity, ": %ld millis\n", time - lastTime);
- }
+verboseVa(verbosity, label, args);
+verbose(verbosity, ": %ld millis\n", time - lastTime);
lastTime = time;
va_end(args);
}