summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2018-03-12 13:33:03 +0800
committerBehdad Esfahbod <behdad@behdad.org>2018-03-23 15:52:33 -0700
commit19256bef9d264f96187261929992b96e61fa43fd (patch)
treeb44971159567a7063532666ae565a802bb722453
parent95f0458f44e9a7ec250f1bc7d9f060745dbabcf3 (diff)
hb-private.hh: Add fallback implementation for round()
For pre-C99 compilers that do not support round(), we need to have a simplistic implementation for it, when it is not detected during build configuration, either via CMake or autotools, by using floor() and ceil(), which are provided in the pre-C99 compilers. Please see discussion at commit 86a0ac2 for more details for re-adding this patch.
-rw-r--r--src/hb-private.hh13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/hb-private.hh b/src/hb-private.hh
index daa496e9..62a103cf 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -1070,4 +1070,17 @@ struct hb_string_t
};
+/* fallback for round() */
+#if !defined (HAVE_ROUND) && !defined (HAVE_DECL_ROUND)
+static inline double
+round (double x)
+{
+ if (x >= 0)
+ return floor (x + 0.5);
+ else
+ return ceil (x - 0.5);
+}
+#endif
+
+
#endif /* HB_PRIVATE_HH */