Skip to content

Commit 2f799c0

Browse files
committed
isinf and isnan are macros, not functions; fix configure script
to use AC_CHECK_DECLS instead of AC_CHECK_FUNCS for these. (See discussion in issue #4506)
1 parent a698de2 commit 2f799c0

5 files changed

Lines changed: 224 additions & 16 deletions

File tree

Include/pymath.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ extern double copysign(double, double);
8787
* Note: PC/pyconfig.h defines Py_IS_NAN as _isnan
8888
*/
8989
#ifndef Py_IS_NAN
90-
#ifdef HAVE_ISNAN
90+
#ifdef HAVE_DECL_ISNAN
9191
#define Py_IS_NAN(X) isnan(X)
9292
#else
9393
#define Py_IS_NAN(X) ((X) != (X))
@@ -104,7 +104,7 @@ extern double copysign(double, double);
104104
* Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf
105105
*/
106106
#ifndef Py_IS_INFINITY
107-
#ifdef HAVE_ISINF
107+
#ifdef HAVE_DECL_ISINF
108108
#define Py_IS_INFINITY(X) isinf(X)
109109
#else
110110
#define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X))

PC/pyconfig.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,11 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
399399
/* Define to 1 if you have the `copysign' function. */
400400
#define HAVE_COPYSIGN 1
401401

402-
/* Define to 1 if you have the `isinf' function. */
403-
#define HAVE_ISINF 1
402+
/* Define to 1 if you have the `isinf' macro. */
403+
#define HAVE_DECL_ISINF 1
404404

405405
/* Define to 1 if you have the `isnan' function. */
406-
#define HAVE_ISNAN 1
406+
#define HAVE_DECL_ISNAN 1
407407

408408
/* Define if on AIX 3.
409409
System headers sometimes define this.

configure

Lines changed: 205 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# From configure.in Revision: 68292 .
2+
# From configure.in Revision: 68296 .
33
# Guess values for system-dependent variables and create Makefiles.
44
# Generated by GNU Autoconf 2.61 for python 2.7.
55
#
@@ -21797,9 +21797,7 @@ done
2179721797

2179821798

2179921799

21800-
21801-
21802-
for ac_func in acosh asinh atanh copysign expm1 finite isinf isnan log1p
21800+
for ac_func in acosh asinh atanh copysign expm1 finite log1p
2180321801
do
2180421802
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
2180521803
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -21892,6 +21890,209 @@ _ACEOF
2189221890
fi
2189321891
done
2189421892

21893+
{ echo "$as_me:$LINENO: checking whether isinf is declared" >&5
21894+
echo $ECHO_N "checking whether isinf is declared... $ECHO_C" >&6; }
21895+
if test "${ac_cv_have_decl_isinf+set}" = set; then
21896+
echo $ECHO_N "(cached) $ECHO_C" >&6
21897+
else
21898+
cat >conftest.$ac_ext <<_ACEOF
21899+
/* confdefs.h. */
21900+
_ACEOF
21901+
cat confdefs.h >>conftest.$ac_ext
21902+
cat >>conftest.$ac_ext <<_ACEOF
21903+
/* end confdefs.h. */
21904+
#include <math.h>
21905+
21906+
int
21907+
main ()
21908+
{
21909+
#ifndef isinf
21910+
(void) isinf;
21911+
#endif
21912+
21913+
;
21914+
return 0;
21915+
}
21916+
_ACEOF
21917+
rm -f conftest.$ac_objext
21918+
if { (ac_try="$ac_compile"
21919+
case "(($ac_try" in
21920+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21921+
*) ac_try_echo=$ac_try;;
21922+
esac
21923+
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21924+
(eval "$ac_compile") 2>conftest.er1
21925+
ac_status=$?
21926+
grep -v '^ *+' conftest.er1 >conftest.err
21927+
rm -f conftest.er1
21928+
cat conftest.err >&5
21929+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
21930+
(exit $ac_status); } && {
21931+
test -z "$ac_c_werror_flag" ||
21932+
test ! -s conftest.err
21933+
} && test -s conftest.$ac_objext; then
21934+
ac_cv_have_decl_isinf=yes
21935+
else
21936+
echo "$as_me: failed program was:" >&5
21937+
sed 's/^/| /' conftest.$ac_ext >&5
21938+
21939+
ac_cv_have_decl_isinf=no
21940+
fi
21941+
21942+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
21943+
fi
21944+
{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_isinf" >&5
21945+
echo "${ECHO_T}$ac_cv_have_decl_isinf" >&6; }
21946+
if test $ac_cv_have_decl_isinf = yes; then
21947+
21948+
cat >>confdefs.h <<_ACEOF
21949+
#define HAVE_DECL_ISINF 1
21950+
_ACEOF
21951+
21952+
21953+
else
21954+
cat >>confdefs.h <<_ACEOF
21955+
#define HAVE_DECL_ISINF 0
21956+
_ACEOF
21957+
21958+
21959+
fi
21960+
{ echo "$as_me:$LINENO: checking whether isnan is declared" >&5
21961+
echo $ECHO_N "checking whether isnan is declared... $ECHO_C" >&6; }
21962+
if test "${ac_cv_have_decl_isnan+set}" = set; then
21963+
echo $ECHO_N "(cached) $ECHO_C" >&6
21964+
else
21965+
cat >conftest.$ac_ext <<_ACEOF
21966+
/* confdefs.h. */
21967+
_ACEOF
21968+
cat confdefs.h >>conftest.$ac_ext
21969+
cat >>conftest.$ac_ext <<_ACEOF
21970+
/* end confdefs.h. */
21971+
#include <math.h>
21972+
21973+
int
21974+
main ()
21975+
{
21976+
#ifndef isnan
21977+
(void) isnan;
21978+
#endif
21979+
21980+
;
21981+
return 0;
21982+
}
21983+
_ACEOF
21984+
rm -f conftest.$ac_objext
21985+
if { (ac_try="$ac_compile"
21986+
case "(($ac_try" in
21987+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
21988+
*) ac_try_echo=$ac_try;;
21989+
esac
21990+
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
21991+
(eval "$ac_compile") 2>conftest.er1
21992+
ac_status=$?
21993+
grep -v '^ *+' conftest.er1 >conftest.err
21994+
rm -f conftest.er1
21995+
cat conftest.err >&5
21996+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
21997+
(exit $ac_status); } && {
21998+
test -z "$ac_c_werror_flag" ||
21999+
test ! -s conftest.err
22000+
} && test -s conftest.$ac_objext; then
22001+
ac_cv_have_decl_isnan=yes
22002+
else
22003+
echo "$as_me: failed program was:" >&5
22004+
sed 's/^/| /' conftest.$ac_ext >&5
22005+
22006+
ac_cv_have_decl_isnan=no
22007+
fi
22008+
22009+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
22010+
fi
22011+
{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_isnan" >&5
22012+
echo "${ECHO_T}$ac_cv_have_decl_isnan" >&6; }
22013+
if test $ac_cv_have_decl_isnan = yes; then
22014+
22015+
cat >>confdefs.h <<_ACEOF
22016+
#define HAVE_DECL_ISNAN 1
22017+
_ACEOF
22018+
22019+
22020+
else
22021+
cat >>confdefs.h <<_ACEOF
22022+
#define HAVE_DECL_ISNAN 0
22023+
_ACEOF
22024+
22025+
22026+
fi
22027+
{ echo "$as_me:$LINENO: checking whether isfinite is declared" >&5
22028+
echo $ECHO_N "checking whether isfinite is declared... $ECHO_C" >&6; }
22029+
if test "${ac_cv_have_decl_isfinite+set}" = set; then
22030+
echo $ECHO_N "(cached) $ECHO_C" >&6
22031+
else
22032+
cat >conftest.$ac_ext <<_ACEOF
22033+
/* confdefs.h. */
22034+
_ACEOF
22035+
cat confdefs.h >>conftest.$ac_ext
22036+
cat >>conftest.$ac_ext <<_ACEOF
22037+
/* end confdefs.h. */
22038+
#include <math.h>
22039+
22040+
int
22041+
main ()
22042+
{
22043+
#ifndef isfinite
22044+
(void) isfinite;
22045+
#endif
22046+
22047+
;
22048+
return 0;
22049+
}
22050+
_ACEOF
22051+
rm -f conftest.$ac_objext
22052+
if { (ac_try="$ac_compile"
22053+
case "(($ac_try" in
22054+
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
22055+
*) ac_try_echo=$ac_try;;
22056+
esac
22057+
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
22058+
(eval "$ac_compile") 2>conftest.er1
22059+
ac_status=$?
22060+
grep -v '^ *+' conftest.er1 >conftest.err
22061+
rm -f conftest.er1
22062+
cat conftest.err >&5
22063+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
22064+
(exit $ac_status); } && {
22065+
test -z "$ac_c_werror_flag" ||
22066+
test ! -s conftest.err
22067+
} && test -s conftest.$ac_objext; then
22068+
ac_cv_have_decl_isfinite=yes
22069+
else
22070+
echo "$as_me: failed program was:" >&5
22071+
sed 's/^/| /' conftest.$ac_ext >&5
22072+
22073+
ac_cv_have_decl_isfinite=no
22074+
fi
22075+
22076+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
22077+
fi
22078+
{ echo "$as_me:$LINENO: result: $ac_cv_have_decl_isfinite" >&5
22079+
echo "${ECHO_T}$ac_cv_have_decl_isfinite" >&6; }
22080+
if test $ac_cv_have_decl_isfinite = yes; then
22081+
22082+
cat >>confdefs.h <<_ACEOF
22083+
#define HAVE_DECL_ISFINITE 1
22084+
_ACEOF
22085+
22086+
22087+
else
22088+
cat >>confdefs.h <<_ACEOF
22089+
#define HAVE_DECL_ISFINITE 0
22090+
_ACEOF
22091+
22092+
22093+
fi
22094+
22095+
2189522096

2189622097
LIBS=$LIBS_SAVE
2189722098

configure.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3209,7 +3209,8 @@ fi
32093209

32103210
AC_REPLACE_FUNCS(hypot)
32113211

3212-
AC_CHECK_FUNCS(acosh asinh atanh copysign expm1 finite isinf isnan log1p)
3212+
AC_CHECK_FUNCS([acosh asinh atanh copysign expm1 finite log1p])
3213+
AC_CHECK_DECLS([isinf, isnan, isfinite], [], [], [[#include <math.h>]])
32133214

32143215
LIBS=$LIBS_SAVE
32153216

pyconfig.h.in

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@
115115
/* Define if you have the 'resize_term' function. */
116116
#undef HAVE_CURSES_RESIZE_TERM
117117

118+
/* Define to 1 if you have the declaration of `isfinite', and to 0 if you
119+
don't. */
120+
#undef HAVE_DECL_ISFINITE
121+
122+
/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't.
123+
*/
124+
#undef HAVE_DECL_ISINF
125+
126+
/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.
127+
*/
128+
#undef HAVE_DECL_ISNAN
129+
118130
/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
119131
*/
120132
#undef HAVE_DECL_TZNAME
@@ -315,12 +327,6 @@
315327
/* Define to 1 if you have the <io.h> header file. */
316328
#undef HAVE_IO_H
317329

318-
/* Define to 1 if you have the `isinf' function. */
319-
#undef HAVE_ISINF
320-
321-
/* Define to 1 if you have the `isnan' function. */
322-
#undef HAVE_ISNAN
323-
324330
/* Define to 1 if you have the `kill' function. */
325331
#undef HAVE_KILL
326332

0 commit comments

Comments
 (0)