From 0586daaa2927bfde9605487eef8e9b95c49d7d2f Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Fri, 5 Aug 2005 07:48:18 +0000 Subject: [PATCH] Patch from John Ehresman to aid win32 compilation: Define snprintf as _snprintf when under the influence of _MSC_VER. Define int32_t and friends as __int32 and friends when under the influence of _MSC_VER. Make include of unistd.h conditional on HAVE_UNISTD_H. --- ChangeLog | 16 ++++++++++++++++ src/cairo-output-stream.c | 4 ++++ src/cairo-wideint.h | 14 +++++++++++++- test/buffer-diff.c | 2 ++ test/cairo-test.c | 6 ++++++ test/read-png.c | 14 +++++++++++++- 6 files changed, 54 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe987515a..c553f87dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-08-05 Carl Worth + + Patch from John Ehresman to aid win32 + compilation: + + * src/cairo-output-stream.c: Define snprintf as _snprintf when + under the influence of _MSC_VER. + + * test/read-png.c: (read_png_argb32): + * src/cairo-wideint.h: Define int32_t and friends as __int32 and + friends when under the influence of _MSC_VER. + + * test/buffer-diff.c: + * test/cairo-test.c: Make include of unistd.h conditional on + HAVE_UNISTD_H. + 2005-08-05 Kristian Høgsberg Patch from Adrian Johnson diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c index 17ef7e2cb..afb4d428d 100644 --- a/src/cairo-output-stream.c +++ b/src/cairo-output-stream.c @@ -39,6 +39,10 @@ #include #include "cairoint.h" +#ifdef _MSC_VER +#define snprintf _snprintf +#endif /* _MSC_VER */ + struct _cairo_output_stream { cairo_write_func_t write_data; void *closure; diff --git a/src/cairo-wideint.h b/src/cairo-wideint.h index 8870df7bc..b008b5d5a 100644 --- a/src/cairo-wideint.h +++ b/src/cairo-wideint.h @@ -1,5 +1,5 @@ /* - * $Id: cairo-wideint.h,v 1.11 2005-07-30 19:57:54 keithp Exp $ + * $Id: cairo-wideint.h,v 1.12 2005-08-05 14:48:19 cworth Exp $ * * Copyright © 2004 Keith Packard * @@ -44,6 +44,18 @@ # include #elif HAVE_SYS_INT_TYPES_H # include +#elif defined(_MSC_VER) + typedef __int8 int8_t; + typedef unsigned __int8 uint8_t; + typedef __int16 int16_t; + typedef unsigned __int16 uint16_t; + typedef __int32 int32_t; + typedef unsigned __int32 uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; +# ifndef HAVE_UINT64_T +# define HAVE_UINT64_T 1 +# endif #else #error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.) #endif diff --git a/test/buffer-diff.c b/test/buffer-diff.c index e5ba513ac..967ab4244 100644 --- a/test/buffer-diff.c +++ b/test/buffer-diff.c @@ -24,7 +24,9 @@ * Author: Richard D. Worth */ #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include diff --git a/test/cairo-test.c b/test/cairo-test.c index aff2125b8..136252ced 100644 --- a/test/cairo-test.c +++ b/test/cairo-test.c @@ -26,7 +26,9 @@ #include #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include #include @@ -38,6 +40,10 @@ #include "write-png.h" #include "xmalloc.h" +#ifdef _MSC_VER +#define vsnprintf _vsnprintf +#endif + #define CAIRO_TEST_LOG_SUFFIX ".log" #define CAIRO_TEST_PNG_SUFFIX "-out.png" #define CAIRO_TEST_REF_SUFFIX "-ref.png" diff --git a/test/read-png.c b/test/read-png.c index 96259dfe8..ff311c283 100644 --- a/test/read-png.c +++ b/test/read-png.c @@ -35,6 +35,18 @@ # include #elif HAVE_SYS_INT_TYPES_H # include +#elif defined(_MSC_VER) + typedef __int8 int8_t; + typedef unsigned __int8 uint8_t; + typedef __int16 int16_t; + typedef unsigned __int16 uint16_t; + typedef __int32 int32_t; + typedef unsigned __int32 uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; +# ifndef HAVE_UINT64_T +# define HAVE_UINT64_T 1 +# endif #else #error Cannot find definitions for fixed-width integral types (uint8_t, uint32_t, etc.) #endif @@ -79,7 +91,7 @@ read_png_argb32 (const char *filename, { int i; FILE *file; - static const int PNG_SIG_SIZE = 8; +#define PNG_SIG_SIZE 8 unsigned char png_sig[PNG_SIG_SIZE]; int sig_bytes; png_struct *png;