[glib: 1/2] meson: Fix the gnulib checks for isnan* functions
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] meson: Fix the gnulib checks for isnan* functions
- Date: Fri, 1 May 2020 16:47:57 +0000 (UTC)
commit fcc7489d465a0e6152e9f5ab0997266df357e83b
Author: Martin Storsjö <martin martin st>
Date: Sat Apr 25 21:10:15 2020 +0300
meson: Fix the gnulib checks for isnan* functions
The gnulib math code uses __builtin_isnanf and __builtin_isnanl
within the __GNUC__ >= 4 ifdef, and clang doesn't provide those
builtins, only the one without a suffix. Make the meson check
match the code it controls, using the exactly right builtins.
Set REPLACE_ISNAN to 1 if either of the have_isnan* functions failed,
this matches how gnulib's m4 routines does it (in gnulib/m4/isnan.m4).
This fixes the isnan functions in the gnulib math header replacement
work on Clang.
glib/gnulib/meson.build | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/glib/gnulib/meson.build b/glib/gnulib/meson.build
index e45e8c2f4..86e0bcbdd 100644
--- a/glib/gnulib/meson.build
+++ b/glib/gnulib/meson.build
@@ -182,7 +182,7 @@ endforeach
nan_tmpl = '''#include <math.h>
#if __GNUC__ >= 4
# undef @0@
- # define @0@(x) __builtin_isnan ((@1@)(x))
+ # define @0@(x) @2@ ((@1@)(x))
#else
# undef @0@
# define @0@(x) isnan ((@1@)(x))
@@ -191,18 +191,29 @@ nan_tmpl = '''#include <math.h>
int main () {return @0@ (x);}
'''
-links = cc.links (nan_tmpl.format ('isnand', 'double'),
+links = cc.links (nan_tmpl.format ('isnan', 'double', '__builtin_isnan'),
dependencies : [libm])
+math_h_config.set ('HAVE_ISNAN', links ? 1 : 0)
+math_h_config.set ('HAVE_ISNAN_IN_LIBC', links ? 1 : 0)
+set_variable ('have_isnan', links)
math_h_config.set ('HAVE_ISNAND', links ? 1 : 0)
math_h_config.set ('HAVE_ISNAND_IN_LIBC', links ? 1 : 0)
set_variable ('have_isnand', links)
-links = cc.links (nan_tmpl.format ('isnanl', 'long double'),
+links = cc.links (nan_tmpl.format ('isnanf', 'float', '__builtin_isnanf'),
+ dependencies : [libm])
+math_h_config.set ('HAVE_ISNANF', links ? 1 : 0)
+math_h_config.set ('HAVE_ISNANF_IN_LIBC', links ? 1 : 0)
+set_variable ('have_isnanf', links)
+
+links = cc.links (nan_tmpl.format ('isnanl', 'long double', '__builtin_isnanl'),
dependencies : [libm])
math_h_config.set ('HAVE_ISNANL', links ? 1 : 0)
math_h_config.set ('HAVE_ISNANL_IN_LIBC', links ? 1 : 0)
set_variable ('have_isnanl', links)
+math_h_config.set ('REPLACE_ISNAN', (have_isnand and have_isnanf and have_isnanl) ? 0 : 1)
+
links = cc.links ('''#include <math.h>
double x;
int y;
@@ -303,7 +314,7 @@ inf_tmpl = '''#include <math.h>
other_needed_math_sources = []
# Some compilers may not have isfinite, isinf available
-foreach f: ['isfinite', 'isinf', 'isnan', 'isnanf', 'signbit']
+foreach f: ['isfinite', 'isinf', 'signbit']
links = cc.links (inf_tmpl.format('@0@'.format(f)),
dependencies : [libm])
math_h_config.set ('HAVE_@0@'.format(f.to_upper()), links ? 1 : 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]