libm/libmcs: add math library libmcs support
add math library libmcs support (1)open menuconfig (2)close math.h:build setup->Customize Header Files->math.h (3) select libmcs:Library Rountines->Select math library->Math Library fram LibmCS (4)build Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
This commit is contained in:
parent
9c66f14e38
commit
e9dfa0094f
8 changed files with 468 additions and 0 deletions
|
@ -39,6 +39,13 @@ config LIBM_NEWLIB
|
|||
---help---
|
||||
Math library from Newlib
|
||||
|
||||
config LIBM_LIBMCS
|
||||
bool "Math library from LibmCS"
|
||||
depends on !ARCH_MATH_H
|
||||
depends on ALLOW_BSD_COMPONENTS
|
||||
---help---
|
||||
Math library from libmcs
|
||||
|
||||
config LIBM_OPENLIBM
|
||||
bool "Math library from openlibm"
|
||||
depends on !ARCH_MATH_H
|
||||
|
@ -60,3 +67,7 @@ endif
|
|||
if LIBM_NEWLIB
|
||||
source "libs/libm/newlib/Kconfig"
|
||||
endif
|
||||
|
||||
if LIBM_LIBMCS
|
||||
source "libs/libm/libmcs/Kconfig"
|
||||
endif
|
||||
|
|
|
@ -24,6 +24,8 @@ ifeq ($(CONFIG_LIBM),y)
|
|||
include libm/Make.defs
|
||||
else ifeq ($(CONFIG_LIBM_NEWLIB),y)
|
||||
include newlib/Make.defs
|
||||
else ifeq ($(CONFIG_LIBM_LIBMCS),y)
|
||||
include libmcs/Make.defs
|
||||
else ifeq ($(CONFIG_LIBM_OPENLIBM),y)
|
||||
include openlibm/Make.defs
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
From 84a14af9f858606a42fbdcd1f04af102594293d3 Mon Sep 17 00:00:00 2001
|
||||
From: yanghuatao <yanghuatao@xiaomi.com>
|
||||
Date: Thu, 23 Mar 2023 09:43:19 +0800
|
||||
Subject: [PATCH 1/3] fix build error: remove unused file fenv.h
|
||||
|
||||
VELAPLATFO-6159
|
||||
|
||||
fenv.h is unused, remove it or will have conflict with quickjs.c`s fenv.h
|
||||
|
||||
(1)open menuconfig (2)close math.h:build setup->Customize Header Files->math.h (2) select libmcs:Library Rountines->Select math library->Math Library fram LibmCS (3)build
|
||||
|
||||
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
|
||||
Change-Id: I70496ce82ff2f9de9016f5c829daf9982fa32d45
|
||||
---
|
||||
libmcs/libmcs/libm/include/fenv.h | 41 -----------------------------------------
|
||||
1 file changed, 41 deletions(-)
|
||||
delete mode 100644 libm/include/fenv.h
|
||||
|
||||
diff --git a/libmcs/libmcs/libm/include/fenv.h libmcs/libmcs/libm/include/fenv.h
|
||||
deleted file mode 100644
|
||||
index 169c85627..000000000
|
||||
--- a/libmcs/libmcs/libm/include/fenv.h
|
||||
+++ /dev/null
|
||||
@@ -1,41 +0,0 @@
|
||||
-/* SPDX-License-Identifier: GTDGmbH */
|
||||
-/* Copyright 2020-2021 by GTD GmbH. */
|
||||
-
|
||||
-#ifndef LIBMCS_FENV_H
|
||||
-#define LIBMCS_FENV_H
|
||||
-
|
||||
-#error fenv.h/fenv.c shall not be used as is. They have no functionality \
|
||||
- other than returning an error value and providing prototypes. \
|
||||
- If you, the user, want to use fenv you will have to implement the \
|
||||
- features yourself (or copy them from somewhere). We can not \
|
||||
- provide these functionalities for you as their implementation is \
|
||||
- highly platform dependant.
|
||||
-
|
||||
-#ifdef __cplusplus
|
||||
-extern "C"{
|
||||
-#endif
|
||||
-
|
||||
-/* Floating-point Exceptions */
|
||||
-extern int feclearexcept(int);
|
||||
-extern int feraiseexcept(int);
|
||||
-extern int fegetexceptflag(fexcept_t *, int);
|
||||
-extern int fesetexceptflag(const fexcept_t *, int);
|
||||
-
|
||||
-/* Rounding Direction */
|
||||
-extern int fegetround();
|
||||
-extern int fesetround(int);
|
||||
-
|
||||
-/* Entire Environment */
|
||||
-extern int fegetenv(fenv_t *);
|
||||
-extern int fesetenv(const fenv_t *);
|
||||
-extern int feholdexcept(fenv_t *);
|
||||
-extern int feupdateenv(const fenv_t *);
|
||||
-
|
||||
-/* Other */
|
||||
-extern int fetestexcept(int);
|
||||
-
|
||||
-#ifdef __cplusplus
|
||||
-}
|
||||
-#endif
|
||||
-
|
||||
-#endif /* !LIBMCS_FENV_H */
|
||||
--
|
||||
2.39.1
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
From 462db92b2ce6645876f90fd7b6dfc423c965cc6d Mon Sep 17 00:00:00 2001
|
||||
From: yanghuatao <yanghuatao@xiaomi.com>
|
||||
Date: Thu, 23 Mar 2023 09:47:17 +0800
|
||||
Subject: [PATCH 2/3] fix build error: do not include config.h
|
||||
|
||||
VELAPLATFO-6159
|
||||
|
||||
config.h is generated by confugure, we do not need it
|
||||
|
||||
(1)open menuconfig (2)close math.h:build setup->Customize Header Files->math.h (2) select libmcs:Library Rountines->Select math library->Math Library fram LibmCS (3)build
|
||||
|
||||
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
|
||||
Change-Id: I2d6efed47a8addee7624cbb972fb2ca914c1684c
|
||||
---
|
||||
libmcs/libmcs/libm/include/complex.h | 1 -
|
||||
libmcs/libmcs/libm/include/math.h | 1 -
|
||||
2 files changed, 2 deletions(-)
|
||||
|
||||
diff --git a/libmcs/libmcs/libm/include/complex.h libmcs/libmcs/libm/include/complex.h
|
||||
index ab30ac979..5a2ba59ac 100644
|
||||
--- a/libmcs/libmcs/libm/include/complex.h
|
||||
+++ libmcs/libmcs/libm/include/complex.h
|
||||
@@ -15,7 +15,6 @@
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
-#include "config.h"
|
||||
#include "internal_config.h"
|
||||
|
||||
#ifndef __LIBMCS_WANT_COMPLEX
|
||||
diff --git a/libmcs/libmcs/libm/include/math.h libmcs/libmcs/libm/include/math.h
|
||||
index 1bb0e4bab..b0f6427df 100644
|
||||
--- a/libmcs/libmcs/libm/include/math.h
|
||||
+++ libmcs/libmcs/libm/include/math.h
|
||||
@@ -5,7 +5,6 @@
|
||||
extern "C"{
|
||||
#endif
|
||||
|
||||
-#include "config.h"
|
||||
#include "internal_config.h"
|
||||
|
||||
/*
|
||||
--
|
||||
2.39.1
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
From 6efff584737164533272e8888e945c60b671139c Mon Sep 17 00:00:00 2001
|
||||
From: yanghuatao <yanghuatao@xiaomi.com>
|
||||
Date: Thu, 23 Mar 2023 09:54:59 +0800
|
||||
Subject: [PATCH 3/3] fix build error: INFINITY error in quickjs.c
|
||||
|
||||
VELAPLATFO-6159
|
||||
|
||||
quickjs/quickjs.c:40035:45: error: initializer element is not constant 40035 | JS_PROP_DOUBLE_DEF("POSITIVE_INFINITY", INFINITY, 0 )
|
||||
|
||||
(1)open menuconfig (2)close math.h:build setup->Customize Header Files->math.h (2) select libmcs:Library Rountines->Select math library->Math Library fram LibmCS (3)build
|
||||
|
||||
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
|
||||
Change-Id: I6d70b7152e047b893429f49abc3c6c0e191735a4
|
||||
---
|
||||
libmcs/libmcs/Makefile.in | 1 -
|
||||
.../2000_misc_internal.rst | 1 -
|
||||
libmcs/libmcs/libm/common/tools.c | 7 -------
|
||||
libmcs/libmcs/libm/include/math.h | 12 ++++++------
|
||||
4 files changed, 6 insertions(+), 15 deletions(-)
|
||||
delete mode 100644 libm/common/tools.c
|
||||
|
||||
diff --git a/libmcs/libmcs/Makefile.in libmcs/libmcs/Makefile.in
|
||||
index 6e3bca4c1..a12073c6f 100644
|
||||
--- a/libmcs/libmcs/Makefile.in
|
||||
+++ libmcs/libmcs/Makefile.in
|
||||
@@ -81,7 +81,6 @@ CSRC = libm/complexd/cabsd.c \
|
||||
libm/complexf/internal/ctrigf.c
|
||||
|
||||
SRC = libm/common/signgam.c \
|
||||
- libm/common/tools.c \
|
||||
libm/mathd/acosd.c \
|
||||
libm/mathd/acoshd.c \
|
||||
libm/mathd/asind.c \
|
||||
diff --git a/libmcs/libmcs/doc/sdd/5_Software_Design/4_Software_Component_Design_Aspects_Of_Each_Component/2000_misc_internal.rst libmcs/libmcs/doc/sdd/5_Software_Design/4_Software_Component_Design_Aspects_Of_Each_Component/2000_misc_internal.rst
|
||||
index da1dd536b..f6bda14da 100644
|
||||
--- a/libmcs/libmcs/doc/sdd/5_Software_Design/4_Software_Component_Design_Aspects_Of_Each_Component/2000_misc_internal.rst
|
||||
+++ libmcs/libmcs/doc/sdd/5_Software_Design/4_Software_Component_Design_Aspects_Of_Each_Component/2000_misc_internal.rst
|
||||
@@ -28,7 +28,6 @@ Source Code Files
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
* libm/common/tools.h
|
||||
-* libm/common/tools.c
|
||||
|
||||
References
|
||||
^^^^^^^^^^
|
||||
diff --git a/libmcs/libmcs/libm/common/tools.c libmcs/libmcs/libm/common/tools.c
|
||||
deleted file mode 100644
|
||||
index 652dfe9f3..000000000
|
||||
--- a/libmcs/libmcs/libm/common/tools.c
|
||||
+++ /dev/null
|
||||
@@ -1,7 +0,0 @@
|
||||
-/* SPDX-License-Identifier: GTDGmbH */
|
||||
-/* Copyright 2020-2021 by GTD GmbH. */
|
||||
-
|
||||
-#include "tools.h"
|
||||
-
|
||||
-const float __inff = 1.0f/0.0f;
|
||||
-const double __infd = 1.0/0.0;
|
||||
diff --git a/libmcs/libmcs/libm/include/math.h libmcs/libmcs/libm/include/math.h
|
||||
index b0f6427df..8cfb61f6b 100644
|
||||
--- a/libmcs/libmcs/libm/include/math.h
|
||||
+++ libmcs/libmcs/libm/include/math.h
|
||||
@@ -35,15 +35,15 @@ typedef double double_t;
|
||||
#define M_SQRT2 1.41421356237309504880
|
||||
#define M_SQRT1_2 0.70710678118654752440
|
||||
|
||||
-#define HUGE_VAL (__infd)
|
||||
-#define HUGE_VALF (__inff)
|
||||
+#ifndef _HUGE_ENUF
|
||||
+#define _HUGE_ENUF (1e+300) /* _HUGE_ENUF*_HUGE_ENUF must overflow */
|
||||
+#endif
|
||||
+
|
||||
+#define HUGE_VAL ((double)(_HUGE_ENUF * _HUGE_ENUF))
|
||||
+#define HUGE_VALF ((float)(_HUGE_ENUF * _HUGE_ENUF))
|
||||
#define HUGE_VALL ((long double) HUGE_VAL)
|
||||
#define INFINITY HUGE_VALF
|
||||
|
||||
-/* Global constants that contain infinities. */
|
||||
-extern const float __inff;
|
||||
-extern const double __infd;
|
||||
-
|
||||
#define NAN (nanf(""))
|
||||
|
||||
#define FP_NAN 0
|
||||
--
|
||||
2.39.1
|
||||
|
10
libs/libm/libmcs/Kconfig
Normal file
10
libs/libm/libmcs/Kconfig
Normal file
|
@ -0,0 +1,10 @@
|
|||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config LIBM_LIBMCS_WANT_COMPLEX
|
||||
bool "libmcs complex support"
|
||||
default y
|
||||
---help---
|
||||
complex support, will use complex.h
|
238
libs/libm/libmcs/Make.defs
Normal file
238
libs/libm/libmcs/Make.defs
Normal file
|
@ -0,0 +1,238 @@
|
|||
|
||||
############################################################################
|
||||
# libs/libm/libmcs/Make.defs
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership. The
|
||||
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance with the
|
||||
# License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
LIBMCS_VERSION=1.2.0
|
||||
|
||||
libmcs-$(LIBMCS_VERSION).zip:
|
||||
$(call DOWNLOAD,https://gitlab.com/gtd-gmbh/libmcs/-/archive/$(LIBMCS_VERSION),libmcs-$(LIBMCS_VERSION).zip,libmcs.zip)
|
||||
|
||||
libmcs/libmcs: libmcs-$(LIBMCS_VERSION).zip
|
||||
$(Q) unzip -o libmcs.zip
|
||||
$(Q) mv libmcs-$(LIBMCS_VERSION) libmcs/libmcs
|
||||
$(Q) patch -p1 < libmcs/0001-fix-build-error-remove-unused-file-fenv.h.patch
|
||||
$(Q) patch -p1 < libmcs/0002-fix-build-error-do-not-include-config.h.patch
|
||||
$(Q) patch -p1 < libmcs/0003-fix-build-error-INFINITY-error-in-quickjs.c.patch
|
||||
$(Q) touch $@
|
||||
|
||||
ifeq ($(wildcard libmcs/libmcs/.git),)
|
||||
distclean::
|
||||
$(call DELFILE, libmcs.zip)
|
||||
$(call DELDIR, libmcs/libmcs)
|
||||
|
||||
context:: libmcs/libmcs
|
||||
else
|
||||
distclean::
|
||||
context::
|
||||
endif
|
||||
|
||||
VPATH += :libmcs/libmcs/libm/common
|
||||
VPATH += :libmcs/libmcs/libm/complexd
|
||||
VPATH += :libmcs/libmcs/libm/complexd/internal
|
||||
VPATH += :libmcs/libmcs/libm/complexf
|
||||
VPATH += :libmcs/libmcs/libm/complexf/internal
|
||||
VPATH += :libmcs/libmcs/libm/mathd
|
||||
VPATH += :libmcs/libmcs/libm/mathd/internal
|
||||
VPATH += :libmcs/libmcs/libm/mathf
|
||||
VPATH += :libmcs/libmcs/libm/mathf/internal
|
||||
|
||||
CFLAGS += ${INCDIR_PREFIX}libmcs/libmcs/libm/common
|
||||
CFLAGS += ${INCDIR_PREFIX}libmcs/libmcs/libm/mathd/internal
|
||||
CFLAGS += ${INCDIR_PREFIX}libmcs/libmcs/libm/mathf/internal
|
||||
|
||||
CSRCS = signgam.c \
|
||||
acosd.c \
|
||||
acoshd.c \
|
||||
asind.c \
|
||||
asinhd.c \
|
||||
atan2d.c \
|
||||
atand.c \
|
||||
atanhd.c \
|
||||
cbrtd.c \
|
||||
ceild.c \
|
||||
copysignd.c \
|
||||
cosd.c \
|
||||
coshd.c \
|
||||
erfcd.c \
|
||||
erfd.c \
|
||||
exp2d.c \
|
||||
expd.c \
|
||||
expm1d.c \
|
||||
fabsd.c \
|
||||
fdimd.c \
|
||||
floord.c \
|
||||
fmad.c \
|
||||
fmaxd.c \
|
||||
fmind.c \
|
||||
fmodd.c \
|
||||
frexpd.c \
|
||||
hypotd.c \
|
||||
ilogbd.c \
|
||||
fpclassifyd.c \
|
||||
gammad.c \
|
||||
signbitd.c \
|
||||
trigd.c \
|
||||
j0d.c \
|
||||
j1d.c \
|
||||
jnd.c \
|
||||
ldexpd.c \
|
||||
lgammad.c \
|
||||
llrintd.c \
|
||||
llroundd.c \
|
||||
log10d.c \
|
||||
log1pd.c \
|
||||
log2d.c \
|
||||
logbd.c \
|
||||
logd.c \
|
||||
lrintd.c \
|
||||
lroundd.c \
|
||||
modfd.c \
|
||||
nand.c \
|
||||
nearbyintd.c \
|
||||
nextafterd.c \
|
||||
nexttowardd.c \
|
||||
powd.c \
|
||||
remainderd.c \
|
||||
remquod.c \
|
||||
rintd.c \
|
||||
roundd.c \
|
||||
scalblnd.c \
|
||||
scalbnd.c \
|
||||
sind.c \
|
||||
sinhd.c \
|
||||
sqrtd.c \
|
||||
tand.c \
|
||||
tanhd.c \
|
||||
tgammad.c \
|
||||
truncd.c \
|
||||
y0d.c \
|
||||
y1d.c \
|
||||
ynd.c \
|
||||
acosf.c \
|
||||
acoshf.c \
|
||||
asinf.c \
|
||||
asinhf.c \
|
||||
atan2f.c \
|
||||
atanf.c \
|
||||
atanhf.c \
|
||||
cbrtf.c \
|
||||
ceilf.c \
|
||||
copysignf.c \
|
||||
cosf.c \
|
||||
coshf.c \
|
||||
erfcf.c \
|
||||
erff.c \
|
||||
exp2f.c \
|
||||
expf.c \
|
||||
expm1f.c \
|
||||
fabsf.c \
|
||||
fdimf.c \
|
||||
floorf.c \
|
||||
fmaf.c \
|
||||
fmaxf.c \
|
||||
fminf.c \
|
||||
fmodf.c \
|
||||
frexpf.c \
|
||||
hypotf.c \
|
||||
ilogbf.c \
|
||||
fpclassifyf.c \
|
||||
gammaf.c \
|
||||
signbitf.c \
|
||||
trigf.c \
|
||||
ldexpf.c \
|
||||
lgammaf.c \
|
||||
llrintf.c \
|
||||
llroundf.c \
|
||||
log10f.c \
|
||||
log1pf.c \
|
||||
log2f.c \
|
||||
logbf.c \
|
||||
logf.c \
|
||||
lrintf.c \
|
||||
lroundf.c \
|
||||
modff.c \
|
||||
nanf.c \
|
||||
nearbyintf.c \
|
||||
nextafterf.c \
|
||||
nexttowardf.c \
|
||||
powf.c \
|
||||
remainderf.c \
|
||||
remquof.c \
|
||||
rintf.c \
|
||||
roundf.c \
|
||||
scalblnf.c \
|
||||
scalbnf.c \
|
||||
sinf.c \
|
||||
sinhf.c \
|
||||
sqrtf.c \
|
||||
tanf.c \
|
||||
tanhf.c \
|
||||
tgammaf.c \
|
||||
truncf.c
|
||||
|
||||
ifeq ($(CONFIG_LIBM_LIBMCS_WANT_COMPLEX),y)
|
||||
CFLAGS += -DLIBMCS_WANT_COMPLEX
|
||||
CSRCS += cabsd.c \
|
||||
cacosd.c \
|
||||
cacoshd.c \
|
||||
cargd.c \
|
||||
casind.c \
|
||||
casinhd.c \
|
||||
catand.c \
|
||||
catanhd.c \
|
||||
ccosd.c \
|
||||
ccoshd.c \
|
||||
cexpd.c \
|
||||
cimagd.c \
|
||||
clogd.c \
|
||||
conjd.c \
|
||||
cpowd.c \
|
||||
cprojd.c \
|
||||
creald.c \
|
||||
csind.c \
|
||||
csinhd.c \
|
||||
csqrtd.c \
|
||||
ctand.c \
|
||||
ctanhd.c \
|
||||
ctrigd.c \
|
||||
cabsf.c \
|
||||
cacosf.c \
|
||||
cacoshf.c \
|
||||
cargf.c \
|
||||
casinf.c \
|
||||
casinhf.c \
|
||||
catanf.c \
|
||||
catanhf.c \
|
||||
ccosf.c \
|
||||
ccoshf.c \
|
||||
cexpf.c \
|
||||
cimagf.c \
|
||||
clogf.c \
|
||||
conjf.c \
|
||||
cpowf.c \
|
||||
cprojf.c \
|
||||
crealf.c \
|
||||
csinf.c \
|
||||
csinhf.c \
|
||||
csqrtf.c \
|
||||
ctanf.c \
|
||||
ctanhf.c \
|
||||
ctrigf.c
|
||||
endif
|
|
@ -662,6 +662,13 @@ ifeq ($(CONFIG_LIBM_NEWLIB),y)
|
|||
ARCHXXINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libm$(DELIM)newlib$(DELIM)include
|
||||
endif
|
||||
|
||||
#libmcs`s math.h should include after libcxx, or it will override libcxx/include/math.h and build error
|
||||
ifeq ($(CONFIG_LIBM_LIBMCS),y)
|
||||
ARCHDEFINES += ${DEFINE_PREFIX}LIBMCS_LONG_DOUBLE_IS_64BITS
|
||||
ARCHXXINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libm$(DELIM)libmcs$(DELIM)libmcs$(DELIM)libm$(DELIM)include
|
||||
ARCHINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libm$(DELIM)libmcs$(DELIM)libmcs$(DELIM)libm$(DELIM)include
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LIBM_OPENLIBM),y)
|
||||
ARCHINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libm$(DELIM)openlibm$(DELIM)openlibm$(DELIM)include
|
||||
ARCHXXINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libm$(DELIM)openlibm$(DELIM)openlibm$(DELIM)include
|
||||
|
|
Loading…
Reference in a new issue