[cairo-commit] perf/cairo-perf-diff perf/cairo-perf-diff-files.c perf/Makefile.win32 perf/README

Vladimir Vukicevic vladimir at kemper.freedesktop.org
Thu Jul 17 13:56:44 PDT 2008


 perf/Makefile.win32          |    4 +++
 perf/README                  |   21 ++++++++++++++++
 perf/cairo-perf-diff         |    6 +++-
 perf/cairo-perf-diff-files.c |   56 +++++++++++++++++++++++++++++++++++++++++--
 4 files changed, 84 insertions(+), 3 deletions(-)

New commits:
commit 5284f8cab488c12db0ff0b12a4485072138b8008
Author: Frederic Plourde <frederic.plourde at polymtl.ca>
Date:   Thu Jul 17 13:56:22 2008 -0700

    [win32] Make cairo-perf-diff run on win32

diff --git a/perf/Makefile.win32 b/perf/Makefile.win32
index f1c86fe..37b5143 100644
--- a/perf/Makefile.win32
+++ b/perf/Makefile.win32
@@ -41,6 +41,10 @@ $(CFG)/cairo-perf.exe: $(OBJECTS)
 	@mkdir -p $(CFG)
 	@$(CC) $(CFLAGS) -Fe"$@" $^ -link $(LDFLAGS)
 
+cairo-perf-diff-files:
+	@mkdir -p $(CFG)
+	@$(CC) $(CFLAGS) -Fe"$@" cairo-perf-diff-files.c cairo-stats.c -link $(LDFLAGS)
+
 clean:
 	@rm -f $(CFG)/*.obj $(CFG)/*.exe $(CFG)/*.dll $(CFG)/*.lib $(CFG)/*.pdb $(CFG)/*.ilk || exit 0
 
diff --git a/perf/README b/perf/README
index d41142a..ca5f2a1 100644
--- a/perf/README
+++ b/perf/README
@@ -179,4 +179,25 @@ added:
     above, three tests would be performed at sizes of 16x16, 32x32 and
     64x64.
 
+How to run cairo-perf-diff on WINDOWS
+-------------------------------------
+This section explains the specifics of running cairo-perf-diff under
+win32 plateforms. It assumes that you have installed a UNIX-like shell
+environment such as MSYS (distributed as part of MinGW).
+
+ 1. From your Mingw32 window, be sure to have all of your MSVC environ-
+    ment variables set up for proper compilation using 'make'
+
+ 2. Add the %GitBaseDir%/Git/bin path to your environment, replacing the 
+    %GitBaseDir% by whatever directory your Git version is installed to.
+
+ 3. Comment out the "UNSET CDPATH" line in the git-sh-setup script 
+    (located inside the ...Git/bin directory) by putting a "#" at the 
+    beginning of the line.
+
+you should be ready to go !
+
+From your mingw32 window, go to your cairo/perf directory and run the 
+cairo-perf-diff script with the right arguments.
+
 Thanks for your contributions and have fun with cairo!
diff --git a/perf/cairo-perf-diff b/perf/cairo-perf-diff
index 3795456..18aa4dd 100755
--- a/perf/cairo-perf-diff
+++ b/perf/cairo-perf-diff
@@ -189,7 +189,11 @@ git_setup
 # Build cairo-perf-diff-files if not available
 if [ ! -e $CAIRO_DIR/perf/cairo-perf-diff-files ]; then
     echo "Building cairo-perf-diff-files"
-    make -C $CAIRO_DIR/perf/ cairo-perf-diff-files
+    if [ $OS = "Windows_NT" ]; then 
+        make -f Makefile.win32 -C $CAIRO_DIR/perf/ cairo-perf-diff-files CFG=debug
+    else
+        make -C $CAIRO_DIR/perf/ cairo-perf-diff-files
+    fi
 fi
 
 if [ ! -e $old ]; then
diff --git a/perf/cairo-perf-diff-files.c b/perf/cairo-perf-diff-files.c
index 5fdf72d..79d844c 100644
--- a/perf/cairo-perf-diff-files.c
+++ b/perf/cairo-perf-diff-files.c
@@ -96,6 +96,12 @@ typedef struct _cairo_perf_diff_files_args {
     cairo_perf_report_options_t options;
 } cairo_perf_diff_files_args_t;
 
+/* 'ssize_t' does not exist in the C standard on win32. 
+ * We use 'ptrdiff_t', which is nearly equivalent. */
+#ifdef _MSC_VER
+typedef ptrdiff_t ssize_t;
+#endif
+
 #ifndef __USE_GNU
 static ssize_t
 getline (char **lineptr, size_t *n, FILE *stream);
@@ -104,6 +110,14 @@ static char *
 strndup (const char *s, size_t n);
 #endif
 
+#ifdef _MSC_VER
+static long long
+strtoll(const char *nptr, char **endptr, int base);
+
+static char *
+basename(char *path);
+#endif
+
 /* Ad-hoc parsing, macros with a strong dependence on the calling
  * context, and plenty of other ugliness is here.  But at least it's
  * not perl... */
@@ -304,6 +318,40 @@ strndup (const char *s, size_t n)
 }
 #endif /* ifndef __USE_GNU */
 
+/* We provide hereafter a win32 implementation of the basename
+ * and strtoll functions which are not available otherwise.
+ * The basename function is fully compliant to its GNU specs.
+ */
+#ifdef _MSC_VER
+long long
+strtoll(const char *nptr, char **endptr, int base)
+{
+    return _atoi64(nptr);
+}
+
+static char *
+basename(char *path)
+{
+    char *end, *s;
+
+    end = (path + strlen(path) - 1);
+    while (end && (end >= path + 1) && (*end == '/')) {
+	*end = '\0';
+	end--;
+    }
+
+    s = strrchr(path, '/');
+    if (s) {
+	if (s == end) {
+	    return s;
+	} else {
+	    return s+1;
+	}
+    } else {
+	return path;
+    }
+}
+#endif /* ifndef _MSC_VER */
 
 static int
 test_report_cmp_backend_then_name (const void *a, const void *b)
@@ -397,9 +445,13 @@ cairo_perf_report_load (cairo_perf_report_t *report, const char *filename)
     size_t line_size = 0;
     char *configuration;
     char *dot;
+    char *baseName;
 
-    configuration = strdup (filename);
-    report->configuration = strdup (basename (configuration));
+    configuration = xmalloc (strlen (filename) * sizeof (char) + 1);
+    strcpy (configuration, filename);
+    baseName = strdup (basename (configuration));
+    report->configuration = xmalloc (strlen (filename) * sizeof (char) + 1);
+    strcpy(report->configuration, baseName);
     free (configuration);
     dot = strrchr (report->configuration, '.');
     if (dot)


More information about the cairo-commit mailing list