提交 ba7c8592 编写于 作者: O openharmony_ci 提交者: Gitee

!182 fix: vfprintf依赖的__signbitl和__fpclassifyl未参与编译

Merge pull request !182 from zhushengle/OpenHarmony-3.0-LTS
......@@ -174,6 +174,10 @@ static_library(libc) {
static_library(libm) {
sources = [
"src/math/__fpclassify.c",
"src/math/__fpclassifyl.c",
"src/math/__signbit.c",
"src/math/__signbitl.c",
"src/math/exp_data.c",
"src/math/frexp.c",
"src/math/frexpl.c",
......
#include <math.h>
#include <stdint.h>
int __fpclassify(double x)
{
union {double f; uint64_t i;} u = {x};
int e = u.i>>52 & 0x7ff;
if (!e) return u.i<<1 ? FP_SUBNORMAL : FP_ZERO;
if (e==0x7ff) return u.i<<12 ? FP_NAN : FP_INFINITE;
return FP_NORMAL;
}
#include "libm.h"
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
int __fpclassifyl(long double x)
{
return __fpclassify(x);
}
#elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384
int __fpclassifyl(long double x)
{
union ldshape u = {x};
int e = u.i.se & 0x7fff;
int msb = u.i.m>>63;
if (!e && !msb)
return u.i.m ? FP_SUBNORMAL : FP_ZERO;
if (e == 0x7fff) {
/* The x86 variant of 80-bit extended precision only admits
* one representation of each infinity, with the mantissa msb
* necessarily set. The version with it clear is invalid/nan.
* The m68k variant, however, allows either, and tooling uses
* the version with it clear. */
if (__BYTE_ORDER == __LITTLE_ENDIAN && !msb)
return FP_NAN;
return u.i.m << 1 ? FP_NAN : FP_INFINITE;
}
if (!msb)
return FP_NAN;
return FP_NORMAL;
}
#elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
int __fpclassifyl(long double x)
{
union ldshape u = {x};
int e = u.i.se & 0x7fff;
u.i.se = 0;
if (!e)
return u.i2.lo | u.i2.hi ? FP_SUBNORMAL : FP_ZERO;
if (e == 0x7fff)
return u.i2.lo | u.i2.hi ? FP_NAN : FP_INFINITE;
return FP_NORMAL;
}
#endif
#include "libm.h"
// FIXME: macro in math.h
int __signbit(double x)
{
union {
double d;
uint64_t i;
} y = { x };
return y.i>>63;
}
#include "libm.h"
#if (LDBL_MANT_DIG == 64 || LDBL_MANT_DIG == 113) && LDBL_MAX_EXP == 16384
int __signbitl(long double x)
{
union ldshape u = {x};
return u.i.se >> 15;
}
#elif LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
int __signbitl(long double x)
{
return __signbit(x);
}
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册