This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libgfortran using missing AIX long double functions


On Wed, Dec 22, 2010 at 2:12 PM, Steve Kargl
<sgk@troutmask.apl.washington.edu> wrote:

> 3) What I am asking is that an AIX maintainer provide more
> ? information than libgfortran is broken. ?How does libgfortran
> ? detect that AIX is misrepresenting its environment?
>
> ? For example, libgfortran/configure already checks for copysignl,
> ? and apparently AIX tells configure that "Yes, I have copysignl".
> ? Then when libgfortran actually uses copysignl, AIX comes back
> ? with "Well, what I meant to say is that I have copysignl, but
> ? it needs __copysignl128, which is missing."

libgfortran configure tests for copysignl() by compiling and linking
the following program:

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char copysignl ();
int
main ()
{
return copysignl ();
  ;
  return 0;
}


AIX supports and implements two versions of long double.  The default
version uses type double.  All of the math functions are defined and
implemented for the default version.  For example, copysignl() is
defined in libm.a, implemented the same as copysign().

The libgfortran configure test does not include the system math.h
header file.  That file includes macro definitions like:

#ifdef __LONGDOUBLE128
...
#define copysignl(__x, __y)     __copysignl128((long double) (__x),
(long double) (__y))


Without the header (which also includes prototypes that could cause
other problems for configure), the conftest never generates a
reference to __copysignl128(), allowing the compilation and link to
succeed.  configure believes that copysignl() exists and everything
proceeds all well and good until it crashes and burns.


libgfortran.h begins with

#include "config.h"
#include <stdio.h>
#include <math.h>
#include <stddef.h>
#include <float.h>
#include <stdarg.h>


libgfortran source code is not using the same definitions and
functions that libgfortran configure tested.


I do not know why 128 bit long double is not completely implemented on
AIX, especially for basic functions like copysignl().  I separately am
raising this issue with the AIX library team.


> ? If an AIX maintainer can fill in A, B, and C below, here's
> ? __copysignl128
>
> #if defined(A) && defined(B) ?// A == _AIX_ and B >= version 42?
> typedef ld128 ?C ? ? ? ? ? ? ?// Is C 'long double' or some internal type?

AIX long double is a pair of normal doubles.

A trivial implementation of copysign probably is something like:

typedef union
{
  long double ldval;
  double dval[2];
} longDblUnion;

long double
__copysignl128 (double a, double, b, double c, double d)
{
  longDblUnion x;

  copysign (a, c);
  copysign (b, d);
  x.dval[0] = a;
  x.dval[1] = b;
  return x.ldval;
}

rs6000.md probably should implement copysign for TFmode, but that does
not address the other missing functions.

Thanks, David


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]