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

!174 M核C库新增接口

Merge pull request !174 from Zhaotianyu/1214musl_add
......@@ -59,6 +59,7 @@ static_library(libc) {
"src/internal/shgetc.c",
"src/locale/__lctrans.c",
"src/locale/c_locale.c",
"src/locale/iconv.c",
"src/locale/langinfo.c",
"src/misc/dirname.c",
"src/misc/realpath.c",
......@@ -110,21 +111,19 @@ static_library(libc) {
"src/stdio/stderr.c",
"src/stdio/stdin.c",
"src/stdio/stdout.c",
"src/stdio/ungetc.c",
"src/stdio/vfprintf.c",
"src/stdio/vsnprintf.c",
"src/stdio/vsprintf.c",
"src/stdlib/abs.c",
"src/stdlib/atof.c",
"src/stdlib/atoi.c",
#"src/stdlib/strtol.c",
"src/locale/iconv.c",
"src/stdio/ungetc.c",
"src/stdlib/atol.c",
"src/stdlib/atoll.c",
"src/stdlib/bsearch.c",
"src/stdlib/llabs.c",
"src/stdlib/strtod.c",
"src/stdlib/strtol.c",
"src/string/memchr.c",
"src/string/memcmp.c",
"src/string/memcpy.c",
......@@ -188,9 +187,21 @@ static_library(libm) {
sources = [
"src/math/__fpclassify.c",
"src/math/__fpclassifyl.c",
"src/math/__math_divzero.c",
"src/math/__math_divzerof.c",
"src/math/__math_invalid.c",
"src/math/__math_invalidf.c",
"src/math/__math_oflow.c",
"src/math/__math_oflowf.c",
"src/math/__math_uflow.c",
"src/math/__math_uflowf.c",
"src/math/__math_xflow.c",
"src/math/__math_xflowf.c",
"src/math/__signbit.c",
"src/math/__signbitl.c",
"src/math/arm/fabs.c",
"src/math/exp_data.c",
"src/math/floor.c",
"src/math/frexp.c",
"src/math/frexpl.c",
"src/math/log.c",
......
#include "libm.h"
double __math_divzero(uint32_t sign)
{
return fp_barrier(sign ? -1.0 : 1.0) / 0.0;
}
#include "libm.h"
float __math_divzerof(uint32_t sign)
{
return fp_barrierf(sign ? -1.0f : 1.0f) / 0.0f;
}
#include "libm.h"
double __math_invalid(double x)
{
return (x - x) / (x - x);
}
#include "libm.h"
float __math_invalidf(float x)
{
return (x - x) / (x - x);
}
#include "libm.h"
double __math_oflow(uint32_t sign)
{
return __math_xflow(sign, 0x1p769);
}
#include "libm.h"
float __math_oflowf(uint32_t sign)
{
return __math_xflowf(sign, 0x1p97f);
}
#include "libm.h"
double __math_uflow(uint32_t sign)
{
return __math_xflow(sign, 0x1p-767);
}
#include "libm.h"
float __math_uflowf(uint32_t sign)
{
return __math_xflowf(sign, 0x1p-95f);
}
#include "libm.h"
double __math_xflow(uint32_t sign, double y)
{
return eval_as_double(fp_barrier(sign ? -y : y) * y);
}
#include "libm.h"
float __math_xflowf(uint32_t sign, float y)
{
return eval_as_float(fp_barrierf(sign ? -y : y) * y);
}
#include <math.h>
#if __ARM_PCS_VFP
double fabs(double x)
{
__asm__ ("vabs.f64 %P0, %P1" : "=w"(x) : "w"(x));
return x;
}
#else
#include "../fabs.c"
#endif
#include <math.h>
#include <stdint.h>
double fabs(double x)
{
union {double f; uint64_t i;} u = {x};
u.i &= -1ULL/2;
return u.f;
}
#include "libm.h"
#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1
#define EPS DBL_EPSILON
#elif FLT_EVAL_METHOD==2
#define EPS LDBL_EPSILON
#endif
static const double_t toint = 1/EPS;
double floor(double x)
{
union {double f; uint64_t i;} u = {x};
int e = u.i >> 52 & 0x7ff;
double_t y;
if (e >= 0x3ff+52 || x == 0)
return x;
/* y = int(x) - x, where int(x) is an integer neighbor of x */
if (u.i >> 63)
y = x - toint + toint - x;
else
y = x + toint - toint - x;
/* special case because of non-nearest rounding modes */
if (e <= 0x3ff-1) {
FORCE_EVAL(y);
return u.i >> 63 ? -1 : 0;
}
if (y > 0)
return x + y - 1;
return x + y;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册