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
CommitLineData
f59d7982
AD
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:
2cb64bf6 6?MAKE:d_signbit: nvtype Compile Setvar cat run rm_try echo n c i_math i_sunmath
f59d7982
AD
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:.
0065f4af 23?F:!try
4c42341b 24?LINT:set d_signbit
f59d7982
AD
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
37int main(int argc, char **argv)
38{
39 NV x = 0.0;
66d157b9 40 NV y = -1.0;
f59d7982
AD
41 if ((signbit(x) == 0) && (signbit(y) != 0))
42 return 0;
43 else
44 return 1;
45}
46EOCP
47val="$undef"
48set try
49if 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
58else
59 $echo "Nope." >&4
60 dflt="$undef"
61fi
62set d_signbit
63eval $setvar
2cb64bf6 64$rm_try
f59d7982 65