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

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

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)

View File

@ -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

View File

@ -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
libs/libm/newlib/Kconfig Normal file
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.

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

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 */

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_ */

View File

@ -0,0 +1,550 @@
/****************************************************************************
* libs/libm/newlib/include/machine/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_BIG_ENDIAN
#ifndef __IEEE_LITTLE_ENDIAN
/* This file can define macros to choose variations of the IEEE float
* format:
*
* _FLT_LARGEST_EXPONENT_IS_NORMAL
*
* Defined if the float format uses the largest exponent for finite
* numbers rather than NaN and infinity representations. Such a
* format cannot represent NaNs or infinities at all, but it's FLT_MAX
* is twice the IEEE value.
*
* _FLT_NO_DENORMALS
*
* Defined if the float format does not support IEEE denormals. Every
* float with a zero exponent is taken to be a zero representation.
*
* ??? At the moment, there are no equivalent macros above for doubles and
* the macros are not fully supported by --enable-newlib-hw-fp.
*
* __IEEE_BIG_ENDIAN
*
* Defined if the float format is big endian. This is mutually
* exclusive with __IEEE_LITTLE_ENDIAN.
*
* __IEEE_LITTLE_ENDIAN
*
* Defined if the float format is little endian. This is mutually
* exclusive with __IEEE_BIG_ENDIAN.
*
* Note that one of __IEEE_BIG_ENDIAN or __IEEE_LITTLE_ENDIAN must be
* specified for a platform or error will occur.
*
* __IEEE_BYTES_LITTLE_ENDIAN
*
* This flag is used in conjunction with __IEEE_BIG_ENDIAN to describe
* a situation whereby multiple words of an IEEE floating point are in
* big endian order, but the words themselves are little endian with
* respect to the bytes.
*
* _DOUBLE_IS_32BITS
*
* This is used on platforms that support double by using the 32-bit
* IEEE float type.
*
* _FLOAT_ARG
*
* This represents what type a float arg is passed as. It is used when
* the type is not promoted to double.
*
* __OBSOLETE_MATH_DEFAULT
*
* Default value for __OBSOLETE_MATH if that's not set by the user.
* It should be set here based on predefined feature macros.
*
* __OBSOLETE_MATH
*
* If set to 1 then some new math code will be disabled and older libm
* code will be used instead. This is necessary because the new math
* code does not support all targets, it assumes that the toolchain has
* ISO C99 support (hexfloat literals, standard fenv semantics), the
* target has IEEE-754 conforming binary32 float and binary64 double
* (not mixed endian) representation, standard SNaN representation,
* double and single precision arithmetics has similar latency and it
* has no legacy SVID matherr support, only POSIX errno and fenv
* exception based error handling.
*/
#if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__)
/* ARM traditionally used big-endian words; and within those words the
* byte ordering was big or little endian depending upon the target.
* Modern floating-point formats are naturally ordered; in this case
* __VFP_FP__ will be defined, even if soft-float.
*/
#ifdef __VFP_FP__
# ifdef __ARMEL__
# define __IEEE_LITTLE_ENDIAN
# else
# define __IEEE_BIG_ENDIAN
# endif
# if __ARM_FP & 0x8
# define __OBSOLETE_MATH_DEFAULT 0
# endif
#else
# define __IEEE_BIG_ENDIAN
# ifdef __ARMEL__
# define __IEEE_BYTES_LITTLE_ENDIAN
# endif
#endif
#ifndef __SOFTFP__
# define _SUPPORTS_ERREXCEPT
#endif
/* As per ISO/IEC TS 18661 '__FLT_EVAL_METHOD__' will be defined to 16
* (if compiling with +fp16 support) so it can't be used by math.h to
* define float_t and double_t. For values of '__FLT_EVAL_METHOD__'
* other than 0, 1, 2 the definition of float_t and double_t is
* implementation-defined.
*/
#define __DOUBLE_TYPE double
#define __FLOAT_TYPE float
#endif
#if defined (__aarch64__)
#if defined (__AARCH64EL__)
#define __IEEE_LITTLE_ENDIAN
#else
#define __IEEE_BIG_ENDIAN
#endif
#define __OBSOLETE_MATH_DEFAULT 0
#ifdef __ARM_FP
# define _SUPPORTS_ERREXCEPT
#endif
/* As per ISO/IEC TS 18661 '__FLT_EVAL_METHOD__' will be defined to 16
* (if compiling with +fp16 support) so it can't be used by math.h to
* define float_t and double_t. For values of '__FLT_EVAL_METHOD__'
* other than 0, 1, 2 the definition of float_t and double_t is
* implementation-defined.
*/
#define __DOUBLE_TYPE double
#define __FLOAT_TYPE float
#endif
#ifdef __epiphany__
#define __IEEE_LITTLE_ENDIAN
#define Sudden_Underflow 1
#endif
#ifdef __hppa__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __nds32__
#ifdef __big_endian__
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#endif
#ifdef __SPU__
#define __IEEE_BIG_ENDIAN
#define isfinite(__y) \
(__extension__ ({int __cy; \
(sizeof (__y) == sizeof (float)) ? (1) : \
(__cy = fpclassify(__y)) != FP_INFINITE && __cy != FP_NAN;}))
#define isinf(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isinfd(__x))
#define isnan(__x) ((sizeof (__x) == sizeof (float)) ? (0) : __isnand(__x))
/* Macros for use in ieeefp.h. We can't just define the real ones here
* (like those above) as we have name space issues when this is *not*
* included via generic the ieeefp.h.
*/
#define __ieeefp_isnanf(x) 0
#define __ieeefp_isinff(x) 0
#define __ieeefp_finitef(x) 1
#endif
#ifdef __sparc__
#ifdef __LITTLE_ENDIAN_DATA__
#define __IEEE_LITTLE_ENDIAN
#else
#define __IEEE_BIG_ENDIAN
#endif
#endif
#if defined(__m68k__) || defined(__mc68000__)
#define __IEEE_BIG_ENDIAN
#endif
#if defined(__mc68hc11__) || defined(__mc68hc12__) || defined(__mc68hc1x__)
#define __IEEE_BIG_ENDIAN
#ifdef __HAVE_SHORT_DOUBLE__
# define _DOUBLE_IS_32BITS
#endif
#endif
#if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__)
#define __IEEE_BIG_ENDIAN
#define _FLOAT_ARG float
#define _DOUBLE_IS_32BITS
#endif
#if defined (__xc16x__) || defined (__xc16xL__) || defined (__xc16xS__)
#define __IEEE_LITTLE_ENDIAN
#define _FLOAT_ARG float
#define _DOUBLE_IS_32BITS
#endif
#ifdef __sh__
#ifdef __LITTLE_ENDIAN__
#define __IEEE_LITTLE_ENDIAN
#else
#define __IEEE_BIG_ENDIAN
#endif
#if defined(__SH2E__) || defined(__SH3E__) || defined(__SH4_SINGLE_ONLY__) || defined(__SH2A_SINGLE_ONLY__)
#define _DOUBLE_IS_32BITS
#endif
#endif
#ifdef _AM29K
#define __IEEE_BIG_ENDIAN
#endif
#ifdef _WIN32
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __i386__
#define __IEEE_LITTLE_ENDIAN
# define _SUPPORTS_ERREXCEPT
#endif
#ifdef __riscv
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __riscv_flen
# define _SUPPORTS_ERREXCEPT
#endif
#if __riscv_flen == 64
# define __OBSOLETE_MATH_DEFAULT 0
#else
# define __OBSOLETE_MATH_DEFAULT 1
#endif
#endif
#ifdef __i960__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __lm32__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __M32R__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __nvptx__
#define __IEEE_LITTLE_ENDIAN
#endif
#if defined(_C4x) || defined(_C3x)
#define __IEEE_BIG_ENDIAN
#define _DOUBLE_IS_32BITS
#endif
#ifdef __TMS320C6X__
#ifdef _BIG_ENDIAN
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#endif
#ifdef __TIC80__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __MIPSEL__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __MIPSEB__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __MMIX__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __D30V__
#define __IEEE_BIG_ENDIAN
#endif
/* necv70 was __IEEE_LITTLE_ENDIAN. */
#ifdef __W65__
#define __IEEE_LITTLE_ENDIAN
#define _DOUBLE_IS_32BITS
#endif
#if defined(__Z8001__) || defined(__Z8002__)
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __m88k__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __mn10300__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __mn10200__
#define __IEEE_LITTLE_ENDIAN
#define _DOUBLE_IS_32BITS
#endif
#ifdef __v800
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __v850
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __D10V__
#define __IEEE_BIG_ENDIAN
#if __DOUBLE__ == 32
#define _DOUBLE_IS_32BITS
#endif
#endif
#ifdef __PPC__
#if (defined(_BIG_ENDIAN) && _BIG_ENDIAN) || (defined(_AIX) && _AIX)
#define __IEEE_BIG_ENDIAN
#else
#if (defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN) || (defined(__sun__) && __sun__) || (defined(_WIN32) && _WIN32)
#define __IEEE_LITTLE_ENDIAN
#endif
#endif
#endif
#ifdef __xstormy16__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __arc__
#ifdef __big_endian__
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#endif
#ifdef __CRX__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __CSKY__
#ifdef __CSKYBE__
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#endif
#ifdef __fr30__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __FT32__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __mcore__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __mt__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __frv__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __moxie__
#ifdef __MOXIE_BIG_ENDIAN__
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#endif
#ifdef __ia64__
#ifdef __BIG_ENDIAN__
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#endif
#ifdef __AVR__
#define __IEEE_LITTLE_ENDIAN
#define _DOUBLE_IS_32BITS
#endif
#if defined(__or1k__) || defined(__OR1K__) || defined(__OR1KND__)
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __IP2K__
#define __IEEE_BIG_ENDIAN
#define __SMALL_BITFIELDS
#define _DOUBLE_IS_32BITS
#endif
#ifdef __iq2000__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __MAVERICK__
#ifdef __ARMEL__
# define __IEEE_LITTLE_ENDIAN
#else /* must be __ARMEB__ */
# define __IEEE_BIG_ENDIAN
#endif /* __ARMEL__ */
#endif /* __MAVERICK__ */
#ifdef __m32c__
#define __IEEE_LITTLE_ENDIAN
#define __SMALL_BITFIELDS
#endif
#ifdef __CRIS__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __BFIN__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __x86_64__
#define __IEEE_LITTLE_ENDIAN
# define _SUPPORTS_ERREXCEPT
#endif
#ifdef __mep__
#ifdef __LITTLE_ENDIAN__
#define __IEEE_LITTLE_ENDIAN
#else
#define __IEEE_BIG_ENDIAN
#endif
#endif
#ifdef __MICROBLAZE__
#ifndef __MICROBLAZEEL__
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#endif
#ifdef __MSP430__
#define __IEEE_LITTLE_ENDIAN
#define __SMALL_BITFIELDS /* 16 Bit INT */
#endif
#ifdef __PRU__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __RL78__
#define __IEEE_LITTLE_ENDIAN
#define __SMALL_BITFIELDS /* 16 Bit INT */
#ifndef __RL78_64BIT_DOUBLES__
#define _DOUBLE_IS_32BITS
#endif
#endif
#ifdef __RX__
#ifdef __RX_BIG_ENDIAN__
#define __IEEE_BIG_ENDIAN
#else
#define __IEEE_LITTLE_ENDIAN
#endif
#ifndef __RX_64BIT_DOUBLES__
#define _DOUBLE_IS_32BITS
#endif
#ifdef __RX_16BIT_INTS__
#define __SMALL_BITFIELDS
#endif
#endif
#if (defined(__CR16__) || defined(__CR16C__) ||defined(__CR16CP__))
#define __IEEE_LITTLE_ENDIAN
#define __SMALL_BITFIELDS /* 16 Bit INT */
#endif
#ifdef __NIOS2__
# ifdef __nios2_big_endian__
# define __IEEE_BIG_ENDIAN
# else
# define __IEEE_LITTLE_ENDIAN
# endif
#endif
#ifdef __VISIUM__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __AMDGCN__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __XTENSA_EL__
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __CYGWIN__
#define __OBSOLETE_MATH_DEFAULT 0
#endif
#ifndef __OBSOLETE_MATH_DEFAULT
/* Use old math code by default. */
#define __OBSOLETE_MATH_DEFAULT 1
#endif
#ifndef __OBSOLETE_MATH
#define __OBSOLETE_MATH __OBSOLETE_MATH_DEFAULT
#endif
#ifndef __IEEE_BIG_ENDIAN
#ifndef __IEEE_LITTLE_ENDIAN
#error Endianess not declared!!
#endif /* not __IEEE_LITTLE_ENDIAN */
#endif /* not __IEEE_BIG_ENDIAN */
#endif /* not __IEEE_LITTLE_ENDIAN */
#endif /* not __IEEE_BIG_ENDIAN */

View File

@ -0,0 +1,649 @@
/****************************************************************************
* libs/libm/newlib/include/math.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 _MATH_H_
#define _MATH_H_
/****************************************************************************
* Included Files
****************************************************************************/
#include <machine/ieeefp.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
#endif
/* Macro to test version of GCC. Returns 0 for non-GCC or too old GCC. */
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif /* __GNUC_PREREQ */
/* Newlib doesn't fully support long double math functions so far.
* On platforms where long double equals double the long double functions
* let's define _LDBL_EQ_DBL to simply call the double functions.
*/
#define _LDBL_EQ_DBL 1
extern _Thread_local int _tls_gamma_signgam;
#define _REENT_SIGNGAM(ptr) _tls_gamma_signgam
/* Natural log of 2 */
#define _M_LN2 0.693147180559945309417
#if __GNUC_PREREQ (3, 3)
/* gcc >= 3.3 implicitly defines builtins for HUGE_VALx values. */
# ifndef HUGE_VAL
# define HUGE_VAL (__builtin_huge_val())
# endif
# ifndef HUGE_VALF
# define HUGE_VALF (__builtin_huge_valf())
# endif
# ifndef HUGE_VALL
# define HUGE_VALL (__builtin_huge_vall())
# endif
# ifndef INFINITY
# define INFINITY (__builtin_inff())
# endif
# ifndef NAN
# define NAN (__builtin_nanf(""))
# endif
#else /* !gcc >= 3.3 */
/* No builtins. Use fixed defines instead. (All 3 HUGE plus the INFINITY
* and NAN macros are required to be constant expressions. Using a variable--
* even a static const--does not meet this requirement, as it cannot be
* evaluated at translation time.)
* The infinities are done using numbers that are far in excess of
* something that would be expected to be encountered in a floating-point
* implementation. (A more certain way uses values from float.h, but that is
* avoided because system includes are not supposed to include each other.)
* This method might produce warnings from some compilers. (It does in
* newer GCCs, but not for ones that would hit this #else.) If this happens,
* please report details to the Newlib mailing list.
*/
#ifndef HUGE_VAL
#define HUGE_VAL (1.0e999999999)
#endif
#ifndef HUGE_VALF
#define HUGE_VALF (1.0e999999999F)
#endif
#if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE)
#define HUGE_VALL (1.0e999999999L)
#endif
#if !defined(INFINITY)
#define INFINITY (HUGE_VALF)
#endif
#if !defined(NAN)
#define NAN (0.0F/0.0F)
#endif
#endif /* !gcc >= 3.3 */
/* Reentrant ANSI C functions. */
#ifndef __math_68881
extern double atan (double);
extern double cos (double);
extern double sin (double);
extern double tan (double);
extern double tanh (double);
extern double frexp (double, int *);
extern double modf (double, double *);
extern double ceil (double);
extern double fabs (double);
extern double floor (double);
#endif /* ! defined (__math_68881) */
/* Non reentrant ANSI C functions. */
#ifndef __math_68881
extern double acos (double);
extern double asin (double);
extern double atan2 (double, double);
extern double cosh (double);
extern double sinh (double);
extern double exp (double);
extern double ldexp (double, int);
extern double log (double);
extern double log10 (double);
extern double pow (double, double);
extern double sqrt (double);
extern double fmod (double, double);
#endif /* ! defined (__math_68881) */
extern int finite (double);
extern int finitef (float);
extern int finitel (long double);
extern int isinff (float);
extern int isnanf (float);
#ifdef __CYGWIN__ /* not implemented in newlib yet */
extern int isinfl (long double);
extern int isnanl (long double);
#endif
#if !defined(__cplusplus) || __cplusplus < 201103L
extern int isinf (double);
#endif
#if !defined(__cplusplus) || __cplusplus < 201103L
extern int isnan (double);
#endif
/* ISO C99 types and macros. */
/* FIXME: FLT_EVAL_METHOD should somehow be gotten from float.h (which is
* hard, considering that the standard says the includes it defines should
* not include other includes that it defines) and that value used. (This
* can be solved, but autoconf has a bug which makes the solution more
* difficult, so it has been skipped for now.)
*/
#if !defined(FLT_EVAL_METHOD) && defined(__FLT_EVAL_METHOD__)
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#define __TMP_FLT_EVAL_METHOD
#endif /* FLT_EVAL_METHOD */
#if defined FLT_EVAL_METHOD
/* FLT_EVAL_METHOD == 16 has meaning as defined in ISO/IEC TS 18661-3,
* which provides non-compliant extensions to C and POSIX (by adding
* additional positive values for FLT_EVAL_METHOD). It effectively has
* same meaning as the C99 and C11 definitions for value 0, while also
* serving as a flag that the _Float16 (float16_t) type exists.
*
* FLT_EVAL_METHOD could be any number of bits of supported floating point
* format (e.g. 32, 64, 128), but currently only AArch64 and few other
* targets might define that as 16.
*/
#if (FLT_EVAL_METHOD == 0) \
|| (FLT_EVAL_METHOD == 16)
typedef float float_t;
typedef double double_t;
#elif FLT_EVAL_METHOD == 1
typedef double float_t;
typedef double double_t;
#elif FLT_EVAL_METHOD == 2
typedef long double float_t;
typedef long double double_t;
#else
/* Implementation-defined. Assume float_t and double_t have been
* defined previously for this configuration (e.g. config.h).
*/
/* If __DOUBLE_TYPE is defined (__FLOAT_TYPE is then supposed to be
* defined as well) float_t and double_t definition is suggested by
* an arch specific header.
*/
#ifdef __DOUBLE_TYPE
typedef __DOUBLE_TYPE double_t;
typedef __FLOAT_TYPE float_t;
#endif
/* Assume config.h has provided these types. */
#endif
#else
/* Assume basic definitions. */
typedef float float_t;
typedef double double_t;
#endif
#if defined(__TMP_FLT_EVAL_METHOD)
#undef FLT_EVAL_METHOD
#endif
#define FP_NAN 0
#define FP_INFINITE 1
#define FP_ZERO 2
#define FP_SUBNORMAL 3
#define FP_NORMAL 4
#ifndef FP_ILOGB0
# define FP_ILOGB0 (-__INT_MAX__)
#endif
#ifndef FP_ILOGBNAN
# define FP_ILOGBNAN __INT_MAX__
#endif
#ifndef MATH_ERRNO
# define MATH_ERRNO 1
#endif
#ifndef MATH_ERREXCEPT
# define MATH_ERREXCEPT 2
#endif
#ifndef math_errhandling
# ifdef _IEEE_LIBM
# define _MATH_ERRHANDLING_ERRNO 0
# else
# define _MATH_ERRHANDLING_ERRNO MATH_ERRNO
# endif
# ifdef _SUPPORTS_ERREXCEPT
# define _MATH_ERRHANDLING_ERREXCEPT MATH_ERREXCEPT
# else
# define _MATH_ERRHANDLING_ERREXCEPT 0
# endif
# define math_errhandling (_MATH_ERRHANDLING_ERRNO | _MATH_ERRHANDLING_ERREXCEPT)
#endif
extern int __isinff (float);
extern int __isinfd (double);
extern int __isnanf (float);
extern int __isnand (double);
extern int __fpclassifyf (float);
extern int __fpclassifyd (double);
extern int __signbitf (float);
extern int __signbitd (double);
/* Note: isinf and isnan were once functions in newlib that took double
* arguments. C99 specifies that these names are reserved for macros
* supporting multiple floating point types. Thus, they are
* now defined as macros. Implementations of the old functions
* taking double arguments still exist for compatibility purposes
* (prototypes for them are earlier in this header).
*/
#if __GNUC_PREREQ (4, 4)
#define fpclassify(__x) (__builtin_fpclassify (FP_NAN, FP_INFINITE, \
FP_NORMAL, FP_SUBNORMAL, \
FP_ZERO, __x))
#ifndef isfinite
#define isfinite(__x) (__builtin_isfinite (__x))
#endif
#ifndef isinf
#define isinf(__x) (__builtin_isinf_sign (__x))
#endif
#ifndef isnan
#define isnan(__x) (__builtin_isnan (__x))
#endif
#define isnormal(__x) (__builtin_isnormal (__x))
#else
#define fpclassify(__x) \
((sizeof(__x) == sizeof(float)) ? __fpclassifyf(__x) : \
__fpclassifyd(__x))
#ifndef isfinite
#define isfinite(__y) \
(__extension__ ({int __cy = fpclassify(__y); \
__cy != FP_INFINITE && __cy != FP_NAN;}))
#endif
#ifndef isinf
#define isinf(__x) (fpclassify(__x) == FP_INFINITE)
#endif
#ifndef isnan
#define isnan(__x) (fpclassify(__x) == FP_NAN)
#endif
#define isnormal(__x) (fpclassify(__x) == FP_NORMAL)
#endif
#if __GNUC_PREREQ (4, 0)
#if defined(_HAVE_LONG_DOUBLE)
#define signbit(__x) \
((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \
(sizeof(__x) == sizeof(double)) ? __builtin_signbit (__x) : \
__builtin_signbitl(__x))
#else
#define signbit(__x) \
((sizeof(__x) == sizeof(float)) ? __builtin_signbitf(__x) : \
__builtin_signbit (__x))
#endif
#else
#define signbit(__x) \
((sizeof(__x) == sizeof(float)) ? __signbitf(__x) : \
__signbitd(__x))
#endif
#if __GNUC_PREREQ (2, 97)
#define isgreater(__x,__y) (__builtin_isgreater (__x, __y))
#define isgreaterequal(__x,__y) (__builtin_isgreaterequal (__x, __y))
#define isless(__x,__y) (__builtin_isless (__x, __y))
#define islessequal(__x,__y) (__builtin_islessequal (__x, __y))
#define islessgreater(__x,__y) (__builtin_islessgreater (__x, __y))
#define isunordered(__x,__y) (__builtin_isunordered (__x, __y))
#else
#define isgreater(x,y) \
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
!isunordered(__x,__y) && (__x > __y);}))
#define isgreaterequal(x,y) \
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
!isunordered(__x,__y) && (__x >= __y);}))
#define isless(x,y) \
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
!isunordered(__x,__y) && (__x < __y);}))
#define islessequal(x,y) \
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
!isunordered(__x,__y) && (__x <= __y);}))
#define islessgreater(x,y) \
(__extension__ ({__typeof__(x) __x = (x); __typeof__(y) __y = (y); \
!isunordered(__x,__y) && (__x < __y || __x > __y);}))
#define isunordered(a,b) \
(__extension__ ({__typeof__(a) __a = (a); __typeof__(b) __b = (b); \
fpclassify(__a) == FP_NAN || fpclassify(__b) == FP_NAN;}))
#endif
/* Non ANSI double precision functions. */
extern double infinity (void);
extern double nan (const char *);
extern double copysign (double, double);
extern double logb (double);
extern int ilogb (double);
extern double asinh (double);
extern double cbrt (double);
extern double nextafter (double, double);
extern double rint (double);
extern double scalbn (double, int);
extern double exp2 (double);
extern double scalbln (double, long int);
extern double tgamma (double);
extern double nearbyint (double);
extern long int lrint (double);
extern long long int llrint (double);
extern double round (double);
extern long int lround (double);
extern long long int llround (double);
extern double trunc (double);
extern double remquo (double, double, int *);
extern double fdim (double, double);
extern double fmax (double, double);
extern double fmin (double, double);
extern double fma (double, double, double);
#ifndef __math_68881
extern double log1p (double);
extern double expm1 (double);
#endif /* ! defined (__math_68881) */
extern double acosh (double);
extern double atanh (double);
extern double remainder (double, double);
extern double gamma (double);
extern double lgamma (double);
extern double erf (double);
extern double erfc (double);
extern double log2 (double);
#if !defined(__cplusplus)
#define log2(x) (log (x) / _M_LN2)
#endif
#ifndef __math_68881
extern double hypot (double, double);
#endif
/* Single precision versions of ANSI functions. */
extern float atanf (float);
extern float cosf (float);
extern float sinf (float);
extern float tanf (float);
extern float tanhf (float);
extern float frexpf (float, int *);
extern float modff (float, float *);
extern float ceilf (float);
extern float fabsf (float);
extern float floorf (float);
extern float acosf (float);
extern float asinf (float);
extern float atan2f (float, float);
extern float coshf (float);
extern float sinhf (float);
extern float expf (float);
extern float ldexpf (float, int);
extern float logf (float);
extern float log10f (float);
extern float powf (float, float);
extern float sqrtf (float);
extern float fmodf (float, float);
/* Other single precision functions. */
extern float exp2f (float);
extern float scalblnf (float, long int);
extern float tgammaf (float);
extern float nearbyintf (float);
extern long int lrintf (float);
extern long long int llrintf (float);
extern float roundf (float);
extern long int lroundf (float);
extern long long int llroundf (float);
extern float truncf (float);
extern float remquof (float, float, int *);
extern float fdimf (float, float);
extern float fmaxf (float, float);
extern float fminf (float, float);
extern float fmaf (float, float, float);
extern float infinityf (void);
extern float nanf (const char *);
extern float copysignf (float, float);
extern float logbf (float);
extern int ilogbf (float);
extern float asinhf (float);
extern float cbrtf (float);
extern float nextafterf (float, float);
extern float rintf (float);
extern float scalbnf (float, int);
extern float log1pf (float);
extern float expm1f (float);
extern float acoshf (float);
extern float atanhf (float);
extern float remainderf (float, float);
extern float gammaf (float);
extern float lgammaf (float);
extern float erff (float);
extern float erfcf (float);
extern float log2f (float);
extern float hypotf (float, float);
/* Newlib doesn't fully support long double math functions so far.
* On platforms where long double equals double the long double functions
* simply call the double functions. On Cygwin the long double functions
* are implemented independently from newlib to be able to use optimized
* assembler functions despite using the Microsoft x86_64 ABI.
*/
#if defined (_LDBL_EQ_DBL) || defined (__CYGWIN__)
/* Reentrant ANSI C functions. */
#ifndef __math_68881
extern long double atanl (long double);
extern long double cosl (long double);
extern long double sinl (long double);
extern long double tanl (long double);
extern long double tanhl (long double);
extern long double frexpl (long double, int *);
extern long double modfl (long double, long double *);
extern long double ceill (long double);
extern long double fabsl (long double);
extern long double floorl (long double);
extern long double log1pl (long double);
extern long double expm1l (long double);
#endif /* ! defined (__math_68881) */
/* Non reentrant ANSI C functions. */
#ifndef __math_68881
extern long double acosl (long double);
extern long double asinl (long double);
extern long double atan2l (long double, long double);
extern long double coshl (long double);
extern long double sinhl (long double);
extern long double expl (long double);
extern long double ldexpl (long double, int);
extern long double logl (long double);
extern long double log10l (long double);
extern long double powl (long double, long double);
extern long double sqrtl (long double);
extern long double fmodl (long double, long double);
extern long double hypotl (long double, long double);
#endif /* ! defined (__math_68881) */
extern long double copysignl (long double, long double);
extern long double nanl (const char *);
extern int ilogbl (long double);
extern long double asinhl (long double);
extern long double cbrtl (long double);
extern long double nextafterl (long double, long double);
extern float nexttowardf (float, long double);
extern double nexttoward (double, long double);
extern long double nexttowardl (long double, long double);
extern long double logbl (long double);
extern long double log2l (long double);
extern long double rintl (long double);
extern long double scalbnl (long double, int);
extern long double exp2l (long double);
extern long double scalblnl (long double, long);
extern long double tgammal (long double);
extern long double nearbyintl (long double);
extern long int lrintl (long double);
extern long long int llrintl (long double);
extern long double roundl (long double);
extern long lroundl (long double);
extern long long int llroundl (long double);
extern long double truncl (long double);
extern long double remquol (long double, long double, int *);
extern long double fdiml (long double, long double);
extern long double fmaxl (long double, long double);
extern long double fminl (long double, long double);
extern long double fmal (long double, long double, long double);
extern long double acoshl (long double);
extern long double atanhl (long double);
extern long double remainderl (long double, long double);
extern long double lgammal (long double);
extern long double erfl (long double);
extern long double erfcl (long double);
#else /* !_LDBL_EQ_DBL && !__CYGWIN__ */
extern long double hypotl (long double, long double);
extern long double sqrtl (long double);
extern long double frexpl (long double, int *);
#ifdef __i386__
/* Other long double precision functions. */
extern _LONG_DOUBLE rintl (_LONG_DOUBLE);
extern long int lrintl (_LONG_DOUBLE);
extern long long int llrintl (_LONG_DOUBLE);
#endif /* __i386__ */
#endif /* !_LDBL_EQ_DBL && !__CYGWIN__ */
extern double drem (double, double);
extern float dremf (float, float);
#ifdef __CYGWIN__
extern float dreml (long double, long double);
#endif /* __CYGWIN__ */
extern double gamma_r (double, int *);
extern double lgamma_r (double, int *);
extern float gammaf_r (float, int *);
extern float lgammaf_r (float, int *);
extern double y0 (double);
extern double y1 (double);
extern double yn (int, double);
extern double j0 (double);
extern double j1 (double);
extern double jn (int, double);
extern float y0f (float);
extern float y1f (float);
extern float ynf (int, float);
extern float j0f (float);
extern float j1f (float);
extern float jnf (int, float);
/* GNU extensions */
extern void sincos (double, double *, double *);
extern void sincosf (float, float *, float *);
#ifdef __CYGWIN__
extern void sincosl (long double, long double *, long double *);
#endif /* __CYGWIN__ */
# ifndef exp10
extern double exp10 (double);
# endif
# ifndef pow10
extern double pow10 (double);
# endif
# ifndef exp10f
extern float exp10f (float);
# endif
# ifndef pow10f
extern float pow10f (float);
# endif
#ifdef __CYGWIN__
# ifndef exp10l
extern float exp10l (float);
# endif
# ifndef pow10l
extern float pow10l (float);
# endif
#endif /* __CYGWIN__ */
/* The gamma functions use a global variable, signgam. */
#define signgam (*__signgam())
extern int *__signgam (void);
#define __signgam_r(ptr) _REENT_SIGNGAM(ptr)
/* Useful constants. */
#define MAXFLOAT 3.40282347e+38F
#define M_E 2.7182818284590452354
#define M_LOG2E 1.4426950408889634074
#define M_LOG10E 0.43429448190325182765
#define M_LN2 _M_LN2
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.78539816339744830962
#define M_1_PI 0.31830988618379067154
#define M_2_PI 0.63661977236758134308
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.70710678118654752440
#define M_TWOPI (M_PI * 2.0)
#define M_3PI_4 2.3561944901923448370E0
#define M_SQRTPI 1.77245385090551602792981
#define M_LN2LO 1.9082149292705877000E-10
#define M_LN2HI 6.9314718036912381649E-1
#define M_SQRT3 1.73205080756887719000
#define M_IVLN10 0.43429448190325182765 /* 1 / log(10) */
#define M_LOG2_E _M_LN2
#define M_INVLN2 1.4426950408889633870E0 /* 1 / log(2) */
#ifdef __cplusplus
}
#endif
#endif /* _MATH_H_ */

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_ */

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)

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",