예제 #1
0
long double _Complex
__mulxc3(long double fa, long double fb, long double fc, long double fd)
{
	union ul ua, ub, uc, ud, ux, uy, uac, ubd, uad, ubc;

	ua.f = fa;
	ub.f = fb;
	uc.f = fc;
	ud.f = fd;

	uac.f = ua.f * uc.f;
	ubd.f = ub.f * ud.f;
	uad.f = ua.f * ud.f;
	ubc.f = ub.f * uc.f;

	ux.f=uac.f-ubd.f;
	uy.f=uad.f+ubc.f;


	if (LDBL_ISNAN(ux) && LDBL_ISNAN(uy)) {
		/* Recover infinities that computed as NaN+iNaN ... */
		int recalc = 0;
		if (LDBL_ISINF(ua) || LDBL_ISINF(ub) ) { // z is infinite
			/* "Box" the infinity and change NaNs
			   in the other factor to 0 */
			ua.f = pcc_copysignl(LDBL_ISINF(ua) ? 1.0 : 0.0, ua.f);
			ub.f = pcc_copysignl(LDBL_ISINF(ub) ? 1.0 : 0.0, ub.f);
			if (LDBL_ISNAN(uc)) uc.f = pcc_copysignl(0.0, uc.f);
			if (LDBL_ISNAN(ud)) ud.f = pcc_copysignl(0.0, ud.f);
			recalc = 1;
		}
		if (LDBL_ISINF(uc) || LDBL_ISINF(ud) ) { // w is infinite
			/* "Box" the infinity and change NaNs
			    in the other factor to 0 */
			uc.f = pcc_copysignl(LDBL_ISINF(uc) ? 1.0 : 0.0, uc.f);
			ud.f = pcc_copysignl(LDBL_ISINF(ud) ? 1.0 : 0.0, ud.f);
			if (LDBL_ISNAN(ua)) ua.f = pcc_copysignl(0.0, ua.f);
			if (LDBL_ISNAN(ub)) ub.f = pcc_copysignl(0.0, ub.f);
			recalc = 1;
		}
		if (!recalc && (LDBL_ISINF(uac) || LDBL_ISINF(ubd) ||
		    LDBL_ISINF(uad) || LDBL_ISINF(ubc))) {
			/* Recover infinities from overflow by
			   changing NaNs to 0 ... */
			if (LDBL_ISNAN(ua)) ua.f = pcc_copysignl(0.0, ua.f);
			if (LDBL_ISNAN(ub)) ub.f = pcc_copysignl(0.0, ub.f);
			if (LDBL_ISNAN(uc)) uc.f = pcc_copysignl(0.0, uc.f);
			if (LDBL_ISNAN(ud)) ud.f = pcc_copysignl(0.0, ud.f);
			recalc = 1;
		}
		if (recalc) {
			ux.f = __builtin_infl() * ( ua.f * uc.f - ub.f * ud.f );
			uy.f = __builtin_infl() * ( ua.f * ud.f + ub.f * uc.f );
		}
	}
	return ux.f + 1.0iF * uy.f;
}
int
main ()
{
  double nan = __builtin_nan ("");
  float nanf = __builtin_nanf ("");
  long double nanl = __builtin_nanl ("");

  double pinf = __builtin_inf ();
  float pinff = __builtin_inff ();
  long double pinfl = __builtin_infl ();

  if (__builtin_finite (pinf))
    link_error ();
  if (__builtin_finitef (pinff))
    link_error ();
  if (__builtin_finitel (pinfl))
    link_error ();

  if (__builtin_finite (nan))
    link_error ();
  if (__builtin_finitef (nanf))
    link_error ();
  if (__builtin_finitel (nanl))
    link_error ();

  if (!__builtin_finite (4.0))
    link_error ();
  if (!__builtin_finitef (4.0))
    link_error ();
  if (!__builtin_finitel (4.0))
    link_error ();
}
예제 #3
0
int main()
{
  test (34.0, __builtin_inf());
  testf (34.0f, __builtin_inff());
  testf (34.0l, __builtin_infl());
  return 0;
}
예제 #4
0
int __fpclassify( long double x )
{
    x = __builtin_fabsl(x);
    if( EXPECT_FALSE( x == 0.0L ) )
        return FP_ZERO;
        
    if( EXPECT_FALSE( x < 0x1.0p-16382L ) )
        return FP_SUBNORMAL;
    
    if( EXPECT_TRUE( x < __builtin_infl() ) )
        return FP_NORMAL;
        
    if( EXPECT_TRUE( x == __builtin_infl() ) )
        return FP_INFINITE;

    return FP_NAN;
}
GFC_REAL_16
nearest_r16 (GFC_REAL_16 s, GFC_REAL_16 dir)
{
  dir = copysignl (__builtin_infl (), dir);
  if (FLT_EVAL_METHOD != 0)
    {
      /* ??? Work around glibc bug on x86.  */
      volatile GFC_REAL_16 r = nextafterl (s, dir);
      return r;
    }
  else
    return nextafterl (s, dir);
}
예제 #6
0
int main()
{
	/*
	 * Return inf means infinity,and return NAN means not a number.
	 */
	printf("The __builtin_inf():[%lf]\n",
			__builtin_inf());
	printf("The __builtin_inff():[%f]\n",
			__builtin_inff());
	printf("The __builtin_infl:[%Lf]\n",
			__builtin_infl());
	return 0;
}
예제 #7
0
void testl(long double f, long double i)
{
  if (f == __builtin_infl())
    abort ();
  if (f == -__builtin_infl())
    abort ();
  if (i == -__builtin_infl())
    abort ();
  if (i != __builtin_infl())
    abort ();

  if (f >= __builtin_infl())
    abort ();
  if (f > __builtin_infl())
    abort ();
  if (i > __builtin_infl())
    abort ();
  if (f <= -__builtin_infl())
    abort ();
  if (f < -__builtin_infl())
    abort ();
}
예제 #8
0
int main() {
  volatile float a = __builtin_nanf("");
  if (__builtin_isfinite(a)) {
    return 1;
  }
  volatile float b = __builtin_inff();
  if (__builtin_isfinite(b)) {
    return 1;
  }
  volatile double c = __builtin_nan("");
  if (__builtin_isfinite(c)) {
    return 1;
  }
  volatile double d = __builtin_inf();
  if (__builtin_isfinite(d)) {
    return 1;
  }
#ifdef __clang__ // TODO: dragonegg uses native calls which do not work with X86_FP80
  volatile long double e = __builtin_nanl("");
  if (__builtin_isfinite(e)) {
    return 1;
  }
  volatile long double f = __builtin_infl();
  if (__builtin_isfinite(f)) {
    return 1;
  }
#endif
  volatile float g = 0;
  if (!__builtin_isfinite(g)) {
    return 1;
  }
  volatile double h = 0;
  if (!__builtin_isfinite(h)) {
    return 1;
  }
#ifdef __clang__ // TODO: dragonegg uses native calls which do not work with X86_FP80
  volatile long double i = 0;
  if (!__builtin_isfinite(i)) {
    return 1;
  }
#endif
  return 0;
}
예제 #9
0
파일: inf-1.c 프로젝트: 0day-ci/gcc
int main()
{
#ifndef __SPU__
  /* The SPU single-precision floating point format does not support Inf.  */
  float fi = __builtin_inff();
#endif
  double di = __builtin_inf();
  long double li = __builtin_infl();

  float fh = __builtin_huge_valf();
  double dh = __builtin_huge_val();
  long double lh = __builtin_huge_vall();

#ifndef __SPU__
  if (fi + fi != fi)
    abort ();
#endif
  if (di + di != di)
    abort ();
  if (li + li != li)
    abort ();

#ifndef __SPU__
  if (fi != fh)
    abort ();
#endif
  if (di != dh)
    abort ();
  if (li != lh)
    abort ();

#ifndef __SPU__
  if (fi <= 0)
    abort ();
#endif
  if (di <= 0)
    abort ();
  if (li <= 0)
    abort ();

  return 0;
}
예제 #10
0
파일: e_cosh.c 프로젝트: 010001111/darling
long double coshl( long double x )
{
    static const long double overflow = 0x1.62e9bb80635d81d4p+13L;		 //ln(LDBL_MAX) + ln(2.0)
    static const long double ln2 = 0.693147180559945309417232121458176568L;                             //ln(2)
    long double fabsx = __builtin_fabsl( x );
    long double t, w;

	if( x != x )	return x + x;

    if( fabsx < __builtin_infl() )
    {
        if( fabsx < 0.5L * ln2 )
        {
			if( fabsx > 0x1.0p-1000L )	//avoid underflow, save time
				fabsx = expm1l( fabsx );
            w = 1.0L + fabsx;
            if( fabsx < 0x1.0p-67L )
                return w;
            return 1.0L + (fabsx*fabsx)/(w+w);
        }
        
        if( fabsx < 22.L )
        {
            t =  expl( fabsx );
            return 0.5L * t + 0.5L/t;
        }
        
        if( fabsx < overflow )
        {
            w = expl( 0.5L * fabsx );
            t = 0.5L * w;
            return t * w;
        }
		
		return fabsx * 0x1.0p16383L;
    }

    //Nan or Inf result
    return fabsx + fabsx;
}
int
main ()
{
  double pinf = __builtin_inf ();
  float pinff = __builtin_inff ();
  long double pinfl = __builtin_infl ();

  if (__builtin_isinf (pinf) != 1)
    link_error ();
  if (__builtin_isinf (pinff) != 1)
    link_error ();
  if (__builtin_isinff (pinff) != 1)
    link_error ();
  if (__builtin_isinf (pinfl) != 1)
    link_error ();
  if (__builtin_isinfl (pinfl) != 1)
    link_error ();

  if (__builtin_isinf (-pinf) != -1)
    link_error ();
  if (__builtin_isinf (-pinff) != -1)
    link_error ();
  if (__builtin_isinff (-pinff) != -1)
    link_error ();
  if (__builtin_isinf (-pinfl) != -1)
    link_error ();
  if (__builtin_isinfl (-pinfl) != -1)
    link_error ();

  if (__builtin_isinf (4.0))
    link_error ();
  if (__builtin_isinf (4.0))
    link_error ();
  if (__builtin_isinff (4.0))
    link_error ();
  if (__builtin_isinf (4.0))
    link_error ();
  if (__builtin_isinfl (4.0))
    link_error ();
}
예제 #12
0
// RUN: %clang_cc1 -fsyntax-only -verify %s

// Math stuff

double       g0  = __builtin_huge_val();
float        g1  = __builtin_huge_valf();
long double  g2  = __builtin_huge_vall();

double       g3  = __builtin_inf();
float        g4  = __builtin_inff();
long double  g5  = __builtin_infl();

double       g6  = __builtin_nan("");
float        g7  = __builtin_nanf("");
long double  g8  = __builtin_nanl("");

// GCC constant folds these too (via native strtol):
//double       g6_1  = __builtin_nan("1");
//float        g7_1  = __builtin_nanf("1");
//long double  g8_1  = __builtin_nanl("1");

// APFloat doesn't have signalling NaN functions.
//double       g9  = __builtin_nans("");
//float        g10 = __builtin_nansf("");
//long double  g11 = __builtin_nansl("");

//int          g12 = __builtin_abs(-12);

double       g13 = __builtin_fabs(-12.);
double       g13_0 = __builtin_fabs(-0.);
double       g13_1 = __builtin_fabs(-__builtin_inf());
예제 #13
0
void bar()
{
  /* An argument of NaN is not evaluated at compile-time.  */
#ifndef __SPU__
  foof (__builtin_exp2f (__builtin_nanf("")));
#endif
  foo (__builtin_exp2 (__builtin_nan("")));
  fool (__builtin_exp2l (__builtin_nanl("")));

  /* An argument of Inf/-Inf is not evaluated at compile-time.  */
#ifndef __SPU__
  foof (__builtin_exp2f (__builtin_inff()));
#endif
  foo (__builtin_exp2 (__builtin_inf()));
  fool (__builtin_exp2l (__builtin_infl()));
#ifndef __SPU__
  foof (__builtin_exp2f (-__builtin_inff()));
#endif
  foo (__builtin_exp2 (-__builtin_inf()));
  fool (__builtin_exp2l (-__builtin_infl()));

  /* Result overflows MPFR, which in version 2.2.x has 30 exponent bits.  */
  TESTIT (exp2, 0x1p50);
  /* Result underflows MPFR, which in version 2.2.x has 30 exponent bits.  */
  TESTIT (exp2, -0x1p50);

  /* Result overflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits.  */
  TESTIT (exp2, 0x1p28);
  /* Result underflows GCC's REAL_VALUE_TYPE, which has 26 exponent bits.  */
  TESTIT (exp2, -0x1p28);
  
  /* Result overflows (even an extended) C double's mode.  */
  TESTIT (exp2, 0x1p24);
  /* Result underflows (even an extended) C double's mode.  */
  TESTIT (exp2, -0x1p24);

  /* Ensure that normal arguments/results are folded.  */
  TESTIT (exp2, 1.5);
  TESTIT (exp2, -1.5);
  
  /* The asin arg must be [-1 ... 1] inclusive.  */
  TESTIT (asin, -1.5);
  TESTIT (asin, 1.5);

  /* The acos arg must be [-1 ... 1] inclusive.  */
  TESTIT (acos, -1.5);
  TESTIT (acos, 1.5);
  
  /* The acosh arg must be [1 ... Inf] inclusive.  */
  TESTIT (acosh, 0.5);

  /* The atanh arg must be [-1 ... 1] EXclusive.  */
  TESTIT (atanh, -1.0);
  TESTIT (atanh, 1.0);

  /* The log* arg must be [0 ... Inf] EXclusive.  */
  TESTIT (log, -1.0);
  TESTIT (log, 0.0);
  TESTIT (log, -0.0);
  
  TESTIT (log2, -1.0);
  TESTIT (log2, 0.0);
  TESTIT (log2, -0.0);
  
  TESTIT (log10, -1.0);
  TESTIT (log10, 0.0);
  TESTIT (log10, -0.0);
  
  /* The log1p arg must be [-1 ... Inf] EXclusive.  */
  TESTIT (log1p, -2.0);
  TESTIT (log1p, -1.0);

  /* The tgamma arg errors with zero or negative integers.  */
  TESTIT (tgamma, 0.0);
  TESTIT (tgamma, -0.0);
  TESTIT (tgamma, -1.0);
  TESTIT (tgamma, -2.0);
  TESTIT (tgamma, -3.0);

  /* An argument of NaN is not evaluated at compile-time.  */
#ifndef __SPU__
  foof (__builtin_powf (__builtin_nanf(""), 2.5F));
#endif
  foo (__builtin_pow (__builtin_nan(""), 2.5));
  fool (__builtin_powl (__builtin_nanl(""), 2.5L));
#ifndef __SPU__
  foof (__builtin_powf (2.5F, __builtin_nanf("")));
#endif
  foo (__builtin_pow (2.5, __builtin_nan("")));
  fool (__builtin_powl (2.5L, __builtin_nanl("")));

  /* An argument of Inf/-Inf is not evaluated at compile-time.  */
#ifndef __SPU__
  foof (__builtin_powf (__builtin_inff(), 2.5F));
#endif
  foo (__builtin_pow (__builtin_inf(), 2.5));
  fool (__builtin_powl (__builtin_infl(), 2.5L));
#ifndef __SPU__
  foof (__builtin_powf (-__builtin_inff(), 2.5F));
#endif
  foo (__builtin_pow (-__builtin_inf(), 2.5));
  fool (__builtin_powl (-__builtin_infl(), 2.5L));
#ifndef __SPU__
  foof (__builtin_powf (2.5F, __builtin_inff()));
#endif
  foo (__builtin_pow (2.5, __builtin_inf()));
  fool (__builtin_powl (2.5L, __builtin_infl()));
#ifndef __SPU__
  foof (__builtin_powf (2.5F, -__builtin_inff()));
#endif
  foo (__builtin_pow (2.5, -__builtin_inf()));
  fool (__builtin_powl (2.5L, -__builtin_infl()));

  /* Check for Inv/NaN return values.  */
  TESTIT2 (pow, -0.0, -4.5); /* Returns Inf */
  TESTIT2 (pow, 0.0, -4.5); /* Returns Inf */
  TESTIT2 (pow, -3.0, -4.5); /* Returns NaN */

  /* Check for overflow/underflow.  */
  foof (__builtin_powf (__FLT_MAX__, 3.5F));
  foo (__builtin_pow (__DBL_MAX__, 3.5));
  fool (__builtin_powl (__LDBL_MAX__, 3.5L));
  TESTIT2 (pow, 2.0, 0x1p50);
  foof (__builtin_powf (__FLT_MAX__, -3.5F));
  foo (__builtin_pow (__DBL_MAX__, -3.5));
  fool (__builtin_powl (__LDBL_MAX__, -3.5L));
  TESTIT2 (pow, 2.0, -0x1p50);
  
  /* The sqrt arg must be [0 ... Inf] inclusive.  */
  TESTIT (sqrt, -0.5);
  TESTIT (sqrt, -0.0);
  TESTIT (sqrt, 0.0);

  /* Check for overflow/underflow.  */

  /* These adjustments are too big.  */
#define FLT_EXP_ADJ (2*(__FLT_MAX_EXP__-__FLT_MIN_EXP__)+1)
#define DBL_EXP_ADJ (2*(__DBL_MAX_EXP__-__DBL_MIN_EXP__)+1)
#define LDBL_EXP_ADJ (2*(__LDBL_MAX_EXP__-__LDBL_MIN_EXP__)+1)

  TESTIT2_I2 (ldexp, 1.0, __INT_MAX__);
  TESTIT2_I2 (ldexp, 1.0, -__INT_MAX__-1);
  TESTIT2_I2 (ldexp, -1.0, __INT_MAX__);
  TESTIT2_I2 (ldexp, -1.0, -__INT_MAX__-1);
  TESTIT2_I2ALL (ldexp, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
		 DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
  TESTIT2_I2ALL (ldexp, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
		 -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
  TESTIT2_I2ALL (ldexp, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
		 __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
  TESTIT2_I2ALL (ldexp, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
		 __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);

  TESTIT2_I2 (scalbn, 1.0, __INT_MAX__);
  TESTIT2_I2 (scalbn, 1.0, -__INT_MAX__-1);
  TESTIT2_I2 (scalbn, -1.0, __INT_MAX__);
  TESTIT2_I2 (scalbn, -1.0, -__INT_MAX__-1);
  TESTIT2_I2ALL (scalbn, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
		 DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
  TESTIT2_I2ALL (scalbn, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
		 -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
  TESTIT2_I2ALL (scalbn, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
		 __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
  TESTIT2_I2ALL (scalbn, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
		 __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);

  TESTIT2_I2 (scalbln, 1.0, __LONG_MAX__);
  TESTIT2_I2 (scalbln, 1.0, -__LONG_MAX__-1);
  TESTIT2_I2 (scalbln, -1.0, __LONG_MAX__);
  TESTIT2_I2 (scalbln, -1.0, -__LONG_MAX__-1);
  TESTIT2_I2ALL (scalbln, __FLT_MIN__, FLT_EXP_ADJ, __DBL_MIN__,
		 DBL_EXP_ADJ, __LDBL_MIN__, LDBL_EXP_ADJ);
  TESTIT2_I2ALL (scalbln, __FLT_MAX__, -FLT_EXP_ADJ, __DBL_MAX__,
		 -DBL_EXP_ADJ, __LDBL_MAX__, -LDBL_EXP_ADJ);
  TESTIT2_I2ALL (scalbln, __FLT_MIN__, __FLT_MIN_EXP__, __DBL_MIN__,
		 __DBL_MIN_EXP__, __LDBL_MIN__, __LDBL_MIN_EXP__);
  TESTIT2_I2ALL (scalbln, __FLT_MAX__, __FLT_MAX_EXP__, __DBL_MAX__,
		 __DBL_MAX_EXP__, __LDBL_MAX__, __LDBL_MAX_EXP__);

  TESTIT (logb, 0.0);
  TESTIT (logb, -0.0);

  TESTIT (ilogb, 0.0);
  TESTIT (ilogb, -0.0);

#ifndef __SPU__
  foof (__builtin_ilogbf (__builtin_inff()));
#endif
  foo (__builtin_ilogb (__builtin_inf()));
  fool (__builtin_ilogbl (__builtin_infl()));
#ifndef __SPU__
  foof (__builtin_ilogbf (-__builtin_inff()));
#endif
  foo (__builtin_ilogb (-__builtin_inf()));
  fool (__builtin_ilogbl (-__builtin_infl()));

#ifndef __SPU__
  foof (__builtin_ilogbf (__builtin_nanf("")));
#endif
  foo (__builtin_ilogb (__builtin_nan("")));
  fool (__builtin_ilogbl (__builtin_nanl("")));
#ifndef __SPU__
  foof (__builtin_ilogbf (-__builtin_nanf("")));
#endif
  foo (__builtin_ilogb (-__builtin_nan("")));
  fool (__builtin_ilogbl (-__builtin_nanl("")));

  /* The y* arg must be [0 ... Inf] EXclusive.  */
  TESTIT (y0, -1.0);
  TESTIT (y0, 0.0);
  TESTIT (y0, -0.0);

  TESTIT (y1, -1.0);
  TESTIT (y1, 0.0);
  TESTIT (y1, -0.0);

  TESTIT2_I1 (yn, 2, -1.0);
  TESTIT2_I1 (yn, 2, 0.0);
  TESTIT2_I1 (yn, 2, -0.0);

  TESTIT2_I1 (yn, -3, -1.0);
  TESTIT2_I1 (yn, -3, 0.0);
  TESTIT2_I1 (yn, -3, -0.0);

  /* The second argument of remquo/remainder/drem must not be 0.  */
  TESTIT_REMQUO (1.0, 0.0);
  TESTIT_REMQUO (1.0, -0.0);
  TESTIT2 (remainder, 1.0, 0.0);
  TESTIT2 (remainder, 1.0, -0.0);
  TESTIT2 (drem, 1.0, 0.0);
  TESTIT2 (drem, 1.0, -0.0);

  /* The argument to lgamma* cannot be zero or a negative integer.  */
  TESTIT_REENT (lgamma, -4.0); /* lgamma_r */
  TESTIT_REENT (lgamma, -3.0); /* lgamma_r */
  TESTIT_REENT (lgamma, -2.0); /* lgamma_r */
  TESTIT_REENT (lgamma, -1.0); /* lgamma_r */
  TESTIT_REENT (lgamma, -0.0); /* lgamma_r */
  TESTIT_REENT (lgamma, 0.0); /* lgamma_r */
  
  TESTIT_REENT (gamma, -4.0); /* gamma_r */
  TESTIT_REENT (gamma, -3.0); /* gamma_r */
  TESTIT_REENT (gamma, -2.0); /* gamma_r */
  TESTIT_REENT (gamma, -1.0); /* gamma_r */
  TESTIT_REENT (gamma, -0.0); /* gamma_r */
  TESTIT_REENT (gamma, 0.0); /* gamma_r */
}
예제 #14
0
int
convert_infnan (st_parameter_dt *dtp, void *dest, const char *buffer,
	        int length)
{
  const char *s = buffer;
  int is_inf, plus = 1;

  if (*s == '+')
    s++;
  else if (*s == '-')
    {
      s++;
      plus = 0;
    }

  is_inf = *s == 'i';

  switch (length)
    {
    case 4:
      if (is_inf)
	*((GFC_REAL_4*) dest) = plus ? __builtin_inff () : -__builtin_inff ();
      else
	*((GFC_REAL_4*) dest) = plus ? __builtin_nanf ("") : -__builtin_nanf ("");
      break;

    case 8:
      if (is_inf)
	*((GFC_REAL_8*) dest) = plus ? __builtin_inf () : -__builtin_inf ();
      else
	*((GFC_REAL_8*) dest) = plus ? __builtin_nan ("") : -__builtin_nan ("");
      break;

#if defined(HAVE_GFC_REAL_10)
    case 10:
      if (is_inf)
	*((GFC_REAL_10*) dest) = plus ? __builtin_infl () : -__builtin_infl ();
      else
	*((GFC_REAL_10*) dest) = plus ? __builtin_nanl ("") : -__builtin_nanl ("");
      break;
#endif

#if defined(HAVE_GFC_REAL_16)
# if defined(GFC_REAL_16_IS_FLOAT128)
    case 16:
      *((GFC_REAL_16*) dest) = __qmath_(strtoflt128) (buffer, NULL);
      break;
# else
    case 16:
      if (is_inf)
	*((GFC_REAL_16*) dest) = plus ? __builtin_infl () : -__builtin_infl ();
      else
	*((GFC_REAL_16*) dest) = plus ? __builtin_nanl ("") : -__builtin_nanl ("");
      break;
# endif
#endif

    default:
      internal_error (&dtp->common, "Unsupported real kind during IO");
    }

  return 0;
}
void bar()
{
  /* An argument of NaN is not evaluated at compile-time.  */
#ifndef __SPU__
  foof (__builtin_csqrtf (__builtin_nanf("")));
#endif
  foo (__builtin_csqrt (__builtin_nan("")));
  fool (__builtin_csqrtl (__builtin_nanl("")));

  /* An argument of Inf/-Inf is not evaluated at compile-time.  */
#ifndef __SPU__
  foof (__builtin_csqrtf (__builtin_inff()));
#endif
  foo (__builtin_csqrt (__builtin_inf()));
  fool (__builtin_csqrtl (__builtin_infl()));
#ifndef __SPU__
  foof (__builtin_csqrtf (-__builtin_inff()));
#endif
  foo (__builtin_csqrt (-__builtin_inf()));
  fool (__builtin_csqrtl (-__builtin_infl()));

  /* Check for overflow/underflow.  */
  TESTIT (cexp, 1e20);
  TESTIT (cexp, -1e20);
  
  /* An argument of NaN is not evaluated at compile-time.  */
#ifndef __SPU__
  foof (__builtin_cpowf (__builtin_nanf(""), 2.5F));
#endif
  foo (__builtin_cpow (__builtin_nan(""), 2.5));
  fool (__builtin_cpowl (__builtin_nanl(""), 2.5L));
#ifndef __SPU__
  foof (__builtin_cpowf (2.5F, __builtin_nanf("")));
#endif
  foo (__builtin_cpow (2.5, __builtin_nan("")));
  fool (__builtin_cpowl (2.5L, __builtin_nanl("")));

  /* An argument of Inf/-Inf is not evaluated at compile-time.  */
#ifndef __SPU__
  foof (__builtin_cpowf (__builtin_inff(), 2.5F));
#endif
  foo (__builtin_cpow (__builtin_inf(), 2.5));
  fool (__builtin_cpowl (__builtin_infl(), 2.5L));
#ifndef __SPU__
  foof (__builtin_cpowf (-__builtin_inff(), 2.5F));
#endif
  foo (__builtin_cpow (-__builtin_inf(), 2.5));
  fool (__builtin_cpowl (-__builtin_infl(), 2.5L));
#ifndef __SPU__
  foof (__builtin_cpowf (2.5F, __builtin_inff()));
#endif
  foo (__builtin_cpow (2.5, __builtin_inf()));
  fool (__builtin_cpowl (2.5L, __builtin_infl()));
#ifndef __SPU__
  foof (__builtin_cpowf (2.5F, -__builtin_inff()));
#endif
  foo (__builtin_cpow (2.5, -__builtin_inf()));
  fool (__builtin_cpowl (2.5L, -__builtin_infl()));

  /* Check for Inv/NaN return values.  */
  TESTIT2 (cpow, -0.0, -4.5); /* Returns Inf */
  TESTIT2 (cpow, 0.0, -4.5); /* Returns Inf */

  /* Check for overflow/underflow.  */
  foof (__builtin_cpowf (__FLT_MAX__, 3.5F));
  foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, 3.5F));
  foo (__builtin_cpow (__DBL_MAX__, 3.5));
  foo (__builtin_cpow (__DBL_MAX__ * 1.I, 3.5));
  fool (__builtin_cpowl (__LDBL_MAX__, 3.5L));
  fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, 3.5L));
  TESTIT2 (cpow, 2.0, 0x1p50);
  TESTIT2 (cpow, 2.0, 0x1p28);
  TESTIT2 (cpow, 2.0, 0x1p24);
  foof (__builtin_cpowf (__FLT_MAX__, -3.5F));
  foof (__builtin_cpowf (__FLT_MAX__ * 1.FI, -3.5F));
  foo (__builtin_cpow (__DBL_MAX__, -3.5));
  foo (__builtin_cpow (__DBL_MAX__ * 1.I, -3.5));
  fool (__builtin_cpowl (__LDBL_MAX__, -3.5L));
  fool (__builtin_cpowl (__LDBL_MAX__ * 1.LI, -3.5L));
  TESTIT2 (cpow, 2.0, -0x1p50);
  TESTIT2 (cpow, 2.0, -0x1p28);
  TESTIT2 (cpow, 2.0, -0x1p24);

}
예제 #16
0
long double __infl( void )
{
    return __builtin_infl();
}
/* { dg-do compile } */

float fi = __builtin_inff();
double di = __builtin_inf();
long double li = __builtin_infl();

float fh = __builtin_huge_valf();
double dh = __builtin_huge_val();
long double lh = __builtin_huge_vall();

/* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* } 3 } */
/* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* } 4 } */
/* { dg-warning "does not support infinity" "INF unsupported" { target vax-*-* } 5 } */
예제 #18
0
long double _Complex
__divxc3(long double ax, long double bx, long double cx, long double dx)
{
	long double denom;
	union ul ua, ub, uc, ud, ur, ulogbw, ux, uy, *urp;
	int uci, udi, res, ilogbw = 0;

	ua.f = ax;
	ub.f = bx;
	uc.f = cx;
	ud.f = dx;

	/* fabsf; clear sign */
	uci = uc.dlh & LDBL_MANTEXP;
	udi = ud.dlh & LDBL_MANTEXP;

	/* fmaxl; integer compare */
	if ((uci > udi) ||
	    ((uci == udi) && (uc.dil1 > ud.dil1)) ||
	    ((uci == udi) && (uc.dil1 == ud.dil1) && (uc.dil2 > ud.dil2)) ||
	    ((uci == udi) && (uc.dil1 == ud.dil1) && (uc.dil2 == ud.dil2) &&
	    (uc.dil3 > ud.dil3)))
		urp = &uc;
	else
		urp = &ud;

	ur.dlh = urp->dlh;
	ur.dil1 = urp->dil1;
	ur.dil2 = urp->dil2;
	ur.dil3 = urp->dil3;

	/* logbf */
	res = ur.dlh;
	if (res == 0 && ur.dil1 == 0 && ur.dil2 == 0 && ur.dil3 == 0)
		ulogbw.f = (long double)-1.0/ur.f;
	else if (res == 32767)
		ulogbw.f = ur.f * ur.f;
	else if (res == 0)
		ulogbw.f = -16382.0;
	else
		ulogbw.f = (res-16383);

	/* isfinite */
	if (LDBL_ISFIN(ulogbw)) {
		ilogbw = (int)ulogbw.f;
		uc.f = pcc_scalbnl(uc.f, -ilogbw);
		ud.f = pcc_scalbnl(ud.f, -ilogbw);
	}
	denom = uc.f * uc.f + ud.f * ud.f;
	ux.f = pcc_scalbnl((ua.f * uc.f + ub.f * ud.f) / denom, -ilogbw);
	uy.f = pcc_scalbnl((ub.f * uc.f - ua.f * ud.f) / denom, -ilogbw);

	if (LDBL_ISNAN(ux) && LDBL_ISNAN(uy)) {
		if ((denom == 0.0) &&
		    (!LDBL_ISNAN(ua) || !LDBL_ISNAN(ub))) {
			ux.f = pcc_copysignl(__builtin_infl(), uc.f) * ua.f;
			uy.f = pcc_copysignl(__builtin_infl(), uc.f) * ub.f;
		} else if ((LDBL_ISINF(ua) || LDBL_ISINF(ub)) &&
		    LDBL_ISFIN(uc) && LDBL_ISFIN(ud)) {
			ua.f = pcc_copysignl(LDBL_ISINF(ua) ? 1.0 : 0.0, ua.f);
			ub.f = pcc_copysignl(LDBL_ISINF(ub) ? 1.0 : 0.0, ub.f);
			ux.f = __builtin_infl() * ( ua.f * uc.f + ub.f * ud.f );
			uy.f = __builtin_infl() * ( ub.f * uc.f - ua.f * ud.f );
		} else if (LDBL_ISINF(ulogbw) &&
		    LDBL_ISFIN(ua) && LDBL_ISFIN(ub)) {
			uc.f = pcc_copysignl(LDBL_ISINF(uc) ? 1.0 : 0.0, uc.f);
			ud.f = pcc_copysignl(LDBL_ISINF(ud) ? 1.0 : 0.0, ud.f);
			ux.f = 0.0 * ( ua.f * uc.f + ub.f * ud.f );
			uy.f = 0.0 * ( ub.f * uc.f - ua.f * ud.f );
		}
	}
	return ux.f + 1.0iF * uy.f;
}