develooper Front page | perl.perl5.porters | Postings from May 2002

[PATCH] work round prototypeless modfl

Thread Next
From:
Nicholas Clark
Date:
May 28, 2002 15:01
Subject:
[PATCH] work round prototypeless modfl
Message ID:
20020528220039.GB288@Bagpuss.unfortu.net
There are probably enough other things going on to keep everyone running to
the hills before RC1, so this might want to wait until 5.9

ARM Linux and PPC Linux both fail to prototype modfl.
Currently Configure runs a test to try to detect a previous glibc modfl bug,
and concludes "I don't understand your modfl at all"
This is because the C compiler is treating it as returning int, because it
is unprototyped.

With the appended, at least Configure is happy to announce that modfl works.
So we look better.

However, it gains us little on ARM or PPC, as on both sizeof (long double)
== sizeof (double), so Configure elects to go back to doubles.

(Also PPC glibc is currently missing an implementation of sqrtl)

Nicholas Clark
-- 
Even better than the real thing:	http://nms-cgi.sourceforge.net/

--- perl.h.orig	Mon May  6 00:39:52 2002
+++ perl.h	Wed May 15 22:23:12 2002
@@ -1229,6 +1229,11 @@
 /* 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
--- config_h.SH.orig	Wed May  1 23:46:33 2002
+++ config_h.SH	Wed May 15 22:22:51 2002
@@ -1955,6 +1955,12 @@
  *	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).
@@ -1963,6 +1969,7 @@
  *	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:
--- Configure.orig	Sat May 11 20:47:23 2002
+++ Configure	Wed May 15 22:10:20 2002
@@ -5939,6 +5939,31 @@
 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
@@ -5949,6 +5974,14 @@
 $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;
@@ -9101,25 +9134,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

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About