[pypy-commit] stmgc default: Fix the coloring
arigo
noreply at buildbot.pypy.org
Mon May 27 16:22:13 CEST 2013
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r44:53f2a3179081
Date: 2013-05-27 16:21 +0200
http://bitbucket.org/pypy/stmgc/changeset/53f2a3179081/
Log: Fix the coloring
diff --git a/c3/Makefile b/c3/Makefile
--- a/c3/Makefile
+++ b/c3/Makefile
@@ -25,8 +25,8 @@
+make test-demo4 test-demo5 test-demo1 test-demo2 test-demo3
-H_FILES = et.h lists.h nursery.h gcpage.h stmsync.h dbgmem.h stmgc.h atomic_ops.h stmimpl.h
-C_FILES = et.c lists.c nursery.c gcpage.c stmsync.c dbgmem.c
+H_FILES = et.h lists.h nursery.h gcpage.h stmsync.h dbgmem.h fprintcolor.h stmgc.h atomic_ops.h stmimpl.h
+C_FILES = et.c lists.c nursery.c gcpage.c stmsync.c dbgmem.c fprintcolor.c
DEBUG = -g -DGC_NURSERY=0x10000 -D_GC_DEBUG=2
diff --git a/c3/fprintcolor.c b/c3/fprintcolor.c
new file mode 100644
--- /dev/null
+++ b/c3/fprintcolor.c
@@ -0,0 +1,32 @@
+#include "stmimpl.h"
+
+static __thread revision_t tcolor = 0;
+static revision_t tnextid = 0;
+
+
+int threadcolor_fprintf(FILE *stream, const char *format, ...)
+{
+ char buffer[2048];
+ va_list ap;
+ int result;
+ if (tcolor == 0) {
+ while (1) {
+ tcolor = tnextid;
+ if (bool_cas(&tnextid, tcolor, tcolor + 1))
+ break;
+ }
+ tcolor = 31 + tcolor % 7;
+ }
+ int size = (int)sprintf(buffer, "\033[%dm", (int)tcolor);
+ assert(size >= 0);
+
+ va_start(ap, format);
+ result = vsnprintf(buffer + size, 2000, format, ap);
+ assert(result >= 0);
+ va_end(ap);
+
+ strcpy(buffer + size + result, "\033[0m");
+ fputs(buffer, stream);
+
+ return result;
+}
diff --git a/c3/fprintcolor.h b/c3/fprintcolor.h
--- a/c3/fprintcolor.h
+++ b/c3/fprintcolor.h
@@ -5,33 +5,4 @@
int threadcolor_fprintf(FILE *stream, const char *format, ...)
- __attribute__((unused, format (printf, 2, 3), weak));
-
-int threadcolor_fprintf(FILE *stream, const char *format, ...)
-{
- char buffer[2048];
- va_list ap;
- int result;
- static __thread revision_t color = 0;
- if (color == 0) {
- static revision_t nextid = 0;
- while (1) {
- color = nextid;
- if (bool_cas(&nextid, color, color + 1))
- break;
- }
- color = 31 + color % 7;
- }
- int size = (int)sprintf(buffer, "\033[%dm", (int)color);
- assert(size >= 0);
-
- va_start(ap, format);
- result = vsnprintf(buffer + size, 2000, format, ap);
- assert(result >= 0);
- va_end(ap);
-
- strcpy(buffer + size + result, "\033[0m");
- fputs(buffer, stream);
-
- return result;
-}
+ __attribute__((format (printf, 2, 3)));
diff --git a/c3/test/support.py b/c3/test/support.py
--- a/c3/test/support.py
+++ b/c3/test/support.py
@@ -6,11 +6,11 @@
header_files = [os.path.join(parent_dir, _n) for _n in
"et.h lists.h nursery.h gcpage.h "
- "stmsync.h dbgmem.h "
+ "stmsync.h dbgmem.h fprintcolor.h "
"stmgc.h stmimpl.h atomic_ops.h".split()]
source_files = [os.path.join(parent_dir, _n) for _n in
"et.c lists.c nursery.c gcpage.c "
- "stmsync.c dbgmem.c".split()]
+ "stmsync.c dbgmem.c fprintcolor.c".split()]
_pycache_ = os.path.join(parent_dir, 'test', '__pycache__')
if os.path.exists(_pycache_):
More information about the pypy-commit
mailing list