[cairo-commit] 2 commits - boilerplate/cairo-boilerplate-beos.cpp boilerplate/cairo-boilerplate-glitz-agl.c boilerplate/cairo-boilerplate-glitz-glx.c boilerplate/cairo-boilerplate-glitz-wgl.c boilerplate/cairo-boilerplate.h boilerplate/cairo-boilerplate-system.c boilerplate/cairo-boilerplate-xcb.c boilerplate/cairo-boilerplate-xlib.c test/cairo-test.h

Chris Wilson ickle at kemper.freedesktop.org
Sat Jan 3 14:59:21 PST 2009


 boilerplate/cairo-boilerplate-beos.cpp    |   19 +++----------------
 boilerplate/cairo-boilerplate-glitz-agl.c |   10 +++++-----
 boilerplate/cairo-boilerplate-glitz-glx.c |    6 +++---
 boilerplate/cairo-boilerplate-glitz-wgl.c |   10 +++++-----
 boilerplate/cairo-boilerplate-system.c    |   16 ++++++++--------
 boilerplate/cairo-boilerplate-xcb.c       |    4 ++--
 boilerplate/cairo-boilerplate-xlib.c      |   18 +++++++++---------
 boilerplate/cairo-boilerplate.h           |    6 +-----
 test/cairo-test.h                         |    1 -
 9 files changed, 36 insertions(+), 54 deletions(-)

New commits:
commit 388ae177e4100698289819429fa1f8e6958d1c60
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jan 3 22:51:28 2009 +0000

    [boilerplate] Remove CAIRO_BOILERPLATE_LOG()
    
    The variadic macro is only used within boilerplate/ so replace it with a
    simple, and portable, call to fprintf.

diff --git a/boilerplate/cairo-boilerplate-beos.cpp b/boilerplate/cairo-boilerplate-beos.cpp
index 2a84d1b..497d927 100644
--- a/boilerplate/cairo-boilerplate-beos.cpp
+++ b/boilerplate/cairo-boilerplate-beos.cpp
@@ -38,10 +38,6 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
-// BeOS's C++ compiler does not support varargs in macros
-// So, define CAIRO_BOILERPLATE_LOG here
-#define CAIRO_BOILERPLATE_LOG cairo_beos_boilerplate_log
-
 extern "C" {
 #include "cairo-boilerplate.h"
 }
@@ -57,15 +53,6 @@ extern "C" {
 #include <View.h>
 #include <Bitmap.h>
 
-static int cairo_beos_boilerplate_log(const char* format, ...) {
-    va_list args;
-    int rv;
-    va_start(args, format);
-    rv = vfprintf(stderr, format, args);
-    va_end(args);
-    return rv;
-}
-
 class CairoTestWindow : public BWindow
 {
 public:
@@ -142,18 +129,18 @@ AppRunner::AppRunner()
 
     sem_id initsem = create_sem(0, "Cairo BApplication init");
     if (initsem < B_OK) {
-	CAIRO_BOILERPLATE_LOG("Error creating BeOS initialization semaphore\n");
+	fprintf (stderr, "Error creating BeOS initialization semaphore\n");
         return;
     }
 
     thread_id tid = spawn_thread(nsBeOSApp::Main, "Cairo/BeOS test", B_NORMAL_PRIORITY, (void *)initsem);
     if (tid < B_OK || B_OK != resume_thread(tid)) {
-	CAIRO_BOILERPLATE_LOG("Error spawning thread\n");
+	fprintf (stderr, "Error spawning thread\n");
 	return;
     }
 
     if (B_OK != acquire_sem(initsem)) {
-	CAIRO_BOILERPLATE_LOG("Error acquiring semaphore\n");
+	fprintf (stderr, "Error acquiring semaphore\n");
 	return;
     }
 
diff --git a/boilerplate/cairo-boilerplate-glitz-agl.c b/boilerplate/cairo-boilerplate-glitz-agl.c
index 06b9030..dd10a00 100644
--- a/boilerplate/cairo-boilerplate-glitz-agl.c
+++ b/boilerplate/cairo-boilerplate-glitz-agl.c
@@ -66,25 +66,25 @@ _cairo_boilerplate_glitz_agl_create_surface_internal (glitz_format_name_t		 form
 
     dformat = glitz_agl_find_pbuffer_format (mask, &templ, 0);
     if (!dformat) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
+	fprintf (stderr, "Glitz failed to find pbuffer format for template.");
 	goto FAIL;
     }
 
     gdraw = glitz_agl_create_pbuffer_drawable (dformat, width, height);
     if (!gdraw) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
+	fprintf (stderr, "Glitz failed to create pbuffer drawable.");
 	goto FAIL;
     }
 
     format = glitz_find_standard_format (gdraw, formatname);
     if (!format) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
+	fprintf (stderr, "Glitz failed to find standard format for drawable.");
 	goto DESTROY_DRAWABLE;
     }
 
     sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
     if (!sr) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
+	fprintf (stderr, "Glitz failed to create a surface.");
 	goto DESTROY_DRAWABLE;
     }
 
@@ -127,7 +127,7 @@ _cairo_boilerplate_glitz_agl_create_surface (const char			 *name,
 	break;
     case CAIRO_CONTENT_ALPHA:
     default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-agl test: %d\n", content);
+	fprintf (stderr, "Invalid content for glitz-agl test: %d\n", content);
 	goto FAIL;
     }
 
diff --git a/boilerplate/cairo-boilerplate-glitz-glx.c b/boilerplate/cairo-boilerplate-glitz-glx.c
index 5dcf8b6..4c26b87 100644
--- a/boilerplate/cairo-boilerplate-glitz-glx.c
+++ b/boilerplate/cairo-boilerplate-glitz-glx.c
@@ -176,7 +176,7 @@ _cairo_boilerplate_glitz_glx_create_surface (const char			 *name,
 
     gxtc->dpy = XOpenDisplay (getenv("CAIRO_TEST_GLITZ_DISPLAY"));
     if (!gxtc->dpy) {
-	CAIRO_BOILERPLATE_LOG ("Failed to open display: %s\n", XDisplayName(0));
+	fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
 	goto FAIL;
     }
 
@@ -193,11 +193,11 @@ _cairo_boilerplate_glitz_glx_create_surface (const char			 *name,
 	break;
     case CAIRO_CONTENT_ALPHA:
     default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-glx test: %d\n", content);
+	fprintf (stderr, "Invalid content for glitz-glx test: %d\n", content);
 	goto FAIL_CLOSE_DISPLAY;
     }
     if (!glitz_surface) {
-	CAIRO_BOILERPLATE_LOG ("Failed to create glitz-glx surface\n");
+	fprintf (stderr, "Failed to create glitz-glx surface\n");
 	goto FAIL_CLOSE_DISPLAY;
     }
 
diff --git a/boilerplate/cairo-boilerplate-glitz-wgl.c b/boilerplate/cairo-boilerplate-glitz-wgl.c
index b11a818..dfd764f 100644
--- a/boilerplate/cairo-boilerplate-glitz-wgl.c
+++ b/boilerplate/cairo-boilerplate-glitz-wgl.c
@@ -66,25 +66,25 @@ _cairo_boilerplate_glitz_wgl_create_surface_internal (glitz_format_name_t		 form
 
     dformat = glitz_wgl_find_pbuffer_format (mask, &templ, 0);
     if (!dformat) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to find pbuffer format for template.");
+	fprintf (stderr, "Glitz failed to find pbuffer format for template.");
 	goto FAIL;
     }
 
     gdraw = glitz_wgl_create_pbuffer_drawable (dformat, width, height);
     if (!gdraw) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to create pbuffer drawable.");
+	fprintf (stderr, "Glitz failed to create pbuffer drawable.");
 	goto FAIL;
     }
 
     format = glitz_find_standard_format (gdraw, formatname);
     if (!format) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to find standard format for drawable.");
+	fprintf (stderr, "Glitz failed to find standard format for drawable.");
 	goto DESTROY_DRAWABLE;
     }
 
     sr = glitz_surface_create (gdraw, format, width, height, 0, NULL);
     if (!sr) {
-	CAIRO_BOILERPLATE_LOG ("Glitz failed to create a surface.");
+	fprintf (stderr, "Glitz failed to create a surface.");
 	goto DESTROY_DRAWABLE;
     }
 
@@ -124,7 +124,7 @@ _cairo_boilerplate_glitz_wgl_create_surface (const char			 *name,
 	glitz_surface = _cairo_boilerplate_glitz_wgl_create_surface_internal (GLITZ_STANDARD_ARGB32, width, height, NULL);
 	break;
     default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for glitz-wgl test: %d\n", content);
+	fprintf (stderr, "Invalid content for glitz-wgl test: %d\n", content);
 	goto FAIL;
     }
 
diff --git a/boilerplate/cairo-boilerplate-system.c b/boilerplate/cairo-boilerplate-system.c
index af07681..3855b73 100644
--- a/boilerplate/cairo-boilerplate-system.c
+++ b/boilerplate/cairo-boilerplate-system.c
@@ -46,7 +46,7 @@ xmalloc (size_t size)
 
     buf = malloc (size);
     if (buf == NULL) {
-	CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
+	fprintf (stderr, "Error: Out of memory. Exiting.\n");
 	exit (1);
     }
 
@@ -63,7 +63,7 @@ xcalloc (size_t nmemb, size_t size)
 
     buf = calloc (nmemb, size);
     if (buf == NULL) {
-	CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting\n");
+	fprintf (stderr, "Error: Out of memory. Exiting\n");
 	exit (1);
     }
 
@@ -75,7 +75,7 @@ xrealloc (void *buf, size_t size)
 {
     buf = realloc (buf, size);
     if (buf == NULL && size != 0) {
-	CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting\n");
+	fprintf (stderr, "Error: Out of memory. Exiting\n");
 	exit (1);
     }
 
@@ -94,7 +94,7 @@ xasprintf (char **strp, const char *fmt, ...)
     va_end (va);
 
     if (ret < 0) {
-	CAIRO_BOILERPLATE_LOG ("Error: Out of memory. Exiting.\n");
+	fprintf (stderr, "Error: Out of memory. Exiting.\n");
 	exit (1);
     }
 #else /* !HAVE_VASNPRINTF */
@@ -108,14 +108,14 @@ xasprintf (char **strp, const char *fmt, ...)
     va_end (va);
 
     if (ret < 0) {
-	CAIRO_BOILERPLATE_LOG ("Failure in vsnprintf\n");
+	fprintf (stderr, "Failure in vsnprintf\n");
 	exit (1);
     }
 
     len = (ret + sizeof (int)) & -sizeof (int);
     *strp = malloc (len);
     if (*strp == NULL) {
-	CAIRO_BOILERPLATE_LOG ("Out of memory\n");
+	fprintf (stderr, "Out of memory\n");
 	exit (1);
     }
 
@@ -128,7 +128,7 @@ xasprintf (char **strp, const char *fmt, ...)
 
 	if (ret >= len) {
 	    free (*strp);
-	    CAIRO_BOILERPLATE_LOG ("Overflowed dynamic buffer\n");
+	    fprintf (stderr, "Overflowed dynamic buffer\n");
 	    exit (1);
 	}
     }
@@ -140,7 +140,7 @@ void
 xunlink (const char *pathname)
 {
     if (unlink (pathname) < 0 && errno != ENOENT) {
-	CAIRO_BOILERPLATE_LOG ("Error: Cannot remove %s: %s\n",
+	fprintf (stderr, "Error: Cannot remove %s: %s\n",
 			       pathname, strerror (errno));
 	exit (1);
     }
diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c
index dca7acf..306f874 100644
--- a/boilerplate/cairo-boilerplate-xcb.c
+++ b/boilerplate/cairo-boilerplate-xcb.c
@@ -73,7 +73,7 @@ _cairo_boilerplate_xcb_create_surface (const char		 *name,
 
     xtc->c = c = xcb_connect(NULL,NULL);
     if (xcb_connection_has_error(c)) {
-	CAIRO_BOILERPLATE_LOG ("Failed to connect to X server through XCB\n");
+	fprintf (stderr, "Failed to connect to X server through XCB\n");
 	return NULL;
     }
 
@@ -92,7 +92,7 @@ _cairo_boilerplate_xcb_create_surface (const char		 *name,
 	break;
     case CAIRO_CONTENT_ALPHA:  /* would be XCB_PICT_STANDARD_A_8 */
     default:
-	CAIRO_BOILERPLATE_LOG ("Invalid content for XCB test: %d\n", content);
+	fprintf (stderr, "Invalid content for XCB test: %d\n", content);
 	return NULL;
     }
 
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index 9f4b00c..d3b86d1 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -70,10 +70,6 @@
 # define UINT16_MAX	(65535)
 #endif
 
-#ifndef CAIRO_BOILERPLATE_LOG
-#define CAIRO_BOILERPLATE_LOG(...) fprintf(stderr, __VA_ARGS__)
-#endif
-
 #ifndef CAIRO_BOILERPLATE_DEBUG
 #define CAIRO_BOILERPLATE_DEBUG(x)
 #endif
diff --git a/test/cairo-test.h b/test/cairo-test.h
index 5bb23ae..a9dbf19 100644
--- a/test/cairo-test.h
+++ b/test/cairo-test.h
@@ -26,7 +26,6 @@
 #ifndef _CAIRO_TEST_H_
 #define _CAIRO_TEST_H_
 
-#define CAIRO_BOILERPLATE_LOG(...) cairo_test_log (__VA_ARGS__)
 #include "cairo-boilerplate.h"
 
 #include <stdarg.h>
commit 5f816ccd25d1cd303fc1e9e44e80c1207b2a424a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jan 3 22:30:55 2009 +0000

    [boilerplate] Redefine DEBUG() for portability concerns
    
    Behdad warned that using an empty variadic macro was non-portable.

diff --git a/boilerplate/cairo-boilerplate-xlib.c b/boilerplate/cairo-boilerplate-xlib.c
index e9642e5..a4deeb7 100644
--- a/boilerplate/cairo-boilerplate-xlib.c
+++ b/boilerplate/cairo-boilerplate-xlib.c
@@ -108,11 +108,11 @@ _cairo_boilerplate_xlib_test_create_surface (Display			*dpy,
 	break;
     case CAIRO_CONTENT_ALPHA:
     default:
-	CAIRO_BOILERPLATE_DEBUG ("Invalid content for xlib test: %d\n", content);
+	CAIRO_BOILERPLATE_DEBUG (("Invalid content for xlib test: %d\n", content));
 	return NULL;
     }
     if (xrender_format == NULL) {
-	CAIRO_BOILERPLATE_DEBUG ("X server does not have the Render extension.\n");
+	CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n"));
 	return NULL;
     }
 
@@ -141,7 +141,7 @@ _cairo_boilerplate_xlib_perf_create_surface (Display			*dpy,
     case CAIRO_CONTENT_COLOR_ALPHA:
 	xrender_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
 	if (xrender_format == NULL) {
-	    CAIRO_BOILERPLATE_DEBUG ("X server does not have the Render extension.\n");
+	    CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n"));
 	    return NULL;
 	}
 
@@ -154,14 +154,14 @@ _cairo_boilerplate_xlib_perf_create_surface (Display			*dpy,
 	if (! _cairo_boilerplate_xlib_check_screen_size (dpy,
 		                                         DefaultScreen (dpy),
 		                                         width, height)) {
-	    CAIRO_BOILERPLATE_DEBUG ("Surface is larger than the Screen.\n");
+	    CAIRO_BOILERPLATE_DEBUG (("Surface is larger than the Screen.\n"));
 	    return NULL;
 	}
 
 	visual = DefaultVisual (dpy, DefaultScreen (dpy));
 	xrender_format = XRenderFindVisualFormat (dpy, visual);
 	if (xrender_format == NULL) {
-	    CAIRO_BOILERPLATE_DEBUG ("X server does not have the Render extension.\n");
+	    CAIRO_BOILERPLATE_DEBUG (("X server does not have the Render extension.\n"));
 	    return NULL;
 	}
 
@@ -175,7 +175,7 @@ _cairo_boilerplate_xlib_perf_create_surface (Display			*dpy,
 
     case CAIRO_CONTENT_ALPHA:
     default:
-	CAIRO_BOILERPLATE_DEBUG ("Invalid content for xlib test: %d\n", content);
+	CAIRO_BOILERPLATE_DEBUG (("Invalid content for xlib test: %d\n", content));
 	return NULL;
     }
 
@@ -210,7 +210,7 @@ _cairo_boilerplate_xlib_create_surface (const char			 *name,
     xtc->dpy = dpy = XOpenDisplay (NULL);
     if (xtc->dpy == NULL) {
 	free (xtc);
-	CAIRO_BOILERPLATE_DEBUG ("Failed to open display: %s\n", XDisplayName(0));
+	CAIRO_BOILERPLATE_DEBUG (("Failed to open display: %s\n", XDisplayName(0)));
 	return NULL;
     }
 
@@ -272,7 +272,7 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char			 *name,
 
     xtc->dpy = dpy = XOpenDisplay (NULL);
     if (xtc->dpy == NULL) {
-	CAIRO_BOILERPLATE_DEBUG ("Failed to open display: %s\n", XDisplayName(0));
+	CAIRO_BOILERPLATE_DEBUG (("Failed to open display: %s\n", XDisplayName(0)));
 	free (xtc);
 	return NULL;
     }
@@ -285,7 +285,7 @@ _cairo_boilerplate_xlib_fallback_create_surface (const char			 *name,
     screen = DefaultScreen (dpy);
     if (! _cairo_boilerplate_xlib_check_screen_size (dpy, screen,
 		                                     width, height)) {
-	CAIRO_BOILERPLATE_DEBUG ("Surface is larger than the Screen.\n");
+	CAIRO_BOILERPLATE_DEBUG (("Surface is larger than the Screen.\n"));
 	XCloseDisplay (dpy);
 	free (xtc);
 	return NULL;
diff --git a/boilerplate/cairo-boilerplate.h b/boilerplate/cairo-boilerplate.h
index b2d79a7..9f4b00c 100644
--- a/boilerplate/cairo-boilerplate.h
+++ b/boilerplate/cairo-boilerplate.h
@@ -75,7 +75,7 @@
 #endif
 
 #ifndef CAIRO_BOILERPLATE_DEBUG
-#define CAIRO_BOILERPLATE_DEBUG(...)
+#define CAIRO_BOILERPLATE_DEBUG(x)
 #endif
 
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)


More information about the cairo-commit mailing list