[glib/gnulib.msvc.fixes: 16/19] build: Improve tests for frexpl() and ldexpl()



commit e3b01ef3c335ce62d608cfd2c741d863db40b2fb
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Mar 28 17:55:59 2019 +0800

    build: Improve tests for frexpl() and ldexpl()
    
    The test programs for those in the Meson build files will not work for
    Visual Studio prior to 2013 (whereas the rest of the code does).
    Improve the tests for these by:
    
    -Adding a test to see whether we can re-define a prototype for these
     functions, using cc.compiles().  If so, set HAVE_DECL_xxxx to be 0,
     otherwise set HAVE_DECL_xxxx to be 1.
    
    Also, for glib/gnulib/frexpl.c, don't undefine frexpl on Visual Studio,
    otherwise we will not be able to compile/link it on Visual Studio
    compilers.

 glib/gnulib/frexpl.c                            |  2 ++
 glib/gnulib/gl_cv_func_frexpl_works/meson.build | 12 ++++++++++++
 glib/gnulib/gl_cv_func_ldexpl_works/meson.build | 12 ++++++++++++
 glib/gnulib/meson.build                         |  2 ++
 4 files changed, 28 insertions(+)
---
diff --git a/glib/gnulib/frexpl.c b/glib/gnulib/frexpl.c
index 5736dc848..cd6a81c77 100644
--- a/glib/gnulib/frexpl.c
+++ b/glib/gnulib/frexpl.c
@@ -14,6 +14,8 @@ long double rpl_frexpl (long double x, int *expptr)
     return x;
   else if (isinf (x))
     return x;
+#ifndef _MSC_VER
 #undef frexpl
+#endif
   return frexpl (x, expptr);
 }
diff --git a/glib/gnulib/gl_cv_func_frexpl_works/meson.build b/glib/gnulib/gl_cv_func_frexpl_works/meson.build
index c37b741db..303ec63d7 100644
--- a/glib/gnulib/gl_cv_func_frexpl_works/meson.build
+++ b/glib/gnulib/gl_cv_func_frexpl_works/meson.build
@@ -29,7 +29,11 @@ extern
 #ifdef __cplusplus
 "C"
 #endif
+
+#if !defined (_MSC_VER) || defined (TEST_FREXPL_DECL)
 long double frexpl (long double, int *);
+#endif
+
 int main()
 {
   int result = 0;
@@ -128,3 +132,11 @@ else
     gl_cv_func_frexpl_broken_beyond_repair = false
   endif
 endif
+
+frexpl_test_decl = '''
+#define TEST_FREXPL_DECL 1
+''' + frexpl_test
+
+build_result = cc.compiles(frexpl_test_decl,
+    name : 'frexpl prototype can be re-listed')
+gl_cv_func_frexpl_decl = build_result
diff --git a/glib/gnulib/gl_cv_func_ldexpl_works/meson.build b/glib/gnulib/gl_cv_func_ldexpl_works/meson.build
index dc83675ed..ae176cb8e 100644
--- a/glib/gnulib/gl_cv_func_ldexpl_works/meson.build
+++ b/glib/gnulib/gl_cv_func_ldexpl_works/meson.build
@@ -9,7 +9,11 @@ extern
 #ifdef __cplusplus
 "C"
 #endif
+
+#if !defined (_MSC_VER) || defined (TEST_LDEXPL_DECL)
 long double ldexpl (long double, int);
+#endif
+
 int main()
 {
   int result = 0;
@@ -43,3 +47,11 @@ else
     gl_cv_func_ldexpl_works = true
   endif
 endif
+
+ldexpl_test_decl = '''
+#define TEST_LDEXPL_DECL 1
+''' + ldexpl_test
+
+build_result = cc.compiles(ldexpl_test_decl,
+    name : 'ldexpl prototype can be re-listed')
+gl_cv_func_ldexpl_decl = build_result
diff --git a/glib/gnulib/meson.build b/glib/gnulib/meson.build
index 60499d9b7..2d369a6ef 100644
--- a/glib/gnulib/meson.build
+++ b/glib/gnulib/meson.build
@@ -282,6 +282,7 @@ endif
 
 math_h_config.set ('REPLACE_FREXP', gl_cv_func_frexp_works ? 0 : 1)
 math_h_config.set ('REPLACE_FREXPL', gl_cv_func_frexpl_works ? 0 : 1)
+math_h_config.set ('HAVE_DECL_FREXPL', gl_cv_func_frexpl_decl ? 0 : 1)
 
 math_h_config.set ('REPLACE_ITOLD', 0)
 math_h_config.set ('REPLACE_HUGE_VAL', 0)
@@ -293,6 +294,7 @@ else
   gl_cv_func_ldexpl_works = false
 endif
 math_h_config.set ('REPLACE_LDEXPL', gl_cv_func_ldexpl_works ? 0 : 1)
+math_h_config.set ('HAVE_DECL_LDEXPL', gl_cv_func_ldexpl_decl ? 0 : 1)
 
 math_h = configure_file (input: 'gnulib_math.h.in',
                          output: 'gnulib_math.h',


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