This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Metaconfig unit change for #11027.
[metaconfig.git] / U / perl / d_modfl.U
1 ?RCS: $Id$
2 ?RCS:
3 ?RCS: Copyright (c) 2000 Jarkko Hietaniemi
4 ?RCS:
5 ?RCS: You may distribute under the terms of either the GNU General Public
6 ?RCS: License or the Artistic License, as specified in the README file.
7 ?RCS:
8 ?MAKE:d_modfl d_modfl_pow32_bug: Inlibc Compile cat rm sPRIfldbl d_longdbl \
9         osname gccversion ccflags run
10 ?MAKE:  -pick add $@ %<
11 ?S:d_modfl:
12 ?S:     This variable conditionally defines the HAS_MODFL symbol, which
13 ?S:     indicates to the C program that the modfl() routine is available.
14 ?S:.
15 ?S:d_modfl_pow32_bug:
16 ?S:     This variable conditionally defines the HAS_MODFL_POW32_BUG symbol,
17 ?S:     which indicates that modfl() is broken for long doubles >= pow(2, 32).
18 ?S:     For example from 4294967303.150000 one would get 4294967302.000000
19 ?S:     and 1.150000.  The bug has been seen in certain versions of glibc,
20 ?S:     release 2.2.2 is known to be okay.
21 ?S:.
22 ?C:HAS_MODFL:
23 ?C:     This symbol, if defined, indicates that the modfl routine is
24 ?C:     available to split a long double x into a fractional part f and
25 ?C:     an integer part i such that |f| < 1.0 and (f + i) = x.
26 ?C:.
27 ?C:HAS_MODFL_POW32_BUG:
28 ?C:     This symbol, if defined, indicates that the modfl routine is
29 ?C:     broken for long doubles >= pow(2, 32).
30 ?C:     For example from 4294967303.150000 one would get 4294967302.000000
31 ?C:     and 1.150000.  The bug has been seen in certain versions of glibc,
32 ?C:     release 2.2.2 is known to be okay.
33 ?C:.
34 ?H:#$d_modfl HAS_MODFL          /**/
35 ?H:#$d_modfl_pow32_bug HAS_MODFL_POW32_BUG              /**/
36 ?H:.
37 ?T:foo saveccflags
38 ?LINT:set d_modfl
39 ?LINT:set d_modfl_pow32_bug
40 ?LINT:change ccflags
41 : see if modfl exists
42 set modfl d_modfl
43 eval $inlibc
44
45 d_modfl_pow32_bug="$undef"
46
47 case "$d_longdbl$d_modfl" in
48 $define$define)
49         $cat <<EOM
50 Checking to see whether your modfl() is okay for large values...
51 EOM
52 $cat >try.c <<EOCP
53 #include <math.h> 
54 #include <stdio.h>
55 int main() {
56     long double nv = 4294967303.15;
57     long double v, w;
58     v = modfl(nv, &w);         
59 #ifdef __GLIBC__
60     printf("glibc");
61 #endif
62     printf(" %"$sPRIfldbl" %"$sPRIfldbl" %"$sPRIfldbl"\n", nv, v, w);
63     return 0;
64 }
65 EOCP
66         case "$osname:$gccversion" in
67         aix:)   saveccflags="$ccflags"
68                 ccflags="$ccflags -qlongdouble" ;; # to avoid core dump
69         esac
70         set try
71         if eval $compile; then
72                 foo=`$run ./try`
73                 case "$foo" in
74                 *" 4294967303.150000 1.150000 4294967302.000000")
75                         echo >&4 "Your modfl() is broken for large values."
76                         d_modfl_pow32_bug="$define"
77                         case "$foo" in
78                         glibc)  echo >&4 "You should upgrade your glibc to at least 2.2.2 to get a fixed modfl()."
79                         ;;
80                         esac
81                         ;;
82                 *" 4294967303.150000 0.150000 4294967303.000000")
83                         echo >&4 "Your modfl() seems okay for large values."
84                         ;;
85                 *)      echo >&4 "I don't understand your modfl() at all."
86                         d_modfl="$undef"
87                         ;;
88                 esac
89                 $rm -f try.* try core core.try.*
90         else
91                 echo "I cannot figure out whether your modfl() is okay, assuming it isn't."
92                 d_modfl="$undef"
93         fi
94         case "$osname:$gccversion" in
95         aix:)   ccflags="$saveccflags" ;; # restore
96         esac
97         ;;
98 esac
99