You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2020/10/25 14:30:21 UTC

[incubator-nuttx] branch master updated: math: Make this friendly with libcxx

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new df812d0  math: Make this friendly with libcxx
df812d0 is described below

commit df812d09a219495a8ba1d0c30a2e9ebc05c37f3b
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Thu Oct 22 16:13:29 2020 +0900

    math: Make this friendly with libcxx
    
    - Turn some macros into functions
    
    - Implement some type-agnostic functions.
      (Just use __builtin_xxx)
    
    - Add some missing function prototypes
      (Just prototypes, not actually implemented in this commit)
---
 include/nuttx/lib/math.h      | 205 ++++++++++++++++++++++++++++++++++++++----
 libs/libc/math/Make.defs      |   6 ++
 libs/libc/math/lib_erfc.c     |  39 ++++++++
 libs/libc/math/lib_erfcf.c    |  37 ++++++++
 libs/libc/math/lib_erfcl.c    |  39 ++++++++
 libs/libc/math/lib_expm1.c    |  39 ++++++++
 libs/libc/math/lib_expm1f.c   |  37 ++++++++
 libs/libc/math/lib_expm1l.c   |  39 ++++++++
 libs/libc/math/lib_llround.c  |  41 +++++++++
 libs/libc/math/lib_llroundf.c |  39 ++++++++
 libs/libc/math/lib_llroundl.c |  41 +++++++++
 libs/libc/math/lib_lround.c   |  39 ++++++++
 libs/libc/math/lib_lroundf.c  |  37 ++++++++
 libs/libc/math/lib_lroundl.c  |  39 ++++++++
 libs/libc/math/lib_nan.c      |  39 ++++++++
 libs/libc/math/lib_nanf.c     |  37 ++++++++
 libs/libc/math/lib_nanl.c     |  39 ++++++++
 17 files changed, 776 insertions(+), 16 deletions(-)

diff --git a/include/nuttx/lib/math.h b/include/nuttx/lib/math.h
index faa9d68..af93e37 100644
--- a/include/nuttx/lib/math.h
+++ b/include/nuttx/lib/math.h
@@ -172,21 +172,21 @@ double      round (double x);
 long double roundl(long double x);
 #endif
 
-#define lroundf(x) ((long)roundf(x))
+long int    lroundf(float x);
 #ifdef CONFIG_HAVE_DOUBLE
-#define lround(x)  ((long)round(x))
+long int    lround(double x);
 #endif
 #ifdef CONFIG_HAVE_LONG_DOUBLE
-#define lroundl(x) ((long)roundl(x))
+long int    lroundl(long double x);
 #endif
 
 #ifdef CONFIG_HAVE_LONG_LONG
-#define llroundf(x) ((long long)roundf(x))
+long long int llroundf(float x);
 #ifdef CONFIG_HAVE_DOUBLE
-#define llround(x)  ((long long)round(x))
+long long int llround (double x);
 #endif
 #ifdef CONFIG_HAVE_LONG_DOUBLE
-#define llroundl(x) ((long long)roundl(x))
+long long int llroundl(long double x);
 #endif
 #endif
 
@@ -198,6 +198,24 @@ double      rint(double x);
 long double rintl(long double x); /* Not implemented */
 #endif
 
+long int    lrintf(float x);
+#ifdef CONFIG_HAVE_DOUBLE
+long int    lrint(double x);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long int    lrintl(long double x);
+#endif
+
+#ifdef CONFIG_HAVE_LONG_LONG
+long long int llrintf(float x);
+#ifdef CONFIG_HAVE_DOUBLE
+long long int llrint(double x);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long long int llrintl(long double x);
+#endif
+#endif
+
 float       fabsf (float x);
 #ifdef CONFIG_HAVE_DOUBLE
 double      fabs  (double x);
@@ -233,22 +251,77 @@ long double powl  (long double b, long double e);
 #endif
 
 float       expf  (float x);
-#define expm1f(x) (expf(x) - 1.0)
+float       exp2f (float x);
+float       expm1f(float x);
 #ifdef CONFIG_HAVE_DOUBLE
 double      exp   (double x);
-#define expm1(x) (exp(x) - 1.0)
+double      exp2  (double x);
+double      expm1 (double x);
 #endif
 #ifdef CONFIG_HAVE_LONG_DOUBLE
 long double expl  (long double x);
-#define expm1l(x) (expl(x) - 1.0)
+long double exp2l (long double x);
+long double expm1l(long double x);
 #endif
 
+float       fdimf(float x, float y);
+#ifdef CONFIG_HAVE_DOUBLE
+double      fdim(double x, double y);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double fdiml(long double x, long double y);
+#endif
+
+float       fmaf(float x, float y, float z);
+#ifdef CONFIG_HAVE_DOUBLE
+double      fma(double x, double y, double z);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double fmal(long double x, long double y, long double z);
+#endif
+
+float       fmaxf(float x, float y);
+#ifdef CONFIG_HAVE_DOUBLE
+double      fmax(double x, double y);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double fmaxl(long double x, long double y);
+#endif
+
+float       fminf(float x, float y);
+#ifdef CONFIG_HAVE_DOUBLE
+double      fmin(double x, double y);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double fminl(long double x, long double y);
+#endif
+
+float       hypotf(float x, float y);
+#ifdef CONFIG_HAVE_DOUBLE
+double      hypot(double x, double y);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double hypotl(long double x, long double y);
+#endif
+
+float       lgammaf(float x);
 #ifdef CONFIG_HAVE_DOUBLE
 double      __cos(double x, double y);
 double      __sin(double x, double y, int iy);
 double      gamma(double x);
 double      lgamma(double x);
 #endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double lgammal(long double x);
+#endif
+
+float       tgammaf(float x);
+#ifdef CONFIG_HAVE_DOUBLE
+double      tgamma(double x);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double tgammal(long double x);
+#endif
 
 float       logf  (float x);
 #ifdef CONFIG_HAVE_DOUBLE
@@ -266,6 +339,14 @@ double      log10 (double x);
 long double log10l(long double x);
 #endif
 
+float       log1pf(float x);
+#ifdef CONFIG_HAVE_DOUBLE
+double      log1p (double x);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double log1pl(long double x);
+#endif
+
 float       log2f (float x);
 #ifdef CONFIG_HAVE_DOUBLE
 double      log2  (double x);
@@ -274,6 +355,22 @@ double      log2  (double x);
 long double log2l (long double x);
 #endif
 
+float       logbf (float x);
+#ifdef CONFIG_HAVE_DOUBLE
+double      logb  (double x);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double logbl (long double x);
+#endif
+
+int         ilogbf (float x);
+#ifdef CONFIG_HAVE_DOUBLE
+int         ilogb  (double x);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+int         ilogbl (long double x);
+#endif
+
 float       sqrtf (float x);
 #ifdef CONFIG_HAVE_DOUBLE
 double      sqrt  (double x);
@@ -372,9 +469,13 @@ double      cosh  (double x);
 long double coshl (long double x);
 #endif
 
+float       cbrtf (float x);
 #ifdef CONFIG_HAVE_DOUBLE
 double      cbrt  (double x);
 #endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double cbrtl (long double x);
+#endif
 
 float       tanhf (float x);
 #ifdef CONFIG_HAVE_DOUBLE
@@ -409,14 +510,14 @@ long double atanhl (long double x);
 #endif
 
 float       erff (float x);
-#define     erfcf(x) (1 - erff(x))
+float       erfcf(float x);
 #ifdef CONFIG_HAVE_DOUBLE
 double      erf  (double x);
-#define     erfc(x) (1 - erf(x))
+double      erfc(double x);
 #endif
 #ifdef CONFIG_HAVE_LONG_DOUBLE
 long double erfl (long double x);
-#define     erfcl(x) (1 - erfl(x))
+long double erfcl(long double x);
 #endif
 
 float       copysignf (float x, float y);
@@ -435,15 +536,87 @@ double      trunc (double x);
 long double truncl (long double x);
 #endif
 
-#define nanf(x) ((float)(NAN))
+float       nanf(const char *tagp);
+#ifdef CONFIG_HAVE_DOUBLE
+double      nan(const char *tagp);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double nanl(const char *tagp);
+#endif
+
+float       nearbyintf(float x);
+#ifdef CONFIG_HAVE_DOUBLE
+double      nearbyint(double x);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double nearbyintl(long double x);
+#endif
+
+float       nextafterf(float x, float y);
+#ifdef CONFIG_HAVE_DOUBLE
+double      nextafter(double x, double y);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double nextafterl(long double x, long double y);
+#endif
+
+float       nexttowardf(float x, long double y);
+#ifdef CONFIG_HAVE_DOUBLE
+double      nexttoward(double x, long double y);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double nexttowardl(long double x, long double y);
+#endif
+
+float       remainderf(float x, float y);
+#ifdef CONFIG_HAVE_DOUBLE
+double      remainder(double x, double y);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double remainderl(long double x, long double y);
+#endif
+
+float       remquof(float x, float y, int *quo);
+#ifdef CONFIG_HAVE_DOUBLE
+double      remquo(double x, double y, int *quo);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double remquol(long double x, long double y, int *quo);
+#endif
+
+float       scalblnf(float x, long int n);
 #ifdef CONFIG_HAVE_DOUBLE
-#define nan(x) ((double)(NAN))
+double      scalbln(double x, long int n);
 #endif
 #ifdef CONFIG_HAVE_LONG_DOUBLE
-#define nanl(x) ((long double)(NAN))
+long double scalblnl(long double x, long int n);
 #endif
 
-#define	signbit(x)	__builtin_signbit(x)
+float       scalbnf(float x, int n);
+#ifdef CONFIG_HAVE_DOUBLE
+double      scalbn(double x, int n);
+#endif
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double scalbnl(long double x, int n);
+#endif
+
+#define FP_INFINITE     0
+#define FP_NAN          1
+#define FP_NORMAL       2
+#define FP_SUBNORMAL    3
+#define FP_ZERO         4
+#define fpclassify(x) \
+    __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, \
+                         FP_ZERO, x)
+
+#define isunordered(x, y)    __builtin_isunordered(x, y)
+#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 isnormal(x)          __builtin_isnormal(x)
+#define signbit(x)           __builtin_signbit(x)
 
 #if defined(__cplusplus)
 }
diff --git a/libs/libc/math/Make.defs b/libs/libc/math/Make.defs
index 087ea14..86b3796 100644
--- a/libs/libc/math/Make.defs
+++ b/libs/libc/math/Make.defs
@@ -62,6 +62,12 @@ CSRCS += lib_truncl.c
 CSRCS += lib_libexpi.c lib_libsqrtapprox.c
 CSRCS += lib_libexpif.c
 
+CSRCS += lib_erfc.c lib_erfcf.c lib_erfcl.c
+CSRCS += lib_expm1.c lib_expm1f.c lib_expm1l.c
+CSRCS += lib_lround.c lib_lroundf.c lib_lroundl.c
+CSRCS += lib_llround.c lib_llroundf.c lib_llroundl.c
+CSRCS += lib_nan.c lib_nanf.c lib_nanl.c
+
 CSRCS += __cos.c __sin.c lib_gamma.c lib_lgamma.c
 
 # Use the C versions of some functions only if architecture specific
diff --git a/libs/libc/math/lib_erfc.c b/libs/libc/math/lib_erfc.c
new file mode 100644
index 0000000..cd1dfca
--- /dev/null
+++ b/libs/libc/math/lib_erfc.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_erfc.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_DOUBLE
+double erfc(double x)
+{
+  return 1 - erf(x);
+}
+#endif
diff --git a/libs/libc/math/lib_erfcf.c b/libs/libc/math/lib_erfcf.c
new file mode 100644
index 0000000..c7a8752
--- /dev/null
+++ b/libs/libc/math/lib_erfcf.c
@@ -0,0 +1,37 @@
+/****************************************************************************
+ * lib/math/lib_erfcf.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+float erfcf(float x)
+{
+  return 1 - erff(x);
+}
diff --git a/libs/libc/math/lib_erfcl.c b/libs/libc/math/lib_erfcl.c
new file mode 100644
index 0000000..c3ca7c8
--- /dev/null
+++ b/libs/libc/math/lib_erfcl.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_erfcl.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double erfcl(long double x)
+{
+  return 1 - erfl(x);
+}
+#endif
diff --git a/libs/libc/math/lib_expm1.c b/libs/libc/math/lib_expm1.c
new file mode 100644
index 0000000..d87984d
--- /dev/null
+++ b/libs/libc/math/lib_expm1.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_expm1.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_DOUBLE
+double expm1(double x)
+{
+  return exp(x) - 1.0;
+}
+#endif
diff --git a/libs/libc/math/lib_expm1f.c b/libs/libc/math/lib_expm1f.c
new file mode 100644
index 0000000..6668ff8
--- /dev/null
+++ b/libs/libc/math/lib_expm1f.c
@@ -0,0 +1,37 @@
+/****************************************************************************
+ * lib/math/lib_expm1f.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+float expm1f(float x)
+{
+  return expf(x) - 1.0;
+}
diff --git a/libs/libc/math/lib_expm1l.c b/libs/libc/math/lib_expm1l.c
new file mode 100644
index 0000000..d481882
--- /dev/null
+++ b/libs/libc/math/lib_expm1l.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_expm1l.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double expm1l(long double x)
+{
+  return expl(x) - 1.0;
+}
+#endif
diff --git a/libs/libc/math/lib_llround.c b/libs/libc/math/lib_llround.c
new file mode 100644
index 0000000..45af61e
--- /dev/null
+++ b/libs/libc/math/lib_llround.c
@@ -0,0 +1,41 @@
+/****************************************************************************
+ * lib/math/lib_llround.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_LONG_LONG
+#ifdef CONFIG_HAVE_DOUBLE
+long long llround(double x)
+{
+  return (long long)round(x);
+}
+#endif
+#endif
diff --git a/libs/libc/math/lib_llroundf.c b/libs/libc/math/lib_llroundf.c
new file mode 100644
index 0000000..50c3dc8
--- /dev/null
+++ b/libs/libc/math/lib_llroundf.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_llroundf.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_LONG_LONG
+long long llroundf(float x)
+{
+  return (long long)roundf(x);
+}
+#endif
diff --git a/libs/libc/math/lib_llroundl.c b/libs/libc/math/lib_llroundl.c
new file mode 100644
index 0000000..79027fd
--- /dev/null
+++ b/libs/libc/math/lib_llroundl.c
@@ -0,0 +1,41 @@
+/****************************************************************************
+ * lib/math/lib_llroundl.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_LONG_LONG
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long long llroundl(long double x)
+{
+  return (long long)roundl(x);
+}
+#endif
+#endif
diff --git a/libs/libc/math/lib_lround.c b/libs/libc/math/lib_lround.c
new file mode 100644
index 0000000..32a47bb
--- /dev/null
+++ b/libs/libc/math/lib_lround.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_lround.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_DOUBLE
+long int lround(double x)
+{
+  return (long int)round(x);
+}
+#endif
diff --git a/libs/libc/math/lib_lroundf.c b/libs/libc/math/lib_lroundf.c
new file mode 100644
index 0000000..8fa3bd4
--- /dev/null
+++ b/libs/libc/math/lib_lroundf.c
@@ -0,0 +1,37 @@
+/****************************************************************************
+ * lib/math/lib_lroundf.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+long int lroundf(float x)
+{
+  return (long int)roundf(x);
+}
diff --git a/libs/libc/math/lib_lroundl.c b/libs/libc/math/lib_lroundl.c
new file mode 100644
index 0000000..a3b6abb
--- /dev/null
+++ b/libs/libc/math/lib_lroundl.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_lroundl.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long int lroundl(long double x)
+{
+  return (long int)roundl(x);
+}
+#endif
diff --git a/libs/libc/math/lib_nan.c b/libs/libc/math/lib_nan.c
new file mode 100644
index 0000000..23ed134
--- /dev/null
+++ b/libs/libc/math/lib_nan.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_nan.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_DOUBLE
+double nan(const char *tagp)
+{
+  return (double)NAN;
+}
+#endif
diff --git a/libs/libc/math/lib_nanf.c b/libs/libc/math/lib_nanf.c
new file mode 100644
index 0000000..3d32789
--- /dev/null
+++ b/libs/libc/math/lib_nanf.c
@@ -0,0 +1,37 @@
+/****************************************************************************
+ * lib/math/lib_nanf.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+float nanf(const char *tagp)
+{
+  return (float)NAN;
+}
diff --git a/libs/libc/math/lib_nanl.c b/libs/libc/math/lib_nanl.c
new file mode 100644
index 0000000..e57da9b
--- /dev/null
+++ b/libs/libc/math/lib_nanl.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * lib/math/lib_nanl.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+
+#include <math.h>
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+#ifdef CONFIG_HAVE_LONG_DOUBLE
+long double nanl(const char *tagp)
+{
+  return (long double)NAN;
+}
+#endif