[cairo-commit] 6 commits - configure.ac Makefile.win32 perf/cairo-perf-os2.c perf/cairo-perf-posix.c perf/cairo-perf-trace.c perf/cairo-perf-win32.c perf/dirent-win32.h perf/Makefile.am perf/Makefile.sources perf/Makefile.win32 perf/micro src/cairo.c src/cairo-compiler-private.h src/cairo-error.c src/Makefile.sources test/Makefile.win32 util/cairo-script

Andrea Canciani ranma42 at kemper.freedesktop.org
Fri Jun 24 05:17:40 PDT 2011


 Makefile.win32                             |    3 
 configure.ac                               |    1 
 perf/Makefile.am                           |  110 +++++++----------------------
 perf/Makefile.sources                      |   35 +++++++++
 perf/Makefile.win32                        |  104 ++++++++++++++++++---------
 perf/cairo-perf-os2.c                      |    8 +-
 perf/cairo-perf-posix.c                    |    8 +-
 perf/cairo-perf-trace.c                    |   59 +++++++++++----
 perf/cairo-perf-win32.c                    |    8 +-
 perf/dirent-win32.h                        |  102 ++++++++++++++++++++++++++
 perf/micro/Makefile.am                     |   16 ++++
 perf/micro/Makefile.sources                |   35 +++++++++
 perf/micro/Makefile.win32                  |   12 +++
 perf/micro/pythagoras-tree.c               |    1 
 src/Makefile.sources                       |    1 
 src/cairo-compiler-private.h               |    4 -
 src/cairo-error.c                          |   69 ++++++++++++++++++
 src/cairo.c                                |   26 ------
 test/Makefile.win32                        |   14 +--
 util/cairo-script/Makefile.am              |   12 +--
 util/cairo-script/Makefile.sources         |   13 +++
 util/cairo-script/Makefile.win32           |   10 ++
 util/cairo-script/cairo-script-operators.c |    6 +
 util/cairo-script/cairo-script-private.h   |    5 +
 util/cairo-script/cairo-script-scanner.c   |    1 
 25 files changed, 483 insertions(+), 180 deletions(-)

New commits:
commit 463a8b67a3e2dfacede3f4e2ed1f65afc8ae5662
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Tue Jun 21 18:12:29 2011 +0200

    perf: Fix build on win32
    
    The performance tools build system for Win32 hasn't been maintained
    for some time.  The makefiles are now structured as in other
    directories (Makefile.sources used by both Makefile.am and
    Makefile.win32) and some additional code hides os-specific parts.

diff --git a/Makefile.win32 b/Makefile.win32
index 770df70..f475246 100644
--- a/Makefile.win32
+++ b/Makefile.win32
@@ -9,5 +9,8 @@ all: cairo
 cairo: inform
 	@$(MAKE) -C src -f Makefile.win32
 
+perf: inform
+	@$(MAKE) -C perf -f Makefile.win32 perf
+
 test: inform
 	@$(MAKE) -C test -f Makefile.win32 test
diff --git a/configure.ac b/configure.ac
index 5d72c24..6687791 100644
--- a/configure.ac
+++ b/configure.ac
@@ -815,6 +815,7 @@ src/Makefile
 test/Makefile
 test/pdiff/Makefile
 perf/Makefile
+perf/micro/Makefile
 util/Makefile
 util/cairo-fdr/Makefile
 util/cairo-gobject/Makefile
diff --git a/perf/Makefile.am b/perf/Makefile.am
index 1e1bf5b..d01ea06 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -1,5 +1,7 @@
 include $(top_srcdir)/build/Makefile.am.common
 
+include $(top_srcdir)/perf/Makefile.sources
+
 AM_CPPFLAGS =					\
 	-I$(srcdir)				\
 	-I$(top_srcdir)/boilerplate		\
@@ -22,105 +24,46 @@ EXTRA_LTLIBRARIES += libcairoperf.la
 
 LDADD = libcairoperf.la \
 	$(top_builddir)/boilerplate/libcairoboilerplate.la \
-	$(top_builddir)/src/libcairo.la \
-	$(CAIROPERF_LIBS)
-
-cairo_perf_micro_SOURCES =		\
-	cairo-perf-micro.c	\
-	cairo-perf.h		\
-	micro/cairo-perf-cover.c	\
-	micro/box-outline.c		\
-	micro/composite-checker.c	\
-	micro/fill.c			\
-	micro/long-lines.c		\
-	micro/mosaic.c		\
-	micro/mosaic.h		\
-	micro/paint.c			\
-	micro/paint-with-alpha.c	\
-	micro/mask.c			\
-	micro/pattern_create_radial.c \
-	micro/rectangles.c		\
-	micro/rounded-rectangles.c	\
-	micro/stroke.c		\
-	micro/subimage_copy.c		\
-	micro/tessellate.c		\
-	micro/text.c			\
-	micro/glyphs.c		\
-	micro/twin.c			\
-	micro/unaligned-clip.c	\
-	micro/wave.c			\
-	micro/world-map.c		\
-	micro/world-map.h		\
-	micro/zrusin.c		\
-	micro/zrusin-another.h	\
-	micro/long-dashed-lines.c	\
-	micro/dragon.c		\
-	micro/pythagoras-tree.c	\
-	micro/intersections.c		\
-	micro/spiral.c
-
-if CAIRO_HAS_WIN32_SURFACE
-cairo_perf_micro_SOURCES += cairo-perf-win32.c
-else
-if CAIRO_HAS_OS2_SURFACE
-cairo_perf_micro_SOURCES += cairo-perf-os2.c
-else
-cairo_perf_micro_SOURCES += cairo-perf-posix.c
-endif
-endif
-cairo_perf_micro_LDADD = $(LDADD)
+	$(top_builddir)/src/libcairo.la
+
+cairo_perf_micro_SOURCES = $(cairo_perf_micro_sources)
+cairo_perf_micro_LDADD = \
+	$(top_builddir)/perf/micro/libcairo-perf-micro.la \
+	$(LDADD)
 cairo_perf_micro_DEPENDENCIES = \
-        $(top_builddir)/boilerplate/libcairoboilerplate.la	\
-	$(top_builddir)/src/libcairo.la \
-	libcairoperf.la
+	$(top_builddir)/perf/micro/libcairo-perf-micro.la \
+	$(LDADD)
 
 libcairoperf_la_SOURCES = \
-	cairo-perf-report.c	\
-	cairo-stats.c		\
-	cairo-stats.h
-
-cairo_perf_trace_SOURCES =		\
-	cairo-perf-trace.c		\
-	../src/cairo-error.c		\
-	../src/cairo-hash.c
-if CAIRO_HAS_WIN32_SURFACE
-cairo_perf_trace_SOURCES += cairo-perf-win32.c
-else
-if CAIRO_HAS_OS2_SURFACE
-cairo_perf_trace_SOURCES += cairo-perf-os2.c
-else
-cairo_perf_trace_SOURCES += cairo-perf-posix.c
-endif
-endif
+	$(libcairoperf_sources)	\
+	$(libcairoperf_headers)
+libcairoperf_la_LIBADD = $(CAIROPERF_LIBS)
+
+cairo_perf_trace_SOURCES = \
+	$(cairo_perf_trace_sources)	\
+	$(cairo_perf_trace_external_sources)
 cairo_perf_trace_LDADD =		\
 	$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
 	$(LDADD)
 cairo_perf_trace_DEPENDENCIES = \
 	$(top_builddir)/util/cairo-script/libcairo-script-interpreter.la \
-        $(top_builddir)/boilerplate/libcairoboilerplate.la	\
-	$(top_builddir)/src/libcairo.la \
-	libcairoperf.la
-
-cairo_perf_diff_files_SOURCES =	\
-	cairo-perf-diff-files.c
-
-cairo_perf_print_SOURCES =	\
-	cairo-perf-print.c
-
-cairo_perf_chart_SOURCES =	\
-	cairo-perf-chart.c
+	$(LDADD)
 
-cairo_perf_compare_backends_SOURCES =	\
-	cairo-perf-compare-backends.c
+cairo_perf_diff_files_SOURCES =	$(cairo_perf_diff_files_sources)
+cairo_perf_print_SOURCES = $(cairo_perf_print_sources)
+cairo_perf_chart_SOURCES = $(cairo_perf_chart_sources)
+cairo_perf_compare_backends_SOURCES = $(cairo_perf_compare_backends_sources)
 
 cairo_perf_graph_files_SOURCES = \
-	cairo-perf-graph.h \
-	cairo-perf-graph-files.c \
-	cairo-perf-graph-widget.c
+	$(cairo_perf_graph_files_sources)	\
+	$(cairo_perf_graph_files_headers)
 cairo_perf_graph_files_CFLAGS = @gtk_CFLAGS@
 cairo_perf_graph_files_LDADD = @gtk_LIBS@ $(LDADD)
 
 # Install rules to rebuild the libraries and add explicit dependencies
+$(top_builddir)/perf/micro/libcairo-perf-micro.la:
+	cd $(top_builddir)/perf/micro && $(MAKE) $(AM_MAKEFLAGS) libcairo-perf-micro.la
+
 $(top_builddir)/boilerplate/libcairoboilerplate.la: $(top_builddir)/src/libcairo.la
 	cd $(top_builddir)/boilerplate && $(MAKE) $(AM_MAKEFLAGS) libcairoboilerplate.la
 
diff --git a/perf/Makefile.sources b/perf/Makefile.sources
new file mode 100644
index 0000000..9867ea5
--- /dev/null
+++ b/perf/Makefile.sources
@@ -0,0 +1,35 @@
+libcairoperf_sources = \
+	cairo-perf-os2.c	\
+	cairo-perf-posix.c	\
+	cairo-perf-report.c	\
+	cairo-perf-win32.c	\
+	cairo-stats.c		\
+	$(NULL)
+
+libcairoperf_headers = \
+	cairo-perf.h   \
+	cairo-stats.h  \
+	$(NULL)
+
+cairo_perf_trace_sources = cairo-perf-trace.c
+cairo_perf_trace_external_sources = \
+	../src/cairo-error.c \
+	../src/cairo-hash.c \
+	$(NULL)
+
+cairo_perf_micro_sources = cairo-perf-micro.c
+
+cairo_perf_diff_files_sources =	cairo-perf-diff-files.c
+
+cairo_perf_print_sources = cairo-perf-print.c
+
+cairo_perf_chart_sources = cairo-perf-chart.c
+
+cairo_perf_compare_backends_sources = cairo-perf-compare-backends.c
+
+cairo_perf_graph_files_sources =	\
+	cairo-perf-graph-files.c	\
+	cairo-perf-graph-widget.c	\
+	$(NULL)
+
+cairo_perf_graph_files_headers = cairo-perf-graph.h
diff --git a/perf/Makefile.win32 b/perf/Makefile.win32
index ef993a7..084abf0 100644
--- a/perf/Makefile.win32
+++ b/perf/Makefile.win32
@@ -1,44 +1,78 @@
 top_srcdir = ..
 include $(top_srcdir)/build/Makefile.win32.common
+include $(top_srcdir)/perf/Makefile.sources
 
-LDFLAGS += ../src/$(CFG)/cairo-static.lib $(PIXMAN_LIBS) ../boilerplate/$(CFG)/boiler.lib $(EXE_LDFLAGS)
-
-PERF_SOURCES = \
-	box-outline.c \
-	cairo-perf-win32.c \
-	cairo-perf-cover.c \
-	cairo-perf.c \
-	cairo-stats.c \
-	fill.c \
-	long-dashed-lines.c \
-	long-lines.c \
-	mosaic.c \
-	paint.c \
-	paint-with-alpha.c \
-	pattern_create_radial.c \
-	rectangles.c \
-	stroke.c \
-	subimage_copy.c \
-	tessellate.c \
-	text.c \
-	unaligned-clip.c \
-	world-map.c \
-	zrusin.c \
-#	extend-pad.c \
+CFLAGS += -I$(top_srcdir)/boilerplate -I$(top_srcdir)/util/cairo-script/
+
+PERF_LIBS = \
+	  $(CFG)/libcairoperf.lib	\
+	  $(top_builddir)/boilerplate/$(CFG)/boiler.lib	\
+	  $(top_builddir)/src/$(CFG)/cairo-static.lib	\
+	  $(NULL)
+
+PERF_EXES = \
+	  $(CFG)/cairo-perf-trace.exe	\
+	  $(CFG)/cairo-perf-micro.exe	\
+	  $(CFG)/cairo-perf-diff-files.exe	\
+	  $(CFG)/cairo-perf-print.exe	\
+	  $(CFG)/cairo-perf-chart.exe	\
+	  $(CFG)/cairo-perf-compare-backends.exe	\
+	  $(NULL)
+
+all: inform $(PERF_EXES)
+
+perf: inform $(CFG)/cairo-perf-micro.exe
+	./$(CFG)/cairo-perf-micro.exe
+
+
+libcairoperf_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(libcairoperf_sources))
+
+$(CFG)/libcairoperf.lib: $(libcairoperf_OBJECTS)
+	@$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $(libcairoperf_OBJECTS)
+
+cairo_perf_trace_OBJECTS = \
+	$(patsubst %.c, $(CFG)/%-static.obj, $(cairo_perf_trace_sources))		\
+	$(top_builddir)/util/cairo-script/$(CFG)/libcairo-script-interpreter.lib	\
+	$(NULL)
+
+cairo_perf_micro_OBJECTS = \
+	$(patsubst %.c, $(CFG)/%-static.obj, $(cairo_perf_micro_sources))	\
+	./micro/$(CFG)/libcairo-perf-micro.lib 					\
 	$(NULL)
 
-OBJECTS = $(patsubst %.c, $(CFG)/%.obj, $(PERF_SOURCES))
+cairo_perf_diff_files_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(cairo_perf_diff_files_sources))
+cairo_perf_print_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(cairo_perf_print_sources))
+cairo_perf_chart_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(cairo_perf_chart_sources))
+cairo_perf_compare_backends_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(cairo_perf_compare_backends_sources))
+
+
+$(CFG)/cairo-perf-trace.exe: $(cairo_perf_trace_OBJECTS) $(PERF_LIBS)
+	@$(LD) $(CAIRO_LDFLAGS) -OUT:$@ $(cairo_perf_trace_OBJECTS) $(PERF_LIBS) $(CAIRO_LIBS)
+
+$(CFG)/cairo-perf-micro.exe: $(cairo_perf_micro_OBJECTS) $(PERF_LIBS)
+	@$(LD) $(CAIRO_LDFLAGS) -OUT:$@ $(cairo_perf_micro_OBJECTS) $(PERF_LIBS) $(CAIRO_LIBS)
+
+$(CFG)/cairo-perf-diff-files.exe: $(cairo_perf_diff_files_OBJECTS) $(PERF_LIBS)
+	@$(LD) $(CAIRO_LDFLAGS) -OUT:$@ $(cairo_perf_diff_files_OBJECTS) $(PERF_LIBS) $(CAIRO_LIBS)
+
+$(CFG)/cairo-perf-print.exe: $(cairo_perf_print_OBJECTS) $(PERF_LIBS)
+	@$(LD) $(CAIRO_LDFLAGS) -OUT:$@ $(cairo_perf_print_OBJECTS) $(PERF_LIBS) $(CAIRO_LIBS)
+
+$(CFG)/cairo-perf-chart.exe: $(cairo_perf_chart_OBJECTS) $(PERF_LIBS)
+	@$(LD) $(CAIRO_LDFLAGS) -OUT:$@ $(cairo_perf_chart_OBJECTS) $(PERF_LIBS) $(CAIRO_LIBS)
+
+$(CFG)/cairo-perf-compare-backends.exe: $(cairo_perf_compare_backends_OBJECTS) $(PERF_LIBS)
+	@$(LD) $(CAIRO_LDFLAGS) -OUT:$@ $(cairo_perf_compare_backends_OBJECTS) $(PERF_LIBS) $(CAIRO_LIBS)
+
 
-all: inform $(CFG)/cairo-perf.exe
+./micro/$(CFG)/libcairo-perf-micro.lib:
+	$(MAKE) -C micro -f Makefile.win32
 
-$(CFG)/cairo-perf.exe: $(OBJECTS)
-	@mkdir -p $(CFG)
-	@$(CC) $(CFLAGS) -Fe"$@" $^ -link $(LDFLAGS)
+$(top_builddir)/src/$(CFG)/cairo-static.lib:
+	$(MAKE) -C $(top_srcdir)/src -f Makefile.win32
 
-cairo-perf-diff-files:
-	@mkdir -p $(CFG)
-	@$(CC) $(CFLAGS) -Fe"$@" cairo-perf-diff-files.c cairo-perf-report.c cairo-stats.c -link $(LDFLAGS)
+$(top_builddir)/boilerplate/$(CFG)/boiler.lib:
+	$(MAKE) -C $(top_srcdir)/boilerplate -f Makefile.win32
 
-cairo-perf-graph-files:
-	@mkdir -p $(CFG)
-	@$(CC) $(CFLAGS) -Fe"$@" cairo-perf-graph-files.c cairo-perf-report.c cairo-stats.c -link $(LDFLAGS)
+$(top_builddir)/util/cairo-script/$(CFG)/libcairo-script-interpreter.lib:
+	$(MAKE) -C $(top_srcdir)/util/cairo-script -f Makefile.win32
diff --git a/perf/cairo-perf-os2.c b/perf/cairo-perf-os2.c
index 5f4f078..1849938 100644
--- a/perf/cairo-perf-os2.c
+++ b/perf/cairo-perf-os2.c
@@ -27,11 +27,13 @@
  *	    Carl Worth <cworth at cworth.org> (win32/linux code)
  */
 
+#include "cairo-perf.h"
+
+#if CAIRO_HAS_OS2_SURFACE
+
 #define INCL_BASE
 #include <os2.h>
 
-#include "cairo-perf.h"
-
 /* timers */
 typedef struct _cairo_perf_timer
 {
@@ -93,3 +95,5 @@ cairo_perf_yield (void) {
     /* try to deactivate this thread until the scheduler calls it again */
     DosSleep (0);
 }
+
+#endif /* CAIRO_HAS_OS2_SURFACE */
diff --git a/perf/cairo-perf-posix.c b/perf/cairo-perf-posix.c
index 84064b0..59d8e3c 100644
--- a/perf/cairo-perf-posix.c
+++ b/perf/cairo-perf-posix.c
@@ -55,6 +55,10 @@
 
 #define _XOPEN_SOURCE 600	/* for round() */
 
+#include "cairo-perf.h"
+
+#if !CAIRO_HAS_OS2_SURFACE && !CAIRO_HAS_WIN32_SURFACE
+
 #include "config.h"
 
 #include <signal.h>
@@ -65,8 +69,6 @@
 #include <sched.h>
 #endif
 
-#include "cairo-perf.h"
-
 /* timers */
 
 #if defined(HAVE_CLOCK_GETTIME)
@@ -251,3 +253,5 @@ cairo_perf_yield (void)
     sched_yield ();
 #endif
 }
+
+#endif /* !CAIRO_HAS_OS2_SURFACE && !CAIRO_HAS_WIN32_SURFACE */
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index 2d454cb..ff22882 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -51,8 +51,44 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
+
+#ifdef _MSC_VER
+#include "dirent-win32.h"
+
+typedef SSIZE_T ssize_t;
+
+static char *
+basename_no_ext (char *path)
+{
+    static char name[_MAX_FNAME + 1];
+
+    _splitpath (path, NULL, NULL, name, NULL);
+
+    name[_MAX_FNAME] = '\0';
+
+    return name;
+}
+
+
+#else
 #include <dirent.h>
 
+static char *
+basename_no_ext (char *path)
+{
+    char *dot, *name;
+
+    name = basename (path);
+
+    dot = strchr (name, '.');
+    if (dot)
+	*dot = '\0';
+
+    return name;
+}
+
+#endif
+
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -319,18 +355,19 @@ execute (cairo_perf_t	 *perf,
     cairo_perf_ticks_t *times;
     cairo_stats_t stats = {0.0, 0.0};
     int low_std_dev_count;
-    char *trace_cpy, *name, *dot;
+    char *trace_cpy, *name;
     const cairo_script_interpreter_hooks_t hooks = {
-	.closure = args,
-	.surface_create = _similar_surface_create,
-	.context_create = _context_create
+	args,
+	_similar_surface_create,
+	NULL, /* surface_destroy */
+	_context_create,
+	NULL, /* context_destroy */
+	NULL, /* show_page */
+	NULL /* copy_page */
     };
 
     trace_cpy = xstrdup (trace);
-    name = basename (trace_cpy);
-    dot = strchr (name, '.');
-    if (dot)
-	*dot = '\0';
+    name = basename_no_ext (trace_cpy);
 
     if (perf->list_only) {
 	printf ("%s\n", name);
diff --git a/perf/cairo-perf-win32.c b/perf/cairo-perf-win32.c
index 9a09679..23b8fb4 100644
--- a/perf/cairo-perf-win32.c
+++ b/perf/cairo-perf-win32.c
@@ -25,13 +25,15 @@
  *	    Carl Worth <cworth at cworth.org>
  */
 
+#include "cairo-perf.h"
+
+#if CAIRO_HAS_WIN32_SURFACE
+
 #define USE_WINAPI
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 
-#include "cairo-perf.h"
-
 /* timers */
 
 typedef struct _cairo_perf_timer
@@ -87,3 +89,5 @@ void
 cairo_perf_yield (void) {
     SleepEx(0, TRUE);
 }
+
+#endif /* CAIRO_HAS_WIN32_SURFACE */
diff --git a/perf/dirent-win32.h b/perf/dirent-win32.h
new file mode 100644
index 0000000..0f2ed05
--- /dev/null
+++ b/perf/dirent-win32.h
@@ -0,0 +1,102 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/*
+ * Copyright 2011 Andrea Canciani
+ *
+ * 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 authors not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. The authors make no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE AUTHORS 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.
+ *
+ * Authors: Andrea Canciani <ranma42 at gmail.com>
+ */
+
+#include "cairo-compiler-private.h"
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#define stat _stat
+
+#define S_ISDIR(s) ((s) & _S_IFDIR)
+
+struct dirent {
+    ino_t d_ino;
+    char d_name[FILENAME_MAX + 1];
+};
+
+typedef struct _DIR {
+    HANDLE handle;
+    cairo_bool_t has_next;
+    WIN32_FIND_DATA data;
+    struct dirent de;
+} DIR;
+
+static DIR *
+opendir(const char *dirname)
+{
+    DIR *dirp;
+
+    dirp = malloc (sizeof (*dirp));
+    if (unlikely (dirp == NULL))
+	return NULL;
+
+    dirp->handle = FindFirstFile(dirname, &dirp->data);
+
+    if (unlikely (dirp->handle == INVALID_HANDLE_VALUE)) {
+	free (dirp);
+	return NULL;
+    }
+
+    memcpy (dirp->de.d_name, dirp->data.cFileName,
+	    sizeof (dirp->data.cFileName));
+    dirp->de.d_name[FILENAME_MAX] = '\0';
+
+    dirp->has_next = TRUE;
+
+    return dirp;
+}
+
+static int
+closedir(DIR *dirp)
+{
+    int ret;
+
+    ret = ! FindClose (dirp->handle);
+
+    free (dirp);
+
+    /* TODO: set errno */
+
+    return ret;
+}
+
+static struct dirent *
+readdir(DIR *dirp)
+{
+    if (! dirp->has_next)
+	return NULL;
+
+    /* COMPILE_TIME_ASSERT (FILENAME_MAX == sizeof (dirp->data.cFileName)); */
+
+    memcpy (dirp->de.d_name, dirp->data.cFileName,
+	    sizeof (dirp->data.cFileName));
+    dirp->de.d_name[FILENAME_MAX] = '\0';
+
+    dirp->has_next = FindNextFile (dirp->handle, &dirp->data);
+
+    return &dirp->de;
+}
diff --git a/perf/micro/Makefile.am b/perf/micro/Makefile.am
new file mode 100644
index 0000000..3edbf53
--- /dev/null
+++ b/perf/micro/Makefile.am
@@ -0,0 +1,16 @@
+include $(top_srcdir)/build/Makefile.am.common
+
+include $(top_srcdir)/perf/micro/Makefile.sources
+
+noinst_LTLIBRARIES = libcairo-perf-micro.la
+libcairo_perf_micro_la_SOURCES = \
+	$(libcairo_perf_micro_sources)	\
+	$(libcairo_perf_micro_headers)
+
+AM_CPPFLAGS =				\
+	-I$(srcdir)			\
+	-I$(top_srcdir)/boilerplate	\
+	-I$(top_srcdir)/src		\
+	-I$(top_srcdir)/perf		\
+	-I$(top_builddir)/src		\
+	$(CAIRO_CFLAGS)
diff --git a/perf/micro/Makefile.sources b/perf/micro/Makefile.sources
new file mode 100644
index 0000000..794ed62
--- /dev/null
+++ b/perf/micro/Makefile.sources
@@ -0,0 +1,35 @@
+libcairo_perf_micro_sources = \
+	cairo-perf-cover.c	\
+	box-outline.c		\
+	composite-checker.c	\
+	fill.c			\
+	long-lines.c		\
+	mosaic.c		\
+	paint.c			\
+	paint-with-alpha.c	\
+	mask.c			\
+	pattern_create_radial.c \
+	rectangles.c		\
+	rounded-rectangles.c	\
+	stroke.c		\
+	subimage_copy.c		\
+	tessellate.c		\
+	text.c			\
+	glyphs.c		\
+	twin.c			\
+	unaligned-clip.c	\
+	wave.c			\
+	world-map.c		\
+	zrusin.c		\
+	long-dashed-lines.c	\
+	dragon.c		\
+	pythagoras-tree.c	\
+	intersections.c		\
+	spiral.c		\
+	$(NULL)
+
+libcairo_perf_micro_headers = \
+	mosaic.h		\
+	world-map.h		\
+	zrusin-another.h	\
+	$(NULL)
diff --git a/perf/micro/Makefile.win32 b/perf/micro/Makefile.win32
new file mode 100644
index 0000000..f41f781
--- /dev/null
+++ b/perf/micro/Makefile.win32
@@ -0,0 +1,12 @@
+top_srcdir = ../..
+include $(top_srcdir)/build/Makefile.win32.common
+include $(top_srcdir)/perf/micro/Makefile.sources
+
+CFLAGS += -I$(top_srcdir)/perf -I$(top_srcdir)/boilerplate/
+
+OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(libcairo_perf_micro_sources))
+
+all: inform $(CFG)/libcairo-perf-micro.lib
+
+$(CFG)/libcairo-perf-micro.lib: $(OBJECTS)
+	@$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $(OBJECTS)
commit 33403cfb378de03a2cff707b4b1cc16025378822
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Tue Jun 21 18:11:58 2011 +0200

    perf: Ensure M_SQRT2 is defined
    
    pythagoras-tree uses M_SQRT2, which on Win32 is defined by math.h if
    and only if _USE_MATH_DEFINES is defined.

diff --git a/perf/micro/pythagoras-tree.c b/perf/micro/pythagoras-tree.c
index 964d5c1..3da4569 100644
--- a/perf/micro/pythagoras-tree.c
+++ b/perf/micro/pythagoras-tree.c
@@ -24,6 +24,7 @@
  */
 
 #include "cairo-perf.h"
+#define _USE_MATH_DEFINES /* for M_SQRT2 on win32 */
 #include <math.h>
 
 static void
commit 5291f7ccad54b587bd1bee3a89426cf1d158c5bb
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Wed Jun 22 14:40:23 2011 +0200

    script-interpreter: Build on win32
    
    Restructure the Makefiles in .sources, .am and .win32 to enable
    building cairo-script-interpreter on Win32.
    
    Some minor changes are needed to compile on MSVC:
     - include stdint.h to define INT_MAX-like macros
     - redefine "inline"
     - avoid deprecated functions (snprintf, replaced by _snprintf)
     - define _USE_MATH_DEFINES so that math.h defines M_PI, M_SQRT2 and
       M_LN2

diff --git a/util/cairo-script/Makefile.am b/util/cairo-script/Makefile.am
index d7e4427..c2f55a3 100644
--- a/util/cairo-script/Makefile.am
+++ b/util/cairo-script/Makefile.am
@@ -1,3 +1,5 @@
+include $(top_srcdir)/util/cairo-script/Makefile.sources
+
 SUBDIRS = examples
 
 lib_LTLIBRARIES = libcairo-script-interpreter.la
@@ -8,14 +10,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src
 cairoincludedir=$(includedir)/cairo
 cairoinclude_HEADERS = cairo-script-interpreter.h
 libcairo_script_interpreter_la_SOURCES = \
-	cairo-script-private.h \
-	cairo-script-file.c \
-	cairo-script-hash.c \
-	cairo-script-interpreter.c \
-	cairo-script-objects.c \
-	cairo-script-operators.c \
-	cairo-script-scanner.c \
-	cairo-script-stack.c \
+	$(libcairo_script_interpreter_sources)	\
+	$(libcairo_script_interpreter_headers)	\
 	$(NULL)
 libcairo_script_interpreter_la_CFLAGS = $(CAIRO_CFLAGS)
 libcairo_script_interpreter_la_LDFLAGS = -version-info $(CAIRO_LIBTOOL_VERSION_INFO) -no-undefined $(export_symbols)
diff --git a/util/cairo-script/Makefile.sources b/util/cairo-script/Makefile.sources
new file mode 100644
index 0000000..fd73a17
--- /dev/null
+++ b/util/cairo-script/Makefile.sources
@@ -0,0 +1,13 @@
+libcairo_script_interpreter_sources = \
+	cairo-script-file.c \
+	cairo-script-hash.c \
+	cairo-script-interpreter.c \
+	cairo-script-objects.c \
+	cairo-script-operators.c \
+	cairo-script-scanner.c \
+	cairo-script-stack.c \
+	$(NULL)
+
+libcairo_script_interpreter_headers = \
+	cairo-script-private.h \
+	$(NULL)
diff --git a/util/cairo-script/Makefile.win32 b/util/cairo-script/Makefile.win32
new file mode 100644
index 0000000..0aef981
--- /dev/null
+++ b/util/cairo-script/Makefile.win32
@@ -0,0 +1,10 @@
+top_srcdir = ../../
+include $(top_srcdir)/build/Makefile.win32.common
+include $(top_srcdir)/util/cairo-script/Makefile.sources
+
+all: inform $(CFG)/libcairo-script-interpreter.lib
+
+libcairo_script_interpreter_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(libcairo_script_interpreter_sources))
+
+$(CFG)/libcairo-script-interpreter.lib: $(libcairo_script_interpreter_OBJECTS)
+	@$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $(libcairo_script_interpreter_OBJECTS)
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index 34b534e..f5a9bf1 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -39,6 +39,12 @@
 #include <stdio.h> /* snprintf */
 #include <stdlib.h> /* mkstemp */
 #include <string.h>
+
+#ifdef _MSC_VER
+#define _USE_MATH_DEFINES /* for M_LN2, M_PI and M_SQRT2 on win32 */
+#define snprintf _snprintf
+#endif
+
 #include <math.h>
 #include <limits.h> /* INT_MAX */
 #include <assert.h>
diff --git a/util/cairo-script/cairo-script-private.h b/util/cairo-script/cairo-script-private.h
index 64dd155..3286bb4 100644
--- a/util/cairo-script/cairo-script-private.h
+++ b/util/cairo-script/cairo-script-private.h
@@ -43,6 +43,11 @@
 
 #include <setjmp.h>
 
+#ifdef _MSC_VER
+#undef inline
+#define inline __inline
+#endif
+
 #ifndef FALSE
 #define FALSE 0
 #endif
diff --git a/util/cairo-script/cairo-script-scanner.c b/util/cairo-script/cairo-script-scanner.c
index 37492b6..969fb63 100644
--- a/util/cairo-script/cairo-script-scanner.c
+++ b/util/cairo-script/cairo-script-scanner.c
@@ -37,6 +37,7 @@
 #include <limits.h> /* INT_MAX */
 #include <math.h> /* pow */
 #include <stdio.h> /* EOF */
+#include <stdint.h> /* for {INT,UINT}*_{MIN,MAX} */
 #include <string.h> /* memset */
 #include <assert.h>
 #include <zlib.h>
commit 3a5c8b2c74e73c8a35e80b369f043e62dc2ad26c
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Tue Jun 21 18:11:38 2011 +0200

    test: Cleanup build on Win32
    
    Put cairo-test-suite.exe in a $(CFG)-dependent folder and link to
    libraries from $(top_builddir).

diff --git a/test/Makefile.win32 b/test/Makefile.win32
index cd08db8..5235769 100644
--- a/test/Makefile.win32
+++ b/test/Makefile.win32
@@ -4,9 +4,9 @@ include $(top_srcdir)/test/Makefile.sources
 
 CFLAGS += -I$(top_srcdir)/boilerplate -I./pdiff
 
-TEST_LIBS = ./pdiff/$(CFG)/pdiff.lib $(top_srcdir)/src/$(CFG)/cairo-static.lib $(top_srcdir)/boilerplate/$(CFG)/boiler.lib
+TEST_LIBS = ./pdiff/$(CFG)/pdiff.lib $(top_builddir)/src/$(CFG)/cairo-static.lib $(top_builddir)/boilerplate/$(CFG)/boiler.lib
 
-all: inform cairo-test-suite.exe
+all: inform $(CFG)/cairo-test-suite.exe
 
 cairo-test-constructors.c: Makefile.sources Makefile.win32 $(test_sources) make-cairo-test-constructors.sh
 	sh ./make-cairo-test-constructors.sh $(test_sources) > $@
@@ -15,21 +15,21 @@ SOURCES = $(cairo_test_suite_sources) $(test_sources) cairo-test-constructors.c
 
 OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(SOURCES))
 
-cairo-test-suite.exe: $(OBJECTS) $(TEST_LIBS)
+$(CFG)/cairo-test-suite.exe: $(OBJECTS) $(TEST_LIBS)
 	@$(LD) $(CAIRO_LDFLAGS) -OUT:$@ $(OBJECTS) $(TEST_LIBS) $(CAIRO_LIBS)
 
 ./pdiff/$(CFG)/pdiff.lib:
 	$(MAKE) -C pdiff -f Makefile.win32
 
-$(top_srcdir)/src/$(CFG)/cairo-static.lib:
+$(top_builddir)/src/$(CFG)/cairo-static.lib:
 	$(MAKE) -C $(top_srcdir)/src -f Makefile.win32
 
-$(top_srcdir)/boilerplate/$(CFG)/boiler.lib:
+$(top_builddir)/boilerplate/$(CFG)/boiler.lib:
 	$(MAKE) -C $(top_srcdir)/boilerplate -f Makefile.win32
 
 .PHONY: check test
 
-check: inform cairo-test-suite.exe
-	./cairo-test-suite.exe
+check: inform $(CFG)/cairo-test-suite.exe
+	./$(CFG)/cairo-test-suite.exe
 
 test: inform check
commit f21ac5b13b4a2a5455349da29529692a02c2a5e0
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Thu Jun 23 10:09:30 2011 +0200

    error: Do not define _cairo_error twice
    
    cairo-perf-trace uses cairo-hash.c, which calls _cairo_error.
    
    Instead of redefining it in cairo-perf-trace.c it can be abstracted in
    a separate source which is directly included in the build of
    cairo-perf-trace.
    
    This avoids visibility issues when compiling cairo-perf-trace with a
    statically linked cairo library on architectures which do not support
    hidden visibility (example: win32).

diff --git a/perf/Makefile.am b/perf/Makefile.am
index f4e4cf4..1e1bf5b 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -81,6 +81,7 @@ libcairoperf_la_SOURCES = \
 
 cairo_perf_trace_SOURCES =		\
 	cairo-perf-trace.c		\
+	../src/cairo-error.c		\
 	../src/cairo-hash.c
 if CAIRO_HAS_WIN32_SURFACE
 cairo_perf_trace_SOURCES += cairo-perf-win32.c
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index b3d22cf..2d454cb 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -884,9 +884,3 @@ main (int   argc,
 
     return 0;
 }
-
-cairo_status_t
-_cairo_error (cairo_status_t status)
-{
-    return status;
-}
diff --git a/src/Makefile.sources b/src/Makefile.sources
index edb9f44..c7a0540 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -123,6 +123,7 @@ cairo_sources = \
 	cairo-composite-rectangles.c \
 	cairo-debug.c \
 	cairo-device.c \
+	cairo-error.c \
 	cairo-fixed.c \
 	cairo-font-face.c \
 	cairo-font-face-twin.c \
diff --git a/src/cairo-error.c b/src/cairo-error.c
new file mode 100644
index 0000000..a3fc197
--- /dev/null
+++ b/src/cairo-error.c
@@ -0,0 +1,69 @@
+/* -*- Mode: c; c-basic-offset: 4; indent-tabs-mode: t; tab-width: 8; -*- */
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright © 2002 University of Southern California
+ * Copyright © 2005 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is University of Southern
+ * California.
+ *
+ * Contributor(s):
+ *	Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairoint.h"
+#include "cairo-private.h"
+
+#include "cairo-error-private.h"
+#include <assert.h>
+
+/**
+ * _cairo_error:
+ * @status: a status value indicating an error, (eg. not
+ * %CAIRO_STATUS_SUCCESS)
+ *
+ * Checks that status is an error status, but does nothing else.
+ *
+ * All assignments of an error status to any user-visible object
+ * within the cairo application should result in a call to
+ * _cairo_error().
+ *
+ * The purpose of this function is to allow the user to set a
+ * breakpoint in _cairo_error() to generate a stack trace for when the
+ * user causes cairo to detect an error.
+ *
+ * Return value: the error status.
+ **/
+cairo_status_t
+_cairo_error (cairo_status_t status)
+{
+    CAIRO_ENSURE_UNIQUE;
+    assert (_cairo_status_is_error (status));
+
+    return status;
+}
diff --git a/src/cairo.c b/src/cairo.c
index c19a1e9..dde9dac 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -154,32 +154,6 @@ static const cairo_t _cairo_nil__null_pointer = {
 #include <assert.h>
 
 /**
- * _cairo_error:
- * @status: a status value indicating an error, (eg. not
- * %CAIRO_STATUS_SUCCESS)
- *
- * Checks that status is an error status, but does nothing else.
- *
- * All assignments of an error status to any user-visible object
- * within the cairo application should result in a call to
- * _cairo_error().
- *
- * The purpose of this function is to allow the user to set a
- * breakpoint in _cairo_error() to generate a stack trace for when the
- * user causes cairo to detect an error.
- *
- * Return value: the error status.
- **/
-cairo_status_t
-_cairo_error (cairo_status_t status)
-{
-    CAIRO_ENSURE_UNIQUE;
-    assert (_cairo_status_is_error (status));
-
-    return status;
-}
-
-/**
  * _cairo_set_error:
  * @cr: a cairo context
  * @status: a status value indicating an error
commit 0740c8e4f37e5ff17d2bf294c37c438de0be0a41
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Thu Jun 23 10:08:52 2011 +0200

    Hide private symbols on MacOSX
    
    gcc provides the hidden visibility attribute on Darwin, which can be
    used to deny access to private cairo symbols.

diff --git a/src/cairo-compiler-private.h b/src/cairo-compiler-private.h
index fe1d1d4..2bbd302 100644
--- a/src/cairo-compiler-private.h
+++ b/src/cairo-compiler-private.h
@@ -114,7 +114,9 @@
 
 /* slim_internal.h */
 #define CAIRO_HAS_HIDDEN_SYMBOLS 1
-#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)
+#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && \
+    (defined(__ELF__) || defined(__APPLE__)) &&			\
+    !defined(__sun)
 #define cairo_private_no_warn	__attribute__((__visibility__("hidden")))
 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
 #define cairo_private_no_warn	__hidden


More information about the cairo-commit mailing list