[gnu.gcc.bug] patch for inline math library.

self@BAYES.ARC.NASA.GOV (Matthew Self) (03/25/89)

  Here is a patch to correct the argument types of the modf() function
in the inline math library (thanks to Dirk Grunwald for catching
this).  Also included is a program which appears to demonstrate a bug
in gas for the 68881 (thanks to Kriton Kyrimis).  I don't know where
such bugs should be reported....

#include <math.h>
 
double
foo(x,y)
  double x, y;
{
  printf("%lf\n", atan2(x,y));
}

gas 1.31 reports the following error:

159:Ignoring junk after expression

Here is the relevant assembler:

L147:
	fcmpd LC0,fp0
	fjnlt L150			(this is line 159)
	fmovex fp1,fp3
	fdivx fp0,fp3
	moveq #-72,d0
	addl a6,d0

Sun's assembler has no problem with this.

I should also point out that there has been some confusion over what
this library is meant to do.  It is an ANSI math library only.  It
does not provide any support for -traditional features such as
declaring atof(), or BSD functions like gamma().  These would be great
additions (and the 68881 has instructions for many of them), but
providing ANSI compliance was my first priority.

  --Matthew


*** math.h.dist	Fri Mar 24 13:20:32 1989
--- math.h	Fri Mar 24 13:22:28 1989
***************
*** 1,5 ****
  /******************************************************************\
  *								   *
! *  ANSI <math.h>		last modified: March 6, 1989.	   *
  *								   *
  *  Copyright (C) 1989 by Matthew Self.				   *
--- 1,5 ----
  /******************************************************************\
  *								   *
! *  ANSI <math.h>		last modified: March 24, 1989.	   *
  *								   *
  *  Copyright (C) 1989 by Matthew Self.				   *
***************
*** 48,52 ****
  
  extern double
!   frexp (double x, int *exp), modf (double x, int *ip);
  
  #endif				/* Different machine types */
--- 48,52 ----
  
  extern double
!   frexp (double x, int *exp), modf (double x, double *ip);
  
  #endif				/* Different machine types */
***************
*** 67,71 ****
  
  extern double
!   frexp (double x, int *exp), modf (double x, int *ip);
  
  #endif /* __STRICT_ANSI */
--- 67,71 ----
  
  extern double
!   frexp (double x, int *exp), modf (double x, double *ip);
  
  #endif /* __STRICT_ANSI */
***************
*** 84,88 ****
    fmod (double x , double y),
    ldexp (double x, int n),
!   frexp (double x, int *exp), modf (double x, int *ip);
  
  #endif /* __GNUC__ */
--- 84,88 ----
    fmod (double x , double y),
    ldexp (double x, int n),
!   frexp (double x, int *exp), modf (double x, double *ip);
  
  #endif /* __GNUC__ */
*** math-68881.h.dist	Fri Mar 24 13:22:03 1989
--- math-68881.h	Fri Mar 24 13:23:04 1989
***************
*** 1,5 ****
  /******************************************************************\
  *								   *
! *  <math-68881.h>		last modified: March 22, 1989.	   *
  *								   *
  *  Copyright (C) 1989 by Matthew Self.				   *
--- 1,5 ----
  /******************************************************************\
  *								   *
! *  <math-68881.h>		last modified: March 24, 1989.	   *
  *								   *
  *  Copyright (C) 1989 by Matthew Self.				   *
***************
*** 375,379 ****
  }
  
! __inline static double modf (double x, int *ip)
  {
    double temp;
--- 375,379 ----
  }
  
! __inline static double modf (double x, double *ip)
  {
    double temp;
***************
*** 382,386 ****
  	 : "=f" (temp)			/* integer-valued float */
  	 : "f" (x));
!   *ip = (int) temp;
    return x - temp;
  }
--- 382,386 ----
  	 : "=f" (temp)			/* integer-valued float */
  	 : "f" (x));
!   *ip = temp;
    return x - temp;
  }