Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/gen/isnan.c
Show All 34 Lines | |||||
* binary compat until we can bump libm's major version number. | * binary compat until we can bump libm's major version number. | ||||
* | * | ||||
* Note this only applies to the dynamic versions of libm and libc, so | * Note this only applies to the dynamic versions of libm and libc, so | ||||
* for the static and profiled versions we stub out the definitions. | * for the static and profiled versions we stub out the definitions. | ||||
* Otherwise you cannot link statically to libm and libc at the same | * Otherwise you cannot link statically to libm and libc at the same | ||||
* time, when calling both functions. | * time, when calling both functions. | ||||
*/ | */ | ||||
#ifdef PIC | #ifdef __PIC__ | ||||
__weak_reference(__isnan, isnan); | __weak_reference(__isnan, isnan); | ||||
__weak_reference(__isnanf, isnanf); | __weak_reference(__isnanf, isnanf); | ||||
int | int | ||||
__isnan(double d) | __isnan(double d) | ||||
{ | { | ||||
union IEEEd2bits u; | union IEEEd2bits u; | ||||
u.d = d; | u.d = d; | ||||
return (u.bits.exp == 2047 && (u.bits.manl != 0 || u.bits.manh != 0)); | return (u.bits.exp == 2047 && (u.bits.manl != 0 || u.bits.manh != 0)); | ||||
} | } | ||||
int | int | ||||
__isnanf(float f) | __isnanf(float f) | ||||
{ | { | ||||
union IEEEf2bits u; | union IEEEf2bits u; | ||||
u.f = f; | u.f = f; | ||||
return (u.bits.exp == 255 && u.bits.man != 0); | return (u.bits.exp == 255 && u.bits.man != 0); | ||||
} | } | ||||
#endif /* PIC */ | #endif /* __PIC__ */ |