[cairo-commit] 5 commits - perf/cairo-analyse-trace.c perf/cairo-perf-report.c perf/cairo-perf-trace.c src/cairo-malloc-private.h src/cairo-surface-observer.c src/cairo-wideint-private.h util/cairo-missing

Andrea Canciani ranma42 at kemper.freedesktop.org
Sun Sep 4 16:24:50 PDT 2011


 perf/cairo-analyse-trace.c         |    2 --
 perf/cairo-perf-report.c           |    6 ------
 perf/cairo-perf-trace.c            |    2 --
 src/cairo-malloc-private.h         |    1 +
 src/cairo-surface-observer.c       |    2 +-
 src/cairo-wideint-private.h        |    4 ++--
 util/cairo-missing/Makefile.win32  |    4 ++--
 util/cairo-missing/cairo-missing.h |    8 ++++++++
 util/cairo-missing/getline.c       |    9 +++++----
 util/cairo-missing/strndup.c       |    7 +++++--
 10 files changed, 24 insertions(+), 21 deletions(-)

New commits:
commit 6ad63946d4374ad30ef7fbdad421d85bfd8da423
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sun Sep 4 15:19:21 2011 -0700

    cairo-missing: Fix build
    
    The cairo-missing code contains multiple typos and uses
    _cairo_*alloc*() functions without including cairo-malloc-private.h

diff --git a/util/cairo-missing/Makefile.win32 b/util/cairo-missing/Makefile.win32
index ac24a2c..c2c5bc0 100644
--- a/util/cairo-missing/Makefile.win32
+++ b/util/cairo-missing/Makefile.win32
@@ -6,5 +6,5 @@ all: inform $(CFG)/libcairo-missing.lib
 
 libcairo_missing_OBJECTS = $(patsubst %.c, $(CFG)/%-static.obj, $(libcairo_missing_sources))
 
-$(CFG)/libcairo-script-interpreter.lib: $(libcairo_missing_OBJECTS)
-	@$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $(libcairo_missing_OBJECTS)
+$(CFG)/libcairo-missing.lib: $(libcairo_missing_OBJECTS)
+	@$(AR) $(CAIRO_ARFLAGS) -OUT:$@ $^
diff --git a/util/cairo-missing/getline.c b/util/cairo-missing/getline.c
index 584c6ac..8585cfd 100644
--- a/util/cairo-missing/getline.c
+++ b/util/cairo-missing/getline.c
@@ -31,6 +31,7 @@
 #include "cairo-missing.h"
 
 #ifndef HAVE_GETLINE
+#include "cairo-malloc-private.h"
 
 #define GETLINE_MIN_BUFFER_SIZE 128
 ssize_t
@@ -45,20 +46,20 @@ getline (char	**lineptr,
     offset = 0;
     len = *n;
     line = *lineptr;
-    if (len < GETLINE_BUFFER_SIZE) {
-	len = GETLINE_BUFFER_SIZE;
+    if (len < GETLINE_MIN_BUFFER_SIZE) {
+	len = GETLINE_MIN_BUFFER_SIZE;
 	line = NULL;
     }
 
     if (line == NULL) {
-	line = (char *) malloc (len);
+	line = (char *) _cairo_malloc (len);
 	if (unlikely (line == NULL))
 	    return -1;
     }
 
     while (1) {
 	if (offset + 1 == len) {
-	    tmpline = (char *) cairo_realloc (line, len, 2);
+	    tmpline = (char *) _cairo_realloc_ab (line, len, 2);
 	    if (unlikely (tmpline == NULL)) {
 		if (line != *lineptr)
 		    free (line);
diff --git a/util/cairo-missing/strndup.c b/util/cairo-missing/strndup.c
index 6eabc12..280ea30 100644
--- a/util/cairo-missing/strndup.c
+++ b/util/cairo-missing/strndup.c
@@ -31,6 +31,8 @@
 #include "cairo-missing.h"
 
 #ifndef HAVE_STRNDUP
+#include "cairo-malloc-private.h"
+
 char *
 strndup (const char *s,
 	 size_t      n)
@@ -42,8 +44,9 @@ strndup (const char *s,
 	return NULL;
 
     len = strlen (s);
-    len = MIN (n, len);
-    sdup = (char *) malloc (len + 1);
+    if (len > n)
+	len = n;
+    sdup = (char *) _cairo_malloc (len + 1);
     if (sdup != NULL) {
 	memcpy (sdup, s, len);
 	sdup[len] = '\0';
commit ed84cb522cc9a65ac89b2b008010ecfe78dde7de
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sun Sep 4 15:18:34 2011 -0700

    wideint: Fix build on suncc
    
    "static cairo_private" means nothing and suncc complains loudly about
    it. The visibility of _cairo_double_to_uint64() and
    _cairo_uint64_to_double() should just be "static".

diff --git a/src/cairo-wideint-private.h b/src/cairo-wideint-private.h
index 53d2546..f6ae5bc 100644
--- a/src/cairo-wideint-private.h
+++ b/src/cairo-wideint-private.h
@@ -112,8 +112,8 @@ _cairo_uint64_divrem (cairo_uint64_t num, cairo_uint64_t den)
  * warning: cast from function call of type ‘#cairo_uint64_t’ to
  * non-matching type ‘double’
  */
-static cairo_always_inline cairo_uint64_t I _cairo_double_to_uint64 (double i) { return i; }
-static cairo_always_inline double I _cairo_uint64_to_double (cairo_uint64_t i) { return i; }
+static cairo_always_inline cairo_const cairo_uint64_t _cairo_double_to_uint64 (double i) { return i; }
+static cairo_always_inline cairo_const double _cairo_uint64_to_double (cairo_uint64_t i) { return i; }
 
 #define			_cairo_uint32_to_uint64(i)  ((uint64_t) (i))
 #define			_cairo_uint64_to_uint32(i)  ((uint32_t) (i))
commit 01729606fb5026ca5b4c8ac67a083c065be8d7a0
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sun Sep 4 15:17:20 2011 -0700

    malloc: Fix build on suncc
    
    cairo-malloc-private.h depends on malloc() and realloc() being
    declared, hence it should include stdlib.h.

diff --git a/src/cairo-malloc-private.h b/src/cairo-malloc-private.h
index e5776ab..e5acf16 100644
--- a/src/cairo-malloc-private.h
+++ b/src/cairo-malloc-private.h
@@ -38,6 +38,7 @@
 #define CAIRO_MALLOC_PRIVATE_H
 
 #include "cairo-wideint-private.h"
+#include <stdlib.h>
 
 #if HAVE_MEMFAULT
 #include <memfault.h>
commit 761ef7ae8bad6d76f0f5e550882c5991fc0f92b1
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sun Sep 4 15:16:30 2011 -0700

    cairo-missing: Fix and cleanup ssize_t type definition
    
    The definition of ssize_t is needed in cairo-missing.h and can be
    dropped from files which include it.

diff --git a/perf/cairo-analyse-trace.c b/perf/cairo-analyse-trace.c
index 9622907..ac2a4e7 100644
--- a/perf/cairo-analyse-trace.c
+++ b/perf/cairo-analyse-trace.c
@@ -55,8 +55,6 @@
 #ifdef _MSC_VER
 #include "dirent-win32.h"
 
-typedef SSIZE_T ssize_t;
-
 static char *
 basename_no_ext (char *path)
 {
diff --git a/perf/cairo-perf-report.c b/perf/cairo-perf-report.c
index ffcd90a..fcce0e0 100644
--- a/perf/cairo-perf-report.c
+++ b/perf/cairo-perf-report.c
@@ -44,12 +44,6 @@
 #include <libgen.h>
 #endif
 
-/* '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
-
 #ifdef _MSC_VER
 static long long
 strtoll (const char  *nptr,
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index 3a9b822..2cef2b1 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -56,8 +56,6 @@
 #ifdef _MSC_VER
 #include "dirent-win32.h"
 
-typedef SSIZE_T ssize_t;
-
 static char *
 basename_no_ext (char *path)
 {
diff --git a/util/cairo-missing/cairo-missing.h b/util/cairo-missing/cairo-missing.h
index 1397756..ccb85fa 100644
--- a/util/cairo-missing/cairo-missing.h
+++ b/util/cairo-missing/cairo-missing.h
@@ -35,6 +35,14 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <sys/types.h>
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+typedef SSIZE_T ssize_t;
+#endif
 
 #ifndef HAVE_GETLINE
 cairo_private ssize_t
commit 60e04ff49eb818e9628c2e1421f5368655c61bea
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Sun Sep 4 14:09:54 2011 -0700

    observer: Fix build on suncc
    
    Returning a void value is an error on suncc and causes a warning on msvc:
    cairo-surface-observer.c(1273) : warning C4098:
    '_cairo_surface_observer_release_source_image' : 'void' function
    returning a value

diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c
index 65f6585..3314b82 100644
--- a/src/cairo-surface-observer.c
+++ b/src/cairo-surface-observer.c
@@ -1270,7 +1270,7 @@ _cairo_surface_observer_release_source_image (void                   *abstract_s
 {
     cairo_surface_observer_t *surface = abstract_surface;
 
-    return _cairo_surface_release_source_image (surface->target, image, image_extra);
+    _cairo_surface_release_source_image (surface->target, image, image_extra);
 }
 
 static cairo_surface_t *


More information about the cairo-commit mailing list