From: Nicholas Clark <nick@ccl4.org>
Date: Sun, 11 Aug 2002 20:05:49 +0000 (+0100)
Subject: better modfl detection
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=51997bc3cf799cd7796ef40df40dca19c40bb71a;p=p5sagit%2Fp5-mst-13.2.git

better modfl detection
Message-id: <20020811190548.GK300@Bagpuss.unfortu.net>

p4raw-id: //depot/perl@17715
---

diff --git a/Configure b/Configure
index 03b4c7d..453e1f7 100755
--- a/Configure
+++ b/Configure
@@ -6035,6 +6035,31 @@ esac
 set modfl d_modfl
 eval $inlibc
 
+
+hasproto='varname=$1; func=$2; shift; shift;
+while $test $# -ge 2; do
+	case "$1" in
+	$define) echo "#include <$2>";;
+	esac ;
+    shift 2;
+done > try.c;
+$cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
+if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
+	echo "$func() prototype found.";
+	val="$define";
+else
+	echo "$func() prototype NOT found.";
+	val="$undef";
+fi;
+set $varname;
+eval $setvar;
+$rm -f try.c tryout.c'
+
+: see if prototype for modfl is available
+echo " "
+set d_modflproto modfl math.h
+eval $hasproto
+
 d_modfl_pow32_bug="$undef"
 
 case "$d_longdbl$d_modfl" in
@@ -6045,6 +6070,14 @@ EOM
 $cat >try.c <<EOCP
 #include <math.h> 
 #include <stdio.h>
+EOCP
+if $test "X$d_modflproto" != "X$define"; then
+	$cat >>try.c <<EOCP
+/* Sigh. many current glibcs provide the function, but do not prototype it.  */ 
+long double modfl (long double, long double *);
+EOCP
+fi
+$cat >>try.c <<EOCP
 int main() {
     long double nv = 4294967303.15;
     long double v, w;
@@ -9153,25 +9186,6 @@ EOSH
 chmod +x protochk
 $eunicefix protochk
 
-hasproto='varname=$1; func=$2; shift; shift;
-while $test $# -ge 2; do
-	case "$1" in
-	$define) echo "#include <$2>";;
-	esac ;
-    shift 2;
-done > try.c;
-$cppstdin $cppflags $cppminus < try.c > tryout.c 2>/dev/null;
-if $contains "$func.*(" tryout.c >/dev/null 2>&1; then
-	echo "$func() prototype found.";
-	val="$define";
-else
-	echo "$func() prototype NOT found.";
-	val="$undef";
-fi;
-set $varname;
-eval $setvar;
-$rm -f try.c tryout.c'
-
 : see if sys/types.h has to be included
 set sys/types.h i_systypes
 eval $inhdr
diff --git a/config_h.SH b/config_h.SH
index 4ff4b5d..aa95c98 100644
--- a/config_h.SH
+++ b/config_h.SH
@@ -2598,6 +2598,12 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un
  *	available to split a long double x into a fractional part f and
  *	an integer part i such that |f| < 1.0 and (f + i) = x.
  */
+/* HAS_MODFL_PROTO:
+ *	This symbol, if defined, indicates that the system provides
+ *	a prototype for the modfl() function.  Otherwise, it is up
+ *	to the program to supply one.  C99 says it should be
+ *		long double modfl(long double, long double *);
+ */
 /* HAS_MODFL_POW32_BUG:
  *	This symbol, if defined, indicates that the modfl routine is
  *	broken for long doubles >= pow(2, 32).
@@ -2606,6 +2612,7 @@ sed <<!GROK!THIS! >$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un
  *	release 2.2.2 is known to be okay.
  */
 #$d_modfl HAS_MODFL		/**/
+#$d_modflproto HAS_MODFL_PROTO		/**/
 #$d_modfl_pow32_bug HAS_MODFL_POW32_BUG		/**/
 
 /* HAS_MPROTECT:
diff --git a/perl.h b/perl.h
index 944dcc7..dbc3758 100644
--- a/perl.h
+++ b/perl.h
@@ -1241,6 +1241,11 @@ typedef NVTYPE NV;
 /* e.g. libsunmath doesn't have modfl and frexpl as of mid-March 2000 */
 #   ifdef HAS_MODFL
 #       define Perl_modf(x,y) modfl(x,y)
+/* eg glibc 2.2 series seems to provide modfl on ppc and arm, but has no
+   prototype in <math.h> */
+#       ifndef HAS_MODFL_PROTO
+long double modfl(long double, long double *);
+#	endif
 #   else
 #       define Perl_modf(x,y) ((long double)modf((double)(x),(double*)(y)))
 #   endif