[gtk/check-for-sincosf] build: Check for sincosf()



commit 962951c7350076bbe83a445bbbd0312d14c12d68
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Jan 8 17:05:44 2020 +0800

    build: Check for sincosf()
    
    sincosf() is really a GCC-specific function that may more may not be
    supported on non-GCC compilers, so we want to check for it, otherwise we
    use a fallback implementation, not unlike the one in
    demos/gtk-demo/gtkgears.c.

 gsk/gsktransform.c | 10 +++++++++-
 meson.build        |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/gsk/gsktransform.c b/gsk/gsktransform.c
index 3f944db9ea..c915ec0991 100644
--- a/gsk/gsktransform.c
+++ b/gsk/gsktransform.c
@@ -712,7 +712,15 @@ _sincos (float  deg,
     }
   else
     {
-      sincosf (deg * M_PI / 180.0, out_s, out_c);
+      float angle = deg * M_PI;
+
+#ifdef HAVE_SINCOSF
+      sincosf (angle / 180.0, out_s, out_c);
+#else
+      *out_s = sinf (angle);
+      *out_c = cosf (angle);
+#endif
+
     }
 }
 
diff --git a/meson.build b/meson.build
index c07ae0340e..22a211c4fc 100644
--- a/meson.build
+++ b/meson.build
@@ -198,6 +198,7 @@ check_functions = [
   'log2',
   'exp2',
   'sincos',
+  'sincosf',
 ]
 
 foreach func : check_functions


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]