[cairo-commit] 9 commits - boilerplate/Makefile.am build/configure.ac.system build/shave.in src/cairo-image-surface.c src/cairoint.h test/any2ppm.c test/cairo-test.h test/cairo-test-private.h test/cairo-test-runner.c test/.gitignore test/invalid-matrix.c test/make-cairo-test-constructors.c test/make-cairo-test-constructors.pl test/Makefile.am test/Makefile.win32

M. Joonas Pihlaja joonas at kemper.freedesktop.org
Thu Jun 18 09:34:28 PDT 2009


 boilerplate/Makefile.am              |    2 
 build/configure.ac.system            |   16 +--
 build/shave.in                       |    2 
 src/cairo-image-surface.c            |   36 +++++---
 src/cairoint.h                       |    6 +
 test/.gitignore                      |    1 
 test/Makefile.am                     |   20 ++--
 test/Makefile.win32                  |    7 +
 test/any2ppm.c                       |   62 +++++++++++++-
 test/cairo-test-private.h            |    2 
 test/cairo-test-runner.c             |    2 
 test/cairo-test.h                    |   14 ---
 test/invalid-matrix.c                |    6 -
 test/make-cairo-test-constructors.c  |  153 +++++++++++++++++++++++++++++++++++
 test/make-cairo-test-constructors.pl |   18 ----
 15 files changed, 267 insertions(+), 80 deletions(-)

New commits:
commit d066154e62d6b4ecad15e0eef431aa2f4a56fecb
Author: Jeff Muizelaar <jeff at infidigm.net>
Date:   Tue Jun 16 15:55:53 2009 -0400

    Factor out _cairo_image_surface_span_render_row()
    
    This allows other backends use the same function for rendering rows.
    More specifically, I intend to use this with the win32-backend.

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 8c9df5a..6bbf80c 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -1235,27 +1235,27 @@ typedef struct _cairo_image_surface_span_renderer {
     cairo_composite_rectangles_t composite_rectangles;
 } cairo_image_surface_span_renderer_t;
 
-static cairo_status_t
-_cairo_image_surface_span_renderer_render_row (
-    void				*abstract_renderer,
-    int					 y,
-    const cairo_half_open_span_t	*spans,
-    unsigned				 num_spans)
+void
+_cairo_image_surface_span_render_row (
+    int                                  y,
+    const cairo_half_open_span_t        *spans,
+    unsigned                             num_spans,
+    cairo_image_surface_t               *mask,
+    const cairo_composite_rectangles_t  *rects)
 {
-    cairo_image_surface_span_renderer_t *renderer = abstract_renderer;
-    int xmin = renderer->composite_rectangles.mask.x;
-    int xmax = xmin + renderer->composite_rectangles.width;
+    int xmin = rects->mask.x;
+    int xmax = xmin + rects->width;
     uint8_t *row;
     int prev_x = xmin;
     int prev_alpha = 0;
     unsigned i;
 
     /* Make sure we're within y-range. */
-    y -= renderer->composite_rectangles.mask.y;
-    if (y < 0 || y >= renderer->composite_rectangles.height)
-	return CAIRO_STATUS_SUCCESS;
+    y -= rects->mask.y;
+    if (y < 0 || y >= rects->height)
+	return;
 
-    row = (uint8_t*)(renderer->mask->data) + y*(size_t)renderer->mask->stride - xmin;
+    row = (uint8_t*)(mask->data) + y*(size_t)mask->stride - xmin;
 
     /* Find the first span within x-range. */
     for (i=0; i < num_spans && spans[i].x < xmin; i++) {}
@@ -1289,7 +1289,17 @@ _cairo_image_surface_span_renderer_render_row (
     if (prev_alpha != 0 && prev_x < xmax) {
 	memset(row + prev_x, prev_alpha, xmax - prev_x);
     }
+}
 
+static cairo_status_t
+_cairo_image_surface_span_renderer_render_row (
+    void				*abstract_renderer,
+    int					 y,
+    const cairo_half_open_span_t	*spans,
+    unsigned				 num_spans)
+{
+    cairo_image_surface_span_renderer_t *renderer = abstract_renderer;
+    _cairo_image_surface_span_render_row (y, spans, num_spans, renderer->mask, &renderer->composite_rectangles);
     return CAIRO_STATUS_SUCCESS;
 }
 
diff --git a/src/cairoint.h b/src/cairoint.h
index 0bb4d02..f5968f3 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -2209,6 +2209,12 @@ _cairo_image_surface_set_clip_region (void *abstract_surface,
 cairo_private cairo_image_surface_t *
 _cairo_image_surface_coerce (cairo_image_surface_t	*surface,
 			     cairo_format_t		 format);
+cairo_private void
+_cairo_image_surface_span_render_row (int				 y,
+				      const cairo_half_open_span_t	 *spans,
+				      unsigned				 num_spans,
+				      cairo_image_surface_t              *mask,
+				      const cairo_composite_rectangles_t *rects);
 
 cairo_private cairo_image_transparency_t
 _cairo_image_analyze_transparency (cairo_image_surface_t      *image);
commit fd142d0a6e21c492624ca8bc5019d89b0d7c5457
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Thu Jun 18 16:14:50 2009 +0100

    [shave] Robuster usage of the test shell built-in.
    
    Solaris 9 confuses shave, resulting in an empty variable.
    This patch papers over the resulting build failure from
    the test shell built-in being called with an empty argument
    which was unquoted.

diff --git a/build/shave.in b/build/shave.in
index cedccd4..a23ec29 100644
--- a/build/shave.in
+++ b/build/shave.in
@@ -69,7 +69,7 @@ lt_unmangle "$lt_output"
 output=$last_result
 
 if test -z $V; then
-    if test $output = "/dev/null"; then
+    if test "$output" = "/dev/null"; then
 	pass_through=1
     fi
     if test $pass_through -eq 0; then
commit 9ecee571c12e4d1645d9db2929280c9b35b1aad4
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Thu Jun 18 16:09:31 2009 +0100

    [test/build] Don't test Freetype font stuff without Fontconfig.
    
    Most Freetype hitting tests require Fontconfig to find
    them some fonts.

diff --git a/test/Makefile.am b/test/Makefile.am
index d6b2121..2ff45f5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -13,8 +13,10 @@ test_sources += $(pthread_test_sources)
 endif
 
 if CAIRO_HAS_FT_FONT
+if CAIRO_HAS_FC_FONT
 test_sources += $(ft_font_test_sources)
 endif
+endif
 
 # Need to add quartz-surface-source
 if CAIRO_HAS_QUARTZ_SURFACE
commit 742b1ad4b069653a99fc6bd4510f2b6abb6abf95
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun May 24 23:41:28 2009 +0100

    [test] Fix checking of the fenv.h include.
    
    This adds a configure check for fenv.h and makes
    invalid-matrix.c check for it with HAVE_FENV_H instead
    of HAVE_FEDISABLEEXCEPT -- turns out Solaris doesn't
    have fedisableexcept(), but it does have feclearexcept().
    
    The same issue appears on OSX and was fixed in
    ab86662ab499e1f29c0f8c4248771e730c281e3f. This patch
    adds some configure magic.

diff --git a/build/configure.ac.system b/build/configure.ac.system
index 46909ad..07d30c2 100644
--- a/build/configure.ac.system
+++ b/build/configure.ac.system
@@ -88,7 +88,7 @@ AC_CHECK_HEADER(fenv.h,
 	[AC_CHECK_FUNCS(feenableexcept fedisableexcept feclearexcept)])
 
 dnl check for misc headers and functions
-AC_CHECK_HEADERS([libgen.h byteswap.h signal.h setjmp.h])
+AC_CHECK_HEADERS([libgen.h byteswap.h signal.h setjmp.h fenv.h])
 AC_CHECK_FUNCS([vasnprintf link ctime_r drand48 flockfile ffs])
 
 dnl check for win32 headers (this detects mingw as well)
diff --git a/test/invalid-matrix.c b/test/invalid-matrix.c
index 0d7e69c..6cfaedf 100644
--- a/test/invalid-matrix.c
+++ b/test/invalid-matrix.c
@@ -33,8 +33,8 @@
 #define INFINITY HUGE_VAL
 #endif
 
-#if HAVE_FEDISABLEEXCEPT || HAVE_FECLEAREXCEPT
-#include <fenv.h>
+#if HAVE_FENV_H
+# include <fenv.h>
 #endif
 
 static cairo_test_status_t
commit 75f1d11d93236b19d06515b8ed2baf612b0767ab
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun May 24 21:28:04 2009 +0300

    [test] Fallback to HUGE_VAL in place of INFINITY in invalid-matrix.c.
    
    GCC 3.4.3 on OpenSolaris does not recognise INFINITY.  Use HUGE_VAL
    instead for every compiler instead of just MSVC.

diff --git a/test/invalid-matrix.c b/test/invalid-matrix.c
index 2e4b665..0d7e69c 100644
--- a/test/invalid-matrix.c
+++ b/test/invalid-matrix.c
@@ -29,7 +29,7 @@
 
 #include "cairo-test.h"
 
-#if !defined(INFINITY) && defined(_MSC_VER)
+#if !defined(INFINITY)
 #define INFINITY HUGE_VAL
 #endif
 
commit d1994d1ac292cbc896cffd24094ddfa5f2b1e8a9
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun May 24 23:46:13 2009 +0300

    [test/any2ppm] Daemonize without BSD's daemon().
    
    Solaris libc doesn't provide daemon() so implement
    any2ppm daemon's detaching without it.

diff --git a/test/Makefile.am b/test/Makefile.am
index 143b2e5..d6b2121 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1188,7 +1188,7 @@ check_PROGRAMS += any2ppm
 any2ppm_CFLAGS = $(AM_CFLAGS) $(POPPLER_CFLAGS) $(LIBRSVG_CFLAGS) $(LIBSPECTRE_CFLAGS)
 # add LDADD, so poppler/librsvg uses "our" cairo
 any2ppm_LDFLAGS = $(AM_LDFLAGS) $(CAIRO_TEST_UNDEFINED_LDFLAGS)
-any2ppm_LDADD = $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la $(top_builddir)/src/libcairo.la $(CAIRO_LDADD) $(POPPLER_LIBS) $(LIBRSVG_LIBS) $(LIBSPECTRE_LIBS)
+any2ppm_LDADD = $(top_builddir)/util/cairo-script/libcairo-script-interpreter.la $(top_builddir)/src/libcairo.la $(CAIRO_LDADD) $(CAIROBOILERPLATE_LIBS) $(POPPLER_LIBS) $(LIBRSVG_LIBS) $(LIBSPECTRE_LIBS)
 endif
 
 if CAIRO_CAN_TEST_PDF_SURFACE
diff --git a/test/any2ppm.c b/test/any2ppm.c
index 1327581..4800b54 100644
--- a/test/any2ppm.c
+++ b/test/any2ppm.c
@@ -89,11 +89,7 @@
 #define SOCKET_PATH "./.any2ppm"
 #define TIMEOUT 60000 /* 60 seconds */
 
-#if _BSD_SOURCE || (_XOPEN_SOURCE && _XOPEN_SOURCE < 500)
 #define CAN_RUN_AS_DAEMON 1
-#else
-#define CAN_RUN_AS_DAEMON 0
-#endif
 #endif
 
 #define ARRAY_LENGTH(A) (sizeof (A) / sizeof (A[0]))
@@ -662,6 +658,62 @@ write_pid_file (void)
     return ret;
 }
 
+static int
+open_devnull_to_fd (int want_fd, int flags)
+{
+    int error;
+    int got_fd;
+
+    close (want_fd);
+
+    got_fd = open("/dev/null", flags | O_CREAT, 0700);
+    if (got_fd == -1)
+        return -1;
+
+    error = dup2 (got_fd, want_fd);
+    close (got_fd);
+
+    return error;
+}
+
+static int
+daemonize (void)
+{
+    void (*oldhup) (int);
+
+    /* Let the parent go. */
+    switch (fork ()) {
+    case -1: return -1;
+    case 0: break;
+    default: _exit (0);
+    }
+
+    /* Become session leader. */
+    if (setsid () == -1)
+	return -1;
+
+    /* Refork to yield session leadership. */
+    oldhup = signal (SIGHUP, SIG_IGN);
+
+    switch (fork ()) {		/* refork to yield session leadership. */
+    case -1: return -1;
+    case 0: break;
+    default: _exit (0);
+    }
+
+    signal (SIGHUP, oldhup);
+
+    /* Establish stdio. */
+    if (open_devnull_to_fd (0, O_RDONLY) == -1)
+	return -1;
+    if (open_devnull_to_fd (1, O_WRONLY | O_APPEND) == -1)
+	return -1;
+    if (dup2 (1, 2) == -1)
+	return -1;
+
+    return 0;
+}
+
 static const char *
 any2ppm_daemon (void)
 {
@@ -707,7 +759,7 @@ any2ppm_daemon (void)
     }
 
     /* ready for client connection - detach from parent/terminal */
-    if (getenv ("ANY2PPM_NODAEMON") == NULL && daemon (1, 0) == -1) {
+    if (getenv ("ANY2PPM_NODAEMON") == NULL && daemonize () == -1) {
 	close (sk);
 	return "unable to detach from parent";
     }
commit aafff0b9528952fbbe9d04a70bf8c76ee701743f
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun May 24 23:50:03 2009 +0300

    [boilerplate] Check for connect() in libsocket.
    
    Solaris requires -lsocket to be able to talk to
    the any2ppm daemon over unix domain sockets.

diff --git a/boilerplate/Makefile.am b/boilerplate/Makefile.am
index 980bae4..239af56 100644
--- a/boilerplate/Makefile.am
+++ b/boilerplate/Makefile.am
@@ -45,6 +45,8 @@ if CAIRO_HAS_WIN32_SURFACE
 libcairoboilerplate_la_LIBADD += -lwinspool
 endif
 
+libcairoboilerplate_la_LIBADD += $(CAIROBOILERPLATE_LIBS)
+
 test: check
 
 if CROSS_COMPILING
diff --git a/build/configure.ac.system b/build/configure.ac.system
index 01a6a0a..46909ad 100644
--- a/build/configure.ac.system
+++ b/build/configure.ac.system
@@ -56,6 +56,10 @@ AC_CHECK_LIB(rt, shm_open, [
 AM_CONDITIONAL(HAVE_SHM, test "x$has_shm_open" = "xyes")
 AC_SUBST(SHM_LIBS)
 
+AC_CHECK_LIB(socket, connect, [SOCKET_LIBS=-lsocket], [SOCKET_LIBS=])
+CAIROBOILERPLATE_LIBS=$SOCKET_LIBS
+AC_SUBST(CAIROBOILERPLATE_LIBS)
+
 dnl ====================================================================
 dnl Header/function checks
 dnl ====================================================================
commit c4c06931690226e12622a957bbb6d652134f78b0
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun May 24 16:14:33 2009 +0300

    [test] Make test constructors without perl.
    
    Remove the dependency on perl when building the test suite
    by replacing the script which makes cairo-test-constructors.c
    with a C program.

diff --git a/test/.gitignore b/test/.gitignore
index 24ec7a6..867db42 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -36,3 +36,4 @@ valgrind-log
 *.o
 *~
 .*.sw?
+make-cairo-test-constructors
diff --git a/test/Makefile.am b/test/Makefile.am
index d651884..143b2e5 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -67,8 +67,11 @@ test_sources += $(test)
 
 TESTS += cairo-test-suite$(EXEEXT)
 
-cairo-test-constructors.c: Makefile $(test_sources) make-cairo-test-constructors.pl
-	@(cd $(srcdir) && ./make-cairo-test-constructors.pl $(test_sources)) > $@
+make-cairo-test-constructors$(EXEEXT): make-cairo-test-constructors.c
+	$(CC) -o $@ make-cairo-test-constructors.c
+
+cairo-test-constructors.c: Makefile $(test_sources) make-cairo-test-constructors$(EXEEXT)
+	(cd $(srcdir) && ./make-cairo-test-constructors$(EXEEXT) $(test_sources)) > $@
 
 cairo_test_suite_SOURCES = 		\
 	$(cairo_test_suite_sources)	\
@@ -109,9 +112,9 @@ cairo_test_trace_DEPENDENCIES = \
 endif
 
 BUILT_SOURCES += cairo-test-constructors.c
-noinst_SCRIPTS = make-cairo-test-constructors.pl
 EXTRA_DIST += $(BUILT_SOURCES) $(noinst_SCRIPTS) COPYING
 CLEANFILES += $(BUILT_SOURCES)
+CLEANFILES += make-cairo-test-constructors
 
 # All tests which have a reference image go here.
 REFERENCE_IMAGES = \
diff --git a/test/Makefile.win32 b/test/Makefile.win32
index f6a936e..b45617b 100644
--- a/test/Makefile.win32
+++ b/test/Makefile.win32
@@ -14,8 +14,11 @@ TESTCORE_SOURCES = \
 
 all: cairo-test-suite.exe
 
-cairo-test-constructors.c: $(test_sources)
-	./make-cairo-test-constructors.pl $(test_sources) > $@
+make-cairo-test-constructors.exe: $(CFG)/make-cairo-test-constructors.obj
+	$(CC) $(OPT) $(MS_MDFLAGS) $(CFG)/make-cairo-test-constructors.obj -Fe"$@" -link $(LDFLAGS) user32.lib /NODEFAULTLIB:library
+
+cairo-test-constructors.c: $(test_sources) make-cairo-test-constructors.exe
+	./make-cairo-test-constructors.exe $(test_sources) > $@
 
 SOURCES = $(cairo_test_suite_sources) $(test_sources) cairo-test-constructors.c
 
diff --git a/test/make-cairo-test-constructors.c b/test/make-cairo-test-constructors.c
new file mode 100644
index 0000000..1a8bd55
--- /dev/null
+++ b/test/make-cairo-test-constructors.c
@@ -0,0 +1,153 @@
+/*
+ * Copyright © 2009 Joonas Pihlaja
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+/* Usage:
+ *   ./make-cairo-test-constructors [tests.c...] >cairo-test-constructors.c
+ *
+ * Parses invocations of the CAIRO_TEST macro from the source files
+ * given on the command line, gathers names of tests, and outputs a C
+ * file with one function _cairo_test_runner_register_tests() which
+ * calls the functions _register_<testname>() in reverse order.
+ */
+/* Keep this file ANSI compliant without any special needs. */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+struct name {
+    struct name *next;
+    char        *name;
+};
+
+static struct name *head = NULL;
+
+static void *
+xmalloc (size_t n)
+{
+    void *bytes = malloc(n);
+    if (!bytes) {
+        fprintf (stderr, "Out of memory\n");
+        exit(2);
+    }
+    return bytes;
+}
+
+static void
+add_name (const char *name)
+{
+    struct name *node = xmalloc (sizeof (struct name));
+
+    node->name = xmalloc (strlen(name)+1);
+    strcpy (node->name, name);
+
+    node->next = head;
+    head = node;
+}
+
+static int
+scan_file (const char   *filename,
+           FILE         *fp)
+{
+    int line_num = 0;
+    char linebuf[1024];
+    int fail = 0;
+
+    while (fgets (linebuf, sizeof (linebuf)-1, fp)) {
+        char *macro;
+        char *name;
+        size_t length;
+
+        line_num++;
+        linebuf[sizeof (linebuf)-1] = 0;
+
+        macro = strstr (linebuf, "CAIRO_TEST");
+        if (!macro)
+            continue;
+        macro += strlen ("CAIRO_TEST");
+
+        length = strspn (macro, " (");
+        if (length == 0)
+            continue;
+        name = macro + length;
+
+        length = strspn (name,
+                         "_"
+                         "abcdefghijklmnopqrstuvwxyz"
+                         "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                         "0123456789");
+        name[length] = 0;
+
+        if (length == 0) {
+            fprintf (stderr, "%s:%d: CAIRO_TEST invocation "
+                     "can't be parsed by make-cairo-test-constructors.c\n",
+                     filename, line_num);
+            fail = 1;
+            continue;
+        }
+
+        add_name (name);
+    }
+
+    return fail;
+}
+
+int
+main (int argc, char **argv)
+{
+    int i;
+    int fail = 0;
+    struct name *node;
+
+    for (i=1; i<argc; i++) {
+        FILE *fp = fopen (argv[i], "r");
+        if (fp) {
+            fail |= scan_file (argv[i], fp);
+            fclose (fp);
+        }
+    }
+    if (fail)
+        exit(1);
+
+    puts ("/* WARNING: Autogenerated file - "
+          "see make-cairo-test-constructors.c! */");
+    puts ("");
+    puts ("#include \"cairo-test-private.h\"");
+    puts ("");
+
+    for (node = head; node; node = node->next) {
+        printf("extern void _register_%s (void);\n",
+               node->name);
+    }
+    puts("");
+
+    puts ("void _cairo_test_runner_register_tests (void);");
+    puts("");
+
+    puts ("void");
+    puts ("_cairo_test_runner_register_tests (void)");
+    puts ("{");
+    for (node = head; node; node = node->next) {
+        printf("    _register_%s ();\n", node->name);
+    }
+    puts ("}");
+
+    return 0;
+}
diff --git a/test/make-cairo-test-constructors.pl b/test/make-cairo-test-constructors.pl
deleted file mode 100755
index 5e77175..0000000
--- a/test/make-cairo-test-constructors.pl
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/usr/bin/perl -w
-
-while (<>) {
-    next unless /CAIRO_TEST \((.*),/; # XXX Parse multi-line macro
-    push @names, $1;
-}
-
-print <<EOD
-/* WARNING: Autogenerated file - see make-cairo-test-constructors.pl! */
-
-#include "cairo-test-private.h"
-
-EOD
-;
-print "extern void _register_$_ (void);\n" foreach (@names);
-print "\nvoid\n_cairo_test_runner_register_tests (void)\n{\n";
-print "    _register_$_ ();\n" foreach (reverse @names);
-print "}\n";
commit cdd27a8d4cc3486867cff4ce81bb4e064eb74d58
Author: M Joonas Pihlaja <jpihlaja at cc.helsinki.fi>
Date:   Sun May 24 16:19:31 2009 +0300

    [test] Never use gcc __attribute__ magic for constructors.
    
    The configure test for __attribute__((constructor)) succeeds when
    compiling with Sun Studio 12 on OpenSolaris but the attribute
    is just ignored and has no actual effect.  This causes the test
    suite to not run any tests at all.  With this patch we revert to
    always using make-cairo-test-constructors.pl.

diff --git a/build/configure.ac.system b/build/configure.ac.system
index 35fd28d..01a6a0a 100644
--- a/build/configure.ac.system
+++ b/build/configure.ac.system
@@ -135,15 +135,5 @@ dnl ===========================================================================
 dnl
 dnl Test for the tools required for building one big test binary
 dnl
-AC_MSG_CHECKING([for the constructor attribute])
-cairo_has_constructor_attribute="no"
-AC_TRY_LINK([static void __attribute__((constructor)) constructor(void) {}], [],
-    cairo_has_constructor_attribute="yes"
-  )
-AC_MSG_RESULT([$cairo_has_constructor_attribute])
-if test "x$cairo_has_constructor_attribute" = "xyes"; then
-    AC_DEFINE(CAIRO_HAS_CONSTRUCTOR_ATTRIBUTE, 1, [Define to 1 if your compiler supports __attribute__(constructor)])
-fi
-AM_CONDITIONAL(CAIRO_HAS_CONSTRUCTOR_ATTRIBUTE, test "x$cairo_has_constructor_attribute" = "xyes")
 
 AC_CHECK_FUNCS(fork waitpid raise)
diff --git a/test/Makefile.am b/test/Makefile.am
index 155077d..d651884 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -73,11 +73,8 @@ cairo-test-constructors.c: Makefile $(test_sources) make-cairo-test-constructors
 cairo_test_suite_SOURCES = 		\
 	$(cairo_test_suite_sources)	\
 	$(cairo_test_suite_headers)	\
-	$(test_sources)
-if CAIRO_HAS_CONSTRUCTOR_ATTRIBUTE
-else
-cairo_test_suite_SOURCES += cairo-test-constructors.c
-endif
+	$(test_sources)			\
+	cairo-test-constructors.c
 cairo_test_suite_LDADD = 					\
 	$(top_builddir)/test/pdiff/libpdiff.la 			\
         $(top_builddir)/boilerplate/libcairoboilerplate.la	\
diff --git a/test/cairo-test-private.h b/test/cairo-test-private.h
index 03c7a2b..8c84149 100644
--- a/test/cairo-test-private.h
+++ b/test/cairo-test-private.h
@@ -64,10 +64,8 @@ cairo_test (const cairo_test_t *test);
 void
 cairo_test_fini (cairo_test_context_t *ctx);
 
-#if ! CAIRO_HAS_CONSTRUCTOR_ATTRIBUTE
 void
 _cairo_test_runner_register_tests (void);
-#endif
 
 CAIRO_END_DECLS
 
diff --git a/test/cairo-test-runner.c b/test/cairo-test-runner.c
index 7476d1e..2eb2986 100644
--- a/test/cairo-test-runner.c
+++ b/test/cairo-test-runner.c
@@ -599,9 +599,7 @@ main (int argc, char **argv)
     _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
 #endif
 
-#ifndef CAIRO_HAS_CONSTRUCTOR_ATTRIBUTE
     _cairo_test_runner_register_tests ();
-#endif
 
     memset (&runner, 0, sizeof (runner));
     runner.num_device_offsets = 1;
diff --git a/test/cairo-test.h b/test/cairo-test.h
index afdc888..b16f340 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -133,19 +133,6 @@ struct _cairo_test {
  * one backend that is tested and if all tested backend pass according
  * to the four criteria above.
  */
-#if CAIRO_HAS_CONSTRUCTOR_ATTRIBUTE
-#define CAIRO_TEST(name, description, keywords, requirements, width, height, preamble, draw) \
-static void __attribute__((constructor)) _register_##name (void) \
-{\
-    static const cairo_test_t test = { \
-	#name, description, \
-	keywords, requirements, \
-	width, height, \
-	preamble, draw \
-    }; \
-    cairo_test_register (&test); \
-}
-#else
 #define CAIRO_TEST(name, description, keywords, requirements, width, height, preamble, draw) \
 void _register_##name (void); \
 void _register_##name (void) { \
@@ -157,7 +144,6 @@ void _register_##name (void) { \
     }; \
     cairo_test_register (&test); \
 }
-#endif
 
 void
 cairo_test_register (const cairo_test_t *test);


More information about the cairo-commit mailing list