libm/newlib: add newlib/libm support

Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
This commit is contained in:
yanghuatao
2023-04-22 19:08:00 +08:00
committed by Xiang Xiao
parent 70395f49b2
commit 826dd87f30
13 changed files with 2172 additions and 1 deletions
+10
View File
@@ -33,6 +33,12 @@ config LIBM
comes from the Rhombus OS and was written by Nick Johnson. The
Rhombus OS math library port was contributed by Darcy Gong.
config LIBM_NEWLIB
bool "Math library from Newlib"
depends on !ARCH_MATH_H
---help---
Math library from Newlib
config LIBM_TOOLCHAIN
bool "Math library from toolchain"
@@ -44,3 +50,7 @@ endchoice
if LIBM
source "libs/libm/libm/Kconfig"
endif
if LIBM_NEWLIB
source "libs/libm/newlib/Kconfig"
endif
+3 -1
View File
@@ -22,6 +22,8 @@ include $(TOPDIR)/Make.defs
ifeq ($(CONFIG_LIBM),y)
include libm/Make.defs
else ifeq ($(CONFIG_LIBM_NEWLIB),y)
include newlib/Make.defs
endif
BINDIR ?= bin
@@ -87,7 +89,7 @@ clean:
# Deep clean -- removes all traces of the configuration
distclean: clean
distclean:: clean
$(Q) $(MAKE) -C bin distclean
$(Q) $(MAKE) -C kbin distclean
$(call DELFILE, bin$(DELIM)Make.dep)
@@ -0,0 +1,84 @@
From 47160b8facc968ed945decfa3ed5f1d4c608ac90 Mon Sep 17 00:00:00 2001
From: yanghuatao <yanghuatao@xiaomi.com>
Date: Sun, 26 Mar 2023 01:16:23 +0800
Subject: [PATCH 1/2] newlib libm fix __RCSID build error
VELAPLATFO-6159
remove code __RCSID in newlib/libm
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
Change-Id: I7eec03396b911ead48183fc80936475a9136f3ee
---
newlib/libm/complex/conjl.c | 3 ---
newlib/libm/complex/cprojl.c | 3 ---
newlib/libm/complex/csqrtl.c | 8 --------
newlib/libm/machine/sparc/fenv.c | 5 -----
4 files changed, 19 deletions(-)
diff --git a/newlib/newlib/newlib/libm/complex/conjl.c newlib/newlib/newlib/libm/complex/conjl.c
index 35094ce89..75c8544a1 100644
--- a/newlib/newlib/newlib/libm/complex/conjl.c
+++ newlib/newlib/newlib/libm/complex/conjl.c
@@ -25,9 +25,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$NetBSD: conjl.c,v 1.4 2010/09/20 16:55:20 christos Exp $");
-
#include <complex.h>
#include "../common/fdlibm.h"
diff --git a/newlib/newlib/newlib/libm/complex/cprojl.c newlib/newlib/newlib/libm/complex/cprojl.c
index e71c77353..93308b29f 100644
--- a/newlib/newlib/newlib/libm/complex/cprojl.c
+++ newlib/newlib/newlib/libm/complex/cprojl.c
@@ -25,9 +25,6 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__RCSID("$NetBSD: cprojl.c,v 1.7 2014/10/10 00:48:18 christos Exp $");
-
#include <complex.h>
#include <math.h>
diff --git a/newlib/newlib/newlib/libm/complex/csqrtl.c newlib/newlib/newlib/libm/complex/csqrtl.c
index c10a1264a..96c177c03 100644
--- a/newlib/newlib/newlib/libm/complex/csqrtl.c
+++ newlib/newlib/newlib/libm/complex/csqrtl.c
@@ -23,14 +23,6 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-
-#include <sys/cdefs.h>
-#if 0
-__FBSDID("$FreeBSD: head/lib/msun/src/s_csqrtl.c 181402 2008-08-08 00:15:16Z das $");
-#else
-__RCSID("$NetBSD: csqrtl.c,v 1.2 2014/10/11 00:43:51 christos Exp $");
-#endif
-
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/newlib/newlib/newlib/libm/machine/sparc/fenv.c newlib/newlib/newlib/libm/machine/sparc/fenv.c
index 127898021..b2bcdc1e4 100644
--- a/newlib/newlib/newlib/libm/machine/sparc/fenv.c
+++ newlib/newlib/newlib/libm/machine/sparc/fenv.c
@@ -23,11 +23,6 @@
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
*/
-#include <sys/cdefs.h>
-__RCSID("$NetBSD: fenv.c,v 1.2 2017/03/22 23:11:09 chs Exp $");
-
-
-
#include <assert.h>
#include <fenv.h>
--
2.39.1
@@ -0,0 +1,69 @@
From 4bf252f304579f3d0c162a573b64547cd4fb4c05 Mon Sep 17 00:00:00 2001
From: yanghuatao <yanghuatao@xiaomi.com>
Date: Sun, 26 Mar 2023 09:31:15 +0800
Subject: [PATCH 2/2] newlib libm remove include reent.h
VELAPLATFO-6159
remove include reent.h
Signed-off-by: yanghuatao <yanghuatao@xiaomi.com>
Change-Id: I8265baa3bfc9df9035fb45f02676047ea8adacbd
---
newlib/libm/math/w_gamma.c | 1 -
newlib/libm/math/w_lgamma.c | 1 -
newlib/libm/math/wf_gamma.c | 1 -
newlib/libm/math/wf_lgamma.c | 1 -
4 files changed, 4 deletions(-)
diff --git a/newlib/newlib/newlib/libm/math/w_gamma.c newlib/newlib/newlib/libm/math/w_gamma.c
index 16962c570..fdbe2c8b4 100644
--- a/newlib/newlib/newlib/libm/math/w_gamma.c
+++ newlib/newlib/newlib/libm/math/w_gamma.c
@@ -136,7 +136,6 @@ in terms of the base return values, although the <[signgam]> global for
*/
#include "fdlibm.h"
-#include <reent.h>
#include <errno.h>
#ifndef _DOUBLE_IS_32BITS
diff --git a/newlib/newlib/newlib/libm/math/w_lgamma.c newlib/newlib/newlib/libm/math/w_lgamma.c
index c075a4fc1..054291162 100644
--- a/newlib/newlib/newlib/libm/math/w_lgamma.c
+++ newlib/newlib/newlib/libm/math/w_lgamma.c
@@ -19,7 +19,6 @@
*/
#include "fdlibm.h"
-#include <reent.h>
#include <errno.h>
#ifdef _REENT_THREAD_LOCAL
diff --git a/newlib/newlib/newlib/libm/math/wf_gamma.c newlib/newlib/newlib/libm/math/wf_gamma.c
index 29f88a50b..0a4c31cd7 100644
--- a/newlib/newlib/newlib/libm/math/wf_gamma.c
+++ newlib/newlib/newlib/libm/math/wf_gamma.c
@@ -15,7 +15,6 @@
*/
#include "fdlibm.h"
-#include <reent.h>
#include <errno.h>
#ifdef __STDC__
diff --git a/newlib/newlib/newlib/libm/math/wf_lgamma.c newlib/newlib/newlib/libm/math/wf_lgamma.c
index b232ecfe4..f64aa6347 100644
--- a/newlib/newlib/newlib/libm/math/wf_lgamma.c
+++ newlib/newlib/newlib/libm/math/wf_lgamma.c
@@ -15,7 +15,6 @@
*/
#include "fdlibm.h"
-#include <reent.h>
#include <errno.h>
#ifdef __STDC__
--
2.39.1
+12
View File
@@ -0,0 +1,12 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config LIBM_NEWLIB_HW_FP
bool "Newlib hardware floating-point routines"
default n
---help---
The option is being disabled because the mathfp library is
not up to standard due to inaccuracies caused by some of the
floating-point algorithms used.
+90
View File
@@ -0,0 +1,90 @@
############################################################################
# libs/libm/newlib/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.
#
############################################################################
NEWLIB_VERSION=4.3.0.20230120
newlib-$(NEWLIB_VERSION).tar.gz:
$(call DOWNLOAD,ftp://sourceware.org/pub/newlib,newlib-$(NEWLIB_VERSION).tar.gz)
newlib/newlib: newlib-$(NEWLIB_VERSION).tar.gz
$(Q) tar -xf newlib-$(NEWLIB_VERSION).tar.gz
$(Q) mv newlib-$(NEWLIB_VERSION) newlib/newlib
$(Q) patch -p0 < newlib/0001-newlib-libm-fix-__RCSID-build-error.patch
$(Q) patch -p0 < newlib/0002-newlib-libm-remove-include-reent.h.patch
$(Q) touch $@
ifeq ($(wildcard newlib/newlib/.git),)
distclean::
$(call DELFILE, newlib-$(NEWLIB_VERSION).tar.gz)
$(call DELDIR, newlib/newlib)
context:: newlib/newlib
else
distclean::
context::
endif
CSRCS += $(wildcard newlib/newlib/newlib/libm/common/*.c)
CSRCS += $(wildcard newlib/newlib/newlib/libm/complex/*.c)
VPATH += :newlib/newlib/newlib/libm/common
VPATH += :newlib/newlib/newlib/libm/complex
ifeq ($(CONFIG_ARCH_ARM),y)
ARCH = arm
else ifeq ($(CONFIG_ARCH_ARM64),y)
ARCH = aarch64
else ifeq ($(CONFIG_ARCH_RISCV),y)
ARCH = riscv
else ifeq ($(CONFIG_ARCH_X86),y)
ARCH = i386
else ifeq ($(CONFIG_ARCH_X86_64),y)
ARCH = x86_64
else ifeq ($(CONFIG_ARCH_SPARC),y)
ARCH = sparc
else ifeq ($(CONFIG_ARCH_MIPS),y)
ARCH = mips
else
ARCH = $(CONFIG_ARCH)
endif
CSRCS += $(wildcard newlib/newlib/newlib/libm/machine/$(ARCH)/*.c)
VPATH += :newlib/newlib/newlib/libm/machine/$(ARCH)
ifeq ($(CONFIG_LIBM_NEWLIB_HW_FP),y)
CSRCS += $(wildcard newlib/newlib/newlib/libm/mathfp/*.c)
VPATH += :newlib/newlib/newlib/libm/mathfp
CFLAGS += -Wno-dangling-else
CFLAGS += -Wno-endif-labels
CFLAGS += -Wno-implicit-function-declaration
CFLAGS += -Wno-missing-braces
CFLAGS += -Wno-shadow
CFLAGS += -Wno-strict-prototypes
CFLAGS += -Wno-unused-const-variable
else
CSRCS += $(wildcard newlib/newlib/newlib/libm/math/*.c)
VPATH += :newlib/newlib/newlib/libm/math
endif
CSRCS := $(shell echo $(notdir $(CSRCS) | tr " " "\n" | sort | uniq))
CFLAGS += -Wno-undef -Wno-unused-but-set-variable
CFLAGS += ${INCDIR_PREFIX}newlib/newlib/newlib/libm/common
CFLAGS += -D__int32_t=int32_t -D__uint32_t=uint32_t -D_REENT=0 -D_REENT_THREAD_LOCAL=1
+189
View File
@@ -0,0 +1,189 @@
/****************************************************************************
* libs/libm/newlib/include/complex.h
*
* 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.
*
****************************************************************************/
/* Written by Matthias Drochner.
* Public domain.
*/
#ifndef _COMPLEX_H
#define _COMPLEX_H
#define complex _Complex
#define _Complex_I 1.0fi
#define I _Complex_I
#ifdef __cplusplus
extern "C"
{
#endif
/* 7.3.5 Trigonometric functions */
/* 7.3.5.1 The cacos functions */
double complex cacos(double complex);
float complex cacosf(float complex);
long double complex cacosl(long double complex);
/* 7.3.5.2 The casin functions */
double complex casin(double complex);
float complex casinf(float complex);
long double complex casinl(long double complex);
/* 7.3.5.1 The catan functions */
double complex catan(double complex);
float complex catanf(float complex);
long double complex catanl(long double complex);
/* 7.3.5.1 The ccos functions */
double complex ccos(double complex);
float complex ccosf(float complex);
long double complex ccosl(long double complex);
/* 7.3.5.1 The csin functions */
double complex csin(double complex);
float complex csinf(float complex);
long double complex csinl(long double complex);
/* 7.3.5.1 The ctan functions */
double complex ctan(double complex);
float complex ctanf(float complex);
long double complex ctanl(long double complex);
/* 7.3.6 Hyperbolic functions */
/* 7.3.6.1 The cacosh functions */
double complex cacosh(double complex);
float complex cacoshf(float complex);
long double complex cacoshl(long double complex);
/* 7.3.6.2 The casinh functions */
double complex casinh(double complex);
float complex casinhf(float complex);
long double complex casinhl(long double complex);
/* 7.3.6.3 The catanh functions */
double complex catanh(double complex);
float complex catanhf(float complex);
long double complex catanhl(long double complex);
/* 7.3.6.4 The ccosh functions */
double complex ccosh(double complex);
float complex ccoshf(float complex);
long double complex ccoshl(long double complex);
/* 7.3.6.5 The csinh functions */
double complex csinh(double complex);
float complex csinhf(float complex);
long double complex csinhl(long double complex);
/* 7.3.6.6 The ctanh functions */
double complex ctanh(double complex);
float complex ctanhf(float complex);
long double complex ctanhl(long double complex);
/* 7.3.7 Exponential and logarithmic functions */
/* 7.3.7.1 The cexp functions */
double complex cexp(double complex);
float complex cexpf(float complex);
long double complex cexpl(long double complex);
/* 7.3.7.2 The clog functions */
double complex clog(double complex);
float complex clogf(float complex);
long double complex clogl(long double complex);
/* 7.3.8 Power and absolute-value functions */
/* 7.3.8.1 The cabs functions */
long double cabsl(long double complex) ;
double cabs(double complex) ;
float cabsf(float complex) ;
/* 7.3.8.2 The cpow functions */
double complex cpow(double complex, double complex);
float complex cpowf(float complex, float complex);
long double complex cpowl(long double complex, long double complex);
/* 7.3.8.3 The csqrt functions */
double complex csqrt(double complex);
float complex csqrtf(float complex);
long double complex csqrtl(long double complex);
/* 7.3.9 Manipulation functions */
/* 7.3.9.1 The carg functions */
double carg(double complex);
float cargf(float complex);
long double cargl(long double complex);
/* 7.3.9.2 The cimag functions */
double cimag(double complex);
float cimagf(float complex);
long double cimagl(long double complex);
/* 7.3.9.3 The conj functions */
double complex conj(double complex);
float complex conjf(float complex);
long double complex conjl(long double complex);
/* 7.3.9.4 The cproj functions */
double complex cproj(double complex);
float complex cprojf(float complex);
long double complex cprojl(long double complex);
/* 7.3.9.5 The creal functions */
double creal(double complex);
float crealf(float complex);
long double creall(long double complex);
double complex clog10(double complex);
float complex clog10f(float complex);
# if defined(__CYGWIN__)
long double complex clog10l(long double complex);
# endif
#ifdef __cplusplus
}
#endif
#endif /* ! _COMPLEX_H */
+317
View File
@@ -0,0 +1,317 @@
/****************************************************************************
* libs/libm/newlib/include/ieeefp.h
*
* 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.
*
****************************************************************************/
#ifndef _IEEE_FP_H_
#define _IEEE_FP_H_
/****************************************************************************
* Included Files
****************************************************************************/
#include <machine/ieeefp.h>
#include <float.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* FIXME FIXME FIXME:
* Neither of __ieee_{float,double}_shape_type seem to be used anywhere
* except in libm/test. If that is the case, please delete these from here.
* If that is not the case, please insert documentation here describing why
* they're needed.
*/
#ifdef __IEEE_BIG_ENDIAN
typedef union
{
double value;
struct
{
unsigned int sign : 1;
unsigned int exponent: 11;
unsigned int fraction0:4;
unsigned int fraction1:16;
unsigned int fraction2:16;
unsigned int fraction3:16;
} number;
struct
{
unsigned int sign : 1;
unsigned int exponent: 11;
unsigned int quiet:1;
unsigned int function0:3;
unsigned int function1:16;
unsigned int function2:16;
unsigned int function3:16;
} nan;
struct
{
unsigned long msw;
unsigned long lsw;
} parts;
long aslong[2];
} __ieee_double_shape_type;
#elif defined __IEEE_LITTLE_ENDIAN
typedef union
{
double value;
struct
{
#ifdef __SMALL_BITFIELDS
unsigned int fraction3:16;
unsigned int fraction2:16;
unsigned int fraction1:16;
unsigned int fraction0: 4;
#else
unsigned int fraction1:32;
unsigned int fraction0:20;
#endif
unsigned int exponent :11;
unsigned int sign : 1;
} number;
struct
{
#ifdef __SMALL_BITFIELDS
unsigned int function3:16;
unsigned int function2:16;
unsigned int function1:16;
unsigned int function0:3;
#else
unsigned int function1:32;
unsigned int function0:19;
#endif
unsigned int quiet:1;
unsigned int exponent: 11;
unsigned int sign : 1;
} nan;
struct
{
unsigned long lsw;
unsigned long msw;
} parts;
long aslong[2];
} __ieee_double_shape_type;
#endif /* __IEEE_LITTLE_ENDIAN */
#ifdef __IEEE_BIG_ENDIAN
typedef union
{
float value;
struct
{
unsigned int sign : 1;
unsigned int exponent: 8;
unsigned int fraction0: 7;
unsigned int fraction1: 16;
} number;
struct
{
unsigned int sign:1;
unsigned int exponent:8;
unsigned int quiet:1;
unsigned int function0:6;
unsigned int function1:16;
} nan;
long p1;
} __ieee_float_shape_type;
#elif defined __IEEE_LITTLE_ENDIAN
typedef union
{
float value;
struct
{
unsigned int fraction0: 7;
unsigned int fraction1: 16;
unsigned int exponent: 8;
unsigned int sign : 1;
} number;
struct
{
unsigned int function1:16;
unsigned int function0:6;
unsigned int quiet:1;
unsigned int exponent:8;
unsigned int sign:1;
} nan;
long p1;
} __ieee_float_shape_type;
#endif /* __IEEE_LITTLE_ENDIAN */
#ifndef _LDBL_EQ_DBL
#ifndef LDBL_MANT_DIG
#error "LDBL_MANT_DIG not defined - should be found in float.h"
#elif LDBL_MANT_DIG == DBL_MANT_DIG
#error "double and long double are the same size but LDBL_EQ_DBL is not defined"
#elif LDBL_MANT_DIG == 53
/* This happens when doubles are 32-bits and long doubles are 64-bits. */
#define EXT_EXPBITS 11
#define EXT_FRACHBITS 20
#define EXT_FRACLBITS 32
#define __ieee_ext_field_type unsigned long
#elif LDBL_MANT_DIG == 64
#define EXT_EXPBITS 15
#define EXT_FRACHBITS 32
#define EXT_FRACLBITS 32
#define __ieee_ext_field_type unsigned int
#elif LDBL_MANT_DIG == 65
#define EXT_EXPBITS 15
#define EXT_FRACHBITS 32
#define EXT_FRACLBITS 32
#define __ieee_ext_field_type unsigned int
#elif LDBL_MANT_DIG == 112
#define EXT_EXPBITS 15
#define EXT_FRACHBITS 48
#define EXT_FRACLBITS 64
#define __ieee_ext_field_type unsigned long long
#elif LDBL_MANT_DIG == 113
#define EXT_EXPBITS 15
#define EXT_FRACHBITS 48
#define EXT_FRACLBITS 64
#define __ieee_ext_field_type unsigned long long
#else
#error Unsupported value for LDBL_MANT_DIG
#endif
#define EXT_EXP_INFNAN ((1 << EXT_EXPBITS) - 1) /* 32767 */
#define EXT_EXP_BIAS ((1 << (EXT_EXPBITS - 1)) - 1) /* 16383 */
#define EXT_FRACBITS (EXT_FRACLBITS + EXT_FRACHBITS)
typedef struct ieee_ext
{
__ieee_ext_field_type ext_fracl : EXT_FRACLBITS;
__ieee_ext_field_type ext_frach : EXT_FRACHBITS;
__ieee_ext_field_type ext_exp : EXT_EXPBITS;
__ieee_ext_field_type ext_sign : 1;
} ieee_ext;
typedef union ieee_ext_u
{
long double extu_ld;
struct ieee_ext extu_ext;
} ieee_ext_u;
#endif /* ! _LDBL_EQ_DBL */
/* FLOATING ROUNDING */
typedef int fp_rnd;
#define FP_RN 0 /* Round to nearest */
#define FP_RM 1 /* Round down */
#define FP_RP 2 /* Round up */
#define FP_RZ 3 /* Round to zero (trunate) */
fp_rnd fpgetround (void);
fp_rnd fpsetround (fp_rnd);
/* EXCEPTIONS */
typedef int fp_except;
#define FP_X_INV 0x10 /* Invalid operation */
#define FP_X_DX 0x80 /* Divide by zero */
#define FP_X_OFL 0x04 /* Overflow exception */
#define FP_X_UFL 0x02 /* Underflow exception */
#define FP_X_IMP 0x01 /* imprecise exception */
fp_except fpgetmask (void);
fp_except fpsetmask (fp_except);
fp_except fpgetsticky (void);
fp_except fpsetsticky (fp_except);
/* INTEGER ROUNDING */
typedef int fp_rdi;
#define FP_RDI_TOZ 0 /* Round to Zero */
#define FP_RDI_RD 1 /* Follow float mode */
fp_rdi fpgetroundtoi (void);
fp_rdi fpsetroundtoi (fp_rdi);
#define __IEEE_DBL_EXPBIAS 1023
#define __IEEE_FLT_EXPBIAS 127
#define __IEEE_DBL_EXPLEN 11
#define __IEEE_FLT_EXPLEN 8
#define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
#define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))
#define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
#define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1))
#define __IEEE_DBL_NAN_EXP 0x7ff
#define __IEEE_FLT_NAN_EXP 0xff
#ifdef __ieeefp_isnanf
#define isnanf(x) __ieeefp_isnanf(x)
#endif
#ifdef __ieeefp_isinff
#define isinff(x) __ieeefp_isinff(x)
#endif
#ifdef __ieeefp_finitef
#define finitef(x) __ieeefp_finitef(x)
#endif
#ifdef _DOUBLE_IS_32BITS
#undef __IEEE_DBL_EXPBIAS
#define __IEEE_DBL_EXPBIAS __IEEE_FLT_EXPBIAS
#undef __IEEE_DBL_EXPLEN
#define __IEEE_DBL_EXPLEN __IEEE_FLT_EXPLEN
#undef __IEEE_DBL_FRACLEN
#define __IEEE_DBL_FRACLEN __IEEE_FLT_FRACLEN
#undef __IEEE_DBL_MAXPOWTWO
#define __IEEE_DBL_MAXPOWTWO __IEEE_FLT_MAXPOWTWO
#undef __IEEE_DBL_NAN_EXP
#define __IEEE_DBL_NAN_EXP __IEEE_FLT_NAN_EXP
#undef __ieee_double_shape_type
#define __ieee_double_shape_type __ieee_float_shape_type
#endif /* _DOUBLE_IS_32BITS */
#ifdef __cplusplus
}
#endif
#endif /* _IEEE_FP_H_ */
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+189
View File
@@ -0,0 +1,189 @@
/* http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/tgmath.h.html */
/* Copyright (c) 2004 Stefan Farfeleder.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _TGMATH_H_
#define _TGMATH_H_
/****************************************************************************
* Included Files
****************************************************************************/
#include <complex.h>
#include <math.h>
#ifdef log2
#undef log2
#endif
/* This implementation of <tgmath.h> requires two implementation-dependent
* macros to be defined:
* __tg_impl_simple(x, y, z, fn, fnf, fnl, ...)
* Invokes fnl() if the corresponding real type of x, y or z is long
* double, fn() if it is double or any has an integer type, and fnf()
* otherwise.
* __tg_impl_full(x, y, z, fn, fnf, fnl, cfn, cfnf, cfnl, ...)
* Invokes [c]fnl() if the corresponding real type of x, y or z is long
* double, [c]fn() if it is double or any has an integer type, and
* [c]fnf() otherwise. The function with the 'c' prefix is called if
* any of x, y or z is a complex number.
* Both macros call the chosen function with all additional arguments passed
* to them, as given by __VA_ARGS__.
*
* Note that these macros cannot be implemented with C's ?: operator,
* because the return type of the whole expression would incorrectly be long
* double complex regardless of the argument types.
*/
/* requires GCC >= 3.1 */
#if !__GNUC_PREREQ (3, 1)
#error "<tgmath.h> not implemented for this compiler"
#endif
#define __tg_type(__e, __t) \
__builtin_types_compatible_p(__typeof__(__e), __t)
#define __tg_type3(__e1, __e2, __e3, __t) \
(__tg_type(__e1, __t) || __tg_type(__e2, __t) || \
__tg_type(__e3, __t))
#define __tg_type_corr(__e1, __e2, __e3, __t) \
(__tg_type3(__e1, __e2, __e3, __t) || \
__tg_type3(__e1, __e2, __e3, __t _Complex))
#define __tg_integer(__e1, __e2, __e3) \
(((__typeof__(__e1))1.5 == 1) || ((__typeof__(__e2))1.5 == 1) || \
((__typeof__(__e3))1.5 == 1))
#define __tg_is_complex(__e1, __e2, __e3) \
(__tg_type3(__e1, __e2, __e3, float _Complex) || \
__tg_type3(__e1, __e2, __e3, double _Complex) || \
__tg_type3(__e1, __e2, __e3, long double _Complex) || \
__tg_type3(__e1, __e2, __e3, __typeof__(_Complex_I)))
#if defined (_LDBL_EQ_DBL) || defined (__CYGWIN__)
#define __tg_impl_simple(x, y, z, fn, fnf, fnl, ...) \
__builtin_choose_expr(__tg_type_corr(x, y, z, long double), \
fnl(__VA_ARGS__), __builtin_choose_expr( \
__tg_type_corr(x, y, z, double) || __tg_integer(x, y, z), \
fn(__VA_ARGS__), fnf(__VA_ARGS__)))
#else
#define __tg_impl_simple(__x, __y, __z, __fn, __fnf, __fnl, ...) \
(__tg_type_corr(__x, __y, __z, double) || __tg_integer(__x, __y, __z)) \
? __fn(__VA_ARGS__) : __fnf(__VA_ARGS__)
#endif
#define __tg_impl_full(__x, __y, __z, __fn, __fnf, __fnl, __cfn, __cfnf, __cfnl, ...) \
__builtin_choose_expr(__tg_is_complex(__x, __y, __z), \
__tg_impl_simple(__x, __y, __z, __cfn, __cfnf, __cfnl, __VA_ARGS__), \
__tg_impl_simple(__x, __y, __z, __fn, __fnf, __fnl, __VA_ARGS__))
/* Macros to save lots of repetition below */
#define __tg_simple(__x, __fn) \
__tg_impl_simple(__x, __x, __x, __fn, __fn##f, __fn##l, __x)
#define __tg_simple2(__x, __y, __fn) \
__tg_impl_simple(__x, __x, __y, __fn, __fn##f, __fn##l, __x, __y)
#define __tg_simplev(__x, __fn, ...) \
__tg_impl_simple(__x, __x, __x, __fn, __fn##f, __fn##l, __VA_ARGS__)
#define __tg_full(__x, __fn) \
__tg_impl_full(__x, __x, __x, __fn, __fn##f, __fn##l, c##__fn, c##__fn##f, c##__fn##l, __x)
/* 7.22#4 -- These macros expand to real or complex functions, depending on
* the type of their arguments.
*/
#define acos(__x) __tg_full(__x, acos)
#define asin(__x) __tg_full(__x, asin)
#define atan(__x) __tg_full(__x, atan)
#define acosh(__x) __tg_full(__x, acosh)
#define asinh(__x) __tg_full(__x, asinh)
#define atanh(__x) __tg_full(__x, atanh)
#define cos(__x) __tg_full(__x, cos)
#define sin(__x) __tg_full(__x, sin)
#define tan(__x) __tg_full(__x, tan)
#define cosh(__x) __tg_full(__x, cosh)
#define sinh(__x) __tg_full(__x, sinh)
#define tanh(__x) __tg_full(__x, tanh)
#define exp(__x) __tg_full(__x, exp)
#define log(__x) __tg_full(__x, log)
#define pow(__x, __y) __tg_impl_full(__x, __x, __y, pow, powf, powl, \
cpow, cpowf, cpowl, __x, __y)
#define sqrt(__x) __tg_full(__x, sqrt)
/* "The corresponding type-generic macro for fabs and cabs is fabs." */
#define fabs(__x) __tg_impl_full(__x, __x, __x, fabs, fabsf, fabsl, \
cabs, cabsf, cabsl, __x)
/* 7.22#5 -- These macros are only defined for arguments with real type. */
#define atan2(__x, __y) __tg_simple2(__x, __y, atan2)
#define cbrt(__x) __tg_simple(__x, cbrt)
#define ceil(__x) __tg_simple(__x, ceil)
#define copysign(__x, __y) __tg_simple2(__x, __y, copysign)
#define erf(__x) __tg_simple(__x, erf)
#define erfc(__x) __tg_simple(__x, erfc)
#define exp2(__x) __tg_simple(__x, exp2)
#define expm1(__x) __tg_simple(__x, expm1)
#define fdim(__x, __y) __tg_simple2(__x, __y, fdim)
#define floor(__x) __tg_simple(__x, floor)
#define fma(__x, __y, __z) __tg_impl_simple(__x, __y, __z, fma, fmaf, fmal, \
__x, __y, __z)
#define fmax(__x, __y) __tg_simple2(__x, __y, fmax)
#define fmin(__x, __y) __tg_simple2(__x, __y, fmin)
#define fmod(__x, __y) __tg_simple2(__x, __y, fmod)
#define frexp(__x, __y) __tg_simplev(__x, frexp, __x, __y)
#define hypot(__x, __y) __tg_simple2(__x, __y, hypot)
#define ilogb(__x) __tg_simple(__x, ilogb)
#define ldexp(__x, __y) __tg_simplev(__x, ldexp, __x, __y)
#define lgamma(__x) __tg_simple(__x, lgamma)
#define llrint(__x) __tg_simple(__x, llrint)
#define llround(__x) __tg_simple(__x, llround)
#define log10(__x) __tg_simple(__x, log10)
#define log1p(__x) __tg_simple(__x, log1p)
#define log2(__x) __tg_simple(__x, log2)
#define logb(__x) __tg_simple(__x, logb)
#define lrint(__x) __tg_simple(__x, lrint)
#define lround(__x) __tg_simple(__x, lround)
#define nearbyint(__x) __tg_simple(__x, nearbyint)
#define nextafter(__x, __y) __tg_simple2(__x, __y, nextafter)
/* not yet implemented even for _LDBL_EQ_DBL platforms */
#ifdef __CYGWIN__
#define nexttoward(__x, __y) __tg_simplev(__x, nexttoward, __x, __y)
#endif
#define remainder(__x, __y) __tg_simple2(__x, __y, remainder)
#define remquo(__x, __y, __z) __tg_impl_simple(__x, __x, __y, remquo, remquof, \
remquol, __x, __y, __z)
#define rint(__x) __tg_simple(__x, rint)
#define round(__x) __tg_simple(__x, round)
#define scalbn(__x, __y) __tg_simplev(__x, scalbn, __x, __y)
#define scalbln(__x, __y) __tg_simplev(__x, scalbln, __x, __y)
#define tgamma(__x) __tg_simple(__x, tgamma)
#define trunc(__x) __tg_simple(__x, trunc)
/* 7.22#6 -- These macros always expand to complex functions. */
#define carg(__x) __tg_simple(__x, carg)
#define cimag(__x) __tg_simple(__x, cimag)
#define conj(__x) __tg_simple(__x, conj)
#define cproj(__x) __tg_simple(__x, cproj)
#define creal(__x) __tg_simple(__x, creal)
#endif /* !_TGMATH_H_ */
+6
View File
@@ -656,6 +656,12 @@ else
ARCHXXINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)include$(DELIM)etl
endif
endif
ifeq ($(CONFIG_LIBM_NEWLIB),y)
ARCHINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libm$(DELIM)newlib$(DELIM)include
ARCHXXINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)libs$(DELIM)libm$(DELIM)newlib$(DELIM)include
endif
ARCHXXINCLUDES += ${INCSYSDIR_PREFIX}$(TOPDIR)$(DELIM)include
# Convert filepaths to their proper system format (i.e. Windows/Unix)
+4
View File
@@ -243,6 +243,10 @@ static const char *g_white_list[] =
"_Atomic",
/* Ref: https://en.cppreference.com/w/c/keyword/_Thread_local */
"_Thread_local",
/* Ref: unwind-arm-common.h */
"_Unwind",