diff options
-rw-r--r-- | config.h.win32.in | 10 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | gdk-pixbuf/Makefile.am | 3 | ||||
-rwxr-xr-x | gdk-pixbuf/fallback-c89.c | 49 | ||||
-rw-r--r-- | gdk-pixbuf/io-jpeg.c | 1 | ||||
-rw-r--r-- | gdk-pixbuf/io-png.c | 3 | ||||
-rw-r--r-- | gdk-pixbuf/io-tiff.c | 1 | ||||
-rw-r--r-- | gdk-pixbuf/pixops/pixops.c | 1 |
8 files changed, 68 insertions, 3 deletions
diff --git a/config.h.win32.in b/config.h.win32.in index 9a8640b5b..1aaa149f0 100644 --- a/config.h.win32.in +++ b/config.h.win32.in @@ -41,12 +41,22 @@ /*#define HAVE_INTTYPES_H*/ #endif +/* Define to 1 if lrint() is available */ +#if !defined (_MSC_VER) || (_MSC_VER >= 1800) +#define HAVE_LRINT 1 +#endif + /* Define to 1 if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 is libjpeg supports progressive JPEG */ #define HAVE_PROGRESSIVE_JPEG 1 +/* Define to 1 if round() is available */ +#if !defined (_MSC_VER) || (_MSC_VER >= 1800) +#define HAVE_ROUND 1 +#endif + /* Define to 1 if sigsetjmp is available */ /*#undef HAVE_SIGSETJMP*/ diff --git a/configure.ac b/configure.ac index 491a9b5bf..5bab06144 100644 --- a/configure.ac +++ b/configure.ac @@ -424,6 +424,9 @@ AC_CHECK_FUNCS(setrlimit) saved_cflags="$CFLAGS" saved_ldflags="$LDFLAGS" +AC_CHECK_LIB(m,round,) +AC_CHECK_LIB(m,lrint,) +AC_CHECK_FUNCS(round lrint) # Checks for header files. AC_HEADER_STDC diff --git a/gdk-pixbuf/Makefile.am b/gdk-pixbuf/Makefile.am index a3189857b..691cb78a0 100644 --- a/gdk-pixbuf/Makefile.am +++ b/gdk-pixbuf/Makefile.am @@ -595,7 +595,8 @@ EXTRA_DIST = \ gdk-pixbuf-enum-types.c.template \ gdk-pixbuf-enum-types.h.template \ gen-color-table.pl \ - gdiplus.def + gdiplus.def \ + fallback-c89.c # ---------- MSVC Items ------------------ diff --git a/gdk-pixbuf/fallback-c89.c b/gdk-pixbuf/fallback-c89.c new file mode 100755 index 000000000..f2078ff16 --- /dev/null +++ b/gdk-pixbuf/fallback-c89.c @@ -0,0 +1,49 @@ +/* GTK - The GIMP Toolkit + * Copyright (C) 2011 Chun-wei Fan <fanc999@yahoo.com.tw> + * + * Author: Chun-wei Fan <fanc999@yahoo.com.tw> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <math.h> + +/* Workaround for round() for non-GCC/non-C99 compilers */ +#ifndef HAVE_ROUND +static inline double +round (double x) +{ + if (x >= 0) + return floor (x + 0.5); + else + return ceil (x - 0.5); +} +#endif + +/* Workaround for lrint() for non-GCC/non-C99 compilers */ +#ifndef HAVE_LRINT +static inline long +lrint (double x) +{ + if (ceil (x + 0.5) == floor (x + 0.5)) + { + if (x < 1 && x > -1) + return 0; + + return (int) ceil (x) % 2 == 0 ? ceil (x) : floor (x); + } + else + return x >= 0 ? floor (x + 0.5) : ceil (x - 0.5); +} +#endif
\ No newline at end of file diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c index 96f993f40..92ec36b47 100644 --- a/gdk-pixbuf/io-jpeg.c +++ b/gdk-pixbuf/io-jpeg.c @@ -35,6 +35,7 @@ #include <math.h> #include "gdk-pixbuf-private.h" +#include "fallback-c89.c" #ifndef HAVE_SIGSETJMP #define sigjmp_buf jmp_buf diff --git a/gdk-pixbuf/io-png.c b/gdk-pixbuf/io-png.c index a9fc1f6bf..759e78a1f 100644 --- a/gdk-pixbuf/io-png.c +++ b/gdk-pixbuf/io-png.c @@ -28,8 +28,7 @@ #include <png.h> #include <math.h> #include "gdk-pixbuf-private.h" - - +#include "fallback-c89.c" static gboolean setup_png_transformations(png_structp png_read_ptr, png_infop png_info_ptr, diff --git a/gdk-pixbuf/io-tiff.c b/gdk-pixbuf/io-tiff.c index 62f25313a..4d10ef094 100644 --- a/gdk-pixbuf/io-tiff.c +++ b/gdk-pixbuf/io-tiff.c @@ -36,6 +36,7 @@ #include <tiffio.h> #include <errno.h> #include "gdk-pixbuf-private.h" +#include "fallback-c89.c" #ifdef G_OS_WIN32 #include <fcntl.h> diff --git a/gdk-pixbuf/pixops/pixops.c b/gdk-pixbuf/pixops/pixops.c index dc1b46152..f91f0e339 100644 --- a/gdk-pixbuf/pixops/pixops.c +++ b/gdk-pixbuf/pixops/pixops.c @@ -21,6 +21,7 @@ #include <math.h> #include <glib.h> +#include "../fallback-c89.c" #include "pixops.h" #include "pixops-internal.h" |