Changeset View
Changeset View
Standalone View
Standalone View
lib/msun/src/s_fmax.c
Show All 28 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <float.h> | #include <float.h> | ||||
#include <math.h> | #include <math.h> | ||||
#include "fpmath.h" | #include "fpmath.h" | ||||
#ifdef USE_BUILTIN_FMAX | |||||
double | double | ||||
fmax(double x, double y) | fmax(double x, double y) | ||||
{ | { | ||||
return (__builtin_fmax(x, y)); | |||||
} | |||||
#else | |||||
double | |||||
fmax(double x, double y) | |||||
{ | |||||
union IEEEd2bits u[2]; | union IEEEd2bits u[2]; | ||||
u[0].d = x; | u[0].d = x; | ||||
u[1].d = y; | u[1].d = y; | ||||
/* Check for NaNs to avoid raising spurious exceptions. */ | /* Check for NaNs to avoid raising spurious exceptions. */ | ||||
if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0) | if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0) | ||||
return (y); | return (y); | ||||
if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0) | if (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0) | ||||
return (x); | return (x); | ||||
/* Handle comparisons of signed zeroes. */ | /* Handle comparisons of signed zeroes. */ | ||||
if (u[0].bits.sign != u[1].bits.sign) | if (u[0].bits.sign != u[1].bits.sign) | ||||
return (u[u[0].bits.sign].d); | return (u[u[0].bits.sign].d); | ||||
return (x > y ? x : y); | return (x > y ? x : y); | ||||
} | } | ||||
#endif | |||||
#if (LDBL_MANT_DIG == 53) | #if (LDBL_MANT_DIG == 53) | ||||
__weak_reference(fmax, fmaxl); | __weak_reference(fmax, fmaxl); | ||||
#endif | #endif |