This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix .gitignore: only ignore 'perl' in root of repo, not U/perl subdir
[metaconfig.git] / U / perl / d_signbit.U
1 ?RCS: $Id$
2 ?RCS:
3 ?RCS: You may distribute under the terms of either the GNU General Public
4 ?RCS: License or the Artistic License, as specified in the README file.
5 ?RCS:
6 ?MAKE:d_signbit: nvtype Compile Setvar cat run rm_try echo n c i_math i_sunmath
7 ?MAKE:  -pick add $@ %<
8 ?S:d_signbit:
9 ?S:     This variable conditionally defines the HAS_SIGNBIT symbol, which
10 ?S:     indicates to the C program that the signbit() routine is available
11 ?S:     and safe to use with perl's intern NV type.
12 ?S:.
13 ?C:HAS_SIGNBIT:
14 ?C:     This symbol, if defined, indicates that the signbit routine is
15 ?C:     available to check if the given number has the sign bit set.
16 ?C:     This should include correct testing of -0.0.  This will only be set
17 ?C:     if the signbit() routine is safe to use with the NV type used internally
18 ?C:     in perl.  Users should call Perl_signbit(), which will be #defined to
19 ?C:     the system's signbit() function or macro if this symbol is defined.
20 ?C:.
21 ?H:#$d_signbit HAS_SIGNBIT              /**/
22 ?H:.
23 ?F:!try
24 ?LINT:set d_signbit
25 : see if signbit exists
26 $echo $n "Checking to see if you have signbit() available to work on $nvtype... $c" >&4
27 $cat >try.c <<EOCP
28 #$i_math I_MATH
29 #$i_sunmath I_SUNMATH
30 #ifdef I_MATH
31 #  include <math.h>
32 #endif
33 #ifdef I_SUNMATH  /* Solaris special math library */
34 #  include <sunmath.h>
35 #endif
36 #define NV $nvtype
37 int main(int argc, char **argv)
38 {
39     NV x = 0.0;
40     NV y = -1.0;
41     if ((signbit(x) == 0) && (signbit(y) != 0))
42         return 0;
43     else
44         return 1;
45 }
46 EOCP
47 val="$undef"
48 set try
49 if eval $compile; then
50     if $run ./try; then
51         $echo "Yes." >&4
52         val="$define"
53     else
54         $echo "Signbit seems to be available, but doesn't work as I expected."
55         $echo "I won't use it." >&4
56         val="$undef"
57     fi
58 else
59     $echo "Nope." >&4
60     dflt="$undef"
61 fi
62 set d_signbit
63 eval $setvar
64 $rm_try
65