[gdk-pixbuf] Visual Studio Builds: Provide Implementation for round()
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gdk-pixbuf] Visual Studio Builds: Provide Implementation for round()
- Date: Tue, 23 Dec 2014 08:06:33 +0000 (UTC)
commit f09c022ff8164fb2521107edaed046b541dd7b3b
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Tue Dec 23 13:03:12 2014 +0800
Visual Studio Builds: Provide Implementation for round()
Visual Studio 2012 and earlier do not provide round() in their CRTs, so
use the round() implementation in GTK+-3.x and add it in a compatibility
math.h header that is strictly for Visual Studio only, and let the Visual
Studio builds find this math.h first (which would then include the stock
math.h).
https://bugzilla.gnome.org/show_bug.cgi?id=739778
build/win32/Makefile.am | 2 +
build/win32/math-compat/math.h | 58 ++++++++++++++++++++++
build/win32/vs10/gdk-pixbuf-build-defines.props | 2 +-
build/win32/vs9/gdk-pixbuf-build-defines.vsprops | 2 +-
4 files changed, 62 insertions(+), 2 deletions(-)
---
diff --git a/build/win32/Makefile.am b/build/win32/Makefile.am
index cd43acb..f2f3f03 100644
--- a/build/win32/Makefile.am
+++ b/build/win32/Makefile.am
@@ -4,4 +4,6 @@ SUBDIRS = \
vs11 \
vs12
+EXTRA_DIST = math-compat/math.h
+
-include $(top_srcdir)/git.mk
diff --git a/build/win32/math-compat/math.h b/build/win32/math-compat/math.h
new file mode 100644
index 0000000..a442179
--- /dev/null
+++ b/build/win32/math-compat/math.h
@@ -0,0 +1,58 @@
+/* GdkPixbuf library - Compatibility Math Header for
+ * pre-Visual Studio 2013 Headers
+ * to Build GDK-Pixbuf
+ *
+ * Copyright (C) 2014 Chun-wei Fan
+ *
+ * Authors: 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/>.
+ */
+
+#ifndef _MSC_VER
+#error "This Header is intended for Visual Studio Builds only"
+#endif
+
+/* Include the stock Visual Studio math.h first */
+#include <../include/math.h>
+
+/* Visual Studio 2013 and later do not need this compatibility item */
+#if (_MSC_VER < 1800)
+
+#ifndef __MSVC_MATH_COMPAT_H__
+#define __MSVC_MATH_COMPAT_H__
+
+/* Note: This is a rather generic fallback implementation for round(), which is
+ * okay for the purposes for GTK+, but please note the following if intending
+ * use this implementation:
+ *
+ * -The largest floating point value strictly less than 0.5. The problem is
+ * that the addition produces 1 due to rounding.
+ *
+ * -A set of large integers near 2^52 for which adding 0.5 is the same as
+ * adding 1, again due to rounding.
+ */
+
+static __inline double
+round (double x)
+{
+ if (x >= 0)
+ return floor (x + 0.5);
+ else
+ return ceil (x - 0.5);
+}
+
+#endif /* __MSVC_MATH_COMPAT_H__ */
+
+#endif /* _MSC_VER < 1800 */
\ No newline at end of file
diff --git a/build/win32/vs10/gdk-pixbuf-build-defines.props b/build/win32/vs10/gdk-pixbuf-build-defines.props
index 6904cb0..9e94b68 100644
--- a/build/win32/vs10/gdk-pixbuf-build-defines.props
+++ b/build/win32/vs10/gdk-pixbuf-build-defines.props
@@ -21,7 +21,7 @@
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
-
<AdditionalIncludeDirectories>..\..\..;..\..\..\gdk-pixbuf;$(GlibEtcInstallRoot)\include\glib-2.0;$(GlibEtcInstallRoot)\lib\glib-2.0\include;$(GlibEtcInstallRoot)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+
<AdditionalIncludeDirectories>..\..\..;..\..\..\gdk-pixbuf;..\math-compat;$(GlibEtcInstallRoot)\include\glib-2.0;$(GlibEtcInstallRoot)\lib\glib-2.0\include;$(GlibEtcInstallRoot)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_CONFIG_H;G_DISABLE_SINGLE_INCLUDES;GDK_PIXBUF_DISABLE_SINGLE_INCLUDES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ForcedIncludeFiles>msvc_recommended_pragmas.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
</ClCompile>
diff --git a/build/win32/vs9/gdk-pixbuf-build-defines.vsprops
b/build/win32/vs9/gdk-pixbuf-build-defines.vsprops
index 60ea797..2dc9fac 100644
--- a/build/win32/vs9/gdk-pixbuf-build-defines.vsprops
+++ b/build/win32/vs9/gdk-pixbuf-build-defines.vsprops
@@ -9,7 +9,7 @@
>
<Tool
Name="VCCLCompilerTool"
-
AdditionalIncludeDirectories="..\..\..;..\..\..\gdk-pixbuf;$(GlibEtcInstallRoot)\include\glib-2.0;$(GlibEtcInstallRoot)\lib\glib-2.0\include;$(GlibEtcInstallRoot)\include"
+
AdditionalIncludeDirectories="..\..\..;..\..\..\gdk-pixbuf;..\math-compat;$(GlibEtcInstallRoot)\include\glib-2.0;$(GlibEtcInstallRoot)\lib\glib-2.0\include;$(GlibEtcInstallRoot)\include"
PreprocessorDefinitions="HAVE_CONFIG_H;G_DISABLE_SINGLE_INCLUDES;GDK_PIXBUF_DISABLE_SINGLE_INCLUDES"
ForcedIncludeFiles="msvc_recommended_pragmas.h"
/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]