diff options
author | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2010-06-27 03:03:17 +0300 |
---|---|---|
committer | M Joonas Pihlaja <jpihlaja@cc.helsinki.fi> | 2010-07-11 21:40:26 +0300 |
commit | fca8977219b857e2e61dd86ac39ae9f40086f306 (patch) | |
tree | a4c13879aa27adf0f3b1c936b973051bee2ed078 /test | |
parent | 47c35e5e86a3c99fc39afe2e13a7c92d5247ee1e (diff) |
build: Rework pthread detection.
Use two levels of pthread support: a minimal level used to
build cairo itself, and a full level to build threaded apps
which want to use cairo. The minimal level tries to use
pthread stubs from libc if possible, but falls back to the
full level if that's not possible. We use CFLAGS=-D_REENTRANT
LIBS=-lpthread to find a real pthread library since that seems
to work on every unix-like test box we can get our hands on.
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 16 | ||||
-rw-r--r-- | test/cairo-test-trace.c | 10 | ||||
-rw-r--r-- | test/cairo-test.c | 6 |
3 files changed, 13 insertions, 19 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index a66e0104..54815f73 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS=pdiff . # Then we have a collection of tests that are only run if certain # features are compiled into cairo -if HAVE_PTHREAD +if HAVE_REAL_PTHREAD test_sources += $(pthread_test_sources) endif @@ -81,8 +81,9 @@ cairo_test_suite_SOURCES = \ $(cairo_test_suite_headers) \ $(test_sources) \ cairo-test-constructors.c -cairo_test_suite_CFLAGS = $(AM_CFLAGS) +cairo_test_suite_CFLAGS = $(AM_CFLAGS) $(real_pthread_CFLAGS) cairo_test_suite_LDADD = \ + $(real_pthread_LIBS) \ $(top_builddir)/test/pdiff/libpdiff.la \ $(top_builddir)/boilerplate/libcairoboilerplate.la \ $(top_builddir)/src/libcairo.la \ @@ -95,10 +96,6 @@ if BUILD_ANY2PPM cairo_test_suite_DEPENDENCIES += \ any2ppm endif -if HAVE_PTHREAD -cairo_test_suite_CFLAGS += -pthread -cairo_test_suite_LDADD += -lpthread -endif if HAVE_SHM EXTRA_PROGRAMS += cairo-test-trace @@ -106,18 +103,15 @@ cairo_test_trace_SOURCES = \ cairo-test-trace.c \ buffer-diff.c \ buffer-diff.h -cairo_test_trace_CFLAGS = $(AM_CFLAGS) +cairo_test_trace_CFLAGS = $(AM_CFLAGS) $(real_pthread_CFLAGS) cairo_test_trace_LDADD = \ + $(real_pthread_LIBS) \ $(top_builddir)/test/pdiff/libpdiff.la \ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \ $(top_builddir)/boilerplate/libcairoboilerplate.la \ $(top_builddir)/src/libcairo.la \ $(CAIRO_LDADD) \ $(SHM_LIBS) -if HAVE_PTHREAD -cairo_test_trace_CFLAGS += -pthread -cairo_test_trace_LDADD += -lpthread -endif cairo_test_trace_DEPENDENCIES = \ $(top_builddir)/test/pdiff/libpdiff.la \ $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \ diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c index 77ee84bc..15643197 100644 --- a/test/cairo-test-trace.c +++ b/test/cairo-test-trace.c @@ -82,7 +82,7 @@ #include <sys/un.h> #include <errno.h> #include <assert.h> -#if CAIRO_HAS_PTHREAD +#if CAIRO_HAS_REAL_PTHREAD #include <pthread.h> #endif @@ -162,7 +162,7 @@ struct surface_tag { }; static const cairo_user_data_key_t surface_tag; -#if CAIRO_HAS_PTHREAD +#if CAIRO_HAS_REAL_PTHREAD #define tr_die(t) t->is_recording ? pthread_exit(NULL) : exit(1) #else #define tr_die(t) exit(1) @@ -245,7 +245,7 @@ send_recording_surface (test_runner_t *tr, int width, int height, struct context_closure *closure) { -#if CAIRO_HAS_PTHREAD +#if CAIRO_HAS_REAL_PTHREAD const struct request_image rq = { closure->id, closure->start_line, @@ -591,7 +591,7 @@ spawn_target (const char *socket_path, exit (0); } -#if CAIRO_HAS_PTHREAD +#if CAIRO_HAS_REAL_PTHREAD static void cleanup_recorder (void *arg) { @@ -1274,7 +1274,7 @@ _test_trace (test_trace_t *test, s = slaves = xcalloc (2*test->num_targets + 1, sizeof (struct slave)); -#if CAIRO_HAS_PTHREAD +#if CAIRO_HAS_REAL_PTHREAD /* set-up a recording-surface to reconstruct errors */ slave = spawn_recorder (socket_path, trace); if (slave < 0) { diff --git a/test/cairo-test.c b/test/cairo-test.c index 5b80ba13..69af6ba8 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -47,7 +47,7 @@ #if HAVE_FCFINI #include <fontconfig/fontconfig.h> #endif -#if CAIRO_HAS_PTHREAD +#if CAIRO_HAS_REAL_PTHREAD #include <pthread.h> #endif #if HAVE_SYS_STAT_H @@ -1832,7 +1832,7 @@ _cairo_test_context_run (cairo_test_context_t *ctx) return ret; } -#if CAIRO_HAS_PTHREAD +#if CAIRO_HAS_REAL_PTHREAD typedef struct _cairo_test_thread { pthread_t thread; cairo_test_context_t *ctx; @@ -1867,7 +1867,7 @@ cairo_test_expecting (const cairo_test_t *test) _cairo_test_init (&ctx, NULL, test, test->name); printf ("%s\n", test->description); -#if CAIRO_HAS_PTHREAD +#if CAIRO_HAS_REAL_PTHREAD num_threads = 0; if (getenv ("CAIRO_TEST_NUM_THREADS")) num_threads = atoi (getenv ("CAIRO_TEST_NUM_THREADS")); |