Bug 684049 - cairoint.h should only use lround in C99 programs; r=jrmuizel
authorEhsan Akhgari <ehsan@mozilla.com>
Thu, 01 Sep 2011 17:46:52 -0400
changeset 76421 4e76b1e5c1d1e28ee14779e8c3b32e9a1c7d4057
parent 76420 e6fc4594c22eff5fb29eaf616129f81b1022bbb4
child 76422 ca798b7e74efc33b5e20f0bcdf2fa2862d6e458d
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjrmuizel
bugs684049
milestone9.0a1
Bug 684049 - cairoint.h should only use lround in C99 programs; r=jrmuizel
gfx/cairo/README
gfx/cairo/cairo/src/cairo-misc.c
gfx/cairo/cairo/src/cairoint.h
gfx/cairo/lround-c99-only.patch
--- a/gfx/cairo/README
+++ b/gfx/cairo/README
@@ -167,16 +167,18 @@ fix-cairo-win32-print-gdi-error.diff: Do
 pixman-image-transform.patch: Reset the transform on pixman images when using them as destinations.
 
 fix-cairo-surface-wrapper-flush-build-warning.patch: Ensures that _cairo_surface_wrapper_flush always returns a status, to silence the build warning
 
 fixup-unbounded.patch: Hack to work around bad assumption.
 
 quartz-get-image-performance: Make cairo_quartz_get_image faster in the failure case by not flushing unless we are going to succeed.
 
+lround-c99-only.patch: Only use lround in C99 programs.
+
 ==== pixman patches ====
 
 pixman-android-cpu-detect.patch: Add CPU detection support for Android, where we can't reliably access /proc/self/auxv.
 
 pixman-rename-and-endian.patch: include cairo-platform.h for renaming of external symbols and endian macros
 
 NOTE: we previously supported ARM assembler on MSVC, this has been removed because of the maintenance burden
 
--- a/gfx/cairo/cairo/src/cairo-misc.c
+++ b/gfx/cairo/cairo/src/cairo-misc.c
@@ -478,17 +478,17 @@ uint32_t
     case CAIRO_OPERATOR_IN:
     case CAIRO_OPERATOR_DEST_IN:
     case CAIRO_OPERATOR_DEST_ATOP:
 	return 0;
     }
 
 }
 
-#if DISABLE_SOME_FLOATING_POINT
+#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
 /* This function is identical to the C99 function lround(), except that it
  * performs arithmetic rounding (floor(d + .5) instead of away-from-zero rounding) and
  * has a valid input range of (INT_MIN, INT_MAX] instead of
  * [INT_MIN, INT_MAX]. It is much faster on both x86 and FPU-less systems
  * than other commonly used methods for rounding (lround, round, rint, lrint
  * or float (d + 0.5)).
  *
  * The reason why this function is much faster on x86 than other
--- a/gfx/cairo/cairo/src/cairoint.h
+++ b/gfx/cairo/cairo/src/cairoint.h
@@ -969,17 +969,17 @@ static inline double cairo_const
  * away from 0. _cairo_round rounds halfway cases toward negative infinity.
  * This matches the rounding behaviour of _cairo_lround. */
 static inline double cairo_const
 _cairo_round (double r)
 {
     return floor (r + .5);
 }
 
-#if DISABLE_SOME_FLOATING_POINT
+#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
 cairo_private int
 _cairo_lround (double d) cairo_const;
 #else
 #define _cairo_lround lround
 #endif
 
 cairo_private uint16_t
 _cairo_half_from_float (float f) cairo_const;
new file mode 100644
--- /dev/null
+++ b/gfx/cairo/lround-c99-only.patch
@@ -0,0 +1,46 @@
+Only use lround in C99 programs.
+
+diff --git a/gfx/cairo/cairo/src/cairo-misc.c b/gfx/cairo/cairo/src/cairo-misc.c
+--- a/gfx/cairo/cairo/src/cairo-misc.c
++++ b/gfx/cairo/cairo/src/cairo-misc.c
+@@ -478,17 +478,17 @@ _cairo_operator_bounded_by_either (cairo
+     case CAIRO_OPERATOR_IN:
+     case CAIRO_OPERATOR_DEST_IN:
+     case CAIRO_OPERATOR_DEST_ATOP:
+ 	return 0;
+     }
+ 
+ }
+ 
+-#if DISABLE_SOME_FLOATING_POINT
++#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
+ /* This function is identical to the C99 function lround(), except that it
+  * performs arithmetic rounding (floor(d + .5) instead of away-from-zero rounding) and
+  * has a valid input range of (INT_MIN, INT_MAX] instead of
+  * [INT_MIN, INT_MAX]. It is much faster on both x86 and FPU-less systems
+  * than other commonly used methods for rounding (lround, round, rint, lrint
+  * or float (d + 0.5)).
+  *
+  * The reason why this function is much faster on x86 than other
+diff --git a/gfx/cairo/cairo/src/cairoint.h b/gfx/cairo/cairo/src/cairoint.h
+--- a/gfx/cairo/cairo/src/cairoint.h
++++ b/gfx/cairo/cairo/src/cairoint.h
+@@ -969,17 +969,17 @@ _cairo_restrict_value (double value, dou
+  * away from 0. _cairo_round rounds halfway cases toward negative infinity.
+  * This matches the rounding behaviour of _cairo_lround. */
+ static inline double cairo_const
+ _cairo_round (double r)
+ {
+     return floor (r + .5);
+ }
+ 
+-#if DISABLE_SOME_FLOATING_POINT
++#if DISABLE_SOME_FLOATING_POINT || __STDC_VERSION__ < 199901L
+ cairo_private int
+ _cairo_lround (double d) cairo_const;
+ #else
+ #define _cairo_lround lround
+ #endif
+ 
+ cairo_private uint16_t
+ _cairo_half_from_float (float f) cairo_const;